xref: /aoo41x/main/svx/source/dialog/svxruler.cxx (revision f6e50924)
1*f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f6e50924SAndrew Rist  * distributed with this work for additional information
6*f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9*f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f6e50924SAndrew Rist  *
11*f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f6e50924SAndrew Rist  *
13*f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15*f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f6e50924SAndrew Rist  * specific language governing permissions and limitations
18*f6e50924SAndrew Rist  * under the License.
19*f6e50924SAndrew Rist  *
20*f6e50924SAndrew Rist  *************************************************************/
21*f6e50924SAndrew Rist 
22*f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <string.h>
30cdf0e10cSrcweir #include <limits.h>
31cdf0e10cSrcweir #include <tools/shl.hxx>
32cdf0e10cSrcweir #include <vcl/image.hxx>
33cdf0e10cSrcweir #include <svl/eitem.hxx>
34cdf0e10cSrcweir #include <svl/rectitem.hxx>
35cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include <svl/smplhint.hxx>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir 
40cdf0e10cSrcweir 
41cdf0e10cSrcweir 
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include <svx/dialogs.hrc>
44cdf0e10cSrcweir #include <svx/dialmgr.hxx>
45cdf0e10cSrcweir #include <svx/ruler.hxx>
46cdf0e10cSrcweir #include "rlrcitem.hxx"
47cdf0e10cSrcweir #include "svx/rulritem.hxx"
48cdf0e10cSrcweir #include <editeng/tstpitem.hxx>
49cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
50cdf0e10cSrcweir #include "editeng/protitem.hxx"
51cdf0e10cSrcweir #ifndef _APP_HXX
52cdf0e10cSrcweir #include <vcl/svapp.hxx>
53cdf0e10cSrcweir #endif
54cdf0e10cSrcweir #ifndef RULER_TAB_RTL
55cdf0e10cSrcweir #define RULER_TAB_RTL           ((sal_uInt16)0x0010)
56cdf0e10cSrcweir #endif
57cdf0e10cSrcweir 
58cdf0e10cSrcweir #include <comphelper/uieventslogger.hxx>
59cdf0e10cSrcweir 
60cdf0e10cSrcweir namespace
61cdf0e10cSrcweir {
lcl_logRulerUse(const::rtl::OUString & sURL)62cdf0e10cSrcweir     void lcl_logRulerUse(const ::rtl::OUString& sURL) //#i99729#
63cdf0e10cSrcweir     {
64cdf0e10cSrcweir         using namespace ::com::sun::star;
65cdf0e10cSrcweir         util::URL aTargetURL;
66cdf0e10cSrcweir         aTargetURL.Complete = sURL;
67cdf0e10cSrcweir         aTargetURL.Main = sURL;
68cdf0e10cSrcweir         if(::comphelper::UiEventsLogger::isEnabled()) //#i88653#
69cdf0e10cSrcweir         {
70cdf0e10cSrcweir             ::rtl::OUString sAppName;
71cdf0e10cSrcweir             uno::Sequence<beans::PropertyValue> source;
72cdf0e10cSrcweir             ::comphelper::UiEventsLogger::appendDispatchOrigin(source, sAppName, ::rtl::OUString::createFromAscii("SfxRuler"));
73cdf0e10cSrcweir             ::comphelper::UiEventsLogger::logDispatch(aTargetURL, source);
74cdf0e10cSrcweir         }
75cdf0e10cSrcweir     }
76cdf0e10cSrcweir }
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 
80cdf0e10cSrcweir // STATIC DATA -----------------------------------------------------------
81cdf0e10cSrcweir 
82cdf0e10cSrcweir #define CTRL_ITEM_COUNT 14
83cdf0e10cSrcweir #define GAP 10
84cdf0e10cSrcweir #define OBJECT_BORDER_COUNT 4
85cdf0e10cSrcweir #define TAB_GAP 1
86cdf0e10cSrcweir #define INDENT_GAP 2
87cdf0e10cSrcweir #define INDENT_FIRST_LINE   4
88cdf0e10cSrcweir #define INDENT_LEFT_MARGIN  5
89cdf0e10cSrcweir #define INDENT_RIGHT_MARGIN 6
90cdf0e10cSrcweir #define INDENT_LEFT_BORDER  2
91cdf0e10cSrcweir #define INDENT_RIGHT_BORDER 3
92cdf0e10cSrcweir #define INDENT_COUNT        5 //without the first two old values
93cdf0e10cSrcweir 
94cdf0e10cSrcweir #define PIXEL_H_ADJUST( l1, l2 ) PixelHAdjust(l1,l2)
95cdf0e10cSrcweir 
96cdf0e10cSrcweir #ifdef DEBUGLIN
97cdf0e10cSrcweir 
ToMM(Window * pWin,long lVal)98cdf0e10cSrcweir inline long ToMM(Window *pWin, long lVal)
99cdf0e10cSrcweir {
100cdf0e10cSrcweir 	return pWin->PixelToLogic(Size(lVal, 0), MapMode(MAP_MM)).Width();
101cdf0e10cSrcweir }
102cdf0e10cSrcweir 
Debug_Impl(Window * pWin,SvxColumnItem & rColItem)103cdf0e10cSrcweir void Debug_Impl(Window *pWin, SvxColumnItem& rColItem)
104cdf0e10cSrcweir {
105cdf0e10cSrcweir 	String aTmp("Aktuell: ");
106cdf0e10cSrcweir 	aTmp += rColItem.GetActColumn();
107cdf0e10cSrcweir 	aTmp += " ColLeft: ";
108cdf0e10cSrcweir 	aTmp +=  String(ToMM(pWin, rColItem.GetLeft()));
109cdf0e10cSrcweir 	aTmp += "   ColRight: ";
110cdf0e10cSrcweir 	aTmp +=  String(ToMM(pWin, rColItem.GetRight()));
111cdf0e10cSrcweir 	for(sal_uInt16 i = 0; i < rColItem.Count(); ++i) {
112cdf0e10cSrcweir 		aTmp += " Start: ";
113cdf0e10cSrcweir 		aTmp += String(ToMM(pWin, rColItem[i].nStart));
114cdf0e10cSrcweir 		aTmp += " End: ";
115cdf0e10cSrcweir 		aTmp += String(ToMM(pWin, rColItem[i].nEnd));
116cdf0e10cSrcweir 	}
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 	InfoBox(0, aTmp).Execute();
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
Debug_Impl(Window * pWin,const SvxLongLRSpaceItem & rLRSpace)121cdf0e10cSrcweir void Debug_Impl(Window *pWin, const SvxLongLRSpaceItem& rLRSpace)
122cdf0e10cSrcweir {
123cdf0e10cSrcweir 	String aTmp("Left: ");
124cdf0e10cSrcweir 	aTmp += pWin->PixelToLogic(Size(rLRSpace.GetLeft(), 0), MapMode(MAP_MM)).Width();
125cdf0e10cSrcweir 	aTmp += "   Right: ";
126cdf0e10cSrcweir 	aTmp +=pWin->PixelToLogic(Size(rLRSpace.GetRight(), 0), MapMode(MAP_MM)).Width();
127cdf0e10cSrcweir 	InfoBox(0, aTmp).Execute();
128cdf0e10cSrcweir }
129cdf0e10cSrcweir 
Debug_Impl(Window * pWin,const SvxLongULSpaceItem & rULSpace)130cdf0e10cSrcweir void Debug_Impl(Window *pWin, const SvxLongULSpaceItem& rULSpace)
131cdf0e10cSrcweir {
132cdf0e10cSrcweir 	String aTmp("Upper: ");
133cdf0e10cSrcweir 	aTmp += pWin->PixelToLogic(Size(rULSpace.GetUpper(), 0), MapMode(MAP_MM)).Width();
134cdf0e10cSrcweir 	aTmp += "   Lower: ";
135cdf0e10cSrcweir 	aTmp += pWin->PixelToLogic(Size(rULSpace.GetLower(), 0), MapMode(MAP_MM)).Width();
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	InfoBox(0, aTmp).Execute();
138cdf0e10cSrcweir }
139cdf0e10cSrcweir 
DebugTabStops_Impl(const SvxTabStopItem & rTabs)140cdf0e10cSrcweir void DebugTabStops_Impl(const SvxTabStopItem& rTabs)
141cdf0e10cSrcweir {
142cdf0e10cSrcweir 	String aTmp("Tabs: ");
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 	// Def Tabs loeschen
145cdf0e10cSrcweir 	for(sal_uInt16 i = 0; i < rTabs.Count(); ++i)
146cdf0e10cSrcweir 	{
147cdf0e10cSrcweir 		aTmp += String(rTabs[i].GetTabPos() / 56);
148cdf0e10cSrcweir 		aTmp += " : ";
149cdf0e10cSrcweir 	}
150cdf0e10cSrcweir 	InfoBox(0, aTmp).Execute();
151cdf0e10cSrcweir }
152cdf0e10cSrcweir 
DebugParaMargin_Impl(const SvxLRSpaceItem & rLRSpace)153cdf0e10cSrcweir void DebugParaMargin_Impl(const SvxLRSpaceItem& rLRSpace)
154cdf0e10cSrcweir {
155cdf0e10cSrcweir 	String aTmp("ParaLeft: ");
156cdf0e10cSrcweir 	aTmp += rLRSpace.GetTxtLeft() / 56;
157cdf0e10cSrcweir 	aTmp += "   ParaRight: ";
158cdf0e10cSrcweir 	aTmp += rLRSpace.GetRight() / 56;
159cdf0e10cSrcweir 	aTmp += "   FLI: ";
160cdf0e10cSrcweir 	aTmp += rLRSpace.GetTxtFirstLineOfst() / 56;
161cdf0e10cSrcweir 	InfoBox(0, aTmp).Execute();
162cdf0e10cSrcweir }
163cdf0e10cSrcweir 
164cdf0e10cSrcweir #endif // DEBUGLIN
165cdf0e10cSrcweir #ifdef DEBUG_RULER
166cdf0e10cSrcweir #include <vcl/svapp.hxx>
167cdf0e10cSrcweir #include <vcl/lstbox.hxx>
168cdf0e10cSrcweir class RulerDebugWindow : public Window
169cdf0e10cSrcweir {
170cdf0e10cSrcweir     ListBox aBox;
171cdf0e10cSrcweir public:
RulerDebugWindow(Window * pParent)172cdf0e10cSrcweir         RulerDebugWindow(Window* pParent) :
173cdf0e10cSrcweir             Window(pParent, WB_BORDER|WB_SIZEMOVE|WB_DIALOGCONTROL|WB_CLIPCHILDREN|WB_SYSTEMWINDOW),
174cdf0e10cSrcweir             aBox(this, WB_BORDER)
175cdf0e10cSrcweir             {
176cdf0e10cSrcweir                 Size aOutput(200, 400);
177cdf0e10cSrcweir                 SetOutputSizePixel(aOutput);
178cdf0e10cSrcweir                 aBox.SetSizePixel(aOutput);
179cdf0e10cSrcweir                 aBox.Show();
180cdf0e10cSrcweir                 Show();
181cdf0e10cSrcweir                 Size aParentSize(pParent->GetOutputSizePixel());
182cdf0e10cSrcweir                 Size aOwnSize(GetSizePixel());
183cdf0e10cSrcweir                 aParentSize.Width() -= aOwnSize.Width();
184cdf0e10cSrcweir                 aParentSize.Height() -= aOwnSize.Height();
185cdf0e10cSrcweir                 SetPosPixel(Point(aParentSize.Width(), aParentSize.Height()));
186cdf0e10cSrcweir             }
187cdf0e10cSrcweir         ~RulerDebugWindow();
188cdf0e10cSrcweir 
GetLBox()189cdf0e10cSrcweir         ListBox& GetLBox() {return aBox;}
190cdf0e10cSrcweir         static void     AddDebugText(const sal_Char* pDescription, const String& rText );
191cdf0e10cSrcweir };
192cdf0e10cSrcweir static RulerDebugWindow* pDebugWindow = 0;
193cdf0e10cSrcweir 
~RulerDebugWindow()194cdf0e10cSrcweir RulerDebugWindow::~RulerDebugWindow()
195cdf0e10cSrcweir {
196cdf0e10cSrcweir     pDebugWindow = 0;
197cdf0e10cSrcweir }
AddDebugText(const sal_Char * pDescription,const String & rText)198cdf0e10cSrcweir void     RulerDebugWindow::AddDebugText(const sal_Char* pDescription, const String& rText )
199cdf0e10cSrcweir {
200cdf0e10cSrcweir     if(!pDebugWindow)
201cdf0e10cSrcweir     {
202cdf0e10cSrcweir         Window* pParent = Application::GetFocusWindow();
203cdf0e10cSrcweir         while(pParent->GetParent())
204cdf0e10cSrcweir             pParent = pParent->GetParent();
205cdf0e10cSrcweir         pDebugWindow = new RulerDebugWindow(pParent);
206cdf0e10cSrcweir     }
207cdf0e10cSrcweir     String sContent(String::CreateFromAscii(pDescription));
208cdf0e10cSrcweir     sContent += rText;
209cdf0e10cSrcweir     sal_uInt16 nPos = pDebugWindow->GetLBox().InsertEntry(sContent);
210cdf0e10cSrcweir     pDebugWindow->GetLBox().SelectEntryPos(nPos);
211cdf0e10cSrcweir     pDebugWindow->GrabFocus();
212cdf0e10cSrcweir }
213cdf0e10cSrcweir 
214cdf0e10cSrcweir #define ADD_DEBUG_TEXT(cDescription, sValue) \
215cdf0e10cSrcweir     RulerDebugWindow::AddDebugText(cDescription, sValue);
216cdf0e10cSrcweir 
217cdf0e10cSrcweir #define REMOVE_DEBUG_WINDOW \
218cdf0e10cSrcweir     delete pDebugWindow;    \
219cdf0e10cSrcweir     pDebugWindow = 0;
220cdf0e10cSrcweir 
221cdf0e10cSrcweir #else
222cdf0e10cSrcweir #define ADD_DEBUG_TEXT(cDescription, sValue)
223cdf0e10cSrcweir #define REMOVE_DEBUG_WINDOW
224cdf0e10cSrcweir #endif
225cdf0e10cSrcweir 
226cdf0e10cSrcweir struct SvxRuler_Impl  {
227cdf0e10cSrcweir 	sal_uInt16 *pPercBuf;
228cdf0e10cSrcweir 	sal_uInt16 *pBlockBuf;
229cdf0e10cSrcweir 	sal_uInt16 nPercSize;
230cdf0e10cSrcweir 	long   nTotalDist;
231cdf0e10cSrcweir 	long   lOldWinPos;
232cdf0e10cSrcweir 	long   lMaxLeftLogic;
233cdf0e10cSrcweir 	long   lMaxRightLogic;
234cdf0e10cSrcweir 	long   lLastLMargin;
235cdf0e10cSrcweir 	long   lLastRMargin;
236cdf0e10cSrcweir     SvxProtectItem aProtectItem;
237cdf0e10cSrcweir     SfxBoolItem* pTextRTLItem;
238cdf0e10cSrcweir 	sal_uInt16 nControlerItems;
239cdf0e10cSrcweir 	sal_uInt16 nIdx;
240cdf0e10cSrcweir 	sal_uInt16 nColLeftPix, nColRightPix; // Pixelwerte fuer linken / rechten Rand
241cdf0e10cSrcweir 									  // bei Spalten; gepuffert, um Umrechenfehler
242cdf0e10cSrcweir 									  // zu vermeiden.
243cdf0e10cSrcweir 									  // Muesste vielleicht fuer weitere Werte
244cdf0e10cSrcweir 									  // aufgebohrt werden
245cdf0e10cSrcweir     sal_Bool bIsTableRows : 1;      // pColumnItem contains table rows instead of columns
246cdf0e10cSrcweir     //#i24363# tab stops relative to indent
247cdf0e10cSrcweir     sal_Bool bIsTabsRelativeToIndent : 1; // Tab stops relative to paragraph indent?
SvxRuler_ImplSvxRuler_Impl248cdf0e10cSrcweir     SvxRuler_Impl() :
249cdf0e10cSrcweir     pPercBuf(0), pBlockBuf(0),
250cdf0e10cSrcweir     nPercSize(0), nTotalDist(0),
251cdf0e10cSrcweir     lOldWinPos(0),
252cdf0e10cSrcweir     lMaxLeftLogic(0), lMaxRightLogic(0),
253cdf0e10cSrcweir     lLastLMargin(0), lLastRMargin(0),
254cdf0e10cSrcweir     aProtectItem(SID_RULER_PROTECT),
255cdf0e10cSrcweir     pTextRTLItem(0), nControlerItems(0),
256cdf0e10cSrcweir     nIdx(0),
257cdf0e10cSrcweir     nColLeftPix(0), nColRightPix(0),
258cdf0e10cSrcweir 
259cdf0e10cSrcweir     bIsTableRows(sal_False),
260cdf0e10cSrcweir     bIsTabsRelativeToIndent(sal_True)
261cdf0e10cSrcweir 	{
262cdf0e10cSrcweir 	}
~SvxRuler_ImplSvxRuler_Impl263cdf0e10cSrcweir 	~SvxRuler_Impl()
264cdf0e10cSrcweir 	{
265cdf0e10cSrcweir 		nPercSize = 0; nTotalDist = 0;
266cdf0e10cSrcweir 		delete[] pPercBuf; delete[] pBlockBuf; pPercBuf = 0;
267cdf0e10cSrcweir         delete pTextRTLItem;
268cdf0e10cSrcweir 	}
269cdf0e10cSrcweir 	void SetPercSize(sal_uInt16 nSize);
270cdf0e10cSrcweir 
271cdf0e10cSrcweir };
272cdf0e10cSrcweir 
273cdf0e10cSrcweir 
274cdf0e10cSrcweir 
SetPercSize(sal_uInt16 nSize)275cdf0e10cSrcweir void SvxRuler_Impl::SetPercSize(sal_uInt16 nSize)
276cdf0e10cSrcweir {
277cdf0e10cSrcweir 	if(nSize > nPercSize)
278cdf0e10cSrcweir 	{
279cdf0e10cSrcweir 		delete[] pPercBuf;
280cdf0e10cSrcweir 		delete[] pBlockBuf;
281cdf0e10cSrcweir 		pPercBuf = new sal_uInt16[nPercSize = nSize];
282cdf0e10cSrcweir 		pBlockBuf = new sal_uInt16[nPercSize = nSize];
283cdf0e10cSrcweir 	}
284cdf0e10cSrcweir 	size_t nSize2 = sizeof(sal_uInt16) * nPercSize;
285cdf0e10cSrcweir 	memset(pPercBuf, 0, nSize2);
286cdf0e10cSrcweir 	memset(pBlockBuf, 0, nSize2);
287cdf0e10cSrcweir }
288cdf0e10cSrcweir 
289cdf0e10cSrcweir 
290cdf0e10cSrcweir // Konstruktor des Lineals
291cdf0e10cSrcweir 
292cdf0e10cSrcweir // SID_ATTR_ULSPACE, SID_ATTR_LRSPACE
293cdf0e10cSrcweir // erwartet als Parameter SvxULSpaceItem f"ur Seitenr"ander
294cdf0e10cSrcweir // (entweder links/rechts oder oben/unten)
295cdf0e10cSrcweir // Lineal: SetMargin1, SetMargin2
296cdf0e10cSrcweir 
297cdf0e10cSrcweir // SID_RULER_PAGE_POS
298cdf0e10cSrcweir // erwartet als Parameter Anfangswert der Seite sowie Seitenbreite
299cdf0e10cSrcweir // Lineal: SetPagePos
300cdf0e10cSrcweir 
301cdf0e10cSrcweir // SID_ATTR_TABSTOP
302cdf0e10cSrcweir // erwartet: SvxTabStopItem
303cdf0e10cSrcweir // Lineal: SetTabs
304cdf0e10cSrcweir 
305cdf0e10cSrcweir // SID_ATTR_PARA_LRSPACE
306cdf0e10cSrcweir // linker, rechter Absatzrand bei H-Lineal
307cdf0e10cSrcweir // Lineal: SetIndents
308cdf0e10cSrcweir 
309cdf0e10cSrcweir // SID_RULER_BORDERS
310cdf0e10cSrcweir // Tabellenraender, Spalten
311cdf0e10cSrcweir // erwartet: so etwas wie SwTabCols
312cdf0e10cSrcweir // Lineal: SetBorders
313cdf0e10cSrcweir 
314cdf0e10cSrcweir 
SvxRuler(Window * pParent,Window * pWin,sal_uInt16 flags,SfxBindings & rBindings,WinBits nWinStyle)315cdf0e10cSrcweir SvxRuler::SvxRuler
316cdf0e10cSrcweir (
317cdf0e10cSrcweir  Window* pParent,                               // StarView Parent
318cdf0e10cSrcweir  Window* pWin,                                  // Ausgabefenster; wird fuer Umrechnung logische
319cdf0e10cSrcweir 				// Einheiten <-> Pixel verwendet
320cdf0e10cSrcweir  sal_uInt16  flags,                                 // Anzeige Flags, siehe ruler.hxx
321cdf0e10cSrcweir  SfxBindings &rBindings,                // zugeordnete Bindings
322cdf0e10cSrcweir  WinBits nWinStyle                              // StarView WinBits
323cdf0e10cSrcweir )
324cdf0e10cSrcweir : Ruler(pParent, nWinStyle),
325cdf0e10cSrcweir   pCtrlItem(new SvxRulerItem *[CTRL_ITEM_COUNT]),
326cdf0e10cSrcweir   pLRSpaceItem(0),
327cdf0e10cSrcweir   pMinMaxItem(0),
328cdf0e10cSrcweir   pULSpaceItem(0),
329cdf0e10cSrcweir   pTabStopItem(0),
330cdf0e10cSrcweir   pParaItem(0),
331cdf0e10cSrcweir   pParaBorderItem(0),
332cdf0e10cSrcweir   pPagePosItem(0),
333cdf0e10cSrcweir   pColumnItem(0),
334cdf0e10cSrcweir   pObjectItem(0),
335cdf0e10cSrcweir   pEditWin(pWin),
336cdf0e10cSrcweir   pRuler_Imp(new SvxRuler_Impl),
337cdf0e10cSrcweir   bAppSetNullOffset(sal_False),  //Wird der 0-Offset des Lineals
338cdf0e10cSrcweir                              //durch die appl. gesetzt?
339cdf0e10cSrcweir   lLogicNullOffset(0),
340cdf0e10cSrcweir   lAppNullOffset(LONG_MAX),
341cdf0e10cSrcweir   lMinFrame(5),
342cdf0e10cSrcweir   lInitialDragPos(0),
343cdf0e10cSrcweir   nFlags(flags),
344cdf0e10cSrcweir   nDragType(NONE),
345cdf0e10cSrcweir   nDefTabType(RULER_TAB_LEFT),
346cdf0e10cSrcweir   nTabCount(0),
347cdf0e10cSrcweir   nTabBufSize(0),
348cdf0e10cSrcweir   lDefTabDist(50),
349cdf0e10cSrcweir   lTabPos(-1),
350cdf0e10cSrcweir   pTabs(0),
351cdf0e10cSrcweir   pIndents(0),
352cdf0e10cSrcweir   pBorders(new RulerBorder[1]), //wg 1 Spaltiger Tabellen
353cdf0e10cSrcweir   nBorderCount(0),
354cdf0e10cSrcweir   pObjectBorders(0),
355cdf0e10cSrcweir   pBindings(&rBindings),
356cdf0e10cSrcweir   nDragOffset(0),
357cdf0e10cSrcweir   nMaxLeft(0),
358cdf0e10cSrcweir   nMaxRight(0),
359cdf0e10cSrcweir   bValid(sal_False),
360cdf0e10cSrcweir   bListening(sal_False),
361cdf0e10cSrcweir   bActive(sal_True)
362cdf0e10cSrcweir 
363cdf0e10cSrcweir /*
364cdf0e10cSrcweir    [Beschreibung]
365cdf0e10cSrcweir 
366cdf0e10cSrcweir    ctor;
367cdf0e10cSrcweir    Datenpuffer initialisieren; ControllerItems werden erzeugt
368cdf0e10cSrcweir 
369cdf0e10cSrcweir */
370cdf0e10cSrcweir {
371cdf0e10cSrcweir 	memset(pCtrlItem, 0, sizeof(SvxRulerItem *) * CTRL_ITEM_COUNT);
372cdf0e10cSrcweir 
373cdf0e10cSrcweir 	rBindings.EnterRegistrations();
374cdf0e10cSrcweir 
375cdf0e10cSrcweir 	// Unterstuetzte Items anlegen
376cdf0e10cSrcweir 	sal_uInt16 i = 0;
377cdf0e10cSrcweir 	// Seitenraender
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 	pCtrlItem[i++] = new SvxRulerItem(SID_RULER_LR_MIN_MAX, *this, rBindings);
380cdf0e10cSrcweir 	if((nWinStyle & WB_VSCROLL) == WB_VSCROLL)
381cdf0e10cSrcweir 	{
382cdf0e10cSrcweir 		bHorz = sal_False;
383cdf0e10cSrcweir 		pCtrlItem[i++] = new SvxRulerItem(SID_ATTR_LONG_ULSPACE, *this, rBindings);
384cdf0e10cSrcweir     }
385cdf0e10cSrcweir 	else
386cdf0e10cSrcweir 	{
387cdf0e10cSrcweir 		bHorz = sal_True;
388cdf0e10cSrcweir 		pCtrlItem[i++] = new SvxRulerItem(SID_ATTR_LONG_LRSPACE, *this, rBindings);
389cdf0e10cSrcweir 	}
390cdf0e10cSrcweir 
391cdf0e10cSrcweir 	// Seitenposition
392cdf0e10cSrcweir 	pCtrlItem[i++] = new SvxRulerItem(SID_RULER_PAGE_POS, *this, rBindings);
393cdf0e10cSrcweir 
394cdf0e10cSrcweir 	if((nFlags & SVXRULER_SUPPORT_TABS) == SVXRULER_SUPPORT_TABS)
395cdf0e10cSrcweir 	{
396cdf0e10cSrcweir         sal_uInt16 nTabStopId = bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL;
397cdf0e10cSrcweir         pCtrlItem[i++] = new SvxRulerItem(nTabStopId, *this, rBindings);
398cdf0e10cSrcweir 		SetExtraType(RULER_EXTRA_TAB, nDefTabType);
399cdf0e10cSrcweir 	}
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 
402cdf0e10cSrcweir     if(0 != (nFlags & (SVXRULER_SUPPORT_PARAGRAPH_MARGINS |SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL)))
403cdf0e10cSrcweir 	{
404cdf0e10cSrcweir 		if(bHorz)
405cdf0e10cSrcweir 			pCtrlItem[i++] = new SvxRulerItem(SID_ATTR_PARA_LRSPACE, *this, rBindings);
406cdf0e10cSrcweir 		else
407cdf0e10cSrcweir 			pCtrlItem[i++] = new SvxRulerItem(SID_ATTR_PARA_LRSPACE_VERTICAL, *this, rBindings);
408cdf0e10cSrcweir         pIndents = new RulerIndent[5+INDENT_GAP];
409cdf0e10cSrcweir 		memset(pIndents, 0, sizeof(RulerIndent)*(3+INDENT_GAP));
410cdf0e10cSrcweir 		pIndents[0].nStyle = RULER_STYLE_DONTKNOW;
411cdf0e10cSrcweir 		pIndents[1].nStyle = RULER_STYLE_DONTKNOW;
412cdf0e10cSrcweir         pIndents[INDENT_FIRST_LINE].nStyle = RULER_INDENT_TOP;
413cdf0e10cSrcweir         pIndents[INDENT_LEFT_MARGIN].nStyle = RULER_INDENT_BOTTOM;
414cdf0e10cSrcweir         pIndents[INDENT_RIGHT_MARGIN].nStyle = RULER_INDENT_BOTTOM;
415cdf0e10cSrcweir         pIndents[INDENT_LEFT_BORDER].nStyle = RULER_INDENT_BORDER;
416cdf0e10cSrcweir         pIndents[INDENT_RIGHT_BORDER].nStyle = RULER_INDENT_BORDER;
417cdf0e10cSrcweir         for(sal_uInt16 nIn = 0; nIn < 7; nIn++)
418cdf0e10cSrcweir             pIndents[nIn].nPos = 0;
419cdf0e10cSrcweir     }
420cdf0e10cSrcweir 
421cdf0e10cSrcweir 	if((nFlags & SVXRULER_SUPPORT_BORDERS) ==  SVXRULER_SUPPORT_BORDERS)
422cdf0e10cSrcweir     {
423cdf0e10cSrcweir         pCtrlItem[i++] = new SvxRulerItem(bHorz ? SID_RULER_BORDERS : SID_RULER_BORDERS_VERTICAL, *this, rBindings);
424cdf0e10cSrcweir         pCtrlItem[i++] = new SvxRulerItem(bHorz ? SID_RULER_ROWS : SID_RULER_ROWS_VERTICAL, *this, rBindings);
425cdf0e10cSrcweir     }
426cdf0e10cSrcweir 
427cdf0e10cSrcweir     pCtrlItem[i++] = new SvxRulerItem(SID_RULER_TEXT_RIGHT_TO_LEFT, *this, rBindings);
428cdf0e10cSrcweir 
429cdf0e10cSrcweir 	if((nFlags & SVXRULER_SUPPORT_OBJECT) == SVXRULER_SUPPORT_OBJECT)
430cdf0e10cSrcweir 	{
431cdf0e10cSrcweir 		pCtrlItem[i++] = new SvxRulerItem(SID_RULER_OBJECT, *this, rBindings );
432cdf0e10cSrcweir 		pObjectBorders = new RulerBorder[OBJECT_BORDER_COUNT];
433cdf0e10cSrcweir 		size_t nSize = sizeof( RulerBorder ) * OBJECT_BORDER_COUNT;
434cdf0e10cSrcweir 		memset(pObjectBorders, 0, nSize);
435cdf0e10cSrcweir         for(sal_uInt16 nBorder = 0; nBorder < OBJECT_BORDER_COUNT; ++nBorder)
436cdf0e10cSrcweir 		{
437cdf0e10cSrcweir             pObjectBorders[nBorder].nPos   = 0;
438cdf0e10cSrcweir             pObjectBorders[nBorder].nWidth = 0;
439cdf0e10cSrcweir             pObjectBorders[nBorder].nStyle = RULER_BORDER_MOVEABLE;
440cdf0e10cSrcweir 		}
441cdf0e10cSrcweir 	}
442cdf0e10cSrcweir 
443cdf0e10cSrcweir 	pCtrlItem[i++] = new SvxRulerItem( SID_RULER_PROTECT, *this, rBindings );
444cdf0e10cSrcweir     pCtrlItem[i++] = new SvxRulerItem(SID_RULER_BORDER_DISTANCE, *this, rBindings);
445cdf0e10cSrcweir     pRuler_Imp->nControlerItems=i;
446cdf0e10cSrcweir 
447cdf0e10cSrcweir 	if((nFlags & SVXRULER_SUPPORT_SET_NULLOFFSET) ==
448cdf0e10cSrcweir 	   SVXRULER_SUPPORT_SET_NULLOFFSET)
449cdf0e10cSrcweir 		SetExtraType(RULER_EXTRA_NULLOFFSET, 0);
450cdf0e10cSrcweir 
451cdf0e10cSrcweir 	rBindings.LeaveRegistrations();
452cdf0e10cSrcweir }
453cdf0e10cSrcweir 
454cdf0e10cSrcweir 
~SvxRuler()455cdf0e10cSrcweir __EXPORT SvxRuler::~SvxRuler()
456cdf0e10cSrcweir /*
457cdf0e10cSrcweir    [Beschreibung]
458cdf0e10cSrcweir 
459cdf0e10cSrcweir    Destruktor Lineal
460cdf0e10cSrcweir    Freigabe interner Puffer
461cdf0e10cSrcweir 
462cdf0e10cSrcweir 
463cdf0e10cSrcweir */
464cdf0e10cSrcweir {
465cdf0e10cSrcweir     REMOVE_DEBUG_WINDOW
466cdf0e10cSrcweir     if(bListening)
467cdf0e10cSrcweir 		EndListening(*pBindings);
468cdf0e10cSrcweir 
469cdf0e10cSrcweir 	pBindings->EnterRegistrations();
470cdf0e10cSrcweir 
471cdf0e10cSrcweir 	for(sal_uInt16 i = 0; i < CTRL_ITEM_COUNT  && pCtrlItem[i]; ++i)
472cdf0e10cSrcweir 		delete pCtrlItem[i];
473cdf0e10cSrcweir 	delete[] pCtrlItem;
474cdf0e10cSrcweir 
475cdf0e10cSrcweir 	delete pLRSpaceItem;
476cdf0e10cSrcweir 	delete pMinMaxItem;
477cdf0e10cSrcweir 	delete pULSpaceItem;
478cdf0e10cSrcweir 	delete pTabStopItem;
479cdf0e10cSrcweir 	delete pParaItem;
480cdf0e10cSrcweir     delete pParaBorderItem;
481cdf0e10cSrcweir     delete pPagePosItem;
482cdf0e10cSrcweir 	delete pColumnItem;
483cdf0e10cSrcweir 	delete pObjectItem;
484cdf0e10cSrcweir 	delete[] pIndents;
485cdf0e10cSrcweir 	delete[] pBorders;
486cdf0e10cSrcweir 	delete[] pObjectBorders;
487cdf0e10cSrcweir 	delete[] pTabs;
488cdf0e10cSrcweir 	delete pRuler_Imp;
489cdf0e10cSrcweir 
490cdf0e10cSrcweir 	pBindings->LeaveRegistrations();
491cdf0e10cSrcweir }
492cdf0e10cSrcweir 
493cdf0e10cSrcweir /*
494cdf0e10cSrcweir 
495cdf0e10cSrcweir    [Beschreibung]
496cdf0e10cSrcweir 
497cdf0e10cSrcweir    Interne Umrechenroutinen
498cdf0e10cSrcweir 
499cdf0e10cSrcweir */
500cdf0e10cSrcweir 
ConvertHPosPixel(long nVal) const501cdf0e10cSrcweir long SvxRuler::ConvertHPosPixel(long nVal) const
502cdf0e10cSrcweir {
503cdf0e10cSrcweir 	return pEditWin->LogicToPixel(Size(nVal, 0)).Width();
504cdf0e10cSrcweir }
505cdf0e10cSrcweir 
ConvertVPosPixel(long nVal) const506cdf0e10cSrcweir long SvxRuler::ConvertVPosPixel(long nVal) const
507cdf0e10cSrcweir {
508cdf0e10cSrcweir 	return pEditWin->LogicToPixel(Size(0, nVal)).Height();
509cdf0e10cSrcweir }
510cdf0e10cSrcweir 
ConvertHSizePixel(long nVal) const511cdf0e10cSrcweir long SvxRuler::ConvertHSizePixel(long nVal) const
512cdf0e10cSrcweir {
513cdf0e10cSrcweir 	return pEditWin->LogicToPixel(Size(nVal, 0)).Width();
514cdf0e10cSrcweir }
515cdf0e10cSrcweir 
ConvertVSizePixel(long nVal) const516cdf0e10cSrcweir long SvxRuler::ConvertVSizePixel(long nVal) const
517cdf0e10cSrcweir {
518cdf0e10cSrcweir 	return pEditWin->LogicToPixel(Size(0, nVal)).Height();
519cdf0e10cSrcweir }
520cdf0e10cSrcweir 
ConvertPosPixel(long nVal) const521cdf0e10cSrcweir long SvxRuler::ConvertPosPixel(long nVal) const
522cdf0e10cSrcweir {
523cdf0e10cSrcweir 	return bHorz ? ConvertHPosPixel(nVal): ConvertVPosPixel(nVal);
524cdf0e10cSrcweir }
525cdf0e10cSrcweir 
ConvertSizePixel(long nVal) const526cdf0e10cSrcweir long SvxRuler::ConvertSizePixel(long nVal) const
527cdf0e10cSrcweir {
528cdf0e10cSrcweir 	return bHorz? ConvertHSizePixel(nVal): ConvertVSizePixel(nVal);
529cdf0e10cSrcweir }
530cdf0e10cSrcweir 
531cdf0e10cSrcweir 
ConvertHPosLogic(long nVal) const532cdf0e10cSrcweir inline long SvxRuler::ConvertHPosLogic(long nVal) const
533cdf0e10cSrcweir {
534cdf0e10cSrcweir 	return pEditWin->PixelToLogic(Size(nVal, 0)).Width();
535cdf0e10cSrcweir }
536cdf0e10cSrcweir 
ConvertVPosLogic(long nVal) const537cdf0e10cSrcweir inline long SvxRuler::ConvertVPosLogic(long nVal) const
538cdf0e10cSrcweir {
539cdf0e10cSrcweir 	return pEditWin->PixelToLogic(Size(0, nVal)).Height();
540cdf0e10cSrcweir }
541cdf0e10cSrcweir 
ConvertHSizeLogic(long nVal) const542cdf0e10cSrcweir inline long SvxRuler::ConvertHSizeLogic(long nVal) const
543cdf0e10cSrcweir {
544cdf0e10cSrcweir 	return pEditWin->PixelToLogic(Size(nVal, 0)).Width();
545cdf0e10cSrcweir }
546cdf0e10cSrcweir 
ConvertVSizeLogic(long nVal) const547cdf0e10cSrcweir inline long SvxRuler::ConvertVSizeLogic(long nVal) const
548cdf0e10cSrcweir {
549cdf0e10cSrcweir 	return pEditWin->PixelToLogic(Size(0, nVal)).Height();
550cdf0e10cSrcweir }
551cdf0e10cSrcweir 
ConvertPosLogic(long nVal) const552cdf0e10cSrcweir inline long SvxRuler::ConvertPosLogic(long nVal) const
553cdf0e10cSrcweir {
554cdf0e10cSrcweir 	return bHorz? ConvertHPosLogic(nVal): ConvertVPosLogic(nVal);
555cdf0e10cSrcweir }
556cdf0e10cSrcweir 
ConvertSizeLogic(long nVal) const557cdf0e10cSrcweir inline long SvxRuler::ConvertSizeLogic(long nVal) const
558cdf0e10cSrcweir {
559cdf0e10cSrcweir 	return bHorz? ConvertHSizeLogic(nVal): ConvertVSizeLogic(nVal);
560cdf0e10cSrcweir }
561cdf0e10cSrcweir 
PixelHAdjust(long nVal,long nValOld) const562cdf0e10cSrcweir long SvxRuler::PixelHAdjust(long nVal, long nValOld) const
563cdf0e10cSrcweir {
564cdf0e10cSrcweir 		if(ConvertHSizePixel(nVal)!=ConvertHSizePixel(nValOld))
565cdf0e10cSrcweir 				return  nVal;
566cdf0e10cSrcweir 		else
567cdf0e10cSrcweir 				return  nValOld;
568cdf0e10cSrcweir }
569cdf0e10cSrcweir 
PixelVAdjust(long nVal,long nValOld) const570cdf0e10cSrcweir long SvxRuler::PixelVAdjust(long nVal, long nValOld) const
571cdf0e10cSrcweir {
572cdf0e10cSrcweir 		if(ConvertVSizePixel(nVal)!=ConvertVSizePixel(nValOld))
573cdf0e10cSrcweir 				return  nVal;
574cdf0e10cSrcweir 		else
575cdf0e10cSrcweir 				return  nValOld;
576cdf0e10cSrcweir }
577cdf0e10cSrcweir 
PixelAdjust(long nVal,long nValOld) const578cdf0e10cSrcweir long SvxRuler::PixelAdjust(long nVal, long nValOld) const
579cdf0e10cSrcweir {
580cdf0e10cSrcweir 		if(ConvertSizePixel(nVal)!=ConvertSizePixel(nValOld))
581cdf0e10cSrcweir 				return  nVal;
582cdf0e10cSrcweir 		else
583cdf0e10cSrcweir 				return  nValOld;
584cdf0e10cSrcweir }
585cdf0e10cSrcweir 
586cdf0e10cSrcweir 
GetObjectBordersOff(sal_uInt16 nIdx) const587cdf0e10cSrcweir inline sal_uInt16 SvxRuler::GetObjectBordersOff(sal_uInt16 nIdx) const
588cdf0e10cSrcweir {
589cdf0e10cSrcweir 	return bHorz? nIdx: nIdx + 2;
590cdf0e10cSrcweir }
591cdf0e10cSrcweir 
592cdf0e10cSrcweir 
593cdf0e10cSrcweir 
UpdateFrame()594cdf0e10cSrcweir void SvxRuler::UpdateFrame()
595cdf0e10cSrcweir 
596cdf0e10cSrcweir /*
597cdf0e10cSrcweir    [Beschreibung]
598cdf0e10cSrcweir 
599cdf0e10cSrcweir    Linken, oberen Rand aktualisieren
600cdf0e10cSrcweir    Items werden in die Darstellung des Lineals uebersetzt.
601cdf0e10cSrcweir 
602cdf0e10cSrcweir */
603cdf0e10cSrcweir 
604cdf0e10cSrcweir {
605cdf0e10cSrcweir 	const sal_uInt16 nMarginStyle =
606cdf0e10cSrcweir 		( pRuler_Imp->aProtectItem.IsSizeProtected() ||
607cdf0e10cSrcweir 		  pRuler_Imp->aProtectItem.IsPosProtected() ) ?
608cdf0e10cSrcweir 		0 : RULER_MARGIN_SIZEABLE;
609cdf0e10cSrcweir 
610cdf0e10cSrcweir 	if(pLRSpaceItem && pPagePosItem)
611cdf0e10cSrcweir 	{
612cdf0e10cSrcweir 		// wenn keine Initialisierung durch App Defaultverhalten
613cdf0e10cSrcweir 		const long nOld = lLogicNullOffset;
614cdf0e10cSrcweir 		lLogicNullOffset = pColumnItem?
615cdf0e10cSrcweir 			pColumnItem->GetLeft(): pLRSpaceItem->GetLeft();
616cdf0e10cSrcweir 		if(bAppSetNullOffset)
617cdf0e10cSrcweir 			lAppNullOffset += lLogicNullOffset - nOld;
618cdf0e10cSrcweir 		if(!bAppSetNullOffset || lAppNullOffset == LONG_MAX)
619cdf0e10cSrcweir 		{
620cdf0e10cSrcweir 			Ruler::SetNullOffset(ConvertHPosPixel(lLogicNullOffset));
621cdf0e10cSrcweir 			SetMargin1( 0, nMarginStyle );
622cdf0e10cSrcweir 			lAppNullOffset = 0;
623cdf0e10cSrcweir 		}
624cdf0e10cSrcweir 		else
625cdf0e10cSrcweir 			SetMargin1( ConvertHPosPixel( lAppNullOffset ), nMarginStyle );
626cdf0e10cSrcweir 		long lRight = 0;
627cdf0e10cSrcweir 			// bei Tabelle rechten Rand der Tabelle auswerten
628cdf0e10cSrcweir 		if(pColumnItem && pColumnItem->IsTable())
629cdf0e10cSrcweir 			lRight = pColumnItem->GetRight();
630cdf0e10cSrcweir 		else
631cdf0e10cSrcweir 			lRight = pLRSpaceItem->GetRight();
632cdf0e10cSrcweir 
633cdf0e10cSrcweir 		sal_uIntPtr aWidth=
634cdf0e10cSrcweir 			ConvertHPosPixel(pPagePosItem->GetWidth() - lRight -
635cdf0e10cSrcweir 									lLogicNullOffset + lAppNullOffset);
636cdf0e10cSrcweir 		SetMargin2( aWidth, nMarginStyle );
637cdf0e10cSrcweir 	}
638cdf0e10cSrcweir 	else
639cdf0e10cSrcweir 		if(pULSpaceItem && pPagePosItem)
640cdf0e10cSrcweir 		{
641cdf0e10cSrcweir 			// Nullpunkt aus oberem Rand des umgebenden Rahmens
642cdf0e10cSrcweir 			const long nOld = lLogicNullOffset;
643cdf0e10cSrcweir 			lLogicNullOffset = pColumnItem?
644cdf0e10cSrcweir 				pColumnItem->GetLeft(): pULSpaceItem->GetUpper();
645cdf0e10cSrcweir 			if(bAppSetNullOffset)
646cdf0e10cSrcweir 				lAppNullOffset += lLogicNullOffset - nOld;
647cdf0e10cSrcweir 			if(!bAppSetNullOffset || lAppNullOffset == LONG_MAX) {
648cdf0e10cSrcweir 				Ruler::SetNullOffset(ConvertVPosPixel(lLogicNullOffset));
649cdf0e10cSrcweir 				lAppNullOffset = 0;
650cdf0e10cSrcweir 				SetMargin1( 0, nMarginStyle );
651cdf0e10cSrcweir 			}
652cdf0e10cSrcweir 			else
653cdf0e10cSrcweir 				SetMargin1( ConvertVPosPixel( lAppNullOffset ),nMarginStyle );
654cdf0e10cSrcweir 
655cdf0e10cSrcweir 			long lLower = pColumnItem ?
656cdf0e10cSrcweir 				pColumnItem->GetRight() : pULSpaceItem->GetLower();
657cdf0e10cSrcweir 
658cdf0e10cSrcweir 			SetMargin2(ConvertVPosPixel(pPagePosItem->GetHeight() - lLower -
659cdf0e10cSrcweir 										lLogicNullOffset + lAppNullOffset),
660cdf0e10cSrcweir 										nMarginStyle );
661cdf0e10cSrcweir 		}
662cdf0e10cSrcweir 	else
663cdf0e10cSrcweir 	{
664cdf0e10cSrcweir 		// schaltet die Anzeige aus
665cdf0e10cSrcweir 		SetMargin1();
666cdf0e10cSrcweir 		SetMargin2();
667cdf0e10cSrcweir 	}
668cdf0e10cSrcweir 	if(pColumnItem)
669cdf0e10cSrcweir 	{
670cdf0e10cSrcweir 		pRuler_Imp->nColLeftPix = (sal_uInt16) ConvertSizePixel(pColumnItem->GetLeft());
671cdf0e10cSrcweir 		pRuler_Imp->nColRightPix = (sal_uInt16) ConvertSizePixel(pColumnItem->GetRight());
672cdf0e10cSrcweir 	}
673cdf0e10cSrcweir 
674cdf0e10cSrcweir }
675cdf0e10cSrcweir 
MouseMove(const MouseEvent & rMEvt)676cdf0e10cSrcweir void SvxRuler::MouseMove( const MouseEvent& rMEvt )
677cdf0e10cSrcweir {
678cdf0e10cSrcweir 	if( bActive )
679cdf0e10cSrcweir 	{
680cdf0e10cSrcweir 		pBindings->Update( SID_RULER_LR_MIN_MAX );
681cdf0e10cSrcweir 		pBindings->Update( SID_ATTR_LONG_ULSPACE );
682cdf0e10cSrcweir 		pBindings->Update( SID_ATTR_LONG_LRSPACE );
683cdf0e10cSrcweir 		pBindings->Update( SID_RULER_PAGE_POS );
684cdf0e10cSrcweir         pBindings->Update( bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL);
685cdf0e10cSrcweir         pBindings->Update( bHorz ? SID_ATTR_PARA_LRSPACE : SID_ATTR_PARA_LRSPACE_VERTICAL);
686cdf0e10cSrcweir         pBindings->Update( bHorz ? SID_RULER_BORDERS : SID_RULER_BORDERS_VERTICAL);
687cdf0e10cSrcweir         pBindings->Update( bHorz ? SID_RULER_ROWS : SID_RULER_ROWS_VERTICAL);
688cdf0e10cSrcweir         pBindings->Update( SID_RULER_OBJECT );
689cdf0e10cSrcweir 		pBindings->Update( SID_RULER_PROTECT );
690cdf0e10cSrcweir 	}
691cdf0e10cSrcweir 	Ruler::MouseMove( rMEvt );
692cdf0e10cSrcweir }
StartListening_Impl()693cdf0e10cSrcweir void SvxRuler::StartListening_Impl()
694cdf0e10cSrcweir {
695cdf0e10cSrcweir     if(!bListening)
696cdf0e10cSrcweir 	{
697cdf0e10cSrcweir 		bValid = sal_False;
698cdf0e10cSrcweir 		StartListening(*pBindings);
699cdf0e10cSrcweir 		bListening = sal_True;
700cdf0e10cSrcweir 	}
701cdf0e10cSrcweir }
702cdf0e10cSrcweir 
UpdateFrame(const SvxLongLRSpaceItem * pItem)703cdf0e10cSrcweir void SvxRuler::UpdateFrame
704cdf0e10cSrcweir (
705cdf0e10cSrcweir  const SvxLongLRSpaceItem *pItem    // neuer Wert LRSpace
706cdf0e10cSrcweir )
707cdf0e10cSrcweir 
708cdf0e10cSrcweir /*
709cdf0e10cSrcweir    [Beschreibung]
710cdf0e10cSrcweir 
711cdf0e10cSrcweir    Neuen Wert fuer LRSpace merken; alten gfs. loeschen
712cdf0e10cSrcweir 
713cdf0e10cSrcweir */
714cdf0e10cSrcweir 
715cdf0e10cSrcweir {
716cdf0e10cSrcweir   if(bActive)
717cdf0e10cSrcweir   {
718cdf0e10cSrcweir 	delete pLRSpaceItem; pLRSpaceItem = 0;
719cdf0e10cSrcweir 	if(pItem)
720cdf0e10cSrcweir 		pLRSpaceItem = new SvxLongLRSpaceItem(*pItem);
721cdf0e10cSrcweir     StartListening_Impl();
722cdf0e10cSrcweir   }
723cdf0e10cSrcweir }
724cdf0e10cSrcweir 
725cdf0e10cSrcweir 
UpdateFrameMinMax(const SfxRectangleItem * pItem)726cdf0e10cSrcweir void SvxRuler::UpdateFrameMinMax
727cdf0e10cSrcweir (
728cdf0e10cSrcweir  const SfxRectangleItem *pItem  // Werte fuer MinMax
729cdf0e10cSrcweir )
730cdf0e10cSrcweir 
731cdf0e10cSrcweir /*
732cdf0e10cSrcweir    [Beschreibung]
733cdf0e10cSrcweir 
734cdf0e10cSrcweir    Neuen Wert fuer MinMax setzen; alten gfs. loeschen
735cdf0e10cSrcweir 
736cdf0e10cSrcweir */
737cdf0e10cSrcweir 
738cdf0e10cSrcweir {
739cdf0e10cSrcweir 	if(bActive)
740cdf0e10cSrcweir 	{
741cdf0e10cSrcweir 		delete pMinMaxItem; pMinMaxItem = 0;
742cdf0e10cSrcweir 		if(pItem)
743cdf0e10cSrcweir 			pMinMaxItem = new SfxRectangleItem(*pItem);
744cdf0e10cSrcweir 	}
745cdf0e10cSrcweir }
746cdf0e10cSrcweir 
747cdf0e10cSrcweir 
UpdateFrame(const SvxLongULSpaceItem * pItem)748cdf0e10cSrcweir void SvxRuler::UpdateFrame
749cdf0e10cSrcweir (
750cdf0e10cSrcweir  const SvxLongULSpaceItem *pItem    // neuer Wert
751cdf0e10cSrcweir )
752cdf0e10cSrcweir 
753cdf0e10cSrcweir /*
754cdf0e10cSrcweir    [Beschreibung]
755cdf0e10cSrcweir 
756cdf0e10cSrcweir    Rechten / unteren Rand aktualisieren
757cdf0e10cSrcweir 
758cdf0e10cSrcweir */
759cdf0e10cSrcweir 
760cdf0e10cSrcweir 
761cdf0e10cSrcweir {
762cdf0e10cSrcweir   if(bActive && !bHorz)
763cdf0e10cSrcweir   {
764cdf0e10cSrcweir 	delete pULSpaceItem; pULSpaceItem = 0;
765cdf0e10cSrcweir 	if(pItem)
766cdf0e10cSrcweir 		pULSpaceItem = new SvxLongULSpaceItem(*pItem);
767cdf0e10cSrcweir     StartListening_Impl();
768cdf0e10cSrcweir   }
769cdf0e10cSrcweir }
770cdf0e10cSrcweir 
Update(const SvxProtectItem * pItem)771cdf0e10cSrcweir void SvxRuler::Update( const SvxProtectItem* pItem )
772cdf0e10cSrcweir {
773cdf0e10cSrcweir 	if( pItem ) pRuler_Imp->aProtectItem = *pItem;
774cdf0e10cSrcweir }
775cdf0e10cSrcweir /* -----------------------------22.08.2002 13:10------------------------------
776cdf0e10cSrcweir 
777cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
UpdateTextRTL(const SfxBoolItem * pItem)778cdf0e10cSrcweir void SvxRuler::UpdateTextRTL(const SfxBoolItem* pItem)
779cdf0e10cSrcweir {
780cdf0e10cSrcweir   if(bActive && bHorz)
781cdf0e10cSrcweir   {
782cdf0e10cSrcweir     delete pRuler_Imp->pTextRTLItem; pRuler_Imp->pTextRTLItem = 0;
783cdf0e10cSrcweir 	if(pItem)
784cdf0e10cSrcweir         pRuler_Imp->pTextRTLItem = new SfxBoolItem(*pItem);
785cdf0e10cSrcweir     SetTextRTL(pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue());
786cdf0e10cSrcweir     StartListening_Impl();
787cdf0e10cSrcweir   }
788cdf0e10cSrcweir }
789cdf0e10cSrcweir 
Update(const SvxColumnItem * pItem,sal_uInt16 nSID)790cdf0e10cSrcweir void SvxRuler::Update
791cdf0e10cSrcweir (
792cdf0e10cSrcweir  const SvxColumnItem *pItem,             // neuer Wert
793cdf0e10cSrcweir  sal_uInt16 nSID //Slot Id to identify NULL items
794cdf0e10cSrcweir )
795cdf0e10cSrcweir 
796cdf0e10cSrcweir /*
797cdf0e10cSrcweir    [Beschreibung]
798cdf0e10cSrcweir 
799cdf0e10cSrcweir    Neuen Wert fuer Spaltendarstellung setzen
800cdf0e10cSrcweir 
801cdf0e10cSrcweir */
802cdf0e10cSrcweir 
803cdf0e10cSrcweir {
804cdf0e10cSrcweir 	if(bActive)
805cdf0e10cSrcweir 	{
806cdf0e10cSrcweir         if(pItem)
807cdf0e10cSrcweir 		{
808cdf0e10cSrcweir             delete pColumnItem; pColumnItem = 0;
809cdf0e10cSrcweir             pRuler_Imp->bIsTableRows = (pItem->Which() == SID_RULER_ROWS || pItem->Which() == SID_RULER_ROWS_VERTICAL);
810cdf0e10cSrcweir             pColumnItem = new SvxColumnItem(*pItem);
811cdf0e10cSrcweir             if(!bHorz && !pRuler_Imp->bIsTableRows)
812cdf0e10cSrcweir                 pColumnItem->SetWhich(SID_RULER_BORDERS_VERTICAL);
813cdf0e10cSrcweir 		}
814cdf0e10cSrcweir         else if(pColumnItem && pColumnItem->Which() == nSID)
815cdf0e10cSrcweir         //there are two groups of column items table/frame columns and table rows
816cdf0e10cSrcweir         //both can occur in vertical or horizontal mode
817cdf0e10cSrcweir         //the horizontal ruler handles the SID_RULER_BORDERS and SID_RULER_ROWS_VERTICAL
818cdf0e10cSrcweir         //and the vertical handles SID_RULER_BORDERS_VERTICAL and SID_RULER_ROWS
819cdf0e10cSrcweir         //if pColumnItem is already set with one of the ids then a NULL pItem argument
820cdf0e10cSrcweir         //must not delete it
821cdf0e10cSrcweir         {
822cdf0e10cSrcweir             delete pColumnItem; pColumnItem = 0;
823cdf0e10cSrcweir             pRuler_Imp->bIsTableRows = sal_False;
824cdf0e10cSrcweir         }
825cdf0e10cSrcweir         StartListening_Impl();
826cdf0e10cSrcweir     }
827cdf0e10cSrcweir }
828cdf0e10cSrcweir 
829cdf0e10cSrcweir 
UpdateColumns()830cdf0e10cSrcweir void SvxRuler::UpdateColumns()
831cdf0e10cSrcweir /*
832cdf0e10cSrcweir    [Beschreibung]
833cdf0e10cSrcweir 
834cdf0e10cSrcweir    Anzeige der Spaltendarstellung aktualisieren
835cdf0e10cSrcweir 
836cdf0e10cSrcweir */
837cdf0e10cSrcweir {
838cdf0e10cSrcweir 	if(pColumnItem && pColumnItem->Count() > 1)
839cdf0e10cSrcweir 	{
840cdf0e10cSrcweir 		if( nBorderCount < pColumnItem->Count())
841cdf0e10cSrcweir 		{
842cdf0e10cSrcweir 			delete[] pBorders;
843cdf0e10cSrcweir 			nBorderCount = pColumnItem->Count();
844cdf0e10cSrcweir 			pBorders = new RulerBorder[nBorderCount];
845cdf0e10cSrcweir 		}
846cdf0e10cSrcweir         sal_uInt16 _nFlags = RULER_BORDER_VARIABLE;
847cdf0e10cSrcweir 		sal_Bool bProtectColumns =
848cdf0e10cSrcweir 			pRuler_Imp->aProtectItem.IsSizeProtected() ||
849cdf0e10cSrcweir 			pRuler_Imp->aProtectItem.IsPosProtected();
850cdf0e10cSrcweir 		if( !bProtectColumns )
851cdf0e10cSrcweir             _nFlags |= RULER_BORDER_MOVEABLE;
852cdf0e10cSrcweir 		if( pColumnItem->IsTable() )
853cdf0e10cSrcweir             _nFlags |= RULER_BORDER_TABLE;
854cdf0e10cSrcweir 		else
855cdf0e10cSrcweir 			if ( !bProtectColumns )
856cdf0e10cSrcweir                 _nFlags |= RULER_BORDER_SIZEABLE;
857cdf0e10cSrcweir 
858cdf0e10cSrcweir 		sal_uInt16 nBorders = pColumnItem->Count();
859cdf0e10cSrcweir 		if(!pRuler_Imp->bIsTableRows)
860cdf0e10cSrcweir 			--nBorders;
861cdf0e10cSrcweir 		for(sal_uInt16 i = 0; i < nBorders; ++i)
862cdf0e10cSrcweir 		{
863cdf0e10cSrcweir             pBorders[i].nStyle = _nFlags;
864cdf0e10cSrcweir 			if(!(*pColumnItem)[i].bVisible)
865cdf0e10cSrcweir 				pBorders[i].nStyle |= RULER_STYLE_INVISIBLE;
866cdf0e10cSrcweir 			pBorders[i].nPos =
867cdf0e10cSrcweir 				ConvertPosPixel((*pColumnItem)[i].nEnd + lAppNullOffset);
868cdf0e10cSrcweir 			if(pColumnItem->Count() == i + 1)
869cdf0e10cSrcweir 			{
870cdf0e10cSrcweir 				//with table rows the end of the table is contained in the
871cdf0e10cSrcweir 				//column item but it has no width!
872cdf0e10cSrcweir 				pBorders[i].nWidth = 0;
873cdf0e10cSrcweir 			}
874cdf0e10cSrcweir 			else
875cdf0e10cSrcweir 			{
876cdf0e10cSrcweir 				pBorders[i].nWidth =
877cdf0e10cSrcweir 					ConvertSizePixel((*pColumnItem)[i+1].nStart -
878cdf0e10cSrcweir 								 (*pColumnItem)[i].nEnd);
879cdf0e10cSrcweir 			}
880cdf0e10cSrcweir             pBorders[i].nMinPos =
881cdf0e10cSrcweir                 ConvertPosPixel((*pColumnItem)[i].nEndMin + lAppNullOffset);
882cdf0e10cSrcweir             pBorders[i].nMaxPos =
883cdf0e10cSrcweir                 ConvertPosPixel((*pColumnItem)[i].nEndMax + lAppNullOffset);
884cdf0e10cSrcweir         }
885cdf0e10cSrcweir 		SetBorders(pColumnItem->Count()-1, pBorders);
886cdf0e10cSrcweir 	}
887cdf0e10cSrcweir 	else
888cdf0e10cSrcweir 	{
889cdf0e10cSrcweir 		SetBorders();
890cdf0e10cSrcweir 	}
891cdf0e10cSrcweir }
892cdf0e10cSrcweir 
893cdf0e10cSrcweir 
UpdateObject()894cdf0e10cSrcweir void SvxRuler::UpdateObject()
895cdf0e10cSrcweir 
896cdf0e10cSrcweir /*
897cdf0e10cSrcweir    [Beschreibung]
898cdf0e10cSrcweir 
899cdf0e10cSrcweir    Anzeige der Objektdarstellung aktualisieren
900cdf0e10cSrcweir 
901cdf0e10cSrcweir */
902cdf0e10cSrcweir 
903cdf0e10cSrcweir {
904cdf0e10cSrcweir 	if(pObjectItem)
905cdf0e10cSrcweir 	{
906cdf0e10cSrcweir 		DBG_ASSERT(pObjectBorders, "kein Buffer");
907cdf0e10cSrcweir 		// !! zum Seitenrand
908cdf0e10cSrcweir 		long nMargin = pLRSpaceItem? pLRSpaceItem->GetLeft(): 0;
909cdf0e10cSrcweir 		pObjectBorders[0].nPos =
910cdf0e10cSrcweir 			ConvertPosPixel(pObjectItem->GetStartX() -
911cdf0e10cSrcweir 							nMargin + lAppNullOffset);
912cdf0e10cSrcweir 		pObjectBorders[1].nPos =
913cdf0e10cSrcweir 			ConvertPosPixel(pObjectItem->GetEndX() - nMargin + lAppNullOffset);
914cdf0e10cSrcweir 		nMargin = pULSpaceItem? pULSpaceItem->GetUpper(): 0;
915cdf0e10cSrcweir 		pObjectBorders[2].nPos =
916cdf0e10cSrcweir 			ConvertPosPixel(pObjectItem->GetStartY() -
917cdf0e10cSrcweir 							nMargin + lAppNullOffset);
918cdf0e10cSrcweir 		pObjectBorders[3].nPos =
919cdf0e10cSrcweir 			ConvertPosPixel(pObjectItem->GetEndY() - nMargin + lAppNullOffset);
920cdf0e10cSrcweir 
921cdf0e10cSrcweir 		const sal_uInt16 nOff = GetObjectBordersOff(0);
922cdf0e10cSrcweir 		SetBorders(2, pObjectBorders + nOff);
923cdf0e10cSrcweir 	}
924cdf0e10cSrcweir 	else
925cdf0e10cSrcweir 	{
926cdf0e10cSrcweir 		SetBorders();
927cdf0e10cSrcweir 	}
928cdf0e10cSrcweir }
929cdf0e10cSrcweir 
930cdf0e10cSrcweir 
UpdatePara()931cdf0e10cSrcweir void SvxRuler::UpdatePara()
932cdf0e10cSrcweir 
933cdf0e10cSrcweir /*
934cdf0e10cSrcweir    [Beschreibung]
935cdf0e10cSrcweir 
936cdf0e10cSrcweir    Anzeige der Absatzeinzuege aktualisieren:
937cdf0e10cSrcweir    Linken Rand, Erstzeileneinzug, rechten Rand Absatz aktualisieren
938cdf0e10cSrcweir    pIndents[0] = Buffer fuer alten Einzug
939cdf0e10cSrcweir    pIndents[1] = Buffer fuer alten Einzug
940cdf0e10cSrcweir    pIndents[INDENT_FIRST_LINE] = Erstzeileneinzug
941cdf0e10cSrcweir    pIndents[3] = linker Rand
942cdf0e10cSrcweir    pIndents[4] = rechter Rand
943cdf0e10cSrcweir    pIndents[5] = left border distance
944cdf0e10cSrcweir    pIndents[6] = right border distance
945cdf0e10cSrcweir 
946cdf0e10cSrcweir */
947cdf0e10cSrcweir 
948cdf0e10cSrcweir {
949cdf0e10cSrcweir 	// Abhaengigkeit zu PagePosItem
950cdf0e10cSrcweir 	if(pParaItem && pPagePosItem && !pObjectItem)
951cdf0e10cSrcweir 	{
952cdf0e10cSrcweir         sal_Bool bRTLText = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
953cdf0e10cSrcweir         // Erstzeileneinzug, ist negativ zum linken Absatzrand
954cdf0e10cSrcweir         long nLeftFrameMargin = GetLeftFrameMargin();
955cdf0e10cSrcweir         long nRightFrameMargin = GetRightFrameMargin();
956cdf0e10cSrcweir         if(bRTLText)
957cdf0e10cSrcweir             pIndents[INDENT_FIRST_LINE].nPos =
958cdf0e10cSrcweir                 ConvertHPosPixel(
959cdf0e10cSrcweir                 nRightFrameMargin -
960cdf0e10cSrcweir                 pParaItem->GetTxtLeft() -
961cdf0e10cSrcweir 				pParaItem->GetTxtFirstLineOfst() + lAppNullOffset );
962cdf0e10cSrcweir         else
963cdf0e10cSrcweir             pIndents[INDENT_FIRST_LINE].nPos =
964cdf0e10cSrcweir                 ConvertHPosPixel(
965cdf0e10cSrcweir                     nLeftFrameMargin +
966cdf0e10cSrcweir                     pParaItem->GetTxtLeft() +
967cdf0e10cSrcweir                     pParaItem->GetTxtFirstLineOfst() +
968cdf0e10cSrcweir                     lAppNullOffset);
969cdf0e10cSrcweir 		if( pParaItem->IsAutoFirst() )
970cdf0e10cSrcweir             pIndents[INDENT_FIRST_LINE].nStyle |= RULER_STYLE_INVISIBLE;
971cdf0e10cSrcweir 		else
972cdf0e10cSrcweir             pIndents[INDENT_FIRST_LINE].nStyle &= ~RULER_STYLE_INVISIBLE;
973cdf0e10cSrcweir 
974cdf0e10cSrcweir         if(bRTLText)
975cdf0e10cSrcweir         {
976cdf0e10cSrcweir             // left margin
977cdf0e10cSrcweir             pIndents[INDENT_LEFT_MARGIN].nPos =
978cdf0e10cSrcweir                 ConvertHPosPixel(
979cdf0e10cSrcweir                     nRightFrameMargin -
980cdf0e10cSrcweir                     pParaItem->GetTxtLeft() + lAppNullOffset);
981cdf0e10cSrcweir             // right margin
982cdf0e10cSrcweir             pIndents[INDENT_RIGHT_MARGIN].nPos =
983cdf0e10cSrcweir                 ConvertHPosPixel(
984cdf0e10cSrcweir                     nLeftFrameMargin +
985cdf0e10cSrcweir                     pParaItem->GetRight() + lAppNullOffset);
986cdf0e10cSrcweir         }
987cdf0e10cSrcweir         else
988cdf0e10cSrcweir         {
989cdf0e10cSrcweir             // linker Rand
990cdf0e10cSrcweir             pIndents[INDENT_LEFT_MARGIN].nPos =
991cdf0e10cSrcweir                 ConvertHPosPixel(
992cdf0e10cSrcweir                     nLeftFrameMargin +
993cdf0e10cSrcweir                     pParaItem->GetTxtLeft() + lAppNullOffset);
994cdf0e10cSrcweir             // rechter Rand, immer negativ zum rechten Rand des umgebenden Frames
995cdf0e10cSrcweir             pIndents[INDENT_RIGHT_MARGIN].nPos =
996cdf0e10cSrcweir                 ConvertHPosPixel(
997cdf0e10cSrcweir                     nRightFrameMargin -
998cdf0e10cSrcweir                     pParaItem->GetRight() + lAppNullOffset);
999cdf0e10cSrcweir         }
1000cdf0e10cSrcweir         if(pParaBorderItem)
1001cdf0e10cSrcweir         {
1002cdf0e10cSrcweir             pIndents[INDENT_LEFT_BORDER].nPos =
1003cdf0e10cSrcweir             ConvertHPosPixel( nLeftFrameMargin + lAppNullOffset);
1004cdf0e10cSrcweir             pIndents[INDENT_RIGHT_BORDER].nPos =
1005cdf0e10cSrcweir                 ConvertHPosPixel(nRightFrameMargin - lAppNullOffset);
1006cdf0e10cSrcweir             pIndents[INDENT_LEFT_BORDER].nStyle = pIndents[INDENT_RIGHT_BORDER].nStyle &= ~RULER_STYLE_INVISIBLE;
1007cdf0e10cSrcweir         }
1008cdf0e10cSrcweir         else
1009cdf0e10cSrcweir             pIndents[INDENT_LEFT_BORDER].nStyle = pIndents[INDENT_RIGHT_BORDER].nStyle |= RULER_STYLE_INVISIBLE;
1010cdf0e10cSrcweir 
1011cdf0e10cSrcweir         SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
1012cdf0e10cSrcweir 	}
1013cdf0e10cSrcweir 	else
1014cdf0e10cSrcweir 	{
1015cdf0e10cSrcweir 		if(pIndents)
1016cdf0e10cSrcweir 		{
1017cdf0e10cSrcweir             pIndents[INDENT_FIRST_LINE].nPos =
1018cdf0e10cSrcweir             pIndents[INDENT_LEFT_MARGIN].nPos =
1019cdf0e10cSrcweir             pIndents[INDENT_RIGHT_MARGIN].nPos = 0;
1020cdf0e10cSrcweir 		}
1021cdf0e10cSrcweir 		SetIndents();        // ausschalten
1022cdf0e10cSrcweir 	}
1023cdf0e10cSrcweir }
1024cdf0e10cSrcweir 
1025cdf0e10cSrcweir 
UpdatePara(const SvxLRSpaceItem * pItem)1026cdf0e10cSrcweir void SvxRuler::UpdatePara
1027cdf0e10cSrcweir (
1028cdf0e10cSrcweir  const SvxLRSpaceItem *pItem    // neuer Wert Absatzeinzuege
1029cdf0e10cSrcweir )
1030cdf0e10cSrcweir 
1031cdf0e10cSrcweir /*
1032cdf0e10cSrcweir    [Beschreibung]
1033cdf0e10cSrcweir 
1034cdf0e10cSrcweir    Neuen Wert Absatzeinzuege merken
1035cdf0e10cSrcweir */
1036cdf0e10cSrcweir 
1037cdf0e10cSrcweir {
1038cdf0e10cSrcweir 	if(bActive)
1039cdf0e10cSrcweir 	{
1040cdf0e10cSrcweir 		delete pParaItem; pParaItem = 0;
1041cdf0e10cSrcweir 		if(pItem)
1042cdf0e10cSrcweir 			pParaItem = new SvxLRSpaceItem(*pItem);
1043cdf0e10cSrcweir         StartListening_Impl();
1044cdf0e10cSrcweir     }
1045cdf0e10cSrcweir }
UpdateParaBorder(const SvxLRSpaceItem * pItem)1046cdf0e10cSrcweir void SvxRuler::UpdateParaBorder(const SvxLRSpaceItem * pItem )
1047cdf0e10cSrcweir /*
1048cdf0e10cSrcweir    [Description]
1049cdf0e10cSrcweir    Border distance
1050cdf0e10cSrcweir */
1051cdf0e10cSrcweir 
1052cdf0e10cSrcweir {
1053cdf0e10cSrcweir 	if(bActive)
1054cdf0e10cSrcweir 	{
1055cdf0e10cSrcweir         delete pParaBorderItem; pParaBorderItem = 0;
1056cdf0e10cSrcweir 		if(pItem)
1057cdf0e10cSrcweir             pParaBorderItem = new SvxLRSpaceItem(*pItem);
1058cdf0e10cSrcweir         StartListening_Impl();
1059cdf0e10cSrcweir     }
1060cdf0e10cSrcweir }
1061cdf0e10cSrcweir 
1062cdf0e10cSrcweir 
UpdatePage()1063cdf0e10cSrcweir void SvxRuler::UpdatePage()
1064cdf0e10cSrcweir 
1065cdf0e10cSrcweir /*
1066cdf0e10cSrcweir    [Beschreibung]
1067cdf0e10cSrcweir 
1068cdf0e10cSrcweir    Anzeige von Postion und Breite der Seite aktualisieren
1069cdf0e10cSrcweir 
1070cdf0e10cSrcweir */
1071cdf0e10cSrcweir 
1072cdf0e10cSrcweir {
1073cdf0e10cSrcweir 	if(pPagePosItem)
1074cdf0e10cSrcweir 	{
1075cdf0e10cSrcweir 		// alle Objekte werden automatisch angepasst
1076cdf0e10cSrcweir 		if(bHorz)
1077cdf0e10cSrcweir 			SetPagePos(
1078cdf0e10cSrcweir 				pEditWin->LogicToPixel(pPagePosItem->GetPos()).X(),
1079cdf0e10cSrcweir 				pEditWin->LogicToPixel(Size(pPagePosItem->GetWidth(),0)).
1080cdf0e10cSrcweir 				Width());
1081cdf0e10cSrcweir 		else
1082cdf0e10cSrcweir 			SetPagePos(
1083cdf0e10cSrcweir 				pEditWin->LogicToPixel(pPagePosItem->GetPos()).Y(),
1084cdf0e10cSrcweir 				pEditWin->LogicToPixel(Size(0, pPagePosItem->GetHeight())).
1085cdf0e10cSrcweir 				Height());
1086cdf0e10cSrcweir 		if(bAppSetNullOffset)
1087cdf0e10cSrcweir 			SetNullOffset(ConvertSizePixel(-lAppNullOffset + lLogicNullOffset));
1088cdf0e10cSrcweir 	}
1089cdf0e10cSrcweir 	else
1090cdf0e10cSrcweir 		SetPagePos();
1091cdf0e10cSrcweir 
1092cdf0e10cSrcweir 	long lPos = 0;
1093cdf0e10cSrcweir     Point aOwnPos = GetPosPixel();
1094cdf0e10cSrcweir     Point aEdtWinPos = pEditWin->GetPosPixel();
1095cdf0e10cSrcweir     if( Application::GetSettings().GetLayoutRTL() && bHorz )
1096cdf0e10cSrcweir     {
1097cdf0e10cSrcweir         //#i73321# in RTL the window and the ruler is not mirrored but the
1098cdf0e10cSrcweir         // influence of the vertical ruler is inverted
1099cdf0e10cSrcweir         Size aOwnSize = GetSizePixel();
1100cdf0e10cSrcweir         Size aEdtWinSize = pEditWin->GetSizePixel();
1101cdf0e10cSrcweir         lPos = aOwnSize.Width() - aEdtWinSize.Width();
1102cdf0e10cSrcweir         lPos -= (aEdtWinPos - aOwnPos).X();
1103cdf0e10cSrcweir     }
1104cdf0e10cSrcweir     else
1105cdf0e10cSrcweir     {
1106cdf0e10cSrcweir         Point aPos(aEdtWinPos - aOwnPos);
1107cdf0e10cSrcweir 	    lPos= bHorz ? aPos.X() : aPos.Y();
1108cdf0e10cSrcweir     }
1109cdf0e10cSrcweir 
1110cdf0e10cSrcweir // Leider bekommen wir den Offset des Editfensters zum Lineal nie
1111cdf0e10cSrcweir // per Statusmeldung. Also setzen wir ihn selbst, wenn noetig.
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir 	if(lPos!=pRuler_Imp->lOldWinPos)
1114cdf0e10cSrcweir 	{
1115cdf0e10cSrcweir 		pRuler_Imp->lOldWinPos=lPos;
1116cdf0e10cSrcweir 		SetWinPos(lPos);
1117cdf0e10cSrcweir 	}
1118cdf0e10cSrcweir }
1119cdf0e10cSrcweir 
1120cdf0e10cSrcweir 
Update(const SvxPagePosSizeItem * pItem)1121cdf0e10cSrcweir void SvxRuler::Update
1122cdf0e10cSrcweir (
1123cdf0e10cSrcweir  const SvxPagePosSizeItem *pItem // neuer Wert Seitenattribute
1124cdf0e10cSrcweir )
1125cdf0e10cSrcweir 
1126cdf0e10cSrcweir /*
1127cdf0e10cSrcweir    [Beschreibung]
1128cdf0e10cSrcweir 
1129cdf0e10cSrcweir    Neuen Wert Seitenattribute merken
1130cdf0e10cSrcweir 
1131cdf0e10cSrcweir */
1132cdf0e10cSrcweir 
1133cdf0e10cSrcweir {
1134cdf0e10cSrcweir 	if(bActive)
1135cdf0e10cSrcweir 	{
1136cdf0e10cSrcweir 		delete pPagePosItem; pPagePosItem = 0;
1137cdf0e10cSrcweir 		if(pItem)
1138cdf0e10cSrcweir 			pPagePosItem = new SvxPagePosSizeItem(*pItem);
1139cdf0e10cSrcweir         StartListening_Impl();
1140cdf0e10cSrcweir     }
1141cdf0e10cSrcweir }
1142cdf0e10cSrcweir 
1143cdf0e10cSrcweir 
1144cdf0e10cSrcweir //
1145cdf0e10cSrcweir 
SetDefTabDist(long l)1146cdf0e10cSrcweir void SvxRuler::SetDefTabDist
1147cdf0e10cSrcweir (
1148cdf0e10cSrcweir  long l                                                 // Neuer Abstand fuer DefaultTabs in App-Metrik
1149cdf0e10cSrcweir )
1150cdf0e10cSrcweir 
1151cdf0e10cSrcweir /*
1152cdf0e10cSrcweir    [Beschreibung]
1153cdf0e10cSrcweir 
1154cdf0e10cSrcweir    Neuer Abstand fuer DefaultTabs wird gesetzt
1155cdf0e10cSrcweir 
1156cdf0e10cSrcweir */
1157cdf0e10cSrcweir 
1158cdf0e10cSrcweir {
1159cdf0e10cSrcweir 
1160cdf0e10cSrcweir 	lDefTabDist = l;
1161cdf0e10cSrcweir 	UpdateTabs();
1162cdf0e10cSrcweir }
1163cdf0e10cSrcweir 
1164cdf0e10cSrcweir 
GetDefTabDist() const1165cdf0e10cSrcweir long SvxRuler::GetDefTabDist() const
1166cdf0e10cSrcweir 
1167cdf0e10cSrcweir /*
1168cdf0e10cSrcweir    [Beschreibung]
1169cdf0e10cSrcweir 
1170cdf0e10cSrcweir    Wert fuer DefaultTabs erfragen (wird in App.-Methik geliefert)
1171cdf0e10cSrcweir 
1172cdf0e10cSrcweir */
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir {
1175cdf0e10cSrcweir 	return lDefTabDist;
1176cdf0e10cSrcweir }
1177cdf0e10cSrcweir 
1178cdf0e10cSrcweir 
ToSvTab_Impl(SvxTabAdjust eAdj)1179cdf0e10cSrcweir sal_uInt16 ToSvTab_Impl(SvxTabAdjust eAdj)
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir /*
1182cdf0e10cSrcweir    [Beschreibung]
1183cdf0e10cSrcweir 
1184cdf0e10cSrcweir    Interne Konvertierungsroutinen zwischen SV-Tab.-Enum und Svx
1185cdf0e10cSrcweir 
1186cdf0e10cSrcweir */
1187cdf0e10cSrcweir 
1188cdf0e10cSrcweir {
1189cdf0e10cSrcweir 	switch(eAdj) {
1190cdf0e10cSrcweir 	case SVX_TAB_ADJUST_LEFT:    return RULER_TAB_LEFT;
1191cdf0e10cSrcweir 	case SVX_TAB_ADJUST_RIGHT:   return RULER_TAB_RIGHT;
1192cdf0e10cSrcweir 	case SVX_TAB_ADJUST_DECIMAL: return RULER_TAB_DECIMAL;
1193cdf0e10cSrcweir 	case SVX_TAB_ADJUST_CENTER:  return RULER_TAB_CENTER;
1194cdf0e10cSrcweir 	case SVX_TAB_ADJUST_DEFAULT: return RULER_TAB_DEFAULT;
1195cdf0e10cSrcweir     default: ;//prevent warning
1196cdf0e10cSrcweir 	}
1197cdf0e10cSrcweir 	return 0;
1198cdf0e10cSrcweir }
1199cdf0e10cSrcweir 
1200cdf0e10cSrcweir 
ToAttrTab_Impl(sal_uInt16 eAdj)1201cdf0e10cSrcweir SvxTabAdjust ToAttrTab_Impl(sal_uInt16 eAdj)
1202cdf0e10cSrcweir {
1203cdf0e10cSrcweir 	switch(eAdj) {
1204cdf0e10cSrcweir 	case RULER_TAB_LEFT:    return SVX_TAB_ADJUST_LEFT    ;
1205cdf0e10cSrcweir 	case RULER_TAB_RIGHT:   return SVX_TAB_ADJUST_RIGHT   ;
1206cdf0e10cSrcweir 	case RULER_TAB_DECIMAL: return SVX_TAB_ADJUST_DECIMAL ;
1207cdf0e10cSrcweir 	case RULER_TAB_CENTER:  return SVX_TAB_ADJUST_CENTER  ;
1208cdf0e10cSrcweir 	case RULER_TAB_DEFAULT: return SVX_TAB_ADJUST_DEFAULT ;
1209cdf0e10cSrcweir 	}
1210cdf0e10cSrcweir 	return SVX_TAB_ADJUST_LEFT;
1211cdf0e10cSrcweir }
1212cdf0e10cSrcweir 
1213cdf0e10cSrcweir 
UpdateTabs()1214cdf0e10cSrcweir void SvxRuler::UpdateTabs()
1215cdf0e10cSrcweir 
1216cdf0e10cSrcweir /*
1217cdf0e10cSrcweir    [Beschreibung]
1218cdf0e10cSrcweir 
1219cdf0e10cSrcweir    Anzeige der Tabulatoren
1220cdf0e10cSrcweir 
1221cdf0e10cSrcweir */
1222cdf0e10cSrcweir 
1223cdf0e10cSrcweir {
1224cdf0e10cSrcweir 	if(IsDrag())
1225cdf0e10cSrcweir 		return;
1226cdf0e10cSrcweir 	if(pPagePosItem && pParaItem && pTabStopItem && !pObjectItem)
1227cdf0e10cSrcweir 	{
1228cdf0e10cSrcweir 		// Puffer fuer DefaultTabStop
1229cdf0e10cSrcweir 		// Abstand letzter Tab <-> Rechter Absatzrand / DefaultTabDist
1230cdf0e10cSrcweir 		sal_Bool bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
1231cdf0e10cSrcweir         long nLeftFrameMargin = GetLeftFrameMargin();
1232cdf0e10cSrcweir         long nRightFrameMargin = GetRightFrameMargin();
1233cdf0e10cSrcweir 
1234cdf0e10cSrcweir     //#i24363# tab stops relative to indent
1235cdf0e10cSrcweir         const long nParaItemTxtLeft = pParaItem->GetTxtLeft();
1236cdf0e10cSrcweir 
1237cdf0e10cSrcweir         const long lParaIndent = nLeftFrameMargin + nParaItemTxtLeft;
1238cdf0e10cSrcweir 
1239cdf0e10cSrcweir 		const long lLastTab =
1240cdf0e10cSrcweir 			 pTabStopItem->Count()?
1241cdf0e10cSrcweir 			  ConvertHPosPixel((*pTabStopItem)[pTabStopItem->Count()-1].GetTabPos()): 0;
1242cdf0e10cSrcweir 		const long lPosPixel =
1243cdf0e10cSrcweir 			ConvertHPosPixel(lParaIndent) + lLastTab;
1244cdf0e10cSrcweir 		const long lRightIndent =
1245cdf0e10cSrcweir 			ConvertHPosPixel(nRightFrameMargin - pParaItem->GetRight());
1246cdf0e10cSrcweir 		long nDefTabDist = ConvertHPosPixel(lDefTabDist);
1247cdf0e10cSrcweir 		if( !nDefTabDist )
1248cdf0e10cSrcweir 			nDefTabDist = 1;
1249cdf0e10cSrcweir 		const sal_uInt16 nDefTabBuf = lPosPixel > lRightIndent ||
1250cdf0e10cSrcweir 			lLastTab > lRightIndent
1251cdf0e10cSrcweir 				? 0
1252cdf0e10cSrcweir 				: (sal_uInt16)( (lRightIndent - lPosPixel) / nDefTabDist );
1253cdf0e10cSrcweir 
1254cdf0e10cSrcweir 		if(pTabStopItem->Count() + TAB_GAP + nDefTabBuf > nTabBufSize)
1255cdf0e10cSrcweir 		{
1256cdf0e10cSrcweir 			delete[] pTabs;
1257cdf0e10cSrcweir 			// 10 (GAP) auf Vorrat
1258cdf0e10cSrcweir 			nTabBufSize = pTabStopItem->Count() + TAB_GAP + nDefTabBuf + GAP;
1259cdf0e10cSrcweir 			pTabs = new RulerTab[nTabBufSize];
1260cdf0e10cSrcweir 		}
1261cdf0e10cSrcweir 
1262cdf0e10cSrcweir 		nTabCount = 0;
1263cdf0e10cSrcweir 		sal_uInt16 j;
1264cdf0e10cSrcweir         //#i24363# tab stops relative to indent
1265cdf0e10cSrcweir         const long lRightPixMargin = ConvertSizePixel(nRightFrameMargin - nParaItemTxtLeft );
1266cdf0e10cSrcweir 		const long lParaIndentPix = ConvertSizePixel(lParaIndent);
1267cdf0e10cSrcweir 		for(j = 0; j < pTabStopItem->Count(); ++j)
1268cdf0e10cSrcweir 		{
1269cdf0e10cSrcweir 			const SvxTabStop *pTab = &(*pTabStopItem)[j];
1270cdf0e10cSrcweir 			pTabs[nTabCount+TAB_GAP].nPos =
1271cdf0e10cSrcweir 				ConvertHPosPixel(
1272cdf0e10cSrcweir                 (pRuler_Imp->bIsTabsRelativeToIndent ? lParaIndent : 0 ) + pTab->GetTabPos() + lAppNullOffset);
1273cdf0e10cSrcweir 			if(bRTL)
1274cdf0e10cSrcweir 			{
1275cdf0e10cSrcweir 				pTabs[nTabCount+TAB_GAP].nPos = lParaIndentPix + lRightPixMargin - pTabs[nTabCount+TAB_GAP].nPos;
1276cdf0e10cSrcweir 			}
1277cdf0e10cSrcweir 			pTabs[nTabCount+TAB_GAP].nStyle = ToSvTab_Impl(pTab->GetAdjustment());
1278cdf0e10cSrcweir 			++nTabCount;
1279cdf0e10cSrcweir 		}
1280cdf0e10cSrcweir 		if(!pTabStopItem->Count())
1281cdf0e10cSrcweir 			pTabs[0].nPos = bRTL ? lRightPixMargin : lParaIndentPix;
1282cdf0e10cSrcweir 
1283cdf0e10cSrcweir 		// Rest mit Default-Tabs fuellen
1284cdf0e10cSrcweir 		if(bRTL)
1285cdf0e10cSrcweir 		{
1286cdf0e10cSrcweir 			for(j = 0; j < nDefTabBuf; ++j)
1287cdf0e10cSrcweir 			{
1288cdf0e10cSrcweir 				pTabs[nTabCount + TAB_GAP].nPos =
1289cdf0e10cSrcweir 					pTabs[nTabCount].nPos - nDefTabDist;
1290cdf0e10cSrcweir 
1291cdf0e10cSrcweir 				if(j == 0 )
1292cdf0e10cSrcweir 					pTabs[nTabCount + TAB_GAP].nPos -=
1293cdf0e10cSrcweir 						((pTabs[nTabCount + TAB_GAP].nPos - lRightPixMargin)
1294cdf0e10cSrcweir 						 % nDefTabDist );
1295cdf0e10cSrcweir 				if(pTabs[nTabCount+TAB_GAP].nPos <= lParaIndentPix)
1296cdf0e10cSrcweir 					break;
1297cdf0e10cSrcweir 				pTabs[nTabCount + TAB_GAP].nStyle = RULER_TAB_DEFAULT;
1298cdf0e10cSrcweir 				++nTabCount;
1299cdf0e10cSrcweir 			}
1300cdf0e10cSrcweir 		}
1301cdf0e10cSrcweir 		else
1302cdf0e10cSrcweir 		{
1303cdf0e10cSrcweir 			for(j = 0; j < nDefTabBuf; ++j)
1304cdf0e10cSrcweir 			{
1305cdf0e10cSrcweir 				if( j == 0 )
1306cdf0e10cSrcweir                 {
1307cdf0e10cSrcweir                     //set the first default tab stop
1308cdf0e10cSrcweir                     if(pRuler_Imp->bIsTabsRelativeToIndent)
1309cdf0e10cSrcweir                     {
1310cdf0e10cSrcweir                         pTabs[nTabCount + TAB_GAP].nPos =
1311cdf0e10cSrcweir                             (pTabs[nTabCount].nPos + nDefTabDist);
1312cdf0e10cSrcweir                         pTabs[nTabCount + TAB_GAP].nPos -=
1313cdf0e10cSrcweir                             ((pTabs[nTabCount + TAB_GAP].nPos - lParaIndentPix)
1314cdf0e10cSrcweir 						        % nDefTabDist );
1315cdf0e10cSrcweir                     }
1316cdf0e10cSrcweir                     else
1317cdf0e10cSrcweir                     {
1318cdf0e10cSrcweir                         if( pTabs[nTabCount].nPos < 0 )
1319cdf0e10cSrcweir                         {
1320cdf0e10cSrcweir                             pTabs[nTabCount + TAB_GAP].nPos = ( pTabs[nTabCount].nPos / nDefTabDist ) * nDefTabDist;
1321cdf0e10cSrcweir                         }
1322cdf0e10cSrcweir                         else
1323cdf0e10cSrcweir                         {
1324cdf0e10cSrcweir                             pTabs[nTabCount + TAB_GAP].nPos = ( pTabs[nTabCount].nPos / nDefTabDist + 1 ) * nDefTabDist;
1325cdf0e10cSrcweir                         }
1326cdf0e10cSrcweir                     }
1327cdf0e10cSrcweir 
1328cdf0e10cSrcweir                 }
1329cdf0e10cSrcweir                 else
1330cdf0e10cSrcweir                 {
1331cdf0e10cSrcweir                     //simply add the default distance to the last position
1332cdf0e10cSrcweir                     pTabs[nTabCount + TAB_GAP].nPos =
1333cdf0e10cSrcweir 					pTabs[nTabCount].nPos + nDefTabDist;
1334cdf0e10cSrcweir                 }
1335cdf0e10cSrcweir 
1336cdf0e10cSrcweir 				if(pTabs[nTabCount+TAB_GAP].nPos >= lRightIndent)
1337cdf0e10cSrcweir 					break;
1338cdf0e10cSrcweir 				pTabs[nTabCount + TAB_GAP].nStyle = RULER_TAB_DEFAULT;
1339cdf0e10cSrcweir 				++nTabCount;
1340cdf0e10cSrcweir 			}
1341cdf0e10cSrcweir 		}
1342cdf0e10cSrcweir 		SetTabs(nTabCount, pTabs+TAB_GAP);
1343cdf0e10cSrcweir 		DBG_ASSERT(nTabCount + TAB_GAP <= nTabBufSize, "BufferSize zu klein");
1344cdf0e10cSrcweir 	}
1345cdf0e10cSrcweir 	else
1346cdf0e10cSrcweir 	{
1347cdf0e10cSrcweir 		SetTabs();
1348cdf0e10cSrcweir 	}
1349cdf0e10cSrcweir }
1350cdf0e10cSrcweir 
1351cdf0e10cSrcweir 
Update(const SvxTabStopItem * pItem)1352cdf0e10cSrcweir void SvxRuler::Update
1353cdf0e10cSrcweir (
1354cdf0e10cSrcweir  const SvxTabStopItem *pItem    // Neuer Wert fuer Tabulatoren
1355cdf0e10cSrcweir )
1356cdf0e10cSrcweir 
1357cdf0e10cSrcweir /*
1358cdf0e10cSrcweir    [Beschreibung]
1359cdf0e10cSrcweir 
1360cdf0e10cSrcweir    Neuen Wert fuer Tabulatoren merken; alten gfs. loeschen
1361cdf0e10cSrcweir 
1362cdf0e10cSrcweir */
1363cdf0e10cSrcweir 
1364cdf0e10cSrcweir {
1365cdf0e10cSrcweir 	if(bActive)
1366cdf0e10cSrcweir 	{
1367cdf0e10cSrcweir 		delete pTabStopItem; pTabStopItem = 0;
1368cdf0e10cSrcweir 		if(pItem)
1369cdf0e10cSrcweir 		{
1370cdf0e10cSrcweir 			pTabStopItem = new SvxTabStopItem(*pItem);
1371cdf0e10cSrcweir 			if(!bHorz)
1372cdf0e10cSrcweir 				pTabStopItem->SetWhich(SID_ATTR_TABSTOP_VERTICAL);
1373cdf0e10cSrcweir 		}
1374cdf0e10cSrcweir         StartListening_Impl();
1375cdf0e10cSrcweir     }
1376cdf0e10cSrcweir }
1377cdf0e10cSrcweir 
1378cdf0e10cSrcweir 
Update(const SvxObjectItem * pItem)1379cdf0e10cSrcweir void SvxRuler::Update
1380cdf0e10cSrcweir (
1381cdf0e10cSrcweir  const SvxObjectItem *pItem             // Neuer Wert fuer Objekte
1382cdf0e10cSrcweir )
1383cdf0e10cSrcweir 
1384cdf0e10cSrcweir /*
1385cdf0e10cSrcweir    [Beschreibung]
1386cdf0e10cSrcweir 
1387cdf0e10cSrcweir    Neuen Wert fuer Objekte merken
1388cdf0e10cSrcweir 
1389cdf0e10cSrcweir */
1390cdf0e10cSrcweir 
1391cdf0e10cSrcweir {
1392cdf0e10cSrcweir 	if(bActive)
1393cdf0e10cSrcweir 	{
1394cdf0e10cSrcweir 		delete pObjectItem; pObjectItem = 0;
1395cdf0e10cSrcweir 		if(pItem)
1396cdf0e10cSrcweir 			pObjectItem = new SvxObjectItem(*pItem);
1397cdf0e10cSrcweir         StartListening_Impl();
1398cdf0e10cSrcweir 	}
1399cdf0e10cSrcweir }
1400cdf0e10cSrcweir 
1401cdf0e10cSrcweir 
SetNullOffsetLogic(long lVal)1402cdf0e10cSrcweir void SvxRuler::SetNullOffsetLogic
1403cdf0e10cSrcweir (
1404cdf0e10cSrcweir  long lVal                                              // Setzen des logischen NullOffsets
1405cdf0e10cSrcweir )
1406cdf0e10cSrcweir {
1407cdf0e10cSrcweir 	lAppNullOffset = lLogicNullOffset - lVal;
1408cdf0e10cSrcweir 	bAppSetNullOffset = sal_True;
1409cdf0e10cSrcweir 	Ruler::SetNullOffset(ConvertSizePixel(lVal));
1410cdf0e10cSrcweir 	Update();
1411cdf0e10cSrcweir }
1412cdf0e10cSrcweir 
1413cdf0e10cSrcweir 
Update()1414cdf0e10cSrcweir void SvxRuler::Update()
1415cdf0e10cSrcweir 
1416cdf0e10cSrcweir /*
1417cdf0e10cSrcweir    [Beschreibung]
1418cdf0e10cSrcweir 
1419cdf0e10cSrcweir    Aktualisierung der Anzeige anstossen
1420cdf0e10cSrcweir 
1421cdf0e10cSrcweir */
1422cdf0e10cSrcweir 
1423cdf0e10cSrcweir {
1424cdf0e10cSrcweir 	if(IsDrag())
1425cdf0e10cSrcweir 		return;
1426cdf0e10cSrcweir 	UpdatePage();
1427cdf0e10cSrcweir 	UpdateFrame();
1428cdf0e10cSrcweir 	if((nFlags & SVXRULER_SUPPORT_OBJECT) == SVXRULER_SUPPORT_OBJECT)
1429cdf0e10cSrcweir 		UpdateObject();
1430cdf0e10cSrcweir 	else
1431cdf0e10cSrcweir 		UpdateColumns();
1432cdf0e10cSrcweir 
1433cdf0e10cSrcweir     if(0 != (nFlags & (SVXRULER_SUPPORT_PARAGRAPH_MARGINS |SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL)))
1434cdf0e10cSrcweir 	  UpdatePara();
1435cdf0e10cSrcweir     if(0 != (nFlags & SVXRULER_SUPPORT_TABS))
1436cdf0e10cSrcweir       UpdateTabs();
1437cdf0e10cSrcweir }
1438cdf0e10cSrcweir 
1439cdf0e10cSrcweir 
GetPageWidth() const1440cdf0e10cSrcweir inline long SvxRuler::GetPageWidth() const
1441cdf0e10cSrcweir {
1442cdf0e10cSrcweir 	return bHorz ? pPagePosItem->GetWidth() : pPagePosItem->GetHeight();
1443cdf0e10cSrcweir 
1444cdf0e10cSrcweir }
1445cdf0e10cSrcweir 
1446cdf0e10cSrcweir 
GetFrameLeft() const1447cdf0e10cSrcweir inline long SvxRuler::GetFrameLeft() const
1448cdf0e10cSrcweir 
1449cdf0e10cSrcweir /*
1450cdf0e10cSrcweir    [Beschreibung]
1451cdf0e10cSrcweir 
1452cdf0e10cSrcweir    Erfragen des linken Randes in Pixeln
1453cdf0e10cSrcweir 
1454cdf0e10cSrcweir */
1455cdf0e10cSrcweir 
1456cdf0e10cSrcweir 
1457cdf0e10cSrcweir {
1458cdf0e10cSrcweir 	return  bAppSetNullOffset?
1459cdf0e10cSrcweir 			GetMargin1() + ConvertSizePixel(lLogicNullOffset):
1460cdf0e10cSrcweir 			Ruler::GetNullOffset();
1461cdf0e10cSrcweir }
1462cdf0e10cSrcweir 
SetFrameLeft(long l)1463cdf0e10cSrcweir inline void SvxRuler::SetFrameLeft(long l)
1464cdf0e10cSrcweir 
1465cdf0e10cSrcweir /*
1466cdf0e10cSrcweir    [Beschreibung]
1467cdf0e10cSrcweir 
1468cdf0e10cSrcweir    Setzen des linken Randes in Pixeln
1469cdf0e10cSrcweir 
1470cdf0e10cSrcweir */
1471cdf0e10cSrcweir 
1472cdf0e10cSrcweir {
1473cdf0e10cSrcweir 	sal_Bool bProtectColumns =
1474cdf0e10cSrcweir 		pRuler_Imp->aProtectItem.IsSizeProtected() ||
1475cdf0e10cSrcweir 		pRuler_Imp->aProtectItem.IsPosProtected();
1476cdf0e10cSrcweir 	if(bAppSetNullOffset)
1477cdf0e10cSrcweir 		SetMargin1(l - ConvertSizePixel(lLogicNullOffset),
1478cdf0e10cSrcweir 				   bProtectColumns ? 0 : RULER_MARGIN_SIZEABLE);
1479cdf0e10cSrcweir 	else
1480cdf0e10cSrcweir 		Ruler::SetNullOffset(l);
1481cdf0e10cSrcweir }
1482cdf0e10cSrcweir 
1483cdf0e10cSrcweir 
GetFirstLineIndent() const1484cdf0e10cSrcweir long SvxRuler::GetFirstLineIndent() const
1485cdf0e10cSrcweir 
1486cdf0e10cSrcweir /*
1487cdf0e10cSrcweir    [Beschreibung]
1488cdf0e10cSrcweir 
1489cdf0e10cSrcweir    Erstzeileneinzug in Pixels erfragen
1490cdf0e10cSrcweir */
1491cdf0e10cSrcweir 
1492cdf0e10cSrcweir {
1493cdf0e10cSrcweir     return pParaItem? pIndents[INDENT_FIRST_LINE].nPos: GetMargin1();
1494cdf0e10cSrcweir }
1495cdf0e10cSrcweir 
1496cdf0e10cSrcweir 
GetLeftIndent() const1497cdf0e10cSrcweir long SvxRuler::GetLeftIndent() const
1498cdf0e10cSrcweir 
1499cdf0e10cSrcweir /*
1500cdf0e10cSrcweir    [Beschreibung]
1501cdf0e10cSrcweir 
1502cdf0e10cSrcweir    Linken Absatzrand in Pixels erfragen
1503cdf0e10cSrcweir */
1504cdf0e10cSrcweir 
1505cdf0e10cSrcweir {
1506cdf0e10cSrcweir     return pParaItem? pIndents[INDENT_LEFT_MARGIN].nPos: GetMargin1();
1507cdf0e10cSrcweir }
1508cdf0e10cSrcweir 
1509cdf0e10cSrcweir 
1510cdf0e10cSrcweir 
GetRightIndent() const1511cdf0e10cSrcweir long SvxRuler::GetRightIndent() const
1512cdf0e10cSrcweir 
1513cdf0e10cSrcweir /*
1514cdf0e10cSrcweir    [Beschreibung]
1515cdf0e10cSrcweir 
1516cdf0e10cSrcweir    Rechten Absatzrand in Pixels erfragen
1517cdf0e10cSrcweir */
1518cdf0e10cSrcweir 
1519cdf0e10cSrcweir {
1520cdf0e10cSrcweir     return pParaItem? pIndents[INDENT_RIGHT_MARGIN].nPos: GetMargin2();
1521cdf0e10cSrcweir }
1522cdf0e10cSrcweir 
1523cdf0e10cSrcweir 
GetLogicRightIndent() const1524cdf0e10cSrcweir long SvxRuler::GetLogicRightIndent() const
1525cdf0e10cSrcweir 
1526cdf0e10cSrcweir /*
1527cdf0e10cSrcweir    [Beschreibung]
1528cdf0e10cSrcweir 
1529cdf0e10cSrcweir    Rechten Absatzrand in Logic erfragen
1530cdf0e10cSrcweir */
1531cdf0e10cSrcweir 
1532cdf0e10cSrcweir {
1533cdf0e10cSrcweir 	return pParaItem ? GetRightFrameMargin()-pParaItem->GetRight() : GetRightFrameMargin();
1534cdf0e10cSrcweir }
1535cdf0e10cSrcweir 
1536cdf0e10cSrcweir // linker Rand in App-Werten; ist entweder der Seitenrand (=0)
1537cdf0e10cSrcweir // oder der linke Rand der Spalte, die im Spaltenattribut als
1538cdf0e10cSrcweir // altuelle Spalte eingestellt ist.
1539cdf0e10cSrcweir 
GetLeftFrameMargin() const1540cdf0e10cSrcweir long SvxRuler::GetLeftFrameMargin() const
1541cdf0e10cSrcweir {
1542cdf0e10cSrcweir     // #126721# for some unknown reason the current column is set to 0xffff
1543cdf0e10cSrcweir     DBG_ASSERT(!pColumnItem || pColumnItem->GetActColumn() < pColumnItem->Count(),
1544cdf0e10cSrcweir                     "issue #126721# - invalid current column!");
1545cdf0e10cSrcweir     long nLeft =
1546cdf0e10cSrcweir         pColumnItem && pColumnItem->Count() && pColumnItem->GetActColumn() < pColumnItem->Count() ?
1547cdf0e10cSrcweir         (*pColumnItem)[pColumnItem->GetActColumn()].nStart : 0;
1548cdf0e10cSrcweir     if(pParaBorderItem && (!pColumnItem || pColumnItem->IsTable()))
1549cdf0e10cSrcweir         nLeft += pParaBorderItem->GetLeft();
1550cdf0e10cSrcweir     return nLeft;
1551cdf0e10cSrcweir }
1552cdf0e10cSrcweir 
GetLeftMin() const1553cdf0e10cSrcweir inline long SvxRuler::GetLeftMin() const
1554cdf0e10cSrcweir {
1555cdf0e10cSrcweir 	DBG_ASSERT(pMinMaxItem, "kein MinMax-Wert gesetzt");
1556cdf0e10cSrcweir 	return pMinMaxItem?
1557cdf0e10cSrcweir 		bHorz? 	pMinMaxItem->GetValue().Left(): pMinMaxItem->GetValue().Top()
1558cdf0e10cSrcweir 				: 0;
1559cdf0e10cSrcweir }
1560cdf0e10cSrcweir 
GetRightMax() const1561cdf0e10cSrcweir inline long SvxRuler::GetRightMax() const
1562cdf0e10cSrcweir {
1563cdf0e10cSrcweir 	DBG_ASSERT(pMinMaxItem, "kein MinMax-Wert gesetzt");
1564cdf0e10cSrcweir 	return pMinMaxItem?
1565cdf0e10cSrcweir 		bHorz? pMinMaxItem->GetValue().Right(): pMinMaxItem->GetValue().Bottom()
1566cdf0e10cSrcweir 			: 0;
1567cdf0e10cSrcweir }
1568cdf0e10cSrcweir 
1569cdf0e10cSrcweir 
GetRightFrameMargin() const1570cdf0e10cSrcweir long SvxRuler::GetRightFrameMargin() const
1571cdf0e10cSrcweir 
1572cdf0e10cSrcweir /*
1573cdf0e10cSrcweir    [Beschreibung]
1574cdf0e10cSrcweir 
1575cdf0e10cSrcweir    Rechten umgebenden Rand erfragen (in logischen Einheiten)
1576cdf0e10cSrcweir 
1577cdf0e10cSrcweir */
1578cdf0e10cSrcweir 
1579cdf0e10cSrcweir {
1580cdf0e10cSrcweir 	if(pColumnItem)
1581cdf0e10cSrcweir 	{
1582cdf0e10cSrcweir 		if(!IsActLastColumn( sal_True ))
1583cdf0e10cSrcweir 		{
1584cdf0e10cSrcweir 			long nRet = (*pColumnItem)[GetActRightColumn( sal_True )].nEnd;
1585cdf0e10cSrcweir 			if(pColumnItem->IsTable() && pParaBorderItem)
1586cdf0e10cSrcweir 				nRet -= pParaBorderItem->GetRight();
1587cdf0e10cSrcweir 			return nRet;
1588cdf0e10cSrcweir 		}
1589cdf0e10cSrcweir 	}
1590cdf0e10cSrcweir 
1591cdf0e10cSrcweir 	long l = lLogicNullOffset;
1592cdf0e10cSrcweir 
1593cdf0e10cSrcweir 	// gfs. rechten Tabelleneinzug abziehen
1594cdf0e10cSrcweir 	if(pColumnItem && pColumnItem->IsTable())
1595cdf0e10cSrcweir 		l += pColumnItem->GetRight();
1596cdf0e10cSrcweir     else if(bHorz && pLRSpaceItem)
1597cdf0e10cSrcweir 		l += pLRSpaceItem->GetRight();
1598cdf0e10cSrcweir     else if(!bHorz && pULSpaceItem)
1599cdf0e10cSrcweir         l += pULSpaceItem->GetLower();
1600cdf0e10cSrcweir 
1601cdf0e10cSrcweir     if(pParaBorderItem &&
1602cdf0e10cSrcweir         (!pColumnItem || pColumnItem->IsTable()||IsActLastColumn( sal_True )))
1603cdf0e10cSrcweir         l += pParaBorderItem->GetRight();
1604cdf0e10cSrcweir 
1605cdf0e10cSrcweir     if(bHorz)
1606cdf0e10cSrcweir         l = pPagePosItem->GetWidth() - l;
1607cdf0e10cSrcweir 	else
1608cdf0e10cSrcweir         l = pPagePosItem->GetHeight() - l;
1609cdf0e10cSrcweir     return l;
1610cdf0e10cSrcweir }
1611cdf0e10cSrcweir 
1612cdf0e10cSrcweir #define NEG_FLAG ( (nFlags & SVXRULER_SUPPORT_NEGATIVE_MARGINS) == \
1613cdf0e10cSrcweir 				   SVXRULER_SUPPORT_NEGATIVE_MARGINS )
1614cdf0e10cSrcweir #define TAB_FLAG ( pColumnItem && pColumnItem->IsTable() )
1615cdf0e10cSrcweir 
GetCorrectedDragPos(sal_Bool bLeft,sal_Bool bRight)1616cdf0e10cSrcweir long SvxRuler::GetCorrectedDragPos( sal_Bool bLeft, sal_Bool bRight )
1617cdf0e10cSrcweir 
1618cdf0e10cSrcweir /*
1619cdf0e10cSrcweir    [Beschreibung]
1620cdf0e10cSrcweir 
1621cdf0e10cSrcweir    Korrigiert die Position innerhalb der errechneten Grenzwerte.
1622cdf0e10cSrcweir    Die Grenzwerte sind in Pixel relativ zum Seitenrand.
1623cdf0e10cSrcweir 
1624cdf0e10cSrcweir */
1625cdf0e10cSrcweir 
1626cdf0e10cSrcweir {
1627cdf0e10cSrcweir 	const long lNullPix = Ruler::GetNullOffset();
1628cdf0e10cSrcweir 	long lDragPos = GetDragPos() + lNullPix;
1629cdf0e10cSrcweir ADD_DEBUG_TEXT("lDragPos: ", String::CreateFromInt32(lDragPos))
1630cdf0e10cSrcweir  	sal_Bool bHoriRows = bHorz && pRuler_Imp->bIsTableRows;
1631cdf0e10cSrcweir 	if((bLeft || (bHoriRows)) && lDragPos < nMaxLeft)
1632cdf0e10cSrcweir 		lDragPos = nMaxLeft;
1633cdf0e10cSrcweir 	else if((bRight||bHoriRows) && lDragPos > nMaxRight)
1634cdf0e10cSrcweir 		lDragPos = nMaxRight;
1635cdf0e10cSrcweir 	return lDragPos - lNullPix;
1636cdf0e10cSrcweir }
1637cdf0e10cSrcweir 
1638cdf0e10cSrcweir 
1639cdf0e10cSrcweir 
ModifyTabs_Impl(sal_uInt16 nCount,RulerTab * pTabs,long lDiff)1640cdf0e10cSrcweir void ModifyTabs_Impl
1641cdf0e10cSrcweir (
1642cdf0e10cSrcweir  sal_uInt16 nCount,                                 // Anzahl Tabs
1643cdf0e10cSrcweir  RulerTab *pTabs,                               // Tab-Puffer
1644cdf0e10cSrcweir  long lDiff                                     // zu addierende Differenz
1645cdf0e10cSrcweir  )
1646cdf0e10cSrcweir 
1647cdf0e10cSrcweir /*
1648cdf0e10cSrcweir    [Beschreibung]
1649cdf0e10cSrcweir 
1650cdf0e10cSrcweir    Hilfsroutine; alle Tabs um einen festen Wert verschieben
1651cdf0e10cSrcweir 
1652cdf0e10cSrcweir */
1653cdf0e10cSrcweir {
1654cdf0e10cSrcweir 	if( pTabs )
1655cdf0e10cSrcweir 		for(sal_uInt16 i = 0; i < nCount; ++i)	pTabs[i].nPos += lDiff;
1656cdf0e10cSrcweir }
1657cdf0e10cSrcweir 
1658cdf0e10cSrcweir 
1659cdf0e10cSrcweir 
DragMargin1()1660cdf0e10cSrcweir void SvxRuler::DragMargin1()
1661cdf0e10cSrcweir 
1662cdf0e10cSrcweir /*
1663cdf0e10cSrcweir    [Beschreibung]
1664cdf0e10cSrcweir 
1665cdf0e10cSrcweir    Draggen des linken Frame-Randes
1666cdf0e10cSrcweir 
1667cdf0e10cSrcweir */
1668cdf0e10cSrcweir {
1669cdf0e10cSrcweir 	const long lDragPos = GetCorrectedDragPos( !TAB_FLAG || !NEG_FLAG, sal_True );
1670cdf0e10cSrcweir 	DrawLine_Impl(lTabPos, ( TAB_FLAG && NEG_FLAG ) ? 3 : 7, bHorz);
1671cdf0e10cSrcweir     if(pColumnItem&&
1672cdf0e10cSrcweir 	   (//nDragType & DRAG_OBJECT_SIZE_LINEAR ||
1673cdf0e10cSrcweir 		nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL))
1674cdf0e10cSrcweir 		DragBorders();
1675cdf0e10cSrcweir     AdjustMargin1(lDragPos);
1676cdf0e10cSrcweir }
AdjustMargin1(long lDiff)1677cdf0e10cSrcweir void SvxRuler::AdjustMargin1(long lDiff)
1678cdf0e10cSrcweir {
1679cdf0e10cSrcweir     const long nOld = bAppSetNullOffset? GetMargin1(): GetNullOffset();
1680cdf0e10cSrcweir     const long lDragPos = lDiff;
1681cdf0e10cSrcweir     sal_Bool bProtectColumns =
1682cdf0e10cSrcweir 		pRuler_Imp->aProtectItem.IsSizeProtected() ||
1683cdf0e10cSrcweir 		pRuler_Imp->aProtectItem.IsPosProtected();
1684cdf0e10cSrcweir 
1685cdf0e10cSrcweir 	const sal_uInt16 nMarginStyle =
1686cdf0e10cSrcweir 		bProtectColumns ? 0 : RULER_MARGIN_SIZEABLE;
1687cdf0e10cSrcweir 
1688cdf0e10cSrcweir 	if(!bAppSetNullOffset)
1689cdf0e10cSrcweir 	{
1690cdf0e10cSrcweir         long _lDiff = lDragPos;
1691cdf0e10cSrcweir         SetNullOffset(nOld + _lDiff);
1692cdf0e10cSrcweir 		if(!pColumnItem||!(nDragType & DRAG_OBJECT_SIZE_LINEAR))
1693cdf0e10cSrcweir 		{
1694cdf0e10cSrcweir             SetMargin2( GetMargin2() - _lDiff, nMarginStyle );
1695cdf0e10cSrcweir 
1696cdf0e10cSrcweir 			if(!pColumnItem && !pObjectItem && pParaItem)
1697cdf0e10cSrcweir 			{
1698cdf0e10cSrcweir 				// Rechten Einzug an alter Position
1699cdf0e10cSrcweir                 pIndents[INDENT_RIGHT_MARGIN].nPos -= _lDiff;
1700cdf0e10cSrcweir                 SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
1701cdf0e10cSrcweir 			}
1702cdf0e10cSrcweir 			if(pObjectItem)
1703cdf0e10cSrcweir 			{
1704cdf0e10cSrcweir                 pObjectBorders[GetObjectBordersOff(0)].nPos -= _lDiff;
1705cdf0e10cSrcweir                 pObjectBorders[GetObjectBordersOff(1)].nPos -= _lDiff;
1706cdf0e10cSrcweir 				SetBorders(2, pObjectBorders + GetObjectBordersOff(0));
1707cdf0e10cSrcweir 			}
1708cdf0e10cSrcweir 			if(pColumnItem)
1709cdf0e10cSrcweir 			{
1710cdf0e10cSrcweir 				for(sal_uInt16 i = 0; i < pColumnItem->Count()-1; ++i)
1711cdf0e10cSrcweir                     pBorders[i].nPos -= _lDiff;
1712cdf0e10cSrcweir 				SetBorders(pColumnItem->Count()-1, pBorders);
1713cdf0e10cSrcweir 				if(pColumnItem->IsFirstAct())
1714cdf0e10cSrcweir 				{
1715cdf0e10cSrcweir 					// Rechten Einzug an alter Position
1716cdf0e10cSrcweir 					if(pParaItem)
1717cdf0e10cSrcweir 					{
1718cdf0e10cSrcweir                         pIndents[INDENT_RIGHT_MARGIN].nPos -= _lDiff;
1719cdf0e10cSrcweir                         SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
1720cdf0e10cSrcweir 					}
1721cdf0e10cSrcweir 				}
1722cdf0e10cSrcweir 				else
1723cdf0e10cSrcweir 				{
1724cdf0e10cSrcweir 					if(pParaItem)
1725cdf0e10cSrcweir 					{
1726cdf0e10cSrcweir                         pIndents[INDENT_FIRST_LINE].nPos -= _lDiff;
1727cdf0e10cSrcweir                         pIndents[INDENT_LEFT_MARGIN].nPos -= _lDiff;
1728cdf0e10cSrcweir                         pIndents[INDENT_RIGHT_MARGIN].nPos -= _lDiff;
1729cdf0e10cSrcweir                         SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
1730cdf0e10cSrcweir 					}
1731cdf0e10cSrcweir 				}
1732cdf0e10cSrcweir 				if(pTabStopItem&& (nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
1733cdf0e10cSrcweir 				   &&!IsActFirstColumn())
1734cdf0e10cSrcweir 				{
1735cdf0e10cSrcweir                     ModifyTabs_Impl(nTabCount+TAB_GAP, pTabs, -_lDiff);
1736cdf0e10cSrcweir 					SetTabs(nTabCount, pTabs+TAB_GAP);
1737cdf0e10cSrcweir 				}
1738cdf0e10cSrcweir 			}
1739cdf0e10cSrcweir 		}
1740cdf0e10cSrcweir 	}
1741cdf0e10cSrcweir 	else
1742cdf0e10cSrcweir 	{
1743cdf0e10cSrcweir         long _lDiff = lDragPos - nOld;
1744cdf0e10cSrcweir         SetMargin1(nOld + _lDiff, nMarginStyle );
1745cdf0e10cSrcweir 
1746cdf0e10cSrcweir 		if(!pColumnItem||!(nDragType & (DRAG_OBJECT_SIZE_LINEAR |
1747cdf0e10cSrcweir 										DRAG_OBJECT_SIZE_PROPORTIONAL)))
1748cdf0e10cSrcweir 		{
1749cdf0e10cSrcweir 			if(!pColumnItem && !pObjectItem && pParaItem)
1750cdf0e10cSrcweir 			{
1751cdf0e10cSrcweir 				// Linke Einzuege an alter Position
1752cdf0e10cSrcweir                 pIndents[INDENT_FIRST_LINE].nPos += _lDiff;
1753cdf0e10cSrcweir                 pIndents[INDENT_LEFT_MARGIN].nPos += _lDiff;
1754cdf0e10cSrcweir                 SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
1755cdf0e10cSrcweir 			}
1756cdf0e10cSrcweir 
1757cdf0e10cSrcweir 			if(pColumnItem)
1758cdf0e10cSrcweir 			{
1759cdf0e10cSrcweir 				for(sal_uInt16 i = 0; i < pColumnItem->Count()-1; ++i)
1760cdf0e10cSrcweir                     pBorders[i].nPos += _lDiff;
1761cdf0e10cSrcweir 				SetBorders(pColumnItem->Count()-1, pBorders);
1762cdf0e10cSrcweir 				if(pColumnItem->IsFirstAct())
1763cdf0e10cSrcweir 				{
1764cdf0e10cSrcweir 					// Linke Einzuege an alter Position
1765cdf0e10cSrcweir 					if(pParaItem)
1766cdf0e10cSrcweir 					{
1767cdf0e10cSrcweir                         pIndents[INDENT_FIRST_LINE].nPos += _lDiff;
1768cdf0e10cSrcweir                         pIndents[INDENT_LEFT_MARGIN].nPos += _lDiff;
1769cdf0e10cSrcweir                         SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
1770cdf0e10cSrcweir 					}
1771cdf0e10cSrcweir 				}
1772cdf0e10cSrcweir 				else
1773cdf0e10cSrcweir 				{
1774cdf0e10cSrcweir 					if(pParaItem)
1775cdf0e10cSrcweir 					{
1776cdf0e10cSrcweir                         pIndents[INDENT_FIRST_LINE].nPos += _lDiff;
1777cdf0e10cSrcweir                         pIndents[INDENT_LEFT_MARGIN].nPos += _lDiff;
1778cdf0e10cSrcweir                         pIndents[INDENT_RIGHT_MARGIN].nPos += _lDiff;
1779cdf0e10cSrcweir                         SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
1780cdf0e10cSrcweir 					}
1781cdf0e10cSrcweir 				}
1782cdf0e10cSrcweir 			}
1783cdf0e10cSrcweir 			if(pTabStopItem)
1784cdf0e10cSrcweir 			{
1785cdf0e10cSrcweir                 ModifyTabs_Impl(nTabCount+TAB_GAP, pTabs, _lDiff);
1786cdf0e10cSrcweir 				SetTabs(nTabCount, pTabs+TAB_GAP);
1787cdf0e10cSrcweir 			}
1788cdf0e10cSrcweir 		}
1789cdf0e10cSrcweir 	}
1790cdf0e10cSrcweir }
1791cdf0e10cSrcweir 
1792cdf0e10cSrcweir 
DragMargin2()1793cdf0e10cSrcweir void SvxRuler::DragMargin2()
1794cdf0e10cSrcweir /*
1795cdf0e10cSrcweir    [Beschreibung]
1796cdf0e10cSrcweir 
1797cdf0e10cSrcweir    Draggen des rechten Frame-Randes
1798cdf0e10cSrcweir 
1799cdf0e10cSrcweir */
1800cdf0e10cSrcweir {
1801cdf0e10cSrcweir 	const long lDragPos = GetCorrectedDragPos( sal_True, !TAB_FLAG || !NEG_FLAG);
1802cdf0e10cSrcweir 	DrawLine_Impl(lTabPos, ( TAB_FLAG && NEG_FLAG ) ? 5 : 7, bHorz);
1803cdf0e10cSrcweir 	long lDiff = lDragPos - GetMargin2();
1804cdf0e10cSrcweir 
1805cdf0e10cSrcweir 	if(pRuler_Imp->bIsTableRows && !bHorz && pColumnItem&&
1806cdf0e10cSrcweir 	   (//nDragType & DRAG_OBJECT_SIZE_LINEAR ||
1807cdf0e10cSrcweir 		nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL))
1808cdf0e10cSrcweir 		DragBorders();
1809cdf0e10cSrcweir 
1810cdf0e10cSrcweir 	sal_Bool bProtectColumns =
1811cdf0e10cSrcweir 		pRuler_Imp->aProtectItem.IsSizeProtected() ||
1812cdf0e10cSrcweir 		pRuler_Imp->aProtectItem.IsPosProtected();
1813cdf0e10cSrcweir 	const sal_uInt16 nMarginStyle =
1814cdf0e10cSrcweir 		bProtectColumns ? 0 : RULER_MARGIN_SIZEABLE;
1815cdf0e10cSrcweir 	SetMargin2( lDragPos, nMarginStyle );
1816cdf0e10cSrcweir 
1817cdf0e10cSrcweir 	// Rechten Einzug an alter Position
1818cdf0e10cSrcweir 	if((!pColumnItem || IsActLastColumn()) && pParaItem)
1819cdf0e10cSrcweir 	{
1820cdf0e10cSrcweir         pIndents[INDENT_FIRST_LINE].nPos += lDiff;
1821cdf0e10cSrcweir         SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
1822cdf0e10cSrcweir 	}
1823cdf0e10cSrcweir }
1824cdf0e10cSrcweir 
1825cdf0e10cSrcweir 
DragIndents()1826cdf0e10cSrcweir void SvxRuler::DragIndents()
1827cdf0e10cSrcweir /*
1828cdf0e10cSrcweir    [Beschreibung]
1829cdf0e10cSrcweir 
1830cdf0e10cSrcweir    Draggen der Absatzeinzuege
1831cdf0e10cSrcweir 
1832cdf0e10cSrcweir */
1833cdf0e10cSrcweir {
1834cdf0e10cSrcweir 	const long lDragPos = NEG_FLAG ? GetDragPos() : GetCorrectedDragPos();
1835cdf0e10cSrcweir 	const sal_uInt16 nIdx = GetDragAryPos()+INDENT_GAP;
1836cdf0e10cSrcweir 	const long lDiff = pIndents[nIdx].nPos - lDragPos;
1837cdf0e10cSrcweir 
1838cdf0e10cSrcweir 	if((nIdx == INDENT_FIRST_LINE ||
1839cdf0e10cSrcweir             nIdx == INDENT_LEFT_MARGIN )  &&
1840cdf0e10cSrcweir 		(nDragType & DRAG_OBJECT_LEFT_INDENT_ONLY) !=
1841cdf0e10cSrcweir         DRAG_OBJECT_LEFT_INDENT_ONLY)
1842cdf0e10cSrcweir         pIndents[INDENT_FIRST_LINE].nPos -= lDiff;
1843cdf0e10cSrcweir 
1844cdf0e10cSrcweir 	pIndents[nIdx].nPos = lDragPos;
1845cdf0e10cSrcweir 
1846cdf0e10cSrcweir     SetIndents(INDENT_COUNT, pIndents + INDENT_GAP);
1847cdf0e10cSrcweir 	DrawLine_Impl(lTabPos, 1, bHorz);
1848cdf0e10cSrcweir }
1849cdf0e10cSrcweir 
1850cdf0e10cSrcweir 
DrawLine_Impl(long & _lTabPos,int nNew,sal_Bool Hori)1851cdf0e10cSrcweir void SvxRuler::DrawLine_Impl(long &_lTabPos, int nNew, sal_Bool Hori)
1852cdf0e10cSrcweir /*
1853cdf0e10cSrcweir    [Beschreibung]
1854cdf0e10cSrcweir 
1855cdf0e10cSrcweir    Ausgaberoutine fuer Hilfslinie beim Vereschieben von Tabs, Tabellen-
1856cdf0e10cSrcweir    und anderen Spalten
1857cdf0e10cSrcweir 
1858cdf0e10cSrcweir */
1859cdf0e10cSrcweir {
1860cdf0e10cSrcweir 	if(Hori)
1861cdf0e10cSrcweir 	{
1862cdf0e10cSrcweir 		const long nHeight = pEditWin->GetOutputSize().Height();
1863cdf0e10cSrcweir 		Point aZero=pEditWin->GetMapMode().GetOrigin();
1864cdf0e10cSrcweir         if(_lTabPos!=-1)
1865cdf0e10cSrcweir 			pEditWin->InvertTracking(
1866cdf0e10cSrcweir                 Rectangle( Point(_lTabPos, -aZero.Y()),
1867cdf0e10cSrcweir                            Point(_lTabPos, -aZero.Y()+nHeight)),
1868cdf0e10cSrcweir 				SHOWTRACK_SPLIT | SHOWTRACK_CLIP );
1869cdf0e10cSrcweir 		if( nNew & 1 )
1870cdf0e10cSrcweir 		{
1871cdf0e10cSrcweir 
1872cdf0e10cSrcweir             _lTabPos = ConvertHSizeLogic(
1873cdf0e10cSrcweir                 GetCorrectedDragPos( ( nNew&4 ) != 0, ( nNew&2 ) != 0 ) +
1874cdf0e10cSrcweir                 GetNullOffset() );
1875cdf0e10cSrcweir 			if(pPagePosItem)
1876cdf0e10cSrcweir                 _lTabPos += pPagePosItem->GetPos().X();
1877cdf0e10cSrcweir 			pEditWin->InvertTracking(
1878cdf0e10cSrcweir                 Rectangle(Point(_lTabPos, -aZero.Y()),
1879cdf0e10cSrcweir                           Point(_lTabPos, -aZero.Y()+nHeight)),
1880cdf0e10cSrcweir 				SHOWTRACK_CLIP | SHOWTRACK_SPLIT );
1881cdf0e10cSrcweir 		}
1882cdf0e10cSrcweir 	}
1883cdf0e10cSrcweir 	else
1884cdf0e10cSrcweir 	{
1885cdf0e10cSrcweir 		const long nWidth = pEditWin->GetOutputSize().Width();
1886cdf0e10cSrcweir 		Point aZero=pEditWin->GetMapMode().GetOrigin();
1887cdf0e10cSrcweir         if(_lTabPos != -1)
1888cdf0e10cSrcweir 		{
1889cdf0e10cSrcweir 			pEditWin->InvertTracking(
1890cdf0e10cSrcweir                 Rectangle( Point(-aZero.X(), _lTabPos),
1891cdf0e10cSrcweir                            Point(-aZero.X()+nWidth, _lTabPos)),
1892cdf0e10cSrcweir 				SHOWTRACK_SPLIT | SHOWTRACK_CLIP );
1893cdf0e10cSrcweir 		}
1894cdf0e10cSrcweir 
1895cdf0e10cSrcweir 		if(nNew & 1)
1896cdf0e10cSrcweir 		{
1897cdf0e10cSrcweir             _lTabPos = ConvertVSizeLogic(GetCorrectedDragPos()+GetNullOffset());
1898cdf0e10cSrcweir 			if(pPagePosItem)
1899cdf0e10cSrcweir                 _lTabPos += pPagePosItem->GetPos().Y();
1900cdf0e10cSrcweir 			pEditWin->InvertTracking(
1901cdf0e10cSrcweir                 Rectangle( Point(-aZero.X(), _lTabPos),
1902cdf0e10cSrcweir                            Point(-aZero.X()+nWidth, _lTabPos)),
1903cdf0e10cSrcweir 				SHOWTRACK_CLIP | SHOWTRACK_SPLIT );
1904cdf0e10cSrcweir 		}
1905cdf0e10cSrcweir 	}
1906cdf0e10cSrcweir }
1907cdf0e10cSrcweir 
1908cdf0e10cSrcweir 
1909cdf0e10cSrcweir 
1910cdf0e10cSrcweir 
DragTabs()1911cdf0e10cSrcweir void SvxRuler::DragTabs()
1912cdf0e10cSrcweir 
1913cdf0e10cSrcweir /*
1914cdf0e10cSrcweir    [Beschreibung]
1915cdf0e10cSrcweir 
1916cdf0e10cSrcweir    Draggen von Tabs
1917cdf0e10cSrcweir 
1918cdf0e10cSrcweir */
1919cdf0e10cSrcweir {
1920cdf0e10cSrcweir 
1921cdf0e10cSrcweir 	long lDragPos = GetCorrectedDragPos(sal_True, sal_False);
1922cdf0e10cSrcweir 
1923cdf0e10cSrcweir 	sal_uInt16 nIdx = GetDragAryPos()+TAB_GAP;
1924cdf0e10cSrcweir 	DrawLine_Impl(lTabPos, 7, bHorz);
1925cdf0e10cSrcweir 
1926cdf0e10cSrcweir 	long nDiff = lDragPos - pTabs[nIdx].nPos;
1927cdf0e10cSrcweir 
1928cdf0e10cSrcweir 	if(nDragType & DRAG_OBJECT_SIZE_LINEAR)
1929cdf0e10cSrcweir 	{
1930cdf0e10cSrcweir 
1931cdf0e10cSrcweir 		for(sal_uInt16 i = nIdx; i < nTabCount; ++i)
1932cdf0e10cSrcweir 		{
1933cdf0e10cSrcweir 			pTabs[i].nPos += nDiff;
1934cdf0e10cSrcweir 			// auf Maximum begrenzen
1935cdf0e10cSrcweir 			if(pTabs[i].nPos > GetMargin2())
1936cdf0e10cSrcweir 				pTabs[nIdx].nStyle |= RULER_STYLE_INVISIBLE;
1937cdf0e10cSrcweir 			else
1938cdf0e10cSrcweir 				pTabs[nIdx].nStyle &= ~RULER_STYLE_INVISIBLE;
1939cdf0e10cSrcweir 		}
1940cdf0e10cSrcweir 	}
1941cdf0e10cSrcweir 	else if(nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
1942cdf0e10cSrcweir 	{
1943cdf0e10cSrcweir 		pRuler_Imp->nTotalDist -= nDiff;
1944cdf0e10cSrcweir 		pTabs[nIdx].nPos = lDragPos;
1945cdf0e10cSrcweir 		for(sal_uInt16 i = nIdx+1; i < nTabCount; ++i)
1946cdf0e10cSrcweir 		{
1947cdf0e10cSrcweir 			if(pTabs[i].nStyle & RULER_TAB_DEFAULT)
1948cdf0e10cSrcweir 				// bei den DefaultTabs kann abgebrochen werden
1949cdf0e10cSrcweir 				break;
1950cdf0e10cSrcweir 			long nDelta = pRuler_Imp->nTotalDist * pRuler_Imp->pPercBuf[i];
1951cdf0e10cSrcweir 			nDelta /= 1000;
1952cdf0e10cSrcweir 			pTabs[i].nPos = pTabs[nIdx].nPos + nDelta;
1953cdf0e10cSrcweir 			if(pTabs[i].nPos+GetNullOffset() > nMaxRight)
1954cdf0e10cSrcweir 				pTabs[i].nStyle |= RULER_STYLE_INVISIBLE;
1955cdf0e10cSrcweir 			else
1956cdf0e10cSrcweir 				pTabs[i].nStyle &= ~RULER_STYLE_INVISIBLE;
1957cdf0e10cSrcweir 		}
1958cdf0e10cSrcweir 	}
1959cdf0e10cSrcweir 	else
1960cdf0e10cSrcweir 		pTabs[nIdx].nPos = lDragPos;
1961cdf0e10cSrcweir 
1962cdf0e10cSrcweir 	if(IsDragDelete())
1963cdf0e10cSrcweir 		pTabs[nIdx].nStyle |= RULER_STYLE_INVISIBLE;
1964cdf0e10cSrcweir 	else
1965cdf0e10cSrcweir 		pTabs[nIdx].nStyle &= ~RULER_STYLE_INVISIBLE;
1966cdf0e10cSrcweir 	SetTabs(nTabCount, pTabs+TAB_GAP);
1967cdf0e10cSrcweir }
1968cdf0e10cSrcweir 
1969cdf0e10cSrcweir 
1970cdf0e10cSrcweir 
SetActive(sal_Bool bOn)1971cdf0e10cSrcweir void SvxRuler::SetActive(sal_Bool bOn)
1972cdf0e10cSrcweir {
1973cdf0e10cSrcweir 	if(bOn)
1974cdf0e10cSrcweir 	{
1975cdf0e10cSrcweir 		Activate();
1976cdf0e10cSrcweir /*		pBindings->Invalidate( SID_RULER_LR_MIN_MAX, sal_True, sal_True );
1977cdf0e10cSrcweir 		pBindings->Update( SID_RULER_LR_MIN_MAX );
1978cdf0e10cSrcweir 		pBindings->Invalidate( SID_ATTR_LONG_ULSPACE, sal_True, sal_True );
1979cdf0e10cSrcweir 		pBindings->Update( SID_ATTR_LONG_ULSPACE );
1980cdf0e10cSrcweir 		pBindings->Invalidate( SID_ATTR_LONG_LRSPACE, sal_True, sal_True );
1981cdf0e10cSrcweir 		pBindings->Update( SID_ATTR_LONG_LRSPACE );
1982cdf0e10cSrcweir 		pBindings->Invalidate( SID_RULER_PAGE_POS, sal_True, sal_True );
1983cdf0e10cSrcweir 		pBindings->Update( SID_RULER_PAGE_POS );
1984cdf0e10cSrcweir 		pBindings->Invalidate( SID_ATTR_TABSTOP, sal_True, sal_True );
1985cdf0e10cSrcweir 		pBindings->Update( SID_ATTR_TABSTOP );
1986cdf0e10cSrcweir 		pBindings->Invalidate( SID_ATTR_PARA_LRSPACE, sal_True, sal_True );
1987cdf0e10cSrcweir 		pBindings->Update( SID_ATTR_PARA_LRSPACE );
1988cdf0e10cSrcweir 		pBindings->Invalidate( SID_RULER_BORDERS, sal_True, sal_True );
1989cdf0e10cSrcweir 		pBindings->Update( SID_RULER_BORDERS );
1990cdf0e10cSrcweir 		pBindings->Invalidate( SID_RULER_OBJECT, sal_True, sal_True );
1991cdf0e10cSrcweir 		pBindings->Update( SID_RULER_OBJECT );
1992cdf0e10cSrcweir 		pBindings->Invalidate( SID_RULER_PROTECT, sal_True, sal_True );
1993cdf0e10cSrcweir 		pBindings->Update( SID_RULER_PROTECT );*/
1994cdf0e10cSrcweir 	}
1995cdf0e10cSrcweir 	else
1996cdf0e10cSrcweir 		Deactivate();
1997cdf0e10cSrcweir 	if(bActive!=bOn)
1998cdf0e10cSrcweir 	{
1999cdf0e10cSrcweir 		pBindings->EnterRegistrations();
2000cdf0e10cSrcweir 		if(bOn)
2001cdf0e10cSrcweir 			for(sal_uInt16 i=0;i<pRuler_Imp->nControlerItems;i++)
2002cdf0e10cSrcweir 				pCtrlItem[i]->ReBind();
2003cdf0e10cSrcweir 		else
2004cdf0e10cSrcweir 			for(sal_uInt16 j=0;j<pRuler_Imp->nControlerItems;j++)
2005cdf0e10cSrcweir 				pCtrlItem[j]->UnBind();
2006cdf0e10cSrcweir 		pBindings->LeaveRegistrations();
2007cdf0e10cSrcweir 	}
2008cdf0e10cSrcweir 	bActive = bOn;
2009cdf0e10cSrcweir }
2010cdf0e10cSrcweir 
2011cdf0e10cSrcweir 
2012cdf0e10cSrcweir 
2013cdf0e10cSrcweir 
UpdateParaContents_Impl(long l,UpdateType eType)2014cdf0e10cSrcweir void SvxRuler::UpdateParaContents_Impl
2015cdf0e10cSrcweir (
2016cdf0e10cSrcweir  long l,                                                // Differenz
2017cdf0e10cSrcweir  UpdateType eType                               // Art (alle, links oder rechts)
2018cdf0e10cSrcweir )
2019cdf0e10cSrcweir 
2020cdf0e10cSrcweir /*
2021cdf0e10cSrcweir    [Beschreibung]
2022cdf0e10cSrcweir 
2023cdf0e10cSrcweir    Hilfsroutine; Mitfuehren von Tabulatoren und Absatzraendern
2024cdf0e10cSrcweir 
2025cdf0e10cSrcweir */
2026cdf0e10cSrcweir {
2027cdf0e10cSrcweir 	switch(eType) {
2028cdf0e10cSrcweir 	case MOVE_RIGHT:
2029cdf0e10cSrcweir         pIndents[INDENT_RIGHT_MARGIN].nPos += l;
2030cdf0e10cSrcweir 		break;
2031cdf0e10cSrcweir 	case MOVE_ALL:
2032cdf0e10cSrcweir         pIndents[INDENT_RIGHT_MARGIN].nPos += l;
2033cdf0e10cSrcweir 		// no break
2034cdf0e10cSrcweir 	case MOVE_LEFT:
2035cdf0e10cSrcweir 		{
2036cdf0e10cSrcweir             pIndents[INDENT_FIRST_LINE].nPos += l;
2037cdf0e10cSrcweir             pIndents[INDENT_LEFT_MARGIN].nPos += l;
2038cdf0e10cSrcweir 			if ( pTabs )
2039cdf0e10cSrcweir 			{
2040cdf0e10cSrcweir 				for(sal_uInt16 i = 0; i < nTabCount+TAB_GAP;++i)
2041cdf0e10cSrcweir 					pTabs[i].nPos += l;
2042cdf0e10cSrcweir 				SetTabs(nTabCount, pTabs+TAB_GAP);
2043cdf0e10cSrcweir 			}
2044cdf0e10cSrcweir 			break;
2045cdf0e10cSrcweir 		}
2046cdf0e10cSrcweir 	}
2047cdf0e10cSrcweir     SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
2048cdf0e10cSrcweir }
2049cdf0e10cSrcweir 
2050cdf0e10cSrcweir 
2051cdf0e10cSrcweir 
DragBorders()2052cdf0e10cSrcweir void SvxRuler::DragBorders()
2053cdf0e10cSrcweir 
2054cdf0e10cSrcweir /*
2055cdf0e10cSrcweir    [Beschreibung]
2056cdf0e10cSrcweir 
2057cdf0e10cSrcweir    Draggen von Borders (Tabellen- und anderen Spalten)
2058cdf0e10cSrcweir 
2059cdf0e10cSrcweir */
2060cdf0e10cSrcweir {
2061cdf0e10cSrcweir 	sal_Bool bLeftIndentsCorrected = sal_False, bRightIndentsCorrected = sal_False;
2062cdf0e10cSrcweir 	int nIdx;
2063cdf0e10cSrcweir 
2064cdf0e10cSrcweir 	if(GetDragType()==RULER_TYPE_BORDER)
2065cdf0e10cSrcweir 	{
2066cdf0e10cSrcweir 		DrawLine_Impl(lTabPos, 7, bHorz);
2067cdf0e10cSrcweir 		nIdx = GetDragAryPos();
2068cdf0e10cSrcweir 	}
2069cdf0e10cSrcweir 	else
2070cdf0e10cSrcweir 		nIdx=0;
2071cdf0e10cSrcweir 
2072cdf0e10cSrcweir 	sal_uInt16 nDragSize = GetDragSize();
2073cdf0e10cSrcweir 	long lDiff = 0;
2074cdf0e10cSrcweir 
2075cdf0e10cSrcweir 	// the drag position has to be corrected to be able to prevent borders from passing each other
2076cdf0e10cSrcweir 	long lPos = GetCorrectedDragPos();
2077cdf0e10cSrcweir 
2078cdf0e10cSrcweir 
2079cdf0e10cSrcweir 	switch(nDragSize)
2080cdf0e10cSrcweir 	{
2081cdf0e10cSrcweir 	  case RULER_DRAGSIZE_MOVE:
2082cdf0e10cSrcweir 		{
2083cdf0e10cSrcweir ADD_DEBUG_TEXT("lLastLMargin: ", String::CreateFromInt32(pRuler_Imp->lLastLMargin))
2084cdf0e10cSrcweir             lDiff = GetDragType()==RULER_TYPE_BORDER ?
2085cdf0e10cSrcweir 				lPos-nDragOffset - pBorders[nIdx].nPos
2086cdf0e10cSrcweir 				: GetDragType() == RULER_TYPE_MARGIN1 ? lPos - pRuler_Imp->lLastLMargin : lPos - pRuler_Imp->lLastRMargin;
2087cdf0e10cSrcweir 
2088cdf0e10cSrcweir //			pBorders[nIdx].nPos += lDiff;
2089cdf0e10cSrcweir //			lDiff = pBorders[nIdx].nPos - nOld;
2090cdf0e10cSrcweir 			if(nDragType & DRAG_OBJECT_SIZE_LINEAR)
2091cdf0e10cSrcweir 			{
2092cdf0e10cSrcweir 				long nRight = GetMargin2()-lMinFrame; // rechter Begrenzer
2093cdf0e10cSrcweir 				for(int i = nBorderCount-2; i >= nIdx; --i)
2094cdf0e10cSrcweir 				{
2095cdf0e10cSrcweir 					long l = pBorders[i].nPos;
2096cdf0e10cSrcweir 					pBorders[i].nPos += lDiff;
2097cdf0e10cSrcweir 					pBorders[i].nPos = Min(pBorders[i].nPos, nRight - pBorders[i].nWidth);
2098cdf0e10cSrcweir 					nRight = pBorders[i].nPos - lMinFrame;
2099cdf0e10cSrcweir 					// RR der Spalte aktualisieren
2100cdf0e10cSrcweir 					if(i == GetActRightColumn())
2101cdf0e10cSrcweir 					{
2102cdf0e10cSrcweir 						UpdateParaContents_Impl(pBorders[i].nPos - l, MOVE_RIGHT);
2103cdf0e10cSrcweir 						bRightIndentsCorrected = sal_True;
2104cdf0e10cSrcweir 					}
2105cdf0e10cSrcweir 					// LAR, EZE der Spalte aktualisieren
2106cdf0e10cSrcweir 					else if(i == GetActLeftColumn())
2107cdf0e10cSrcweir 					{
2108cdf0e10cSrcweir 						UpdateParaContents_Impl(pBorders[i].nPos - l, MOVE_LEFT);
2109cdf0e10cSrcweir 						bLeftIndentsCorrected = sal_True;
2110cdf0e10cSrcweir 					}
2111cdf0e10cSrcweir 				}
2112cdf0e10cSrcweir 			}
2113cdf0e10cSrcweir 			else if(nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
2114cdf0e10cSrcweir 			{
2115cdf0e10cSrcweir 				int nLimit;
2116cdf0e10cSrcweir 				long lLeft;
2117cdf0e10cSrcweir 				int nStartLimit = nBorderCount-2;
2118cdf0e10cSrcweir 				switch(GetDragType())
2119cdf0e10cSrcweir 				{
2120cdf0e10cSrcweir                 default: ;//prevent warning
2121cdf0e10cSrcweir 					DBG_ERROR("svx::SvxRuler::DragBorders(), unknown drag type!" );
2122cdf0e10cSrcweir 				case RULER_TYPE_BORDER:
2123cdf0e10cSrcweir 					if(pRuler_Imp->bIsTableRows)
2124cdf0e10cSrcweir 					{
2125cdf0e10cSrcweir 						pBorders[nIdx].nPos += lDiff;
2126cdf0e10cSrcweir 						if(bHorz)
2127cdf0e10cSrcweir 						{
2128cdf0e10cSrcweir 							lLeft = pBorders[nIdx].nPos;
2129cdf0e10cSrcweir 							pRuler_Imp->nTotalDist -= lDiff;
2130cdf0e10cSrcweir 							nLimit=nIdx+1;
2131cdf0e10cSrcweir 						}
2132cdf0e10cSrcweir 						else
2133cdf0e10cSrcweir 						{
2134cdf0e10cSrcweir 							lLeft = 0;
2135cdf0e10cSrcweir 							nStartLimit = nIdx - 1;
2136cdf0e10cSrcweir 							pRuler_Imp->nTotalDist += lDiff;
2137cdf0e10cSrcweir 							nLimit = 0;
2138cdf0e10cSrcweir 						}
2139cdf0e10cSrcweir 					}
2140cdf0e10cSrcweir 					else
2141cdf0e10cSrcweir 					{
2142cdf0e10cSrcweir 						nLimit=nIdx+1;
2143cdf0e10cSrcweir 						pBorders[nIdx].nPos += lDiff;
2144cdf0e10cSrcweir 						lLeft = pBorders[nIdx].nPos;
2145cdf0e10cSrcweir 						pRuler_Imp->nTotalDist-=lDiff;
2146cdf0e10cSrcweir 					}
2147cdf0e10cSrcweir 				break;
2148cdf0e10cSrcweir 				case RULER_TYPE_MARGIN1:
2149cdf0e10cSrcweir 					nLimit=0;
2150cdf0e10cSrcweir 					lLeft=pRuler_Imp->lLastLMargin+lDiff;
2151cdf0e10cSrcweir 					pRuler_Imp->nTotalDist-=lDiff;
2152cdf0e10cSrcweir 				break;
2153cdf0e10cSrcweir 				case RULER_TYPE_MARGIN2:
2154cdf0e10cSrcweir 					nLimit = 0;
2155cdf0e10cSrcweir 					lLeft= 0;//pRuler_Imp->lLastRMargin + lDiff;
2156cdf0e10cSrcweir 					nStartLimit = nBorderCount - 2;
2157cdf0e10cSrcweir 					pRuler_Imp->nTotalDist += lDiff;
2158cdf0e10cSrcweir 				break;
2159cdf0e10cSrcweir 				}
2160cdf0e10cSrcweir 
2161cdf0e10cSrcweir                 for(int i  = nStartLimit; i >= nLimit; --i)
2162cdf0e10cSrcweir 				{
2163cdf0e10cSrcweir 
2164cdf0e10cSrcweir 					long l = pBorders[i].nPos;
2165cdf0e10cSrcweir 					pBorders[i].nPos=lLeft+
2166cdf0e10cSrcweir 						(pRuler_Imp->nTotalDist*pRuler_Imp->pPercBuf[i])/1000+
2167cdf0e10cSrcweir 							pRuler_Imp->pBlockBuf[i];
2168cdf0e10cSrcweir 
2169cdf0e10cSrcweir 					// RR der Spalte aktualisieren
2170cdf0e10cSrcweir 					if(!pRuler_Imp->bIsTableRows)
2171cdf0e10cSrcweir 					{
2172cdf0e10cSrcweir 						if(i == GetActRightColumn())
2173cdf0e10cSrcweir 						{
2174cdf0e10cSrcweir 							UpdateParaContents_Impl(pBorders[i].nPos - l, MOVE_RIGHT);
2175cdf0e10cSrcweir 							bRightIndentsCorrected = sal_True;
2176cdf0e10cSrcweir 						}
2177cdf0e10cSrcweir 						// LAR, EZE der Spalte aktualisieren
2178cdf0e10cSrcweir 						else if(i == GetActLeftColumn())
2179cdf0e10cSrcweir 						{
2180cdf0e10cSrcweir 							UpdateParaContents_Impl(pBorders[i].nPos - l, MOVE_LEFT);
2181cdf0e10cSrcweir 							bLeftIndentsCorrected = sal_True;
2182cdf0e10cSrcweir 						}
2183cdf0e10cSrcweir 					}
2184cdf0e10cSrcweir 				}
2185cdf0e10cSrcweir 				if(pRuler_Imp->bIsTableRows)
2186cdf0e10cSrcweir 				{
2187cdf0e10cSrcweir 					//in vertical tables the left borders have to be moved
2188cdf0e10cSrcweir 					if(bHorz)
2189cdf0e10cSrcweir 					{
2190cdf0e10cSrcweir 						for(int i  = 0; i < nIdx; ++i)
2191cdf0e10cSrcweir 							pBorders[i].nPos += lDiff;
2192cdf0e10cSrcweir                         AdjustMargin1(lDiff);
2193cdf0e10cSrcweir 					}
2194cdf0e10cSrcweir 					else
2195cdf0e10cSrcweir 					{
2196cdf0e10cSrcweir 						//otherwise the right borders are moved
2197cdf0e10cSrcweir 						for(int i  = pColumnItem->Count() - 1; i > nIdx; --i)
2198cdf0e10cSrcweir 							pBorders[i].nPos += lDiff;
2199cdf0e10cSrcweir 						SetMargin2( GetMargin2() + lDiff, 0 );
2200cdf0e10cSrcweir 					}
2201cdf0e10cSrcweir 				}
2202cdf0e10cSrcweir 			}
2203cdf0e10cSrcweir             else if(pRuler_Imp->bIsTableRows)
2204cdf0e10cSrcweir             {
2205cdf0e10cSrcweir                 //moving rows: if a row is resized all following rows
2206cdf0e10cSrcweir                 //have to be moved by the same amount.
2207cdf0e10cSrcweir                 //This includes the left border when the table is not limited
2208cdf0e10cSrcweir                 //to a lower frame border.
2209cdf0e10cSrcweir                 int nLimit;
2210cdf0e10cSrcweir                 long lLeft;
2211cdf0e10cSrcweir                 if(GetDragType()==RULER_TYPE_BORDER)
2212cdf0e10cSrcweir                 {
2213cdf0e10cSrcweir                     nLimit=nIdx+1;
2214cdf0e10cSrcweir                     lLeft=(pBorders[nIdx].nPos+=lDiff);
2215cdf0e10cSrcweir                 }
2216cdf0e10cSrcweir                 else
2217cdf0e10cSrcweir                 {
2218cdf0e10cSrcweir                     nLimit=0;
2219cdf0e10cSrcweir                     lLeft=pRuler_Imp->lLastLMargin+lDiff;
2220cdf0e10cSrcweir                 }
2221cdf0e10cSrcweir 				//in vertical tables the left borders have to be moved
2222cdf0e10cSrcweir 				if(bHorz)
2223cdf0e10cSrcweir 				{
2224cdf0e10cSrcweir 					for(int i  = 0; i < nIdx; ++i)
2225cdf0e10cSrcweir 					{
2226cdf0e10cSrcweir 						pBorders[i].nPos += lDiff;
2227cdf0e10cSrcweir 					}
2228cdf0e10cSrcweir                     AdjustMargin1(lDiff);
2229cdf0e10cSrcweir 				}
2230cdf0e10cSrcweir 				else
2231cdf0e10cSrcweir 				{
2232cdf0e10cSrcweir 					//otherwise the right borders are moved
2233cdf0e10cSrcweir 					for(int i  = nBorderCount-2; i >= nLimit; --i)
2234cdf0e10cSrcweir 					{
2235cdf0e10cSrcweir 						pBorders[i].nPos += lDiff;
2236cdf0e10cSrcweir 					}
2237cdf0e10cSrcweir 					SetMargin2( GetMargin2() + lDiff, 0 );
2238cdf0e10cSrcweir 				}
2239cdf0e10cSrcweir             }
2240cdf0e10cSrcweir 			else
2241cdf0e10cSrcweir 				pBorders[nIdx].nPos+=lDiff;
2242cdf0e10cSrcweir 			break;
2243cdf0e10cSrcweir 		}
2244cdf0e10cSrcweir 	  case RULER_DRAGSIZE_1:
2245cdf0e10cSrcweir 		{
2246cdf0e10cSrcweir 			lDiff = lPos - pBorders[nIdx].nPos;
2247cdf0e10cSrcweir 			pBorders[nIdx].nWidth += pBorders[nIdx].nPos - lPos;
2248cdf0e10cSrcweir 			pBorders[nIdx].nPos = lPos;
2249cdf0e10cSrcweir 			break;
2250cdf0e10cSrcweir 		}
2251cdf0e10cSrcweir 	  case RULER_DRAGSIZE_2:
2252cdf0e10cSrcweir 		{
2253cdf0e10cSrcweir 			const long nOld = pBorders[nIdx].nWidth;
2254cdf0e10cSrcweir 			pBorders[nIdx].nWidth = lPos - pBorders[nIdx].nPos;
2255cdf0e10cSrcweir 			lDiff = pBorders[nIdx].nWidth - nOld;
2256cdf0e10cSrcweir 			break;
2257cdf0e10cSrcweir 		}
2258cdf0e10cSrcweir 	}
2259cdf0e10cSrcweir 	if(!bRightIndentsCorrected &&
2260cdf0e10cSrcweir 	   GetActRightColumn() == nIdx &&
2261cdf0e10cSrcweir 	   nDragSize != RULER_DRAGSIZE_2 && pIndents &&
2262cdf0e10cSrcweir 	   !pRuler_Imp->bIsTableRows)
2263cdf0e10cSrcweir 	{
2264cdf0e10cSrcweir 		UpdateParaContents_Impl(lDiff, MOVE_RIGHT);
2265cdf0e10cSrcweir 	}
2266cdf0e10cSrcweir 	else if(!bLeftIndentsCorrected &&
2267cdf0e10cSrcweir 			GetActLeftColumn()==nIdx &&
2268cdf0e10cSrcweir 			nDragSize != RULER_DRAGSIZE_1 && pIndents)
2269cdf0e10cSrcweir 	{
2270cdf0e10cSrcweir 		UpdateParaContents_Impl(lDiff, MOVE_LEFT);
2271cdf0e10cSrcweir 	}
2272cdf0e10cSrcweir 	SetBorders(pColumnItem->Count()-1, pBorders);
2273cdf0e10cSrcweir }
2274cdf0e10cSrcweir 
2275cdf0e10cSrcweir 
DragObjectBorder()2276cdf0e10cSrcweir void SvxRuler::DragObjectBorder()
2277cdf0e10cSrcweir 
2278cdf0e10cSrcweir /*
2279cdf0e10cSrcweir    [Beschreibung]
2280cdf0e10cSrcweir 
2281cdf0e10cSrcweir    Draggen von Objektraendern
2282cdf0e10cSrcweir 
2283cdf0e10cSrcweir */
2284cdf0e10cSrcweir {
2285cdf0e10cSrcweir 	if(RULER_DRAGSIZE_MOVE == GetDragSize())
2286cdf0e10cSrcweir 	{
2287cdf0e10cSrcweir 		const long lPos = GetCorrectedDragPos();
2288cdf0e10cSrcweir 		const sal_uInt16 nIdx = GetDragAryPos();
2289cdf0e10cSrcweir 		pObjectBorders[GetObjectBordersOff(nIdx)].nPos = lPos;
2290cdf0e10cSrcweir 		SetBorders(2, pObjectBorders + GetObjectBordersOff(0));
2291cdf0e10cSrcweir 		DrawLine_Impl(lTabPos, 7, bHorz);
2292cdf0e10cSrcweir 
2293cdf0e10cSrcweir 	}
2294cdf0e10cSrcweir }
2295cdf0e10cSrcweir 
2296cdf0e10cSrcweir 
ApplyMargins()2297cdf0e10cSrcweir void SvxRuler::ApplyMargins()
2298cdf0e10cSrcweir /*
2299cdf0e10cSrcweir    [Beschreibung]
2300cdf0e10cSrcweir 
2301cdf0e10cSrcweir    Anwenden von Randeinstellungen; durch Draggen veraendert.
2302cdf0e10cSrcweir 
2303cdf0e10cSrcweir */
2304cdf0e10cSrcweir {
2305cdf0e10cSrcweir 	const SfxPoolItem *pItem = 0;
2306cdf0e10cSrcweir 	sal_uInt16 nId = SID_ATTR_LONG_LRSPACE;
2307cdf0e10cSrcweir 	if(bHorz)
2308cdf0e10cSrcweir 	{
2309cdf0e10cSrcweir 		const long lOldNull = lLogicNullOffset;
2310cdf0e10cSrcweir 		if(pRuler_Imp->lMaxLeftLogic!=-1&&nMaxLeft==GetMargin1()+Ruler::GetNullOffset())
2311cdf0e10cSrcweir 			pLRSpaceItem->SetLeft(lLogicNullOffset=pRuler_Imp->lMaxLeftLogic);
2312cdf0e10cSrcweir 		else
2313cdf0e10cSrcweir 			pLRSpaceItem->SetLeft(PixelHAdjust(
2314cdf0e10cSrcweir 				lLogicNullOffset =	ConvertHPosLogic(GetFrameLeft()) -
2315cdf0e10cSrcweir 				lAppNullOffset,	pLRSpaceItem->GetLeft()));
2316cdf0e10cSrcweir 
2317cdf0e10cSrcweir 		if(bAppSetNullOffset)
2318cdf0e10cSrcweir 			lAppNullOffset += lLogicNullOffset - lOldNull;
2319cdf0e10cSrcweir 
2320cdf0e10cSrcweir 		if(pRuler_Imp->lMaxRightLogic!=-1
2321cdf0e10cSrcweir 		   &&nMaxRight==GetMargin2()+Ruler::GetNullOffset())
2322cdf0e10cSrcweir 			pLRSpaceItem->SetRight(GetPageWidth()-pRuler_Imp->lMaxRightLogic);
2323cdf0e10cSrcweir 		else
2324cdf0e10cSrcweir 			pLRSpaceItem->SetRight(
2325cdf0e10cSrcweir 				PixelHAdjust(
2326cdf0e10cSrcweir 					Max((long)0,pPagePosItem->GetWidth() -
2327cdf0e10cSrcweir 						pLRSpaceItem->GetLeft() -
2328cdf0e10cSrcweir 						(ConvertHPosLogic(GetMargin2()) -
2329cdf0e10cSrcweir 						 lAppNullOffset)),pLRSpaceItem->GetRight()));
2330cdf0e10cSrcweir 		pItem = pLRSpaceItem;
2331cdf0e10cSrcweir #ifdef DEBUGLIN
2332cdf0e10cSrcweir 		Debug_Impl(pEditWin,*pLRSpaceItem);
2333cdf0e10cSrcweir #endif // DEBUGLIN
2334cdf0e10cSrcweir 	}
2335cdf0e10cSrcweir 	else {
2336cdf0e10cSrcweir 		const long lOldNull = lLogicNullOffset;
2337cdf0e10cSrcweir 		pULSpaceItem->SetUpper(
2338cdf0e10cSrcweir 			PixelVAdjust(
2339cdf0e10cSrcweir 				lLogicNullOffset =
2340cdf0e10cSrcweir 				ConvertVPosLogic(GetFrameLeft()) -
2341cdf0e10cSrcweir 				lAppNullOffset,pULSpaceItem->GetUpper()));
2342cdf0e10cSrcweir 		if(bAppSetNullOffset)
2343cdf0e10cSrcweir 			lAppNullOffset += lLogicNullOffset - lOldNull;
2344cdf0e10cSrcweir 		pULSpaceItem->SetLower(
2345cdf0e10cSrcweir 			PixelVAdjust(
2346cdf0e10cSrcweir 				Max((long)0, pPagePosItem->GetHeight() -
2347cdf0e10cSrcweir 					pULSpaceItem->GetUpper() -
2348cdf0e10cSrcweir 					(ConvertVPosLogic(GetMargin2()) -
2349cdf0e10cSrcweir 					 lAppNullOffset)),pULSpaceItem->GetLower()));
2350cdf0e10cSrcweir 		pItem = pULSpaceItem;
2351cdf0e10cSrcweir 		nId = SID_ATTR_LONG_ULSPACE;
2352cdf0e10cSrcweir #ifdef DEBUGLIN
2353cdf0e10cSrcweir 		Debug_Impl(pEditWin,*pULSpaceItem);
2354cdf0e10cSrcweir #endif // DEBUGLIN
2355cdf0e10cSrcweir 	}
2356cdf0e10cSrcweir 	pBindings->GetDispatcher()->Execute( nId, SFX_CALLMODE_RECORD, pItem, 0L );
2357cdf0e10cSrcweir 	if(pTabStopItem)
2358cdf0e10cSrcweir 		UpdateTabs();
2359cdf0e10cSrcweir }
2360cdf0e10cSrcweir 
2361cdf0e10cSrcweir 
ApplyIndents()2362cdf0e10cSrcweir void SvxRuler::ApplyIndents()
2363cdf0e10cSrcweir /*
2364cdf0e10cSrcweir    [Beschreibung]
2365cdf0e10cSrcweir 
2366cdf0e10cSrcweir    Anwenden von Absatzeinstellungen; durch Draggen veraendert.
2367cdf0e10cSrcweir 
2368cdf0e10cSrcweir */
2369cdf0e10cSrcweir {
2370cdf0e10cSrcweir 	long nNewTxtLeft;
2371cdf0e10cSrcweir 	if(pColumnItem&&!IsActFirstColumn( sal_True ))
2372cdf0e10cSrcweir 	{
2373cdf0e10cSrcweir 		long nLeftCol=GetActLeftColumn( sal_True );
2374cdf0e10cSrcweir 		nNewTxtLeft =
2375cdf0e10cSrcweir 			PixelHAdjust(
2376cdf0e10cSrcweir 				ConvertHPosLogic(
2377cdf0e10cSrcweir                     pIndents[INDENT_LEFT_MARGIN].nPos-
2378cdf0e10cSrcweir 					(pBorders[nLeftCol].nPos +
2379cdf0e10cSrcweir 					 pBorders[nLeftCol].nWidth))-
2380cdf0e10cSrcweir 				lAppNullOffset,pParaItem->GetTxtLeft());
2381cdf0e10cSrcweir 	}
2382cdf0e10cSrcweir 	else
2383cdf0e10cSrcweir 		nNewTxtLeft =
2384cdf0e10cSrcweir 			PixelHAdjust(
2385cdf0e10cSrcweir                 ConvertHPosLogic(pIndents[INDENT_LEFT_MARGIN].nPos),
2386cdf0e10cSrcweir 				pParaItem->GetTxtLeft());
2387cdf0e10cSrcweir 
2388cdf0e10cSrcweir     sal_Bool bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
2389cdf0e10cSrcweir 
2390cdf0e10cSrcweir 	long nNewFirstLineOffset;
2391cdf0e10cSrcweir 	if(bRTL)
2392cdf0e10cSrcweir 	{
2393cdf0e10cSrcweir 		long nRightFrameMargin = GetRightFrameMargin();
2394cdf0e10cSrcweir 		nNewFirstLineOffset = 	PixelHAdjust(nRightFrameMargin -
2395cdf0e10cSrcweir 				ConvertHPosLogic(pIndents[INDENT_FIRST_LINE].nPos ) -
2396cdf0e10cSrcweir 				lAppNullOffset,
2397cdf0e10cSrcweir 				pParaItem->GetTxtFirstLineOfst());
2398cdf0e10cSrcweir 	}
2399cdf0e10cSrcweir 	else
2400cdf0e10cSrcweir 		nNewFirstLineOffset=
2401cdf0e10cSrcweir 			PixelHAdjust(
2402cdf0e10cSrcweir 				ConvertHPosLogic(pIndents[INDENT_FIRST_LINE].nPos -
2403cdf0e10cSrcweir                              pIndents[INDENT_LEFT_MARGIN].nPos) -
2404cdf0e10cSrcweir 				lAppNullOffset,
2405cdf0e10cSrcweir 				pParaItem->GetTxtFirstLineOfst());
2406cdf0e10cSrcweir 
2407cdf0e10cSrcweir 	// #62986# : Ist der neue TxtLeft kleiner als der alte FirstLineIndent,
2408cdf0e10cSrcweir     // dann geht die Differenz verloren und der Absatz wird insgesamt
2409cdf0e10cSrcweir 	// zu weit eingerueckt, deswegen erst den FirstLineOffset setzen, dann den TxtLeft
2410cdf0e10cSrcweir 	if(bRTL)
2411cdf0e10cSrcweir 	{
2412cdf0e10cSrcweir         long nLeftFrameMargin = GetLeftFrameMargin();
2413cdf0e10cSrcweir         long nRightFrameMargin = GetRightFrameMargin();
2414cdf0e10cSrcweir 		nNewTxtLeft = nRightFrameMargin - nNewTxtLeft - nLeftFrameMargin;
2415cdf0e10cSrcweir 		nNewFirstLineOffset -= nNewTxtLeft;
2416cdf0e10cSrcweir 		if(pParaBorderItem)
2417cdf0e10cSrcweir 		{
2418cdf0e10cSrcweir 			nNewTxtLeft += pParaBorderItem->GetLeft() + pParaBorderItem->GetRight();
2419cdf0e10cSrcweir 			nNewFirstLineOffset -= pParaBorderItem->GetRight();
2420cdf0e10cSrcweir 		}
2421cdf0e10cSrcweir 	}
2422cdf0e10cSrcweir 	pParaItem->SetTxtFirstLineOfst(
2423cdf0e10cSrcweir         sal::static_int_cast< short >(nNewFirstLineOffset));
2424cdf0e10cSrcweir 	pParaItem->SetTxtLeft(nNewTxtLeft);
2425cdf0e10cSrcweir 
2426cdf0e10cSrcweir 	if(pColumnItem && ((!bRTL && !IsActLastColumn( sal_True ))|| (bRTL && !IsActFirstColumn())))
2427cdf0e10cSrcweir 	{
2428cdf0e10cSrcweir 		if(bRTL)
2429cdf0e10cSrcweir 		{
2430cdf0e10cSrcweir 			long nActBorder = pBorders[GetActLeftColumn( sal_True )].nPos;
2431cdf0e10cSrcweir 			long nRightMargin = pIndents[INDENT_RIGHT_MARGIN].nPos;
2432cdf0e10cSrcweir 			long nConvert = ConvertHPosLogic( nRightMargin - nActBorder );
2433cdf0e10cSrcweir 			pParaItem->SetRight( PixelHAdjust( nConvert - lAppNullOffset, pParaItem->GetRight() ) );
2434cdf0e10cSrcweir 		}
2435cdf0e10cSrcweir 		else
2436cdf0e10cSrcweir 		{
2437cdf0e10cSrcweir 			pParaItem->SetRight(
2438cdf0e10cSrcweir 				PixelHAdjust(
2439cdf0e10cSrcweir 					ConvertHPosLogic(
2440cdf0e10cSrcweir 						pBorders[GetActRightColumn( sal_True )].nPos -
2441cdf0e10cSrcweir 						pIndents[INDENT_RIGHT_MARGIN].nPos) -
2442cdf0e10cSrcweir 					lAppNullOffset,
2443cdf0e10cSrcweir 					pParaItem->GetRight()));
2444cdf0e10cSrcweir 		}
2445cdf0e10cSrcweir 
2446cdf0e10cSrcweir 	}
2447cdf0e10cSrcweir 	else
2448cdf0e10cSrcweir 	{
2449cdf0e10cSrcweir 		if(bRTL)
2450cdf0e10cSrcweir 		{
2451cdf0e10cSrcweir 			pParaItem->SetRight( PixelHAdjust(
2452cdf0e10cSrcweir 				ConvertHPosLogic(GetMargin1() +
2453cdf0e10cSrcweir                              pIndents[INDENT_RIGHT_MARGIN].nPos) - GetLeftFrameMargin() +
2454cdf0e10cSrcweir 							 (pParaBorderItem ? pParaBorderItem->GetLeft() : 0) -
2455cdf0e10cSrcweir 				lAppNullOffset,	pParaItem->GetRight()));
2456cdf0e10cSrcweir 		}
2457cdf0e10cSrcweir 		else
2458cdf0e10cSrcweir 		{
2459cdf0e10cSrcweir 			pParaItem->SetRight( PixelHAdjust(
2460cdf0e10cSrcweir 				ConvertHPosLogic(GetMargin2() -
2461cdf0e10cSrcweir                              pIndents[INDENT_RIGHT_MARGIN].nPos) -
2462cdf0e10cSrcweir 				lAppNullOffset,	pParaItem->GetRight()));
2463cdf0e10cSrcweir 		}
2464cdf0e10cSrcweir 	}
2465cdf0e10cSrcweir     sal_uInt16 nParaId  = bHorz ? SID_ATTR_PARA_LRSPACE : SID_ATTR_PARA_LRSPACE_VERTICAL;
2466cdf0e10cSrcweir     pBindings->GetDispatcher()->Execute( nParaId, SFX_CALLMODE_RECORD, pParaItem, 0L );
2467cdf0e10cSrcweir 	UpdateTabs();
2468cdf0e10cSrcweir }
2469cdf0e10cSrcweir 
2470cdf0e10cSrcweir 
ApplyTabs()2471cdf0e10cSrcweir void SvxRuler::ApplyTabs()
2472cdf0e10cSrcweir /*
2473cdf0e10cSrcweir    [Beschreibung]
2474cdf0e10cSrcweir 
2475cdf0e10cSrcweir    Anwenden von Tabulatoreinstellungen; durch Draggen veraendert.
2476cdf0e10cSrcweir 
2477cdf0e10cSrcweir */
2478cdf0e10cSrcweir {
2479cdf0e10cSrcweir 	sal_Bool bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
2480cdf0e10cSrcweir 	const sal_uInt16 nCoreIdx = GetDragAryPos();
2481cdf0e10cSrcweir 	if(IsDragDelete())
2482cdf0e10cSrcweir 	{
2483cdf0e10cSrcweir 		pTabStopItem->Remove(nCoreIdx);
2484cdf0e10cSrcweir 	}
2485cdf0e10cSrcweir 	else if(DRAG_OBJECT_SIZE_LINEAR & nDragType ||
2486cdf0e10cSrcweir 			DRAG_OBJECT_SIZE_PROPORTIONAL & nDragType)
2487cdf0e10cSrcweir 	{
2488cdf0e10cSrcweir 		SvxTabStopItem *pItem = new SvxTabStopItem(pTabStopItem->Which());
2489cdf0e10cSrcweir         //remove default tab stops
2490cdf0e10cSrcweir         for ( sal_uInt16 i = 0; i < pItem->Count(); )
2491cdf0e10cSrcweir         {
2492cdf0e10cSrcweir             if ( SVX_TAB_ADJUST_DEFAULT == (*pItem)[i].GetAdjustment() )
2493cdf0e10cSrcweir             {
2494cdf0e10cSrcweir                 pItem->Remove(i);
2495cdf0e10cSrcweir                 continue;
2496cdf0e10cSrcweir             }
2497cdf0e10cSrcweir             ++i;
2498cdf0e10cSrcweir         }
2499cdf0e10cSrcweir 
2500cdf0e10cSrcweir         sal_uInt16 j;
2501cdf0e10cSrcweir 		for(j = 0; j < nCoreIdx; ++j)
2502cdf0e10cSrcweir 		{
2503cdf0e10cSrcweir 			pItem->Insert((*pTabStopItem)[j]);
2504cdf0e10cSrcweir 		}
2505cdf0e10cSrcweir 		for(; j < pTabStopItem->Count(); ++j)
2506cdf0e10cSrcweir 		{
2507cdf0e10cSrcweir 			SvxTabStop aTabStop = (*pTabStopItem)[j];
2508cdf0e10cSrcweir 			aTabStop.GetTabPos() = PixelHAdjust(
2509cdf0e10cSrcweir 				ConvertHPosLogic(pTabs[j+TAB_GAP].nPos -
2510cdf0e10cSrcweir 								 GetLeftIndent()) -
2511cdf0e10cSrcweir 				lAppNullOffset,
2512cdf0e10cSrcweir 				aTabStop.GetTabPos());
2513cdf0e10cSrcweir 			pItem->Insert(aTabStop);
2514cdf0e10cSrcweir 		}
2515cdf0e10cSrcweir 		delete pTabStopItem;
2516cdf0e10cSrcweir 		pTabStopItem = pItem;
2517cdf0e10cSrcweir 	}
2518cdf0e10cSrcweir 	else if( pTabStopItem->Count() == 0 )
2519cdf0e10cSrcweir 		return;
2520cdf0e10cSrcweir 	else
2521cdf0e10cSrcweir 	{
2522cdf0e10cSrcweir 		SvxTabStop aTabStop = (*pTabStopItem)[nCoreIdx];
2523cdf0e10cSrcweir 		if(pRuler_Imp->lMaxRightLogic!=-1&&
2524cdf0e10cSrcweir 		   pTabs[nCoreIdx+TAB_GAP].nPos+Ruler::GetNullOffset()==nMaxRight)
2525cdf0e10cSrcweir 			aTabStop.GetTabPos() = pRuler_Imp->lMaxRightLogic-lLogicNullOffset;
2526cdf0e10cSrcweir 		else
2527cdf0e10cSrcweir 		{
2528cdf0e10cSrcweir 			if(bRTL)
2529cdf0e10cSrcweir             {
2530cdf0e10cSrcweir                 //#i24363# tab stops relative to indent
2531cdf0e10cSrcweir                 const long nTmpLeftIndent = pRuler_Imp->bIsTabsRelativeToIndent ?
2532cdf0e10cSrcweir                                             GetLeftIndent() :
2533cdf0e10cSrcweir                                             ConvertHPosPixel( GetRightFrameMargin() + lAppNullOffset );
2534cdf0e10cSrcweir 
2535cdf0e10cSrcweir 				aTabStop.GetTabPos() = PixelHAdjust(
2536cdf0e10cSrcweir                     ConvertHPosLogic( nTmpLeftIndent - pTabs[nCoreIdx+TAB_GAP].nPos) - lAppNullOffset,
2537cdf0e10cSrcweir 																						aTabStop.GetTabPos());
2538cdf0e10cSrcweir             }
2539cdf0e10cSrcweir 			else
2540cdf0e10cSrcweir             {
2541cdf0e10cSrcweir                 //#i24363# tab stops relative to indent
2542cdf0e10cSrcweir                 const long nTmpLeftIndent = pRuler_Imp->bIsTabsRelativeToIndent ?
2543cdf0e10cSrcweir                                             GetLeftIndent() :
2544cdf0e10cSrcweir                                             0;
2545cdf0e10cSrcweir 
2546cdf0e10cSrcweir                 aTabStop.GetTabPos() = PixelHAdjust(
2547cdf0e10cSrcweir                     ConvertHPosLogic( pTabs[nCoreIdx+TAB_GAP].nPos - nTmpLeftIndent ) - lAppNullOffset,
2548cdf0e10cSrcweir                                                                                          aTabStop.GetTabPos() );
2549cdf0e10cSrcweir             }
2550cdf0e10cSrcweir 		}
2551cdf0e10cSrcweir 		pTabStopItem->Remove(nCoreIdx);
2552cdf0e10cSrcweir 		pTabStopItem->Insert(aTabStop);
2553cdf0e10cSrcweir 	}
2554cdf0e10cSrcweir     sal_uInt16 nTabStopId = bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL;
2555cdf0e10cSrcweir     pBindings->GetDispatcher()->Execute( nTabStopId, SFX_CALLMODE_RECORD, pTabStopItem, 0L );
2556cdf0e10cSrcweir 	UpdateTabs();
2557cdf0e10cSrcweir }
2558cdf0e10cSrcweir 
2559cdf0e10cSrcweir 
ApplyBorders()2560cdf0e10cSrcweir void SvxRuler::ApplyBorders()
2561cdf0e10cSrcweir /*
2562cdf0e10cSrcweir    [Beschreibung]
2563cdf0e10cSrcweir 
2564cdf0e10cSrcweir    Anwenden von (Tabellen-)Spalteneinstellungen; durch Draggen veraendert.
2565cdf0e10cSrcweir 
2566cdf0e10cSrcweir */
2567cdf0e10cSrcweir {
2568cdf0e10cSrcweir 	if(pColumnItem->IsTable())
2569cdf0e10cSrcweir 	{
2570cdf0e10cSrcweir 		long l = GetFrameLeft();
2571cdf0e10cSrcweir 		if(l != pRuler_Imp->nColLeftPix)
2572cdf0e10cSrcweir 			pColumnItem->SetLeft( PixelHAdjust(
2573cdf0e10cSrcweir 				ConvertHPosLogic(l) - lAppNullOffset, pColumnItem->GetLeft()));
2574cdf0e10cSrcweir 		l = GetMargin2();
2575cdf0e10cSrcweir 		if(l != pRuler_Imp->nColRightPix)
2576cdf0e10cSrcweir 		{
2577cdf0e10cSrcweir             long nWidthOrHeight = bHorz ? pPagePosItem->GetWidth() : pPagePosItem->GetHeight();
2578cdf0e10cSrcweir 			pColumnItem->SetRight( PixelHAdjust( nWidthOrHeight -
2579cdf0e10cSrcweir 					pColumnItem->GetLeft() - ConvertHPosLogic(l) -
2580cdf0e10cSrcweir 					lAppNullOffset, pColumnItem->GetRight() ) );
2581cdf0e10cSrcweir 		}
2582cdf0e10cSrcweir 	}
2583cdf0e10cSrcweir 	for(sal_uInt16 i = 0; i < pColumnItem->Count()-1; ++i)
2584cdf0e10cSrcweir 	{
2585cdf0e10cSrcweir 		long& nEnd = (*pColumnItem)[i].nEnd;
2586cdf0e10cSrcweir 		nEnd = PIXEL_H_ADJUST(
2587cdf0e10cSrcweir 			ConvertPosLogic(pBorders[i].nPos),
2588cdf0e10cSrcweir 			(*pColumnItem)[i].nEnd);
2589cdf0e10cSrcweir 		long& nStart = (*pColumnItem)[i+1].nStart;
2590cdf0e10cSrcweir 		nStart = PIXEL_H_ADJUST(
2591cdf0e10cSrcweir 			ConvertSizeLogic(pBorders[i].nPos +
2592cdf0e10cSrcweir 							 pBorders[i].nWidth) -
2593cdf0e10cSrcweir 			lAppNullOffset,
2594cdf0e10cSrcweir 			(*pColumnItem)[i+1].nStart);
2595cdf0e10cSrcweir 		// Es kann sein, dass aufgrund der PIXEL_H_ADJUST rejustierung auf
2596cdf0e10cSrcweir 		// alte Werte die Breite < 0 wird. Das rerejustieren wir.
2597cdf0e10cSrcweir 		if( nEnd > nStart )
2598cdf0e10cSrcweir 			nStart = nEnd;
2599cdf0e10cSrcweir 	}
2600cdf0e10cSrcweir #ifdef DEBUGLIN
2601cdf0e10cSrcweir 		Debug_Impl(pEditWin,*pColumnItem);
2602cdf0e10cSrcweir #endif // DEBUGLIN
2603cdf0e10cSrcweir 	SfxBoolItem aFlag(SID_RULER_ACT_LINE_ONLY,
2604cdf0e10cSrcweir 					  nDragType & DRAG_OBJECT_ACTLINE_ONLY? sal_True : sal_False);
2605cdf0e10cSrcweir     sal_uInt16 nColId = pRuler_Imp->bIsTableRows ? (bHorz ? SID_RULER_ROWS : SID_RULER_ROWS_VERTICAL) :
2606cdf0e10cSrcweir                             (bHorz ? SID_RULER_BORDERS : SID_RULER_BORDERS_VERTICAL);
2607cdf0e10cSrcweir     pBindings->GetDispatcher()->Execute( nColId, SFX_CALLMODE_RECORD, pColumnItem, &aFlag, 0L );
2608cdf0e10cSrcweir }
2609cdf0e10cSrcweir 
ApplyObject()2610cdf0e10cSrcweir void SvxRuler::ApplyObject()
2611cdf0e10cSrcweir /*
2612cdf0e10cSrcweir    [Beschreibung]
2613cdf0e10cSrcweir 
2614cdf0e10cSrcweir    Anwenden von Objekteinstellungen; durch Draggen veraendert.
2615cdf0e10cSrcweir 
2616cdf0e10cSrcweir */
2617cdf0e10cSrcweir {
2618cdf0e10cSrcweir 		// zum Seitenrand
2619cdf0e10cSrcweir 	long nMargin = pLRSpaceItem? pLRSpaceItem->GetLeft(): 0;
2620cdf0e10cSrcweir 	pObjectItem->SetStartX(
2621cdf0e10cSrcweir 						   PixelAdjust(
2622cdf0e10cSrcweir 							  ConvertPosLogic(pObjectBorders[0].nPos)
2623cdf0e10cSrcweir 							  + nMargin - lAppNullOffset,pObjectItem->GetStartX()));
2624cdf0e10cSrcweir 	pObjectItem->SetEndX(
2625cdf0e10cSrcweir 						 PixelAdjust(
2626cdf0e10cSrcweir 							 ConvertPosLogic(pObjectBorders[1].nPos)
2627cdf0e10cSrcweir 						 + nMargin -  lAppNullOffset,pObjectItem->GetEndX()));
2628cdf0e10cSrcweir 	nMargin = pULSpaceItem? pULSpaceItem->GetUpper(): 0;
2629cdf0e10cSrcweir 	pObjectItem->SetStartY(
2630cdf0e10cSrcweir 						 PixelAdjust(
2631cdf0e10cSrcweir 							 ConvertPosLogic(pObjectBorders[2].nPos)
2632cdf0e10cSrcweir 						   + nMargin - lAppNullOffset,pObjectItem->GetStartY()));
2633cdf0e10cSrcweir 	pObjectItem->SetEndY(
2634cdf0e10cSrcweir 					 PixelAdjust(
2635cdf0e10cSrcweir 						 ConvertPosLogic(pObjectBorders[3].nPos)
2636cdf0e10cSrcweir 						 + nMargin - lAppNullOffset,pObjectItem->GetEndY()));
2637cdf0e10cSrcweir 	pBindings->GetDispatcher()->Execute( SID_RULER_OBJECT, SFX_CALLMODE_RECORD, pObjectItem, 0L );
2638cdf0e10cSrcweir }
2639cdf0e10cSrcweir 
PrepareProportional_Impl(RulerType eType)2640cdf0e10cSrcweir void SvxRuler::PrepareProportional_Impl(RulerType eType)
2641cdf0e10cSrcweir /*
2642cdf0e10cSrcweir    [Beschreibung]
2643cdf0e10cSrcweir 
2644cdf0e10cSrcweir    Vorbereitung proportionales Draggen; es wird der proportionale
2645cdf0e10cSrcweir    Anteil bezogen auf die Gesamtbreite in Promille berechnet.
2646cdf0e10cSrcweir 
2647cdf0e10cSrcweir */
2648cdf0e10cSrcweir {
2649cdf0e10cSrcweir 	pRuler_Imp->nTotalDist = GetMargin2();
2650cdf0e10cSrcweir 	switch((int)eType)
2651cdf0e10cSrcweir 	{
2652cdf0e10cSrcweir       case RULER_TYPE_MARGIN2:
2653cdf0e10cSrcweir       case RULER_TYPE_MARGIN1:
2654cdf0e10cSrcweir 	  case RULER_TYPE_BORDER:
2655cdf0e10cSrcweir 		{
2656cdf0e10cSrcweir             DBG_ASSERT(pColumnItem, "kein ColumnItem");
2657cdf0e10cSrcweir 
2658cdf0e10cSrcweir 			pRuler_Imp->SetPercSize(pColumnItem->Count());
2659cdf0e10cSrcweir 
2660cdf0e10cSrcweir 			long lPos;
2661cdf0e10cSrcweir 			long lWidth=0;
2662cdf0e10cSrcweir 			sal_uInt16 nStart;
2663cdf0e10cSrcweir 			sal_uInt16 nIdx=GetDragAryPos();
2664cdf0e10cSrcweir 			lWidth=0;
2665cdf0e10cSrcweir 			long lActWidth=0;
2666cdf0e10cSrcweir 			long lActBorderSum;
2667cdf0e10cSrcweir 			long lOrigLPos;
2668cdf0e10cSrcweir 
2669cdf0e10cSrcweir 			if(eType != RULER_TYPE_BORDER)
2670cdf0e10cSrcweir 			{
2671cdf0e10cSrcweir 				lOrigLPos = GetMargin1();
2672cdf0e10cSrcweir 				nStart = 0;
2673cdf0e10cSrcweir 				lActBorderSum = 0;
2674cdf0e10cSrcweir 			}
2675cdf0e10cSrcweir 			else
2676cdf0e10cSrcweir 			{
2677cdf0e10cSrcweir 				if(pRuler_Imp->bIsTableRows &&!bHorz)
2678cdf0e10cSrcweir 				{
2679cdf0e10cSrcweir 					lOrigLPos = GetMargin1();
2680cdf0e10cSrcweir 					nStart = 0;
2681cdf0e10cSrcweir 				}
2682cdf0e10cSrcweir 				else
2683cdf0e10cSrcweir 				{
2684cdf0e10cSrcweir 					lOrigLPos = pBorders[nIdx].nPos + pBorders[nIdx].nWidth;
2685cdf0e10cSrcweir 					nStart = 1;
2686cdf0e10cSrcweir 				}
2687cdf0e10cSrcweir 				lActBorderSum = pBorders[nIdx].nWidth;
2688cdf0e10cSrcweir 			}
2689cdf0e10cSrcweir 
2690cdf0e10cSrcweir             //in horizontal mode the percentage value has to be
2691cdf0e10cSrcweir             //calculated on a "current change" position base
2692cdf0e10cSrcweir             //because the height of the table changes while dragging
2693cdf0e10cSrcweir             if(pRuler_Imp->bIsTableRows && RULER_TYPE_BORDER == eType)
2694cdf0e10cSrcweir             {
2695cdf0e10cSrcweir                 sal_uInt16 nStartBorder;
2696cdf0e10cSrcweir                 sal_uInt16 nEndBorder;
2697cdf0e10cSrcweir                 if(bHorz)
2698cdf0e10cSrcweir                 {
2699cdf0e10cSrcweir                     nStartBorder = nIdx + 1;
2700cdf0e10cSrcweir                     nEndBorder = pColumnItem->Count() - 1;
2701cdf0e10cSrcweir                 }
2702cdf0e10cSrcweir                 else
2703cdf0e10cSrcweir                 {
2704cdf0e10cSrcweir                     nStartBorder = 0;
2705cdf0e10cSrcweir                     nEndBorder = nIdx;
2706cdf0e10cSrcweir                 }
2707cdf0e10cSrcweir 
2708cdf0e10cSrcweir 				lWidth = pBorders[nIdx].nPos;
2709cdf0e10cSrcweir 				if(bHorz)
2710cdf0e10cSrcweir 					lWidth = GetMargin2() - lWidth;
2711cdf0e10cSrcweir                 pRuler_Imp->nTotalDist = lWidth;
2712cdf0e10cSrcweir                 lPos = lOrigLPos = pBorders[nIdx].nPos;
2713cdf0e10cSrcweir 
2714cdf0e10cSrcweir                 for(sal_uInt16 i = nStartBorder; i < nEndBorder; ++i)
2715cdf0e10cSrcweir                 {
2716cdf0e10cSrcweir                     if(bHorz)
2717cdf0e10cSrcweir 					{
2718cdf0e10cSrcweir 						lActWidth += pBorders[i].nPos - lPos;
2719cdf0e10cSrcweir 						lPos = pBorders[i].nPos + pBorders[i].nWidth;
2720cdf0e10cSrcweir 					}
2721cdf0e10cSrcweir 					else
2722cdf0e10cSrcweir 						lActWidth = pBorders[i].nPos;
2723cdf0e10cSrcweir                     pRuler_Imp->pPercBuf[i] = (sal_uInt16)((lActWidth * 1000)
2724cdf0e10cSrcweir                                                     / pRuler_Imp->nTotalDist);
2725cdf0e10cSrcweir                     pRuler_Imp->pBlockBuf[i] = (sal_uInt16)lActBorderSum;
2726cdf0e10cSrcweir                     lActBorderSum += pBorders[i].nWidth;
2727cdf0e10cSrcweir                 }
2728cdf0e10cSrcweir             }
2729cdf0e10cSrcweir             else
2730cdf0e10cSrcweir             {
2731cdf0e10cSrcweir                 lPos = lOrigLPos;
2732cdf0e10cSrcweir                 for(sal_uInt16 ii = nStart; ii < pColumnItem->Count() - 1; ++ii)
2733cdf0e10cSrcweir                 {
2734cdf0e10cSrcweir                     lWidth += pBorders[ii].nPos - lPos;
2735cdf0e10cSrcweir                     lPos = pBorders[ii].nPos + pBorders[ii].nWidth;
2736cdf0e10cSrcweir                 }
2737cdf0e10cSrcweir 
2738cdf0e10cSrcweir                 lWidth += GetMargin2() - lPos;
2739cdf0e10cSrcweir                 pRuler_Imp->nTotalDist = lWidth;
2740cdf0e10cSrcweir                 lPos = lOrigLPos;
2741cdf0e10cSrcweir 
2742cdf0e10cSrcweir                 for(sal_uInt16 i = nStart; i < pColumnItem->Count() - 1; ++i)
2743cdf0e10cSrcweir                 {
2744cdf0e10cSrcweir                     lActWidth += pBorders[i].nPos - lPos;
2745cdf0e10cSrcweir                     lPos = pBorders[i].nPos + pBorders[i].nWidth;
2746cdf0e10cSrcweir                     pRuler_Imp->pPercBuf[i] = (sal_uInt16)((lActWidth * 1000)
2747cdf0e10cSrcweir                                                     / pRuler_Imp->nTotalDist);
2748cdf0e10cSrcweir                     pRuler_Imp->pBlockBuf[i] = (sal_uInt16)lActBorderSum;
2749cdf0e10cSrcweir                     lActBorderSum += pBorders[i].nWidth;
2750cdf0e10cSrcweir                 }
2751cdf0e10cSrcweir             }
2752cdf0e10cSrcweir         }
2753cdf0e10cSrcweir         break;
2754cdf0e10cSrcweir         case RULER_TYPE_TAB:
2755cdf0e10cSrcweir 		{
2756cdf0e10cSrcweir 			const sal_uInt16 nIdx = GetDragAryPos()+TAB_GAP;
2757cdf0e10cSrcweir 			pRuler_Imp->nTotalDist -= pTabs[nIdx].nPos;
2758cdf0e10cSrcweir 			pRuler_Imp->SetPercSize(nTabCount);
2759cdf0e10cSrcweir 			for(sal_uInt16 n=0;n<=nIdx;pRuler_Imp->pPercBuf[n++]=0) ;
2760cdf0e10cSrcweir 			for(sal_uInt16 i = nIdx+1; i < nTabCount; ++i)
2761cdf0e10cSrcweir 			{
2762cdf0e10cSrcweir 				const long nDelta = pTabs[i].nPos - pTabs[nIdx].nPos;
2763cdf0e10cSrcweir 				pRuler_Imp->pPercBuf[i] = (sal_uInt16)((nDelta * 1000) / pRuler_Imp->nTotalDist);
2764cdf0e10cSrcweir 			}
2765cdf0e10cSrcweir 			break;
2766cdf0e10cSrcweir 		}
2767cdf0e10cSrcweir 	}
2768cdf0e10cSrcweir }
2769cdf0e10cSrcweir 
2770cdf0e10cSrcweir 
EvalModifier()2771cdf0e10cSrcweir void SvxRuler::EvalModifier()
2772cdf0e10cSrcweir 
2773cdf0e10cSrcweir /*
2774cdf0e10cSrcweir    [Beschreibung]
2775cdf0e10cSrcweir 
2776cdf0e10cSrcweir    Modifier Draggen auswerten
2777cdf0e10cSrcweir 
2778cdf0e10cSrcweir    Shift: Linear verschieben
2779cdf0e10cSrcweir    Control: Proportional verschieben
2780cdf0e10cSrcweir    Shift+Control: Tabelle: nur aktuelle Zeile
2781cdf0e10cSrcweir    alt: Bemassungspfeile (n.i.) //!!
2782cdf0e10cSrcweir 
2783cdf0e10cSrcweir */
2784cdf0e10cSrcweir 
2785cdf0e10cSrcweir {
2786cdf0e10cSrcweir     sal_uInt16 nModifier = GetDragModifier();
2787cdf0e10cSrcweir     if(pRuler_Imp->bIsTableRows)
2788cdf0e10cSrcweir     {
2789cdf0e10cSrcweir         //rows can only be moved in one way, additionally current column is possible
2790cdf0e10cSrcweir         if(nModifier == KEY_SHIFT)
2791cdf0e10cSrcweir             nModifier = 0;
2792cdf0e10cSrcweir     }
2793cdf0e10cSrcweir     switch(nModifier)
2794cdf0e10cSrcweir     {
2795cdf0e10cSrcweir 	 case KEY_SHIFT:
2796cdf0e10cSrcweir 		nDragType = DRAG_OBJECT_SIZE_LINEAR;
2797cdf0e10cSrcweir 		break;
2798cdf0e10cSrcweir 	 case KEY_MOD1:  {
2799cdf0e10cSrcweir 		 const RulerType eType = GetDragType();
2800cdf0e10cSrcweir 		 nDragType = DRAG_OBJECT_SIZE_PROPORTIONAL;
2801cdf0e10cSrcweir          if( RULER_TYPE_TAB == eType ||
2802cdf0e10cSrcweir              ( ( RULER_TYPE_BORDER == eType || RULER_TYPE_MARGIN1 == eType || RULER_TYPE_MARGIN2 == eType) &&
2803cdf0e10cSrcweir                pColumnItem ) )
2804cdf0e10cSrcweir 			 PrepareProportional_Impl(eType);
2805cdf0e10cSrcweir 		 break;
2806cdf0e10cSrcweir 	 }
2807cdf0e10cSrcweir 	 case KEY_MOD1 | KEY_SHIFT:
2808cdf0e10cSrcweir 		if(GetDragType()!=RULER_TYPE_MARGIN1&&
2809cdf0e10cSrcweir 		   GetDragType()!=RULER_TYPE_MARGIN2)
2810cdf0e10cSrcweir 			nDragType = DRAG_OBJECT_ACTLINE_ONLY;
2811cdf0e10cSrcweir 		break;
2812cdf0e10cSrcweir 		// alt: Bemassungspfeile
2813cdf0e10cSrcweir 	}
2814cdf0e10cSrcweir }
2815cdf0e10cSrcweir 
2816cdf0e10cSrcweir 
Click()2817cdf0e10cSrcweir void __EXPORT SvxRuler::Click()
2818cdf0e10cSrcweir 
2819cdf0e10cSrcweir /*
2820cdf0e10cSrcweir    [Beschreibung]
2821cdf0e10cSrcweir 
2822cdf0e10cSrcweir    Ueberladener Handler SV; setzt Tab per Dispatcheraufruf
2823cdf0e10cSrcweir 
2824cdf0e10cSrcweir */
2825cdf0e10cSrcweir 
2826cdf0e10cSrcweir {
2827cdf0e10cSrcweir     lcl_logRulerUse(::rtl::OUString::createFromAscii(".special://SfxRuler/Click"));
2828cdf0e10cSrcweir 	Ruler::Click();
2829cdf0e10cSrcweir 	if( bActive )
2830cdf0e10cSrcweir 	{
2831cdf0e10cSrcweir 		pBindings->Update( SID_RULER_LR_MIN_MAX );
2832cdf0e10cSrcweir 		pBindings->Update( SID_ATTR_LONG_ULSPACE );
2833cdf0e10cSrcweir 		pBindings->Update( SID_ATTR_LONG_LRSPACE );
2834cdf0e10cSrcweir 		pBindings->Update( SID_RULER_PAGE_POS );
2835cdf0e10cSrcweir         pBindings->Update( bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL);
2836cdf0e10cSrcweir         pBindings->Update( bHorz ? SID_ATTR_PARA_LRSPACE : SID_ATTR_PARA_LRSPACE_VERTICAL);
2837cdf0e10cSrcweir         pBindings->Update( bHorz ? SID_RULER_BORDERS : SID_RULER_BORDERS_VERTICAL);
2838cdf0e10cSrcweir         pBindings->Update( bHorz ? SID_RULER_ROWS : SID_RULER_ROWS_VERTICAL);
2839cdf0e10cSrcweir         pBindings->Update( SID_RULER_OBJECT );
2840cdf0e10cSrcweir 		pBindings->Update( SID_RULER_PROTECT );
2841cdf0e10cSrcweir 		pBindings->Update( SID_ATTR_PARA_LRSPACE_VERTICAL );
2842cdf0e10cSrcweir 	}
2843cdf0e10cSrcweir 	sal_Bool bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
2844cdf0e10cSrcweir 	if(pTabStopItem &&
2845cdf0e10cSrcweir 	   (nFlags & SVXRULER_SUPPORT_TABS) == SVXRULER_SUPPORT_TABS)
2846cdf0e10cSrcweir 	{
2847cdf0e10cSrcweir 		sal_Bool bContentProtected = pRuler_Imp->aProtectItem.IsCntntProtected();
2848cdf0e10cSrcweir 		if( bContentProtected ) return;
2849cdf0e10cSrcweir 		const long lPos = GetClickPos();
2850cdf0e10cSrcweir 		if((bRTL && lPos < Min(GetFirstLineIndent(), GetLeftIndent()) && lPos > GetRightIndent()) ||
2851cdf0e10cSrcweir 			(!bRTL && lPos > Min(GetFirstLineIndent(), GetLeftIndent()) && lPos < GetRightIndent()))
2852cdf0e10cSrcweir 		{
2853cdf0e10cSrcweir 			//convert position in left-to-right text
2854cdf0e10cSrcweir 			long nTabPos;
2855cdf0e10cSrcweir     //#i24363# tab stops relative to indent
2856cdf0e10cSrcweir             if(bRTL)
2857cdf0e10cSrcweir                 nTabPos = ( pRuler_Imp->bIsTabsRelativeToIndent ?
2858cdf0e10cSrcweir                             GetLeftIndent() :
2859cdf0e10cSrcweir                             ConvertHPosPixel( GetRightFrameMargin() + lAppNullOffset ) ) -
2860cdf0e10cSrcweir                           lPos;
2861cdf0e10cSrcweir             else
2862cdf0e10cSrcweir                 nTabPos = lPos -
2863cdf0e10cSrcweir                           ( pRuler_Imp->bIsTabsRelativeToIndent ?
2864cdf0e10cSrcweir                             GetLeftIndent() :
2865cdf0e10cSrcweir                             0 );
2866cdf0e10cSrcweir 
2867cdf0e10cSrcweir 			SvxTabStop aTabStop(ConvertHPosLogic(nTabPos),
2868cdf0e10cSrcweir 								ToAttrTab_Impl(nDefTabType));
2869cdf0e10cSrcweir 			pTabStopItem->Insert(aTabStop);
2870cdf0e10cSrcweir 			UpdateTabs();
2871cdf0e10cSrcweir 		}
2872cdf0e10cSrcweir 	}
2873cdf0e10cSrcweir }
2874cdf0e10cSrcweir 
2875cdf0e10cSrcweir 
CalcLimits(long & nMax1,long & nMax2,sal_Bool) const2876cdf0e10cSrcweir sal_Bool SvxRuler::CalcLimits
2877cdf0e10cSrcweir (
2878cdf0e10cSrcweir  long &nMax1,                                   // zu setzenden Minimalwert
2879cdf0e10cSrcweir  long &nMax2,                                   // zu setzenden Maximalwert
2880cdf0e10cSrcweir  sal_Bool
2881cdf0e10cSrcweir ) const
2882cdf0e10cSrcweir /*
2883cdf0e10cSrcweir    [Beschreibung]
2884cdf0e10cSrcweir 
2885cdf0e10cSrcweir    Defaultimplementierung der virtuellen Funktion; kann die Applikation
2886cdf0e10cSrcweir    ueberladen, um eine eigene Grenzwertbehandlung zu implementieren.
2887cdf0e10cSrcweir    Die Werte sind auf die Seite bezogen.
2888cdf0e10cSrcweir */
2889cdf0e10cSrcweir {
2890cdf0e10cSrcweir 	nMax1 = LONG_MIN;
2891cdf0e10cSrcweir 	nMax2 = LONG_MAX;
2892cdf0e10cSrcweir 	return sal_False;
2893cdf0e10cSrcweir }
2894cdf0e10cSrcweir 
2895cdf0e10cSrcweir 
CalcMinMax()2896cdf0e10cSrcweir void SvxRuler::CalcMinMax()
2897cdf0e10cSrcweir 
2898cdf0e10cSrcweir /*
2899cdf0e10cSrcweir    [Beschreibung]
2900cdf0e10cSrcweir 
2901cdf0e10cSrcweir    Berechnet die Grenzwerte fuers Draggen; diese sind in Pixeln
2902cdf0e10cSrcweir    relativ zum Seitenrand
2903cdf0e10cSrcweir 
2904cdf0e10cSrcweir */
2905cdf0e10cSrcweir 
2906cdf0e10cSrcweir {
2907cdf0e10cSrcweir 	sal_Bool bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
2908cdf0e10cSrcweir 	const long lNullPix = ConvertPosPixel(lLogicNullOffset);
2909cdf0e10cSrcweir 	pRuler_Imp->lMaxLeftLogic=pRuler_Imp->lMaxRightLogic=-1;
2910cdf0e10cSrcweir 	switch(GetDragType())
2911cdf0e10cSrcweir 	{
2912cdf0e10cSrcweir 	  case RULER_TYPE_MARGIN1:
2913cdf0e10cSrcweir 		{        // linker Rand umgebender Frame
2914cdf0e10cSrcweir 			// DragPos - NOf zwischen links - rechts
2915cdf0e10cSrcweir 			pRuler_Imp->lMaxLeftLogic = GetLeftMin();
2916cdf0e10cSrcweir 			nMaxLeft=ConvertSizePixel(pRuler_Imp->lMaxLeftLogic);
2917cdf0e10cSrcweir 
2918cdf0e10cSrcweir 			if(!pColumnItem || pColumnItem->Count() == 1 )
2919cdf0e10cSrcweir 			{
2920cdf0e10cSrcweir 				if(bRTL)
2921cdf0e10cSrcweir 				{
2922cdf0e10cSrcweir 					nMaxRight = lNullPix - GetRightIndent() +
2923cdf0e10cSrcweir 						Max(GetFirstLineIndent(), GetLeftIndent()) -
2924cdf0e10cSrcweir 						lMinFrame;
2925cdf0e10cSrcweir 				}
2926cdf0e10cSrcweir 				else
2927cdf0e10cSrcweir 				{
2928cdf0e10cSrcweir 					nMaxRight = lNullPix + GetRightIndent() -
2929cdf0e10cSrcweir 						Max(GetFirstLineIndent(), GetLeftIndent()) -
2930cdf0e10cSrcweir 						lMinFrame;
2931cdf0e10cSrcweir 				}
2932cdf0e10cSrcweir 			}
2933cdf0e10cSrcweir 			else if(pRuler_Imp->bIsTableRows)
2934cdf0e10cSrcweir 			{
2935cdf0e10cSrcweir 				//top border is not moveable when table rows are displayed
2936cdf0e10cSrcweir 				// protection of content means the margin is not moveable - it's just a page break inside of a cell
2937cdf0e10cSrcweir 				if(bHorz && !pRuler_Imp->aProtectItem.IsCntntProtected())
2938cdf0e10cSrcweir 				{
2939cdf0e10cSrcweir 					nMaxLeft = pBorders[0].nMinPos + lNullPix;
2940cdf0e10cSrcweir 					if(nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
2941cdf0e10cSrcweir 						nMaxRight = GetRightIndent() + lNullPix -
2942cdf0e10cSrcweir 								(pColumnItem->Count() - 1 ) * lMinFrame;
2943cdf0e10cSrcweir 					else
2944cdf0e10cSrcweir 						nMaxRight = pBorders[0].nPos - lMinFrame + lNullPix;
2945cdf0e10cSrcweir 				}
2946cdf0e10cSrcweir 				else
2947cdf0e10cSrcweir 					nMaxLeft = nMaxRight = lNullPix;
2948cdf0e10cSrcweir 			}
2949cdf0e10cSrcweir 			else
2950cdf0e10cSrcweir 			{
2951cdf0e10cSrcweir 				if(nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
2952cdf0e10cSrcweir 				   //nDragType & DRAG_OBJECT_SIZE_LINEAR)
2953cdf0e10cSrcweir 				{
2954cdf0e10cSrcweir 					nMaxRight=lNullPix+CalcPropMaxRight();
2955cdf0e10cSrcweir 				}
2956cdf0e10cSrcweir 				else if(nDragType & DRAG_OBJECT_SIZE_LINEAR)
2957cdf0e10cSrcweir 				{
2958cdf0e10cSrcweir 					nMaxRight = ConvertPosPixel(
2959cdf0e10cSrcweir 						GetPageWidth() - (
2960cdf0e10cSrcweir 							(pColumnItem->IsTable() && pLRSpaceItem)
2961cdf0e10cSrcweir 							? pLRSpaceItem->GetRight() : 0))
2962cdf0e10cSrcweir 							- GetMargin2() + GetMargin1();
2963cdf0e10cSrcweir 				}
2964cdf0e10cSrcweir 				else
2965cdf0e10cSrcweir 				{
2966cdf0e10cSrcweir 					nMaxRight = lNullPix - lMinFrame;
2967cdf0e10cSrcweir 					if(pColumnItem->IsFirstAct())
2968cdf0e10cSrcweir 					{
2969cdf0e10cSrcweir 						if(bRTL)
2970cdf0e10cSrcweir 						{
2971cdf0e10cSrcweir 							nMaxRight += Min(
2972cdf0e10cSrcweir 								pBorders[0].nPos,
2973cdf0e10cSrcweir 								Max(GetFirstLineIndent(), GetLeftIndent()) - GetRightIndent());
2974cdf0e10cSrcweir 						}
2975cdf0e10cSrcweir 						else
2976cdf0e10cSrcweir 						{
2977cdf0e10cSrcweir 							nMaxRight += Min(
2978cdf0e10cSrcweir 								pBorders[0].nPos, GetRightIndent() -
2979cdf0e10cSrcweir 								Max(GetFirstLineIndent(), GetLeftIndent()));
2980cdf0e10cSrcweir 						}
2981cdf0e10cSrcweir 					}
2982cdf0e10cSrcweir 					else if( pColumnItem->Count() > 1 )
2983cdf0e10cSrcweir 						nMaxRight += pBorders[0].nPos;
2984cdf0e10cSrcweir 					else
2985cdf0e10cSrcweir 						nMaxRight +=GetRightIndent() -
2986cdf0e10cSrcweir 							Max(GetFirstLineIndent(), GetLeftIndent());
2987cdf0e10cSrcweir 					// den linken Tabellen-Rand nicht ueber den Seitenrand ziehen
2988cdf0e10cSrcweir 					if(pLRSpaceItem&&pColumnItem->IsTable())
2989cdf0e10cSrcweir 					{
2990cdf0e10cSrcweir 						long nTmp=ConvertSizePixel(pLRSpaceItem->GetLeft());
2991cdf0e10cSrcweir 						if(nTmp>nMaxLeft)
2992cdf0e10cSrcweir 							nMaxLeft=nTmp;
2993cdf0e10cSrcweir 					}
2994cdf0e10cSrcweir 				}
2995cdf0e10cSrcweir 			}
2996cdf0e10cSrcweir 			break;
2997cdf0e10cSrcweir 		}
2998cdf0e10cSrcweir 	  case RULER_TYPE_MARGIN2:
2999cdf0e10cSrcweir 	 {        // rechter Rand umgebender Frame
3000cdf0e10cSrcweir 		pRuler_Imp->lMaxRightLogic =
3001cdf0e10cSrcweir 			pMinMaxItem ?
3002cdf0e10cSrcweir 				GetPageWidth() - GetRightMax() : GetPageWidth();
3003cdf0e10cSrcweir 		nMaxRight = ConvertSizePixel(pRuler_Imp->lMaxRightLogic);
3004cdf0e10cSrcweir 
3005cdf0e10cSrcweir 
3006cdf0e10cSrcweir 		if(!pColumnItem)
3007cdf0e10cSrcweir 		{
3008cdf0e10cSrcweir 			if(bRTL)
3009cdf0e10cSrcweir 			{
3010cdf0e10cSrcweir 				nMaxLeft =  GetMargin2() + GetRightIndent() -
3011cdf0e10cSrcweir 					Max(GetFirstLineIndent(),GetLeftIndent())  - GetMargin1()+
3012cdf0e10cSrcweir 						lMinFrame + lNullPix;
3013cdf0e10cSrcweir 			}
3014cdf0e10cSrcweir 			else
3015cdf0e10cSrcweir 			{
3016cdf0e10cSrcweir 				nMaxLeft =  GetMargin2() - GetRightIndent() +
3017cdf0e10cSrcweir 					Max(GetFirstLineIndent(),GetLeftIndent())  - GetMargin1()+
3018cdf0e10cSrcweir 						lMinFrame + lNullPix;
3019cdf0e10cSrcweir 			}
3020cdf0e10cSrcweir 		}
3021cdf0e10cSrcweir 		else if(pRuler_Imp->bIsTableRows)
3022cdf0e10cSrcweir 		{
3023cdf0e10cSrcweir 			// get the bottom move range from the last border position - only available for rows!
3024cdf0e10cSrcweir 			// protection of content means the margin is not moveable - it's just a page break inside of a cell
3025cdf0e10cSrcweir 			if(bHorz || pRuler_Imp->aProtectItem.IsCntntProtected())
3026cdf0e10cSrcweir 			{
3027cdf0e10cSrcweir 				nMaxLeft = nMaxRight = pBorders[pColumnItem->Count() - 1].nMaxPos + lNullPix;
3028cdf0e10cSrcweir 			}
3029cdf0e10cSrcweir 			else
3030cdf0e10cSrcweir 			{
3031cdf0e10cSrcweir                 if(nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
3032cdf0e10cSrcweir                 {
3033cdf0e10cSrcweir                     nMaxLeft = (pColumnItem->Count()) * lMinFrame + lNullPix;
3034cdf0e10cSrcweir                 }
3035cdf0e10cSrcweir                 else
3036cdf0e10cSrcweir                 {
3037cdf0e10cSrcweir                     if(pColumnItem->Count() > 1)
3038cdf0e10cSrcweir                         nMaxLeft = pBorders[pColumnItem->Count() - 2].nPos + lMinFrame + lNullPix;
3039cdf0e10cSrcweir                     else
3040cdf0e10cSrcweir                         nMaxLeft = lMinFrame + lNullPix;
3041cdf0e10cSrcweir                 }
3042cdf0e10cSrcweir                 if(pColumnItem->Count() > 1)
3043cdf0e10cSrcweir                     nMaxRight = pBorders[pColumnItem->Count() - 2].nMaxPos + lNullPix;
3044cdf0e10cSrcweir                 else
3045cdf0e10cSrcweir                     nMaxRight -= GetRightIndent() - lNullPix;
3046cdf0e10cSrcweir 			}
3047cdf0e10cSrcweir 		}
3048cdf0e10cSrcweir 		else
3049cdf0e10cSrcweir 		{
3050cdf0e10cSrcweir 			nMaxLeft = lMinFrame + lNullPix;
3051cdf0e10cSrcweir 			if(IsActLastColumn() || pColumnItem->Count() < 2 ) //Falls letzte Spalte aktiv
3052cdf0e10cSrcweir 			{
3053cdf0e10cSrcweir 				if(bRTL)
3054cdf0e10cSrcweir 				{
3055cdf0e10cSrcweir 					nMaxLeft = lMinFrame + lNullPix + GetMargin2() +
3056cdf0e10cSrcweir 						GetRightIndent() - Max(GetFirstLineIndent(),
3057cdf0e10cSrcweir 											   GetLeftIndent());
3058cdf0e10cSrcweir 				}
3059cdf0e10cSrcweir 				else
3060cdf0e10cSrcweir 				{
3061cdf0e10cSrcweir 					nMaxLeft = lMinFrame + lNullPix + GetMargin2() -
3062cdf0e10cSrcweir 						GetRightIndent() + Max(GetFirstLineIndent(),
3063cdf0e10cSrcweir 											   GetLeftIndent());
3064cdf0e10cSrcweir 				}
3065cdf0e10cSrcweir 			}
3066cdf0e10cSrcweir 			if( pColumnItem->Count() >= 2 )
3067cdf0e10cSrcweir 			{
3068cdf0e10cSrcweir 				long nNewMaxLeft =
3069cdf0e10cSrcweir 					lMinFrame + lNullPix +
3070cdf0e10cSrcweir 					pBorders[pColumnItem->Count()-2].nPos +
3071cdf0e10cSrcweir 					pBorders[pColumnItem->Count()-2].nWidth;
3072cdf0e10cSrcweir 				nMaxLeft=Max(nMaxLeft,nNewMaxLeft);
3073cdf0e10cSrcweir 			}
3074cdf0e10cSrcweir 
3075cdf0e10cSrcweir 		}
3076cdf0e10cSrcweir 		break;
3077cdf0e10cSrcweir 	}
3078cdf0e10cSrcweir 	case RULER_TYPE_BORDER:
3079cdf0e10cSrcweir 	{                // Tabelle, Spalten (Modifier)
3080cdf0e10cSrcweir 		const sal_uInt16 nIdx = GetDragAryPos();
3081cdf0e10cSrcweir 		switch(GetDragSize())
3082cdf0e10cSrcweir 		{
3083cdf0e10cSrcweir 		  case RULER_DRAGSIZE_1 :
3084cdf0e10cSrcweir 			{
3085cdf0e10cSrcweir 				nMaxRight = pBorders[nIdx].nPos +
3086cdf0e10cSrcweir 					pBorders[nIdx].nWidth + lNullPix;
3087cdf0e10cSrcweir 
3088cdf0e10cSrcweir 				if(0 == nIdx)
3089cdf0e10cSrcweir 					nMaxLeft = lNullPix;
3090cdf0e10cSrcweir 				else
3091cdf0e10cSrcweir 					nMaxLeft = pBorders[nIdx-1].nPos +
3092cdf0e10cSrcweir 						pBorders[nIdx-1].nWidth + lNullPix;
3093cdf0e10cSrcweir 				if(nIdx == pColumnItem->GetActColumn())
3094cdf0e10cSrcweir 				{
3095cdf0e10cSrcweir 					if(bRTL)
3096cdf0e10cSrcweir 					{
3097cdf0e10cSrcweir 						nMaxLeft += pBorders[nIdx].nPos +
3098cdf0e10cSrcweir 							GetRightIndent() - Max(GetFirstLineIndent(),
3099cdf0e10cSrcweir 												   GetLeftIndent());
3100cdf0e10cSrcweir 					}
3101cdf0e10cSrcweir 					else
3102cdf0e10cSrcweir 					{
3103cdf0e10cSrcweir 						nMaxLeft += pBorders[nIdx].nPos -
3104cdf0e10cSrcweir 							GetRightIndent() + Max(GetFirstLineIndent(),
3105cdf0e10cSrcweir 												   GetLeftIndent());
3106cdf0e10cSrcweir 					}
3107cdf0e10cSrcweir 					if(0 != nIdx)
3108cdf0e10cSrcweir 						nMaxLeft -= pBorders[nIdx-1].nPos +
3109cdf0e10cSrcweir 							pBorders[nIdx-1].nWidth;
3110cdf0e10cSrcweir 				}
3111cdf0e10cSrcweir 				nMaxLeft += lMinFrame;
3112cdf0e10cSrcweir 				nMaxLeft += nDragOffset;
3113cdf0e10cSrcweir 				break;
3114cdf0e10cSrcweir 			}
3115cdf0e10cSrcweir 		  case RULER_DRAGSIZE_MOVE:
3116cdf0e10cSrcweir 			{
3117cdf0e10cSrcweir 				if(pColumnItem)
3118cdf0e10cSrcweir 				{
3119cdf0e10cSrcweir 					//nIdx contains the position of the currently moved item
3120cdf0e10cSrcweir 					//next visible separator on the left
3121cdf0e10cSrcweir 					sal_uInt16 nLeftCol=GetActLeftColumn(sal_False, nIdx);
3122cdf0e10cSrcweir 					//next visible separator on the right
3123cdf0e10cSrcweir 					sal_uInt16 nRightCol=GetActRightColumn(sal_False, nIdx);
3124cdf0e10cSrcweir 					//next separator on the left - regardless if visible or not
3125cdf0e10cSrcweir 					sal_uInt16 nActLeftCol=GetActLeftColumn();
3126cdf0e10cSrcweir 					//next separator on the right - regardless if visible or not
3127cdf0e10cSrcweir 					sal_uInt16 nActRightCol=GetActRightColumn();
3128cdf0e10cSrcweir                     if(pColumnItem->IsTable())
3129cdf0e10cSrcweir 					{
3130cdf0e10cSrcweir 						if(nDragType & DRAG_OBJECT_ACTLINE_ONLY)
3131cdf0e10cSrcweir 						{
3132cdf0e10cSrcweir 							//the current row/column should be modified only
3133cdf0e10cSrcweir 							//then the next/previous visible border position
3134cdf0e10cSrcweir 							//marks the min/max positions
3135cdf0e10cSrcweir 							nMaxLeft = nLeftCol == USHRT_MAX ?
3136cdf0e10cSrcweir 								0 :
3137cdf0e10cSrcweir 								pBorders[nLeftCol].nPos;
3138cdf0e10cSrcweir 							//rows can always be increased without a limit
3139cdf0e10cSrcweir 							if(pRuler_Imp->bIsTableRows)
3140cdf0e10cSrcweir 								nMaxRight = pBorders[nIdx].nMaxPos;
3141cdf0e10cSrcweir 							else
3142cdf0e10cSrcweir 								nMaxRight = nRightCol == USHRT_MAX ?
3143cdf0e10cSrcweir 									GetMargin2():
3144cdf0e10cSrcweir 									pBorders[nRightCol].nPos;
3145cdf0e10cSrcweir 							nMaxLeft += lNullPix;
3146cdf0e10cSrcweir 							nMaxRight += lNullPix;
3147cdf0e10cSrcweir 						}
3148cdf0e10cSrcweir 						else
3149cdf0e10cSrcweir 						{
3150cdf0e10cSrcweir 							if(DRAG_OBJECT_SIZE_PROPORTIONAL & nDragType && !bHorz && pRuler_Imp->bIsTableRows)
3151cdf0e10cSrcweir 								nMaxLeft = (nIdx + 1) * lMinFrame + lNullPix;
3152cdf0e10cSrcweir 							else
3153cdf0e10cSrcweir 								nMaxLeft = pBorders[nIdx].nMinPos + lNullPix;
3154cdf0e10cSrcweir 							if(DRAG_OBJECT_SIZE_PROPORTIONAL & nDragType||
3155cdf0e10cSrcweir 							(DRAG_OBJECT_SIZE_LINEAR & nDragType) )
3156cdf0e10cSrcweir 							{
3157cdf0e10cSrcweir 								if(pRuler_Imp->bIsTableRows)
3158cdf0e10cSrcweir 								{
3159cdf0e10cSrcweir 									if(bHorz)
3160cdf0e10cSrcweir 										nMaxRight = GetRightIndent() + lNullPix -
3161cdf0e10cSrcweir 												(pColumnItem->Count() - nIdx - 1) * lMinFrame;
3162cdf0e10cSrcweir 									else
3163cdf0e10cSrcweir 										nMaxRight = pBorders[nIdx].nMaxPos + lNullPix;
3164cdf0e10cSrcweir 								}
3165cdf0e10cSrcweir 								else
3166cdf0e10cSrcweir 									nMaxRight=lNullPix+CalcPropMaxRight(nIdx);
3167cdf0e10cSrcweir 							}
3168cdf0e10cSrcweir 							else
3169cdf0e10cSrcweir 								nMaxRight = pBorders[nIdx].nMaxPos + lNullPix;
3170cdf0e10cSrcweir 						}
3171cdf0e10cSrcweir 						nMaxLeft += lMinFrame;
3172cdf0e10cSrcweir 						nMaxRight -= lMinFrame;
3173cdf0e10cSrcweir 
3174cdf0e10cSrcweir 					}
3175cdf0e10cSrcweir 					else
3176cdf0e10cSrcweir 					{
3177cdf0e10cSrcweir                         if(nLeftCol==USHRT_MAX)
3178cdf0e10cSrcweir                             nMaxLeft=lNullPix;
3179cdf0e10cSrcweir                         else
3180cdf0e10cSrcweir                             nMaxLeft = pBorders[nLeftCol].nPos +
3181cdf0e10cSrcweir                                 pBorders[nLeftCol].nWidth + lNullPix;
3182cdf0e10cSrcweir 
3183cdf0e10cSrcweir                         if(nActRightCol == nIdx)
3184cdf0e10cSrcweir                         {
3185cdf0e10cSrcweir                             if(bRTL)
3186cdf0e10cSrcweir                             {
3187cdf0e10cSrcweir                                 nMaxLeft += pBorders[nIdx].nPos +
3188cdf0e10cSrcweir                                     GetRightIndent() - Max(GetFirstLineIndent(),
3189cdf0e10cSrcweir                                                            GetLeftIndent());
3190cdf0e10cSrcweir                                 if(nActLeftCol!=USHRT_MAX)
3191cdf0e10cSrcweir                                     nMaxLeft -= pBorders[nActLeftCol].nPos +
3192cdf0e10cSrcweir                                         pBorders[nActLeftCol].nWidth;
3193cdf0e10cSrcweir                             }
3194cdf0e10cSrcweir                             else
3195cdf0e10cSrcweir                             {
3196cdf0e10cSrcweir                                 nMaxLeft += pBorders[nIdx].nPos -
3197cdf0e10cSrcweir                                     GetRightIndent() + Max(GetFirstLineIndent(),
3198cdf0e10cSrcweir                                                            GetLeftIndent());
3199cdf0e10cSrcweir                                 if(nActLeftCol!=USHRT_MAX)
3200cdf0e10cSrcweir                                     nMaxLeft -= pBorders[nActLeftCol].nPos +
3201cdf0e10cSrcweir                                         pBorders[nActLeftCol].nWidth;
3202cdf0e10cSrcweir                             }
3203cdf0e10cSrcweir                         }
3204cdf0e10cSrcweir                         nMaxLeft += lMinFrame;
3205cdf0e10cSrcweir                         nMaxLeft += nDragOffset;
3206cdf0e10cSrcweir 
3207cdf0e10cSrcweir                         // nMaxRight
3208cdf0e10cSrcweir                         // linear / proprotional verschieben
3209cdf0e10cSrcweir                         if(DRAG_OBJECT_SIZE_PROPORTIONAL & nDragType||
3210cdf0e10cSrcweir                            (DRAG_OBJECT_SIZE_LINEAR & nDragType) )
3211cdf0e10cSrcweir                         {
3212cdf0e10cSrcweir                             nMaxRight=lNullPix+CalcPropMaxRight(nIdx);
3213cdf0e10cSrcweir                         }
3214cdf0e10cSrcweir                         else if(DRAG_OBJECT_SIZE_LINEAR & nDragType)
3215cdf0e10cSrcweir                         {
3216cdf0e10cSrcweir                             nMaxRight=lNullPix+GetMargin2()-GetMargin1()+
3217cdf0e10cSrcweir                                 (nBorderCount-nIdx-1)*lMinFrame;
3218cdf0e10cSrcweir                         }
3219cdf0e10cSrcweir                         else
3220cdf0e10cSrcweir                         {
3221cdf0e10cSrcweir                             if(nRightCol==USHRT_MAX)
3222cdf0e10cSrcweir                             { // letzte Spalte
3223cdf0e10cSrcweir                                 nMaxRight = GetMargin2() + lNullPix;
3224cdf0e10cSrcweir                                 if(IsActLastColumn())
3225cdf0e10cSrcweir                                 {
3226cdf0e10cSrcweir                                     if(bRTL)
3227cdf0e10cSrcweir                                     {
3228cdf0e10cSrcweir                                         nMaxRight -=
3229cdf0e10cSrcweir                                             GetMargin2() + GetRightIndent() -
3230cdf0e10cSrcweir                                                 Max(GetFirstLineIndent(),
3231cdf0e10cSrcweir                                                     GetLeftIndent());
3232cdf0e10cSrcweir                                     }
3233cdf0e10cSrcweir                                     else
3234cdf0e10cSrcweir                                     {
3235cdf0e10cSrcweir                                         nMaxRight -=
3236cdf0e10cSrcweir                                             GetMargin2() - GetRightIndent() +
3237cdf0e10cSrcweir                                                 Max(GetFirstLineIndent(),
3238cdf0e10cSrcweir                                                     GetLeftIndent());
3239cdf0e10cSrcweir                                     }
3240cdf0e10cSrcweir                                     nMaxRight += pBorders[nIdx].nPos +
3241cdf0e10cSrcweir                                         pBorders[nIdx].nWidth;
3242cdf0e10cSrcweir                                 }
3243cdf0e10cSrcweir                             }
3244cdf0e10cSrcweir                             else
3245cdf0e10cSrcweir                             {
3246cdf0e10cSrcweir                                 nMaxRight = lNullPix + pBorders[nRightCol].nPos;
3247cdf0e10cSrcweir                                 sal_uInt16 nNotHiddenRightCol =
3248cdf0e10cSrcweir                                     GetActRightColumn(sal_True, nIdx);
3249cdf0e10cSrcweir 
3250cdf0e10cSrcweir                                 if( nActLeftCol == nIdx )
3251cdf0e10cSrcweir                                 {
3252cdf0e10cSrcweir                                     long nBorder = nNotHiddenRightCol ==
3253cdf0e10cSrcweir                                         USHRT_MAX ?
3254cdf0e10cSrcweir                                         GetMargin2() :
3255cdf0e10cSrcweir                                         pBorders[nNotHiddenRightCol].nPos;
3256cdf0e10cSrcweir                                     if(bRTL)
3257cdf0e10cSrcweir                                     {
3258cdf0e10cSrcweir                                         nMaxRight -= nBorder + GetRightIndent() -
3259cdf0e10cSrcweir                                             Max(GetFirstLineIndent(),
3260cdf0e10cSrcweir                                                 GetLeftIndent());
3261cdf0e10cSrcweir                                     }
3262cdf0e10cSrcweir                                     else
3263cdf0e10cSrcweir                                     {
3264cdf0e10cSrcweir                                         nMaxRight -= nBorder - GetRightIndent() +
3265cdf0e10cSrcweir                                             Max(GetFirstLineIndent(),
3266cdf0e10cSrcweir                                                 GetLeftIndent());
3267cdf0e10cSrcweir                                     }
3268cdf0e10cSrcweir                                     nMaxRight += pBorders[nIdx].nPos +
3269cdf0e10cSrcweir                                         pBorders[nIdx].nWidth;
3270cdf0e10cSrcweir                                 }
3271cdf0e10cSrcweir                             }
3272cdf0e10cSrcweir                             nMaxRight -= lMinFrame;
3273cdf0e10cSrcweir                             nMaxRight -= pBorders[nIdx].nWidth;
3274cdf0e10cSrcweir                         }
3275cdf0e10cSrcweir                     }
3276cdf0e10cSrcweir 				}
3277cdf0e10cSrcweir 				// ObjectItem
3278cdf0e10cSrcweir 				else
3279cdf0e10cSrcweir 				{
3280cdf0e10cSrcweir 					if(pObjectItem->HasLimits())
3281cdf0e10cSrcweir 					{
3282cdf0e10cSrcweir 						if(CalcLimits(nMaxLeft, nMaxRight, nIdx & 1? sal_False : sal_True))
3283cdf0e10cSrcweir 						{
3284cdf0e10cSrcweir 							nMaxLeft = ConvertPosPixel(nMaxLeft);
3285cdf0e10cSrcweir 							nMaxRight = ConvertPosPixel(nMaxRight);
3286cdf0e10cSrcweir 						}
3287cdf0e10cSrcweir 					}
3288cdf0e10cSrcweir 					else
3289cdf0e10cSrcweir 					{
3290cdf0e10cSrcweir 						nMaxLeft = LONG_MIN;
3291cdf0e10cSrcweir 						nMaxRight = LONG_MAX;
3292cdf0e10cSrcweir 					}
3293cdf0e10cSrcweir 				}
3294cdf0e10cSrcweir 				break;
3295cdf0e10cSrcweir 			}
3296cdf0e10cSrcweir 		  case RULER_DRAGSIZE_2:
3297cdf0e10cSrcweir 			{
3298cdf0e10cSrcweir 				nMaxLeft = lNullPix + pBorders[nIdx].nPos;
3299cdf0e10cSrcweir 				if(nIdx == pColumnItem->Count()-2) { // letzte Spalte
3300cdf0e10cSrcweir 					nMaxRight = GetMargin2() + lNullPix;
3301cdf0e10cSrcweir 					if(pColumnItem->IsLastAct()) {
3302cdf0e10cSrcweir 						nMaxRight -=
3303cdf0e10cSrcweir 							GetMargin2() - GetRightIndent() +
3304cdf0e10cSrcweir 								Max(GetFirstLineIndent(),
3305cdf0e10cSrcweir 									GetLeftIndent());
3306cdf0e10cSrcweir 						nMaxRight += pBorders[nIdx].nPos +
3307cdf0e10cSrcweir 							pBorders[nIdx].nWidth;
3308cdf0e10cSrcweir 					}
3309cdf0e10cSrcweir 				}
3310cdf0e10cSrcweir 				else {
3311cdf0e10cSrcweir 					nMaxRight = lNullPix + pBorders[nIdx+1].nPos;
3312cdf0e10cSrcweir 					if(pColumnItem->GetActColumn()-1 == nIdx) {
3313cdf0e10cSrcweir 						nMaxRight -= pBorders[nIdx+1].nPos  - GetRightIndent() +
3314cdf0e10cSrcweir 							Max(GetFirstLineIndent(),
3315cdf0e10cSrcweir 								GetLeftIndent());
3316cdf0e10cSrcweir 						nMaxRight += pBorders[nIdx].nPos +
3317cdf0e10cSrcweir 							pBorders[nIdx].nWidth;
3318cdf0e10cSrcweir 					}
3319cdf0e10cSrcweir 			}
3320cdf0e10cSrcweir 				nMaxRight -= lMinFrame;
3321cdf0e10cSrcweir 				nMaxRight -= pBorders[nIdx].nWidth;
3322cdf0e10cSrcweir 				break;
3323cdf0e10cSrcweir 			}
3324cdf0e10cSrcweir 		}
3325cdf0e10cSrcweir 		nMaxRight += nDragOffset;
3326cdf0e10cSrcweir 		break;
3327cdf0e10cSrcweir 	}
3328cdf0e10cSrcweir 	  case RULER_TYPE_INDENT:
3329cdf0e10cSrcweir 		{
3330cdf0e10cSrcweir 		const sal_uInt16 nIdx = GetDragAryPos();
3331cdf0e10cSrcweir 		switch(nIdx) {
3332cdf0e10cSrcweir 		case INDENT_FIRST_LINE - INDENT_GAP:
3333cdf0e10cSrcweir 		case INDENT_LEFT_MARGIN - INDENT_GAP:
3334cdf0e10cSrcweir             {
3335cdf0e10cSrcweir                 if(bRTL)
3336cdf0e10cSrcweir                 {
3337cdf0e10cSrcweir                     nMaxLeft = lNullPix + GetRightIndent();
3338cdf0e10cSrcweir 
3339cdf0e10cSrcweir                     if(pColumnItem && !pColumnItem->IsFirstAct())
3340cdf0e10cSrcweir                         nMaxLeft += pBorders[pColumnItem->GetActColumn()-1].nPos +
3341cdf0e10cSrcweir                             pBorders[pColumnItem->GetActColumn()-1].nWidth;
3342cdf0e10cSrcweir                     nMaxRight = lNullPix + GetMargin2();
3343cdf0e10cSrcweir 
3344cdf0e10cSrcweir                     // zusammem draggen
3345cdf0e10cSrcweir                     if((INDENT_FIRST_LINE - INDENT_GAP) != nIdx &&
3346cdf0e10cSrcweir                        (nDragType & DRAG_OBJECT_LEFT_INDENT_ONLY) !=
3347cdf0e10cSrcweir                        DRAG_OBJECT_LEFT_INDENT_ONLY)
3348cdf0e10cSrcweir                     {
3349cdf0e10cSrcweir                         if(GetLeftIndent() > GetFirstLineIndent())
3350cdf0e10cSrcweir                             nMaxLeft += GetLeftIndent() - GetFirstLineIndent();
3351cdf0e10cSrcweir                         else
3352cdf0e10cSrcweir                             nMaxRight -= GetFirstLineIndent() - GetLeftIndent();
3353cdf0e10cSrcweir                     }
3354cdf0e10cSrcweir                 }
3355cdf0e10cSrcweir                 else
3356cdf0e10cSrcweir                 {
3357cdf0e10cSrcweir                     nMaxLeft = lNullPix;
3358cdf0e10cSrcweir 
3359cdf0e10cSrcweir                     if(pColumnItem && !pColumnItem->IsFirstAct())
3360cdf0e10cSrcweir                         nMaxLeft += pBorders[pColumnItem->GetActColumn()-1].nPos +
3361cdf0e10cSrcweir                             pBorders[pColumnItem->GetActColumn()-1].nWidth;
3362cdf0e10cSrcweir                     nMaxRight = lNullPix + GetRightIndent() - lMinFrame;
3363cdf0e10cSrcweir 
3364cdf0e10cSrcweir                     // zusammem draggen
3365cdf0e10cSrcweir                     if((INDENT_FIRST_LINE - INDENT_GAP) != nIdx &&
3366cdf0e10cSrcweir                        (nDragType & DRAG_OBJECT_LEFT_INDENT_ONLY) !=
3367cdf0e10cSrcweir                        DRAG_OBJECT_LEFT_INDENT_ONLY)
3368cdf0e10cSrcweir                     {
3369cdf0e10cSrcweir                         if(GetLeftIndent() > GetFirstLineIndent())
3370cdf0e10cSrcweir                             nMaxLeft += GetLeftIndent() - GetFirstLineIndent();
3371cdf0e10cSrcweir                         else
3372cdf0e10cSrcweir                             nMaxRight -= GetFirstLineIndent() - GetLeftIndent();
3373cdf0e10cSrcweir                     }
3374cdf0e10cSrcweir                 }
3375cdf0e10cSrcweir             }
3376cdf0e10cSrcweir           break;
3377cdf0e10cSrcweir           case INDENT_RIGHT_MARGIN - INDENT_GAP:
3378cdf0e10cSrcweir             {
3379cdf0e10cSrcweir                 if(bRTL)
3380cdf0e10cSrcweir                 {
3381cdf0e10cSrcweir                     nMaxLeft = lNullPix;
3382cdf0e10cSrcweir                     nMaxRight = lNullPix + Min(GetFirstLineIndent(), GetLeftIndent()) - lMinFrame;
3383cdf0e10cSrcweir                     if(pColumnItem)
3384cdf0e10cSrcweir                     {
3385cdf0e10cSrcweir                         sal_uInt16 nRightCol=GetActRightColumn( sal_True );
3386cdf0e10cSrcweir                         if(!IsActLastColumn( sal_True ))
3387cdf0e10cSrcweir                             nMaxRight += pBorders[nRightCol].nPos;
3388cdf0e10cSrcweir                         else
3389cdf0e10cSrcweir                             nMaxRight += GetMargin2();
3390cdf0e10cSrcweir                     }
3391cdf0e10cSrcweir                     else
3392cdf0e10cSrcweir                         nMaxLeft += GetMargin1();
3393cdf0e10cSrcweir                     nMaxLeft += lMinFrame;
3394cdf0e10cSrcweir                 }
3395cdf0e10cSrcweir                 else
3396cdf0e10cSrcweir                 {
3397cdf0e10cSrcweir                     nMaxLeft = lNullPix +
3398cdf0e10cSrcweir                         Max(GetFirstLineIndent(), GetLeftIndent());
3399cdf0e10cSrcweir                     nMaxRight = lNullPix;
3400cdf0e10cSrcweir                     if(pColumnItem)
3401cdf0e10cSrcweir                     {
3402cdf0e10cSrcweir                         sal_uInt16 nRightCol=GetActRightColumn( sal_True );
3403cdf0e10cSrcweir                         if(!IsActLastColumn( sal_True ))
3404cdf0e10cSrcweir                             nMaxRight += pBorders[nRightCol].nPos;
3405cdf0e10cSrcweir                         else
3406cdf0e10cSrcweir                             nMaxRight += GetMargin2();
3407cdf0e10cSrcweir                     }
3408cdf0e10cSrcweir                     else
3409cdf0e10cSrcweir                         nMaxRight += GetMargin2();
3410cdf0e10cSrcweir                     nMaxLeft += lMinFrame;
3411cdf0e10cSrcweir                 }
3412cdf0e10cSrcweir             }
3413cdf0e10cSrcweir             break;
3414cdf0e10cSrcweir 		}
3415cdf0e10cSrcweir 		break;
3416cdf0e10cSrcweir 	}
3417cdf0e10cSrcweir 	case RULER_TYPE_TAB:                // Tabs (Modifier)
3418cdf0e10cSrcweir 		/*
3419cdf0e10cSrcweir 		   links = NOf + Max(LAR, EZ)
3420cdf0e10cSrcweir 		   rechts = NOf + RAR
3421cdf0e10cSrcweir 		   */
3422cdf0e10cSrcweir 		nMaxLeft = bRTL ? lNullPix + GetRightIndent()
3423cdf0e10cSrcweir 							: lNullPix + Min(GetFirstLineIndent(), GetLeftIndent());
3424cdf0e10cSrcweir 		pRuler_Imp->lMaxRightLogic=GetLogicRightIndent()+lLogicNullOffset;
3425cdf0e10cSrcweir 		nMaxRight = ConvertSizePixel(pRuler_Imp->lMaxRightLogic);
3426cdf0e10cSrcweir 		break;
3427cdf0e10cSrcweir     default: ; //prevent warning
3428cdf0e10cSrcweir 	}
3429cdf0e10cSrcweir #ifdef DEBUGLIN
3430cdf0e10cSrcweir 	{
3431cdf0e10cSrcweir 		String aStr("MinLeft: ");
3432cdf0e10cSrcweir 		Size aSize(nMaxLeft + lNullPix, 0);
3433cdf0e10cSrcweir 		Size aSize2(nMaxRight + lNullPix, 0);
3434cdf0e10cSrcweir 		aSize = pEditWin->PixelToLogic(aSize, MapMode(MAP_MM));
3435cdf0e10cSrcweir 		aSize2 = pEditWin->PixelToLogic(aSize2, MapMode(MAP_MM));
3436cdf0e10cSrcweir 		aStr += String(aSize.Width());
3437cdf0e10cSrcweir 		aStr += " MaxRight: ";
3438cdf0e10cSrcweir 		aStr += String(aSize2.Width());
3439cdf0e10cSrcweir 		InfoBox(0, aStr).Execute();
3440cdf0e10cSrcweir 	}
3441cdf0e10cSrcweir #endif
3442cdf0e10cSrcweir }
3443cdf0e10cSrcweir 
3444cdf0e10cSrcweir 
StartDrag()3445cdf0e10cSrcweir long __EXPORT SvxRuler::StartDrag()
3446cdf0e10cSrcweir 
3447cdf0e10cSrcweir /*
3448cdf0e10cSrcweir    [Beschreibung]
3449cdf0e10cSrcweir 
3450cdf0e10cSrcweir    Beginn eines Drag-Vorgangs (SV-Handler); wertet Modifier aus
3451cdf0e10cSrcweir    und berechnet Grenzwerte
3452cdf0e10cSrcweir 
3453cdf0e10cSrcweir    [Querverweise]
3454cdf0e10cSrcweir 
3455cdf0e10cSrcweir    <SvxRuler::EvalModifier()>
3456cdf0e10cSrcweir    <SvxRuler::CalcMinMax()>
3457cdf0e10cSrcweir    <SvxRuler::EndDrag()>
3458cdf0e10cSrcweir 
3459cdf0e10cSrcweir */
3460cdf0e10cSrcweir 
3461cdf0e10cSrcweir {
3462cdf0e10cSrcweir     lcl_logRulerUse(::rtl::OUString::createFromAscii(".special://SfxRuler/StartDrag"));
3463cdf0e10cSrcweir 	sal_Bool bContentProtected = pRuler_Imp->aProtectItem.IsCntntProtected();
3464cdf0e10cSrcweir 	if(!bValid)
3465cdf0e10cSrcweir 		return sal_False;
3466cdf0e10cSrcweir 
3467cdf0e10cSrcweir 	pRuler_Imp->lLastLMargin=GetMargin1();
3468cdf0e10cSrcweir 	pRuler_Imp->lLastRMargin=GetMargin2();
3469cdf0e10cSrcweir 	long bOk = 1;
3470cdf0e10cSrcweir 	if(GetStartDragHdl().IsSet())
3471cdf0e10cSrcweir 		bOk = Ruler::StartDrag();
3472cdf0e10cSrcweir 	if(bOk) {
3473cdf0e10cSrcweir 		lInitialDragPos = GetDragPos();
3474cdf0e10cSrcweir 		switch(GetDragType()) {
3475cdf0e10cSrcweir 		case RULER_TYPE_MARGIN1:        // linker Rand umgebender Frame
3476cdf0e10cSrcweir 		case RULER_TYPE_MARGIN2:        // rechter Rand umgebender Frame
3477cdf0e10cSrcweir 			if((bHorz && pLRSpaceItem) || (!bHorz && pULSpaceItem))
3478cdf0e10cSrcweir 			{
3479cdf0e10cSrcweir 				if(pColumnItem)
3480cdf0e10cSrcweir 					EvalModifier();
3481cdf0e10cSrcweir 				else
3482cdf0e10cSrcweir 					nDragType = DRAG_OBJECT;
3483cdf0e10cSrcweir 			}
3484cdf0e10cSrcweir 			else
3485cdf0e10cSrcweir 				bOk = sal_False;
3486cdf0e10cSrcweir 			break;
3487cdf0e10cSrcweir 		case RULER_TYPE_BORDER:                // Tabelle, Spalten (Modifier)
3488cdf0e10cSrcweir 			if(pColumnItem)
3489cdf0e10cSrcweir 			{
3490cdf0e10cSrcweir 				nDragOffset = pColumnItem->IsTable()? 0 :
3491cdf0e10cSrcweir 				GetDragPos() - pBorders[GetDragAryPos()].nPos;
3492cdf0e10cSrcweir 				EvalModifier();
3493cdf0e10cSrcweir 
3494cdf0e10cSrcweir 			}
3495cdf0e10cSrcweir 			else
3496cdf0e10cSrcweir 				nDragOffset = 0;
3497cdf0e10cSrcweir 			break;
3498cdf0e10cSrcweir 		case RULER_TYPE_INDENT: {                // Absatzeinzuege (Modifier)
3499cdf0e10cSrcweir 			if( bContentProtected )
3500cdf0e10cSrcweir 				return sal_False;
3501cdf0e10cSrcweir 			sal_uInt16 nIndent = INDENT_LEFT_MARGIN;
3502cdf0e10cSrcweir             if((nIndent) == GetDragAryPos() + INDENT_GAP) {        // Linker Absatzeinzug
3503cdf0e10cSrcweir                 pIndents[0] = pIndents[INDENT_FIRST_LINE];
3504cdf0e10cSrcweir 				pIndents[0].nStyle |= RULER_STYLE_DONTKNOW;
3505cdf0e10cSrcweir 				EvalModifier();
3506cdf0e10cSrcweir 			}
3507cdf0e10cSrcweir 			else
3508cdf0e10cSrcweir 				nDragType = DRAG_OBJECT;
3509cdf0e10cSrcweir             pIndents[1] = pIndents[GetDragAryPos()+INDENT_GAP];
3510cdf0e10cSrcweir 			pIndents[1].nStyle |= RULER_STYLE_DONTKNOW;
3511cdf0e10cSrcweir 			break;
3512cdf0e10cSrcweir 		}
3513cdf0e10cSrcweir 		case RULER_TYPE_TAB:                // Tabs (Modifier)
3514cdf0e10cSrcweir 			if( bContentProtected ) return sal_False;
3515cdf0e10cSrcweir 			EvalModifier();
3516cdf0e10cSrcweir 			pTabs[0] = pTabs[GetDragAryPos()+1];
3517cdf0e10cSrcweir 			pTabs[0].nStyle |= RULER_STYLE_DONTKNOW;
3518cdf0e10cSrcweir 			break;
3519cdf0e10cSrcweir 		default:
3520cdf0e10cSrcweir 			nDragType = NONE;
3521cdf0e10cSrcweir 		}
3522cdf0e10cSrcweir 	}
3523cdf0e10cSrcweir 	else
3524cdf0e10cSrcweir 		nDragType = NONE;
3525cdf0e10cSrcweir 	if(bOk)
3526cdf0e10cSrcweir 		CalcMinMax();
3527cdf0e10cSrcweir 	return bOk;
3528cdf0e10cSrcweir }
3529cdf0e10cSrcweir 
3530cdf0e10cSrcweir 
Drag()3531cdf0e10cSrcweir void  __EXPORT SvxRuler::Drag()
3532cdf0e10cSrcweir /*
3533cdf0e10cSrcweir    [Beschreibung]
3534cdf0e10cSrcweir 
3535cdf0e10cSrcweir    SV-Draghandler
3536cdf0e10cSrcweir 
3537cdf0e10cSrcweir */
3538cdf0e10cSrcweir {
3539cdf0e10cSrcweir 	if(IsDragCanceled())
3540cdf0e10cSrcweir 	{
3541cdf0e10cSrcweir 		Ruler::Drag();
3542cdf0e10cSrcweir 		return;
3543cdf0e10cSrcweir 	}
3544cdf0e10cSrcweir 	switch(GetDragType()) {
3545cdf0e10cSrcweir 	case RULER_TYPE_MARGIN1:        // linker Rand umgebender Frame
3546cdf0e10cSrcweir 		DragMargin1();
3547cdf0e10cSrcweir 		pRuler_Imp->lLastLMargin=GetMargin1();
3548cdf0e10cSrcweir 		break;
3549cdf0e10cSrcweir 	case RULER_TYPE_MARGIN2:        // rechter Rand umgebender Frame
3550cdf0e10cSrcweir 		DragMargin2();
3551cdf0e10cSrcweir         pRuler_Imp->lLastRMargin = GetMargin2();
3552cdf0e10cSrcweir         break;
3553cdf0e10cSrcweir 	case RULER_TYPE_INDENT:         // Absatzeinzuege
3554cdf0e10cSrcweir 		DragIndents();
3555cdf0e10cSrcweir 		break;
3556cdf0e10cSrcweir 	case RULER_TYPE_BORDER:         // Tabelle, Spalten
3557cdf0e10cSrcweir 		if(pColumnItem)
3558cdf0e10cSrcweir 			DragBorders();
3559cdf0e10cSrcweir 		else if(pObjectItem)
3560cdf0e10cSrcweir 			DragObjectBorder();
3561cdf0e10cSrcweir 		break;
3562cdf0e10cSrcweir 	case RULER_TYPE_TAB:            // Tabs
3563cdf0e10cSrcweir 		DragTabs();
3564cdf0e10cSrcweir 		break;
3565cdf0e10cSrcweir     default: ;//prevent warning
3566cdf0e10cSrcweir 	}
3567cdf0e10cSrcweir 	Ruler::Drag();
3568cdf0e10cSrcweir }
3569cdf0e10cSrcweir 
3570cdf0e10cSrcweir 
EndDrag()3571cdf0e10cSrcweir void __EXPORT SvxRuler::EndDrag()
3572cdf0e10cSrcweir /*
3573cdf0e10cSrcweir    [Beschreibung]
3574cdf0e10cSrcweir 
3575cdf0e10cSrcweir    SV-Handler; wird beim Beenden des Draggens gerufen.
3576cdf0e10cSrcweir    Stoesst die Aktualisierung der Daten der Applikation an, indem
3577cdf0e10cSrcweir    durch Aufruf der jeweiligen Apply...()- Methoden die Daten an die
3578cdf0e10cSrcweir    Applikation geschickt werden.
3579cdf0e10cSrcweir 
3580cdf0e10cSrcweir */
3581cdf0e10cSrcweir {
3582cdf0e10cSrcweir     lcl_logRulerUse(::rtl::OUString::createFromAscii(".special://SfxRuler/EndDrag"));
3583cdf0e10cSrcweir 	const sal_Bool bUndo = IsDragCanceled();
3584cdf0e10cSrcweir 	const long lPos = GetDragPos();
3585cdf0e10cSrcweir 	DrawLine_Impl(lTabPos, 6, bHorz);
3586cdf0e10cSrcweir 	lTabPos=-1;
3587cdf0e10cSrcweir 	if(!bUndo)
3588cdf0e10cSrcweir 		switch(GetDragType())
3589cdf0e10cSrcweir 		{
3590cdf0e10cSrcweir 		  case RULER_TYPE_MARGIN1:   // linker, oberer Rand umgebender Frame
3591cdf0e10cSrcweir 		  case RULER_TYPE_MARGIN2:   // rechter, unterer Rand umgebender Frame
3592cdf0e10cSrcweir 			{
3593cdf0e10cSrcweir 				if(!pColumnItem || !pColumnItem->IsTable())
3594cdf0e10cSrcweir 					ApplyMargins();
3595cdf0e10cSrcweir 
3596cdf0e10cSrcweir 				if(pColumnItem &&
3597cdf0e10cSrcweir 				   (pColumnItem->IsTable() ||
3598cdf0e10cSrcweir 					(nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)))
3599cdf0e10cSrcweir 					ApplyBorders();
3600cdf0e10cSrcweir 
3601cdf0e10cSrcweir 			}
3602cdf0e10cSrcweir 			break;
3603cdf0e10cSrcweir 		  case RULER_TYPE_BORDER:                // Tabelle, Spalten
3604cdf0e10cSrcweir 			if(lInitialDragPos != lPos ||
3605cdf0e10cSrcweir 				(pRuler_Imp->bIsTableRows && bHorz)) //special case - the null offset is changed here
3606cdf0e10cSrcweir 			{
3607cdf0e10cSrcweir 				if(pColumnItem)
3608cdf0e10cSrcweir 				{
3609cdf0e10cSrcweir 					ApplyBorders();
3610cdf0e10cSrcweir 					if(bHorz)
3611cdf0e10cSrcweir 						UpdateTabs();
3612cdf0e10cSrcweir 				}
3613cdf0e10cSrcweir 				else if(pObjectItem)
3614cdf0e10cSrcweir 					ApplyObject();
3615cdf0e10cSrcweir 			}
3616cdf0e10cSrcweir 			break;
3617cdf0e10cSrcweir 		  case RULER_TYPE_INDENT:                // Absatzeinzuege
3618cdf0e10cSrcweir 			if(lInitialDragPos != lPos)
3619cdf0e10cSrcweir 				ApplyIndents();
3620cdf0e10cSrcweir             SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
3621cdf0e10cSrcweir 			break;
3622cdf0e10cSrcweir 		  case RULER_TYPE_TAB:                // Tabs
3623cdf0e10cSrcweir 			{
3624cdf0e10cSrcweir 				ApplyTabs();
3625cdf0e10cSrcweir 				pTabs[GetDragAryPos()].nStyle &= ~RULER_STYLE_INVISIBLE;
3626cdf0e10cSrcweir 				SetTabs(nTabCount, pTabs+TAB_GAP);
3627cdf0e10cSrcweir 			}
3628cdf0e10cSrcweir 			break;
3629cdf0e10cSrcweir             default: ; //prevent warning
3630cdf0e10cSrcweir         }
3631cdf0e10cSrcweir 	nDragType = NONE;
3632cdf0e10cSrcweir 	Ruler::EndDrag();
3633cdf0e10cSrcweir 	if(bUndo)
3634cdf0e10cSrcweir 		for(sal_uInt16 i=0;i<pRuler_Imp->nControlerItems;i++)
3635cdf0e10cSrcweir 		{
3636cdf0e10cSrcweir 			pCtrlItem[i]->ClearCache();
3637cdf0e10cSrcweir 			pCtrlItem[i]->GetBindings().Invalidate(pCtrlItem[i]->GetId());
3638cdf0e10cSrcweir 			//		pCtrlItem[i]->UnBind();
3639cdf0e10cSrcweir //			pCtrlItem[i]->ReBind();
3640cdf0e10cSrcweir 		}
3641cdf0e10cSrcweir }
3642cdf0e10cSrcweir 
3643cdf0e10cSrcweir 
ExtraDown()3644cdf0e10cSrcweir void __EXPORT SvxRuler::ExtraDown()
3645cdf0e10cSrcweir 
3646cdf0e10cSrcweir /*
3647cdf0e10cSrcweir    [Beschreibung]
3648cdf0e10cSrcweir 
3649cdf0e10cSrcweir    Ueberladene SV-Methode; setzt den neuen Typ fuer den Defaulttabulator.
3650cdf0e10cSrcweir */
3651cdf0e10cSrcweir 
3652cdf0e10cSrcweir {
3653cdf0e10cSrcweir 	// Tabulator Typ umschalten
3654cdf0e10cSrcweir 	if(pTabStopItem &&
3655cdf0e10cSrcweir 		(nFlags & SVXRULER_SUPPORT_TABS) ==        SVXRULER_SUPPORT_TABS) {
3656cdf0e10cSrcweir 		++nDefTabType;
3657cdf0e10cSrcweir 		if(RULER_TAB_DEFAULT == nDefTabType)
3658cdf0e10cSrcweir 			nDefTabType = RULER_TAB_LEFT;
3659cdf0e10cSrcweir 		SetExtraType(RULER_EXTRA_TAB, nDefTabType);
3660cdf0e10cSrcweir 	}
3661cdf0e10cSrcweir 	Ruler::ExtraDown();
3662cdf0e10cSrcweir }
3663cdf0e10cSrcweir 
3664cdf0e10cSrcweir 
Notify(SfxBroadcaster &,const SfxHint & rHint)3665cdf0e10cSrcweir void __EXPORT SvxRuler::Notify(SfxBroadcaster&, const SfxHint& rHint)
3666cdf0e10cSrcweir /*
3667cdf0e10cSrcweir 
3668cdf0e10cSrcweir    [Beschreibung]
3669cdf0e10cSrcweir 
3670cdf0e10cSrcweir    Benachrichtigung durch die Bindings, dass die Statusaktualisierung
3671cdf0e10cSrcweir    beendet ist.
3672cdf0e10cSrcweir    Das Lineal aktualisiert seine Darstellung und meldet sich bei den
3673cdf0e10cSrcweir    Bindings wieder ab.
3674cdf0e10cSrcweir 
3675cdf0e10cSrcweir */
3676cdf0e10cSrcweir 
3677cdf0e10cSrcweir {
3678cdf0e10cSrcweir 	// Aktualisierung anstossen
3679cdf0e10cSrcweir 	if(bActive &&
3680cdf0e10cSrcweir 		rHint.Type() == TYPE(SfxSimpleHint) &&
3681cdf0e10cSrcweir 	 ((SfxSimpleHint&) rHint ).GetId() == SFX_HINT_UPDATEDONE ) {
3682cdf0e10cSrcweir 		Update();
3683cdf0e10cSrcweir 		EndListening(*pBindings);
3684cdf0e10cSrcweir 		bValid = sal_True;
3685cdf0e10cSrcweir 		bListening = sal_False;
3686cdf0e10cSrcweir 	}
3687cdf0e10cSrcweir }
3688cdf0e10cSrcweir 
3689cdf0e10cSrcweir 
IMPL_LINK_INLINE_START(SvxRuler,MenuSelect,Menu *,pMenu)3690cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvxRuler, MenuSelect, Menu *, pMenu )
3691cdf0e10cSrcweir 
3692cdf0e10cSrcweir /*
3693cdf0e10cSrcweir    [Beschreibung]
3694cdf0e10cSrcweir 
3695cdf0e10cSrcweir    Handler des Kontextmenues fuer das Umschalten der Masseinheit
3696cdf0e10cSrcweir 
3697cdf0e10cSrcweir */
3698cdf0e10cSrcweir 
3699cdf0e10cSrcweir {
3700cdf0e10cSrcweir 	SetUnit(FieldUnit(pMenu->GetCurItemId()));
3701cdf0e10cSrcweir 	return 0;
3702cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(SvxRuler,MenuSelect,Menu *,pMenu)3703cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvxRuler, MenuSelect, Menu *, pMenu )
3704cdf0e10cSrcweir 
3705cdf0e10cSrcweir 
3706cdf0e10cSrcweir IMPL_LINK( SvxRuler, TabMenuSelect, Menu *, pMenu )
3707cdf0e10cSrcweir 
3708cdf0e10cSrcweir /*
3709cdf0e10cSrcweir    [Beschreibung]
3710cdf0e10cSrcweir 
3711cdf0e10cSrcweir    Handler des Tabulatormenues fuer das Setzen des Typs
3712cdf0e10cSrcweir 
3713cdf0e10cSrcweir */
3714cdf0e10cSrcweir 
3715cdf0e10cSrcweir {
3716cdf0e10cSrcweir     if(pTabStopItem && pTabStopItem->Count() > pRuler_Imp->nIdx)
3717cdf0e10cSrcweir     {
3718cdf0e10cSrcweir         SvxTabStop aTabStop = (*pTabStopItem)[pRuler_Imp->nIdx];
3719cdf0e10cSrcweir         aTabStop.GetAdjustment() = ToAttrTab_Impl(pMenu->GetCurItemId()-1);
3720cdf0e10cSrcweir         pTabStopItem->Remove(pRuler_Imp->nIdx);
3721cdf0e10cSrcweir         pTabStopItem->Insert(aTabStop);
3722cdf0e10cSrcweir         sal_uInt16 nTabStopId = bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL;
3723cdf0e10cSrcweir         pBindings->GetDispatcher()->Execute( nTabStopId, SFX_CALLMODE_RECORD, pTabStopItem, 0L );
3724cdf0e10cSrcweir         UpdateTabs();
3725cdf0e10cSrcweir         pRuler_Imp->nIdx = 0;
3726cdf0e10cSrcweir     }
3727cdf0e10cSrcweir 	return 0;
3728cdf0e10cSrcweir }
3729cdf0e10cSrcweir 
3730cdf0e10cSrcweir 
Command(const CommandEvent & rCEvt)3731cdf0e10cSrcweir void SvxRuler::Command( const CommandEvent& rCEvt )
3732cdf0e10cSrcweir 
3733cdf0e10cSrcweir /*
3734cdf0e10cSrcweir    [Beschreibung]
3735cdf0e10cSrcweir 
3736cdf0e10cSrcweir    Mauskontextmenue fuer das Umschalten der Masseinheit
3737cdf0e10cSrcweir 
3738cdf0e10cSrcweir */
3739cdf0e10cSrcweir 
3740cdf0e10cSrcweir {
3741cdf0e10cSrcweir 	if ( COMMAND_CONTEXTMENU == rCEvt.GetCommand() )
3742cdf0e10cSrcweir 	{
3743cdf0e10cSrcweir 		CancelDrag();
3744cdf0e10cSrcweir         sal_Bool bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
3745cdf0e10cSrcweir 		if ( pTabs &&
3746cdf0e10cSrcweir 			 RULER_TYPE_TAB ==
3747cdf0e10cSrcweir 			 GetType( rCEvt.GetMousePosPixel(), &pRuler_Imp->nIdx ) &&
3748cdf0e10cSrcweir 			 pTabs[pRuler_Imp->nIdx+TAB_GAP].nStyle < RULER_TAB_DEFAULT )
3749cdf0e10cSrcweir 		{
3750cdf0e10cSrcweir 			PopupMenu aMenu;
3751cdf0e10cSrcweir 			aMenu.SetSelectHdl(LINK(this, SvxRuler, TabMenuSelect));
3752cdf0e10cSrcweir 			VirtualDevice aDev;
3753cdf0e10cSrcweir 			const Size aSz(RULER_TAB_WIDTH+2, RULER_TAB_HEIGHT+2);
3754cdf0e10cSrcweir 			aDev.SetOutputSize(aSz);
3755cdf0e10cSrcweir 			aDev.SetBackground(Wallpaper(Color(COL_WHITE)));
3756cdf0e10cSrcweir 			const Point aPt(aSz.Width() / 2, aSz.Height() / 2);
3757cdf0e10cSrcweir 
3758cdf0e10cSrcweir 			for ( sal_uInt16 i = RULER_TAB_LEFT; i < RULER_TAB_DEFAULT; ++i )
3759cdf0e10cSrcweir 			{
3760cdf0e10cSrcweir                 sal_uInt16 nStyle = bRTL ? i|RULER_TAB_RTL : i;
3761cdf0e10cSrcweir 				nStyle |= (sal_uInt16)(bHorz ? WB_HORZ : WB_VERT);
3762cdf0e10cSrcweir 				DrawTab(&aDev, aPt, nStyle);
3763cdf0e10cSrcweir 				aMenu.InsertItem(i+1,
3764cdf0e10cSrcweir 								 String(ResId(RID_SVXSTR_RULER_START+i, DIALOG_MGR())),
3765cdf0e10cSrcweir 								 Image(aDev.GetBitmap(Point(), aSz), Color(COL_WHITE)));
3766cdf0e10cSrcweir 				aMenu.CheckItem(i+1, i == pTabs[pRuler_Imp->nIdx+TAB_GAP].nStyle);
3767cdf0e10cSrcweir 				aDev.SetOutputSize(aSz); // device loeschen
3768cdf0e10cSrcweir 			}
3769cdf0e10cSrcweir 			aMenu.Execute( this, rCEvt.GetMousePosPixel() );
3770cdf0e10cSrcweir 		}
3771cdf0e10cSrcweir 		else
3772cdf0e10cSrcweir 		{
3773cdf0e10cSrcweir 			PopupMenu aMenu(ResId(RID_SVXMN_RULER, DIALOG_MGR()));
3774cdf0e10cSrcweir 			aMenu.SetSelectHdl(LINK(this, SvxRuler, MenuSelect));
3775cdf0e10cSrcweir 			FieldUnit eUnit = GetUnit();
3776cdf0e10cSrcweir 			const sal_uInt16 nCount = aMenu.GetItemCount();
3777cdf0e10cSrcweir 
3778cdf0e10cSrcweir             sal_Bool bReduceMetric = 0 != (nFlags &SVXRULER_SUPPORT_REDUCED_METRIC);
3779cdf0e10cSrcweir             for ( sal_uInt16 i = nCount; i; --i )
3780cdf0e10cSrcweir 			{
3781cdf0e10cSrcweir                 const sal_uInt16 nId = aMenu.GetItemId(i - 1);
3782cdf0e10cSrcweir 				aMenu.CheckItem(nId, nId == (sal_uInt16)eUnit);
3783cdf0e10cSrcweir                 if(bReduceMetric &&
3784cdf0e10cSrcweir                         (nId == FUNIT_M ||
3785cdf0e10cSrcweir                          nId == FUNIT_KM ||
3786cdf0e10cSrcweir                          nId == FUNIT_FOOT ||
3787cdf0e10cSrcweir                          nId == FUNIT_MILE ))
3788cdf0e10cSrcweir                     aMenu.RemoveItem(i - 1);
3789cdf0e10cSrcweir 			}
3790cdf0e10cSrcweir 			aMenu.Execute( this, rCEvt.GetMousePosPixel() );
3791cdf0e10cSrcweir 		}
3792cdf0e10cSrcweir 	}
3793cdf0e10cSrcweir 	else
3794cdf0e10cSrcweir 		Ruler::Command( rCEvt );
3795cdf0e10cSrcweir }
3796cdf0e10cSrcweir 
3797cdf0e10cSrcweir 
GetActRightColumn(sal_Bool bForceDontConsiderHidden,sal_uInt16 nAct) const3798cdf0e10cSrcweir sal_uInt16 SvxRuler::GetActRightColumn(
3799cdf0e10cSrcweir 	sal_Bool bForceDontConsiderHidden, sal_uInt16 nAct ) const
3800cdf0e10cSrcweir {
3801cdf0e10cSrcweir 	if( nAct == USHRT_MAX )
3802cdf0e10cSrcweir 		nAct = pColumnItem->GetActColumn();
3803cdf0e10cSrcweir 	else nAct++; //Damit man die ActDrag uebergeben kann
3804cdf0e10cSrcweir 
3805cdf0e10cSrcweir 	sal_Bool bConsiderHidden = !bForceDontConsiderHidden &&
3806cdf0e10cSrcweir 		!( nDragType & DRAG_OBJECT_ACTLINE_ONLY );
3807cdf0e10cSrcweir 
3808cdf0e10cSrcweir 	while( nAct < pColumnItem->Count() - 1 )
3809cdf0e10cSrcweir 	{
3810cdf0e10cSrcweir 		if( (*pColumnItem)[nAct].bVisible || bConsiderHidden )
3811cdf0e10cSrcweir 			return nAct;
3812cdf0e10cSrcweir 		else
3813cdf0e10cSrcweir 			nAct++;
3814cdf0e10cSrcweir 	}
3815cdf0e10cSrcweir 	return USHRT_MAX;
3816cdf0e10cSrcweir }
3817cdf0e10cSrcweir 
3818cdf0e10cSrcweir 
3819cdf0e10cSrcweir 
GetActLeftColumn(sal_Bool bForceDontConsiderHidden,sal_uInt16 nAct) const3820cdf0e10cSrcweir sal_uInt16 SvxRuler::GetActLeftColumn(
3821cdf0e10cSrcweir 	sal_Bool bForceDontConsiderHidden, sal_uInt16 nAct ) const
3822cdf0e10cSrcweir {
3823cdf0e10cSrcweir 	if(nAct==USHRT_MAX)
3824cdf0e10cSrcweir 		nAct=pColumnItem->GetActColumn();
3825cdf0e10cSrcweir 
3826cdf0e10cSrcweir 	sal_uInt16 nLOffs=1;
3827cdf0e10cSrcweir 
3828cdf0e10cSrcweir 	sal_Bool bConsiderHidden = !bForceDontConsiderHidden &&
3829cdf0e10cSrcweir 		!( nDragType & DRAG_OBJECT_ACTLINE_ONLY );
3830cdf0e10cSrcweir 
3831cdf0e10cSrcweir 	while(nAct>=nLOffs)
3832cdf0e10cSrcweir 	{
3833cdf0e10cSrcweir 		if( (*pColumnItem)[ nAct - nLOffs ].bVisible || bConsiderHidden )
3834cdf0e10cSrcweir 			return nAct-nLOffs;
3835cdf0e10cSrcweir 		else
3836cdf0e10cSrcweir 			nLOffs++;
3837cdf0e10cSrcweir 	}
3838cdf0e10cSrcweir 	return USHRT_MAX;
3839cdf0e10cSrcweir }
3840cdf0e10cSrcweir 
3841cdf0e10cSrcweir 
IsActLastColumn(sal_Bool bForceDontConsiderHidden,sal_uInt16 nAct) const3842cdf0e10cSrcweir sal_Bool SvxRuler::IsActLastColumn(
3843cdf0e10cSrcweir 	sal_Bool bForceDontConsiderHidden, sal_uInt16 nAct) const
3844cdf0e10cSrcweir {
3845cdf0e10cSrcweir 	return GetActRightColumn(bForceDontConsiderHidden, nAct)==USHRT_MAX;
3846cdf0e10cSrcweir }
3847cdf0e10cSrcweir 
IsActFirstColumn(sal_Bool bForceDontConsiderHidden,sal_uInt16 nAct) const3848cdf0e10cSrcweir sal_Bool SvxRuler::IsActFirstColumn(
3849cdf0e10cSrcweir 	sal_Bool bForceDontConsiderHidden, sal_uInt16 nAct) const
3850cdf0e10cSrcweir {
3851cdf0e10cSrcweir 	return GetActLeftColumn(bForceDontConsiderHidden, nAct)==USHRT_MAX;
3852cdf0e10cSrcweir }
3853cdf0e10cSrcweir 
CalcPropMaxRight(sal_uInt16 nCol) const3854cdf0e10cSrcweir long SvxRuler::CalcPropMaxRight(sal_uInt16 nCol) const
3855cdf0e10cSrcweir {
3856cdf0e10cSrcweir 
3857cdf0e10cSrcweir 	if(!(nDragType & DRAG_OBJECT_SIZE_LINEAR))
3858cdf0e10cSrcweir 	{
3859cdf0e10cSrcweir 
3860cdf0e10cSrcweir 		// ausgehend vom rechten Rand die Mindestbreiten
3861cdf0e10cSrcweir 		// aller betroffenen Spalten abziehen
3862cdf0e10cSrcweir         long _nMaxRight = GetMargin2()-GetMargin1();
3863cdf0e10cSrcweir 
3864cdf0e10cSrcweir 		long lFences=0;
3865cdf0e10cSrcweir 		long lMinSpace=USHRT_MAX;
3866cdf0e10cSrcweir 		long lOldPos;
3867cdf0e10cSrcweir 		long lColumns=0;
3868cdf0e10cSrcweir 		sal_uInt16 nStart;
3869cdf0e10cSrcweir 		if(!pColumnItem->IsTable())
3870cdf0e10cSrcweir 		{
3871cdf0e10cSrcweir 			if(nCol==USHRT_MAX)
3872cdf0e10cSrcweir 			{
3873cdf0e10cSrcweir 				lOldPos=GetMargin1();
3874cdf0e10cSrcweir 				nStart=0;
3875cdf0e10cSrcweir 			}
3876cdf0e10cSrcweir 			else
3877cdf0e10cSrcweir 			{
3878cdf0e10cSrcweir 				lOldPos=pBorders[nCol].nPos+pBorders[nCol].nWidth;
3879cdf0e10cSrcweir 				nStart=nCol+1;
3880cdf0e10cSrcweir 				lFences=pBorders[nCol].nWidth;
3881cdf0e10cSrcweir 			}
3882cdf0e10cSrcweir 
3883cdf0e10cSrcweir 			for(sal_uInt16 i = nStart; i < nBorderCount-1; ++i)
3884cdf0e10cSrcweir 			{
3885cdf0e10cSrcweir 				long lWidth=pBorders[i].nPos-lOldPos;
3886cdf0e10cSrcweir 				lColumns+=lWidth;
3887cdf0e10cSrcweir 				if(lWidth<lMinSpace)
3888cdf0e10cSrcweir 					lMinSpace=lWidth;
3889cdf0e10cSrcweir 				lOldPos=pBorders[i].nPos+pBorders[i].nWidth;
3890cdf0e10cSrcweir 				lFences+=pBorders[i].nWidth;
3891cdf0e10cSrcweir 			}
3892cdf0e10cSrcweir 			long lWidth=GetMargin2()-lOldPos;
3893cdf0e10cSrcweir 			lColumns+=lWidth;
3894cdf0e10cSrcweir 			if(lWidth<lMinSpace)
3895cdf0e10cSrcweir 				lMinSpace=lWidth;
3896cdf0e10cSrcweir 		}
3897cdf0e10cSrcweir 		else
3898cdf0e10cSrcweir 		{
3899cdf0e10cSrcweir 			sal_uInt16 nActCol;
3900cdf0e10cSrcweir 			if(nCol==USHRT_MAX) //CalcMinMax fuer LeftMargin
3901cdf0e10cSrcweir 			{
3902cdf0e10cSrcweir 				lOldPos=GetMargin1();
3903cdf0e10cSrcweir 			}
3904cdf0e10cSrcweir 			else
3905cdf0e10cSrcweir 			{
3906cdf0e10cSrcweir 				lOldPos=pBorders[nCol].nPos;
3907cdf0e10cSrcweir 			}
3908cdf0e10cSrcweir 			lColumns=GetMargin2()-lOldPos;
3909cdf0e10cSrcweir 			nActCol=nCol;
3910cdf0e10cSrcweir 			lFences=0;
3911cdf0e10cSrcweir 			while(nActCol<nBorderCount||nActCol==USHRT_MAX)
3912cdf0e10cSrcweir 			{
3913cdf0e10cSrcweir 				sal_uInt16 nRight;
3914cdf0e10cSrcweir 				if(nActCol==USHRT_MAX)
3915cdf0e10cSrcweir 				{
3916cdf0e10cSrcweir 					nRight=0;
3917cdf0e10cSrcweir 					while(!(*pColumnItem)[nRight].bVisible)
3918cdf0e10cSrcweir 						nRight++;
3919cdf0e10cSrcweir 				}
3920cdf0e10cSrcweir 				else
3921cdf0e10cSrcweir 					nRight=GetActRightColumn(sal_False, nActCol);
3922cdf0e10cSrcweir 				long lWidth;
3923cdf0e10cSrcweir 				if(nRight!=USHRT_MAX)
3924cdf0e10cSrcweir 				{
3925cdf0e10cSrcweir 					lWidth=pBorders[nRight].nPos-lOldPos;
3926cdf0e10cSrcweir 					lOldPos=pBorders[nRight].nPos;
3927cdf0e10cSrcweir 				}
3928cdf0e10cSrcweir 				else
3929cdf0e10cSrcweir 					lWidth=GetMargin2()-lOldPos;
3930cdf0e10cSrcweir 				nActCol=nRight;
3931cdf0e10cSrcweir 				if(lWidth<lMinSpace)
3932cdf0e10cSrcweir 					lMinSpace=lWidth;
3933cdf0e10cSrcweir 				if(nActCol==USHRT_MAX)
3934cdf0e10cSrcweir 					break;
3935cdf0e10cSrcweir 			}
3936cdf0e10cSrcweir 		}
3937cdf0e10cSrcweir 
3938cdf0e10cSrcweir         _nMaxRight-=(long)(lFences+lMinFrame/(float)lMinSpace*lColumns);
3939cdf0e10cSrcweir         return _nMaxRight;
3940cdf0e10cSrcweir 	}
3941cdf0e10cSrcweir 	else
3942cdf0e10cSrcweir 	{
3943cdf0e10cSrcweir 		if(pColumnItem->IsTable())
3944cdf0e10cSrcweir 		{
3945cdf0e10cSrcweir 			sal_uInt16 nVisCols=0;
3946cdf0e10cSrcweir 			for(sal_uInt16 i=GetActRightColumn(sal_False, nCol);i<nBorderCount;)
3947cdf0e10cSrcweir 			{
3948cdf0e10cSrcweir 				if((*pColumnItem)[i].bVisible)
3949cdf0e10cSrcweir 					nVisCols++;
3950cdf0e10cSrcweir 				i=GetActRightColumn(sal_False, i);
3951cdf0e10cSrcweir 			}
3952cdf0e10cSrcweir 			return GetMargin2()-GetMargin1()-(nVisCols+1)*lMinFrame;
3953cdf0e10cSrcweir 		}
3954cdf0e10cSrcweir 		else
3955cdf0e10cSrcweir 		{
3956cdf0e10cSrcweir 			long lWidth=0;
3957cdf0e10cSrcweir 			for(sal_uInt16 i=nCol;i<nBorderCount-1;i++)
3958cdf0e10cSrcweir 			{
3959cdf0e10cSrcweir 				lWidth+=lMinFrame+pBorders[i].nWidth;
3960cdf0e10cSrcweir 			}
3961cdf0e10cSrcweir 			return GetMargin2()-GetMargin1()-lWidth;
3962cdf0e10cSrcweir 		}
3963cdf0e10cSrcweir 	}
3964cdf0e10cSrcweir }
3965cdf0e10cSrcweir /*-- 29.11.2007 08:24:23---------------------------------------------------
3966cdf0e10cSrcweir     //#i24363# tab stops relative to indent
3967cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetTabsRelativeToIndent(sal_Bool bRel)3968cdf0e10cSrcweir void SvxRuler::SetTabsRelativeToIndent( sal_Bool bRel )
3969cdf0e10cSrcweir {
3970cdf0e10cSrcweir     pRuler_Imp->bIsTabsRelativeToIndent = bRel;
3971cdf0e10cSrcweir }
3972cdf0e10cSrcweir 
3973