xref: /trunk/main/svx/inc/svx/ruler.hxx (revision 3334a7e6)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SVX_RULER_HXX
24 #define _SVX_RULER_HXX
25 
26 #include <vcl/menu.hxx>
27 #include <svtools/ruler.hxx>
28 #include <svl/lstner.hxx>
29 #include "svx/svxdllapi.h"
30 
31 class SvxProtectItem;
32 class SvxRulerItem;
33 class SfxBindings;
34 class SvxLongLRSpaceItem;
35 class SvxLongULSpaceItem;
36 class SvxTabStopItem;
37 class SvxLRSpaceItem;
38 class SvxPagePosSizeItem;
39 class SvxColumnItem;
40 class SfxRectangleItem;
41 class SvxObjectItem;
42 class SfxBoolItem;
43 struct SvxRuler_Impl;
44 
45 class SVX_DLLPUBLIC SvxRuler: public Ruler, public SfxListener
46 {
47 	friend class SvxRulerItem;
48 	using Window::Notify;
49 
50 	SvxRulerItem **pCtrlItem;
51 	SvxLongLRSpaceItem *pLRSpaceItem;  //Linker und Rechter Rand
52 	SfxRectangleItem *pMinMaxItem; //Maxima fuers Draggen
53 	SvxLongULSpaceItem *pULSpaceItem;  //Oberer und Unterer Rand
54 	SvxTabStopItem *pTabStopItem;  //Tabstops
55 	SvxLRSpaceItem *pParaItem;     //Absaetze
56     SvxLRSpaceItem *pParaBorderItem; //Border distance
57 	SvxPagePosSizeItem *pPagePosItem; //Seitenabstaende zum Lineal
58 	SvxColumnItem *pColumnItem;    //Spalten
59 	SvxObjectItem *pObjectItem;    //Objekt
60 	Window *pEditWin;
61 	SvxRuler_Impl *pRuler_Imp;
62 	sal_Bool bAppSetNullOffset :1;
63 	sal_Bool bHorz :1;
64     long lLogicNullOffset;      // in logischen Koordinaten
65 	long lAppNullOffset;        // in logischen Koordinaten
66 	long lMinFrame;             // minimale Framebreite in Pixel
67 	long lInitialDragPos;
68 	sal_uInt16 nFlags;
69 	enum {
70 		NONE = 0x0000,
71 		DRAG_OBJECT =  0x0001,
72 		// letzte Spalte verkleinern, Shift
73 		DRAG_OBJECT_SIZE_LINEAR = 0x0002,
74 		DRAG_OBJECT_SIZE_PROPORTIONAL = 0x0004, // proportional, Ctrl
75 		// nur aktuelle Zeile (Tabelle; Shift-Ctrl)
76 		DRAG_OBJECT_ACTLINE_ONLY = 0x0008,
77 		// aktuell gleiche Tastenbelegung
78 		DRAG_OBJECT_LEFT_INDENT_ONLY = DRAG_OBJECT_SIZE_PROPORTIONAL
79 		}
80 	nDragType;
81 	sal_uInt16 nDefTabType;
82 	sal_uInt16 nTabCount;
83 	sal_uInt16 nTabBufSize;
84 	long lDefTabDist;
85 	long lTabPos;
86 	RulerTab *pTabs;            // Tabpositionen in Pixel
87 	RulerIndent *pIndents;      // Absatzraender in Pixel
88 	RulerBorder *pBorders;
89 	sal_uInt16 nBorderCount;
90 	RulerBorder *pObjectBorders;
91 	SfxBindings *pBindings;
92 	long nDragOffset;
93 	long nMaxLeft;
94 	long nMaxRight;
95 	sal_Bool bValid;
96 	sal_Bool bListening;
97 	sal_Bool bActive;
98 //#if 0 // _SOLAR__PRIVATE
99     void StartListening_Impl();
100 	long GetCorrectedDragPos( sal_Bool bLeft = sal_True, sal_Bool bRight = sal_True );
101 	void DrawLine_Impl(long &lTabPos, int, sal_Bool Hori=sal_True);
102 	sal_uInt16 GetObjectBordersOff(sal_uInt16 nIdx) const;
103 
104 	// Seitenr"ander oder umgebender Rahmen
105 	void UpdateFrame(const SvxLongLRSpaceItem *);
106 	void UpdateFrame(const SvxLongULSpaceItem *);
107 	void UpdateFrameMinMax(const SfxRectangleItem *);
108 	// Absatzeinzuege
109 	void UpdatePara(const SvxLRSpaceItem *);
110     // Border distance
111     void UpdateParaBorder(const SvxLRSpaceItem *);
112     // Tabs
113 	void Update(const SvxTabStopItem *);
114 	// Seitenposition und -breite
115 	void Update(const SvxPagePosSizeItem *);
116 	// Spalten
117     void Update(const SvxColumnItem *, sal_uInt16 nSID);
118 	// Object Selektion
119 	void Update(const SvxObjectItem *);
120 	// Protect
121 	void Update( const SvxProtectItem* );
122     // left-to-right text
123     void UpdateTextRTL( const SfxBoolItem* );
124 	// Absatzeinzuege
125 	void UpdatePara();
126 	void UpdateTabs();
127 	void UpdatePage();
128 	void UpdateFrame();
129 	void UpdateColumns();
130 	void UpdateObject();
131 
132 	long PixelHAdjust(long lPos, long lPos2) const;
133 	long PixelVAdjust(long lPos, long lPos2) const;
134 	long PixelAdjust(long lPos, long lPos2) const;
135 
136 	long ConvertHPosPixel(long lPos) const;
137 	long ConvertVPosPixel(long lPos) const;
138 	long ConvertHSizePixel(long lSize) const;
139 	long ConvertVSizePixel(long lSize) const;
140 
141 	long ConvertPosPixel(long lPos) const;
142 	long ConvertSizePixel(long lSize) const;
143 
144 	long ConvertHPosLogic(long lPos) const;
145 	long ConvertVPosLogic(long lPos) const;
146 	long ConvertHSizeLogic(long lSize) const;
147 	long ConvertVSizeLogic(long lSize) const;
148 
149 	long ConvertPosLogic(long lPos) const;
150 	long ConvertSizeLogic(long lSize) const;
151 
152 	long GetFirstLineIndent() const;
153 //  long GetLogicFirstLineIndent() const;
154 	long GetLeftIndent() const;
155 //  long GetLogicLeftIndent() const;
156 	long GetRightIndent() const;
157 	long GetLogicRightIndent() const;
158 	long GetPageWidth() const;
159 
160 	inline long GetLeftFrameMargin() const;
161 	long GetRightFrameMargin() const;
162 
163 	void CalcMinMax();
164 
165 	void EvalModifier();
166 	void DragMargin1();
167     //adjust the left margin either after DragMargin1() or after DragBorders()
168     void AdjustMargin1(long lDiff);
169     void DragMargin2();
170 	void DragIndents();
171 	void DragTabs();
172 	void DragBorders();
173 	void DragObjectBorder();
174 
175 	void ApplyMargins();
176 	void ApplyIndents();
177 	void ApplyTabs();
178 	void ApplyBorders();
179 	void ApplyObject();
180 
181 	long GetFrameLeft() const;
182 	void SetFrameLeft(long);
183 
184 	long GetLeftMin() const;
185 	long GetRightMax() const;
186 
187 	DECL_LINK( TabMenuSelect, Menu * );
188 	DECL_LINK( MenuSelect, Menu * );
189 	void PrepareProportional_Impl(RulerType);
190 
191 	sal_uInt16 GetNextVisible(sal_uInt16 nColumn);
192 	sal_uInt16 GetPrevVisible(sal_uInt16 nColumn);
193 //#endif
194 
195 	void Update();
196 
197 enum UpdateType {
198 	MOVE_ALL,
199 	MOVE_LEFT,
200 	MOVE_RIGHT
201 	};
202 	void UpdateParaContents_Impl(long lDiff, UpdateType = MOVE_ALL);
203 protected:
204 	virtual void    Command( const CommandEvent& rCEvt );
205 	virtual void    Click();
206 	virtual long    StartDrag();
207 	virtual void    Drag();
208 	virtual void    EndDrag();
209 	virtual void    ExtraDown();
210 	virtual void	MouseMove( const MouseEvent& rMEvt );
211 
212 	virtual void    Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
213 
214 	// Berechnung der Grenzwerte fuer Objectgrenzen
215 	// Werte sind bezogen auf die Seite
216 	virtual sal_Bool    CalcLimits(long &nMax1, long &nMax2, sal_Bool bFirst) const;
217 	sal_Bool IsActLastColumn(
218 		sal_Bool bForceDontConsiderHidden = sal_False, sal_uInt16 nAct=USHRT_MAX) const ;
219 	sal_Bool IsActFirstColumn(
220 		sal_Bool bForceDontConsiderHidden = sal_False, sal_uInt16 nAct=USHRT_MAX) const;
221 	sal_uInt16 GetActLeftColumn(
222 		sal_Bool bForceDontConsiderHidden = sal_False, sal_uInt16 nAct=USHRT_MAX ) const;
223 	sal_uInt16 GetActRightColumn (
224 		sal_Bool bForceDontConsiderHidden = sal_False, sal_uInt16 nAct=USHRT_MAX ) const;
225 	long CalcPropMaxRight(sal_uInt16 nCol=USHRT_MAX) const;
226 
227 public:
228 #define     SVXRULER_SUPPORT_TABS                       0x0001
229 #define     SVXRULER_SUPPORT_PARAGRAPH_MARGINS          0x0002
230 #define     SVXRULER_SUPPORT_BORDERS                    0x0004
231 #define     SVXRULER_SUPPORT_OBJECT                     0x0008
232 #define     SVXRULER_SUPPORT_SET_NULLOFFSET             0x0010
233 #define     SVXRULER_SUPPORT_NEGATIVE_MARGINS           0x0020
234 #define     SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL 0x0040
235 #define     SVXRULER_SUPPORT_REDUCED_METRIC             0x0080 //shorten the context menu to select metric
236 
237 	SvxRuler(Window* pParent,
238 			 Window *pEditWin,
239 			 sal_uInt16 nRulerFlags,
240 			 SfxBindings &rBindings,
241 			 WinBits nWinStyle = WB_STDRULER);
242 	~SvxRuler();
243 
244 	void SetMinFrameSize(long lSize);
245 	long GetMinFrameSize() const ;
246 
GetRulerFlags() const247 	sal_uInt16 GetRulerFlags() const { return nFlags; }
248 
249 	void SetDefTabDist(long);
250 	long GetDefTabDist() const;
251 
252 	// Setzen / Erfragen NullOffset in logischen Einheiten
253 	void SetNullOffsetLogic(long lOff = 0);
GetNullOffsetLogic() const254 	long GetNullOffsetLogic() const { return lAppNullOffset; }
255 
256 	void SetActive(sal_Bool bOn = sal_True);
IsActive() const257 	sal_Bool IsActive() const { return bActive; }
258 
ForceUpdate()259 	void ForceUpdate() { Update(); }
260 
261     //#i24363# tab stops relative to indent
262     void SetTabsRelativeToIndent( sal_Bool bRel = sal_True );
263 };
264 
265 #endif
266 
267