1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_SVX_RULER_HXX
20 #define INCLUDED_SVX_RULER_HXX
22 #include <vcl/menu.hxx>
23 #include <svtools/ruler.hxx>
24 #include <svl/lstner.hxx>
25 #include <svx/svxdllapi.h>
27 #include <boost/scoped_ptr.hpp>
28 #include <boost/scoped_array.hpp>
33 class SvxLongLRSpaceItem
;
34 class SvxLongULSpaceItem
;
37 class SvxPagePosSizeItem
;
39 class SfxRectangleItem
;
44 class SVX_DLLPUBLIC SvxRuler
: public Ruler
, public SfxListener
46 friend class SvxRulerItem
;
49 SvxRulerItem
** pCtrlItem
;
50 boost::scoped_ptr
<SvxLongLRSpaceItem
> mpLRSpaceItem
; // left and right edge
51 boost::scoped_ptr
<SfxRectangleItem
> mpMinMaxItem
; // maxima for dragging
52 boost::scoped_ptr
<SvxLongULSpaceItem
> mpULSpaceItem
; // upper and lower edge
53 boost::scoped_ptr
<SvxTabStopItem
> mpTabStopItem
; // tab stops
54 boost::scoped_ptr
<SvxLRSpaceItem
> mpParaItem
; // paragraphs
55 boost::scoped_ptr
<SvxLRSpaceItem
> mpParaBorderItem
; // border distance
56 boost::scoped_ptr
<SvxPagePosSizeItem
> mpPagePosItem
; // page distance to the rule
57 boost::scoped_ptr
<SvxColumnItem
> mpColumnItem
; // columns
58 boost::scoped_ptr
<SvxObjectItem
> mpObjectItem
; // object
62 boost::scoped_ptr
<SvxRuler_Impl
> mpRulerImpl
;
64 sal_Bool bAppSetNullOffset
:1;
66 long lLogicNullOffset
; // in logic coordinates
67 long lAppNullOffset
; // in logic coordinates
68 long lMinFrame
; // minimal frame width in pixels
76 // reduce size of the last column, shift
77 DRAG_OBJECT_SIZE_LINEAR
= 0x0002,
78 DRAG_OBJECT_SIZE_PROPORTIONAL
= 0x0004, // proportional, Ctrl
79 // only current line (table; Shift-Ctrl)
80 DRAG_OBJECT_ACTLINE_ONLY
= 0x0008,
81 // currently same key assignment
82 DRAG_OBJECT_LEFT_INDENT_ONLY
= DRAG_OBJECT_SIZE_PROPORTIONAL
85 sal_uInt16 nDefTabType
;
87 sal_uInt16 nTabBufSize
;
91 std::vector
<RulerTab
> mpTabs
; // tab positions in pixel
92 std::vector
<RulerIndent
> mpIndents
; // paragraph margins in pixel
93 std::vector
<RulerBorder
> mpBorders
;
94 std::vector
<RulerBorder
> mpObjectBorders
;
96 SfxBindings
* pBindings
;
104 bool mbCoarseSnapping
;
107 void StartListening_Impl();
108 long GetCorrectedDragPos(sal_Bool bLeft
= sal_True
, sal_Bool bRight
= sal_True
);
109 void DrawLine_Impl(long &lTabPos
, int, sal_Bool Horizontal
=sal_True
);
110 sal_uInt16
GetObjectBordersOff(sal_uInt16 nIdx
) const;
112 // page borders or surrounding frame
113 void UpdateFrame(const SvxLongLRSpaceItem
* pItem
);
114 void UpdateFrame(const SvxLongULSpaceItem
* pItem
);
115 void UpdateFrameMinMax(const SfxRectangleItem
* pItem
);
116 // paragraph indentations
117 void UpdatePara(const SvxLRSpaceItem
* pItem
);
119 void UpdateParaBorder(const SvxLRSpaceItem
* pItem
);
121 void Update(const SvxTabStopItem
* pItem
);
122 // page position and width
123 void Update(const SvxPagePosSizeItem
* pItem
);
125 void Update(const SvxColumnItem
* pItem
, sal_uInt16 nSID
);
127 void Update(const SvxObjectItem
* pItem
);
129 void Update(const SvxProtectItem
* pItem
);
130 // left-to-right text
131 void UpdateTextRTL(const SfxBoolItem
* pItem
);
132 // paragraph indentations
137 void UpdateColumns();
140 // Convert position to stick to ruler ticks
141 long MakePositionSticky(long rValue
, long aPointOfReference
, bool aSnapToFrameMargin
= true) const;
143 long PixelHAdjust(long lPos
, long lPos2
) const;
144 long PixelVAdjust(long lPos
, long lPos2
) const;
145 long PixelAdjust(long lPos
, long lPos2
) const;
147 long ConvertHPosPixel(long lPos
) const;
148 long ConvertVPosPixel(long lPos
) const;
149 long ConvertHSizePixel(long lSize
) const;
150 long ConvertVSizePixel(long lSize
) const;
152 long ConvertPosPixel(long lPos
) const;
153 long ConvertSizePixel(long lSize
) const;
155 long ConvertHPosLogic(long lPos
) const;
156 long ConvertVPosLogic(long lPos
) const;
157 long ConvertHSizeLogic(long lSize
) const;
158 long ConvertVSizeLogic(long lSize
) const;
160 long ConvertPosLogic(long lPos
) const;
161 long ConvertSizeLogic(long lSize
) const;
163 long RoundToCurrentMapMode(long lValue
) const;
165 long GetFirstLineIndent() const;
166 long GetLeftIndent() const;
167 long GetRightIndent() const;
168 long GetLogicRightIndent() const;
170 long GetLeftFrameMargin() const;
171 long GetRightFrameMargin() const;
177 //adjust the left margin either after DragMargin1() or after DragBorders()
178 void AdjustMargin1(long lDiff
);
183 void DragObjectBorder();
191 long GetFrameLeft() const;
192 void SetFrameLeft(long);
194 long GetLeftMin() const;
195 long GetRightMax() const;
197 DECL_LINK( TabMenuSelect
, Menu
* );
198 DECL_LINK( MenuSelect
, Menu
* );
199 void PrepareProportional_Impl(RulerType
);
201 sal_uInt16
GetNextVisible(sal_uInt16 nColumn
);
202 sal_uInt16
GetPrevVisible(sal_uInt16 nColumn
);
210 void UpdateParaContents_Impl(long lDiff
, UpdateType
= MOVE_ALL
);
213 virtual void Command( const CommandEvent
& rCEvt
);
214 virtual void Click();
215 virtual long StartDrag();
217 virtual void EndDrag();
218 virtual void ExtraDown();
219 virtual void MouseMove( const MouseEvent
& rMEvt
);
221 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
223 virtual void Update();
225 // calculation of boundary values for object borders
226 // values refer to the page
227 virtual sal_Bool
CalcLimits(long &nMax1
, long &nMax2
, sal_Bool bFirst
) const;
228 sal_Bool
IsActLastColumn(
229 sal_Bool bForceDontConsiderHidden
= sal_False
,
230 sal_uInt16 nAct
=USHRT_MAX
) const;
231 sal_Bool
IsActFirstColumn(
232 sal_Bool bForceDontConsiderHidden
= sal_False
,
233 sal_uInt16 nAct
=USHRT_MAX
) const;
234 sal_uInt16
GetActLeftColumn(
235 sal_Bool bForceDontConsiderHidden
= sal_False
,
236 sal_uInt16 nAct
=USHRT_MAX
) const;
237 sal_uInt16
GetActRightColumn (
238 sal_Bool bForceDontConsiderHidden
= sal_False
,
239 sal_uInt16 nAct
=USHRT_MAX
) const;
240 long CalcPropMaxRight(sal_uInt16 nCol
= USHRT_MAX
) const;
241 long GetPageWidth() const;
245 #define SVXRULER_SUPPORT_TABS 0x0001
246 #define SVXRULER_SUPPORT_PARAGRAPH_MARGINS 0x0002
247 #define SVXRULER_SUPPORT_BORDERS 0x0004
248 #define SVXRULER_SUPPORT_OBJECT 0x0008
249 #define SVXRULER_SUPPORT_SET_NULLOFFSET 0x0010
250 #define SVXRULER_SUPPORT_NEGATIVE_MARGINS 0x0020
251 #define SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL 0x0040
252 #define SVXRULER_SUPPORT_REDUCED_METRIC 0x0080 //shorten the context menu to select metric
254 SvxRuler(Window
* pParent
, Window
*pEditWin
, sal_uInt16 nRulerFlags
,
255 SfxBindings
&rBindings
, WinBits nWinStyle
= WB_STDRULER
);
258 void SetMinFrameSize(long lSize
);
259 long GetMinFrameSize() const ;
261 sal_uInt16
GetRulerFlags() const
266 void SetDefTabDist(long);
268 // set/get NullOffset in logic units
269 void SetNullOffsetLogic(long lOff
= 0);
270 long GetNullOffsetLogic() const
272 return lAppNullOffset
;
275 void SetActive(sal_Bool bOn
= sal_True
);
276 sal_Bool
IsActive() const
286 //#i24363# tab stops relative to indent
287 void SetTabsRelativeToIndent( sal_Bool bRel
= sal_True
);
292 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */