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