LibreOffice Module svx (master) 1
ruler.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#ifndef INCLUDED_SVX_RULER_HXX
20#define INCLUDED_SVX_RULER_HXX
21
22#include <svtools/ruler.hxx>
23#include <svl/lstner.hxx>
24#include <svx/svxdllapi.h>
26
27#include <memory>
28
29class Menu;
30class SvxProtectItem;
31class SvxRulerItem;
32class SfxBindings;
35class SvxTabStopItem;
36class SvxLRSpaceItem;
38class SvxColumnItem;
40class SvxObjectItem;
41class SfxBoolItem;
42struct SvxRuler_Impl;
43
45{
46 MARGIN1,
48};
49
51{
52 NONE = 0x00,
53 OBJECT = 0x01,
54 // reduce size of the last column, shift
55 OBJECT_SIZE_LINEAR = 0x02,
56 OBJECT_SIZE_PROPORTIONAL = 0x04, // proportional, Ctrl
57 // only current line (table; Shift-Ctrl)
59 // currently same key assignment
61};
62namespace o3tl
63{
64 template<> struct typed_flags<SvxRulerDragFlags> : is_typed_flags<SvxRulerDragFlags, 0x0f> {};
65}
66
68{
69 TABS = 0x0001,
70 PARAGRAPH_MARGINS = 0x0002,
71 BORDERS = 0x0004,
72 OBJECT = 0x0008,
73 SET_NULLOFFSET = 0x0010,
74 NEGATIVE_MARGINS = 0x0020,
76 REDUCED_METRIC = 0x0080, //shorten the context menu to select metric
77};
78namespace o3tl
79{
80 template<> struct typed_flags<SvxRulerSupportFlags> : is_typed_flags<SvxRulerSupportFlags, 0x00ff> {};
81}
82
84{
85 friend class SvxRulerItem;
86
87 std::vector<std::unique_ptr<SvxRulerItem> > pCtrlItems;
88
89 std::unique_ptr<SvxLongLRSpaceItem> mxLRSpaceItem; // left and right edge
90 std::unique_ptr<SfxRectangleItem> mxMinMaxItem; // maxima for dragging
91 std::unique_ptr<SvxLongULSpaceItem> mxULSpaceItem; // upper and lower edge
92 std::unique_ptr<SvxTabStopItem> mxTabStopItem; // tab stops
93 std::unique_ptr<SvxLRSpaceItem> mxParaItem; // paragraphs
94 std::unique_ptr<SvxLRSpaceItem> mxBorderItem; // border distance
95 std::unique_ptr<SvxPagePosSizeItem> mxPagePosItem; // page distance to the rule
96 std::unique_ptr<SvxColumnItem> mxColumnItem; // columns
97 std::unique_ptr<SvxObjectItem> mxObjectItem; // object
98
100
101 std::unique_ptr<SvxRuler_Impl> mxRulerImpl;
102
104 bool bHorz :1;
105 tools::Long lLogicNullOffset; // in logic coordinates
106 tools::Long lAppNullOffset; // in logic coordinates
110 sal_uInt16 nDefTabType;
111 sal_uInt16 nTabCount;
112 sal_uInt16 nTabBufSize;
115
116 std::vector<RulerTab> mpTabs; // tab positions in pixel
117 std::vector<RulerIndent> mpIndents; // paragraph margins in pixel
118 std::vector<RulerBorder> mpBorders;
119 std::vector<RulerBorder> mpObjectBorders;
120
125 bool bValid;
128
131
132 void StartListening_Impl();
133 tools::Long GetCorrectedDragPos(bool bLeft = true, bool bRight = true );
134 void DrawLine_Impl(tools::Long &lTabPos, int, bool Horizontal);
135 sal_uInt16 GetObjectBordersOff(sal_uInt16 nIdx) const;
136
137 // page borders or surrounding frame
138 void UpdateFrame(const SvxLongLRSpaceItem* pItem);
139 void UpdateFrame(const SvxLongULSpaceItem* pItem);
140 void UpdateFrameMinMax(const SfxRectangleItem* pItem);
141 // paragraph indentations
142 void UpdatePara(const SvxLRSpaceItem* pItem);
143 // Border distance
144 void UpdateBorder(const SvxLRSpaceItem* pItem);
145 // Tabs
146 void Update(const SvxTabStopItem* pItem);
147 // page position and width
148 void Update(const SvxPagePosSizeItem* pItem);
149 // columns
150 void Update(const SvxColumnItem* pItem, sal_uInt16 nSID);
151 // object selection
152 void Update(const SvxObjectItem* pItem);
153 // protect
154 void Update(const SvxProtectItem* pItem );
155 // left-to-right text
156 void UpdateTextRTL(const SfxBoolItem* pItem);
157 // paragraph indentations
158 void UpdatePara();
159 void UpdateTabs();
160 void UpdatePage();
161 void UpdateFrame();
162 void UpdateColumns();
163 void UpdateObject();
164
165 // Convert position to stick to ruler ticks
166 tools::Long MakePositionSticky(tools::Long rValue, tools::Long aPointOfReference, bool aSnapToFrameMargin = true) const;
167
168 tools::Long PixelHAdjust(tools::Long lPos, tools::Long lPos2) const;
169 tools::Long PixelVAdjust(tools::Long lPos, tools::Long lPos2) const;
170 tools::Long PixelAdjust(tools::Long lPos, tools::Long lPos2) const;
171
172 tools::Long ConvertHPosPixel(tools::Long lPos) const;
173 tools::Long ConvertVPosPixel(tools::Long lPos) const;
174 tools::Long ConvertHSizePixel(tools::Long lSize) const;
175 tools::Long ConvertVSizePixel(tools::Long lSize) const;
176
177 tools::Long ConvertPosPixel(tools::Long lPos) const;
178 tools::Long ConvertSizePixel(tools::Long lSize) const;
179
180 tools::Long ConvertHPosLogic(tools::Long lPos) const;
181 tools::Long ConvertVPosLogic(tools::Long lPos) const;
182 tools::Long ConvertHSizeLogic(tools::Long lSize) const;
183 tools::Long ConvertVSizeLogic(tools::Long lSize) const;
184
185 tools::Long ConvertPosLogic(tools::Long lPos) const;
186 tools::Long ConvertSizeLogic(tools::Long lSize) const;
187
188 tools::Long RoundToCurrentMapMode(tools::Long lValue) const;
189
190 tools::Long GetFirstLineIndent() const;
191 tools::Long GetLeftIndent() const;
192 tools::Long GetRightIndent() const;
193 tools::Long GetLogicRightIndent() const;
194
195 tools::Long GetLeftFrameMargin() const;
196 tools::Long GetRightFrameMargin() const;
197
198 void CalcMinMax();
199
200 void EvalModifier();
201 void DragMargin1();
202 //adjust the left margin either after DragMargin1() or after DragBorders()
203 void AdjustMargin1(tools::Long lDiff);
204 void DragMargin2();
205 void DragIndents();
206 void DragTabs();
207 void DragBorders();
208 void DragObjectBorder();
209
210 void ApplyMargins();
211 void ApplyIndents();
212 void ApplyTabs();
213 void ApplyBorders();
214 void ApplyObject();
215
216 tools::Long GetFrameLeft() const;
217
218 tools::Long GetLeftMin() const;
219 tools::Long GetRightMax() const;
220
221 void TabMenuSelect(std::u16string_view rIdent);
222 void MenuSelect(std::u16string_view ident);
223 void PrepareProportional_Impl(RulerType);
224
225 enum class UpdateType
226 {
227 MoveLeft,
229 };
230 void UpdateParaContents_Impl(tools::Long lDiff, UpdateType);
231
232protected:
233 virtual void Command( const CommandEvent& rCEvt ) override;
234 virtual void Click() override;
235 virtual bool StartDrag() override;
236 virtual void Drag() override;
237 virtual void EndDrag() override;
238 virtual void ExtraDown() override;
239 virtual void MouseMove( const MouseEvent& rMEvt ) override;
240
241 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
242
243 virtual void Update();
244
245 bool IsActLastColumn(
246 bool bForceDontConsiderHidden = false,
247 sal_uInt16 nAct=USHRT_MAX) const;
248 bool IsActFirstColumn(
249 bool bForceDontConsiderHidden = false,
250 sal_uInt16 nAct=USHRT_MAX) const;
251 sal_uInt16 GetActLeftColumn(
252 bool bForceDontConsiderHidden = false,
253 sal_uInt16 nAct=USHRT_MAX ) const;
254 sal_uInt16 GetActRightColumn (
255 bool bForceDontConsiderHidden = false,
256 sal_uInt16 nAct=USHRT_MAX ) const;
257 tools::Long CalcPropMaxRight(sal_uInt16 nCol = USHRT_MAX) const;
258
259public:
260
261 SvxRuler(vcl::Window* pParent, vcl::Window *pEditWin, SvxRulerSupportFlags nRulerFlags,
262 SfxBindings &rBindings, WinBits nWinStyle);
263 virtual ~SvxRuler() override;
264 virtual void dispose() override;
265
266 void SetDefTabDist(tools::Long);
267
268 // set/get NullOffset in logic units
269 void SetNullOffsetLogic(tools::Long lOff);
270
271 void SetActive(bool bOn = true);
272
274 {
275 Update();
276 }
277
278 //#i24363# tab stops relative to indent
279 void SetTabsRelativeToIndent( bool bRel );
280 void SetValues(RulerChangeType type, tools::Long value);
281 tools::Long GetPageWidth() const;
282};
283
284#endif
285
286/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void MouseMove(const MouseEvent &rMEvt) override
virtual bool StartDrag()
virtual void EndDrag()
virtual void dispose() override
virtual void Drag()
virtual void ExtraDown()
virtual void Click()
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint)
std::unique_ptr< SvxLRSpaceItem > mxBorderItem
Definition: ruler.hxx:94
std::vector< RulerBorder > mpObjectBorders
Definition: ruler.hxx:119
bool bValid
Definition: ruler.hxx:125
tools::Long nMaxRight
Definition: ruler.hxx:124
tools::Long lLogicNullOffset
Definition: ruler.hxx:105
UpdateType
Definition: ruler.hxx:226
tools::Long lInitialDragPos
Definition: ruler.hxx:107
bool bHorz
Definition: ruler.hxx:104
bool mbSnapping
Definition: ruler.hxx:130
sal_uInt16 nDefTabType
Definition: ruler.hxx:110
bool mbCoarseSnapping
Definition: ruler.hxx:129
sal_uInt16 nTabBufSize
Definition: ruler.hxx:112
bool bListening
Definition: ruler.hxx:126
tools::Long lTabPos
Definition: ruler.hxx:114
bool bActive
Definition: ruler.hxx:127
std::vector< RulerIndent > mpIndents
Definition: ruler.hxx:117
bool bAppSetNullOffset
Definition: ruler.hxx:103
tools::Long nMaxLeft
Definition: ruler.hxx:123
std::unique_ptr< SvxRuler_Impl > mxRulerImpl
Definition: ruler.hxx:101
sal_uInt16 nTabCount
Definition: ruler.hxx:111
std::unique_ptr< SvxColumnItem > mxColumnItem
Definition: ruler.hxx:96
std::unique_ptr< SvxObjectItem > mxObjectItem
Definition: ruler.hxx:97
std::unique_ptr< SvxLongLRSpaceItem > mxLRSpaceItem
Definition: ruler.hxx:89
SvxRulerDragFlags nDragType
Definition: ruler.hxx:109
std::unique_ptr< SfxRectangleItem > mxMinMaxItem
Definition: ruler.hxx:90
std::vector< RulerBorder > mpBorders
Definition: ruler.hxx:118
VclPtr< vcl::Window > pEditWin
Definition: ruler.hxx:99
std::unique_ptr< SvxPagePosSizeItem > mxPagePosItem
Definition: ruler.hxx:95
SfxBindings * pBindings
Definition: ruler.hxx:121
std::vector< RulerTab > mpTabs
Definition: ruler.hxx:116
std::unique_ptr< SvxTabStopItem > mxTabStopItem
Definition: ruler.hxx:92
std::unique_ptr< SvxLRSpaceItem > mxParaItem
Definition: ruler.hxx:93
void ForceUpdate()
Definition: ruler.hxx:273
std::vector< std::unique_ptr< SvxRulerItem > > pCtrlItems
Definition: ruler.hxx:87
std::unique_ptr< SvxLongULSpaceItem > mxULSpaceItem
Definition: ruler.hxx:91
tools::Long lAppNullOffset
Definition: ruler.hxx:106
tools::Long nDragOffset
Definition: ruler.hxx:122
SvxRulerSupportFlags nFlags
Definition: ruler.hxx:108
tools::Long lDefTabDist
Definition: ruler.hxx:113
MoveRight
MoveLeft
NONE
long Long
RulerChangeType
Definition: ruler.hxx:45
SvxRulerSupportFlags
Definition: ruler.hxx:68
SvxRulerDragFlags
Definition: ruler.hxx:51
RulerType
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
TABS
sal_Int64 WinBits