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