xref: /AOO41X/main/svtools/source/control/ruler.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svtools.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <string.h>
32*cdf0e10cSrcweir #include <tools/debug.hxx>
33*cdf0e10cSrcweir #include <vcl/svapp.hxx>
34*cdf0e10cSrcweir #include <tools/poly.hxx>
35*cdf0e10cSrcweir #include <vcl/i18nhelp.hxx>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #define _SV_RULER_CXX
38*cdf0e10cSrcweir #include <svtools/ruler.hxx>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir // =======================================================================
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #define RULER_OFF           3
43*cdf0e10cSrcweir #define RULER_TEXTOFF       2
44*cdf0e10cSrcweir #define RULER_RESIZE_OFF    4
45*cdf0e10cSrcweir #define RULER_LINE_WIDTH    7
46*cdf0e10cSrcweir #define RULER_MIN_SIZE      3
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir #define RULER_TICK1_WIDTH   1
49*cdf0e10cSrcweir #define RULER_TICK2_WIDTH   3
50*cdf0e10cSrcweir #define RULER_TICK3_WIDTH   5
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir #define RULER_VAR_SIZE      8
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir #define RULER_TAB_HEIGHT2   2
55*cdf0e10cSrcweir #define RULER_TAB_WIDTH2    2
56*cdf0e10cSrcweir #define RULER_TAB_CWIDTH    8
57*cdf0e10cSrcweir #define RULER_TAB_CWIDTH2   4
58*cdf0e10cSrcweir #define RULER_TAB_CWIDTH3   4
59*cdf0e10cSrcweir #define RULER_TAB_CWIDTH4   2
60*cdf0e10cSrcweir #define RULER_TAB_DHEIGHT   4
61*cdf0e10cSrcweir #define RULER_TAB_DHEIGHT2  1
62*cdf0e10cSrcweir #define RULER_TAB_DWIDTH    5
63*cdf0e10cSrcweir #define RULER_TAB_DWIDTH2   3
64*cdf0e10cSrcweir #define RULER_TAB_DWIDTH3   3
65*cdf0e10cSrcweir #define RULER_TAB_DWIDTH4   1
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir #define RULER_UPDATE_LINES  0x01
68*cdf0e10cSrcweir #define RULER_UPDATE_DRAW   0x02
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir #define RULER_CLIP          150
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir // =======================================================================
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir #define RULER_UNIT_MM       0
75*cdf0e10cSrcweir #define RULER_UNIT_CM       1
76*cdf0e10cSrcweir #define RULER_UNIT_M        2
77*cdf0e10cSrcweir #define RULER_UNIT_KM       3
78*cdf0e10cSrcweir #define RULER_UNIT_INCH     4
79*cdf0e10cSrcweir #define RULER_UNIT_FOOT     5
80*cdf0e10cSrcweir #define RULER_UNIT_MILE     6
81*cdf0e10cSrcweir #define RULER_UNIT_POINT    7
82*cdf0e10cSrcweir #define RULER_UNIT_PICA     8
83*cdf0e10cSrcweir #define RULER_UNIT_COUNT    9
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir // -----------------
86*cdf0e10cSrcweir // - ImplRulerData -
87*cdf0e10cSrcweir // -----------------
88*cdf0e10cSrcweir class ImplRulerData
89*cdf0e10cSrcweir {
90*cdf0e10cSrcweir     friend              class Ruler;
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir private:
93*cdf0e10cSrcweir     RulerLine*          pLines;
94*cdf0e10cSrcweir     RulerArrow*         pArrows;
95*cdf0e10cSrcweir     RulerBorder*        pBorders;
96*cdf0e10cSrcweir     RulerIndent*        pIndents;
97*cdf0e10cSrcweir     RulerTab*           pTabs;
98*cdf0e10cSrcweir     long                nNullVirOff;
99*cdf0e10cSrcweir     long                nRulVirOff;
100*cdf0e10cSrcweir     long                nRulWidth;
101*cdf0e10cSrcweir     long                nPageOff;
102*cdf0e10cSrcweir     long                nPageWidth;
103*cdf0e10cSrcweir     long                nNullOff;
104*cdf0e10cSrcweir     long                nMargin1;
105*cdf0e10cSrcweir     long                nMargin2;
106*cdf0e10cSrcweir     sal_uInt16              nLines;
107*cdf0e10cSrcweir     sal_uInt16              nArrows;
108*cdf0e10cSrcweir     sal_uInt16              nBorders;
109*cdf0e10cSrcweir     sal_uInt16              nIndents;
110*cdf0e10cSrcweir     sal_uInt16              nTabs;
111*cdf0e10cSrcweir     sal_uInt16              nMargin1Style;
112*cdf0e10cSrcweir     sal_uInt16              nMargin2Style;
113*cdf0e10cSrcweir     sal_Bool                bAutoPageWidth;
114*cdf0e10cSrcweir     sal_Bool                bTextRTL;
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir #ifdef _SV_RULER_CXX
117*cdf0e10cSrcweir public:
118*cdf0e10cSrcweir                         ImplRulerData();
119*cdf0e10cSrcweir                         ~ImplRulerData();
120*cdf0e10cSrcweir     ImplRulerData&      operator=( const ImplRulerData& rData );
121*cdf0e10cSrcweir #endif
122*cdf0e10cSrcweir };
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir struct ImplRulerUnitData
126*cdf0e10cSrcweir {
127*cdf0e10cSrcweir     MapUnit         eMapUnit;           // MAP_UNIT zum Umrechnen
128*cdf0e10cSrcweir     long            nTickUnit;          // Teiler fuer Einheit
129*cdf0e10cSrcweir     long            nTick1;             // Schrittweite
130*cdf0e10cSrcweir     long            nTick2;             // Tick fuer halbe Werte
131*cdf0e10cSrcweir     long            nTick3;             // Tick fuer Zahlenausgabe
132*cdf0e10cSrcweir     long            n100THMM;           // Teiler fuer Einheit
133*cdf0e10cSrcweir     sal_uInt16          nUnitDigits;        // Anzahl Nachkommastellen
134*cdf0e10cSrcweir     sal_Char        aUnitStr[8];        // Einheiten-String
135*cdf0e10cSrcweir };
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir static ImplRulerUnitData aImplRulerUnitTab[RULER_UNIT_COUNT] =
138*cdf0e10cSrcweir {
139*cdf0e10cSrcweir { MAP_100TH_MM,        100,    25,     50,    100,     100, 3, " mm"    }, // MM
140*cdf0e10cSrcweir { MAP_100TH_MM,       1000,   250,    500,   1000,    1000, 3, " cm"    }, // CM
141*cdf0e10cSrcweir { MAP_MM,             1000,   250,    500,   1000,   10000, 4, " m"     }, // M
142*cdf0e10cSrcweir { MAP_CM,           100000, 25000,  50000, 100000,  100000, 6, " km"    }, // KM
143*cdf0e10cSrcweir { MAP_100TH_INCH,      100,    10,     50,    100,    2540, 3, "\""     }, // INCH
144*cdf0e10cSrcweir { MAP_100TH_INCH,     1200,   120,    600,   1200,   30480, 3, "'"      }, // FOOT
145*cdf0e10cSrcweir { MAP_10TH_INCH,    633600, 63360, 316800, 633600, 1609344, 4, " miles" }, // MILE
146*cdf0e10cSrcweir { MAP_POINT,             1,    12,     12,     36,     353, 2, " pt"    }, // POINT
147*cdf0e10cSrcweir { MAP_100TH_MM,        423,   423,    423,    846,     423, 3, " pi"    }  // PICA
148*cdf0e10cSrcweir };
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir // =======================================================================
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir struct ImplRulerHitTest
153*cdf0e10cSrcweir {
154*cdf0e10cSrcweir     long        nPos;
155*cdf0e10cSrcweir     RulerType   eType;
156*cdf0e10cSrcweir     sal_uInt16      nAryPos;
157*cdf0e10cSrcweir     sal_uInt16      mnDragSize;
158*cdf0e10cSrcweir     sal_Bool        bSize;
159*cdf0e10cSrcweir     sal_Bool        bSizeBar;
160*cdf0e10cSrcweir     sal_Bool        bExpandTest;
161*cdf0e10cSrcweir     ImplRulerHitTest() :
162*cdf0e10cSrcweir         bExpandTest( sal_False ) {}
163*cdf0e10cSrcweir };
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir // =======================================================================
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir ImplRulerData::ImplRulerData()
168*cdf0e10cSrcweir {
169*cdf0e10cSrcweir     memset( this, 0, sizeof( ImplRulerData ) );
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir     // PageBreite == EditWinBreite
172*cdf0e10cSrcweir     bAutoPageWidth   = sal_True;
173*cdf0e10cSrcweir }
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir // -----------------------------------------------------------------------
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir ImplRulerData::~ImplRulerData()
178*cdf0e10cSrcweir {
179*cdf0e10cSrcweir     delete[] pLines;
180*cdf0e10cSrcweir     delete[] pArrows;
181*cdf0e10cSrcweir     delete[] pBorders;
182*cdf0e10cSrcweir     delete[] pIndents;
183*cdf0e10cSrcweir     delete[] pTabs;
184*cdf0e10cSrcweir }
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir // -----------------------------------------------------------------------
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir ImplRulerData& ImplRulerData::operator=( const ImplRulerData& rData )
189*cdf0e10cSrcweir {
190*cdf0e10cSrcweir     delete[] pLines;
191*cdf0e10cSrcweir     delete[] pArrows;
192*cdf0e10cSrcweir     delete[] pBorders;
193*cdf0e10cSrcweir     delete[] pIndents;
194*cdf0e10cSrcweir     delete[] pTabs;
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir     memcpy( this, &rData, sizeof( ImplRulerData ) );
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir     if ( rData.pLines )
199*cdf0e10cSrcweir     {
200*cdf0e10cSrcweir         pLines = new RulerLine[nLines];
201*cdf0e10cSrcweir         memcpy( pLines, rData.pLines, nLines*sizeof( RulerLine ) );
202*cdf0e10cSrcweir     }
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir     if ( rData.pArrows )
205*cdf0e10cSrcweir     {
206*cdf0e10cSrcweir         pArrows = new RulerArrow[nArrows];
207*cdf0e10cSrcweir         memcpy( pArrows, rData.pArrows, nArrows*sizeof( RulerArrow ) );
208*cdf0e10cSrcweir     }
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir     if ( rData.pBorders )
211*cdf0e10cSrcweir     {
212*cdf0e10cSrcweir         pBorders = new RulerBorder[nBorders];
213*cdf0e10cSrcweir         memcpy( pBorders, rData.pBorders, nBorders*sizeof( RulerBorder ) );
214*cdf0e10cSrcweir     }
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir     if ( rData.pIndents )
217*cdf0e10cSrcweir     {
218*cdf0e10cSrcweir         pIndents = new RulerIndent[nIndents];
219*cdf0e10cSrcweir         memcpy( pIndents, rData.pIndents, nIndents*sizeof( RulerIndent ) );
220*cdf0e10cSrcweir     }
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir     if ( rData.pTabs )
223*cdf0e10cSrcweir     {
224*cdf0e10cSrcweir         pTabs = new RulerTab[nTabs];
225*cdf0e10cSrcweir         memcpy( pTabs, rData.pTabs, nTabs*sizeof( RulerTab ) );
226*cdf0e10cSrcweir     }
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir     return *this;
229*cdf0e10cSrcweir }
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir // =======================================================================
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir void Ruler::ImplInit( WinBits nWinBits )
234*cdf0e10cSrcweir {
235*cdf0e10cSrcweir     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir     // Default WinBits setzen
238*cdf0e10cSrcweir     if ( !(nWinBits & WB_VERT) )
239*cdf0e10cSrcweir     {
240*cdf0e10cSrcweir         nWinBits |= WB_HORZ;
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir         // --- RTL --- no UI mirroring for horizontal rulers, because
243*cdf0e10cSrcweir         // the document is also not mirrored
244*cdf0e10cSrcweir         EnableRTL( sal_False );
245*cdf0e10cSrcweir     }
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir     // Variablen initialisieren
248*cdf0e10cSrcweir     mnWinStyle      = nWinBits;             // Window-Style
249*cdf0e10cSrcweir     mnBorderOff     = 0;                    // Border-Offset
250*cdf0e10cSrcweir     mnWinOff        = 0;                    // EditWinOffset
251*cdf0e10cSrcweir     mnWinWidth      = 0;                    // EditWinWidth
252*cdf0e10cSrcweir     mnWidth         = 0;                    // Fensterbreite
253*cdf0e10cSrcweir     mnHeight        = 0;                    // Fensterhoehe
254*cdf0e10cSrcweir     mnVirOff        = 0;                    // Offset des VirtualDeice vom linke/oberen Rand
255*cdf0e10cSrcweir     mnVirWidth      = 0;                    // Breite bzw. Hoehe vom VirtualDevice
256*cdf0e10cSrcweir     mnVirHeight     = 0;                    // Hoehe bzw. Breite vom VirtualDevice
257*cdf0e10cSrcweir     mnDragPos       = 0;                    // Drag-Position (NullPunkt)
258*cdf0e10cSrcweir     mnUpdateEvtId   = 0;                    // Noch kein Update-Event verschickt
259*cdf0e10cSrcweir     mnDragAryPos    = 0;                    // Drag-Array-Index
260*cdf0e10cSrcweir     mnDragSize      = 0;                    // Wird beim Draggen die Groesse geaendert
261*cdf0e10cSrcweir     mnDragScroll    = 0;                    // Soll beim Draggen gescrollt werden
262*cdf0e10cSrcweir     mnDragModifier  = 0;                    // Modifier-Tasten beim Draggen
263*cdf0e10cSrcweir     mnExtraStyle    = 0;                    // Style des Extra-Feldes
264*cdf0e10cSrcweir     mnExtraClicks   = 0;                    // Click-Anzahl fuer Extra-Feld
265*cdf0e10cSrcweir     mnExtraModifier = 0;                    // Modifier-Tasten beim Click im Extrafeld
266*cdf0e10cSrcweir     mbCalc          = sal_True;                 // Muessen Pagebreiten neu berechnet werden
267*cdf0e10cSrcweir     mbFormat        = sal_True;                 // Muss neu ausgegeben werden
268*cdf0e10cSrcweir     mbDrag          = sal_False;                // Sind wir im Drag-Modus
269*cdf0e10cSrcweir     mbDragDelete    = sal_False;                // Wird Maus beim Draggen unten rausgezogen
270*cdf0e10cSrcweir     mbDragCanceled  = sal_False;                // Wurde Dragging abgebrochen
271*cdf0e10cSrcweir     mbAutoWinWidth  = sal_True;                 // EditWinBreite == RulerBreite
272*cdf0e10cSrcweir     mbActive        = sal_True;                 // Ist Lineal aktiv
273*cdf0e10cSrcweir     mnUpdateFlags   = 0;                    // Was soll im Update-Handler upgedatet werden
274*cdf0e10cSrcweir     mpData          = mpSaveData;           // Wir zeigen auf die normalen Daten
275*cdf0e10cSrcweir     meExtraType     = RULER_EXTRA_DONTKNOW; // Was im ExtraFeld dargestellt wird
276*cdf0e10cSrcweir     meDragType      = RULER_TYPE_DONTKNOW;  // Gibt an, was gedragt wird
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir     // Units initialisieren
279*cdf0e10cSrcweir     mnUnitIndex     = RULER_UNIT_CM;
280*cdf0e10cSrcweir     meUnit          = FUNIT_CM;
281*cdf0e10cSrcweir     maZoom          = Fraction( 1, 1 );
282*cdf0e10cSrcweir     meSourceUnit    = MAP_100TH_MM;
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir     // Border-Breiten berechnen
285*cdf0e10cSrcweir     if ( nWinBits & WB_BORDER )
286*cdf0e10cSrcweir     {
287*cdf0e10cSrcweir         if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
288*cdf0e10cSrcweir             mnBorderWidth = 2;
289*cdf0e10cSrcweir         else
290*cdf0e10cSrcweir             mnBorderWidth = 1;
291*cdf0e10cSrcweir     }
292*cdf0e10cSrcweir     else
293*cdf0e10cSrcweir         mnBorderWidth = 0;
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir     // Einstellungen setzen
296*cdf0e10cSrcweir     ImplInitSettings( sal_True, sal_True, sal_True );
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir     // Default-Groesse setzen
299*cdf0e10cSrcweir     long nDefHeight = GetTextHeight() + RULER_OFF*2 + RULER_TEXTOFF*2 + mnBorderWidth;
300*cdf0e10cSrcweir     Size aDefSize;
301*cdf0e10cSrcweir     if ( nWinBits & WB_HORZ )
302*cdf0e10cSrcweir         aDefSize.Height() = nDefHeight;
303*cdf0e10cSrcweir     else
304*cdf0e10cSrcweir         aDefSize.Width() = nDefHeight;
305*cdf0e10cSrcweir     SetOutputSizePixel( aDefSize );
306*cdf0e10cSrcweir 	SetType(WINDOW_RULER);
307*cdf0e10cSrcweir }
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir // -----------------------------------------------------------------------
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir Ruler::Ruler( Window* pParent, WinBits nWinStyle ) :
312*cdf0e10cSrcweir     Window( pParent, nWinStyle & WB_3DLOOK ),
313*cdf0e10cSrcweir     maVirDev( *this ),
314*cdf0e10cSrcweir     maMapMode( MAP_100TH_MM ),
315*cdf0e10cSrcweir     mpSaveData(new ImplRulerData),
316*cdf0e10cSrcweir     mpData(0),
317*cdf0e10cSrcweir     mpDragData(new ImplRulerData)
318*cdf0e10cSrcweir {
319*cdf0e10cSrcweir     ImplInit( nWinStyle );
320*cdf0e10cSrcweir }
321*cdf0e10cSrcweir 
322*cdf0e10cSrcweir // -----------------------------------------------------------------------
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir Ruler::~Ruler()
325*cdf0e10cSrcweir {
326*cdf0e10cSrcweir     if ( mnUpdateEvtId )
327*cdf0e10cSrcweir         Application::RemoveUserEvent( mnUpdateEvtId );
328*cdf0e10cSrcweir     delete mpSaveData;
329*cdf0e10cSrcweir     delete mpDragData;
330*cdf0e10cSrcweir }
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir // -----------------------------------------------------------------------
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir void Ruler::ImplVDrawLine( long nX1, long nY1, long nX2, long nY2 )
335*cdf0e10cSrcweir {
336*cdf0e10cSrcweir     if ( nX1 < -RULER_CLIP )
337*cdf0e10cSrcweir     {
338*cdf0e10cSrcweir         nX1 = -RULER_CLIP;
339*cdf0e10cSrcweir         if ( nX2 < -RULER_CLIP )
340*cdf0e10cSrcweir             return;
341*cdf0e10cSrcweir     }
342*cdf0e10cSrcweir     long nClip = mnVirWidth+RULER_CLIP;
343*cdf0e10cSrcweir     if ( nX2 > nClip )
344*cdf0e10cSrcweir     {
345*cdf0e10cSrcweir         nX2 = nClip;
346*cdf0e10cSrcweir         if ( nX1 > nClip )
347*cdf0e10cSrcweir             return;
348*cdf0e10cSrcweir     }
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir     if ( mnWinStyle & WB_HORZ )
351*cdf0e10cSrcweir         maVirDev.DrawLine( Point( nX1, nY1 ), Point( nX2, nY2 ) );
352*cdf0e10cSrcweir     else
353*cdf0e10cSrcweir         maVirDev.DrawLine( Point( nY1, nX1 ), Point( nY2, nX2 ) );
354*cdf0e10cSrcweir }
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir // -----------------------------------------------------------------------
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir void Ruler::ImplVDrawRect( long nX1, long nY1, long nX2, long nY2 )
359*cdf0e10cSrcweir {
360*cdf0e10cSrcweir     if ( nX1 < -RULER_CLIP )
361*cdf0e10cSrcweir     {
362*cdf0e10cSrcweir         nX1 = -RULER_CLIP;
363*cdf0e10cSrcweir         if ( nX2 < -RULER_CLIP )
364*cdf0e10cSrcweir             return;
365*cdf0e10cSrcweir     }
366*cdf0e10cSrcweir     long nClip = mnVirWidth+RULER_CLIP;
367*cdf0e10cSrcweir     if ( nX2 > nClip )
368*cdf0e10cSrcweir     {
369*cdf0e10cSrcweir         nX2 = nClip;
370*cdf0e10cSrcweir         if ( nX1 > nClip )
371*cdf0e10cSrcweir             return;
372*cdf0e10cSrcweir     }
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir     if ( mnWinStyle & WB_HORZ )
375*cdf0e10cSrcweir         maVirDev.DrawRect( Rectangle( nX1, nY1, nX2, nY2 ) );
376*cdf0e10cSrcweir     else
377*cdf0e10cSrcweir         maVirDev.DrawRect( Rectangle( nY1, nX1, nY2, nX2 ) );
378*cdf0e10cSrcweir }
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir // -----------------------------------------------------------------------
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir void Ruler::ImplVDrawText( long nX, long nY, const String& rText )
383*cdf0e10cSrcweir {
384*cdf0e10cSrcweir     if ( (nX > -RULER_CLIP) && (nX < mnVirWidth+RULER_CLIP) )
385*cdf0e10cSrcweir     {
386*cdf0e10cSrcweir         if ( mnWinStyle & WB_HORZ )
387*cdf0e10cSrcweir             maVirDev.DrawText( Point( nX, nY ), rText );
388*cdf0e10cSrcweir         else
389*cdf0e10cSrcweir             maVirDev.DrawText( Point( nY, nX ), rText );
390*cdf0e10cSrcweir     }
391*cdf0e10cSrcweir }
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir // -----------------------------------------------------------------------
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir void Ruler::ImplInvertLines( sal_Bool bErase )
396*cdf0e10cSrcweir {
397*cdf0e10cSrcweir     // Positionslinien
398*cdf0e10cSrcweir     if ( mpData->nLines && mbActive && !mbDrag && !mbFormat &&
399*cdf0e10cSrcweir          !(mnUpdateFlags & RULER_UPDATE_LINES) )
400*cdf0e10cSrcweir     {
401*cdf0e10cSrcweir         long n;
402*cdf0e10cSrcweir         long nNullWinOff = mpData->nNullVirOff+mnVirOff;
403*cdf0e10cSrcweir         long nRulX1 = mpData->nRulVirOff+mnVirOff;
404*cdf0e10cSrcweir         long nRulX2 = nRulX1+mpData->nRulWidth;
405*cdf0e10cSrcweir         long nY = (RULER_OFF*2)+mnVirHeight-1;
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir         // Rectangle berechnen
408*cdf0e10cSrcweir         Rectangle aRect;
409*cdf0e10cSrcweir         if ( mnWinStyle & WB_HORZ )
410*cdf0e10cSrcweir             aRect.Bottom() = nY;
411*cdf0e10cSrcweir         else
412*cdf0e10cSrcweir             aRect.Right() = nY;
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir         // Linien ausgeben
415*cdf0e10cSrcweir         for ( sal_uInt16 i = 0; i < mpData->nLines; i++ )
416*cdf0e10cSrcweir         {
417*cdf0e10cSrcweir             n = mpData->pLines[i].nPos+nNullWinOff;
418*cdf0e10cSrcweir             if ( (n >= nRulX1) && (n < nRulX2) )
419*cdf0e10cSrcweir             {
420*cdf0e10cSrcweir                 if ( mnWinStyle & WB_HORZ )
421*cdf0e10cSrcweir                 {
422*cdf0e10cSrcweir                     aRect.Left()   = n;
423*cdf0e10cSrcweir                     aRect.Right()  = n;
424*cdf0e10cSrcweir                 }
425*cdf0e10cSrcweir                 else
426*cdf0e10cSrcweir                 {
427*cdf0e10cSrcweir                     aRect.Top()    = n;
428*cdf0e10cSrcweir                     aRect.Bottom() = n;
429*cdf0e10cSrcweir                 }
430*cdf0e10cSrcweir                 if ( bErase )
431*cdf0e10cSrcweir                 {
432*cdf0e10cSrcweir                     Rectangle aTempRect = aRect;
433*cdf0e10cSrcweir                     if ( mnWinStyle & WB_HORZ )
434*cdf0e10cSrcweir                         aTempRect.Bottom() = RULER_OFF-1;
435*cdf0e10cSrcweir                     else
436*cdf0e10cSrcweir                         aTempRect.Right() = RULER_OFF-1;
437*cdf0e10cSrcweir                     Erase( aTempRect );
438*cdf0e10cSrcweir                     if ( mnWinStyle & WB_HORZ )
439*cdf0e10cSrcweir                     {
440*cdf0e10cSrcweir                         aTempRect.Bottom() = aRect.Bottom();
441*cdf0e10cSrcweir                         aTempRect.Top()    = aTempRect.Bottom()-RULER_OFF+1;
442*cdf0e10cSrcweir                     }
443*cdf0e10cSrcweir                     else
444*cdf0e10cSrcweir                     {
445*cdf0e10cSrcweir                         aTempRect.Right()  = aRect.Right();
446*cdf0e10cSrcweir                         aTempRect.Left()   = aTempRect.Right()-RULER_OFF+1;
447*cdf0e10cSrcweir                     }
448*cdf0e10cSrcweir                     Erase( aTempRect );
449*cdf0e10cSrcweir                 }
450*cdf0e10cSrcweir                 Invert( aRect );
451*cdf0e10cSrcweir             }
452*cdf0e10cSrcweir         }
453*cdf0e10cSrcweir     }
454*cdf0e10cSrcweir }
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir // -----------------------------------------------------------------------
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nCenter )
459*cdf0e10cSrcweir {
460*cdf0e10cSrcweir     long    n = 0;
461*cdf0e10cSrcweir     long    nTick = 0;
462*cdf0e10cSrcweir     long    nTick3 = aImplRulerUnitTab[mnUnitIndex].nTick3;
463*cdf0e10cSrcweir     long    nTickCount = aImplRulerUnitTab[mnUnitIndex].nTick1;
464*cdf0e10cSrcweir     Size    aPixSize = maVirDev.LogicToPixel( Size( nTick3, nTick3 ), maMapMode );
465*cdf0e10cSrcweir     long    nTickWidth;
466*cdf0e10cSrcweir     long    nX;
467*cdf0e10cSrcweir     long    nY;
468*cdf0e10cSrcweir     sal_Bool    bNoTicks = sal_False;
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir     // Groessenvorberechnung
471*cdf0e10cSrcweir     // Sizes calculation
472*cdf0e10cSrcweir     sal_Bool bVertRight = sal_False;
473*cdf0e10cSrcweir     if ( mnWinStyle & WB_HORZ )
474*cdf0e10cSrcweir         nTickWidth = aPixSize.Width();
475*cdf0e10cSrcweir     else
476*cdf0e10cSrcweir     {
477*cdf0e10cSrcweir         Font aFont = GetFont();
478*cdf0e10cSrcweir         if ( mnWinStyle & WB_RIGHT_ALIGNED )
479*cdf0e10cSrcweir         {
480*cdf0e10cSrcweir             aFont.SetOrientation( 2700 );
481*cdf0e10cSrcweir             bVertRight = sal_True;
482*cdf0e10cSrcweir         }
483*cdf0e10cSrcweir         else
484*cdf0e10cSrcweir             aFont.SetOrientation( 900 );
485*cdf0e10cSrcweir         maVirDev.SetFont( aFont );
486*cdf0e10cSrcweir         nTickWidth = aPixSize.Height();
487*cdf0e10cSrcweir     }
488*cdf0e10cSrcweir     long nMaxWidth = maVirDev.PixelToLogic( Size( mpData->nPageWidth, 0 ), maMapMode ).Width();
489*cdf0e10cSrcweir     if ( nMaxWidth < 0 )
490*cdf0e10cSrcweir         nMaxWidth = -nMaxWidth;
491*cdf0e10cSrcweir     nMaxWidth /= aImplRulerUnitTab[mnUnitIndex].nTickUnit;
492*cdf0e10cSrcweir     UniString aNumStr( UniString::CreateFromInt32( nMaxWidth ) );
493*cdf0e10cSrcweir     long nTxtWidth = GetTextWidth( aNumStr );
494*cdf0e10cSrcweir 
495*cdf0e10cSrcweir     const long nTextOff   = 4;
496*cdf0e10cSrcweir     if ( nTickWidth < nTxtWidth+nTextOff )
497*cdf0e10cSrcweir     {
498*cdf0e10cSrcweir         // Calculate the scale of the ruler
499*cdf0e10cSrcweir         long nMulti     = 1;
500*cdf0e10cSrcweir         long nOrgTick3  = nTick3;
501*cdf0e10cSrcweir         while ( nTickWidth < nTxtWidth+nTextOff )
502*cdf0e10cSrcweir         {
503*cdf0e10cSrcweir             long nOldMulti = nMulti;
504*cdf0e10cSrcweir             if ( !nTickWidth ) //If nTickWidth equals 0
505*cdf0e10cSrcweir                 nMulti *= 10;
506*cdf0e10cSrcweir             else if ( nMulti < 10 )
507*cdf0e10cSrcweir                 nMulti++;
508*cdf0e10cSrcweir             else if ( nMulti < 100 )
509*cdf0e10cSrcweir                 nMulti += 10;
510*cdf0e10cSrcweir             else if ( nMulti < 1000 )
511*cdf0e10cSrcweir                 nMulti += 100;
512*cdf0e10cSrcweir             else
513*cdf0e10cSrcweir                 nMulti += 1000;
514*cdf0e10cSrcweir             // Ueberlauf, dann geben wir nichts aus, da wir bei so einem
515*cdf0e10cSrcweir             // unsinnigen Massstab sowieso nichts vernuenftiges anzeigen
516*cdf0e10cSrcweir             // koennen
517*cdf0e10cSrcweir             if ( nMulti < nOldMulti )
518*cdf0e10cSrcweir             {
519*cdf0e10cSrcweir                 bNoTicks = sal_True;
520*cdf0e10cSrcweir                 break;
521*cdf0e10cSrcweir             }
522*cdf0e10cSrcweir 
523*cdf0e10cSrcweir             nTick3 = nOrgTick3 * nMulti;
524*cdf0e10cSrcweir             aPixSize = maVirDev.LogicToPixel( Size( nTick3, nTick3 ), maMapMode );
525*cdf0e10cSrcweir             if ( mnWinStyle & WB_HORZ )
526*cdf0e10cSrcweir                 nTickWidth = aPixSize.Width();
527*cdf0e10cSrcweir             else
528*cdf0e10cSrcweir                 nTickWidth = aPixSize.Height();
529*cdf0e10cSrcweir         }
530*cdf0e10cSrcweir         nTickCount = nTick3;
531*cdf0e10cSrcweir     }
532*cdf0e10cSrcweir     else
533*cdf0e10cSrcweir         maVirDev.SetLineColor( GetSettings().GetStyleSettings().GetWindowTextColor() );
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir     if ( !bNoTicks )
536*cdf0e10cSrcweir     {
537*cdf0e10cSrcweir         long nTxtWidth2;
538*cdf0e10cSrcweir         long nTxtHeight2 = GetTextHeight()/2;
539*cdf0e10cSrcweir         while ( ((nStart-n) >= nMin) || ((nStart+n) <= nMax) )
540*cdf0e10cSrcweir         {
541*cdf0e10cSrcweir             // Null-Punkt
542*cdf0e10cSrcweir             if ( !nTick )
543*cdf0e10cSrcweir             {
544*cdf0e10cSrcweir                 if ( nStart > nMin )
545*cdf0e10cSrcweir                 {
546*cdf0e10cSrcweir                     // 0 is only painted when Margin1 is not equal to zero
547*cdf0e10cSrcweir                     if ( (mpData->nMargin1Style & RULER_STYLE_INVISIBLE) || (mpData->nMargin1 != 0) )
548*cdf0e10cSrcweir                     {
549*cdf0e10cSrcweir                         aNumStr = (sal_Unicode)'0';
550*cdf0e10cSrcweir                         nTxtWidth2 = maVirDev.GetTextWidth( aNumStr )/2;
551*cdf0e10cSrcweir                         if ( (mnWinStyle & WB_HORZ)^mpData->bTextRTL )
552*cdf0e10cSrcweir                             nX = nStart-nTxtWidth2;
553*cdf0e10cSrcweir                         else
554*cdf0e10cSrcweir                             nX = nStart+nTxtWidth2;
555*cdf0e10cSrcweir                         long n_Y = bVertRight ? nCenter+nTxtHeight2 : nCenter-nTxtHeight2;
556*cdf0e10cSrcweir 						ImplVDrawText( nX, n_Y, aNumStr );
557*cdf0e10cSrcweir                     }
558*cdf0e10cSrcweir                 }
559*cdf0e10cSrcweir             }
560*cdf0e10cSrcweir             else
561*cdf0e10cSrcweir             {
562*cdf0e10cSrcweir                 aPixSize = maVirDev.LogicToPixel( Size( nTick, nTick ), maMapMode );
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir                 if ( mnWinStyle & WB_HORZ )
565*cdf0e10cSrcweir                     n = aPixSize.Width();
566*cdf0e10cSrcweir                 else
567*cdf0e10cSrcweir                     n = aPixSize.Height();
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir                 // Tick3 - Output (Text)
570*cdf0e10cSrcweir                 if ( !(nTick % nTick3) )
571*cdf0e10cSrcweir                 {
572*cdf0e10cSrcweir                     aNumStr = UniString::CreateFromInt32( nTick / aImplRulerUnitTab[mnUnitIndex].nTickUnit );
573*cdf0e10cSrcweir                     nTxtWidth2 = GetTextWidth( aNumStr )/2;
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir                     nX = nStart+n;
576*cdf0e10cSrcweir                     //different orientation needs a different starting position
577*cdf0e10cSrcweir                     nY = bVertRight ? nCenter+nTxtHeight2 : nCenter-nTxtHeight2;
578*cdf0e10cSrcweir 
579*cdf0e10cSrcweir                     // Check if we can display full number
580*cdf0e10cSrcweir                     if ( nX < (nMax-nTxtWidth2) )
581*cdf0e10cSrcweir                     {
582*cdf0e10cSrcweir                         if ( mnWinStyle & WB_HORZ )
583*cdf0e10cSrcweir                             nX -= nTxtWidth2;
584*cdf0e10cSrcweir                         else
585*cdf0e10cSrcweir                             nX += nTxtWidth2;
586*cdf0e10cSrcweir                         ImplVDrawText( nX, nY, aNumStr );
587*cdf0e10cSrcweir                     }
588*cdf0e10cSrcweir                     nX = nStart-n;
589*cdf0e10cSrcweir                     if ( nX > (nMin+nTxtWidth2) )
590*cdf0e10cSrcweir                     {
591*cdf0e10cSrcweir                         if ( mnWinStyle & WB_HORZ )
592*cdf0e10cSrcweir                             nX -= nTxtWidth2;
593*cdf0e10cSrcweir                         else
594*cdf0e10cSrcweir                             nX += nTxtWidth2;
595*cdf0e10cSrcweir                         ImplVDrawText( nX, nY, aNumStr );
596*cdf0e10cSrcweir                     }
597*cdf0e10cSrcweir                 }
598*cdf0e10cSrcweir                 // Tick/Tick2 - Output (Strokes)
599*cdf0e10cSrcweir                 else
600*cdf0e10cSrcweir                 {
601*cdf0e10cSrcweir                     if ( !(nTick % aImplRulerUnitTab[mnUnitIndex].nTick2) )
602*cdf0e10cSrcweir                         nTickWidth = RULER_TICK2_WIDTH;
603*cdf0e10cSrcweir                     else
604*cdf0e10cSrcweir                         nTickWidth = RULER_TICK1_WIDTH;
605*cdf0e10cSrcweir                     long nT1 = nCenter-(nTickWidth/2);
606*cdf0e10cSrcweir                     long nT2 = nT1+nTickWidth-1;
607*cdf0e10cSrcweir                     long nT;
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir                     nT = nStart+n;
610*cdf0e10cSrcweir                     if ( nT < nMax )
611*cdf0e10cSrcweir                         ImplVDrawLine( nT, nT1, nT, nT2 );
612*cdf0e10cSrcweir                     nT = nStart-n;
613*cdf0e10cSrcweir                     if ( nT > nMin )
614*cdf0e10cSrcweir                         ImplVDrawLine( nT, nT1, nT, nT2 );
615*cdf0e10cSrcweir                 }
616*cdf0e10cSrcweir             }
617*cdf0e10cSrcweir             // #i49017# with some zoom factors the value nTick can overflow
618*cdf0e10cSrcweir             if( ((sal_uLong)nTick + (sal_uLong)nTickCount) > (sal_uLong)LONG_MAX)
619*cdf0e10cSrcweir                 break;
620*cdf0e10cSrcweir             nTick += nTickCount;
621*cdf0e10cSrcweir         }
622*cdf0e10cSrcweir     }
623*cdf0e10cSrcweir }
624*cdf0e10cSrcweir 
625*cdf0e10cSrcweir // -----------------------------------------------------------------------
626*cdf0e10cSrcweir 
627*cdf0e10cSrcweir void Ruler::ImplDrawArrows( long nCenter )
628*cdf0e10cSrcweir {
629*cdf0e10cSrcweir     sal_uInt16          i;
630*cdf0e10cSrcweir     long            n1;
631*cdf0e10cSrcweir     long            n2;
632*cdf0e10cSrcweir     long            n3;
633*cdf0e10cSrcweir     long            n4;
634*cdf0e10cSrcweir     long            nLogWidth;
635*cdf0e10cSrcweir     String          aStr;
636*cdf0e10cSrcweir     String          aStr2;
637*cdf0e10cSrcweir     sal_Bool            bDrawUnit;
638*cdf0e10cSrcweir     long            nTxtWidth;
639*cdf0e10cSrcweir     long            nTxtHeight2 = GetTextHeight()/2;
640*cdf0e10cSrcweir 
641*cdf0e10cSrcweir     const vcl::I18nHelper& rI18nHelper = GetSettings().GetLocaleI18nHelper();
642*cdf0e10cSrcweir 
643*cdf0e10cSrcweir     maVirDev.SetLineColor( GetSettings().GetStyleSettings().GetWindowTextColor() );
644*cdf0e10cSrcweir     for ( i = 0; i < mpData->nArrows; i++ )
645*cdf0e10cSrcweir     {
646*cdf0e10cSrcweir         n1 = mpData->pArrows[i].nPos+mpData->nNullVirOff+1;
647*cdf0e10cSrcweir         n2 = n1+mpData->pArrows[i].nWidth-2;
648*cdf0e10cSrcweir 
649*cdf0e10cSrcweir         // Einheit umrechnen
650*cdf0e10cSrcweir         nLogWidth = mpData->pArrows[i].nLogWidth;
651*cdf0e10cSrcweir         if ( meSourceUnit == MAP_TWIP )
652*cdf0e10cSrcweir         {
653*cdf0e10cSrcweir             if ( nLogWidth >= 100000 )
654*cdf0e10cSrcweir                 nLogWidth = (nLogWidth*254)/144;
655*cdf0e10cSrcweir             else
656*cdf0e10cSrcweir                 nLogWidth = (nLogWidth*2540)/1440;
657*cdf0e10cSrcweir         }
658*cdf0e10cSrcweir         if ( nLogWidth >= 1000000 )
659*cdf0e10cSrcweir             nLogWidth = (nLogWidth / aImplRulerUnitTab[mnUnitIndex].n100THMM) * 1000;
660*cdf0e10cSrcweir         else
661*cdf0e10cSrcweir             nLogWidth = (nLogWidth*1000) / aImplRulerUnitTab[mnUnitIndex].n100THMM;
662*cdf0e10cSrcweir 		aStr = rI18nHelper.GetNum( nLogWidth, aImplRulerUnitTab[mnUnitIndex].nUnitDigits, sal_True, sal_False );
663*cdf0e10cSrcweir 
664*cdf0e10cSrcweir         // Einheit an den String haengen
665*cdf0e10cSrcweir         aStr2 = aStr;
666*cdf0e10cSrcweir         aStr2.AppendAscii( aImplRulerUnitTab[mnUnitIndex].aUnitStr );
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir         // Textbreite ermitteln
669*cdf0e10cSrcweir         bDrawUnit = sal_True;
670*cdf0e10cSrcweir         nTxtWidth = GetTextWidth( aStr2 );
671*cdf0e10cSrcweir         if ( nTxtWidth < mpData->pArrows[i].nWidth-10 )
672*cdf0e10cSrcweir             aStr = aStr2;
673*cdf0e10cSrcweir         else
674*cdf0e10cSrcweir         {
675*cdf0e10cSrcweir             nTxtWidth = GetTextWidth( aStr );
676*cdf0e10cSrcweir             if ( nTxtWidth > mpData->pArrows[i].nWidth-10 )
677*cdf0e10cSrcweir                 bDrawUnit = sal_False;
678*cdf0e10cSrcweir         }
679*cdf0e10cSrcweir 
680*cdf0e10cSrcweir         // Ist genuegen Platz fuer Einheiten-String vorhanden
681*cdf0e10cSrcweir         if ( bDrawUnit )
682*cdf0e10cSrcweir         {
683*cdf0e10cSrcweir             n3 = n1 + ((n2-n1)/2) - 1;
684*cdf0e10cSrcweir             if ( mnWinStyle & WB_HORZ )
685*cdf0e10cSrcweir                 n3 -= nTxtWidth/2;
686*cdf0e10cSrcweir             else
687*cdf0e10cSrcweir                 n3 += nTxtWidth/2;
688*cdf0e10cSrcweir             if ( mnWinStyle & WB_HORZ )
689*cdf0e10cSrcweir             {
690*cdf0e10cSrcweir                 n4 = n3 + nTxtWidth + 2;
691*cdf0e10cSrcweir                 ImplVDrawLine( n1, nCenter, n3, nCenter );
692*cdf0e10cSrcweir                 ImplVDrawLine( n4, nCenter, n2, nCenter );
693*cdf0e10cSrcweir             }
694*cdf0e10cSrcweir             else
695*cdf0e10cSrcweir             {
696*cdf0e10cSrcweir                 n4 = n3 - nTxtWidth - 2;
697*cdf0e10cSrcweir                 ImplVDrawLine( n1, nCenter, n4, nCenter );
698*cdf0e10cSrcweir                 ImplVDrawLine( n3, nCenter, n2, nCenter );
699*cdf0e10cSrcweir             }
700*cdf0e10cSrcweir             ImplVDrawText( n3, nCenter-nTxtHeight2, aStr );
701*cdf0e10cSrcweir         }
702*cdf0e10cSrcweir         else
703*cdf0e10cSrcweir             ImplVDrawLine( n1, nCenter, n2, nCenter );
704*cdf0e10cSrcweir         ImplVDrawLine( n1+1, nCenter-1, n1+1, nCenter+1 );
705*cdf0e10cSrcweir         ImplVDrawLine( n1+2, nCenter-2, n1+2, nCenter+2 );
706*cdf0e10cSrcweir         ImplVDrawLine( n2-1, nCenter-1, n2-1, nCenter+1 );
707*cdf0e10cSrcweir         ImplVDrawLine( n2-2, nCenter-2, n2-2, nCenter+2 );
708*cdf0e10cSrcweir     }
709*cdf0e10cSrcweir }
710*cdf0e10cSrcweir 
711*cdf0e10cSrcweir // -----------------------------------------------------------------------
712*cdf0e10cSrcweir 
713*cdf0e10cSrcweir void Ruler::ImplDrawBorders( long nMin, long nMax, long nVirTop, long nVirBottom )
714*cdf0e10cSrcweir {
715*cdf0e10cSrcweir     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
716*cdf0e10cSrcweir     long    n;
717*cdf0e10cSrcweir     long    n1;
718*cdf0e10cSrcweir     long    n2;
719*cdf0e10cSrcweir     long    nTemp1;
720*cdf0e10cSrcweir     long    nTemp2;
721*cdf0e10cSrcweir     sal_uInt16  i;
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir     for ( i = 0; i < mpData->nBorders; i++ )
724*cdf0e10cSrcweir     {
725*cdf0e10cSrcweir         if ( mpData->pBorders[i].nStyle & RULER_STYLE_INVISIBLE )
726*cdf0e10cSrcweir             continue;
727*cdf0e10cSrcweir 
728*cdf0e10cSrcweir         n1 = mpData->pBorders[i].nPos+mpData->nNullVirOff;
729*cdf0e10cSrcweir         n2 = n1+mpData->pBorders[i].nWidth;
730*cdf0e10cSrcweir 
731*cdf0e10cSrcweir         if ( ((n1 >= nMin) && (n1 <= nMax)) || ((n2 >= nMin) && (n2 <= nMax)) )
732*cdf0e10cSrcweir         {
733*cdf0e10cSrcweir             if ( (n2-n1) > 3 )
734*cdf0e10cSrcweir             {
735*cdf0e10cSrcweir                 maVirDev.SetLineColor();
736*cdf0e10cSrcweir                 if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
737*cdf0e10cSrcweir                     maVirDev.SetFillColor( rStyleSettings.GetFaceColor() );
738*cdf0e10cSrcweir                 else
739*cdf0e10cSrcweir                     maVirDev.SetFillColor( rStyleSettings.GetWindowColor() );
740*cdf0e10cSrcweir                 ImplVDrawRect( n1, nVirTop, n2, nVirBottom );
741*cdf0e10cSrcweir                 if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
742*cdf0e10cSrcweir                 {
743*cdf0e10cSrcweir                     maVirDev.SetLineColor( rStyleSettings.GetLightColor() );
744*cdf0e10cSrcweir                     ImplVDrawLine( n1+1, nVirTop, n1+1, nVirBottom );
745*cdf0e10cSrcweir                     ImplVDrawLine( n1, nVirTop, n2, nVirTop );
746*cdf0e10cSrcweir                     maVirDev.SetLineColor( rStyleSettings.GetShadowColor() );
747*cdf0e10cSrcweir                     ImplVDrawLine( n1, nVirTop, n1, nVirBottom );
748*cdf0e10cSrcweir                     ImplVDrawLine( n1, nVirBottom, n2, nVirBottom );
749*cdf0e10cSrcweir                     ImplVDrawLine( n2-1, nVirTop, n2-1, nVirBottom );
750*cdf0e10cSrcweir                     maVirDev.SetLineColor( rStyleSettings.GetWindowTextColor() );
751*cdf0e10cSrcweir                     ImplVDrawLine( n2, nVirTop, n2, nVirBottom );
752*cdf0e10cSrcweir                 }
753*cdf0e10cSrcweir                 else
754*cdf0e10cSrcweir                 {
755*cdf0e10cSrcweir                     maVirDev.SetLineColor( rStyleSettings.GetWindowTextColor() );
756*cdf0e10cSrcweir                     ImplVDrawLine( n1, nVirTop, n1, nVirBottom );
757*cdf0e10cSrcweir                     ImplVDrawLine( n2, nVirTop, n2, nVirBottom );
758*cdf0e10cSrcweir                 }
759*cdf0e10cSrcweir 
760*cdf0e10cSrcweir                 if ( mpData->pBorders[i].nStyle & RULER_BORDER_VARIABLE )
761*cdf0e10cSrcweir                 {
762*cdf0e10cSrcweir                     if ( n2-n1 > RULER_VAR_SIZE+4 )
763*cdf0e10cSrcweir                     {
764*cdf0e10cSrcweir                         nTemp1 = n1 + (((n2-n1+1)-RULER_VAR_SIZE) / 2);
765*cdf0e10cSrcweir                         nTemp2 = nVirTop + (((nVirBottom-nVirTop+1)-RULER_VAR_SIZE) / 2);
766*cdf0e10cSrcweir                         long nTemp3 = nTemp1+RULER_VAR_SIZE-1;
767*cdf0e10cSrcweir                         long nTemp4 = nTemp2+RULER_VAR_SIZE-1;
768*cdf0e10cSrcweir                         long nTempY = nTemp2;
769*cdf0e10cSrcweir                         if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
770*cdf0e10cSrcweir                             maVirDev.SetLineColor( rStyleSettings.GetLightColor() );
771*cdf0e10cSrcweir                         else
772*cdf0e10cSrcweir                             maVirDev.SetLineColor( rStyleSettings.GetWindowTextColor() );
773*cdf0e10cSrcweir                         while ( nTempY <= nTemp4 )
774*cdf0e10cSrcweir                         {
775*cdf0e10cSrcweir                             ImplVDrawLine( nTemp1, nTempY, nTemp3, nTempY );
776*cdf0e10cSrcweir                             nTempY += 2;
777*cdf0e10cSrcweir                         }
778*cdf0e10cSrcweir                         if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
779*cdf0e10cSrcweir                         {
780*cdf0e10cSrcweir                             nTempY = nTemp2+1;
781*cdf0e10cSrcweir                             maVirDev.SetLineColor( rStyleSettings.GetShadowColor() );
782*cdf0e10cSrcweir                             while ( nTempY <= nTemp4 )
783*cdf0e10cSrcweir                             {
784*cdf0e10cSrcweir                                 ImplVDrawLine( nTemp1, nTempY, nTemp3, nTempY );
785*cdf0e10cSrcweir                                 nTempY += 2;
786*cdf0e10cSrcweir                             }
787*cdf0e10cSrcweir                         }
788*cdf0e10cSrcweir                     }
789*cdf0e10cSrcweir                 }
790*cdf0e10cSrcweir 
791*cdf0e10cSrcweir                 if ( mpData->pBorders[i].nStyle & RULER_BORDER_SIZEABLE )
792*cdf0e10cSrcweir                 {
793*cdf0e10cSrcweir                     if ( n2-n1 > RULER_VAR_SIZE+10 )
794*cdf0e10cSrcweir                     {
795*cdf0e10cSrcweir                         if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
796*cdf0e10cSrcweir                         {
797*cdf0e10cSrcweir                             maVirDev.SetLineColor( rStyleSettings.GetShadowColor() );
798*cdf0e10cSrcweir                             ImplVDrawLine( n1+4, nVirTop+3, n1+4, nVirBottom-3 );
799*cdf0e10cSrcweir                             ImplVDrawLine( n2-5, nVirTop+3, n2-5, nVirBottom-3 );
800*cdf0e10cSrcweir                             maVirDev.SetLineColor( rStyleSettings.GetLightColor() );
801*cdf0e10cSrcweir                             ImplVDrawLine( n1+5, nVirTop+3, n1+5, nVirBottom-3 );
802*cdf0e10cSrcweir                             ImplVDrawLine( n2-4, nVirTop+3, n2-4, nVirBottom-3 );
803*cdf0e10cSrcweir                         }
804*cdf0e10cSrcweir                         else
805*cdf0e10cSrcweir                         {
806*cdf0e10cSrcweir                             maVirDev.SetLineColor( rStyleSettings.GetWindowTextColor() );
807*cdf0e10cSrcweir                             ImplVDrawLine( n1+4, nVirTop+3, n1+4, nVirBottom-3 );
808*cdf0e10cSrcweir                             ImplVDrawLine( n2-4, nVirTop+3, n2-4, nVirBottom-3 );
809*cdf0e10cSrcweir                         }
810*cdf0e10cSrcweir                     }
811*cdf0e10cSrcweir                 }
812*cdf0e10cSrcweir             }
813*cdf0e10cSrcweir             else
814*cdf0e10cSrcweir             {
815*cdf0e10cSrcweir                 n = n1+((n2-n1)/2);
816*cdf0e10cSrcweir                 if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
817*cdf0e10cSrcweir                     maVirDev.SetLineColor( rStyleSettings.GetShadowColor() );
818*cdf0e10cSrcweir                 else
819*cdf0e10cSrcweir                     maVirDev.SetLineColor( rStyleSettings.GetWindowTextColor() );
820*cdf0e10cSrcweir                 if ( mpData->pBorders[i].nStyle & RULER_BORDER_SNAP )
821*cdf0e10cSrcweir                     ImplVDrawLine( n, nVirTop, n, nVirBottom );
822*cdf0e10cSrcweir                 else if ( mpData->pBorders[i].nStyle & RULER_BORDER_MARGIN )
823*cdf0e10cSrcweir                     ImplVDrawLine( n, nVirTop, n, nVirBottom );
824*cdf0e10cSrcweir                 else
825*cdf0e10cSrcweir                 {
826*cdf0e10cSrcweir                     ImplVDrawLine( n-1, nVirTop, n-1, nVirBottom );
827*cdf0e10cSrcweir                     ImplVDrawLine( n+1, nVirTop, n+1, nVirBottom );
828*cdf0e10cSrcweir                     maVirDev.SetLineColor();
829*cdf0e10cSrcweir                     maVirDev.SetFillColor( rStyleSettings.GetWindowColor() );
830*cdf0e10cSrcweir                     ImplVDrawRect( n, nVirTop, n, nVirBottom );
831*cdf0e10cSrcweir                 }
832*cdf0e10cSrcweir             }
833*cdf0e10cSrcweir         }
834*cdf0e10cSrcweir     }
835*cdf0e10cSrcweir }
836*cdf0e10cSrcweir 
837*cdf0e10cSrcweir // -----------------------------------------------------------------------
838*cdf0e10cSrcweir 
839*cdf0e10cSrcweir void Ruler::ImplDrawIndent( const Polygon& rPoly, sal_uInt16 nStyle )
840*cdf0e10cSrcweir {
841*cdf0e10cSrcweir     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
842*cdf0e10cSrcweir     Point   aPos1;
843*cdf0e10cSrcweir     Point   aPos2;
844*cdf0e10cSrcweir     sal_uInt16  nIndentStyle = nStyle & RULER_INDENT_STYLE;
845*cdf0e10cSrcweir 
846*cdf0e10cSrcweir     if ( nStyle & RULER_STYLE_INVISIBLE )
847*cdf0e10cSrcweir         return;
848*cdf0e10cSrcweir 
849*cdf0e10cSrcweir     if ( nStyle & RULER_STYLE_DONTKNOW )
850*cdf0e10cSrcweir     {
851*cdf0e10cSrcweir         maVirDev.SetLineColor( rStyleSettings.GetShadowColor() );
852*cdf0e10cSrcweir         maVirDev.SetFillColor( rStyleSettings.GetFaceColor() );
853*cdf0e10cSrcweir     }
854*cdf0e10cSrcweir     else
855*cdf0e10cSrcweir     {
856*cdf0e10cSrcweir         maVirDev.SetLineColor( rStyleSettings.GetDarkShadowColor() );
857*cdf0e10cSrcweir         maVirDev.SetFillColor( rStyleSettings.GetFaceColor() );
858*cdf0e10cSrcweir     }
859*cdf0e10cSrcweir 
860*cdf0e10cSrcweir     maVirDev.DrawPolygon( rPoly );
861*cdf0e10cSrcweir 
862*cdf0e10cSrcweir     if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) && !(nStyle & RULER_STYLE_DONTKNOW) )
863*cdf0e10cSrcweir     {
864*cdf0e10cSrcweir         if ( nIndentStyle == RULER_INDENT_BOTTOM )
865*cdf0e10cSrcweir         {
866*cdf0e10cSrcweir             maVirDev.SetLineColor( rStyleSettings.GetLightColor() );
867*cdf0e10cSrcweir             aPos1 = rPoly.GetPoint( 2 );
868*cdf0e10cSrcweir             aPos1.X()++;
869*cdf0e10cSrcweir             aPos2 = rPoly.GetPoint( 1 );
870*cdf0e10cSrcweir             aPos2.X()++;
871*cdf0e10cSrcweir             maVirDev.DrawLine( aPos2, aPos1 );
872*cdf0e10cSrcweir             aPos2.X()--;
873*cdf0e10cSrcweir             aPos2.Y()++;
874*cdf0e10cSrcweir             aPos1 = rPoly.GetPoint( 0 );
875*cdf0e10cSrcweir             aPos1.Y()++;
876*cdf0e10cSrcweir             maVirDev.DrawLine( aPos2, aPos1 );
877*cdf0e10cSrcweir             maVirDev.SetLineColor( rStyleSettings.GetShadowColor() );
878*cdf0e10cSrcweir             aPos2 = rPoly.GetPoint( 4 );
879*cdf0e10cSrcweir             aPos2.Y()++;
880*cdf0e10cSrcweir             maVirDev.DrawLine( aPos1, aPos2 );
881*cdf0e10cSrcweir             aPos2.X()--;
882*cdf0e10cSrcweir             aPos1 = rPoly.GetPoint( 3 );
883*cdf0e10cSrcweir             aPos1.X()--;
884*cdf0e10cSrcweir             maVirDev.DrawLine( aPos2, aPos1 );
885*cdf0e10cSrcweir             aPos1.Y()--;
886*cdf0e10cSrcweir             aPos2 = rPoly.GetPoint( 2 );
887*cdf0e10cSrcweir             aPos2.X()++;
888*cdf0e10cSrcweir             aPos2.Y()--;
889*cdf0e10cSrcweir             maVirDev.DrawLine( aPos2, aPos1 );
890*cdf0e10cSrcweir         }
891*cdf0e10cSrcweir         else
892*cdf0e10cSrcweir         {
893*cdf0e10cSrcweir             maVirDev.SetLineColor( rStyleSettings.GetLightColor() );
894*cdf0e10cSrcweir             aPos1 = rPoly.GetPoint( 2 );
895*cdf0e10cSrcweir             aPos1.X()++;
896*cdf0e10cSrcweir             aPos1.Y()++;
897*cdf0e10cSrcweir             aPos2 = rPoly.GetPoint( 3 );
898*cdf0e10cSrcweir             aPos2.Y()++;
899*cdf0e10cSrcweir             maVirDev.DrawLine( aPos1, aPos2 );
900*cdf0e10cSrcweir             aPos2 = rPoly.GetPoint( 1 );
901*cdf0e10cSrcweir             aPos2.X()++;
902*cdf0e10cSrcweir             maVirDev.DrawLine( aPos1, aPos2 );
903*cdf0e10cSrcweir             aPos2.X()--;
904*cdf0e10cSrcweir             aPos2.Y()--;
905*cdf0e10cSrcweir             aPos1 = rPoly.GetPoint( 0 );
906*cdf0e10cSrcweir             aPos1.Y()--;
907*cdf0e10cSrcweir             maVirDev.DrawLine( aPos2, aPos1 );
908*cdf0e10cSrcweir             maVirDev.SetLineColor( rStyleSettings.GetShadowColor() );
909*cdf0e10cSrcweir             aPos2 = rPoly.GetPoint( 4 );
910*cdf0e10cSrcweir             aPos2.Y()--;
911*cdf0e10cSrcweir             maVirDev.DrawLine( aPos1, aPos2 );
912*cdf0e10cSrcweir             aPos2.X()--;
913*cdf0e10cSrcweir             aPos1 = rPoly.GetPoint( 3 );
914*cdf0e10cSrcweir             aPos1.X()--;
915*cdf0e10cSrcweir             maVirDev.DrawLine( aPos2, aPos1 );
916*cdf0e10cSrcweir         }
917*cdf0e10cSrcweir 
918*cdf0e10cSrcweir         maVirDev.SetLineColor( rStyleSettings.GetDarkShadowColor() );
919*cdf0e10cSrcweir         maVirDev.SetFillColor();
920*cdf0e10cSrcweir         maVirDev.DrawPolygon( rPoly );
921*cdf0e10cSrcweir     }
922*cdf0e10cSrcweir }
923*cdf0e10cSrcweir 
924*cdf0e10cSrcweir // -----------------------------------------------------------------------
925*cdf0e10cSrcweir 
926*cdf0e10cSrcweir void Ruler::ImplDrawIndents( long nMin, long nMax, long nVirTop, long nVirBottom )
927*cdf0e10cSrcweir {
928*cdf0e10cSrcweir     sal_uInt16  j;
929*cdf0e10cSrcweir     long    n;
930*cdf0e10cSrcweir     long    nIndentHeight = (mnVirHeight/2) - 1;
931*cdf0e10cSrcweir     long    nIndentWidth2 = nIndentHeight-3;
932*cdf0e10cSrcweir     Polygon aPoly( 5 );
933*cdf0e10cSrcweir 
934*cdf0e10cSrcweir     for ( j = 0; j < mpData->nIndents; j++ )
935*cdf0e10cSrcweir     {
936*cdf0e10cSrcweir         if ( mpData->pIndents[j].nStyle & RULER_STYLE_INVISIBLE )
937*cdf0e10cSrcweir             continue;
938*cdf0e10cSrcweir 
939*cdf0e10cSrcweir         sal_uInt16  nStyle = mpData->pIndents[j].nStyle;
940*cdf0e10cSrcweir         sal_uInt16  nIndentStyle = nStyle & RULER_INDENT_STYLE;
941*cdf0e10cSrcweir 
942*cdf0e10cSrcweir         n = mpData->pIndents[j].nPos+mpData->nNullVirOff;
943*cdf0e10cSrcweir 
944*cdf0e10cSrcweir         if ( (n >= nMin) && (n <= nMax) )
945*cdf0e10cSrcweir         {
946*cdf0e10cSrcweir             if(nIndentStyle == RULER_INDENT_BORDER)
947*cdf0e10cSrcweir             {
948*cdf0e10cSrcweir 				const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
949*cdf0e10cSrcweir 				maVirDev.SetLineColor( rStyleSettings.GetShadowColor() );
950*cdf0e10cSrcweir                 ImplVDrawLine( n, nVirTop, n, nVirBottom );
951*cdf0e10cSrcweir             }
952*cdf0e10cSrcweir             else if ( nIndentStyle == RULER_INDENT_BOTTOM )
953*cdf0e10cSrcweir             {
954*cdf0e10cSrcweir                 aPoly.SetPoint( Point( n+0, nVirBottom-nIndentHeight ), 0 );
955*cdf0e10cSrcweir                 aPoly.SetPoint( Point( n-nIndentWidth2, nVirBottom-3 ), 1 );
956*cdf0e10cSrcweir                 aPoly.SetPoint( Point( n-nIndentWidth2, nVirBottom ), 2 );
957*cdf0e10cSrcweir                 aPoly.SetPoint( Point( n+nIndentWidth2, nVirBottom ), 3 );
958*cdf0e10cSrcweir                 aPoly.SetPoint( Point( n+nIndentWidth2, nVirBottom-3 ), 4 );
959*cdf0e10cSrcweir             }
960*cdf0e10cSrcweir             else
961*cdf0e10cSrcweir             {
962*cdf0e10cSrcweir                 aPoly.SetPoint( Point( n+0, nVirTop+nIndentHeight ), 0 );
963*cdf0e10cSrcweir                 aPoly.SetPoint( Point( n-nIndentWidth2, nVirTop+3 ), 1 );
964*cdf0e10cSrcweir                 aPoly.SetPoint( Point( n-nIndentWidth2, nVirTop ), 2 );
965*cdf0e10cSrcweir                 aPoly.SetPoint( Point( n+nIndentWidth2, nVirTop ), 3 );
966*cdf0e10cSrcweir                 aPoly.SetPoint( Point( n+nIndentWidth2, nVirTop+3 ), 4 );
967*cdf0e10cSrcweir             }
968*cdf0e10cSrcweir 
969*cdf0e10cSrcweir             if(0 == (mnWinStyle & WB_HORZ))
970*cdf0e10cSrcweir             {
971*cdf0e10cSrcweir                 Point aTmp;
972*cdf0e10cSrcweir                 for(sal_uInt16 i = 0; i < 5; i++)
973*cdf0e10cSrcweir                 {
974*cdf0e10cSrcweir                     aTmp = aPoly[i];
975*cdf0e10cSrcweir                     Point aSet(nVirBottom - aTmp.Y(), aTmp.X());
976*cdf0e10cSrcweir                     aPoly[i] = aSet;
977*cdf0e10cSrcweir                 }
978*cdf0e10cSrcweir             }
979*cdf0e10cSrcweir             if(RULER_INDENT_BORDER != nIndentStyle)
980*cdf0e10cSrcweir 				ImplDrawIndent( aPoly, nStyle );
981*cdf0e10cSrcweir         }
982*cdf0e10cSrcweir     }
983*cdf0e10cSrcweir }
984*cdf0e10cSrcweir 
985*cdf0e10cSrcweir // -----------------------------------------------------------------------
986*cdf0e10cSrcweir 
987*cdf0e10cSrcweir static void ImplCenterTabPos( Point& rPos, sal_uInt16 nTabStyle )
988*cdf0e10cSrcweir {
989*cdf0e10cSrcweir     sal_Bool bRTL  = 0 != (nTabStyle & RULER_TAB_RTL);
990*cdf0e10cSrcweir     nTabStyle &= RULER_TAB_STYLE;
991*cdf0e10cSrcweir     rPos.Y() += RULER_TAB_HEIGHT/2;
992*cdf0e10cSrcweir     if ( (!bRTL && nTabStyle == RULER_TAB_LEFT) ||( bRTL && nTabStyle == RULER_TAB_RIGHT))
993*cdf0e10cSrcweir         rPos.X() -= RULER_TAB_WIDTH/2;
994*cdf0e10cSrcweir     else if ( (!bRTL && nTabStyle == RULER_TAB_RIGHT) ||( bRTL && nTabStyle == RULER_TAB_LEFT))
995*cdf0e10cSrcweir         rPos.X() += RULER_TAB_WIDTH/2;
996*cdf0e10cSrcweir }
997*cdf0e10cSrcweir 
998*cdf0e10cSrcweir // -----------------------------------------------------------------------
999*cdf0e10cSrcweir void lcl_RotateRect_Impl(Rectangle& rRect, const long nReference, sal_Bool bRightAligned)
1000*cdf0e10cSrcweir {
1001*cdf0e10cSrcweir     if(!rRect.IsEmpty())
1002*cdf0e10cSrcweir     {
1003*cdf0e10cSrcweir         Rectangle aTmp(rRect);
1004*cdf0e10cSrcweir         rRect.Top() = aTmp.Left();
1005*cdf0e10cSrcweir         rRect.Bottom() = aTmp.Right();
1006*cdf0e10cSrcweir         rRect.Left() = aTmp.Top();
1007*cdf0e10cSrcweir         rRect.Right() = aTmp.Bottom();
1008*cdf0e10cSrcweir         if(bRightAligned)
1009*cdf0e10cSrcweir         {
1010*cdf0e10cSrcweir             long nRef = 2 * nReference;
1011*cdf0e10cSrcweir 			rRect.Left() = nRef - rRect.Left();
1012*cdf0e10cSrcweir             rRect.Right() = nRef - rRect.Right();
1013*cdf0e10cSrcweir         }
1014*cdf0e10cSrcweir     }
1015*cdf0e10cSrcweir }
1016*cdf0e10cSrcweir // -----------------------------------------------------------------------
1017*cdf0e10cSrcweir 
1018*cdf0e10cSrcweir static void ImplDrawRulerTab( OutputDevice* pDevice,
1019*cdf0e10cSrcweir                              const Point& rPos, sal_uInt16 nStyle, WinBits nWinBits )
1020*cdf0e10cSrcweir {
1021*cdf0e10cSrcweir     if ( nStyle & RULER_STYLE_INVISIBLE )
1022*cdf0e10cSrcweir         return;
1023*cdf0e10cSrcweir 
1024*cdf0e10cSrcweir     sal_uInt16 nTabStyle = nStyle & RULER_TAB_STYLE;
1025*cdf0e10cSrcweir     sal_Bool bRTL = 0 != (nStyle & RULER_TAB_RTL);
1026*cdf0e10cSrcweir     Rectangle aRect1, aRect2, aRect3;
1027*cdf0e10cSrcweir     aRect3.SetEmpty();
1028*cdf0e10cSrcweir     if ( nTabStyle == RULER_TAB_DEFAULT )
1029*cdf0e10cSrcweir     {
1030*cdf0e10cSrcweir         aRect1.Left() =     rPos.X() - RULER_TAB_DWIDTH2 + 1                ;
1031*cdf0e10cSrcweir         aRect1.Top() =      rPos.Y() - RULER_TAB_DHEIGHT2 + 1               ;
1032*cdf0e10cSrcweir         aRect1.Right() =    rPos.X() - RULER_TAB_DWIDTH2 + RULER_TAB_DWIDTH ;
1033*cdf0e10cSrcweir         aRect1.Bottom() =   rPos.Y();
1034*cdf0e10cSrcweir         aRect2.Left() =     rPos.X() - RULER_TAB_DWIDTH2 + RULER_TAB_DWIDTH3;
1035*cdf0e10cSrcweir         aRect2.Top() =      rPos.Y() - RULER_TAB_DHEIGHT + 1;
1036*cdf0e10cSrcweir         aRect2.Right() =    rPos.X() - RULER_TAB_DWIDTH2 + RULER_TAB_DWIDTH3 + RULER_TAB_DWIDTH4 - 1;
1037*cdf0e10cSrcweir         aRect2.Bottom() =   rPos.Y();
1038*cdf0e10cSrcweir 
1039*cdf0e10cSrcweir     }
1040*cdf0e10cSrcweir     else if ( (!bRTL && nTabStyle == RULER_TAB_LEFT) ||( bRTL && nTabStyle == RULER_TAB_RIGHT))
1041*cdf0e10cSrcweir     {
1042*cdf0e10cSrcweir         aRect1.Left() =     rPos.X();
1043*cdf0e10cSrcweir         aRect1.Top() =      rPos.Y() - RULER_TAB_HEIGHT2 + 1;
1044*cdf0e10cSrcweir         aRect1.Right() =    rPos.X() + RULER_TAB_WIDTH - 1;
1045*cdf0e10cSrcweir         aRect1.Bottom() =   rPos.Y();
1046*cdf0e10cSrcweir         aRect2.Left() =     rPos.X();
1047*cdf0e10cSrcweir         aRect2.Top() =      rPos.Y() - RULER_TAB_HEIGHT + 1;
1048*cdf0e10cSrcweir         aRect2.Right() =    rPos.X() + RULER_TAB_WIDTH2 - 1;
1049*cdf0e10cSrcweir         aRect2.Bottom() =   rPos.Y();
1050*cdf0e10cSrcweir     }
1051*cdf0e10cSrcweir     else if ( (!bRTL && nTabStyle == RULER_TAB_RIGHT) ||( bRTL && nTabStyle == RULER_TAB_LEFT))
1052*cdf0e10cSrcweir     {
1053*cdf0e10cSrcweir         aRect1.Left() =     rPos.X() - RULER_TAB_WIDTH + 1;
1054*cdf0e10cSrcweir         aRect1.Top() =      rPos.Y() - RULER_TAB_HEIGHT2 + 1;
1055*cdf0e10cSrcweir         aRect1.Right() =    rPos.X();
1056*cdf0e10cSrcweir         aRect1.Bottom() =   rPos.Y();
1057*cdf0e10cSrcweir         aRect2.Left() =     rPos.X() - RULER_TAB_WIDTH2 + 1;
1058*cdf0e10cSrcweir         aRect2.Top() =      rPos.Y() - RULER_TAB_HEIGHT + 1;
1059*cdf0e10cSrcweir         aRect2.Right() =    rPos.X();
1060*cdf0e10cSrcweir         aRect2.Bottom() =   rPos.Y();
1061*cdf0e10cSrcweir     }
1062*cdf0e10cSrcweir     else
1063*cdf0e10cSrcweir     {
1064*cdf0e10cSrcweir         aRect1.Left() =     rPos.X() - RULER_TAB_CWIDTH2 + 1;
1065*cdf0e10cSrcweir         aRect1.Top() =      rPos.Y() - RULER_TAB_HEIGHT2 + 1;
1066*cdf0e10cSrcweir         aRect1.Right() =    rPos.X() - RULER_TAB_CWIDTH2 + RULER_TAB_CWIDTH;
1067*cdf0e10cSrcweir         aRect1.Bottom() =   rPos.Y();
1068*cdf0e10cSrcweir         aRect2.Left() =     rPos.X() - RULER_TAB_CWIDTH2 + RULER_TAB_CWIDTH3;
1069*cdf0e10cSrcweir         aRect2.Top() =      rPos.Y() - RULER_TAB_HEIGHT + 1;
1070*cdf0e10cSrcweir         aRect2.Right() =    rPos.X() - RULER_TAB_CWIDTH2 + RULER_TAB_CWIDTH3 + RULER_TAB_CWIDTH4 - 1;
1071*cdf0e10cSrcweir         aRect2.Bottom() =   rPos.Y();
1072*cdf0e10cSrcweir 
1073*cdf0e10cSrcweir         if ( nTabStyle == RULER_TAB_DECIMAL )
1074*cdf0e10cSrcweir         {
1075*cdf0e10cSrcweir             aRect3.Left() = rPos.X() - RULER_TAB_CWIDTH2 + RULER_TAB_CWIDTH - 1;
1076*cdf0e10cSrcweir             aRect3.Top()  = rPos.Y() - RULER_TAB_HEIGHT + 1 + 1;
1077*cdf0e10cSrcweir             aRect3.Right() = rPos.X() - RULER_TAB_CWIDTH2 + RULER_TAB_CWIDTH;
1078*cdf0e10cSrcweir             aRect3.Bottom()= rPos.Y() - RULER_TAB_HEIGHT + 1 + 2 ;
1079*cdf0e10cSrcweir         }
1080*cdf0e10cSrcweir     }
1081*cdf0e10cSrcweir     if( 0 == (nWinBits&WB_HORZ) )
1082*cdf0e10cSrcweir     {
1083*cdf0e10cSrcweir         sal_Bool bRightAligned = 0 != (nWinBits&WB_RIGHT_ALIGNED);
1084*cdf0e10cSrcweir         lcl_RotateRect_Impl(aRect1, rPos.Y(), bRightAligned);
1085*cdf0e10cSrcweir         lcl_RotateRect_Impl(aRect2, rPos.Y(), bRightAligned);
1086*cdf0e10cSrcweir         lcl_RotateRect_Impl(aRect3, rPos.Y(), bRightAligned);
1087*cdf0e10cSrcweir     }
1088*cdf0e10cSrcweir     pDevice->DrawRect( aRect1 );
1089*cdf0e10cSrcweir     pDevice->DrawRect( aRect2 );
1090*cdf0e10cSrcweir     if(!aRect2.IsEmpty())
1091*cdf0e10cSrcweir         pDevice->DrawRect( aRect3 );
1092*cdf0e10cSrcweir 
1093*cdf0e10cSrcweir }
1094*cdf0e10cSrcweir 
1095*cdf0e10cSrcweir // -----------------------------------------------------------------------
1096*cdf0e10cSrcweir 
1097*cdf0e10cSrcweir void Ruler::ImplDrawTab( OutputDevice* pDevice, const Point& rPos, sal_uInt16 nStyle )
1098*cdf0e10cSrcweir {
1099*cdf0e10cSrcweir     if ( nStyle & RULER_STYLE_INVISIBLE )
1100*cdf0e10cSrcweir         return;
1101*cdf0e10cSrcweir 
1102*cdf0e10cSrcweir     pDevice->SetLineColor();
1103*cdf0e10cSrcweir     if ( nStyle & RULER_STYLE_DONTKNOW )
1104*cdf0e10cSrcweir         pDevice->SetFillColor( GetSettings().GetStyleSettings().GetFaceColor() );
1105*cdf0e10cSrcweir     else
1106*cdf0e10cSrcweir         pDevice->SetFillColor( GetSettings().GetStyleSettings().GetWindowTextColor() );
1107*cdf0e10cSrcweir 
1108*cdf0e10cSrcweir     if(mpData->bTextRTL)
1109*cdf0e10cSrcweir         nStyle |= RULER_TAB_RTL;
1110*cdf0e10cSrcweir     ImplDrawRulerTab( pDevice, rPos, nStyle, GetStyle());
1111*cdf0e10cSrcweir }
1112*cdf0e10cSrcweir 
1113*cdf0e10cSrcweir // -----------------------------------------------------------------------
1114*cdf0e10cSrcweir 
1115*cdf0e10cSrcweir void Ruler::ImplDrawTabs( long nMin, long nMax, long nVirTop, long nVirBottom )
1116*cdf0e10cSrcweir {
1117*cdf0e10cSrcweir     for ( sal_uInt16 i = 0; i < mpData->nTabs; i++ )
1118*cdf0e10cSrcweir     {
1119*cdf0e10cSrcweir         if ( mpData->pTabs[i].nStyle & RULER_STYLE_INVISIBLE )
1120*cdf0e10cSrcweir             continue;
1121*cdf0e10cSrcweir 
1122*cdf0e10cSrcweir         long n;
1123*cdf0e10cSrcweir             n = mpData->pTabs[i].nPos;
1124*cdf0e10cSrcweir 		n += +mpData->nNullVirOff;
1125*cdf0e10cSrcweir         long nTopBottom = GetStyle() & WB_RIGHT_ALIGNED ? nVirTop : nVirBottom;
1126*cdf0e10cSrcweir         if ( (n >= nMin) && (n <= nMax) )
1127*cdf0e10cSrcweir             ImplDrawTab( &maVirDev, Point( n, nTopBottom ), mpData->pTabs[i].nStyle );
1128*cdf0e10cSrcweir     }
1129*cdf0e10cSrcweir }
1130*cdf0e10cSrcweir 
1131*cdf0e10cSrcweir // -----------------------------------------------------------------------
1132*cdf0e10cSrcweir 
1133*cdf0e10cSrcweir void Ruler::ImplInitSettings( sal_Bool bFont,
1134*cdf0e10cSrcweir                               sal_Bool bForeground, sal_Bool bBackground )
1135*cdf0e10cSrcweir {
1136*cdf0e10cSrcweir     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1137*cdf0e10cSrcweir 
1138*cdf0e10cSrcweir     if ( bFont )
1139*cdf0e10cSrcweir     {
1140*cdf0e10cSrcweir         Font aFont;
1141*cdf0e10cSrcweir         aFont = rStyleSettings.GetToolFont();
1142*cdf0e10cSrcweir         if ( IsControlFont() )
1143*cdf0e10cSrcweir             aFont.Merge( GetControlFont() );
1144*cdf0e10cSrcweir         SetZoomedPointFont( aFont );
1145*cdf0e10cSrcweir     }
1146*cdf0e10cSrcweir 
1147*cdf0e10cSrcweir     if ( bForeground || bFont )
1148*cdf0e10cSrcweir     {
1149*cdf0e10cSrcweir         Color aColor;
1150*cdf0e10cSrcweir         if ( IsControlForeground() )
1151*cdf0e10cSrcweir             aColor = GetControlForeground();
1152*cdf0e10cSrcweir         else
1153*cdf0e10cSrcweir             aColor = rStyleSettings.GetWindowTextColor();
1154*cdf0e10cSrcweir         SetTextColor( aColor );
1155*cdf0e10cSrcweir         SetTextFillColor();
1156*cdf0e10cSrcweir     }
1157*cdf0e10cSrcweir 
1158*cdf0e10cSrcweir     if ( bBackground )
1159*cdf0e10cSrcweir     {
1160*cdf0e10cSrcweir         Color aColor;
1161*cdf0e10cSrcweir         if ( IsControlBackground() )
1162*cdf0e10cSrcweir             aColor = GetControlBackground();
1163*cdf0e10cSrcweir         else
1164*cdf0e10cSrcweir             aColor = rStyleSettings.GetFaceColor();
1165*cdf0e10cSrcweir         SetBackground( aColor );
1166*cdf0e10cSrcweir     }
1167*cdf0e10cSrcweir 
1168*cdf0e10cSrcweir     maVirDev.SetSettings( GetSettings() );
1169*cdf0e10cSrcweir     maVirDev.SetBackground( GetBackground() );
1170*cdf0e10cSrcweir     Font aFont = GetFont();
1171*cdf0e10cSrcweir     if ( mnWinStyle & WB_VERT )
1172*cdf0e10cSrcweir         aFont.SetOrientation( 900 );
1173*cdf0e10cSrcweir     maVirDev.SetFont( aFont );
1174*cdf0e10cSrcweir     maVirDev.SetTextColor( GetTextColor() );
1175*cdf0e10cSrcweir     maVirDev.SetTextFillColor( GetTextFillColor() );
1176*cdf0e10cSrcweir }
1177*cdf0e10cSrcweir 
1178*cdf0e10cSrcweir // -----------------------------------------------------------------------
1179*cdf0e10cSrcweir 
1180*cdf0e10cSrcweir void Ruler::ImplCalc()
1181*cdf0e10cSrcweir {
1182*cdf0e10cSrcweir     // Offset berechnen
1183*cdf0e10cSrcweir     mpData->nRulVirOff = mnWinOff + mpData->nPageOff;
1184*cdf0e10cSrcweir     if ( mpData->nRulVirOff > mnVirOff )
1185*cdf0e10cSrcweir         mpData->nRulVirOff -= mnVirOff;
1186*cdf0e10cSrcweir     else
1187*cdf0e10cSrcweir         mpData->nRulVirOff = 0;
1188*cdf0e10cSrcweir     long nRulWinOff = mpData->nRulVirOff+mnVirOff;
1189*cdf0e10cSrcweir 
1190*cdf0e10cSrcweir     // Nicht sichtbaren Bereich der Page berechnen
1191*cdf0e10cSrcweir     long nNotVisPageWidth;
1192*cdf0e10cSrcweir     if ( mpData->nPageOff < 0 )
1193*cdf0e10cSrcweir     {
1194*cdf0e10cSrcweir         nNotVisPageWidth = -(mpData->nPageOff);
1195*cdf0e10cSrcweir         if ( nRulWinOff < mnWinOff )
1196*cdf0e10cSrcweir             nNotVisPageWidth -= mnWinOff-nRulWinOff;
1197*cdf0e10cSrcweir     }
1198*cdf0e10cSrcweir     else
1199*cdf0e10cSrcweir         nNotVisPageWidth = 0;
1200*cdf0e10cSrcweir 
1201*cdf0e10cSrcweir     // Breite berechnen
1202*cdf0e10cSrcweir     if ( mnWinStyle & WB_HORZ )
1203*cdf0e10cSrcweir     {
1204*cdf0e10cSrcweir         if ( mbAutoWinWidth )
1205*cdf0e10cSrcweir             mnWinWidth = mnWidth - mnVirOff;
1206*cdf0e10cSrcweir         if ( mpData->bAutoPageWidth )
1207*cdf0e10cSrcweir             mpData->nPageWidth = mnWinWidth;
1208*cdf0e10cSrcweir         mpData->nRulWidth = Min( mnWinWidth, mpData->nPageWidth-nNotVisPageWidth );
1209*cdf0e10cSrcweir         if ( nRulWinOff+mpData->nRulWidth > mnWidth )
1210*cdf0e10cSrcweir             mpData->nRulWidth = mnWidth-nRulWinOff;
1211*cdf0e10cSrcweir     }
1212*cdf0e10cSrcweir     else
1213*cdf0e10cSrcweir     {
1214*cdf0e10cSrcweir         if ( mbAutoWinWidth )
1215*cdf0e10cSrcweir             mnWinWidth = mnHeight - mnVirOff;
1216*cdf0e10cSrcweir         if ( mpData->bAutoPageWidth )
1217*cdf0e10cSrcweir             mpData->nPageWidth = mnWinWidth;
1218*cdf0e10cSrcweir         mpData->nRulWidth = Min( mnWinWidth, mpData->nPageWidth-nNotVisPageWidth );
1219*cdf0e10cSrcweir         if ( nRulWinOff+mpData->nRulWidth > mnHeight )
1220*cdf0e10cSrcweir             mpData->nRulWidth = mnHeight-nRulWinOff;
1221*cdf0e10cSrcweir     }
1222*cdf0e10cSrcweir 
1223*cdf0e10cSrcweir     mbCalc = sal_False;
1224*cdf0e10cSrcweir }
1225*cdf0e10cSrcweir 
1226*cdf0e10cSrcweir // -----------------------------------------------------------------------
1227*cdf0e10cSrcweir 
1228*cdf0e10cSrcweir void Ruler::ImplFormat()
1229*cdf0e10cSrcweir {
1230*cdf0e10cSrcweir     // Wenn schon formatiert ist, brauchen wir es nicht nochmal
1231*cdf0e10cSrcweir     if ( !mbFormat )
1232*cdf0e10cSrcweir         return;
1233*cdf0e10cSrcweir 
1234*cdf0e10cSrcweir     // Wenn Fenster noch keine Groesse hat, brauchen wir noch nichts machen
1235*cdf0e10cSrcweir     if ( !mnVirWidth )
1236*cdf0e10cSrcweir         return;
1237*cdf0e10cSrcweir 
1238*cdf0e10cSrcweir     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1239*cdf0e10cSrcweir     long    nP1;            // Pixel-Position von Page1
1240*cdf0e10cSrcweir     long    nP2;            // Pixel-Position von Page2
1241*cdf0e10cSrcweir     long    nM1;            // Pixel-Position von Margin1
1242*cdf0e10cSrcweir     long    nM2;            // Pixel-Position von Margin2
1243*cdf0e10cSrcweir     long    nVirTop;        // Obere/Linke-Kante bei Ausgabe
1244*cdf0e10cSrcweir     long    nVirBottom;     // Untere/Rechte-Kante bei Ausgabe
1245*cdf0e10cSrcweir     long    nVirLeft;       // Linke/Obere-Kante bei Ausgabe
1246*cdf0e10cSrcweir     long    nVirRight;      // Rechte/Untere-Kante bei Ausgabe
1247*cdf0e10cSrcweir     long    nNullVirOff;    // Fuer schnellere Berechnung
1248*cdf0e10cSrcweir 
1249*cdf0e10cSrcweir     // Werte berechnen
1250*cdf0e10cSrcweir     if ( mbCalc )
1251*cdf0e10cSrcweir         ImplCalc();
1252*cdf0e10cSrcweir     mpData->nNullVirOff = mnWinOff+mpData->nPageOff+mpData->nNullOff-mnVirOff;
1253*cdf0e10cSrcweir     nNullVirOff = mpData->nNullVirOff;
1254*cdf0e10cSrcweir     nVirLeft    = mpData->nRulVirOff;
1255*cdf0e10cSrcweir     nVirRight   = nVirLeft+mpData->nRulWidth-1;
1256*cdf0e10cSrcweir     nVirTop     = 0;
1257*cdf0e10cSrcweir     nVirBottom  = mnVirHeight-1;
1258*cdf0e10cSrcweir 
1259*cdf0e10cSrcweir     if ( !IsReallyVisible() )
1260*cdf0e10cSrcweir         return;
1261*cdf0e10cSrcweir 
1262*cdf0e10cSrcweir     Size    aVirDevSize;
1263*cdf0e10cSrcweir     sal_Bool    b3DLook = !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO);
1264*cdf0e10cSrcweir 
1265*cdf0e10cSrcweir     // VirtualDevice initialize
1266*cdf0e10cSrcweir     if ( mnWinStyle & WB_HORZ )
1267*cdf0e10cSrcweir     {
1268*cdf0e10cSrcweir         aVirDevSize.Width() = mnVirWidth;
1269*cdf0e10cSrcweir         aVirDevSize.Height() = mnVirHeight;
1270*cdf0e10cSrcweir     }
1271*cdf0e10cSrcweir     else
1272*cdf0e10cSrcweir     {
1273*cdf0e10cSrcweir         aVirDevSize.Height() = mnVirWidth;
1274*cdf0e10cSrcweir         aVirDevSize.Width() = mnVirHeight;
1275*cdf0e10cSrcweir     }
1276*cdf0e10cSrcweir     if ( aVirDevSize != maVirDev.GetOutputSizePixel() )
1277*cdf0e10cSrcweir         maVirDev.SetOutputSizePixel( aVirDevSize, sal_True );
1278*cdf0e10cSrcweir     else
1279*cdf0e10cSrcweir         maVirDev.Erase();
1280*cdf0e10cSrcweir 
1281*cdf0e10cSrcweir     // Raender berechnen
1282*cdf0e10cSrcweir     if ( !(mpData->nMargin1Style & RULER_STYLE_INVISIBLE) )
1283*cdf0e10cSrcweir     {
1284*cdf0e10cSrcweir         nM1 = mpData->nMargin1+nNullVirOff;
1285*cdf0e10cSrcweir         if ( mpData->bAutoPageWidth )
1286*cdf0e10cSrcweir         {
1287*cdf0e10cSrcweir             nP1 = nVirLeft;
1288*cdf0e10cSrcweir             if ( nM1 < nVirLeft )
1289*cdf0e10cSrcweir                 nP1--;
1290*cdf0e10cSrcweir         }
1291*cdf0e10cSrcweir         else
1292*cdf0e10cSrcweir             nP1 = nNullVirOff-mpData->nNullOff;
1293*cdf0e10cSrcweir     }
1294*cdf0e10cSrcweir     else
1295*cdf0e10cSrcweir     {
1296*cdf0e10cSrcweir         nM1 = nVirLeft-1;
1297*cdf0e10cSrcweir         nP1 = nM1;
1298*cdf0e10cSrcweir     }
1299*cdf0e10cSrcweir     if ( !(mpData->nMargin2Style & RULER_STYLE_INVISIBLE) )
1300*cdf0e10cSrcweir     {
1301*cdf0e10cSrcweir         nM2 = mpData->nMargin2+nNullVirOff;
1302*cdf0e10cSrcweir         if ( mpData->bAutoPageWidth )
1303*cdf0e10cSrcweir         {
1304*cdf0e10cSrcweir             nP2 = nVirRight;
1305*cdf0e10cSrcweir             if ( nM2 > nVirRight )
1306*cdf0e10cSrcweir                 nP2++;
1307*cdf0e10cSrcweir         }
1308*cdf0e10cSrcweir         else
1309*cdf0e10cSrcweir             nP2 = nNullVirOff-mpData->nNullOff+mpData->nPageWidth;
1310*cdf0e10cSrcweir         if ( nM2 > nP2 )
1311*cdf0e10cSrcweir             nM2 = nP2;
1312*cdf0e10cSrcweir     }
1313*cdf0e10cSrcweir     else
1314*cdf0e10cSrcweir     {
1315*cdf0e10cSrcweir         nM2 = nVirRight+1;
1316*cdf0e10cSrcweir         nP2 = nM2;
1317*cdf0e10cSrcweir     }
1318*cdf0e10cSrcweir 
1319*cdf0e10cSrcweir     // Obere/untere Kante ausgeben
1320*cdf0e10cSrcweir     if ( b3DLook )
1321*cdf0e10cSrcweir         maVirDev.SetLineColor( rStyleSettings.GetShadowColor() );
1322*cdf0e10cSrcweir     else
1323*cdf0e10cSrcweir         maVirDev.SetLineColor( rStyleSettings.GetWindowTextColor() );
1324*cdf0e10cSrcweir     ImplVDrawLine( nVirLeft, nVirTop, nM1 - 1, nVirTop ); //top left line
1325*cdf0e10cSrcweir     ImplVDrawLine( nM2 +1, nVirTop, nP2 -1, nVirTop );      //top right line
1326*cdf0e10cSrcweir 
1327*cdf0e10cSrcweir     // Jetzt wird zwischen dem Schatten ausgegeben
1328*cdf0e10cSrcweir     nVirTop++;
1329*cdf0e10cSrcweir     nVirBottom--;
1330*cdf0e10cSrcweir 
1331*cdf0e10cSrcweir     // Margin1, Margin2 und Zwischenraum ausgeben
1332*cdf0e10cSrcweir     maVirDev.SetLineColor();
1333*cdf0e10cSrcweir     if ( b3DLook )
1334*cdf0e10cSrcweir         maVirDev.SetFillColor( rStyleSettings.GetFaceColor() );
1335*cdf0e10cSrcweir     else
1336*cdf0e10cSrcweir         maVirDev.SetFillColor( rStyleSettings.GetWindowColor() );
1337*cdf0e10cSrcweir     if ( nM1 > nVirLeft )
1338*cdf0e10cSrcweir         ImplVDrawRect( nP1, nVirTop, nM1-1, nVirBottom ); //left gray rectangle
1339*cdf0e10cSrcweir     if ( nM2 < nP2 )
1340*cdf0e10cSrcweir         ImplVDrawRect( nM2+1, nVirTop, nP2, nVirBottom ); //right gray rectangle
1341*cdf0e10cSrcweir     if ( nM2-nM1 > 0 )
1342*cdf0e10cSrcweir     {
1343*cdf0e10cSrcweir         maVirDev.SetFillColor( rStyleSettings.GetWindowColor() );
1344*cdf0e10cSrcweir         ImplVDrawRect( nM1, nVirTop, nM2-1, nVirBottom ); //center rectangle
1345*cdf0e10cSrcweir     }
1346*cdf0e10cSrcweir     if ( b3DLook )
1347*cdf0e10cSrcweir     {
1348*cdf0e10cSrcweir         maVirDev.SetLineColor( rStyleSettings.GetShadowColor() );
1349*cdf0e10cSrcweir         if ( nM1 > nVirLeft )
1350*cdf0e10cSrcweir         {
1351*cdf0e10cSrcweir             ImplVDrawLine( nM1-1, nVirTop, nM1-1, nVirBottom );//right line of the left rectangle
1352*cdf0e10cSrcweir             ImplVDrawLine( nP1, nVirBottom, nM1-1, nVirBottom );//bottom line of the left rectangle
1353*cdf0e10cSrcweir             if ( nP1 >= nVirLeft )
1354*cdf0e10cSrcweir             {
1355*cdf0e10cSrcweir                 ImplVDrawLine( nP1, nVirTop, nP1, nVirBottom );//left line of the left rectangle
1356*cdf0e10cSrcweir                 ImplVDrawLine( nP1, nVirBottom, nP1+1, nVirBottom );//?
1357*cdf0e10cSrcweir             }
1358*cdf0e10cSrcweir         }
1359*cdf0e10cSrcweir         if ( nM2 < nP2 )
1360*cdf0e10cSrcweir         {
1361*cdf0e10cSrcweir             ImplVDrawLine( nM2+1, nVirBottom, nP2-1, nVirBottom );//bottom line of the right rectangle
1362*cdf0e10cSrcweir             ImplVDrawLine( nM2+1, nVirTop, nM2+1, nVirBottom );//left line of the right rectangle
1363*cdf0e10cSrcweir             if ( nP2 <= nVirRight+1 )
1364*cdf0e10cSrcweir                 ImplVDrawLine( nP2-1, nVirTop, nP2-1, nVirBottom );//right line of the right rectangle
1365*cdf0e10cSrcweir         }
1366*cdf0e10cSrcweir     }
1367*cdf0e10cSrcweir     else
1368*cdf0e10cSrcweir     {
1369*cdf0e10cSrcweir         maVirDev.SetLineColor( rStyleSettings.GetWindowTextColor() );
1370*cdf0e10cSrcweir         if ( nP1 >= nVirLeft )
1371*cdf0e10cSrcweir             ImplVDrawLine( nP1, nVirTop, nP1, nVirBottom+1 );
1372*cdf0e10cSrcweir         if ( nM1 > nP1 )
1373*cdf0e10cSrcweir             ImplVDrawLine( nM1, nVirTop, nM1, nVirBottom );
1374*cdf0e10cSrcweir         if ( nM2 < nP2 )
1375*cdf0e10cSrcweir             ImplVDrawLine( nM2, nVirTop, nM2, nVirBottom );
1376*cdf0e10cSrcweir         if ( nP2 <= nVirRight+1 )
1377*cdf0e10cSrcweir             ImplVDrawLine( nP2, nVirTop, nP2, nVirBottom+1 );
1378*cdf0e10cSrcweir     }
1379*cdf0e10cSrcweir 
1380*cdf0e10cSrcweir     // Lineal-Beschriftung (nur wenn keine Bemassungspfeile)
1381*cdf0e10cSrcweir     if ( !mpData->pArrows )
1382*cdf0e10cSrcweir     {
1383*cdf0e10cSrcweir         long    nMin = nVirLeft;
1384*cdf0e10cSrcweir         long    nMax = nP2;
1385*cdf0e10cSrcweir         long    nStart = mpData->bTextRTL ? mpData->nMargin2 + nNullVirOff : nNullVirOff;
1386*cdf0e10cSrcweir         long    nCenter = nVirTop+((nVirBottom-nVirTop)/2);
1387*cdf0e10cSrcweir 
1388*cdf0e10cSrcweir         // Nicht Schatten uebermalen
1389*cdf0e10cSrcweir         if ( nP1 > nVirLeft )
1390*cdf0e10cSrcweir             nMin++;
1391*cdf0e10cSrcweir         if ( nP2 < nVirRight )
1392*cdf0e10cSrcweir             nMax--;
1393*cdf0e10cSrcweir 
1394*cdf0e10cSrcweir         // Draw captions
1395*cdf0e10cSrcweir         ImplDrawTicks( nMin, nMax, nStart, nCenter );
1396*cdf0e10cSrcweir     }
1397*cdf0e10cSrcweir 
1398*cdf0e10cSrcweir     // Draw borders
1399*cdf0e10cSrcweir     if ( mpData->pBorders )
1400*cdf0e10cSrcweir         ImplDrawBorders( nVirLeft, nP2, nVirTop, nVirBottom );
1401*cdf0e10cSrcweir 
1402*cdf0e10cSrcweir     // Draw indents
1403*cdf0e10cSrcweir     if ( mpData->pIndents )
1404*cdf0e10cSrcweir         ImplDrawIndents( nVirLeft, nP2, nVirTop-1, nVirBottom+1 );
1405*cdf0e10cSrcweir 
1406*cdf0e10cSrcweir     // Tabs
1407*cdf0e10cSrcweir     if ( mpData->pTabs )
1408*cdf0e10cSrcweir     {
1409*cdf0e10cSrcweir         ImplDrawTabs( nVirLeft, nP2, nVirTop-1, nVirBottom+1 );
1410*cdf0e10cSrcweir     }
1411*cdf0e10cSrcweir 
1412*cdf0e10cSrcweir     // Bemassungspfeile
1413*cdf0e10cSrcweir     if ( mpData->pArrows )
1414*cdf0e10cSrcweir         ImplDrawArrows( nVirTop+((nVirBottom-nVirTop)/2) );
1415*cdf0e10cSrcweir 
1416*cdf0e10cSrcweir     // Wir haben formatiert
1417*cdf0e10cSrcweir     mbFormat = sal_False;
1418*cdf0e10cSrcweir }
1419*cdf0e10cSrcweir 
1420*cdf0e10cSrcweir // -----------------------------------------------------------------------
1421*cdf0e10cSrcweir 
1422*cdf0e10cSrcweir void Ruler::ImplInitExtraField( sal_Bool bUpdate )
1423*cdf0e10cSrcweir {
1424*cdf0e10cSrcweir     // Extra-Field beruecksichtigen
1425*cdf0e10cSrcweir     if ( mnWinStyle & WB_EXTRAFIELD )
1426*cdf0e10cSrcweir     {
1427*cdf0e10cSrcweir         maExtraRect.Left()   = RULER_OFF;
1428*cdf0e10cSrcweir         maExtraRect.Top()    = RULER_OFF;
1429*cdf0e10cSrcweir         maExtraRect.Right()  = RULER_OFF+mnVirHeight-1;
1430*cdf0e10cSrcweir         maExtraRect.Bottom() = RULER_OFF+mnVirHeight-1;
1431*cdf0e10cSrcweir         if(mpData->bTextRTL)
1432*cdf0e10cSrcweir         {
1433*cdf0e10cSrcweir             Size aWinSize = GetOutputSizePixel();
1434*cdf0e10cSrcweir             if(mnWinStyle & WB_HORZ)
1435*cdf0e10cSrcweir 				maExtraRect.Move(aWinSize.Width() - maExtraRect.GetWidth() - maExtraRect.Left(), 0);
1436*cdf0e10cSrcweir 			else
1437*cdf0e10cSrcweir 				maExtraRect.Move(0, aWinSize.Height() - maExtraRect.GetHeight() - maExtraRect.Top());
1438*cdf0e10cSrcweir 			mnVirOff = 0;
1439*cdf0e10cSrcweir         }
1440*cdf0e10cSrcweir 		else
1441*cdf0e10cSrcweir 	        mnVirOff = maExtraRect.Right()+1;
1442*cdf0e10cSrcweir 
1443*cdf0e10cSrcweir     }
1444*cdf0e10cSrcweir     else
1445*cdf0e10cSrcweir     {
1446*cdf0e10cSrcweir         maExtraRect.SetEmpty();
1447*cdf0e10cSrcweir         mnVirOff = 0;
1448*cdf0e10cSrcweir     }
1449*cdf0e10cSrcweir 
1450*cdf0e10cSrcweir     if ( bUpdate )
1451*cdf0e10cSrcweir     {
1452*cdf0e10cSrcweir         mbCalc      = sal_True;
1453*cdf0e10cSrcweir         mbFormat    = sal_True;
1454*cdf0e10cSrcweir         Invalidate();
1455*cdf0e10cSrcweir     }
1456*cdf0e10cSrcweir }
1457*cdf0e10cSrcweir 
1458*cdf0e10cSrcweir // -----------------------------------------------------------------------
1459*cdf0e10cSrcweir 
1460*cdf0e10cSrcweir void Ruler::ImplDraw()
1461*cdf0e10cSrcweir {
1462*cdf0e10cSrcweir     if ( mbFormat )
1463*cdf0e10cSrcweir         ImplFormat();
1464*cdf0e10cSrcweir 
1465*cdf0e10cSrcweir     if ( IsReallyVisible() )
1466*cdf0e10cSrcweir     {
1467*cdf0e10cSrcweir         // Lineal ueber das VirtualDevice ausgeben
1468*cdf0e10cSrcweir         Point   aOffPos;
1469*cdf0e10cSrcweir         Size    aVirDevSize = maVirDev.GetOutputSizePixel();
1470*cdf0e10cSrcweir //        Size    aVirDevSize2 = maVirDev.GetOutputSizePixel();
1471*cdf0e10cSrcweir         if ( mnWinStyle & WB_HORZ )
1472*cdf0e10cSrcweir         {
1473*cdf0e10cSrcweir 			aOffPos.X() = mnVirOff;
1474*cdf0e10cSrcweir 			if(mpData->bTextRTL)
1475*cdf0e10cSrcweir 				aVirDevSize.Width() -= maExtraRect.GetWidth();
1476*cdf0e10cSrcweir 
1477*cdf0e10cSrcweir //	else
1478*cdf0e10cSrcweir //		aVirDevSize.Width() -= mnVirOff;
1479*cdf0e10cSrcweir             aOffPos.Y() = RULER_OFF;
1480*cdf0e10cSrcweir         }
1481*cdf0e10cSrcweir         else
1482*cdf0e10cSrcweir         {
1483*cdf0e10cSrcweir             aOffPos.X() = RULER_OFF;
1484*cdf0e10cSrcweir 			aOffPos.Y() = mnVirOff;
1485*cdf0e10cSrcweir //	else
1486*cdf0e10cSrcweir //		aVirDevSize.Height() -= mnVirOff;
1487*cdf0e10cSrcweir         }
1488*cdf0e10cSrcweir         DrawOutDev( aOffPos, aVirDevSize, Point(), aVirDevSize, maVirDev );
1489*cdf0e10cSrcweir 
1490*cdf0e10cSrcweir         // Positionslinien neu malen
1491*cdf0e10cSrcweir         ImplInvertLines( sal_True );
1492*cdf0e10cSrcweir     }
1493*cdf0e10cSrcweir }
1494*cdf0e10cSrcweir 
1495*cdf0e10cSrcweir // -----------------------------------------------------------------------
1496*cdf0e10cSrcweir 
1497*cdf0e10cSrcweir void Ruler::ImplDrawExtra( sal_Bool bPaint )
1498*cdf0e10cSrcweir {
1499*cdf0e10cSrcweir     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1500*cdf0e10cSrcweir     Rectangle   aRect = maExtraRect;
1501*cdf0e10cSrcweir     sal_Bool        bEraseRect = sal_False;
1502*cdf0e10cSrcweir 
1503*cdf0e10cSrcweir     if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
1504*cdf0e10cSrcweir     {
1505*cdf0e10cSrcweir         aRect.Left()    += 2;
1506*cdf0e10cSrcweir         aRect.Top()     += 2;
1507*cdf0e10cSrcweir         aRect.Right()   -= 2;
1508*cdf0e10cSrcweir         aRect.Bottom()  -= 2;
1509*cdf0e10cSrcweir     }
1510*cdf0e10cSrcweir     else
1511*cdf0e10cSrcweir     {
1512*cdf0e10cSrcweir         aRect.Left()    += 1;
1513*cdf0e10cSrcweir         aRect.Top()     += 1;
1514*cdf0e10cSrcweir         aRect.Right()   -= 1;
1515*cdf0e10cSrcweir         aRect.Bottom()  -= 1;
1516*cdf0e10cSrcweir     }
1517*cdf0e10cSrcweir 
1518*cdf0e10cSrcweir     if ( !bPaint && !(mnExtraStyle & RULER_STYLE_HIGHLIGHT) )
1519*cdf0e10cSrcweir     {
1520*cdf0e10cSrcweir         if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
1521*cdf0e10cSrcweir             SetFillColor( rStyleSettings.GetFaceColor() );
1522*cdf0e10cSrcweir         else
1523*cdf0e10cSrcweir             SetFillColor( rStyleSettings.GetWindowColor() );
1524*cdf0e10cSrcweir         bEraseRect = sal_True;
1525*cdf0e10cSrcweir     }
1526*cdf0e10cSrcweir     else
1527*cdf0e10cSrcweir     {
1528*cdf0e10cSrcweir         if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) && (mnExtraStyle & RULER_STYLE_HIGHLIGHT) )
1529*cdf0e10cSrcweir         {
1530*cdf0e10cSrcweir             SetFillColor( rStyleSettings.GetCheckedColor() );
1531*cdf0e10cSrcweir             bEraseRect = sal_True;
1532*cdf0e10cSrcweir         }
1533*cdf0e10cSrcweir     }
1534*cdf0e10cSrcweir 
1535*cdf0e10cSrcweir     if ( bEraseRect )
1536*cdf0e10cSrcweir     {
1537*cdf0e10cSrcweir         SetLineColor();
1538*cdf0e10cSrcweir         DrawRect( aRect );
1539*cdf0e10cSrcweir     }
1540*cdf0e10cSrcweir 
1541*cdf0e10cSrcweir     // Inhalt ausgeben
1542*cdf0e10cSrcweir     if ( meExtraType == RULER_EXTRA_NULLOFFSET )
1543*cdf0e10cSrcweir     {
1544*cdf0e10cSrcweir         if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
1545*cdf0e10cSrcweir             SetLineColor( rStyleSettings.GetButtonTextColor() );
1546*cdf0e10cSrcweir         else
1547*cdf0e10cSrcweir             SetLineColor( rStyleSettings.GetWindowTextColor() );
1548*cdf0e10cSrcweir         DrawLine( Point( aRect.Left()+1, aRect.Top()+4 ),
1549*cdf0e10cSrcweir                   Point( aRect.Right()-1, aRect.Top()+4 ) );
1550*cdf0e10cSrcweir         DrawLine( Point( aRect.Left()+4, aRect.Top()+1 ),
1551*cdf0e10cSrcweir                   Point( aRect.Left()+4, aRect.Bottom()-1 ) );
1552*cdf0e10cSrcweir     }
1553*cdf0e10cSrcweir     else if ( meExtraType == RULER_EXTRA_TAB )
1554*cdf0e10cSrcweir     {
1555*cdf0e10cSrcweir         sal_uInt16 nTabStyle = mnExtraStyle & RULER_TAB_STYLE;
1556*cdf0e10cSrcweir         if(mpData->bTextRTL)
1557*cdf0e10cSrcweir             nTabStyle |= RULER_TAB_RTL;
1558*cdf0e10cSrcweir         Point aCenter = aRect.Center();
1559*cdf0e10cSrcweir 		Point aDraw(aCenter);
1560*cdf0e10cSrcweir         ImplCenterTabPos( aDraw, nTabStyle );
1561*cdf0e10cSrcweir         WinBits nWinBits = GetStyle();
1562*cdf0e10cSrcweir         if(0 == (nWinBits&WB_HORZ) )
1563*cdf0e10cSrcweir 		{
1564*cdf0e10cSrcweir 			if(0 != (nWinBits&WB_RIGHT_ALIGNED))
1565*cdf0e10cSrcweir 				aDraw.Y() = 2 * aCenter.Y() - aDraw.Y();
1566*cdf0e10cSrcweir 			if(mpData->bTextRTL)
1567*cdf0e10cSrcweir 			{
1568*cdf0e10cSrcweir 				long nTemp = aDraw.X();
1569*cdf0e10cSrcweir 				aDraw.X() = aDraw.Y();
1570*cdf0e10cSrcweir 				aDraw.Y() = nTemp;
1571*cdf0e10cSrcweir 			}
1572*cdf0e10cSrcweir 		}
1573*cdf0e10cSrcweir         ImplDrawTab( this, aDraw, nTabStyle );
1574*cdf0e10cSrcweir     }
1575*cdf0e10cSrcweir 
1576*cdf0e10cSrcweir     if ( (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) && (mnExtraStyle & RULER_STYLE_HIGHLIGHT) )
1577*cdf0e10cSrcweir         Invert( aRect );
1578*cdf0e10cSrcweir }
1579*cdf0e10cSrcweir 
1580*cdf0e10cSrcweir // -----------------------------------------------------------------------
1581*cdf0e10cSrcweir 
1582*cdf0e10cSrcweir void Ruler::ImplUpdate( sal_Bool bMustCalc )
1583*cdf0e10cSrcweir {
1584*cdf0e10cSrcweir     // Hier schon Linien loeschen, damit Sie vor dem Neuberechnen schon
1585*cdf0e10cSrcweir     // geloscht sind, da danach die alten Positionen nicht mehr bestimmt
1586*cdf0e10cSrcweir     // werden koennen
1587*cdf0e10cSrcweir     if ( !mbFormat )
1588*cdf0e10cSrcweir         ImplInvertLines();
1589*cdf0e10cSrcweir 
1590*cdf0e10cSrcweir     // Flags setzen
1591*cdf0e10cSrcweir     if ( bMustCalc )
1592*cdf0e10cSrcweir         mbCalc = sal_True;
1593*cdf0e10cSrcweir     mbFormat = sal_True;
1594*cdf0e10cSrcweir 
1595*cdf0e10cSrcweir     // Wenn wir am Draggen sind, wird nach dem Drag-Handler automatisch
1596*cdf0e10cSrcweir     // das Lineal neu upgedatet
1597*cdf0e10cSrcweir     if ( mbDrag )
1598*cdf0e10cSrcweir         return;
1599*cdf0e10cSrcweir 
1600*cdf0e10cSrcweir     // Gegebenenfalls Update ausloesen
1601*cdf0e10cSrcweir     if ( IsReallyVisible() && IsUpdateMode() )
1602*cdf0e10cSrcweir     {
1603*cdf0e10cSrcweir         mnUpdateFlags |= RULER_UPDATE_DRAW;
1604*cdf0e10cSrcweir         if ( !mnUpdateEvtId )
1605*cdf0e10cSrcweir             mnUpdateEvtId = Application::PostUserEvent( LINK( this, Ruler, ImplUpdateHdl ), NULL );
1606*cdf0e10cSrcweir     }
1607*cdf0e10cSrcweir }
1608*cdf0e10cSrcweir 
1609*cdf0e10cSrcweir // -----------------------------------------------------------------------
1610*cdf0e10cSrcweir 
1611*cdf0e10cSrcweir sal_Bool Ruler::ImplHitTest( const Point& rPos, ImplRulerHitTest* pHitTest,
1612*cdf0e10cSrcweir                          sal_Bool bRequireStyle, sal_uInt16 nRequiredStyle ) const
1613*cdf0e10cSrcweir {
1614*cdf0e10cSrcweir     sal_uInt16      i;
1615*cdf0e10cSrcweir     sal_uInt16      nStyle;
1616*cdf0e10cSrcweir     long        nHitBottom;
1617*cdf0e10cSrcweir     long        nX;
1618*cdf0e10cSrcweir     long        nY;
1619*cdf0e10cSrcweir     long        n1;
1620*cdf0e10cSrcweir     long        n2;
1621*cdf0e10cSrcweir 
1622*cdf0e10cSrcweir     if ( !mbActive )
1623*cdf0e10cSrcweir         return sal_False;
1624*cdf0e10cSrcweir 
1625*cdf0e10cSrcweir     // Position ermitteln
1626*cdf0e10cSrcweir 	sal_Bool bIsHori = 0 != (mnWinStyle & WB_HORZ);
1627*cdf0e10cSrcweir     if ( bIsHori )
1628*cdf0e10cSrcweir     {
1629*cdf0e10cSrcweir         nX = rPos.X();
1630*cdf0e10cSrcweir         nY = rPos.Y();
1631*cdf0e10cSrcweir     }
1632*cdf0e10cSrcweir     else
1633*cdf0e10cSrcweir     {
1634*cdf0e10cSrcweir         nX = rPos.Y();
1635*cdf0e10cSrcweir         nY = rPos.X();
1636*cdf0e10cSrcweir     }
1637*cdf0e10cSrcweir     nHitBottom = mnVirHeight+(RULER_OFF*2);
1638*cdf0e10cSrcweir 
1639*cdf0e10cSrcweir     // --> FME 2004-08-05 #i32608#
1640*cdf0e10cSrcweir     pHitTest->nAryPos = 0;
1641*cdf0e10cSrcweir     pHitTest->mnDragSize = 0;
1642*cdf0e10cSrcweir     pHitTest->bSize = sal_False;
1643*cdf0e10cSrcweir     pHitTest->bSizeBar = sal_False;
1644*cdf0e10cSrcweir     // <--
1645*cdf0e10cSrcweir 
1646*cdf0e10cSrcweir     // Damit ueberstehende Tabs und Einzuege mit beruecksichtigt werden
1647*cdf0e10cSrcweir     long nXExtraOff;
1648*cdf0e10cSrcweir     if ( mpData->pTabs || mpData->pIndents )
1649*cdf0e10cSrcweir         nXExtraOff = (mnVirHeight/2) - 4;
1650*cdf0e10cSrcweir     else
1651*cdf0e10cSrcweir         nXExtraOff = 0;
1652*cdf0e10cSrcweir 
1653*cdf0e10cSrcweir     // Test auf ausserhalb
1654*cdf0e10cSrcweir     nX -= mnVirOff;
1655*cdf0e10cSrcweir     long nXTemp = nX;
1656*cdf0e10cSrcweir     if ( (nX < mpData->nRulVirOff-nXExtraOff) || (nX > mpData->nRulVirOff+mpData->nRulWidth+nXExtraOff) ||
1657*cdf0e10cSrcweir          (nY < 0) || (nY > nHitBottom) )
1658*cdf0e10cSrcweir     {
1659*cdf0e10cSrcweir         pHitTest->nPos = 0;
1660*cdf0e10cSrcweir         pHitTest->eType = RULER_TYPE_OUTSIDE;
1661*cdf0e10cSrcweir         return sal_False;
1662*cdf0e10cSrcweir     }
1663*cdf0e10cSrcweir 
1664*cdf0e10cSrcweir     nX -= mpData->nNullVirOff;
1665*cdf0e10cSrcweir     pHitTest->nPos  = nX;
1666*cdf0e10cSrcweir     pHitTest->eType = RULER_TYPE_DONTKNOW;
1667*cdf0e10cSrcweir 
1668*cdf0e10cSrcweir     // Zuerst die Tabs testen
1669*cdf0e10cSrcweir     Rectangle aRect;
1670*cdf0e10cSrcweir     if ( mpData->pTabs )
1671*cdf0e10cSrcweir     {
1672*cdf0e10cSrcweir         aRect.Bottom()  = nHitBottom;
1673*cdf0e10cSrcweir         aRect.Top()     = aRect.Bottom()-RULER_TAB_HEIGHT-RULER_OFF;
1674*cdf0e10cSrcweir 
1675*cdf0e10cSrcweir         for ( i = mpData->nTabs; i; i-- )
1676*cdf0e10cSrcweir         {
1677*cdf0e10cSrcweir             nStyle = mpData->pTabs[i-1].nStyle;
1678*cdf0e10cSrcweir             if ( !(nStyle & RULER_STYLE_INVISIBLE) )
1679*cdf0e10cSrcweir             {
1680*cdf0e10cSrcweir                 nStyle &= RULER_TAB_STYLE;
1681*cdf0e10cSrcweir 
1682*cdf0e10cSrcweir                 // Default-Tabs werden nur angezeigt
1683*cdf0e10cSrcweir                 if ( nStyle != RULER_TAB_DEFAULT )
1684*cdf0e10cSrcweir                 {
1685*cdf0e10cSrcweir                     n1 = mpData->pTabs[i-1].nPos;
1686*cdf0e10cSrcweir 
1687*cdf0e10cSrcweir                     if ( nStyle == RULER_TAB_LEFT )
1688*cdf0e10cSrcweir                     {
1689*cdf0e10cSrcweir                         aRect.Left()    = n1;
1690*cdf0e10cSrcweir                         aRect.Right()   = n1+RULER_TAB_WIDTH-1;
1691*cdf0e10cSrcweir                     }
1692*cdf0e10cSrcweir                     else if ( nStyle == RULER_TAB_RIGHT )
1693*cdf0e10cSrcweir                     {
1694*cdf0e10cSrcweir                         aRect.Right()   = n1;
1695*cdf0e10cSrcweir                         aRect.Left()    = n1-RULER_TAB_WIDTH-1;
1696*cdf0e10cSrcweir                     }
1697*cdf0e10cSrcweir                     else
1698*cdf0e10cSrcweir                     {
1699*cdf0e10cSrcweir                         aRect.Left()    = n1-RULER_TAB_CWIDTH2+1;
1700*cdf0e10cSrcweir                         aRect.Right()   = n1-RULER_TAB_CWIDTH2+RULER_TAB_CWIDTH;
1701*cdf0e10cSrcweir                     }
1702*cdf0e10cSrcweir 
1703*cdf0e10cSrcweir 					if ( aRect.IsInside( Point( nX, nY ) ) )
1704*cdf0e10cSrcweir                     {
1705*cdf0e10cSrcweir                         pHitTest->eType     = RULER_TYPE_TAB;
1706*cdf0e10cSrcweir                         pHitTest->nAryPos   = i-1;
1707*cdf0e10cSrcweir                         return sal_True;
1708*cdf0e10cSrcweir                     }
1709*cdf0e10cSrcweir                 }
1710*cdf0e10cSrcweir             }
1711*cdf0e10cSrcweir         }
1712*cdf0e10cSrcweir     }
1713*cdf0e10cSrcweir 
1714*cdf0e10cSrcweir     // Dann die Einzuege
1715*cdf0e10cSrcweir     if ( mpData->pIndents )
1716*cdf0e10cSrcweir     {
1717*cdf0e10cSrcweir         long nIndentHeight = (mnVirHeight/2) - 1;
1718*cdf0e10cSrcweir         long nIndentWidth2 = nIndentHeight-3;
1719*cdf0e10cSrcweir 
1720*cdf0e10cSrcweir         for ( i = mpData->nIndents; i; i-- )
1721*cdf0e10cSrcweir         {
1722*cdf0e10cSrcweir             nStyle = mpData->pIndents[i-1].nStyle;
1723*cdf0e10cSrcweir             if ( (! bRequireStyle || nStyle == nRequiredStyle) &&
1724*cdf0e10cSrcweir                  !(nStyle & RULER_STYLE_INVISIBLE) )
1725*cdf0e10cSrcweir             {
1726*cdf0e10cSrcweir                 nStyle &= RULER_INDENT_STYLE;
1727*cdf0e10cSrcweir                 n1 = mpData->pIndents[i-1].nPos;
1728*cdf0e10cSrcweir 
1729*cdf0e10cSrcweir                 if ( (nStyle == RULER_INDENT_BOTTOM) ^ (!bIsHori) )
1730*cdf0e10cSrcweir                 {
1731*cdf0e10cSrcweir                     aRect.Left()    = n1-nIndentWidth2;
1732*cdf0e10cSrcweir                     aRect.Right()   = n1+nIndentWidth2;
1733*cdf0e10cSrcweir                     aRect.Top()     = nHitBottom-nIndentHeight-RULER_OFF+1;
1734*cdf0e10cSrcweir                     aRect.Bottom()  = nHitBottom;
1735*cdf0e10cSrcweir                 }
1736*cdf0e10cSrcweir                 else
1737*cdf0e10cSrcweir                 {
1738*cdf0e10cSrcweir                     aRect.Left()    = n1-nIndentWidth2;
1739*cdf0e10cSrcweir                     aRect.Right()   = n1+nIndentWidth2;
1740*cdf0e10cSrcweir                     aRect.Top()     = 0;
1741*cdf0e10cSrcweir                     aRect.Bottom()  = nIndentHeight+RULER_OFF-1;
1742*cdf0e10cSrcweir                 }
1743*cdf0e10cSrcweir 
1744*cdf0e10cSrcweir                 if ( aRect.IsInside( Point( nX, nY ) ) )
1745*cdf0e10cSrcweir                 {
1746*cdf0e10cSrcweir                     pHitTest->eType     = RULER_TYPE_INDENT;
1747*cdf0e10cSrcweir                     pHitTest->nAryPos   = i-1;
1748*cdf0e10cSrcweir                     return sal_True;
1749*cdf0e10cSrcweir                 }
1750*cdf0e10cSrcweir             }
1751*cdf0e10cSrcweir         }
1752*cdf0e10cSrcweir     }
1753*cdf0e10cSrcweir 
1754*cdf0e10cSrcweir     // Jetzt zaehlt nichts mehr, was links oder rechts uebersteht
1755*cdf0e10cSrcweir     if ( (nXTemp < mpData->nRulVirOff) || (nXTemp > mpData->nRulVirOff+mpData->nRulWidth) )
1756*cdf0e10cSrcweir     {
1757*cdf0e10cSrcweir         pHitTest->nPos = 0;
1758*cdf0e10cSrcweir         pHitTest->eType = RULER_TYPE_OUTSIDE;
1759*cdf0e10cSrcweir         return sal_False;
1760*cdf0e10cSrcweir     }
1761*cdf0e10cSrcweir 
1762*cdf0e10cSrcweir     // Danach die Spalten testen
1763*cdf0e10cSrcweir     int nBorderTolerance = 1;
1764*cdf0e10cSrcweir     if(pHitTest->bExpandTest)
1765*cdf0e10cSrcweir     {
1766*cdf0e10cSrcweir         nBorderTolerance++;
1767*cdf0e10cSrcweir     }
1768*cdf0e10cSrcweir 
1769*cdf0e10cSrcweir     for ( i = mpData->nBorders; i; i-- )
1770*cdf0e10cSrcweir     {
1771*cdf0e10cSrcweir         n1 = mpData->pBorders[i-1].nPos;
1772*cdf0e10cSrcweir         n2 = n1 + mpData->pBorders[i-1].nWidth;
1773*cdf0e10cSrcweir 
1774*cdf0e10cSrcweir         // Spalten werden mit mindestens 3 Pixel breite gezeichnet
1775*cdf0e10cSrcweir         if ( !mpData->pBorders[i-1].nWidth )
1776*cdf0e10cSrcweir         {
1777*cdf0e10cSrcweir              n1 -= nBorderTolerance;
1778*cdf0e10cSrcweir              n2 += nBorderTolerance;
1779*cdf0e10cSrcweir 
1780*cdf0e10cSrcweir         }
1781*cdf0e10cSrcweir 
1782*cdf0e10cSrcweir         if ( (nX >= n1) && (nX <= n2) )
1783*cdf0e10cSrcweir         {
1784*cdf0e10cSrcweir             nStyle = mpData->pBorders[i-1].nStyle;
1785*cdf0e10cSrcweir             if ( !(nStyle & RULER_STYLE_INVISIBLE) )
1786*cdf0e10cSrcweir             {
1787*cdf0e10cSrcweir                 pHitTest->eType     = RULER_TYPE_BORDER;
1788*cdf0e10cSrcweir                 pHitTest->nAryPos   = i-1;
1789*cdf0e10cSrcweir 
1790*cdf0e10cSrcweir                 if ( !(nStyle & RULER_BORDER_SIZEABLE) )
1791*cdf0e10cSrcweir                 {
1792*cdf0e10cSrcweir                     if ( nStyle & RULER_BORDER_MOVEABLE )
1793*cdf0e10cSrcweir                     {
1794*cdf0e10cSrcweir                         pHitTest->bSizeBar = sal_True;
1795*cdf0e10cSrcweir                         pHitTest->mnDragSize = RULER_DRAGSIZE_MOVE;
1796*cdf0e10cSrcweir                     }
1797*cdf0e10cSrcweir                 }
1798*cdf0e10cSrcweir                 else
1799*cdf0e10cSrcweir                 {
1800*cdf0e10cSrcweir                     long nMOff = RULER_MOUSE_BORDERWIDTH;
1801*cdf0e10cSrcweir                     while ( nMOff*2 >= (n2-n1-RULER_MOUSE_BORDERMOVE) )
1802*cdf0e10cSrcweir                     {
1803*cdf0e10cSrcweir                         if ( nMOff < 2 )
1804*cdf0e10cSrcweir                         {
1805*cdf0e10cSrcweir                             nMOff = 0;
1806*cdf0e10cSrcweir                             break;
1807*cdf0e10cSrcweir                         }
1808*cdf0e10cSrcweir                         else
1809*cdf0e10cSrcweir                             nMOff--;
1810*cdf0e10cSrcweir                     }
1811*cdf0e10cSrcweir 
1812*cdf0e10cSrcweir                     if ( nX <= n1+nMOff )
1813*cdf0e10cSrcweir                     {
1814*cdf0e10cSrcweir                         pHitTest->bSize = sal_True;
1815*cdf0e10cSrcweir                         pHitTest->mnDragSize = RULER_DRAGSIZE_1;
1816*cdf0e10cSrcweir                     }
1817*cdf0e10cSrcweir                     else if ( nX >= n2-nMOff )
1818*cdf0e10cSrcweir                     {
1819*cdf0e10cSrcweir                         pHitTest->bSize = sal_True;
1820*cdf0e10cSrcweir                         pHitTest->mnDragSize = RULER_DRAGSIZE_2;
1821*cdf0e10cSrcweir                     }
1822*cdf0e10cSrcweir                     else
1823*cdf0e10cSrcweir                     {
1824*cdf0e10cSrcweir                         if ( nStyle & RULER_BORDER_MOVEABLE )
1825*cdf0e10cSrcweir                         {
1826*cdf0e10cSrcweir                             pHitTest->bSizeBar = sal_True;
1827*cdf0e10cSrcweir                             pHitTest->mnDragSize = RULER_DRAGSIZE_MOVE;
1828*cdf0e10cSrcweir                         }
1829*cdf0e10cSrcweir                     }
1830*cdf0e10cSrcweir                 }
1831*cdf0e10cSrcweir 
1832*cdf0e10cSrcweir                 return sal_True;
1833*cdf0e10cSrcweir             }
1834*cdf0e10cSrcweir         }
1835*cdf0e10cSrcweir     }
1836*cdf0e10cSrcweir 
1837*cdf0e10cSrcweir     // Und zum Schluss die Raender
1838*cdf0e10cSrcweir     int nMarginTolerance = pHitTest->bExpandTest ? nBorderTolerance : RULER_MOUSE_MARGINWIDTH;
1839*cdf0e10cSrcweir 
1840*cdf0e10cSrcweir     if ( (mpData->nMargin1Style & (RULER_MARGIN_SIZEABLE | RULER_STYLE_INVISIBLE)) == RULER_MARGIN_SIZEABLE )
1841*cdf0e10cSrcweir     {
1842*cdf0e10cSrcweir         n1 = mpData->nMargin1;
1843*cdf0e10cSrcweir         if ( (nX >= n1 - nMarginTolerance) && (nX <= n1 + nMarginTolerance) )
1844*cdf0e10cSrcweir         {
1845*cdf0e10cSrcweir             pHitTest->eType = RULER_TYPE_MARGIN1;
1846*cdf0e10cSrcweir             pHitTest->bSize = sal_True;
1847*cdf0e10cSrcweir             return sal_True;
1848*cdf0e10cSrcweir         }
1849*cdf0e10cSrcweir     }
1850*cdf0e10cSrcweir     if ( (mpData->nMargin2Style & (RULER_MARGIN_SIZEABLE | RULER_STYLE_INVISIBLE)) == RULER_MARGIN_SIZEABLE )
1851*cdf0e10cSrcweir     {
1852*cdf0e10cSrcweir         n1 = mpData->nMargin2;
1853*cdf0e10cSrcweir         if ( (nX >= n1 - nMarginTolerance) && (nX <= n1 + nMarginTolerance) )
1854*cdf0e10cSrcweir         {
1855*cdf0e10cSrcweir             pHitTest->eType = RULER_TYPE_MARGIN2;
1856*cdf0e10cSrcweir             pHitTest->bSize = sal_True;
1857*cdf0e10cSrcweir             return sal_True;
1858*cdf0e10cSrcweir         }
1859*cdf0e10cSrcweir     }
1860*cdf0e10cSrcweir 
1861*cdf0e10cSrcweir     // Jetzt nocheinmal die Tabs testen, nur mit etwas mehr spielraum
1862*cdf0e10cSrcweir     if ( mpData->pTabs )
1863*cdf0e10cSrcweir     {
1864*cdf0e10cSrcweir         aRect.Top()     = RULER_OFF;
1865*cdf0e10cSrcweir         aRect.Bottom()  = nHitBottom;
1866*cdf0e10cSrcweir 
1867*cdf0e10cSrcweir         for ( i = mpData->nTabs; i; i-- )
1868*cdf0e10cSrcweir         {
1869*cdf0e10cSrcweir             nStyle = mpData->pTabs[i-1].nStyle;
1870*cdf0e10cSrcweir             if ( !(nStyle & RULER_STYLE_INVISIBLE) )
1871*cdf0e10cSrcweir             {
1872*cdf0e10cSrcweir                 nStyle &= RULER_TAB_STYLE;
1873*cdf0e10cSrcweir 
1874*cdf0e10cSrcweir                 // Default-Tabs werden nur angezeigt
1875*cdf0e10cSrcweir                 if ( nStyle != RULER_TAB_DEFAULT )
1876*cdf0e10cSrcweir                 {
1877*cdf0e10cSrcweir                     n1 = mpData->pTabs[i-1].nPos;
1878*cdf0e10cSrcweir 
1879*cdf0e10cSrcweir                     if ( nStyle == RULER_TAB_LEFT )
1880*cdf0e10cSrcweir                     {
1881*cdf0e10cSrcweir                         aRect.Left()    = n1;
1882*cdf0e10cSrcweir                         aRect.Right()   = n1+RULER_TAB_WIDTH-1;
1883*cdf0e10cSrcweir                     }
1884*cdf0e10cSrcweir                     else if ( nStyle == RULER_TAB_RIGHT )
1885*cdf0e10cSrcweir                     {
1886*cdf0e10cSrcweir                         aRect.Right()   = n1;
1887*cdf0e10cSrcweir                         aRect.Left()    = n1-RULER_TAB_WIDTH-1;
1888*cdf0e10cSrcweir                     }
1889*cdf0e10cSrcweir                     else
1890*cdf0e10cSrcweir                     {
1891*cdf0e10cSrcweir                         aRect.Left()    = n1-RULER_TAB_CWIDTH2+1;
1892*cdf0e10cSrcweir                         aRect.Right()   = n1-RULER_TAB_CWIDTH2+RULER_TAB_CWIDTH;
1893*cdf0e10cSrcweir                     }
1894*cdf0e10cSrcweir 
1895*cdf0e10cSrcweir                     aRect.Left()--;
1896*cdf0e10cSrcweir                     aRect.Right()++;
1897*cdf0e10cSrcweir 
1898*cdf0e10cSrcweir                     if ( aRect.IsInside( Point( nX, nY ) ) )
1899*cdf0e10cSrcweir                     {
1900*cdf0e10cSrcweir                         pHitTest->eType     = RULER_TYPE_TAB;
1901*cdf0e10cSrcweir                         pHitTest->nAryPos   = i-1;
1902*cdf0e10cSrcweir                         return sal_True;
1903*cdf0e10cSrcweir                     }
1904*cdf0e10cSrcweir                 }
1905*cdf0e10cSrcweir             }
1906*cdf0e10cSrcweir         }
1907*cdf0e10cSrcweir     }
1908*cdf0e10cSrcweir 
1909*cdf0e10cSrcweir     return sal_False;
1910*cdf0e10cSrcweir }
1911*cdf0e10cSrcweir 
1912*cdf0e10cSrcweir // -----------------------------------------------------------------------
1913*cdf0e10cSrcweir 
1914*cdf0e10cSrcweir sal_Bool Ruler::ImplDocHitTest( const Point& rPos, RulerType eDragType,
1915*cdf0e10cSrcweir                             ImplRulerHitTest* pHitTest ) const
1916*cdf0e10cSrcweir {
1917*cdf0e10cSrcweir     Point aPos = rPos;
1918*cdf0e10cSrcweir     sal_Bool bRequiredStyle = sal_False;
1919*cdf0e10cSrcweir     sal_uInt16 nRequiredStyle = 0;
1920*cdf0e10cSrcweir 
1921*cdf0e10cSrcweir     if (eDragType == RULER_TYPE_INDENT)
1922*cdf0e10cSrcweir     {
1923*cdf0e10cSrcweir         bRequiredStyle = sal_True;
1924*cdf0e10cSrcweir         nRequiredStyle = RULER_INDENT_BOTTOM;
1925*cdf0e10cSrcweir     }
1926*cdf0e10cSrcweir 
1927*cdf0e10cSrcweir     if ( mnWinStyle & WB_HORZ )
1928*cdf0e10cSrcweir         aPos.X() += mnWinOff;
1929*cdf0e10cSrcweir     else
1930*cdf0e10cSrcweir         aPos.Y() += mnWinOff;
1931*cdf0e10cSrcweir 
1932*cdf0e10cSrcweir     if ( (eDragType == RULER_TYPE_INDENT) || (eDragType == RULER_TYPE_DONTKNOW) )
1933*cdf0e10cSrcweir     {
1934*cdf0e10cSrcweir         if ( mnWinStyle & WB_HORZ )
1935*cdf0e10cSrcweir             aPos.Y() = RULER_OFF+1;
1936*cdf0e10cSrcweir         else
1937*cdf0e10cSrcweir             aPos.X() = RULER_OFF+1;
1938*cdf0e10cSrcweir 
1939*cdf0e10cSrcweir         // HitTest durchfuehren
1940*cdf0e10cSrcweir         if ( ImplHitTest( aPos, pHitTest, bRequiredStyle, nRequiredStyle ) )
1941*cdf0e10cSrcweir         {
1942*cdf0e10cSrcweir             if ( (pHitTest->eType == eDragType) || (eDragType == RULER_TYPE_DONTKNOW) )
1943*cdf0e10cSrcweir                 return sal_True;
1944*cdf0e10cSrcweir         }
1945*cdf0e10cSrcweir     }
1946*cdf0e10cSrcweir 
1947*cdf0e10cSrcweir     if ( (eDragType == RULER_TYPE_INDENT) || (eDragType == RULER_TYPE_TAB) ||
1948*cdf0e10cSrcweir          (eDragType == RULER_TYPE_DONTKNOW) )
1949*cdf0e10cSrcweir     {
1950*cdf0e10cSrcweir         if ( mnWinStyle & WB_HORZ )
1951*cdf0e10cSrcweir             aPos.Y() = mnHeight-RULER_OFF-1;
1952*cdf0e10cSrcweir         else
1953*cdf0e10cSrcweir             aPos.X() = mnWidth-RULER_OFF-1;
1954*cdf0e10cSrcweir 
1955*cdf0e10cSrcweir         // HitTest durchfuehren
1956*cdf0e10cSrcweir         if ( ImplHitTest( aPos, pHitTest, bRequiredStyle, nRequiredStyle ) )
1957*cdf0e10cSrcweir         {
1958*cdf0e10cSrcweir             if ( (pHitTest->eType == eDragType) || (eDragType == RULER_TYPE_DONTKNOW) )
1959*cdf0e10cSrcweir                 return sal_True;
1960*cdf0e10cSrcweir         }
1961*cdf0e10cSrcweir     }
1962*cdf0e10cSrcweir 
1963*cdf0e10cSrcweir     if ( (eDragType == RULER_TYPE_MARGIN1) || (eDragType == RULER_TYPE_MARGIN2) ||
1964*cdf0e10cSrcweir          (eDragType == RULER_TYPE_BORDER) || (eDragType == RULER_TYPE_DONTKNOW) )
1965*cdf0e10cSrcweir     {
1966*cdf0e10cSrcweir         if ( mnWinStyle & WB_HORZ )
1967*cdf0e10cSrcweir             aPos.Y() = RULER_OFF + (mnVirHeight/2);
1968*cdf0e10cSrcweir         else
1969*cdf0e10cSrcweir             aPos.X() = RULER_OFF + (mnVirHeight/2);
1970*cdf0e10cSrcweir 
1971*cdf0e10cSrcweir         // HitTest durchfuehren
1972*cdf0e10cSrcweir         if ( ImplHitTest( aPos, pHitTest ) )
1973*cdf0e10cSrcweir         {
1974*cdf0e10cSrcweir             if ( (pHitTest->eType == eDragType) || (eDragType == RULER_TYPE_DONTKNOW) )
1975*cdf0e10cSrcweir                 return sal_True;
1976*cdf0e10cSrcweir         }
1977*cdf0e10cSrcweir     }
1978*cdf0e10cSrcweir 
1979*cdf0e10cSrcweir     // Auf DontKnow setzen
1980*cdf0e10cSrcweir     pHitTest->eType = RULER_TYPE_DONTKNOW;
1981*cdf0e10cSrcweir 
1982*cdf0e10cSrcweir     return sal_False;
1983*cdf0e10cSrcweir }
1984*cdf0e10cSrcweir 
1985*cdf0e10cSrcweir // -----------------------------------------------------------------------
1986*cdf0e10cSrcweir 
1987*cdf0e10cSrcweir sal_Bool Ruler::ImplStartDrag( ImplRulerHitTest* pHitTest, sal_uInt16 nModifier )
1988*cdf0e10cSrcweir {
1989*cdf0e10cSrcweir     // Wenn eine Spalte angeklick wurde, die weder verschiebar noch
1990*cdf0e10cSrcweir     // in der Groesse aenderbar ist, brauchen wir auch kein Drag ausloesen
1991*cdf0e10cSrcweir     if ( (pHitTest->eType == RULER_TYPE_BORDER) &&
1992*cdf0e10cSrcweir          !pHitTest->bSize && !pHitTest->bSizeBar )
1993*cdf0e10cSrcweir         return sal_False;
1994*cdf0e10cSrcweir 
1995*cdf0e10cSrcweir     // Dragdaten setzen
1996*cdf0e10cSrcweir     meDragType      = pHitTest->eType;
1997*cdf0e10cSrcweir     mnDragPos       = pHitTest->nPos;
1998*cdf0e10cSrcweir     mnDragAryPos    = pHitTest->nAryPos;
1999*cdf0e10cSrcweir     mnDragSize      = pHitTest->mnDragSize;
2000*cdf0e10cSrcweir     mnDragModifier  = nModifier;
2001*cdf0e10cSrcweir     *mpDragData     = *mpSaveData;
2002*cdf0e10cSrcweir     mpData          = mpDragData;
2003*cdf0e10cSrcweir 
2004*cdf0e10cSrcweir     // Handler rufen
2005*cdf0e10cSrcweir     if ( StartDrag() )
2006*cdf0e10cSrcweir     {
2007*cdf0e10cSrcweir         // Wenn der Handler das Draggen erlaubt, dann das Draggen
2008*cdf0e10cSrcweir         // initialisieren
2009*cdf0e10cSrcweir         ImplInvertLines();
2010*cdf0e10cSrcweir         mbDrag = sal_True;
2011*cdf0e10cSrcweir         mnStartDragPos = mnDragPos;
2012*cdf0e10cSrcweir         StartTracking();
2013*cdf0e10cSrcweir         return sal_True;
2014*cdf0e10cSrcweir     }
2015*cdf0e10cSrcweir     else
2016*cdf0e10cSrcweir     {
2017*cdf0e10cSrcweir         // Ansonsten muessen wir die Daten zuruecksetzen
2018*cdf0e10cSrcweir         meDragType      = RULER_TYPE_DONTKNOW;
2019*cdf0e10cSrcweir         mnDragPos       = 0;
2020*cdf0e10cSrcweir         mnDragAryPos    = 0;
2021*cdf0e10cSrcweir         mnDragSize      = 0;
2022*cdf0e10cSrcweir         mnDragModifier  = 0;
2023*cdf0e10cSrcweir         mpData          = mpSaveData;
2024*cdf0e10cSrcweir     }
2025*cdf0e10cSrcweir 
2026*cdf0e10cSrcweir     return sal_False;
2027*cdf0e10cSrcweir }
2028*cdf0e10cSrcweir 
2029*cdf0e10cSrcweir // -----------------------------------------------------------------------
2030*cdf0e10cSrcweir 
2031*cdf0e10cSrcweir void Ruler::ImplDrag( const Point& rPos )
2032*cdf0e10cSrcweir {
2033*cdf0e10cSrcweir     long  nX;
2034*cdf0e10cSrcweir     long  nY;
2035*cdf0e10cSrcweir     long  nOutHeight;
2036*cdf0e10cSrcweir 
2037*cdf0e10cSrcweir     if ( mnWinStyle & WB_HORZ )
2038*cdf0e10cSrcweir     {
2039*cdf0e10cSrcweir         nX          = rPos.X();
2040*cdf0e10cSrcweir         nY          = rPos.Y();
2041*cdf0e10cSrcweir         nOutHeight  = mnHeight;
2042*cdf0e10cSrcweir     }
2043*cdf0e10cSrcweir     else
2044*cdf0e10cSrcweir     {
2045*cdf0e10cSrcweir         nX          = rPos.Y();
2046*cdf0e10cSrcweir         nY          = rPos.X();
2047*cdf0e10cSrcweir         nOutHeight  = mnWidth;
2048*cdf0e10cSrcweir     }
2049*cdf0e10cSrcweir 
2050*cdf0e10cSrcweir     // X berechnen und einpassen
2051*cdf0e10cSrcweir     nX -= mnVirOff;
2052*cdf0e10cSrcweir     if ( nX < mpData->nRulVirOff )
2053*cdf0e10cSrcweir     {
2054*cdf0e10cSrcweir         nX = mpData->nRulVirOff;
2055*cdf0e10cSrcweir         mnDragScroll = RULER_SCROLL_1;
2056*cdf0e10cSrcweir     }
2057*cdf0e10cSrcweir     else if ( nX > mpData->nRulVirOff+mpData->nRulWidth )
2058*cdf0e10cSrcweir     {
2059*cdf0e10cSrcweir         nX = mpData->nRulVirOff+mpData->nRulWidth;
2060*cdf0e10cSrcweir         mnDragScroll = RULER_SCROLL_2;
2061*cdf0e10cSrcweir     }
2062*cdf0e10cSrcweir     nX -= mpData->nNullVirOff;
2063*cdf0e10cSrcweir 
2064*cdf0e10cSrcweir     // Wenn oberhalb oder links vom Lineal, dann alte Werte
2065*cdf0e10cSrcweir     mbDragDelete = sal_False;
2066*cdf0e10cSrcweir     if ( nY < 0 )
2067*cdf0e10cSrcweir     {
2068*cdf0e10cSrcweir         if ( !mbDragCanceled )
2069*cdf0e10cSrcweir         {
2070*cdf0e10cSrcweir             // Daten wiederherstellen
2071*cdf0e10cSrcweir             mbDragCanceled = sal_True;
2072*cdf0e10cSrcweir             ImplRulerData aTempData;
2073*cdf0e10cSrcweir             aTempData = *mpDragData;
2074*cdf0e10cSrcweir             *mpDragData = *mpSaveData;
2075*cdf0e10cSrcweir             mbCalc = sal_True;
2076*cdf0e10cSrcweir             mbFormat = sal_True;
2077*cdf0e10cSrcweir 
2078*cdf0e10cSrcweir             // Handler rufen
2079*cdf0e10cSrcweir             mnDragPos = mnStartDragPos;
2080*cdf0e10cSrcweir             Drag();
2081*cdf0e10cSrcweir 
2082*cdf0e10cSrcweir             // Und neu ausgeben (zeitverzoegert)
2083*cdf0e10cSrcweir /*
2084*cdf0e10cSrcweir             mnUpdateFlags |= RULER_UPDATE_DRAW;
2085*cdf0e10cSrcweir             if ( mnUpdateEvtId )
2086*cdf0e10cSrcweir                 Application::RemoveUserEvent( mnUpdateEvtId );
2087*cdf0e10cSrcweir             mnUpdateEvtId = Application::PostUserEvent( LINK( this, Ruler, ImplUpdateHdl ), NULL );
2088*cdf0e10cSrcweir */
2089*cdf0e10cSrcweir             ImplDraw();
2090*cdf0e10cSrcweir 
2091*cdf0e10cSrcweir             // Daten wieder wie vor dem Cancel herstellen
2092*cdf0e10cSrcweir             *mpDragData = aTempData;
2093*cdf0e10cSrcweir         }
2094*cdf0e10cSrcweir     }
2095*cdf0e10cSrcweir     else
2096*cdf0e10cSrcweir     {
2097*cdf0e10cSrcweir         mbDragCanceled = sal_False;
2098*cdf0e10cSrcweir 
2099*cdf0e10cSrcweir         // +2, damit nicht so schnell die Tabs geloescht werden
2100*cdf0e10cSrcweir         if ( nY > nOutHeight+2 )
2101*cdf0e10cSrcweir             mbDragDelete = sal_True;
2102*cdf0e10cSrcweir 
2103*cdf0e10cSrcweir         mnDragPos = nX;
2104*cdf0e10cSrcweir 
2105*cdf0e10cSrcweir         // Handler rufen
2106*cdf0e10cSrcweir         Drag();
2107*cdf0e10cSrcweir 
2108*cdf0e10cSrcweir         // Und neu ausgeben
2109*cdf0e10cSrcweir         if ( mbFormat )
2110*cdf0e10cSrcweir             ImplDraw();
2111*cdf0e10cSrcweir     }
2112*cdf0e10cSrcweir 
2113*cdf0e10cSrcweir     mnDragScroll = 0;
2114*cdf0e10cSrcweir }
2115*cdf0e10cSrcweir 
2116*cdf0e10cSrcweir // -----------------------------------------------------------------------
2117*cdf0e10cSrcweir 
2118*cdf0e10cSrcweir void Ruler::ImplEndDrag()
2119*cdf0e10cSrcweir {
2120*cdf0e10cSrcweir     // Werte uebernehmen
2121*cdf0e10cSrcweir     if ( mbDragCanceled )
2122*cdf0e10cSrcweir         *mpDragData = *mpSaveData;
2123*cdf0e10cSrcweir     else
2124*cdf0e10cSrcweir         *mpSaveData = *mpDragData;
2125*cdf0e10cSrcweir     mpData = mpSaveData;
2126*cdf0e10cSrcweir     mbDrag = sal_False;
2127*cdf0e10cSrcweir 
2128*cdf0e10cSrcweir     // Handler rufen
2129*cdf0e10cSrcweir     EndDrag();
2130*cdf0e10cSrcweir 
2131*cdf0e10cSrcweir     // Drag-Werte zuruecksetzen
2132*cdf0e10cSrcweir     meDragType      = RULER_TYPE_DONTKNOW;
2133*cdf0e10cSrcweir     mnDragPos       = 0;
2134*cdf0e10cSrcweir     mnDragAryPos    = 0;
2135*cdf0e10cSrcweir     mnDragSize      = 0;
2136*cdf0e10cSrcweir     mbDragCanceled  = sal_False;
2137*cdf0e10cSrcweir     mbDragDelete    = sal_False;
2138*cdf0e10cSrcweir     mnDragModifier  = 0;
2139*cdf0e10cSrcweir     mnDragScroll    = 0;
2140*cdf0e10cSrcweir     mnStartDragPos  = 0;
2141*cdf0e10cSrcweir 
2142*cdf0e10cSrcweir     // Und neu ausgeben
2143*cdf0e10cSrcweir     ImplDraw();
2144*cdf0e10cSrcweir }
2145*cdf0e10cSrcweir 
2146*cdf0e10cSrcweir // -----------------------------------------------------------------------
2147*cdf0e10cSrcweir 
2148*cdf0e10cSrcweir IMPL_LINK( Ruler, ImplUpdateHdl, void*, EMPTYARG )
2149*cdf0e10cSrcweir {
2150*cdf0e10cSrcweir     mnUpdateEvtId = 0;
2151*cdf0e10cSrcweir 
2152*cdf0e10cSrcweir     // Feststellen, was upgedatet werden muss
2153*cdf0e10cSrcweir     if ( mnUpdateFlags & RULER_UPDATE_DRAW )
2154*cdf0e10cSrcweir     {
2155*cdf0e10cSrcweir         mnUpdateFlags = 0;
2156*cdf0e10cSrcweir         ImplDraw();
2157*cdf0e10cSrcweir     }
2158*cdf0e10cSrcweir     else if ( mnUpdateFlags & RULER_UPDATE_LINES )
2159*cdf0e10cSrcweir     {
2160*cdf0e10cSrcweir         mnUpdateFlags = 0;
2161*cdf0e10cSrcweir         ImplInvertLines();
2162*cdf0e10cSrcweir     }
2163*cdf0e10cSrcweir 
2164*cdf0e10cSrcweir     return 0;
2165*cdf0e10cSrcweir }
2166*cdf0e10cSrcweir 
2167*cdf0e10cSrcweir // -----------------------------------------------------------------------
2168*cdf0e10cSrcweir 
2169*cdf0e10cSrcweir void Ruler::MouseButtonDown( const MouseEvent& rMEvt )
2170*cdf0e10cSrcweir {
2171*cdf0e10cSrcweir     if ( rMEvt.IsLeft() && !IsTracking() )
2172*cdf0e10cSrcweir     {
2173*cdf0e10cSrcweir         Point   aMousePos = rMEvt.GetPosPixel();
2174*cdf0e10cSrcweir         sal_uInt16  nMouseClicks = rMEvt.GetClicks();
2175*cdf0e10cSrcweir         sal_uInt16  nMouseModifier = rMEvt.GetModifier();
2176*cdf0e10cSrcweir 
2177*cdf0e10cSrcweir         // Gegebenenfalls Lineal updaten (damit mit den richtigen Daten
2178*cdf0e10cSrcweir         // gearbeitet wird und die Anzeige auch zur Bearbeitung passt)
2179*cdf0e10cSrcweir         if ( mbFormat )
2180*cdf0e10cSrcweir         {
2181*cdf0e10cSrcweir             ImplDraw();
2182*cdf0e10cSrcweir             mnUpdateFlags &= ~RULER_UPDATE_DRAW;
2183*cdf0e10cSrcweir         }
2184*cdf0e10cSrcweir 
2185*cdf0e10cSrcweir         if ( maExtraRect.IsInside( aMousePos ) )
2186*cdf0e10cSrcweir         {
2187*cdf0e10cSrcweir             mnExtraClicks = nMouseClicks;
2188*cdf0e10cSrcweir             mnExtraModifier = nMouseModifier;
2189*cdf0e10cSrcweir             ExtraDown();
2190*cdf0e10cSrcweir             mnExtraClicks = 0;
2191*cdf0e10cSrcweir             mnExtraModifier = 0;
2192*cdf0e10cSrcweir         }
2193*cdf0e10cSrcweir         else
2194*cdf0e10cSrcweir         {
2195*cdf0e10cSrcweir             ImplRulerHitTest aHitTest;
2196*cdf0e10cSrcweir 
2197*cdf0e10cSrcweir             if ( nMouseClicks == 1 )
2198*cdf0e10cSrcweir             {
2199*cdf0e10cSrcweir                 if ( ImplHitTest( aMousePos, &aHitTest ) )
2200*cdf0e10cSrcweir                     ImplStartDrag( &aHitTest, nMouseModifier );
2201*cdf0e10cSrcweir                 else
2202*cdf0e10cSrcweir                 {
2203*cdf0e10cSrcweir                     // Position innerhalb des Lineal-Bereiches
2204*cdf0e10cSrcweir                     if ( aHitTest.eType == RULER_TYPE_DONTKNOW )
2205*cdf0e10cSrcweir                     {
2206*cdf0e10cSrcweir                         mnDragPos = aHitTest.nPos;
2207*cdf0e10cSrcweir                         Click();
2208*cdf0e10cSrcweir                         mnDragPos = 0;
2209*cdf0e10cSrcweir 
2210*cdf0e10cSrcweir                         // Nocheinmal HitTest durchfuehren, da durch den Click
2211*cdf0e10cSrcweir                         // zum Beispiel ein neuer Tab gesetzt werden konnte
2212*cdf0e10cSrcweir                         if ( ImplHitTest( aMousePos, &aHitTest ) )
2213*cdf0e10cSrcweir                             ImplStartDrag( &aHitTest, nMouseModifier );
2214*cdf0e10cSrcweir                     }
2215*cdf0e10cSrcweir                 }
2216*cdf0e10cSrcweir             }
2217*cdf0e10cSrcweir             else
2218*cdf0e10cSrcweir             {
2219*cdf0e10cSrcweir                 if ( ImplHitTest( aMousePos, &aHitTest ) )
2220*cdf0e10cSrcweir                 {
2221*cdf0e10cSrcweir                     mnDragPos    = aHitTest.nPos;
2222*cdf0e10cSrcweir                     mnDragAryPos = aHitTest.nAryPos;
2223*cdf0e10cSrcweir                 }
2224*cdf0e10cSrcweir                 meDragType = aHitTest.eType;
2225*cdf0e10cSrcweir 
2226*cdf0e10cSrcweir                 DoubleClick();
2227*cdf0e10cSrcweir 
2228*cdf0e10cSrcweir                 meDragType      = RULER_TYPE_DONTKNOW;
2229*cdf0e10cSrcweir                 mnDragPos       = 0;
2230*cdf0e10cSrcweir                 mnDragAryPos    = 0;
2231*cdf0e10cSrcweir             }
2232*cdf0e10cSrcweir         }
2233*cdf0e10cSrcweir     }
2234*cdf0e10cSrcweir }
2235*cdf0e10cSrcweir 
2236*cdf0e10cSrcweir // -----------------------------------------------------------------------
2237*cdf0e10cSrcweir 
2238*cdf0e10cSrcweir void Ruler::MouseMove( const MouseEvent& rMEvt )
2239*cdf0e10cSrcweir {
2240*cdf0e10cSrcweir     PointerStyle ePtrStyle = POINTER_ARROW;
2241*cdf0e10cSrcweir 
2242*cdf0e10cSrcweir     // Gegebenenfalls Lineal updaten (damit mit den richtigen Daten
2243*cdf0e10cSrcweir     // gearbeitet wird und die Anzeige auch zur Bearbeitung passt)
2244*cdf0e10cSrcweir     if ( mbFormat )
2245*cdf0e10cSrcweir     {
2246*cdf0e10cSrcweir         ImplDraw();
2247*cdf0e10cSrcweir         mnUpdateFlags &= ~RULER_UPDATE_DRAW;
2248*cdf0e10cSrcweir     }
2249*cdf0e10cSrcweir 
2250*cdf0e10cSrcweir     ImplRulerHitTest aHitTest;
2251*cdf0e10cSrcweir     if ( ImplHitTest( rMEvt.GetPosPixel(), &aHitTest ) )
2252*cdf0e10cSrcweir     {
2253*cdf0e10cSrcweir         if ( aHitTest.bSize )
2254*cdf0e10cSrcweir         {
2255*cdf0e10cSrcweir             if ( mnWinStyle & WB_HORZ )
2256*cdf0e10cSrcweir                 ePtrStyle = POINTER_ESIZE;
2257*cdf0e10cSrcweir             else
2258*cdf0e10cSrcweir                 ePtrStyle = POINTER_SSIZE;
2259*cdf0e10cSrcweir         }
2260*cdf0e10cSrcweir         else if ( aHitTest.bSizeBar )
2261*cdf0e10cSrcweir         {
2262*cdf0e10cSrcweir             if ( mnWinStyle & WB_HORZ )
2263*cdf0e10cSrcweir                 ePtrStyle = POINTER_HSIZEBAR;
2264*cdf0e10cSrcweir             else
2265*cdf0e10cSrcweir                 ePtrStyle = POINTER_VSIZEBAR;
2266*cdf0e10cSrcweir         }
2267*cdf0e10cSrcweir     }
2268*cdf0e10cSrcweir 
2269*cdf0e10cSrcweir     SetPointer( Pointer( ePtrStyle ) );
2270*cdf0e10cSrcweir }
2271*cdf0e10cSrcweir 
2272*cdf0e10cSrcweir // -----------------------------------------------------------------------
2273*cdf0e10cSrcweir 
2274*cdf0e10cSrcweir void Ruler::Tracking( const TrackingEvent& rTEvt )
2275*cdf0e10cSrcweir {
2276*cdf0e10cSrcweir     if ( rTEvt.IsTrackingEnded() )
2277*cdf0e10cSrcweir     {
2278*cdf0e10cSrcweir         // Bei Abbruch, den alten Status wieder herstellen
2279*cdf0e10cSrcweir         if ( rTEvt.IsTrackingCanceled() )
2280*cdf0e10cSrcweir         {
2281*cdf0e10cSrcweir             mbDragCanceled = sal_True;
2282*cdf0e10cSrcweir             mbFormat       = sal_True;
2283*cdf0e10cSrcweir         }
2284*cdf0e10cSrcweir 
2285*cdf0e10cSrcweir         ImplEndDrag();
2286*cdf0e10cSrcweir     }
2287*cdf0e10cSrcweir     else
2288*cdf0e10cSrcweir         ImplDrag( rTEvt.GetMouseEvent().GetPosPixel() );
2289*cdf0e10cSrcweir }
2290*cdf0e10cSrcweir 
2291*cdf0e10cSrcweir // -----------------------------------------------------------------------
2292*cdf0e10cSrcweir 
2293*cdf0e10cSrcweir void Ruler::Paint( const Rectangle& )
2294*cdf0e10cSrcweir {
2295*cdf0e10cSrcweir     ImplDraw();
2296*cdf0e10cSrcweir 
2297*cdf0e10cSrcweir     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
2298*cdf0e10cSrcweir 
2299*cdf0e10cSrcweir     // Extra-Field beruecksichtigen
2300*cdf0e10cSrcweir     if ( mnWinStyle & WB_EXTRAFIELD )
2301*cdf0e10cSrcweir     {
2302*cdf0e10cSrcweir         if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
2303*cdf0e10cSrcweir         {
2304*cdf0e10cSrcweir             SetLineColor( rStyleSettings.GetShadowColor() );
2305*cdf0e10cSrcweir             DrawLine( Point( maExtraRect.Left(), maExtraRect.Top() ),
2306*cdf0e10cSrcweir                       Point( maExtraRect.Right()-1, maExtraRect.Top() ) );
2307*cdf0e10cSrcweir             DrawLine( Point( maExtraRect.Left(), maExtraRect.Top() ),
2308*cdf0e10cSrcweir                       Point( maExtraRect.Left(), maExtraRect.Bottom()-1 ) );
2309*cdf0e10cSrcweir             DrawLine( Point( maExtraRect.Left(), maExtraRect.Bottom()-1 ),
2310*cdf0e10cSrcweir                       Point( maExtraRect.Right()-1, maExtraRect.Bottom()-1 ) );
2311*cdf0e10cSrcweir             DrawLine( Point( maExtraRect.Right()-1, maExtraRect.Top() ),
2312*cdf0e10cSrcweir                       Point( maExtraRect.Right()-1, maExtraRect.Bottom()-1 ) );
2313*cdf0e10cSrcweir             SetLineColor( rStyleSettings.GetLightColor() );
2314*cdf0e10cSrcweir             DrawLine( Point( maExtraRect.Left()+1, maExtraRect.Top()+1 ),
2315*cdf0e10cSrcweir                       Point( maExtraRect.Right()-2, maExtraRect.Top()+1 ) );
2316*cdf0e10cSrcweir             DrawLine( Point( maExtraRect.Left()+1, maExtraRect.Top()+1 ),
2317*cdf0e10cSrcweir                       Point( maExtraRect.Left()+1, maExtraRect.Bottom()-2 ) );
2318*cdf0e10cSrcweir             DrawLine( Point( maExtraRect.Left(), maExtraRect.Bottom() ),
2319*cdf0e10cSrcweir                       Point( maExtraRect.Right(), maExtraRect.Bottom() ) );
2320*cdf0e10cSrcweir             DrawLine( Point( maExtraRect.Right(), maExtraRect.Top() ),
2321*cdf0e10cSrcweir                       Point( maExtraRect.Right(), maExtraRect.Bottom() ) );
2322*cdf0e10cSrcweir         }
2323*cdf0e10cSrcweir         else
2324*cdf0e10cSrcweir         {
2325*cdf0e10cSrcweir             SetLineColor( rStyleSettings.GetWindowTextColor() );
2326*cdf0e10cSrcweir             SetFillColor( rStyleSettings.GetWindowColor() );
2327*cdf0e10cSrcweir             DrawRect( maExtraRect );
2328*cdf0e10cSrcweir         }
2329*cdf0e10cSrcweir 
2330*cdf0e10cSrcweir         // Imhalt vom Extrafeld ausgeben
2331*cdf0e10cSrcweir         ImplDrawExtra( sal_True );
2332*cdf0e10cSrcweir     }
2333*cdf0e10cSrcweir 
2334*cdf0e10cSrcweir     if ( mnWinStyle & WB_BORDER )
2335*cdf0e10cSrcweir     {
2336*cdf0e10cSrcweir         if ( mnWinStyle & WB_HORZ )
2337*cdf0e10cSrcweir         {
2338*cdf0e10cSrcweir             if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
2339*cdf0e10cSrcweir             {
2340*cdf0e10cSrcweir                 SetLineColor( rStyleSettings.GetShadowColor() );
2341*cdf0e10cSrcweir                 DrawLine( Point( mnBorderOff, mnHeight-2 ),
2342*cdf0e10cSrcweir                           Point( mnWidth, mnHeight-2 ) );
2343*cdf0e10cSrcweir                 if ( mnBorderOff )
2344*cdf0e10cSrcweir                 {
2345*cdf0e10cSrcweir                     DrawLine( Point( mnBorderOff-1, mnHeight-2 ),
2346*cdf0e10cSrcweir                               Point( mnBorderOff-1, mnHeight-1 ) );
2347*cdf0e10cSrcweir                 }
2348*cdf0e10cSrcweir             }
2349*cdf0e10cSrcweir             SetLineColor( rStyleSettings.GetWindowTextColor() );
2350*cdf0e10cSrcweir             DrawLine( Point( mnBorderOff, mnHeight-1 ),
2351*cdf0e10cSrcweir                       Point( mnWidth, mnHeight-1 ) );
2352*cdf0e10cSrcweir         }
2353*cdf0e10cSrcweir         else
2354*cdf0e10cSrcweir         {
2355*cdf0e10cSrcweir             if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
2356*cdf0e10cSrcweir             {
2357*cdf0e10cSrcweir                 SetLineColor( rStyleSettings.GetShadowColor() );
2358*cdf0e10cSrcweir                 DrawLine( Point( mnWidth-2, mnBorderOff ),
2359*cdf0e10cSrcweir                           Point( mnWidth-2, mnHeight ) );
2360*cdf0e10cSrcweir                 if ( mnBorderOff )
2361*cdf0e10cSrcweir                 {
2362*cdf0e10cSrcweir                     DrawLine( Point( mnWidth-2, mnBorderOff-1 ),
2363*cdf0e10cSrcweir                               Point( mnWidth-1, mnBorderOff-1 ) );
2364*cdf0e10cSrcweir                 }
2365*cdf0e10cSrcweir             }
2366*cdf0e10cSrcweir             SetLineColor( rStyleSettings.GetWindowTextColor() );
2367*cdf0e10cSrcweir             DrawLine( Point( mnWidth-1, mnBorderOff ),
2368*cdf0e10cSrcweir                       Point( mnWidth-1, mnHeight ) );
2369*cdf0e10cSrcweir         }
2370*cdf0e10cSrcweir     }
2371*cdf0e10cSrcweir }
2372*cdf0e10cSrcweir 
2373*cdf0e10cSrcweir // -----------------------------------------------------------------------
2374*cdf0e10cSrcweir 
2375*cdf0e10cSrcweir void Ruler::Resize()
2376*cdf0e10cSrcweir {
2377*cdf0e10cSrcweir     Size aWinSize = GetOutputSizePixel();
2378*cdf0e10cSrcweir 
2379*cdf0e10cSrcweir     long nNewHeight;
2380*cdf0e10cSrcweir     if ( mnWinStyle & WB_HORZ )
2381*cdf0e10cSrcweir     {
2382*cdf0e10cSrcweir         if ( aWinSize.Height() != mnHeight )
2383*cdf0e10cSrcweir             nNewHeight = aWinSize.Height();
2384*cdf0e10cSrcweir         else
2385*cdf0e10cSrcweir             nNewHeight = 0;
2386*cdf0e10cSrcweir     }
2387*cdf0e10cSrcweir     else
2388*cdf0e10cSrcweir     {
2389*cdf0e10cSrcweir         if ( aWinSize.Width() != mnWidth )
2390*cdf0e10cSrcweir             nNewHeight = aWinSize.Width();
2391*cdf0e10cSrcweir         else
2392*cdf0e10cSrcweir             nNewHeight = 0;
2393*cdf0e10cSrcweir     }
2394*cdf0e10cSrcweir 
2395*cdf0e10cSrcweir     // Hier schon Linien loeschen
2396*cdf0e10cSrcweir     sal_Bool bVisible = IsReallyVisible();
2397*cdf0e10cSrcweir     if ( bVisible && mpData->nLines )
2398*cdf0e10cSrcweir     {
2399*cdf0e10cSrcweir         ImplInvertLines();
2400*cdf0e10cSrcweir         mnUpdateFlags |= RULER_UPDATE_LINES;
2401*cdf0e10cSrcweir         if ( !mnUpdateEvtId )
2402*cdf0e10cSrcweir             mnUpdateEvtId = Application::PostUserEvent( LINK( this, Ruler, ImplUpdateHdl ), NULL );
2403*cdf0e10cSrcweir     }
2404*cdf0e10cSrcweir     mbFormat = sal_True;
2405*cdf0e10cSrcweir 
2406*cdf0e10cSrcweir     // Wenn sich die Hoehe bzw. Breite aendert, dann muessen besimmte Werte
2407*cdf0e10cSrcweir     // neu berechnet werden
2408*cdf0e10cSrcweir     //extra field should always be updated
2409*cdf0e10cSrcweir     ImplInitExtraField( mpData->bTextRTL );
2410*cdf0e10cSrcweir     if ( nNewHeight )
2411*cdf0e10cSrcweir     {
2412*cdf0e10cSrcweir         mbCalc = sal_True;
2413*cdf0e10cSrcweir         mnVirHeight = nNewHeight - mnBorderWidth - (RULER_OFF*2);
2414*cdf0e10cSrcweir     }
2415*cdf0e10cSrcweir     else
2416*cdf0e10cSrcweir     {
2417*cdf0e10cSrcweir         if ( mpData->bAutoPageWidth )
2418*cdf0e10cSrcweir             ImplUpdate( sal_True );
2419*cdf0e10cSrcweir         else if ( mbAutoWinWidth )
2420*cdf0e10cSrcweir             mbCalc = sal_True;
2421*cdf0e10cSrcweir     }
2422*cdf0e10cSrcweir 
2423*cdf0e10cSrcweir     // Wenn Ruler eine Groesse hat, dann Groesse vom VirtualDevice setzen
2424*cdf0e10cSrcweir     if ( (mnVirWidth > RULER_MIN_SIZE) ||
2425*cdf0e10cSrcweir          ((aWinSize.Width() > RULER_MIN_SIZE) && (aWinSize.Height() > RULER_MIN_SIZE)) )
2426*cdf0e10cSrcweir     {
2427*cdf0e10cSrcweir         if ( mnWinStyle & WB_HORZ )
2428*cdf0e10cSrcweir             mnVirWidth = aWinSize.Width()-mnVirOff;
2429*cdf0e10cSrcweir         else
2430*cdf0e10cSrcweir             mnVirWidth = aWinSize.Height()-mnVirOff;
2431*cdf0e10cSrcweir         if ( mnVirWidth < RULER_MIN_SIZE )
2432*cdf0e10cSrcweir             mnVirWidth = 0;
2433*cdf0e10cSrcweir     }
2434*cdf0e10cSrcweir 
2435*cdf0e10cSrcweir     // Gegebenenfalls ein Teil vom Rand loeschen, da 3D-Effekt/Trennlinie am
2436*cdf0e10cSrcweir     // Fensterrand
2437*cdf0e10cSrcweir     if ( bVisible )
2438*cdf0e10cSrcweir     {
2439*cdf0e10cSrcweir         if ( nNewHeight )
2440*cdf0e10cSrcweir             Invalidate();
2441*cdf0e10cSrcweir         else if ( mpData->bAutoPageWidth )
2442*cdf0e10cSrcweir         {
2443*cdf0e10cSrcweir             // Nur bei AutoPageWidth haben wir rechts einen 3D-Effekt,
2444*cdf0e10cSrcweir             // der sich der Fensterbreite anpasst und deshalb neu gezeichnet
2445*cdf0e10cSrcweir             // werden muss
2446*cdf0e10cSrcweir             Rectangle aRect;
2447*cdf0e10cSrcweir 
2448*cdf0e10cSrcweir             if ( mnWinStyle & WB_HORZ )
2449*cdf0e10cSrcweir             {
2450*cdf0e10cSrcweir                 if ( mnWidth < aWinSize.Width() )
2451*cdf0e10cSrcweir                     aRect.Left() = mnWidth-RULER_RESIZE_OFF;
2452*cdf0e10cSrcweir                 else
2453*cdf0e10cSrcweir                     aRect.Left() = aWinSize.Width()-RULER_RESIZE_OFF;
2454*cdf0e10cSrcweir                 aRect.Right()   = aRect.Left()+RULER_RESIZE_OFF;
2455*cdf0e10cSrcweir                 aRect.Top()     = RULER_OFF;
2456*cdf0e10cSrcweir                 aRect.Bottom()  = RULER_OFF+mnVirHeight;
2457*cdf0e10cSrcweir             }
2458*cdf0e10cSrcweir             else
2459*cdf0e10cSrcweir             {
2460*cdf0e10cSrcweir                 if ( mnHeight < aWinSize.Height() )
2461*cdf0e10cSrcweir                     aRect.Top() = mnHeight-RULER_RESIZE_OFF;
2462*cdf0e10cSrcweir                 else
2463*cdf0e10cSrcweir                     aRect.Top() = aWinSize.Height()-RULER_RESIZE_OFF;
2464*cdf0e10cSrcweir                 aRect.Bottom() = aRect.Top()+RULER_RESIZE_OFF;
2465*cdf0e10cSrcweir                 aRect.Left()    = RULER_OFF;
2466*cdf0e10cSrcweir                 aRect.Right()   = RULER_OFF+mnVirHeight;
2467*cdf0e10cSrcweir             }
2468*cdf0e10cSrcweir 
2469*cdf0e10cSrcweir             Invalidate( aRect );
2470*cdf0e10cSrcweir         }
2471*cdf0e10cSrcweir     }
2472*cdf0e10cSrcweir 
2473*cdf0e10cSrcweir     // Neue Groesse merken
2474*cdf0e10cSrcweir     mnWidth  = aWinSize.Width();
2475*cdf0e10cSrcweir     mnHeight = aWinSize.Height();
2476*cdf0e10cSrcweir }
2477*cdf0e10cSrcweir 
2478*cdf0e10cSrcweir // -----------------------------------------------------------------------
2479*cdf0e10cSrcweir 
2480*cdf0e10cSrcweir void Ruler::StateChanged( StateChangedType nType )
2481*cdf0e10cSrcweir {
2482*cdf0e10cSrcweir     Window::StateChanged( nType );
2483*cdf0e10cSrcweir 
2484*cdf0e10cSrcweir     if ( nType == STATE_CHANGE_INITSHOW )
2485*cdf0e10cSrcweir         ImplFormat();
2486*cdf0e10cSrcweir     else if ( nType == STATE_CHANGE_UPDATEMODE )
2487*cdf0e10cSrcweir     {
2488*cdf0e10cSrcweir         if ( IsReallyVisible() && IsUpdateMode() )
2489*cdf0e10cSrcweir             ImplDraw();
2490*cdf0e10cSrcweir     }
2491*cdf0e10cSrcweir     else if ( (nType == STATE_CHANGE_ZOOM) ||
2492*cdf0e10cSrcweir               (nType == STATE_CHANGE_CONTROLFONT) )
2493*cdf0e10cSrcweir     {
2494*cdf0e10cSrcweir         ImplInitSettings( sal_True, sal_False, sal_False );
2495*cdf0e10cSrcweir         Invalidate();
2496*cdf0e10cSrcweir     }
2497*cdf0e10cSrcweir     else if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
2498*cdf0e10cSrcweir     {
2499*cdf0e10cSrcweir         ImplInitSettings( sal_False, sal_True, sal_False );
2500*cdf0e10cSrcweir         Invalidate();
2501*cdf0e10cSrcweir     }
2502*cdf0e10cSrcweir     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
2503*cdf0e10cSrcweir     {
2504*cdf0e10cSrcweir         ImplInitSettings( sal_False, sal_False, sal_True );
2505*cdf0e10cSrcweir         Invalidate();
2506*cdf0e10cSrcweir     }
2507*cdf0e10cSrcweir }
2508*cdf0e10cSrcweir 
2509*cdf0e10cSrcweir // -----------------------------------------------------------------------
2510*cdf0e10cSrcweir 
2511*cdf0e10cSrcweir void Ruler::DataChanged( const DataChangedEvent& rDCEvt )
2512*cdf0e10cSrcweir {
2513*cdf0e10cSrcweir     Window::DataChanged( rDCEvt );
2514*cdf0e10cSrcweir 
2515*cdf0e10cSrcweir     if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
2516*cdf0e10cSrcweir          (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
2517*cdf0e10cSrcweir          (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
2518*cdf0e10cSrcweir          ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
2519*cdf0e10cSrcweir           (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
2520*cdf0e10cSrcweir     {
2521*cdf0e10cSrcweir         mbFormat = sal_True;
2522*cdf0e10cSrcweir         ImplInitSettings( sal_True, sal_True, sal_True );
2523*cdf0e10cSrcweir         Invalidate();
2524*cdf0e10cSrcweir     }
2525*cdf0e10cSrcweir }
2526*cdf0e10cSrcweir 
2527*cdf0e10cSrcweir // -----------------------------------------------------------------------
2528*cdf0e10cSrcweir 
2529*cdf0e10cSrcweir long Ruler::StartDrag()
2530*cdf0e10cSrcweir {
2531*cdf0e10cSrcweir     if ( maStartDragHdl.IsSet() )
2532*cdf0e10cSrcweir         return maStartDragHdl.Call( this );
2533*cdf0e10cSrcweir     else
2534*cdf0e10cSrcweir         return sal_False;
2535*cdf0e10cSrcweir }
2536*cdf0e10cSrcweir 
2537*cdf0e10cSrcweir // -----------------------------------------------------------------------
2538*cdf0e10cSrcweir 
2539*cdf0e10cSrcweir void Ruler::Drag()
2540*cdf0e10cSrcweir {
2541*cdf0e10cSrcweir     maDragHdl.Call( this );
2542*cdf0e10cSrcweir }
2543*cdf0e10cSrcweir 
2544*cdf0e10cSrcweir // -----------------------------------------------------------------------
2545*cdf0e10cSrcweir 
2546*cdf0e10cSrcweir void Ruler::EndDrag()
2547*cdf0e10cSrcweir {
2548*cdf0e10cSrcweir     maEndDragHdl.Call( this );
2549*cdf0e10cSrcweir }
2550*cdf0e10cSrcweir 
2551*cdf0e10cSrcweir // -----------------------------------------------------------------------
2552*cdf0e10cSrcweir 
2553*cdf0e10cSrcweir void Ruler::Click()
2554*cdf0e10cSrcweir {
2555*cdf0e10cSrcweir     maClickHdl.Call( this );
2556*cdf0e10cSrcweir }
2557*cdf0e10cSrcweir 
2558*cdf0e10cSrcweir // -----------------------------------------------------------------------
2559*cdf0e10cSrcweir 
2560*cdf0e10cSrcweir void Ruler::DoubleClick()
2561*cdf0e10cSrcweir {
2562*cdf0e10cSrcweir     maDoubleClickHdl.Call( this );
2563*cdf0e10cSrcweir }
2564*cdf0e10cSrcweir 
2565*cdf0e10cSrcweir // -----------------------------------------------------------------------
2566*cdf0e10cSrcweir 
2567*cdf0e10cSrcweir void Ruler::ExtraDown()
2568*cdf0e10cSrcweir {
2569*cdf0e10cSrcweir     maExtraDownHdl.Call( this );
2570*cdf0e10cSrcweir }
2571*cdf0e10cSrcweir 
2572*cdf0e10cSrcweir // -----------------------------------------------------------------------
2573*cdf0e10cSrcweir 
2574*cdf0e10cSrcweir void Ruler::Activate()
2575*cdf0e10cSrcweir {
2576*cdf0e10cSrcweir     mbActive = sal_True;
2577*cdf0e10cSrcweir 
2578*cdf0e10cSrcweir     // Positionslinien wieder anzeigen (erst hinter mbActive=sal_True rufen, da
2579*cdf0e10cSrcweir     // von ImplInvertLines() ausgewertet wird). Das Zeichnen der Linien
2580*cdf0e10cSrcweir     // wird verzoegert, damit im vermutlich noch nicht gepainteten Zustand
2581*cdf0e10cSrcweir     // Linien gezeichnet werden.
2582*cdf0e10cSrcweir     mnUpdateFlags |= RULER_UPDATE_LINES;
2583*cdf0e10cSrcweir     if ( !mnUpdateEvtId )
2584*cdf0e10cSrcweir         mnUpdateEvtId = Application::PostUserEvent( LINK( this, Ruler, ImplUpdateHdl ), NULL );
2585*cdf0e10cSrcweir }
2586*cdf0e10cSrcweir 
2587*cdf0e10cSrcweir // -----------------------------------------------------------------------
2588*cdf0e10cSrcweir 
2589*cdf0e10cSrcweir void Ruler::Deactivate()
2590*cdf0e10cSrcweir {
2591*cdf0e10cSrcweir     // Positionslinien loeschen (schon vor mbActive=sal_False rufen, da
2592*cdf0e10cSrcweir     // von ImplInvertLines() ausgewertet wird)
2593*cdf0e10cSrcweir     ImplInvertLines();
2594*cdf0e10cSrcweir 
2595*cdf0e10cSrcweir     mbActive = sal_False;
2596*cdf0e10cSrcweir }
2597*cdf0e10cSrcweir 
2598*cdf0e10cSrcweir // -----------------------------------------------------------------------
2599*cdf0e10cSrcweir 
2600*cdf0e10cSrcweir sal_Bool Ruler::StartDocDrag( const MouseEvent& rMEvt, RulerType eDragType )
2601*cdf0e10cSrcweir {
2602*cdf0e10cSrcweir     if ( !mbDrag )
2603*cdf0e10cSrcweir     {
2604*cdf0e10cSrcweir         Point               aMousePos = rMEvt.GetPosPixel();
2605*cdf0e10cSrcweir         sal_uInt16              nMouseClicks = rMEvt.GetClicks();
2606*cdf0e10cSrcweir         sal_uInt16              nMouseModifier = rMEvt.GetModifier();
2607*cdf0e10cSrcweir         ImplRulerHitTest    aHitTest;
2608*cdf0e10cSrcweir         if(eDragType != RULER_TYPE_DONTKNOW)
2609*cdf0e10cSrcweir             aHitTest.bExpandTest = sal_True;
2610*cdf0e10cSrcweir 
2611*cdf0e10cSrcweir         // Gegebenenfalls Lineal updaten (damit mit den richtigen Daten
2612*cdf0e10cSrcweir         // gearbeitet wird und die Anzeige auch zur Bearbeitung passt)
2613*cdf0e10cSrcweir         if ( mbFormat )
2614*cdf0e10cSrcweir         {
2615*cdf0e10cSrcweir             ImplDraw();
2616*cdf0e10cSrcweir             mnUpdateFlags &= ~RULER_UPDATE_DRAW;
2617*cdf0e10cSrcweir         }
2618*cdf0e10cSrcweir 
2619*cdf0e10cSrcweir         if ( nMouseClicks == 1 )
2620*cdf0e10cSrcweir         {
2621*cdf0e10cSrcweir             if ( ImplDocHitTest( aMousePos, eDragType, &aHitTest ) )
2622*cdf0e10cSrcweir             {
2623*cdf0e10cSrcweir                 Pointer aPtr;
2624*cdf0e10cSrcweir 
2625*cdf0e10cSrcweir                 if ( aHitTest.bSize )
2626*cdf0e10cSrcweir                 {
2627*cdf0e10cSrcweir                     if ( mnWinStyle & WB_HORZ )
2628*cdf0e10cSrcweir                         aPtr = Pointer( POINTER_ESIZE );
2629*cdf0e10cSrcweir                     else
2630*cdf0e10cSrcweir                         aPtr = Pointer( POINTER_SSIZE );
2631*cdf0e10cSrcweir                 }
2632*cdf0e10cSrcweir                 else if ( aHitTest.bSizeBar )
2633*cdf0e10cSrcweir                 {
2634*cdf0e10cSrcweir                     if ( mnWinStyle & WB_HORZ )
2635*cdf0e10cSrcweir                         aPtr = Pointer( POINTER_HSIZEBAR );
2636*cdf0e10cSrcweir                     else
2637*cdf0e10cSrcweir                         aPtr = Pointer( POINTER_VSIZEBAR );
2638*cdf0e10cSrcweir                 }
2639*cdf0e10cSrcweir                 SetPointer( aPtr );
2640*cdf0e10cSrcweir                 return ImplStartDrag( &aHitTest, nMouseModifier );
2641*cdf0e10cSrcweir             }
2642*cdf0e10cSrcweir         }
2643*cdf0e10cSrcweir         else if ( nMouseClicks == 2 )
2644*cdf0e10cSrcweir         {
2645*cdf0e10cSrcweir             if ( ImplDocHitTest( aMousePos, eDragType, &aHitTest ) )
2646*cdf0e10cSrcweir             {
2647*cdf0e10cSrcweir                 mnDragPos    = aHitTest.nPos;
2648*cdf0e10cSrcweir                 mnDragAryPos = aHitTest.nAryPos;
2649*cdf0e10cSrcweir             }
2650*cdf0e10cSrcweir             eDragType = aHitTest.eType;
2651*cdf0e10cSrcweir 
2652*cdf0e10cSrcweir             DoubleClick();
2653*cdf0e10cSrcweir 
2654*cdf0e10cSrcweir             eDragType       = RULER_TYPE_DONTKNOW;
2655*cdf0e10cSrcweir             mnDragPos       = 0;
2656*cdf0e10cSrcweir             mnDragAryPos    = 0;
2657*cdf0e10cSrcweir 
2658*cdf0e10cSrcweir             return sal_True;
2659*cdf0e10cSrcweir         }
2660*cdf0e10cSrcweir     }
2661*cdf0e10cSrcweir 
2662*cdf0e10cSrcweir     return sal_False;
2663*cdf0e10cSrcweir }
2664*cdf0e10cSrcweir 
2665*cdf0e10cSrcweir // -----------------------------------------------------------------------
2666*cdf0e10cSrcweir 
2667*cdf0e10cSrcweir RulerType Ruler::GetDocType( const Point& rPos, RulerType eDragType,
2668*cdf0e10cSrcweir                              sal_uInt16* pAryPos ) const
2669*cdf0e10cSrcweir {
2670*cdf0e10cSrcweir     ImplRulerHitTest aHitTest;
2671*cdf0e10cSrcweir 
2672*cdf0e10cSrcweir     // Gegebenenfalls Lineal updaten (damit mit den richtigen Daten
2673*cdf0e10cSrcweir     // gearbeitet wird und die Anzeige auch zur Bearbeitung passt)
2674*cdf0e10cSrcweir     if ( IsReallyVisible() && mbFormat )
2675*cdf0e10cSrcweir     {
2676*cdf0e10cSrcweir         ((Ruler*)this)->ImplDraw();
2677*cdf0e10cSrcweir         ((Ruler*)this)->mnUpdateFlags &= ~RULER_UPDATE_DRAW;
2678*cdf0e10cSrcweir     }
2679*cdf0e10cSrcweir 
2680*cdf0e10cSrcweir     // HitTest durchfuehren
2681*cdf0e10cSrcweir     ImplDocHitTest( rPos, eDragType, &aHitTest );
2682*cdf0e10cSrcweir 
2683*cdf0e10cSrcweir     // Werte zurueckgeben
2684*cdf0e10cSrcweir     if ( pAryPos )
2685*cdf0e10cSrcweir         *pAryPos = aHitTest.nAryPos;
2686*cdf0e10cSrcweir     return aHitTest.eType;
2687*cdf0e10cSrcweir }
2688*cdf0e10cSrcweir 
2689*cdf0e10cSrcweir // -----------------------------------------------------------------------
2690*cdf0e10cSrcweir 
2691*cdf0e10cSrcweir void Ruler::CancelDrag()
2692*cdf0e10cSrcweir {
2693*cdf0e10cSrcweir     if ( mbDrag )
2694*cdf0e10cSrcweir     {
2695*cdf0e10cSrcweir         ImplDrag( Point( -1, -1 ) );
2696*cdf0e10cSrcweir         ImplEndDrag();
2697*cdf0e10cSrcweir     }
2698*cdf0e10cSrcweir }
2699*cdf0e10cSrcweir 
2700*cdf0e10cSrcweir // -----------------------------------------------------------------------
2701*cdf0e10cSrcweir 
2702*cdf0e10cSrcweir RulerType Ruler::GetType( const Point& rPos, sal_uInt16* pAryPos ) const
2703*cdf0e10cSrcweir {
2704*cdf0e10cSrcweir     ImplRulerHitTest aHitTest;
2705*cdf0e10cSrcweir 
2706*cdf0e10cSrcweir     // Gegebenenfalls Lineal updaten (damit mit den richtigen Daten
2707*cdf0e10cSrcweir     // gearbeitet wird und die Anzeige auch zur Bearbeitung passt)
2708*cdf0e10cSrcweir     if ( IsReallyVisible() && mbFormat )
2709*cdf0e10cSrcweir     {
2710*cdf0e10cSrcweir         ((Ruler*)this)->ImplDraw();
2711*cdf0e10cSrcweir         ((Ruler*)this)->mnUpdateFlags &= ~RULER_UPDATE_DRAW;
2712*cdf0e10cSrcweir     }
2713*cdf0e10cSrcweir 
2714*cdf0e10cSrcweir     // HitTest durchfuehren
2715*cdf0e10cSrcweir     ImplHitTest( rPos, &aHitTest );
2716*cdf0e10cSrcweir 
2717*cdf0e10cSrcweir     // Werte zurueckgeben
2718*cdf0e10cSrcweir     if ( pAryPos )
2719*cdf0e10cSrcweir         *pAryPos = aHitTest.nAryPos;
2720*cdf0e10cSrcweir     return aHitTest.eType;
2721*cdf0e10cSrcweir }
2722*cdf0e10cSrcweir 
2723*cdf0e10cSrcweir // -----------------------------------------------------------------------
2724*cdf0e10cSrcweir 
2725*cdf0e10cSrcweir void Ruler::SetWinPos( long nNewOff, long nNewWidth )
2726*cdf0e10cSrcweir {
2727*cdf0e10cSrcweir     // Gegebenenfalls werden die Breiten automatisch berechnet
2728*cdf0e10cSrcweir     if ( !nNewWidth )
2729*cdf0e10cSrcweir         mbAutoWinWidth = sal_True;
2730*cdf0e10cSrcweir     else
2731*cdf0e10cSrcweir         mbAutoWinWidth = sal_False;
2732*cdf0e10cSrcweir 
2733*cdf0e10cSrcweir     // Werte setzen (werden in ImplFormat gegebenenfalls mitberechnet)
2734*cdf0e10cSrcweir     mnWinOff = nNewOff;
2735*cdf0e10cSrcweir     mnWinWidth = nNewWidth;
2736*cdf0e10cSrcweir     ImplUpdate( sal_True );
2737*cdf0e10cSrcweir }
2738*cdf0e10cSrcweir 
2739*cdf0e10cSrcweir // -----------------------------------------------------------------------
2740*cdf0e10cSrcweir 
2741*cdf0e10cSrcweir void Ruler::SetPagePos( long nNewOff, long nNewWidth )
2742*cdf0e10cSrcweir {
2743*cdf0e10cSrcweir     // Muessen wir ueberhaupt was machen
2744*cdf0e10cSrcweir     if ( (mpData->nPageOff == nNewOff) && (mpData->nPageWidth == nNewWidth) )
2745*cdf0e10cSrcweir         return;
2746*cdf0e10cSrcweir 
2747*cdf0e10cSrcweir     // Gegebenenfalls werden die Breiten automatisch berechnet
2748*cdf0e10cSrcweir     if ( !nNewWidth )
2749*cdf0e10cSrcweir         mpData->bAutoPageWidth = sal_True;
2750*cdf0e10cSrcweir     else
2751*cdf0e10cSrcweir         mpData->bAutoPageWidth = sal_False;
2752*cdf0e10cSrcweir 
2753*cdf0e10cSrcweir     // Werte setzen (werden in ImplFormat gegebenenfalls mitberechnet)
2754*cdf0e10cSrcweir     mpData->nPageOff     = nNewOff;
2755*cdf0e10cSrcweir     mpData->nPageWidth   = nNewWidth;
2756*cdf0e10cSrcweir     ImplUpdate( sal_True );
2757*cdf0e10cSrcweir }
2758*cdf0e10cSrcweir 
2759*cdf0e10cSrcweir // -----------------------------------------------------------------------
2760*cdf0e10cSrcweir 
2761*cdf0e10cSrcweir void Ruler::SetBorderPos( long nOff )
2762*cdf0e10cSrcweir {
2763*cdf0e10cSrcweir     if ( mnWinStyle & WB_BORDER )
2764*cdf0e10cSrcweir     {
2765*cdf0e10cSrcweir         if ( mnBorderOff != nOff )
2766*cdf0e10cSrcweir         {
2767*cdf0e10cSrcweir             mnBorderOff = nOff;
2768*cdf0e10cSrcweir 
2769*cdf0e10cSrcweir             if ( IsReallyVisible() && IsUpdateMode() )
2770*cdf0e10cSrcweir                 Invalidate();
2771*cdf0e10cSrcweir         }
2772*cdf0e10cSrcweir     }
2773*cdf0e10cSrcweir }
2774*cdf0e10cSrcweir 
2775*cdf0e10cSrcweir // -----------------------------------------------------------------------
2776*cdf0e10cSrcweir 
2777*cdf0e10cSrcweir void Ruler::SetUnit( FieldUnit eNewUnit )
2778*cdf0e10cSrcweir {
2779*cdf0e10cSrcweir     if ( meUnit != eNewUnit )
2780*cdf0e10cSrcweir     {
2781*cdf0e10cSrcweir         meUnit = eNewUnit;
2782*cdf0e10cSrcweir         switch ( meUnit )
2783*cdf0e10cSrcweir         {
2784*cdf0e10cSrcweir             case FUNIT_MM:
2785*cdf0e10cSrcweir                 mnUnitIndex = RULER_UNIT_MM;
2786*cdf0e10cSrcweir                 break;
2787*cdf0e10cSrcweir             case FUNIT_CM:
2788*cdf0e10cSrcweir                 mnUnitIndex = RULER_UNIT_CM;
2789*cdf0e10cSrcweir                 break;
2790*cdf0e10cSrcweir             case FUNIT_M:
2791*cdf0e10cSrcweir                 mnUnitIndex = RULER_UNIT_M;
2792*cdf0e10cSrcweir                 break;
2793*cdf0e10cSrcweir             case FUNIT_KM:
2794*cdf0e10cSrcweir                 mnUnitIndex = RULER_UNIT_KM;
2795*cdf0e10cSrcweir                 break;
2796*cdf0e10cSrcweir             case FUNIT_INCH:
2797*cdf0e10cSrcweir                 mnUnitIndex = RULER_UNIT_INCH;
2798*cdf0e10cSrcweir                 break;
2799*cdf0e10cSrcweir             case FUNIT_FOOT:
2800*cdf0e10cSrcweir                 mnUnitIndex = RULER_UNIT_FOOT;
2801*cdf0e10cSrcweir                 break;
2802*cdf0e10cSrcweir             case FUNIT_MILE:
2803*cdf0e10cSrcweir                 mnUnitIndex = RULER_UNIT_MILE;
2804*cdf0e10cSrcweir                 break;
2805*cdf0e10cSrcweir             case FUNIT_POINT:
2806*cdf0e10cSrcweir                 mnUnitIndex = RULER_UNIT_POINT;
2807*cdf0e10cSrcweir                 break;
2808*cdf0e10cSrcweir             case FUNIT_PICA:
2809*cdf0e10cSrcweir                 mnUnitIndex = RULER_UNIT_PICA;
2810*cdf0e10cSrcweir                 break;
2811*cdf0e10cSrcweir             default:
2812*cdf0e10cSrcweir #ifdef DBG_UTIL
2813*cdf0e10cSrcweir                 DBG_ERRORFILE( "Ruler::SetUnit() - Wrong Unit" );
2814*cdf0e10cSrcweir #endif
2815*cdf0e10cSrcweir                 break;
2816*cdf0e10cSrcweir         }
2817*cdf0e10cSrcweir 
2818*cdf0e10cSrcweir         maMapMode.SetMapUnit( aImplRulerUnitTab[mnUnitIndex].eMapUnit );
2819*cdf0e10cSrcweir         ImplUpdate();
2820*cdf0e10cSrcweir     }
2821*cdf0e10cSrcweir }
2822*cdf0e10cSrcweir 
2823*cdf0e10cSrcweir // -----------------------------------------------------------------------
2824*cdf0e10cSrcweir 
2825*cdf0e10cSrcweir void Ruler::SetZoom( const Fraction& rNewZoom )
2826*cdf0e10cSrcweir {
2827*cdf0e10cSrcweir     DBG_ASSERT( rNewZoom.GetNumerator(), "Ruler::SetZoom() with scale 0 is not allowed" );
2828*cdf0e10cSrcweir 
2829*cdf0e10cSrcweir     if ( maZoom != rNewZoom )
2830*cdf0e10cSrcweir     {
2831*cdf0e10cSrcweir         maZoom = rNewZoom;
2832*cdf0e10cSrcweir         maMapMode.SetScaleX( maZoom );
2833*cdf0e10cSrcweir         maMapMode.SetScaleY( maZoom );
2834*cdf0e10cSrcweir         ImplUpdate();
2835*cdf0e10cSrcweir     }
2836*cdf0e10cSrcweir }
2837*cdf0e10cSrcweir 
2838*cdf0e10cSrcweir // -----------------------------------------------------------------------
2839*cdf0e10cSrcweir 
2840*cdf0e10cSrcweir void Ruler::SetExtraType( RulerExtra eNewExtraType, sal_uInt16 nStyle )
2841*cdf0e10cSrcweir {
2842*cdf0e10cSrcweir     if ( mnWinStyle & WB_EXTRAFIELD )
2843*cdf0e10cSrcweir     {
2844*cdf0e10cSrcweir         meExtraType  = eNewExtraType;
2845*cdf0e10cSrcweir         mnExtraStyle = nStyle;
2846*cdf0e10cSrcweir         if ( IsReallyVisible() && IsUpdateMode() )
2847*cdf0e10cSrcweir             ImplDrawExtra( sal_False );
2848*cdf0e10cSrcweir     }
2849*cdf0e10cSrcweir }
2850*cdf0e10cSrcweir 
2851*cdf0e10cSrcweir // -----------------------------------------------------------------------
2852*cdf0e10cSrcweir 
2853*cdf0e10cSrcweir void Ruler::SetNullOffset( long nPos )
2854*cdf0e10cSrcweir {
2855*cdf0e10cSrcweir     if ( mpData->nNullOff != nPos )
2856*cdf0e10cSrcweir     {
2857*cdf0e10cSrcweir         mpData->nNullOff = nPos;
2858*cdf0e10cSrcweir         ImplUpdate();
2859*cdf0e10cSrcweir     }
2860*cdf0e10cSrcweir }
2861*cdf0e10cSrcweir 
2862*cdf0e10cSrcweir // -----------------------------------------------------------------------
2863*cdf0e10cSrcweir 
2864*cdf0e10cSrcweir void Ruler::SetMargin1( long nPos, sal_uInt16 nMarginStyle )
2865*cdf0e10cSrcweir {
2866*cdf0e10cSrcweir     if ( (mpData->nMargin1 != nPos) || (mpData->nMargin1Style != nMarginStyle) )
2867*cdf0e10cSrcweir     {
2868*cdf0e10cSrcweir         mpData->nMargin1      = nPos;
2869*cdf0e10cSrcweir         mpData->nMargin1Style = nMarginStyle;
2870*cdf0e10cSrcweir         ImplUpdate();
2871*cdf0e10cSrcweir     }
2872*cdf0e10cSrcweir }
2873*cdf0e10cSrcweir 
2874*cdf0e10cSrcweir // -----------------------------------------------------------------------
2875*cdf0e10cSrcweir 
2876*cdf0e10cSrcweir void Ruler::SetMargin2( long nPos, sal_uInt16 nMarginStyle )
2877*cdf0e10cSrcweir {
2878*cdf0e10cSrcweir     DBG_ASSERT( (nPos >= mpData->nMargin1) ||
2879*cdf0e10cSrcweir                 (mpData->nMargin1Style & RULER_STYLE_INVISIBLE) ||
2880*cdf0e10cSrcweir                 (mpData->nMargin2Style & RULER_STYLE_INVISIBLE),
2881*cdf0e10cSrcweir                 "Ruler::SetMargin2() - Margin2 < Margin1" );
2882*cdf0e10cSrcweir 
2883*cdf0e10cSrcweir     if ( (mpData->nMargin2 != nPos) || (mpData->nMargin2Style != nMarginStyle) )
2884*cdf0e10cSrcweir     {
2885*cdf0e10cSrcweir         mpData->nMargin2      = nPos;
2886*cdf0e10cSrcweir         mpData->nMargin2Style = nMarginStyle;
2887*cdf0e10cSrcweir         ImplUpdate();
2888*cdf0e10cSrcweir     }
2889*cdf0e10cSrcweir }
2890*cdf0e10cSrcweir 
2891*cdf0e10cSrcweir // -----------------------------------------------------------------------
2892*cdf0e10cSrcweir 
2893*cdf0e10cSrcweir void Ruler::SetLines( sal_uInt16 n, const RulerLine* pLineAry )
2894*cdf0e10cSrcweir {
2895*cdf0e10cSrcweir     // To determine if what has changed
2896*cdf0e10cSrcweir     if ( mpData->nLines == n )
2897*cdf0e10cSrcweir     {
2898*cdf0e10cSrcweir         sal_uInt16           i = n;
2899*cdf0e10cSrcweir         const RulerLine* pAry1 = mpData->pLines;
2900*cdf0e10cSrcweir         const RulerLine* pAry2 = pLineAry;
2901*cdf0e10cSrcweir         while ( i )
2902*cdf0e10cSrcweir         {
2903*cdf0e10cSrcweir             if ( (pAry1->nPos   != pAry2->nPos)   ||
2904*cdf0e10cSrcweir                  (pAry1->nStyle != pAry2->nStyle) )
2905*cdf0e10cSrcweir                 break;
2906*cdf0e10cSrcweir             pAry1++;
2907*cdf0e10cSrcweir             pAry2++;
2908*cdf0e10cSrcweir             i--;
2909*cdf0e10cSrcweir         }
2910*cdf0e10cSrcweir         if ( !i )
2911*cdf0e10cSrcweir             return;
2912*cdf0e10cSrcweir     }
2913*cdf0e10cSrcweir 
2914*cdf0e10cSrcweir     // New values and new share issue
2915*cdf0e10cSrcweir     sal_Bool bMustUpdate;
2916*cdf0e10cSrcweir     if ( IsReallyVisible() && IsUpdateMode() )
2917*cdf0e10cSrcweir         bMustUpdate = sal_True;
2918*cdf0e10cSrcweir     else
2919*cdf0e10cSrcweir         bMustUpdate = sal_False;
2920*cdf0e10cSrcweir 
2921*cdf0e10cSrcweir     // Delete old lines
2922*cdf0e10cSrcweir     if ( bMustUpdate )
2923*cdf0e10cSrcweir         ImplInvertLines();
2924*cdf0e10cSrcweir 
2925*cdf0e10cSrcweir     // New data set
2926*cdf0e10cSrcweir     if ( !n || !pLineAry )
2927*cdf0e10cSrcweir     {
2928*cdf0e10cSrcweir         if ( !mpData->pLines )
2929*cdf0e10cSrcweir             return;
2930*cdf0e10cSrcweir         delete[] mpData->pLines;
2931*cdf0e10cSrcweir         mpData->nLines = 0;
2932*cdf0e10cSrcweir         mpData->pLines = NULL;
2933*cdf0e10cSrcweir     }
2934*cdf0e10cSrcweir     else
2935*cdf0e10cSrcweir     {
2936*cdf0e10cSrcweir         if ( mpData->nLines != n )
2937*cdf0e10cSrcweir         {
2938*cdf0e10cSrcweir             delete[] mpData->pLines;
2939*cdf0e10cSrcweir             mpData->nLines = n;
2940*cdf0e10cSrcweir             mpData->pLines = new RulerLine[n];
2941*cdf0e10cSrcweir         }
2942*cdf0e10cSrcweir 
2943*cdf0e10cSrcweir         memcpy( mpData->pLines, pLineAry, n*sizeof( RulerLine ) );
2944*cdf0e10cSrcweir 
2945*cdf0e10cSrcweir         // Linien neu ausgeben
2946*cdf0e10cSrcweir         if ( bMustUpdate )
2947*cdf0e10cSrcweir             ImplInvertLines();
2948*cdf0e10cSrcweir     }
2949*cdf0e10cSrcweir }
2950*cdf0e10cSrcweir 
2951*cdf0e10cSrcweir // -----------------------------------------------------------------------
2952*cdf0e10cSrcweir 
2953*cdf0e10cSrcweir void Ruler::SetArrows( sal_uInt16 n, const RulerArrow* pArrowAry )
2954*cdf0e10cSrcweir {
2955*cdf0e10cSrcweir     if ( !n || !pArrowAry )
2956*cdf0e10cSrcweir     {
2957*cdf0e10cSrcweir         if ( !mpData->pArrows )
2958*cdf0e10cSrcweir             return;
2959*cdf0e10cSrcweir         delete[] mpData->pArrows;
2960*cdf0e10cSrcweir         mpData->nArrows = 0;
2961*cdf0e10cSrcweir         mpData->pArrows = NULL;
2962*cdf0e10cSrcweir     }
2963*cdf0e10cSrcweir     else
2964*cdf0e10cSrcweir     {
2965*cdf0e10cSrcweir         if ( mpData->nArrows != n )
2966*cdf0e10cSrcweir         {
2967*cdf0e10cSrcweir             delete[] mpData->pArrows;
2968*cdf0e10cSrcweir             mpData->nArrows = n;
2969*cdf0e10cSrcweir             mpData->pArrows = new RulerArrow[n];
2970*cdf0e10cSrcweir         }
2971*cdf0e10cSrcweir         else
2972*cdf0e10cSrcweir         {
2973*cdf0e10cSrcweir             sal_uInt16            i = n;
2974*cdf0e10cSrcweir             const RulerArrow* pAry1 = mpData->pArrows;
2975*cdf0e10cSrcweir             const RulerArrow* pAry2 = pArrowAry;
2976*cdf0e10cSrcweir             while ( i )
2977*cdf0e10cSrcweir             {
2978*cdf0e10cSrcweir                 if ( (pAry1->nPos      != pAry2->nPos)      ||
2979*cdf0e10cSrcweir                      (pAry1->nWidth    != pAry2->nWidth)    ||
2980*cdf0e10cSrcweir                      (pAry1->nLogWidth != pAry2->nLogWidth) ||
2981*cdf0e10cSrcweir                      (pAry1->nStyle    != pAry2->nStyle) )
2982*cdf0e10cSrcweir                     break;
2983*cdf0e10cSrcweir                 pAry1++;
2984*cdf0e10cSrcweir                 pAry2++;
2985*cdf0e10cSrcweir                 i--;
2986*cdf0e10cSrcweir             }
2987*cdf0e10cSrcweir             if ( !i )
2988*cdf0e10cSrcweir                 return;
2989*cdf0e10cSrcweir         }
2990*cdf0e10cSrcweir 
2991*cdf0e10cSrcweir         memcpy( mpData->pArrows, pArrowAry, n*sizeof( RulerArrow ) );
2992*cdf0e10cSrcweir     }
2993*cdf0e10cSrcweir 
2994*cdf0e10cSrcweir     ImplUpdate();
2995*cdf0e10cSrcweir }
2996*cdf0e10cSrcweir 
2997*cdf0e10cSrcweir // -----------------------------------------------------------------------
2998*cdf0e10cSrcweir 
2999*cdf0e10cSrcweir void Ruler::SetBorders( sal_uInt16 n, const RulerBorder* pBrdAry )
3000*cdf0e10cSrcweir {
3001*cdf0e10cSrcweir     if ( !n || !pBrdAry )
3002*cdf0e10cSrcweir     {
3003*cdf0e10cSrcweir         if ( !mpData->pBorders )
3004*cdf0e10cSrcweir             return;
3005*cdf0e10cSrcweir         delete[] mpData->pBorders;
3006*cdf0e10cSrcweir         mpData->nBorders = 0;
3007*cdf0e10cSrcweir         mpData->pBorders = NULL;
3008*cdf0e10cSrcweir     }
3009*cdf0e10cSrcweir     else
3010*cdf0e10cSrcweir     {
3011*cdf0e10cSrcweir         if ( mpData->nBorders != n )
3012*cdf0e10cSrcweir         {
3013*cdf0e10cSrcweir             delete[] mpData->pBorders;
3014*cdf0e10cSrcweir             mpData->nBorders = n;
3015*cdf0e10cSrcweir             mpData->pBorders = new RulerBorder[n];
3016*cdf0e10cSrcweir         }
3017*cdf0e10cSrcweir         else
3018*cdf0e10cSrcweir         {
3019*cdf0e10cSrcweir             sal_uInt16             i = n;
3020*cdf0e10cSrcweir             const RulerBorder* pAry1 = mpData->pBorders;
3021*cdf0e10cSrcweir             const RulerBorder* pAry2 = pBrdAry;
3022*cdf0e10cSrcweir             while ( i )
3023*cdf0e10cSrcweir             {
3024*cdf0e10cSrcweir                 if ( (pAry1->nPos   != pAry2->nPos)   ||
3025*cdf0e10cSrcweir                      (pAry1->nWidth != pAry2->nWidth) ||
3026*cdf0e10cSrcweir                      (pAry1->nStyle != pAry2->nStyle) )
3027*cdf0e10cSrcweir                     break;
3028*cdf0e10cSrcweir                 pAry1++;
3029*cdf0e10cSrcweir                 pAry2++;
3030*cdf0e10cSrcweir                 i--;
3031*cdf0e10cSrcweir             }
3032*cdf0e10cSrcweir             if ( !i )
3033*cdf0e10cSrcweir                 return;
3034*cdf0e10cSrcweir         }
3035*cdf0e10cSrcweir 
3036*cdf0e10cSrcweir         memcpy( mpData->pBorders, pBrdAry, n*sizeof( RulerBorder ) );
3037*cdf0e10cSrcweir     }
3038*cdf0e10cSrcweir 
3039*cdf0e10cSrcweir     ImplUpdate();
3040*cdf0e10cSrcweir }
3041*cdf0e10cSrcweir 
3042*cdf0e10cSrcweir // -----------------------------------------------------------------------
3043*cdf0e10cSrcweir 
3044*cdf0e10cSrcweir void Ruler::SetIndents( sal_uInt16 n, const RulerIndent* pIndentAry )
3045*cdf0e10cSrcweir {
3046*cdf0e10cSrcweir 
3047*cdf0e10cSrcweir     if ( !n || !pIndentAry )
3048*cdf0e10cSrcweir     {
3049*cdf0e10cSrcweir         if ( !mpData->pIndents )
3050*cdf0e10cSrcweir             return;
3051*cdf0e10cSrcweir         delete[] mpData->pIndents;
3052*cdf0e10cSrcweir         mpData->nIndents = 0;
3053*cdf0e10cSrcweir         mpData->pIndents = NULL;
3054*cdf0e10cSrcweir     }
3055*cdf0e10cSrcweir     else
3056*cdf0e10cSrcweir     {
3057*cdf0e10cSrcweir         if ( mpData->nIndents != n )
3058*cdf0e10cSrcweir         {
3059*cdf0e10cSrcweir             delete[] mpData->pIndents;
3060*cdf0e10cSrcweir             mpData->nIndents = n;
3061*cdf0e10cSrcweir             mpData->pIndents = new RulerIndent[n];
3062*cdf0e10cSrcweir         }
3063*cdf0e10cSrcweir         else
3064*cdf0e10cSrcweir         {
3065*cdf0e10cSrcweir             sal_uInt16             i = n;
3066*cdf0e10cSrcweir             const RulerIndent* pAry1 = mpData->pIndents;
3067*cdf0e10cSrcweir             const RulerIndent* pAry2 = pIndentAry;
3068*cdf0e10cSrcweir             while ( i )
3069*cdf0e10cSrcweir             {
3070*cdf0e10cSrcweir                 if ( (pAry1->nPos   != pAry2->nPos) ||
3071*cdf0e10cSrcweir                      (pAry1->nStyle != pAry2->nStyle) )
3072*cdf0e10cSrcweir                     break;
3073*cdf0e10cSrcweir                 pAry1++;
3074*cdf0e10cSrcweir                 pAry2++;
3075*cdf0e10cSrcweir                 i--;
3076*cdf0e10cSrcweir             }
3077*cdf0e10cSrcweir             if ( !i )
3078*cdf0e10cSrcweir                 return;
3079*cdf0e10cSrcweir         }
3080*cdf0e10cSrcweir 
3081*cdf0e10cSrcweir         memcpy( mpData->pIndents, pIndentAry, n*sizeof( RulerIndent ) );
3082*cdf0e10cSrcweir     }
3083*cdf0e10cSrcweir 
3084*cdf0e10cSrcweir     ImplUpdate();
3085*cdf0e10cSrcweir }
3086*cdf0e10cSrcweir 
3087*cdf0e10cSrcweir // -----------------------------------------------------------------------
3088*cdf0e10cSrcweir 
3089*cdf0e10cSrcweir void Ruler::SetTabs( sal_uInt16 n, const RulerTab* pTabAry )
3090*cdf0e10cSrcweir {
3091*cdf0e10cSrcweir     if ( !n || !pTabAry )
3092*cdf0e10cSrcweir     {
3093*cdf0e10cSrcweir         if ( !mpData->pTabs )
3094*cdf0e10cSrcweir             return;
3095*cdf0e10cSrcweir         delete[] mpData->pTabs;
3096*cdf0e10cSrcweir         mpData->nTabs = 0;
3097*cdf0e10cSrcweir         mpData->pTabs = NULL;
3098*cdf0e10cSrcweir     }
3099*cdf0e10cSrcweir     else
3100*cdf0e10cSrcweir     {
3101*cdf0e10cSrcweir         if ( mpData->nTabs != n )
3102*cdf0e10cSrcweir         {
3103*cdf0e10cSrcweir             delete[] mpData->pTabs;
3104*cdf0e10cSrcweir             mpData->nTabs = n;
3105*cdf0e10cSrcweir             mpData->pTabs = new RulerTab[n];
3106*cdf0e10cSrcweir         }
3107*cdf0e10cSrcweir         else
3108*cdf0e10cSrcweir         {
3109*cdf0e10cSrcweir             sal_uInt16          i = n;
3110*cdf0e10cSrcweir             const RulerTab* pAry1 = mpData->pTabs;
3111*cdf0e10cSrcweir             const RulerTab* pAry2 = pTabAry;
3112*cdf0e10cSrcweir             while ( i )
3113*cdf0e10cSrcweir             {
3114*cdf0e10cSrcweir                 if ( (pAry1->nPos   != pAry2->nPos) ||
3115*cdf0e10cSrcweir                      (pAry1->nStyle != pAry2->nStyle) )
3116*cdf0e10cSrcweir                     break;
3117*cdf0e10cSrcweir                 pAry1++;
3118*cdf0e10cSrcweir                 pAry2++;
3119*cdf0e10cSrcweir                 i--;
3120*cdf0e10cSrcweir             }
3121*cdf0e10cSrcweir             if ( !i )
3122*cdf0e10cSrcweir                 return;
3123*cdf0e10cSrcweir         }
3124*cdf0e10cSrcweir 
3125*cdf0e10cSrcweir         memcpy( mpData->pTabs, pTabAry, n*sizeof( RulerTab ) );
3126*cdf0e10cSrcweir     }
3127*cdf0e10cSrcweir 
3128*cdf0e10cSrcweir     ImplUpdate();
3129*cdf0e10cSrcweir }
3130*cdf0e10cSrcweir 
3131*cdf0e10cSrcweir // -----------------------------------------------------------------------
3132*cdf0e10cSrcweir 
3133*cdf0e10cSrcweir void Ruler::SetStyle( WinBits nStyle )
3134*cdf0e10cSrcweir {
3135*cdf0e10cSrcweir     if ( mnWinStyle != nStyle )
3136*cdf0e10cSrcweir     {
3137*cdf0e10cSrcweir         mnWinStyle = nStyle;
3138*cdf0e10cSrcweir         ImplInitExtraField( sal_True );
3139*cdf0e10cSrcweir     }
3140*cdf0e10cSrcweir }
3141*cdf0e10cSrcweir 
3142*cdf0e10cSrcweir // -----------------------------------------------------------------------
3143*cdf0e10cSrcweir 
3144*cdf0e10cSrcweir void Ruler::DrawTab( OutputDevice* pDevice, const Point& rPos, sal_uInt16 nStyle )
3145*cdf0e10cSrcweir {
3146*cdf0e10cSrcweir     /*const StyleSettings&    rStyleSettings =*/ pDevice->GetSettings().GetStyleSettings();
3147*cdf0e10cSrcweir     Point                   aPos( rPos );
3148*cdf0e10cSrcweir     sal_uInt16                  nTabStyle = nStyle & (RULER_TAB_STYLE | RULER_TAB_RTL);
3149*cdf0e10cSrcweir 
3150*cdf0e10cSrcweir     pDevice->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
3151*cdf0e10cSrcweir     pDevice->SetLineColor();
3152*cdf0e10cSrcweir     pDevice->SetFillColor( pDevice->GetSettings().GetStyleSettings().GetWindowTextColor() );
3153*cdf0e10cSrcweir     ImplCenterTabPos( aPos, nTabStyle );
3154*cdf0e10cSrcweir     ImplDrawRulerTab( pDevice, aPos, nTabStyle, nStyle  );
3155*cdf0e10cSrcweir     pDevice->Pop();
3156*cdf0e10cSrcweir }
3157*cdf0e10cSrcweir /* -----------------16.10.2002 15:17-----------------
3158*cdf0e10cSrcweir  *
3159*cdf0e10cSrcweir  * --------------------------------------------------*/
3160*cdf0e10cSrcweir void Ruler::SetTextRTL(sal_Bool bRTL)
3161*cdf0e10cSrcweir {
3162*cdf0e10cSrcweir     if(mpData->bTextRTL != bRTL)
3163*cdf0e10cSrcweir     {
3164*cdf0e10cSrcweir         mpData->bTextRTL = bRTL;
3165*cdf0e10cSrcweir         if ( IsReallyVisible() && IsUpdateMode() )
3166*cdf0e10cSrcweir             ImplInitExtraField( sal_True );
3167*cdf0e10cSrcweir     }
3168*cdf0e10cSrcweir 
3169*cdf0e10cSrcweir }
3170*cdf0e10cSrcweir long Ruler::GetPageOffset() const { return mpData->nPageOff; }
3171*cdf0e10cSrcweir long                Ruler::GetPageWidth() const { return mpData->nPageWidth; }
3172*cdf0e10cSrcweir long                Ruler::GetNullOffset() const { return mpData->nNullOff; }
3173*cdf0e10cSrcweir long                Ruler::GetMargin1() const { return mpData->nMargin1; }
3174*cdf0e10cSrcweir sal_uInt16              Ruler::GetMargin1Style() const { return mpData->nMargin1Style; }
3175*cdf0e10cSrcweir long                Ruler::GetMargin2() const { return mpData->nMargin2; }
3176*cdf0e10cSrcweir sal_uInt16              Ruler::GetMargin2Style() const { return mpData->nMargin2Style; }
3177*cdf0e10cSrcweir sal_uInt16              Ruler::GetLineCount() const { return mpData->nLines; }
3178*cdf0e10cSrcweir const RulerLine*    Ruler::GetLines() const { return mpData->pLines; }
3179*cdf0e10cSrcweir sal_uInt16              Ruler::GetArrowCount() const { return mpData->nArrows; }
3180*cdf0e10cSrcweir const RulerArrow*   Ruler::GetArrows() const { return mpData->pArrows; }
3181*cdf0e10cSrcweir sal_uInt16              Ruler::GetBorderCount() const { return mpData->nBorders; }
3182*cdf0e10cSrcweir const RulerBorder*  Ruler::GetBorders() const { return mpData->pBorders; }
3183*cdf0e10cSrcweir sal_uInt16              Ruler::GetIndentCount() const { return mpData->nIndents; }
3184*cdf0e10cSrcweir const RulerIndent*  Ruler::GetIndents() const { return mpData->pIndents; }
3185*cdf0e10cSrcweir 
3186