Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _SVX_RULER_HXX
29 : : #define _SVX_RULER_HXX
30 : :
31 : : #include <vcl/menu.hxx>
32 : : #include <svtools/ruler.hxx>
33 : : #include <svl/lstner.hxx>
34 : : #include "svx/svxdllapi.h"
35 : :
36 : : class SvxProtectItem;
37 : : class SvxRulerItem;
38 : : class SfxBindings;
39 : : class SvxLongLRSpaceItem;
40 : : class SvxLongULSpaceItem;
41 : : class SvxTabStopItem;
42 : : class SvxLRSpaceItem;
43 : : class SvxPagePosSizeItem;
44 : : class SvxColumnItem;
45 : : class SfxRectangleItem;
46 : : class SvxObjectItem;
47 : : class SfxBoolItem;
48 : : struct SvxRuler_Impl;
49 : :
50 : : class SVX_DLLPUBLIC SvxRuler: public Ruler, public SfxListener
51 : : {
52 : : friend class SvxRulerItem;
53 : : using Window::Notify;
54 : :
55 : : SvxRulerItem **pCtrlItem;
56 : : SvxLongLRSpaceItem *pLRSpaceItem; // left and right edge
57 : : SfxRectangleItem *pMinMaxItem; // maxima for dragging
58 : : SvxLongULSpaceItem *pULSpaceItem; // upper and lower edge
59 : : SvxTabStopItem *pTabStopItem; // tab stops
60 : : SvxLRSpaceItem *pParaItem; // paragraphs
61 : : SvxLRSpaceItem *pParaBorderItem; // border distance
62 : : SvxPagePosSizeItem *pPagePosItem; // page distance to the rule
63 : : SvxColumnItem *pColumnItem; // columns
64 : : SvxObjectItem *pObjectItem; // object
65 : : Window *pEditWin;
66 : : SvxRuler_Impl *pRuler_Imp;
67 : : sal_Bool bAppSetNullOffset :1;
68 : : sal_Bool bHorz :1;
69 : : long lLogicNullOffset; // in logic coordinates
70 : : long lAppNullOffset; // in logic coordinates
71 : : long lMinFrame; // minimal frame width in pixels
72 : : long lInitialDragPos;
73 : : sal_uInt16 nFlags;
74 : : enum {
75 : : NONE = 0x0000,
76 : : DRAG_OBJECT = 0x0001,
77 : : // reduce size of the last column, shift
78 : : DRAG_OBJECT_SIZE_LINEAR = 0x0002,
79 : : DRAG_OBJECT_SIZE_PROPORTIONAL = 0x0004, // proportional, Ctrl
80 : : // only current line (table; Shift-Ctrl)
81 : : DRAG_OBJECT_ACTLINE_ONLY = 0x0008,
82 : : // currently same key assignment
83 : : DRAG_OBJECT_LEFT_INDENT_ONLY = DRAG_OBJECT_SIZE_PROPORTIONAL
84 : : }
85 : : nDragType;
86 : : sal_uInt16 nDefTabType;
87 : : sal_uInt16 nTabCount;
88 : : sal_uInt16 nTabBufSize;
89 : : long lDefTabDist;
90 : : long lTabPos;
91 : : RulerTab *pTabs; // tab positions in pixel
92 : : RulerIndent *pIndents; // paragraph margins in pixel
93 : : RulerBorder *pBorders;
94 : : sal_uInt16 nBorderCount;
95 : : RulerBorder *pObjectBorders;
96 : : SfxBindings *pBindings;
97 : : long nDragOffset;
98 : : long nMaxLeft;
99 : : long nMaxRight;
100 : : sal_Bool bValid;
101 : : sal_Bool bListening;
102 : : sal_Bool bActive;
103 : : void StartListening_Impl();
104 : : long GetCorrectedDragPos( sal_Bool bLeft = sal_True, sal_Bool bRight = sal_True );
105 : : void DrawLine_Impl(long &lTabPos, int, sal_Bool Hori=sal_True);
106 : : sal_uInt16 GetObjectBordersOff(sal_uInt16 nIdx) const;
107 : :
108 : : // page borders or surrounding frame
109 : : void UpdateFrame(const SvxLongLRSpaceItem *);
110 : : void UpdateFrame(const SvxLongULSpaceItem *);
111 : : void UpdateFrameMinMax(const SfxRectangleItem *);
112 : : // paragraph indentations
113 : : void UpdatePara(const SvxLRSpaceItem *);
114 : : // Border distance
115 : : void UpdateParaBorder(const SvxLRSpaceItem *);
116 : : // Tabs
117 : : void Update(const SvxTabStopItem *);
118 : : // page position and width
119 : : void Update(const SvxPagePosSizeItem *);
120 : : // columns
121 : : void Update(const SvxColumnItem *, sal_uInt16 nSID);
122 : : // object selection
123 : : void Update(const SvxObjectItem *);
124 : : // protect
125 : : void Update( const SvxProtectItem* );
126 : : // left-to-right text
127 : : void UpdateTextRTL( const SfxBoolItem* );
128 : : // paragraph indentations
129 : : void UpdatePara();
130 : : void UpdateTabs();
131 : : void UpdatePage();
132 : : void UpdateFrame();
133 : : void UpdateColumns();
134 : : void UpdateObject();
135 : :
136 : : long PixelHAdjust(long lPos, long lPos2) const;
137 : : long PixelVAdjust(long lPos, long lPos2) const;
138 : : long PixelAdjust(long lPos, long lPos2) const;
139 : :
140 : : long ConvertHPosPixel(long lPos) const;
141 : : long ConvertVPosPixel(long lPos) const;
142 : : long ConvertHSizePixel(long lSize) const;
143 : : long ConvertVSizePixel(long lSize) const;
144 : :
145 : : long ConvertPosPixel(long lPos) const;
146 : : long ConvertSizePixel(long lSize) const;
147 : :
148 : : long ConvertHPosLogic(long lPos) const;
149 : : long ConvertVPosLogic(long lPos) const;
150 : : long ConvertHSizeLogic(long lSize) const;
151 : : long ConvertVSizeLogic(long lSize) const;
152 : :
153 : : long ConvertPosLogic(long lPos) const;
154 : : long ConvertSizeLogic(long lSize) const;
155 : :
156 : : long GetFirstLineIndent() const;
157 : : long GetLeftIndent() const;
158 : : long GetRightIndent() const;
159 : : long GetLogicRightIndent() const;
160 : : long GetPageWidth() const;
161 : :
162 : : inline long GetLeftFrameMargin() const;
163 : : long GetRightFrameMargin() const;
164 : :
165 : : void CalcMinMax();
166 : :
167 : : void EvalModifier();
168 : : void DragMargin1();
169 : : //adjust the left margin either after DragMargin1() or after DragBorders()
170 : : void AdjustMargin1(long lDiff);
171 : : void DragMargin2();
172 : : void DragIndents();
173 : : void DragTabs();
174 : : void DragBorders();
175 : : void DragObjectBorder();
176 : :
177 : : void ApplyMargins();
178 : : void ApplyIndents();
179 : : void ApplyTabs();
180 : : void ApplyBorders();
181 : : void ApplyObject();
182 : :
183 : : long GetFrameLeft() const;
184 : : void SetFrameLeft(long);
185 : :
186 : : long GetLeftMin() const;
187 : : long GetRightMax() const;
188 : :
189 : : DECL_LINK( TabMenuSelect, Menu * );
190 : : DECL_LINK( MenuSelect, Menu * );
191 : : void PrepareProportional_Impl(RulerType);
192 : :
193 : : sal_uInt16 GetNextVisible(sal_uInt16 nColumn);
194 : : sal_uInt16 GetPrevVisible(sal_uInt16 nColumn);
195 : :
196 : : void Update();
197 : :
198 : : enum UpdateType {
199 : : MOVE_ALL,
200 : : MOVE_LEFT,
201 : : MOVE_RIGHT
202 : : };
203 : : void UpdateParaContents_Impl(long lDiff, UpdateType = MOVE_ALL);
204 : : protected:
205 : : virtual void Command( const CommandEvent& rCEvt );
206 : : virtual void Click();
207 : : virtual long StartDrag();
208 : : virtual void Drag();
209 : : virtual void EndDrag();
210 : : virtual void ExtraDown();
211 : : virtual void MouseMove( const MouseEvent& rMEvt );
212 : :
213 : : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
214 : :
215 : : // calculation of boundary values for object borders
216 : : // values refer to the page
217 : : virtual sal_Bool CalcLimits(long &nMax1, long &nMax2, sal_Bool bFirst) const;
218 : : sal_Bool IsActLastColumn(
219 : : sal_Bool bForceDontConsiderHidden = sal_False, sal_uInt16 nAct=USHRT_MAX) const ;
220 : : sal_Bool IsActFirstColumn(
221 : : sal_Bool bForceDontConsiderHidden = sal_False, sal_uInt16 nAct=USHRT_MAX) const;
222 : : sal_uInt16 GetActLeftColumn(
223 : : sal_Bool bForceDontConsiderHidden = sal_False, sal_uInt16 nAct=USHRT_MAX ) const;
224 : : sal_uInt16 GetActRightColumn (
225 : : sal_Bool bForceDontConsiderHidden = sal_False, sal_uInt16 nAct=USHRT_MAX ) const;
226 : : long CalcPropMaxRight(sal_uInt16 nCol=USHRT_MAX) const;
227 : :
228 : : public:
229 : : #define SVXRULER_SUPPORT_TABS 0x0001
230 : : #define SVXRULER_SUPPORT_PARAGRAPH_MARGINS 0x0002
231 : : #define SVXRULER_SUPPORT_BORDERS 0x0004
232 : : #define SVXRULER_SUPPORT_OBJECT 0x0008
233 : : #define SVXRULER_SUPPORT_SET_NULLOFFSET 0x0010
234 : : #define SVXRULER_SUPPORT_NEGATIVE_MARGINS 0x0020
235 : : #define SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL 0x0040
236 : : #define SVXRULER_SUPPORT_REDUCED_METRIC 0x0080 //shorten the context menu to select metric
237 : :
238 : : SvxRuler(Window* pParent,
239 : : Window *pEditWin,
240 : : sal_uInt16 nRulerFlags,
241 : : SfxBindings &rBindings,
242 : : WinBits nWinStyle = WB_STDRULER);
243 : : ~SvxRuler();
244 : :
245 : : void SetMinFrameSize(long lSize);
246 : : long GetMinFrameSize() const ;
247 : :
248 : : sal_uInt16 GetRulerFlags() const { return nFlags; }
249 : :
250 : : void SetDefTabDist(long);
251 : :
252 : : // set/get NullOffset in logic units
253 : : void SetNullOffsetLogic(long lOff = 0);
254 : : long GetNullOffsetLogic() const { return lAppNullOffset; }
255 : :
256 : : void SetActive(sal_Bool bOn = sal_True);
257 : : sal_Bool IsActive() const { return bActive; }
258 : :
259 : 11998 : 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 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|