update credits
[LibreOffice.git] / include / svx / ruler.hxx
blobaa18893ec3cccf8fe048e14d7e1d30176b8303e8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef _SVX_RULER_HXX
20 #define _SVX_RULER_HXX
22 #include <vcl/menu.hxx>
23 #include <svtools/ruler.hxx>
24 #include <svl/lstner.hxx>
25 #include "svx/svxdllapi.h"
27 class SvxProtectItem;
28 class SvxRulerItem;
29 class SfxBindings;
30 class SvxLongLRSpaceItem;
31 class SvxLongULSpaceItem;
32 class SvxTabStopItem;
33 class SvxLRSpaceItem;
34 class SvxPagePosSizeItem;
35 class SvxColumnItem;
36 class SfxRectangleItem;
37 class SvxObjectItem;
38 class SfxBoolItem;
39 struct SvxRuler_Impl;
41 class SVX_DLLPUBLIC SvxRuler: public Ruler, public SfxListener
43 friend class SvxRulerItem;
44 using Window::Notify;
46 SvxRulerItem **pCtrlItem;
47 SvxLongLRSpaceItem *pLRSpaceItem; // left and right edge
48 SfxRectangleItem *pMinMaxItem; // maxima for dragging
49 SvxLongULSpaceItem *pULSpaceItem; // upper and lower edge
50 SvxTabStopItem *pTabStopItem; // tab stops
51 SvxLRSpaceItem *pParaItem; // paragraphs
52 SvxLRSpaceItem *pParaBorderItem; // border distance
53 SvxPagePosSizeItem *pPagePosItem; // page distance to the rule
54 SvxColumnItem *pColumnItem; // columns
55 SvxObjectItem *pObjectItem; // object
56 Window *pEditWin;
57 SvxRuler_Impl *pRuler_Imp;
58 sal_Bool bAppSetNullOffset :1;
59 sal_Bool bHorz :1;
60 long lLogicNullOffset; // in logic coordinates
61 long lAppNullOffset; // in logic coordinates
62 long lMinFrame; // minimal frame width in pixels
63 long lInitialDragPos;
64 sal_uInt16 nFlags;
65 enum {
66 NONE = 0x0000,
67 DRAG_OBJECT = 0x0001,
68 // reduce size of the last column, shift
69 DRAG_OBJECT_SIZE_LINEAR = 0x0002,
70 DRAG_OBJECT_SIZE_PROPORTIONAL = 0x0004, // proportional, Ctrl
71 // only current line (table; Shift-Ctrl)
72 DRAG_OBJECT_ACTLINE_ONLY = 0x0008,
73 // currently same key assignment
74 DRAG_OBJECT_LEFT_INDENT_ONLY = DRAG_OBJECT_SIZE_PROPORTIONAL
76 nDragType;
77 sal_uInt16 nDefTabType;
78 sal_uInt16 nTabCount;
79 sal_uInt16 nTabBufSize;
80 long lDefTabDist;
81 long lTabPos;
82 RulerTab *pTabs; // tab positions in pixel
83 RulerIndent *pIndents; // paragraph margins in pixel
84 RulerBorder *pBorders;
85 sal_uInt16 nBorderCount;
86 RulerBorder *pObjectBorders;
87 SfxBindings *pBindings;
88 long nDragOffset;
89 long nMaxLeft;
90 long nMaxRight;
91 sal_Bool bValid;
92 sal_Bool bListening;
93 sal_Bool bActive;
94 void StartListening_Impl();
95 long GetCorrectedDragPos( sal_Bool bLeft = sal_True, sal_Bool bRight = sal_True );
96 void DrawLine_Impl(long &lTabPos, int, sal_Bool Hori=sal_True);
97 sal_uInt16 GetObjectBordersOff(sal_uInt16 nIdx) const;
99 // page borders or surrounding frame
100 void UpdateFrame(const SvxLongLRSpaceItem *);
101 void UpdateFrame(const SvxLongULSpaceItem *);
102 void UpdateFrameMinMax(const SfxRectangleItem *);
103 // paragraph indentations
104 void UpdatePara(const SvxLRSpaceItem *);
105 // Border distance
106 void UpdateParaBorder(const SvxLRSpaceItem *);
107 // Tabs
108 void Update(const SvxTabStopItem *);
109 // page position and width
110 void Update(const SvxPagePosSizeItem *);
111 // columns
112 void Update(const SvxColumnItem *, sal_uInt16 nSID);
113 // object selection
114 void Update(const SvxObjectItem *);
115 // protect
116 void Update( const SvxProtectItem* );
117 // left-to-right text
118 void UpdateTextRTL( const SfxBoolItem* );
119 // paragraph indentations
120 void UpdatePara();
121 void UpdateTabs();
122 void UpdatePage();
123 void UpdateFrame();
124 void UpdateColumns();
125 void UpdateObject();
127 long PixelHAdjust(long lPos, long lPos2) const;
128 long PixelVAdjust(long lPos, long lPos2) const;
129 long PixelAdjust(long lPos, long lPos2) const;
131 long ConvertHPosPixel(long lPos) const;
132 long ConvertVPosPixel(long lPos) const;
133 long ConvertHSizePixel(long lSize) const;
134 long ConvertVSizePixel(long lSize) const;
136 long ConvertPosPixel(long lPos) const;
137 long ConvertSizePixel(long lSize) const;
139 long ConvertHPosLogic(long lPos) const;
140 long ConvertVPosLogic(long lPos) const;
141 long ConvertHSizeLogic(long lSize) const;
142 long ConvertVSizeLogic(long lSize) const;
144 long ConvertPosLogic(long lPos) const;
145 long ConvertSizeLogic(long lSize) const;
147 long GetFirstLineIndent() const;
148 long GetLeftIndent() const;
149 long GetRightIndent() const;
150 long GetLogicRightIndent() const;
152 inline long GetLeftFrameMargin() const;
153 long GetRightFrameMargin() const;
155 void CalcMinMax();
157 void EvalModifier();
158 void DragMargin1();
159 //adjust the left margin either after DragMargin1() or after DragBorders()
160 void AdjustMargin1(long lDiff);
161 void DragMargin2();
162 void DragIndents();
163 void DragTabs();
164 void DragBorders();
165 void DragObjectBorder();
167 void ApplyMargins();
168 void ApplyIndents();
169 void ApplyTabs();
170 void ApplyBorders();
171 void ApplyObject();
173 long GetFrameLeft() const;
174 void SetFrameLeft(long);
176 long GetLeftMin() const;
177 long GetRightMax() const;
179 DECL_LINK( TabMenuSelect, Menu * );
180 DECL_LINK( MenuSelect, Menu * );
181 void PrepareProportional_Impl(RulerType);
183 sal_uInt16 GetNextVisible(sal_uInt16 nColumn);
184 sal_uInt16 GetPrevVisible(sal_uInt16 nColumn);
186 enum UpdateType {
187 MOVE_ALL,
188 MOVE_LEFT,
189 MOVE_RIGHT
191 void UpdateParaContents_Impl(long lDiff, UpdateType = MOVE_ALL);
193 protected:
194 virtual void Command( const CommandEvent& rCEvt );
195 virtual void Click();
196 virtual long StartDrag();
197 virtual void Drag();
198 virtual void EndDrag();
199 virtual void ExtraDown();
200 virtual void MouseMove( const MouseEvent& rMEvt );
202 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
204 virtual void Update();
206 // calculation of boundary values for object borders
207 // values refer to the page
208 virtual sal_Bool CalcLimits(long &nMax1, long &nMax2, sal_Bool bFirst) const;
209 sal_Bool IsActLastColumn(
210 sal_Bool bForceDontConsiderHidden = sal_False, sal_uInt16 nAct=USHRT_MAX) const ;
211 sal_Bool IsActFirstColumn(
212 sal_Bool bForceDontConsiderHidden = sal_False, sal_uInt16 nAct=USHRT_MAX) const;
213 sal_uInt16 GetActLeftColumn(
214 sal_Bool bForceDontConsiderHidden = sal_False, sal_uInt16 nAct=USHRT_MAX ) const;
215 sal_uInt16 GetActRightColumn (
216 sal_Bool bForceDontConsiderHidden = sal_False, sal_uInt16 nAct=USHRT_MAX ) const;
217 long CalcPropMaxRight(sal_uInt16 nCol=USHRT_MAX) const;
218 long GetPageWidth() const;
220 public:
221 #define SVXRULER_SUPPORT_TABS 0x0001
222 #define SVXRULER_SUPPORT_PARAGRAPH_MARGINS 0x0002
223 #define SVXRULER_SUPPORT_BORDERS 0x0004
224 #define SVXRULER_SUPPORT_OBJECT 0x0008
225 #define SVXRULER_SUPPORT_SET_NULLOFFSET 0x0010
226 #define SVXRULER_SUPPORT_NEGATIVE_MARGINS 0x0020
227 #define SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL 0x0040
228 #define SVXRULER_SUPPORT_REDUCED_METRIC 0x0080 //shorten the context menu to select metric
230 SvxRuler(Window* pParent,
231 Window *pEditWin,
232 sal_uInt16 nRulerFlags,
233 SfxBindings &rBindings,
234 WinBits nWinStyle = WB_STDRULER);
235 ~SvxRuler();
237 void SetMinFrameSize(long lSize);
238 long GetMinFrameSize() const ;
240 sal_uInt16 GetRulerFlags() const { return nFlags; }
242 void SetDefTabDist(long);
244 // set/get NullOffset in logic units
245 void SetNullOffsetLogic(long lOff = 0);
246 long GetNullOffsetLogic() const { return lAppNullOffset; }
248 void SetActive(sal_Bool bOn = sal_True);
249 sal_Bool IsActive() const { return bActive; }
251 void ForceUpdate() { Update(); }
253 //#i24363# tab stops relative to indent
254 void SetTabsRelativeToIndent( sal_Bool bRel = sal_True );
257 #endif
259 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */