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