Bump version to 5.0-14
[LibreOffice.git] / svtools / source / control / ruler.cxx
blob2d4486c1b623538c7a99b96ed4b1ff0ad0b3df46
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <string.h>
21 #include <tools/debug.hxx>
22 #include <vcl/svapp.hxx>
23 #include <tools/poly.hxx>
24 #include <vcl/i18nhelp.hxx>
25 #include <vcl/settings.hxx>
27 #include <svtools/ruler.hxx>
28 #include <svtools/svtresid.hxx>
29 #include <svtools/svtools.hrc>
30 #include <svtools/colorcfg.hxx>
32 #include <boost/scoped_array.hpp>
33 #include <vector>
35 using namespace std;
36 using namespace ::com::sun::star;
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::lang;
39 using namespace ::com::sun::star::accessibility;
41 #define RULER_OFF 3
42 #define RULER_RESIZE_OFF 4
43 #define RULER_MIN_SIZE 3
45 #define RULER_VAR_SIZE 8
47 #define RULER_UPDATE_LINES 0x01
49 #define RULER_CLIP 150
51 #define RULER_UNIT_MM 0
52 #define RULER_UNIT_CM 1
53 #define RULER_UNIT_M 2
54 #define RULER_UNIT_KM 3
55 #define RULER_UNIT_INCH 4
56 #define RULER_UNIT_FOOT 5
57 #define RULER_UNIT_MILE 6
58 #define RULER_UNIT_POINT 7
59 #define RULER_UNIT_PICA 8
60 #define RULER_UNIT_CHAR 9
61 #define RULER_UNIT_LINE 10
62 #define RULER_UNIT_COUNT 11
64 class ImplRulerData
66 friend class Ruler;
68 private:
69 vector<RulerLine> pLines;
70 vector<RulerBorder> pBorders;
71 vector<RulerIndent> pIndents;
72 vector<RulerTab> pTabs;
74 long nNullVirOff;
75 long nRulVirOff;
76 long nRulWidth;
77 long nPageOff;
78 long nPageWidth;
79 long nNullOff;
80 long nMargin1;
81 long nMargin2;
82 long nLeftFrameMargin;
83 long nRightFrameMargin;
84 sal_uInt16 nMargin1Style;
85 sal_uInt16 nMargin2Style;
86 bool bAutoPageWidth;
87 bool bTextRTL;
89 public:
90 ImplRulerData();
91 ~ImplRulerData();
93 ImplRulerData& operator=( const ImplRulerData& rData );
96 ImplRulerData::ImplRulerData() :
97 nNullVirOff (0),
98 nRulVirOff (0),
99 nRulWidth (0),
100 nPageOff (0),
101 nPageWidth (0),
102 nNullOff (0),
103 nMargin1 (0),
104 nMargin2 (0),
105 nLeftFrameMargin (0),
106 nRightFrameMargin (0),
107 nMargin1Style (0),
108 nMargin2Style (0),
109 bAutoPageWidth (true), // Page width == EditWin width
110 bTextRTL (false)
114 ImplRulerData::~ImplRulerData()
117 ImplRulerData& ImplRulerData::operator=( const ImplRulerData& rData )
119 if( this == &rData )
120 return *this;
122 nNullVirOff = rData.nNullVirOff;
123 nRulVirOff = rData.nRulVirOff;
124 nRulWidth = rData.nRulWidth;
125 nPageOff = rData.nPageOff;
126 nPageWidth = rData.nPageWidth;
127 nNullOff = rData.nNullOff;
128 nMargin1 = rData.nMargin1;
129 nMargin2 = rData.nMargin2;
130 nLeftFrameMargin = rData.nLeftFrameMargin;
131 nRightFrameMargin = rData.nRightFrameMargin;
132 nMargin1Style = rData.nMargin1Style;
133 nMargin2Style = rData.nMargin2Style;
134 bAutoPageWidth = rData.bAutoPageWidth;
135 bTextRTL = rData.bTextRTL;
137 if ( !rData.pLines.empty() )
139 pLines.resize(rData.pLines.size());
140 std::copy(rData.pLines.begin(), rData.pLines.end(), pLines.begin());
142 else
144 pLines.clear();
147 if ( !rData.pBorders.empty() )
149 pBorders.resize(rData.pBorders.size());
150 std::copy(rData.pBorders.begin(), rData.pBorders.end(), pBorders.begin());
152 else
154 pBorders.clear();
157 if ( !rData.pIndents.empty() )
159 pIndents.resize(rData.pIndents.size());
160 std::copy(rData.pIndents.begin(), rData.pIndents.end(), pIndents.begin());
162 else
164 pIndents.clear();
167 if ( !rData.pTabs.empty() )
169 pTabs.resize(rData.pTabs.size());
170 std::copy(rData.pTabs.begin(), rData.pTabs.end(), pTabs.begin());
172 else
174 pTabs.clear();
177 return *this;
180 static const RulerUnitData aImplRulerUnitTab[RULER_UNIT_COUNT] =
182 { MAP_100TH_MM, 100, 25.0, 25.0, 50.0, 100.0, 100, 3, " mm" }, // MM
183 { MAP_100TH_MM, 1000, 100.0, 500.0, 1000.0, 1000.0, 1000, 3, " cm" }, // CM
184 { MAP_MM, 1000, 10.0, 250.0, 500.0, 1000.0, 10000, 4, " m" }, // M
185 { MAP_CM, 100000, 12500.0, 25000.0, 50000.0, 100000.0, 100000, 6, " km" }, // KM
186 { MAP_1000TH_INCH, 1000, 62.5, 125.0, 500.0, 1000.0, 25400, 3, "\"" }, // INCH
187 { MAP_100TH_INCH, 1200, 120.0, 120.0, 600.0, 1200.0, 30480, 3, "'" }, // FOOT
188 { MAP_10TH_INCH, 633600, 63360.0, 63360.0, 316800.0, 633600.0, 1609344, 4, " miles" }, // MILE
189 { MAP_POINT, 1, 12.0, 12.0, 12.0, 36.0, 353, 2, " pt" }, // POINT
190 { MAP_100TH_MM, 423, 423.0, 423.0, 423.0, 846.0, 423, 3, " pi" }, // PICA
191 { MAP_100TH_MM, 371, 371.0, 371.0, 371.0, 743.0, 371, 3, " ch" }, // CHAR
192 { MAP_100TH_MM, 551, 551.0, 551.0, 551.0, 1102.0, 551, 3, " li" } // LINE
195 static RulerTabData ruler_tab =
197 0, // DPIScaleFactor to be set
198 7, // ruler_tab_width
199 6, // ruler_tab_height
200 2, // ruler_tab_height2
201 2, // ruler_tab_width2
202 8, // ruler_tab_cwidth
203 4, // ruler_tab_cwidth2
204 4, // ruler_tab_cwidth3
205 2, // ruler_tab_cwidth4
206 4, // ruler_tab_dheight
207 1, // ruler_tab_dheight2
208 5, // ruler_tab_dwidth
209 3, // ruler_tab_dwidth2
210 3, // ruler_tab_dwidth3
211 1, // ruler_tab_dwidth4
212 5 // ruler_tab_textoff
215 void Ruler::ImplInit( WinBits nWinBits )
217 // Default WinBits setzen
218 if ( !(nWinBits & WB_VERT) )
220 nWinBits |= WB_HORZ;
222 // --- RTL --- no UI mirroring for horizontal rulers, because
223 // the document is also not mirrored
224 EnableRTL( false );
227 // Initialize variables
228 mnWinStyle = nWinBits; // Window-Style
229 mnBorderOff = 0; // Border-Offset
230 mnWinOff = 0; // EditWinOffset
231 mnWinWidth = 0; // EditWinWidth
232 mnWidth = 0; // Window width
233 mnHeight = 0; // Window height
234 mnVirOff = 0; // Offset of VirtualDevice from top-left corner
235 mnVirWidth = 0; // width or height from VirtualDevice
236 mnVirHeight = 0; // height of width from VirtualDevice
237 mnDragPos = 0; // Drag-Position (Null point)
238 mnUpdateEvtId = 0; // Update event was not sent yet
239 mnDragAryPos = 0; // Drag-Array-Index
240 mnDragSize = 0; // Did size change at dragging
241 mnDragModifier = 0; // Modifier key at dragging
242 mnExtraStyle = 0; // Style of Extra field
243 mnExtraClicks = 0; // No. of clicks for Extra field
244 mnExtraModifier = 0; // Modifier key at click in extra field
245 mnCharWidth = 371;
246 mnLineHeight = 551;
247 mbCalc = true; // Should recalculate page width
248 mbFormat = true; // Should redraw
249 mbDrag = false; // Currently at dragging
250 mbDragDelete = false; // Has mouse left the dragging area
251 mbDragCanceled = false; // Dragging cancelled?
252 mbAutoWinWidth = true; // EditWinWidth == RulerWidth
253 mbActive = true; // Is ruler active
254 mnUpdateFlags = 0; // What needs to be updated
255 mpData = mpSaveData; // Pointer to normal data
256 meExtraType = RULER_EXTRA_DONTKNOW; // What is in extra field
257 meDragType = RULER_TYPE_DONTKNOW; // Which element is dragged
259 // Initialize Units
260 mnUnitIndex = RULER_UNIT_CM;
261 meUnit = FUNIT_CM;
262 maZoom = Fraction( 1, 1 );
263 meSourceUnit = MAP_100TH_MM;
265 // Recalculate border widths
266 if ( nWinBits & WB_BORDER )
267 mnBorderWidth = 1;
268 else
269 mnBorderWidth = 0;
271 // Settings
272 ImplInitSettings( true, true, true );
274 // Setup the default size
275 Rectangle aRect;
276 GetTextBoundRect( aRect, OUString( "0123456789" ) );
277 long nDefHeight = aRect.GetHeight() + RULER_OFF * 2 + ruler_tab.textoff * 2 + mnBorderWidth;
279 Size aDefSize;
280 if ( nWinBits & WB_HORZ )
281 aDefSize.Height() = nDefHeight;
282 else
283 aDefSize.Width() = nDefHeight;
284 SetOutputSizePixel( aDefSize );
285 SetType(WINDOW_RULER);
286 pAccContext = NULL;
289 Ruler::Ruler( vcl::Window* pParent, WinBits nWinStyle ) :
290 Window( pParent, nWinStyle & WB_3DLOOK ),
291 maVirDev( VclPtr<VirtualDevice>::Create(*this) ),
292 maMapMode( MAP_100TH_MM ),
293 mpSaveData(new ImplRulerData),
294 mpData(NULL),
295 mpDragData(new ImplRulerData)
297 // Check to see if the ruler constructor has
298 // already been called before otherwise
299 // we end up with over-scaled elements
300 if (ruler_tab.DPIScaleFactor == 0)
302 ruler_tab.DPIScaleFactor = GetDPIScaleFactor();
303 ruler_tab.width *= ruler_tab.DPIScaleFactor;
304 ruler_tab.height *= ruler_tab.DPIScaleFactor;
305 ruler_tab.height2 *= ruler_tab.DPIScaleFactor;
306 ruler_tab.width2 *= ruler_tab.DPIScaleFactor;
307 ruler_tab.cwidth *= ruler_tab.DPIScaleFactor;
308 ruler_tab.cwidth2 *= ruler_tab.DPIScaleFactor;
309 ruler_tab.cwidth3 *= ruler_tab.DPIScaleFactor;
310 ruler_tab.cwidth4 *= ruler_tab.DPIScaleFactor;
311 ruler_tab.dheight *= ruler_tab.DPIScaleFactor;
312 ruler_tab.dheight2 *= ruler_tab.DPIScaleFactor;
313 ruler_tab.dwidth *= ruler_tab.DPIScaleFactor;
314 ruler_tab.dwidth2 *= ruler_tab.DPIScaleFactor;
315 ruler_tab.dwidth3 *= ruler_tab.DPIScaleFactor;
316 ruler_tab.dwidth4 *= ruler_tab.DPIScaleFactor;
317 ruler_tab.textoff *= ruler_tab.DPIScaleFactor;
321 ImplInit( nWinStyle );
324 Ruler::~Ruler()
326 disposeOnce();
329 void Ruler::dispose()
331 if ( mnUpdateEvtId )
332 Application::RemoveUserEvent( mnUpdateEvtId );
333 delete mpSaveData;
334 mpSaveData = NULL;
335 delete mpDragData;
336 mpDragData = NULL;
337 if( pAccContext )
339 pAccContext->release();
340 pAccContext = NULL;
342 Window::dispose();
345 void Ruler::ImplVDrawLine(vcl::RenderContext& rRenderContext, long nX1, long nY1, long nX2, long nY2)
347 if ( nX1 < -RULER_CLIP )
349 nX1 = -RULER_CLIP;
350 if ( nX2 < -RULER_CLIP )
351 return;
353 long nClip = mnVirWidth + RULER_CLIP;
354 if ( nX2 > nClip )
356 nX2 = nClip;
357 if ( nX1 > nClip )
358 return;
361 if ( mnWinStyle & WB_HORZ )
362 rRenderContext.DrawLine( Point( nX1, nY1 ), Point( nX2, nY2 ) );
363 else
364 rRenderContext.DrawLine( Point( nY1, nX1 ), Point( nY2, nX2 ) );
367 void Ruler::ImplVDrawRect(vcl::RenderContext& rRenderContext, long nX1, long nY1, long nX2, long nY2)
369 if ( nX1 < -RULER_CLIP )
371 nX1 = -RULER_CLIP;
372 if ( nX2 < -RULER_CLIP )
373 return;
375 long nClip = mnVirWidth + RULER_CLIP;
376 if ( nX2 > nClip )
378 nX2 = nClip;
379 if ( nX1 > nClip )
380 return;
383 if ( mnWinStyle & WB_HORZ )
384 rRenderContext.DrawRect(Rectangle(nX1, nY1, nX2, nY2));
385 else
386 rRenderContext.DrawRect(Rectangle(nY1, nX1, nY2, nX2));
389 void Ruler::ImplVDrawText(vcl::RenderContext& rRenderContext, long nX, long nY, const OUString& rText, long nMin, long nMax)
391 Rectangle aRect;
392 rRenderContext.GetTextBoundRect(aRect, rText);
394 long nShiftX = ( aRect.GetWidth() / 2 ) + aRect.Left();
395 long nShiftY = ( aRect.GetHeight() / 2 ) + aRect.Top();
397 if ( (nX > -RULER_CLIP) && (nX < mnVirWidth + RULER_CLIP) && ( nX < nMax - nShiftX ) && ( nX > nMin + nShiftX ) )
399 if ( mnWinStyle & WB_HORZ )
400 rRenderContext.DrawText(Point(nX - nShiftX, nY - nShiftY), rText);
401 else
402 rRenderContext.DrawText(Point(nY - nShiftX, nX - nShiftY), rText);
406 void Ruler::ImplInvertLines(vcl::RenderContext& rRenderContext, bool bErase)
408 // Position lines
409 if (!mpData->pLines.empty() && mbActive && !mbDrag && !mbFormat && !(mnUpdateFlags & RULER_UPDATE_LINES) )
411 long nNullWinOff = mpData->nNullVirOff + mnVirOff;
412 long nRulX1 = mpData->nRulVirOff + mnVirOff;
413 long nRulX2 = nRulX1 + mpData->nRulWidth;
414 long nY = (RULER_OFF * 2) + mnVirHeight - 1;
416 // Calculate rectangle
417 Rectangle aRect;
418 if (mnWinStyle & WB_HORZ)
419 aRect.Bottom() = nY;
420 else
421 aRect.Right() = nY;
423 // Draw lines
424 for (sal_uInt32 i = 0; i < mpData->pLines.size(); i++)
426 const long n = mpData->pLines[i].nPos + nNullWinOff;
427 if ((n >= nRulX1) && (n < nRulX2))
429 if (mnWinStyle & WB_HORZ )
431 aRect.Left() = n;
432 aRect.Right() = n;
434 else
436 aRect.Top() = n;
437 aRect.Bottom() = n;
439 if (bErase)
441 Rectangle aTempRect = aRect;
443 if (mnWinStyle & WB_HORZ)
444 aTempRect.Bottom() = RULER_OFF - 1;
445 else
446 aTempRect.Right() = RULER_OFF - 1;
448 rRenderContext.Erase(aTempRect);
450 if (mnWinStyle & WB_HORZ)
452 aTempRect.Bottom() = aRect.Bottom();
453 aTempRect.Top() = aTempRect.Bottom() - RULER_OFF + 1;
455 else
457 aTempRect.Right() = aRect.Right();
458 aTempRect.Left() = aTempRect.Right() - RULER_OFF + 1;
460 rRenderContext.Erase(aTempRect);
462 Invert(aRect);
465 mnUpdateFlags = 0;
469 void Ruler::ImplDrawTicks(vcl::RenderContext& rRenderContext, long nMin, long nMax, long nStart, long nTop, long nBottom)
471 double nCenter = nTop + ((nBottom - nTop) / 2);
473 long nTickLength3 = (nBottom - nTop) * 0.5;
474 long nTickLength2 = nTickLength3 * 0.66;
475 long nTickLength1 = nTickLength2 * 0.66;
477 long nScale = ruler_tab.DPIScaleFactor;
478 long DPIOffset = nScale - 1;
480 double nTick4 = aImplRulerUnitTab[mnUnitIndex].nTick4;
481 double nTick2 = 0;
482 double nTickCount = aImplRulerUnitTab[mnUnitIndex].nTick1 / nScale;
483 double nTickUnit = 0;
484 long nTickWidth;
485 bool bNoTicks = false;
487 double nAcceptanceDelta = 0.0001;
489 Size aPixSize = rRenderContext.LogicToPixel(Size(nTick4, nTick4), maMapMode);
491 if (mnUnitIndex == RULER_UNIT_CHAR)
493 if (mnCharWidth == 0)
494 mnCharWidth = 371;
495 nTick4 = mnCharWidth * 2;
496 nTick2 = mnCharWidth;
497 nTickCount = mnCharWidth;
498 nTickUnit = mnCharWidth;
500 else if (mnUnitIndex == RULER_UNIT_LINE)
502 if (mnLineHeight == 0)
503 mnLineHeight = 551;
504 nTick4 = mnLineHeight * 2;
505 nTick2 = mnLineHeight;
506 nTickUnit = mnLineHeight;
507 nTickCount = mnLineHeight;
510 if (mnWinStyle & WB_HORZ)
512 nTickWidth = aPixSize.Width();
514 else
516 vcl::Font aFont = rRenderContext.GetFont();
517 if (mnWinStyle & WB_RIGHT_ALIGNED)
518 aFont.SetOrientation(2700);
519 else
520 aFont.SetOrientation(900);
521 rRenderContext.SetFont(aFont);
522 nTickWidth = aPixSize.Height();
525 long nMaxWidth = rRenderContext.PixelToLogic(Size(mpData->nPageWidth, 0), maMapMode).Width();
526 if (nMaxWidth < 0)
527 nMaxWidth = -nMaxWidth;
529 if ((mnUnitIndex == RULER_UNIT_CHAR) || (mnUnitIndex == RULER_UNIT_LINE))
530 nMaxWidth /= nTickUnit;
531 else
532 nMaxWidth /= aImplRulerUnitTab[mnUnitIndex].nTickUnit;
534 OUString aNumString = OUString::number(nMaxWidth);
535 long nTxtWidth = rRenderContext.GetTextWidth( aNumString );
536 const long nTextOff = 4;
538 // Determine the number divider for ruler drawn numbers - means which numbers
539 // should be shown on the ruler and which should be skipped because the ruler
540 // is not big enough to draw them
541 if (nTickWidth < nTxtWidth + nTextOff)
543 // Calculate the scale of the ruler
544 long nMulti = 1;
545 long nOrgTick4 = nTick4;
547 while (nTickWidth < nTxtWidth + nTextOff)
549 long nOldMulti = nMulti;
550 if (nTickWidth == 0)
551 nMulti *= 10;
552 else if (nMulti < 10)
553 nMulti++;
554 else if (nMulti < 100)
555 nMulti += 10;
556 else if (nMulti < 1000)
557 nMulti += 100;
558 else
559 nMulti += 1000;
561 // Overflow - in this case don't draw ticks and exit
562 if (nMulti < nOldMulti)
564 bNoTicks = true;
565 break;
568 nTick4 = nOrgTick4 * nMulti;
569 aPixSize = rRenderContext.LogicToPixel(Size(nTick4, nTick4), maMapMode);
570 if (mnWinStyle & WB_HORZ)
571 nTickWidth = aPixSize.Width();
572 else
573 nTickWidth = aPixSize.Height();
575 nTickCount = nTick4;
577 else
579 rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetShadowColor());
582 if (!bNoTicks)
584 long n = 0;
585 double nTick = 0.0;
586 double nTick3 = 0;
588 if ((mnUnitIndex != RULER_UNIT_CHAR) && (mnUnitIndex != RULER_UNIT_LINE))
590 nTick2 = aImplRulerUnitTab[mnUnitIndex].nTick2;
591 nTick3 = aImplRulerUnitTab[mnUnitIndex].nTick3;
594 Size nTickGapSize;
596 nTickGapSize = rRenderContext.LogicToPixel(Size(nTickCount, nTickCount), maMapMode);
597 long nTickGap1 = mnWinStyle & WB_HORZ ? nTickGapSize.Width() : nTickGapSize.Height();
598 nTickGapSize = rRenderContext.LogicToPixel(Size(nTick2, nTick2), maMapMode);
599 long nTickGap2 = mnWinStyle & WB_HORZ ? nTickGapSize.Width() : nTickGapSize.Height();
600 nTickGapSize = rRenderContext.LogicToPixel(Size(nTick3, nTick3), maMapMode);
601 long nTickGap3 = mnWinStyle & WB_HORZ ? nTickGapSize.Width() : nTickGapSize.Height();
603 while (((nStart - n) >= nMin) || ((nStart + n) <= nMax))
605 // Null point
606 if (nTick == 0.0)
608 if (nStart > nMin)
610 // 0 is only painted when Margin1 is not equal to zero
611 if ((mpData->nMargin1Style & RULER_STYLE_INVISIBLE) || (mpData->nMargin1 != 0))
613 aNumString = "0";
614 ImplVDrawText(rRenderContext, nStart, nCenter, aNumString);
618 else
620 aPixSize = rRenderContext.LogicToPixel(Size(nTick, nTick), maMapMode);
622 if (mnWinStyle & WB_HORZ)
623 n = aPixSize.Width();
624 else
625 n = aPixSize.Height();
627 // Tick4 - Output (Text)
628 double aStep = (nTick / nTick4);
629 double aRest = std::abs(aStep - std::floor(aStep));
631 if (aRest < nAcceptanceDelta)
633 if ((mnUnitIndex == RULER_UNIT_CHAR) || (mnUnitIndex == RULER_UNIT_LINE))
634 aNumString = OUString::number(nTick / nTickUnit);
635 else
636 aNumString = OUString::number(nTick / aImplRulerUnitTab[mnUnitIndex].nTickUnit);
638 long nHorizontalLocation = nStart + n;
639 ImplVDrawText(rRenderContext, nHorizontalLocation, nCenter, aNumString, nMin, nMax);
641 if (nMin < nHorizontalLocation && nHorizontalLocation < nMax)
643 ImplVDrawRect(rRenderContext, nHorizontalLocation, nBottom, nHorizontalLocation + DPIOffset, nBottom - 1 * nScale);
644 ImplVDrawRect(rRenderContext, nHorizontalLocation, nTop, nHorizontalLocation + DPIOffset, nTop + 1 * nScale);
647 nHorizontalLocation = nStart - n;
648 ImplVDrawText(rRenderContext, nHorizontalLocation, nCenter, aNumString, nMin, nMax);
650 if (nMin < nHorizontalLocation && nHorizontalLocation < nMax)
652 ImplVDrawRect(rRenderContext, nHorizontalLocation, nBottom,
653 nHorizontalLocation + DPIOffset, nBottom - 1 * nScale);
654 ImplVDrawRect(rRenderContext, nHorizontalLocation, nTop,
655 nHorizontalLocation + DPIOffset, nTop + 1 * nScale);
658 // Tick/Tick2 - Output (Strokes)
659 else
661 long nTickLength = nTickLength1;
663 aStep = (nTick / nTick2);
664 aRest = std::abs(aStep - std::floor(aStep));
665 if (aRest < nAcceptanceDelta)
666 nTickLength = nTickLength2;
668 aStep = (nTick / nTick3);
669 aRest = std::abs(aStep - std::floor(aStep));
670 if (aRest < nAcceptanceDelta )
671 nTickLength = nTickLength3;
673 if ((nTickLength == nTickLength1 && nTickGap1 > 6) ||
674 (nTickLength == nTickLength2 && nTickGap2 > 6) ||
675 (nTickLength == nTickLength3 && nTickGap3 > 6))
677 long nT1 = nCenter - (nTickLength / 2.0);
678 long nT2 = nT1 + nTickLength - 1;
679 long nT;
681 nT = nStart + n;
683 if (nT < nMax)
684 ImplVDrawRect(rRenderContext, nT, nT1, nT + DPIOffset, nT2);
685 nT = nStart - n;
686 if (nT > nMin)
687 ImplVDrawRect(rRenderContext, nT, nT1, nT + DPIOffset, nT2);
691 nTick += nTickCount;
696 void Ruler::ImplDrawBorders(vcl::RenderContext& rRenderContext, long nMin, long nMax, long nVirTop, long nVirBottom)
698 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
699 long n;
700 long n1;
701 long n2;
702 long nTemp1;
703 long nTemp2;
704 sal_uInt32 i;
706 for (i = 0; i < mpData->pBorders.size(); i++)
708 if (mpData->pBorders[i].nStyle & RULER_STYLE_INVISIBLE)
709 continue;
711 n1 = mpData->pBorders[i].nPos + mpData->nNullVirOff;
712 n2 = n1 + mpData->pBorders[i].nWidth;
714 if (((n1 >= nMin) && (n1 <= nMax)) || ((n2 >= nMin) && (n2 <= nMax)))
716 if ((n2 - n1) > 3)
718 rRenderContext.SetLineColor();
719 rRenderContext.SetFillColor(rStyleSettings.GetFaceColor());
720 ImplVDrawRect(rRenderContext, n1, nVirTop, n2, nVirBottom);
722 rRenderContext.SetLineColor(rStyleSettings.GetLightColor());
723 ImplVDrawLine(rRenderContext, n1 + 1, nVirTop, n1 + 1, nVirBottom);
724 ImplVDrawLine(rRenderContext, n1, nVirTop, n2, nVirTop);
726 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
727 ImplVDrawLine(rRenderContext, n1, nVirTop, n1, nVirBottom);
728 ImplVDrawLine(rRenderContext, n1, nVirBottom, n2, nVirBottom);
729 ImplVDrawLine(rRenderContext, n2 - 1, nVirTop, n2 - 1, nVirBottom);
731 rRenderContext.SetLineColor(rStyleSettings.GetDarkShadowColor());
732 ImplVDrawLine(rRenderContext, n2, nVirTop, n2, nVirBottom);
734 if (mpData->pBorders[i].nStyle & RULER_BORDER_VARIABLE)
736 if (n2 - n1 > RULER_VAR_SIZE + 4)
738 nTemp1 = n1 + (((n2 - n1 + 1) - RULER_VAR_SIZE) / 2);
739 nTemp2 = nVirTop + (((nVirBottom - nVirTop + 1) - RULER_VAR_SIZE) / 2);
740 long nTemp3 = nTemp1 + RULER_VAR_SIZE - 1;
741 long nTemp4 = nTemp2 + RULER_VAR_SIZE - 1;
742 long nTempY = nTemp2;
744 rRenderContext.SetLineColor(rStyleSettings.GetLightColor());
745 while (nTempY <= nTemp4)
747 ImplVDrawLine(rRenderContext, nTemp1, nTempY, nTemp3, nTempY);
748 nTempY += 2;
751 nTempY = nTemp2 + 1;
752 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
753 while (nTempY <= nTemp4)
755 ImplVDrawLine(rRenderContext, nTemp1, nTempY, nTemp3, nTempY);
756 nTempY += 2;
761 if (mpData->pBorders[i].nStyle & RULER_BORDER_SIZEABLE)
763 if (n2 - n1 > RULER_VAR_SIZE + 10)
765 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
766 ImplVDrawLine(rRenderContext, n1 + 4, nVirTop + 3, n1 + 4, nVirBottom - 3);
767 ImplVDrawLine(rRenderContext, n2 - 5, nVirTop + 3, n2 - 5, nVirBottom - 3);
768 rRenderContext.SetLineColor(rStyleSettings.GetLightColor());
769 ImplVDrawLine(rRenderContext, n1 + 5, nVirTop + 3, n1 + 5, nVirBottom - 3);
770 ImplVDrawLine(rRenderContext, n2 - 4, nVirTop + 3, n2 - 4, nVirBottom - 3);
774 else
776 n = n1 + ((n2 - n1) / 2);
777 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
779 if (mpData->pBorders[i].nStyle & RULER_BORDER_SNAP)
780 ImplVDrawLine(rRenderContext, n, nVirTop, n, nVirBottom);
781 else if (mpData->pBorders[i].nStyle & RULER_BORDER_MARGIN)
782 ImplVDrawLine(rRenderContext, n, nVirTop, n, nVirBottom);
783 else
785 ImplVDrawLine(rRenderContext, n - 1, nVirTop, n - 1, nVirBottom);
786 ImplVDrawLine(rRenderContext, n + 1, nVirTop, n + 1, nVirBottom);
787 rRenderContext.SetLineColor();
788 rRenderContext.SetFillColor(rStyleSettings.GetWindowColor());
789 ImplVDrawRect(rRenderContext, n, nVirTop, n, nVirBottom);
796 void Ruler::ImplDrawIndent(vcl::RenderContext& rRenderContext, const Polygon& rPoly, sal_uInt16 nStyle, bool bIsHit)
798 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
800 if (nStyle & RULER_STYLE_INVISIBLE)
801 return;
803 rRenderContext.SetLineColor(rStyleSettings.GetDarkShadowColor());
804 rRenderContext.SetFillColor(bIsHit ? rStyleSettings.GetDarkShadowColor() : rStyleSettings.GetWorkspaceColor());
805 rRenderContext.DrawPolygon(rPoly);
808 void Ruler::ImplDrawIndents(vcl::RenderContext& rRenderContext, long nMin, long nMax, long nVirTop, long nVirBottom)
810 sal_uInt32 j;
811 long n;
812 long nIndentHeight = (mnVirHeight / 2) - 1;
813 long nIndentWidth2 = nIndentHeight-3;
815 Polygon aPoly(5);
817 for (j = 0; j < mpData->pIndents.size(); j++)
819 if (mpData->pIndents[j].nStyle & RULER_STYLE_INVISIBLE)
820 continue;
822 sal_uInt16 nStyle = mpData->pIndents[j].nStyle;
823 sal_uInt16 nIndentStyle = nStyle & RULER_INDENT_STYLE;
825 n = mpData->pIndents[j].nPos+mpData->nNullVirOff;
827 if ((n >= nMin) && (n <= nMax))
829 if (nIndentStyle == RULER_INDENT_BORDER)
831 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
832 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
833 ImplVDrawLine(rRenderContext, n, nVirTop + 1, n, nVirBottom - 1);
835 else if (nIndentStyle == RULER_INDENT_BOTTOM)
837 aPoly.SetPoint(Point(n + 0, nVirBottom - nIndentHeight), 0);
838 aPoly.SetPoint(Point(n - nIndentWidth2, nVirBottom - 3), 1);
839 aPoly.SetPoint(Point(n - nIndentWidth2, nVirBottom), 2);
840 aPoly.SetPoint(Point(n + nIndentWidth2, nVirBottom), 3);
841 aPoly.SetPoint(Point(n + nIndentWidth2, nVirBottom - 3), 4);
843 else
845 aPoly.SetPoint(Point(n + 0, nVirTop + nIndentHeight), 0);
846 aPoly.SetPoint(Point(n - nIndentWidth2, nVirTop + 3), 1);
847 aPoly.SetPoint(Point(n - nIndentWidth2, nVirTop), 2);
848 aPoly.SetPoint(Point(n + nIndentWidth2, nVirTop), 3);
849 aPoly.SetPoint(Point(n + nIndentWidth2, nVirTop + 3), 4);
852 if (0 == (mnWinStyle & WB_HORZ))
854 Point aTmp;
855 for (sal_uInt16 i = 0; i < 5; i++)
857 aTmp = aPoly[i];
858 Point aSet(nVirBottom - aTmp.Y(), aTmp.X());
859 aPoly[i] = aSet;
862 if (RULER_INDENT_BORDER != nIndentStyle)
864 bool bIsHit = false;
865 if(mxCurrentHitTest.get() != NULL && mxCurrentHitTest->eType == RULER_TYPE_INDENT)
867 bIsHit = mxCurrentHitTest->nAryPos == j;
869 else if(mbDrag && meDragType == RULER_TYPE_INDENT)
871 bIsHit = mnDragAryPos == j;
873 ImplDrawIndent(rRenderContext, aPoly, nStyle, bIsHit);
879 static void ImplCenterTabPos(Point& rPos, sal_uInt16 nTabStyle)
881 bool bRTL = 0 != (nTabStyle & RULER_TAB_RTL);
882 nTabStyle &= RULER_TAB_STYLE;
883 rPos.Y() += ruler_tab.height/2;
885 if ( (!bRTL && nTabStyle == RULER_TAB_LEFT) ||
886 ( bRTL && nTabStyle == RULER_TAB_RIGHT) )
888 rPos.X() -= ruler_tab.width / 2;
890 else if ( (!bRTL && nTabStyle == RULER_TAB_RIGHT) ||
891 ( bRTL && nTabStyle == RULER_TAB_LEFT) )
893 rPos.X() += ruler_tab.width / 2;
897 static void lcl_RotateRect_Impl(Rectangle& rRect, const long nReference, bool bRightAligned)
899 if (!rRect.IsEmpty())
901 Rectangle aTmp(rRect);
902 rRect.Top() = aTmp.Left();
903 rRect.Bottom() = aTmp.Right();
904 rRect.Left() = aTmp.Top();
905 rRect.Right() = aTmp.Bottom();
907 if (bRightAligned)
909 long nRef = 2 * nReference;
910 rRect.Left() = nRef - rRect.Left();
911 rRect.Right() = nRef - rRect.Right();
916 static void ImplDrawRulerTab(vcl::RenderContext& rRenderContext, const Point& rPos,
917 sal_uInt16 nStyle, WinBits nWinBits)
919 if (nStyle & RULER_STYLE_INVISIBLE)
920 return;
922 sal_uInt16 nTabStyle = nStyle & RULER_TAB_STYLE;
923 bool bRTL = 0 != (nStyle & RULER_TAB_RTL);
925 // Scale by the screen DPI scaling factor
926 // However when doing this some of the rectangles
927 // drawn become asymmetric due to the +1 offsets
928 sal_uInt16 DPIOffset = rRenderContext.GetDPIScaleFactor() - 1;
930 Rectangle aRect1;
931 Rectangle aRect2;
932 Rectangle aRect3;
934 aRect3.SetEmpty();
936 if (nTabStyle == RULER_TAB_DEFAULT)
938 aRect1.Left() = rPos.X() - ruler_tab.dwidth2 + 1;
939 aRect1.Top() = rPos.Y() - ruler_tab.dheight2 + 1;
940 aRect1.Right() = rPos.X() - ruler_tab.dwidth2 + ruler_tab.dwidth + DPIOffset;
941 aRect1.Bottom() = rPos.Y();
943 aRect2.Left() = rPos.X() - ruler_tab.dwidth2 + ruler_tab.dwidth3;
944 aRect2.Top() = rPos.Y() - ruler_tab.dheight + 1;
945 aRect2.Right() = rPos.X() - ruler_tab.dwidth2 + ruler_tab.dwidth3 + ruler_tab.dwidth4 - 1;
946 aRect2.Bottom() = rPos.Y();
949 else if ((!bRTL && nTabStyle == RULER_TAB_LEFT) || (bRTL && nTabStyle == RULER_TAB_RIGHT))
951 aRect1.Left() = rPos.X();
952 aRect1.Top() = rPos.Y() - ruler_tab.height2 + 1;
953 aRect1.Right() = rPos.X() + ruler_tab.width - 1;
954 aRect1.Bottom() = rPos.Y();
956 aRect2.Left() = rPos.X();
957 aRect2.Top() = rPos.Y() - ruler_tab.height + 1;
958 aRect2.Right() = rPos.X() + ruler_tab.width2 - 1;
959 aRect2.Bottom() = rPos.Y();
961 else if ((!bRTL && nTabStyle == RULER_TAB_RIGHT) || (bRTL && nTabStyle == RULER_TAB_LEFT))
963 aRect1.Left() = rPos.X() - ruler_tab.width + 1;
964 aRect1.Top() = rPos.Y() - ruler_tab.height2 + 1;
965 aRect1.Right() = rPos.X();
966 aRect1.Bottom() = rPos.Y();
968 aRect2.Left() = rPos.X() - ruler_tab.width2 + 1;
969 aRect2.Top() = rPos.Y() - ruler_tab.height + 1;
970 aRect2.Right() = rPos.X();
971 aRect2.Bottom() = rPos.Y();
973 else
975 aRect1.Left() = rPos.X() - ruler_tab.cwidth2 + 1;
976 aRect1.Top() = rPos.Y() - ruler_tab.height2 + 1;
977 aRect1.Right() = rPos.X() - ruler_tab.cwidth2 + ruler_tab.cwidth + DPIOffset;
978 aRect1.Bottom() = rPos.Y();
980 aRect2.Left() = rPos.X() - ruler_tab.cwidth2 + ruler_tab.cwidth3;
981 aRect2.Top() = rPos.Y() - ruler_tab.height + 1;
982 aRect2.Right() = rPos.X() - ruler_tab.cwidth2 + ruler_tab.cwidth3 + ruler_tab.cwidth4 - 1;
983 aRect2.Bottom() = rPos.Y();
985 if (nTabStyle == RULER_TAB_DECIMAL)
987 aRect3.Left() = rPos.X() - ruler_tab.cwidth2 + ruler_tab.cwidth - 1;
988 aRect3.Top() = rPos.Y() - ruler_tab.height + 1 + 1 - DPIOffset;
989 aRect3.Right() = rPos.X() - ruler_tab.cwidth2 + ruler_tab.cwidth + DPIOffset;
990 aRect3.Bottom() = rPos.Y() - ruler_tab.height + 1 + 2;
993 if (0 == (nWinBits & WB_HORZ))
995 bool bRightAligned = 0 != (nWinBits & WB_RIGHT_ALIGNED);
996 lcl_RotateRect_Impl(aRect1, rPos.Y(), bRightAligned);
997 lcl_RotateRect_Impl(aRect2, rPos.Y(), bRightAligned);
998 lcl_RotateRect_Impl(aRect3, rPos.Y(), bRightAligned);
1000 rRenderContext.DrawRect(aRect1);
1001 rRenderContext.DrawRect(aRect2);
1003 if (!aRect3.IsEmpty())
1004 rRenderContext.DrawRect(aRect3);
1007 void Ruler::ImplDrawTab(vcl::RenderContext& rRenderContext, const Point& rPos, sal_uInt16 nStyle)
1009 if (nStyle & RULER_STYLE_INVISIBLE)
1010 return;
1012 rRenderContext.SetLineColor();
1014 if (nStyle & RULER_STYLE_DONTKNOW)
1015 rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetFaceColor());
1016 else
1017 rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetDarkShadowColor());
1019 if (mpData->bTextRTL)
1020 nStyle |= RULER_TAB_RTL;
1022 ImplDrawRulerTab(rRenderContext, rPos, nStyle, GetStyle());
1025 void Ruler::ImplDrawTabs(vcl::RenderContext& rRenderContext, long nMin, long nMax, long nVirTop, long nVirBottom)
1027 for (sal_uInt32 i = 0; i < mpData->pTabs.size(); i++)
1029 if (mpData->pTabs[i].nStyle & RULER_STYLE_INVISIBLE)
1030 continue;
1032 long aPosition;
1033 aPosition = mpData->pTabs[i].nPos;
1034 aPosition += +mpData->nNullVirOff;
1035 long nTopBottom = (GetStyle() & WB_RIGHT_ALIGNED) ? nVirTop : nVirBottom;
1036 if (nMin <= aPosition && aPosition <= nMax)
1037 ImplDrawTab(rRenderContext, Point( aPosition, nTopBottom ), mpData->pTabs[i].nStyle);
1041 static int adjustSize(int nOrig)
1043 if (nOrig <= 0)
1044 return 0;
1046 // make sure we return an odd number, that looks better in the ruler
1047 return ( (3*nOrig) / 8) * 2 + 1;
1050 void Ruler::ApplySettings(vcl::RenderContext& rRenderContext)
1052 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
1054 vcl::Font aFont = rStyleSettings.GetToolFont();
1055 // make the font a bit smaller than default
1056 Size aSize(adjustSize(aFont.GetSize().Width()), adjustSize(aFont.GetSize().Height()));
1057 aFont.SetSize(aSize);
1059 ApplyControlFont(rRenderContext, aFont);
1061 ApplyControlForeground(*this, rStyleSettings.GetDarkShadowColor());
1062 SetTextFillColor();
1064 Color aColor;
1065 svtools::ColorConfig aColorConfig;
1066 aColor = Color(aColorConfig.GetColorValue(svtools::APPBACKGROUND).nColor);
1067 ApplyControlBackground(rRenderContext, aColor);
1070 void Ruler::ImplInitSettings(bool bFont, bool bForeground, bool bBackground)
1072 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1074 if (bFont)
1076 vcl::Font aFont = rStyleSettings.GetToolFont();
1077 // make the font a bit smaller than default
1078 Size aSize(adjustSize(aFont.GetSize().Width()), adjustSize(aFont.GetSize().Height()));
1079 aFont.SetSize(aSize);
1081 ApplyControlFont(*this, aFont);
1084 if (bForeground || bFont)
1086 ApplyControlForeground(*this, rStyleSettings.GetDarkShadowColor());
1087 SetTextFillColor();
1090 if (bBackground)
1092 Color aColor;
1093 svtools::ColorConfig aColorConfig;
1094 aColor = Color(aColorConfig.GetColorValue(svtools::APPBACKGROUND).nColor);
1095 ApplyControlBackground(*this, aColor);
1098 maVirDev->SetSettings( GetSettings() );
1099 maVirDev->SetBackground( GetBackground() );
1100 vcl::Font aFont = GetFont();
1102 if (mnWinStyle & WB_VERT)
1103 aFont.SetOrientation(900);
1105 maVirDev->SetFont(aFont);
1106 maVirDev->SetTextColor(GetTextColor());
1107 maVirDev->SetTextFillColor(GetTextFillColor());
1110 void Ruler::ImplCalc()
1112 // calculate offset
1113 mpData->nRulVirOff = mnWinOff + mpData->nPageOff;
1114 if ( mpData->nRulVirOff > mnVirOff )
1115 mpData->nRulVirOff -= mnVirOff;
1116 else
1117 mpData->nRulVirOff = 0;
1118 long nRulWinOff = mpData->nRulVirOff+mnVirOff;
1120 // calculate non-visual part of the page
1121 long nNotVisPageWidth;
1122 if ( mpData->nPageOff < 0 )
1124 nNotVisPageWidth = -(mpData->nPageOff);
1125 if ( nRulWinOff < mnWinOff )
1126 nNotVisPageWidth -= mnWinOff-nRulWinOff;
1128 else
1129 nNotVisPageWidth = 0;
1131 // calculate width
1132 if ( mnWinStyle & WB_HORZ )
1134 if ( mbAutoWinWidth )
1135 mnWinWidth = mnWidth - mnVirOff;
1136 if ( mpData->bAutoPageWidth )
1137 mpData->nPageWidth = mnWinWidth;
1138 mpData->nRulWidth = std::min( mnWinWidth, mpData->nPageWidth-nNotVisPageWidth );
1139 if ( nRulWinOff+mpData->nRulWidth > mnWidth )
1140 mpData->nRulWidth = mnWidth-nRulWinOff;
1142 else
1144 if ( mbAutoWinWidth )
1145 mnWinWidth = mnHeight - mnVirOff;
1146 if ( mpData->bAutoPageWidth )
1147 mpData->nPageWidth = mnWinWidth;
1148 mpData->nRulWidth = std::min( mnWinWidth, mpData->nPageWidth-nNotVisPageWidth );
1149 if ( nRulWinOff+mpData->nRulWidth > mnHeight )
1150 mpData->nRulWidth = mnHeight-nRulWinOff;
1153 mbCalc = false;
1156 void Ruler::ImplFormat(vcl::RenderContext& rRenderContext)
1158 // if already formatted, don't do it again
1159 if (!mbFormat)
1160 return;
1162 // don't do anything if the window still has no size
1163 if (!mnVirWidth)
1164 return;
1166 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
1167 long nP1; // pixel position of Page1
1168 long nP2; // pixel position of Page2
1169 long nM1; // pixel position of Margin1
1170 long nM2; // pixel position of Margin2
1171 long nVirTop; // top/left corner
1172 long nVirBottom; // bottom/right corner
1173 long nVirLeft; // left/top corner
1174 long nVirRight; // right/bottom corner
1175 long nNullVirOff; // for faster calculation
1177 // calculate values
1178 if (mbCalc)
1179 ImplCalc();
1181 mpData->nNullVirOff = mnWinOff + mpData->nPageOff + mpData->nNullOff - mnVirOff;
1183 nNullVirOff = mpData->nNullVirOff;
1184 nVirLeft = mpData->nRulVirOff;
1185 nVirRight = nVirLeft + mpData->nRulWidth - 1;
1186 nVirTop = 0;
1187 nVirBottom = mnVirHeight - 1;
1189 if (!IsReallyVisible())
1190 return;
1192 Size aVirDevSize;
1194 // initialize VirtualDevice
1195 if (mnWinStyle & WB_HORZ)
1197 aVirDevSize.Width() = mnVirWidth;
1198 aVirDevSize.Height() = mnVirHeight;
1200 else
1202 aVirDevSize.Height() = mnVirWidth;
1203 aVirDevSize.Width() = mnVirHeight;
1205 if (aVirDevSize != maVirDev->GetOutputSizePixel())
1206 maVirDev->SetOutputSizePixel(aVirDevSize, true);
1207 else
1208 maVirDev->Erase();
1210 // calculate margins
1211 if (!(mpData->nMargin1Style & RULER_STYLE_INVISIBLE))
1213 nM1 = mpData->nMargin1 + nNullVirOff;
1214 if (mpData->bAutoPageWidth)
1216 nP1 = nVirLeft;
1217 if (nM1 < nVirLeft)
1218 nP1--;
1220 else
1221 nP1 = nNullVirOff - mpData->nNullOff;
1223 else
1225 nM1 = nVirLeft-1;
1226 nP1 = nM1;
1228 if (!(mpData->nMargin2Style & RULER_STYLE_INVISIBLE))
1230 nM2 = mpData->nMargin2 + nNullVirOff;
1231 if (mpData->bAutoPageWidth)
1233 nP2 = nVirRight;
1234 if (nM2 > nVirRight)
1235 nP2++;
1237 else
1238 nP2 = nNullVirOff - mpData->nNullOff + mpData->nPageWidth;
1239 if (nM2 > nP2)
1240 nM2 = nP2;
1242 else
1244 nM2 = nVirRight+1;
1245 nP2 = nM2;
1248 // top/bottom border
1249 maVirDev->SetLineColor(rStyleSettings.GetShadowColor());
1250 ImplVDrawLine(*maVirDev.get(), nVirLeft, nVirTop + 1, nM1, nVirTop + 1); //top left line
1251 ImplVDrawLine(*maVirDev.get(), nM2, nVirTop + 1, nP2 - 1, nVirTop + 1); //top right line
1253 nVirTop++;
1254 nVirBottom--;
1256 // draw margin1, margin2 and in-between
1257 maVirDev->SetLineColor();
1258 maVirDev->SetFillColor(rStyleSettings.GetDialogColor());
1259 if (nM1 > nVirLeft)
1260 ImplVDrawRect(*maVirDev.get(), nP1, nVirTop + 1, nM1, nVirBottom); //left gray rectangle
1261 if (nM2 < nP2)
1262 ImplVDrawRect(*maVirDev.get(), nM2, nVirTop + 1, nP2, nVirBottom); //right gray rectangle
1263 if (nM2 - nM1 > 0)
1265 maVirDev->SetFillColor(rStyleSettings.GetWindowColor());
1266 ImplVDrawRect(*maVirDev.get(), nM1 + 1, nVirTop, nM2 - 1, nVirBottom); //center rectangle
1268 maVirDev->SetLineColor(rStyleSettings.GetShadowColor());
1269 if (nM1 > nVirLeft)
1271 ImplVDrawLine(*maVirDev.get(), nM1, nVirTop + 1, nM1, nVirBottom); //right line of the left rectangle
1272 ImplVDrawLine(*maVirDev.get(), nP1, nVirBottom, nM1, nVirBottom); //bottom line of the left rectangle
1273 if (nP1 >= nVirLeft)
1275 ImplVDrawLine(*maVirDev.get(), nP1, nVirTop + 1, nP1, nVirBottom); //left line of the left rectangle
1276 ImplVDrawLine(*maVirDev.get(), nP1, nVirBottom, nP1 + 1, nVirBottom); //?
1279 if (nM2 < nP2)
1281 ImplVDrawLine(*maVirDev.get(), nM2, nVirBottom, nP2 - 1, nVirBottom); //bottom line of the right rectangle
1282 ImplVDrawLine(*maVirDev.get(), nM2, nVirTop + 1, nM2, nVirBottom); //left line of the right rectangle
1283 if (nP2 <= nVirRight + 1)
1284 ImplVDrawLine(*maVirDev.get(), nP2 - 1, nVirTop + 1, nP2 - 1, nVirBottom); //right line of the right rectangle
1287 long nMin = nVirLeft;
1288 long nMax = nP2;
1289 long nStart = 0;
1291 if (mpData->bTextRTL)
1292 nStart = mpData->nRightFrameMargin + nNullVirOff;
1293 else
1294 nStart = mpData->nLeftFrameMargin + nNullVirOff;
1296 if (nP1 > nVirLeft)
1297 nMin++;
1299 if (nP2 < nVirRight)
1300 nMax--;
1302 // Draw captions
1303 ImplDrawTicks(*maVirDev.get(), nMin, nMax, nStart, nVirTop, nVirBottom);
1305 // Draw borders
1306 if (!mpData->pBorders.empty())
1307 ImplDrawBorders(*maVirDev.get(), nVirLeft, nP2, nVirTop, nVirBottom);
1309 // Draw indents
1310 if (!mpData->pIndents.empty())
1311 ImplDrawIndents(*maVirDev.get(), nVirLeft, nP2, nVirTop - 1, nVirBottom + 1);
1313 // Tabs
1314 if (!mpData->pTabs.empty())
1315 ImplDrawTabs(*maVirDev.get(), nVirLeft, nP2, nVirTop-1, nVirBottom + 1);
1317 mbFormat = false;
1320 void Ruler::ImplInitExtraField( bool bUpdate )
1322 Size aWinSize = GetOutputSizePixel();
1324 // extra field evaluate
1325 if ( mnWinStyle & WB_EXTRAFIELD )
1327 maExtraRect.Left() = RULER_OFF;
1328 maExtraRect.Top() = RULER_OFF;
1329 maExtraRect.Right() = RULER_OFF + mnVirHeight - 1;
1330 maExtraRect.Bottom() = RULER_OFF + mnVirHeight - 1;
1331 if(mpData->bTextRTL)
1333 if(mnWinStyle & WB_HORZ)
1334 maExtraRect.Move(aWinSize.Width() - maExtraRect.GetWidth() - maExtraRect.Left(), 0);
1335 else
1336 maExtraRect.Move(0, aWinSize.Height() - maExtraRect.GetHeight() - maExtraRect.Top());
1337 mnVirOff = 0;
1339 else
1340 mnVirOff = maExtraRect.Right()+1;
1343 else
1345 maExtraRect.SetEmpty();
1346 mnVirOff = 0;
1349 // mnVirWidth depends on mnVirOff
1350 if ( (mnVirWidth > RULER_MIN_SIZE) ||
1351 ((aWinSize.Width() > RULER_MIN_SIZE) && (aWinSize.Height() > RULER_MIN_SIZE)) )
1353 if ( mnWinStyle & WB_HORZ )
1354 mnVirWidth = aWinSize.Width()-mnVirOff;
1355 else
1356 mnVirWidth = aWinSize.Height()-mnVirOff;
1358 if ( mnVirWidth < RULER_MIN_SIZE )
1359 mnVirWidth = 0;
1362 if ( bUpdate )
1364 mbCalc = true;
1365 mbFormat = true;
1366 Invalidate();
1370 void Ruler::ImplDraw(vcl::RenderContext& rRenderContext)
1372 if (mbFormat)
1374 ImplFormat(rRenderContext);
1377 if (IsReallyVisible())
1379 // output the ruler to the virtual device
1380 Point aOffPos;
1381 Size aVirDevSize = maVirDev->GetOutputSizePixel();
1383 if (mnWinStyle & WB_HORZ)
1385 aOffPos.X() = mnVirOff;
1386 if (mpData->bTextRTL)
1387 aVirDevSize.Width() -= maExtraRect.GetWidth();
1389 aOffPos.Y() = RULER_OFF;
1391 else
1393 aOffPos.X() = RULER_OFF;
1394 aOffPos.Y() = mnVirOff;
1396 rRenderContext.DrawOutDev(aOffPos, aVirDevSize, Point(), aVirDevSize, *maVirDev.get());
1398 // redraw positionlines
1399 ImplInvertLines(rRenderContext, true);
1403 void Ruler::ImplDrawExtra(vcl::RenderContext& rRenderContext, bool bPaint)
1405 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
1406 Rectangle aRect = maExtraRect;
1407 bool bEraseRect = false;
1409 aRect.Left() += 2;
1410 aRect.Top() += 2;
1411 aRect.Right() -= 2;
1412 aRect.Bottom() -= 2;
1414 if (!bPaint && !(mnExtraStyle & RULER_STYLE_HIGHLIGHT))
1416 rRenderContext.SetFillColor(rStyleSettings.GetWorkspaceColor());
1417 bEraseRect = true;
1419 else
1421 if (mnExtraStyle & RULER_STYLE_HIGHLIGHT)
1423 rRenderContext.SetFillColor(rStyleSettings.GetCheckedColor());
1424 bEraseRect = true;
1428 if (bEraseRect)
1430 rRenderContext.SetLineColor();
1431 rRenderContext.DrawRect(aRect);
1434 // output content
1435 if (meExtraType == RULER_EXTRA_NULLOFFSET)
1437 rRenderContext.SetLineColor(rStyleSettings.GetButtonTextColor());
1438 rRenderContext.DrawLine(Point(aRect.Left() + 1, aRect.Top() + 4),
1439 Point(aRect.Right() - 1, aRect.Top() + 4));
1440 rRenderContext.DrawLine(Point(aRect.Left() + 4, aRect.Top() + 1),
1441 Point(aRect.Left() + 4, aRect.Bottom() - 1));
1443 else if (meExtraType == RULER_EXTRA_TAB)
1445 sal_uInt16 nTabStyle = mnExtraStyle & RULER_TAB_STYLE;
1446 if (mpData->bTextRTL)
1447 nTabStyle |= RULER_TAB_RTL;
1448 Point aCenter = aRect.Center();
1449 Point aDraw(aCenter);
1450 ImplCenterTabPos(aDraw, nTabStyle);
1451 WinBits nWinBits = GetStyle();
1452 if (0 == (nWinBits & WB_HORZ))
1454 if ((nWinBits & WB_RIGHT_ALIGNED) != 0)
1455 aDraw.Y() = 2 * aCenter.Y() - aDraw.Y();
1457 if (mpData->bTextRTL)
1459 long nTemp = aDraw.X();
1460 aDraw.X() = aDraw.Y();
1461 aDraw.Y() = nTemp;
1464 ImplDrawTab(rRenderContext, aDraw, nTabStyle);
1468 void Ruler::ImplUpdate( bool bMustCalc )
1470 // clear lines in this place so they aren't considered at recalculation
1471 if (!mbFormat)
1472 Invalidate(INVALIDATE_NOERASE);
1474 // set flags
1475 if (bMustCalc)
1476 mbCalc = true;
1477 mbFormat = true;
1479 // abort if we are dragging as drag-handler will update the ruler after drag is finished
1480 if (mbDrag)
1481 return;
1483 // otherwise trigger update
1484 if (IsReallyVisible() && IsUpdateMode())
1486 Invalidate(INVALIDATE_NOERASE);
1490 bool Ruler::ImplHitTest( const Point& rPos, RulerSelection* pHitTest,
1491 bool bRequireStyle, sal_uInt16 nRequiredStyle ) const
1493 sal_Int32 i;
1494 sal_uInt16 nStyle;
1495 long nHitBottom;
1496 long nX;
1497 long nY;
1498 long n1;
1500 if ( !mbActive )
1501 return false;
1503 // determine positions
1504 bool bIsHori = 0 != (mnWinStyle & WB_HORZ);
1505 if ( bIsHori )
1507 nX = rPos.X();
1508 nY = rPos.Y();
1510 else
1512 nX = rPos.Y();
1513 nY = rPos.X();
1515 nHitBottom = mnVirHeight + (RULER_OFF * 2);
1517 // #i32608#
1518 pHitTest->nAryPos = 0;
1519 pHitTest->mnDragSize = 0;
1520 pHitTest->bSize = false;
1521 pHitTest->bSizeBar = false;
1523 // so that leftover tabs and indents are taken into account
1524 long nXExtraOff;
1525 if ( !mpData->pTabs.empty() || !mpData->pIndents.empty() )
1526 nXExtraOff = (mnVirHeight / 2) - 4;
1527 else
1528 nXExtraOff = 0;
1530 // test if outside
1531 nX -= mnVirOff;
1532 long nXTemp = nX;
1533 if ( (nX < mpData->nRulVirOff - nXExtraOff) ||
1534 (nX > mpData->nRulVirOff + mpData->nRulWidth + nXExtraOff) ||
1535 (nY < 0) ||
1536 (nY > nHitBottom) )
1538 pHitTest->nPos = 0;
1539 pHitTest->eType = RULER_TYPE_OUTSIDE;
1540 return false;
1543 nX -= mpData->nNullVirOff;
1544 pHitTest->nPos = nX;
1545 pHitTest->eType = RULER_TYPE_DONTKNOW;
1547 // first test the tabs
1548 Rectangle aRect;
1549 if ( !mpData->pTabs.empty() )
1551 aRect.Bottom() = nHitBottom;
1552 aRect.Top() = aRect.Bottom() - ruler_tab.height - RULER_OFF;
1554 for ( i = mpData->pTabs.size() - 1; i >= 0; i-- )
1556 nStyle = mpData->pTabs[i].nStyle;
1557 if ( !(nStyle & RULER_STYLE_INVISIBLE) )
1559 nStyle &= RULER_TAB_STYLE;
1561 // default tabs are only shown (no action)
1562 if ( nStyle != RULER_TAB_DEFAULT )
1564 n1 = mpData->pTabs[i].nPos;
1566 if ( nStyle == RULER_TAB_LEFT )
1568 aRect.Left() = n1;
1569 aRect.Right() = n1 + ruler_tab.width - 1;
1571 else if ( nStyle == RULER_TAB_RIGHT )
1573 aRect.Right() = n1;
1574 aRect.Left() = n1 - ruler_tab.width - 1;
1576 else
1578 aRect.Left() = n1 - ruler_tab.cwidth2 + 1;
1579 aRect.Right() = n1 - ruler_tab.cwidth2 + ruler_tab.cwidth;
1582 if ( aRect.IsInside( Point( nX, nY ) ) )
1584 pHitTest->eType = RULER_TYPE_TAB;
1585 pHitTest->nAryPos = i;
1586 return true;
1593 // Indents
1594 if ( !mpData->pIndents.empty() )
1596 long nIndentHeight = (mnVirHeight / 2) - 1;
1597 long nIndentWidth2 = nIndentHeight - 3;
1599 for ( i = mpData->pIndents.size(); i; i-- )
1601 nStyle = mpData->pIndents[i-1].nStyle;
1602 if ( (! bRequireStyle || nStyle == nRequiredStyle) &&
1603 !(nStyle & RULER_STYLE_INVISIBLE) )
1605 nStyle &= RULER_INDENT_STYLE;
1606 n1 = mpData->pIndents[i-1].nPos;
1608 if ( (nStyle == RULER_INDENT_BOTTOM) != !bIsHori )
1610 aRect.Left() = n1-nIndentWidth2;
1611 aRect.Right() = n1+nIndentWidth2;
1612 aRect.Top() = nHitBottom-nIndentHeight-RULER_OFF+1;
1613 aRect.Bottom() = nHitBottom;
1615 else
1617 aRect.Left() = n1-nIndentWidth2;
1618 aRect.Right() = n1+nIndentWidth2;
1619 aRect.Top() = 0;
1620 aRect.Bottom() = nIndentHeight+RULER_OFF-1;
1623 if ( aRect.IsInside( Point( nX, nY ) ) )
1625 pHitTest->eType = RULER_TYPE_INDENT;
1626 pHitTest->nAryPos = i-1;
1627 return true;
1633 // everything left and right is outside and don't take this into account
1634 if ( (nXTemp < mpData->nRulVirOff) || (nXTemp > mpData->nRulVirOff+mpData->nRulWidth) )
1636 pHitTest->nPos = 0;
1637 pHitTest->eType = RULER_TYPE_OUTSIDE;
1638 return false;
1641 // test the borders
1642 int nBorderTolerance = 1;
1643 if(pHitTest->bExpandTest)
1645 nBorderTolerance++;
1648 for ( i = mpData->pBorders.size(); i; i-- )
1650 n1 = mpData->pBorders[i-1].nPos;
1651 long n2 = n1 + mpData->pBorders[i-1].nWidth;
1653 // borders have at least 3 pixel padding
1654 if ( !mpData->pBorders[i-1].nWidth )
1656 n1 -= nBorderTolerance;
1657 n2 += nBorderTolerance;
1661 if ( (nX >= n1) && (nX <= n2) )
1663 nStyle = mpData->pBorders[i-1].nStyle;
1664 if ( !(nStyle & RULER_STYLE_INVISIBLE) )
1666 pHitTest->eType = RULER_TYPE_BORDER;
1667 pHitTest->nAryPos = i-1;
1669 if ( !(nStyle & RULER_BORDER_SIZEABLE) )
1671 if ( nStyle & RULER_BORDER_MOVEABLE )
1673 pHitTest->bSizeBar = true;
1674 pHitTest->mnDragSize = RULER_DRAGSIZE_MOVE;
1677 else
1679 long nMOff = RULER_MOUSE_BORDERWIDTH;
1680 while ( nMOff*2 >= (n2-n1-RULER_MOUSE_BORDERMOVE) )
1682 if ( nMOff < 2 )
1684 nMOff = 0;
1685 break;
1687 else
1688 nMOff--;
1691 if ( nX <= n1+nMOff )
1693 pHitTest->bSize = true;
1694 pHitTest->mnDragSize = RULER_DRAGSIZE_1;
1696 else if ( nX >= n2-nMOff )
1698 pHitTest->bSize = true;
1699 pHitTest->mnDragSize = RULER_DRAGSIZE_2;
1701 else
1703 if ( nStyle & RULER_BORDER_MOVEABLE )
1705 pHitTest->bSizeBar = true;
1706 pHitTest->mnDragSize = RULER_DRAGSIZE_MOVE;
1711 return true;
1716 // Margins
1717 int nMarginTolerance = pHitTest->bExpandTest ? nBorderTolerance : RULER_MOUSE_MARGINWIDTH;
1719 if ( (mpData->nMargin1Style & (RULER_MARGIN_SIZEABLE | RULER_STYLE_INVISIBLE)) == RULER_MARGIN_SIZEABLE )
1721 n1 = mpData->nMargin1;
1722 if ( (nX >= n1 - nMarginTolerance) && (nX <= n1 + nMarginTolerance) )
1724 pHitTest->eType = RULER_TYPE_MARGIN1;
1725 pHitTest->bSize = true;
1726 return true;
1729 if ( (mpData->nMargin2Style & (RULER_MARGIN_SIZEABLE | RULER_STYLE_INVISIBLE)) == RULER_MARGIN_SIZEABLE )
1731 n1 = mpData->nMargin2;
1732 if ( (nX >= n1 - nMarginTolerance) && (nX <= n1 + nMarginTolerance) )
1734 pHitTest->eType = RULER_TYPE_MARGIN2;
1735 pHitTest->bSize = true;
1736 return true;
1740 // test tabs again
1741 if ( !mpData->pTabs.empty() )
1743 aRect.Top() = RULER_OFF;
1744 aRect.Bottom() = nHitBottom;
1746 for ( i = mpData->pTabs.size() - 1; i >= 0; i-- )
1748 nStyle = mpData->pTabs[i].nStyle;
1749 if ( !(nStyle & RULER_STYLE_INVISIBLE) )
1751 nStyle &= RULER_TAB_STYLE;
1753 // default tabs are only shown (no action)
1754 if ( nStyle != RULER_TAB_DEFAULT )
1756 n1 = mpData->pTabs[i].nPos;
1758 if ( nStyle == RULER_TAB_LEFT )
1760 aRect.Left() = n1;
1761 aRect.Right() = n1 + ruler_tab.width - 1;
1763 else if ( nStyle == RULER_TAB_RIGHT )
1765 aRect.Right() = n1;
1766 aRect.Left() = n1 - ruler_tab.width - 1;
1768 else
1770 aRect.Left() = n1 - ruler_tab.cwidth2 + 1;
1771 aRect.Right() = n1 - ruler_tab.cwidth2 + ruler_tab.cwidth;
1774 aRect.Left()--;
1775 aRect.Right()++;
1777 if ( aRect.IsInside( Point( nX, nY ) ) )
1779 pHitTest->eType = RULER_TYPE_TAB;
1780 pHitTest->nAryPos = i;
1781 return true;
1788 return false;
1791 bool Ruler::ImplDocHitTest( const Point& rPos, RulerType eDragType,
1792 RulerSelection* pHitTest ) const
1794 Point aPos = rPos;
1795 bool bRequiredStyle = false;
1796 sal_uInt16 nRequiredStyle = 0;
1798 if (eDragType == RULER_TYPE_INDENT)
1800 bRequiredStyle = true;
1801 nRequiredStyle = RULER_INDENT_BOTTOM;
1804 if ( mnWinStyle & WB_HORZ )
1805 aPos.X() += mnWinOff;
1806 else
1807 aPos.Y() += mnWinOff;
1809 if ( (eDragType == RULER_TYPE_INDENT) || (eDragType == RULER_TYPE_DONTKNOW) )
1811 if ( mnWinStyle & WB_HORZ )
1812 aPos.Y() = RULER_OFF + 1;
1813 else
1814 aPos.X() = RULER_OFF + 1;
1816 if ( ImplHitTest( aPos, pHitTest, bRequiredStyle, nRequiredStyle ) )
1818 if ( (pHitTest->eType == eDragType) || (eDragType == RULER_TYPE_DONTKNOW) )
1819 return true;
1823 if ( (eDragType == RULER_TYPE_INDENT) ||
1824 (eDragType == RULER_TYPE_TAB) ||
1825 (eDragType == RULER_TYPE_DONTKNOW) )
1827 if ( mnWinStyle & WB_HORZ )
1828 aPos.Y() = mnHeight - RULER_OFF - 1;
1829 else
1830 aPos.X() = mnWidth - RULER_OFF - 1;
1832 if ( ImplHitTest( aPos, pHitTest, bRequiredStyle, nRequiredStyle ) )
1834 if ( (pHitTest->eType == eDragType) || (eDragType == RULER_TYPE_DONTKNOW) )
1835 return true;
1839 if ( (eDragType == RULER_TYPE_MARGIN1) || (eDragType == RULER_TYPE_MARGIN2) ||
1840 (eDragType == RULER_TYPE_BORDER) || (eDragType == RULER_TYPE_DONTKNOW) )
1842 if ( mnWinStyle & WB_HORZ )
1843 aPos.Y() = RULER_OFF + (mnVirHeight / 2);
1844 else
1845 aPos.X() = RULER_OFF + (mnVirHeight / 2);
1847 if ( ImplHitTest( aPos, pHitTest ) )
1849 if ( (pHitTest->eType == eDragType) || (eDragType == RULER_TYPE_DONTKNOW) )
1850 return true;
1854 pHitTest->eType = RULER_TYPE_DONTKNOW;
1856 return false;
1859 bool Ruler::ImplStartDrag( RulerSelection* pHitTest, sal_uInt16 nModifier )
1861 // don't trigger drag if a border that was clicked can not be changed
1862 if ( (pHitTest->eType == RULER_TYPE_BORDER) &&
1863 !pHitTest->bSize && !pHitTest->bSizeBar )
1864 return false;
1866 // Set drag data
1867 meDragType = pHitTest->eType;
1868 mnDragPos = pHitTest->nPos;
1869 mnDragAryPos = pHitTest->nAryPos;
1870 mnDragSize = pHitTest->mnDragSize;
1871 mnDragModifier = nModifier;
1872 *mpDragData = *mpSaveData;
1873 mpData = mpDragData;
1875 // call handler
1876 if (StartDrag())
1878 // if the handler allows dragging, initialize dragging
1879 mbDrag = true;
1880 mnStartDragPos = mnDragPos;
1881 StartTracking();
1882 Invalidate(INVALIDATE_NOERASE);
1883 return true;
1885 else
1887 // otherwise reset the data
1888 meDragType = RULER_TYPE_DONTKNOW;
1889 mnDragPos = 0;
1890 mnDragAryPos = 0;
1891 mnDragSize = 0;
1892 mnDragModifier = 0;
1893 mpData = mpSaveData;
1896 return false;
1899 void Ruler::ImplDrag( const Point& rPos )
1901 long nX;
1902 long nY;
1903 long nOutHeight;
1905 if ( mnWinStyle & WB_HORZ )
1907 nX = rPos.X();
1908 nY = rPos.Y();
1909 nOutHeight = mnHeight;
1911 else
1913 nX = rPos.Y();
1914 nY = rPos.X();
1915 nOutHeight = mnWidth;
1918 // calculate and fit X
1919 nX -= mnVirOff;
1920 if ( nX < mpData->nRulVirOff )
1922 nX = mpData->nRulVirOff;
1924 else if ( nX > mpData->nRulVirOff+mpData->nRulWidth )
1926 nX = mpData->nRulVirOff+mpData->nRulWidth;
1928 nX -= mpData->nNullVirOff;
1930 // if upper or left from ruler, then consider old values
1931 mbDragDelete = false;
1932 if ( nY < 0 )
1934 if ( !mbDragCanceled )
1936 // reset the data
1937 mbDragCanceled = true;
1938 ImplRulerData aTempData;
1939 aTempData = *mpDragData;
1940 *mpDragData = *mpSaveData;
1941 mbCalc = true;
1942 mbFormat = true;
1944 // call handler
1945 mnDragPos = mnStartDragPos;
1946 Drag();
1948 // and redraw
1949 Invalidate(INVALIDATE_NOERASE);
1951 // reset the data as before cancel
1952 *mpDragData = aTempData;
1955 else
1957 mbDragCanceled = false;
1959 // +2, so the tabs are not cleared too quickly
1960 if ( nY > nOutHeight + 2 )
1961 mbDragDelete = true;
1963 mnDragPos = nX;
1965 // call handler
1966 Drag();
1968 // redraw
1969 if (mbFormat)
1970 Invalidate(INVALIDATE_NOERASE);
1974 void Ruler::ImplEndDrag()
1976 // get values
1977 if ( mbDragCanceled )
1978 *mpDragData = *mpSaveData;
1979 else
1980 *mpSaveData = *mpDragData;
1982 mpData = mpSaveData;
1983 mbDrag = false;
1985 // call handler
1986 EndDrag();
1988 // reset drag values
1989 meDragType = RULER_TYPE_DONTKNOW;
1990 mnDragPos = 0;
1991 mnDragAryPos = 0;
1992 mnDragSize = 0;
1993 mbDragCanceled = false;
1994 mbDragDelete = false;
1995 mnDragModifier = 0;
1996 mnStartDragPos = 0;
1998 // redraw
1999 Invalidate(INVALIDATE_NOERASE);
2002 void Ruler::MouseButtonDown( const MouseEvent& rMEvt )
2004 if ( rMEvt.IsLeft() && !IsTracking() )
2006 Point aMousePos = rMEvt.GetPosPixel();
2007 sal_uInt16 nMouseClicks = rMEvt.GetClicks();
2008 sal_uInt16 nMouseModifier = rMEvt.GetModifier();
2010 // update ruler
2011 if ( mbFormat )
2013 Invalidate(INVALIDATE_NOERASE);
2016 if ( maExtraRect.IsInside( aMousePos ) )
2018 mnExtraClicks = nMouseClicks;
2019 mnExtraModifier = nMouseModifier;
2020 ExtraDown();
2021 mnExtraClicks = 0;
2022 mnExtraModifier = 0;
2024 else
2026 boost::scoped_ptr<RulerSelection> pHitTest(new RulerSelection);
2027 bool bHitTestResult = ImplHitTest(aMousePos, pHitTest.get());
2029 if ( nMouseClicks == 1 )
2031 if ( bHitTestResult )
2033 ImplStartDrag( pHitTest.get(), nMouseModifier );
2035 else
2037 // calculate position inside of ruler area
2038 if ( pHitTest->eType == RULER_TYPE_DONTKNOW )
2040 mnDragPos = pHitTest->nPos;
2041 Click();
2042 mnDragPos = 0;
2044 // call HitTest again as a click, for example, could set a new tab
2045 if ( ImplHitTest(aMousePos, pHitTest.get()) )
2046 ImplStartDrag(pHitTest.get(), nMouseModifier);
2050 else
2052 if (bHitTestResult)
2054 mnDragPos = pHitTest->nPos;
2055 mnDragAryPos = pHitTest->nAryPos;
2057 meDragType = pHitTest->eType;
2059 DoubleClick();
2061 meDragType = RULER_TYPE_DONTKNOW;
2062 mnDragPos = 0;
2063 mnDragAryPos = 0;
2069 void Ruler::MouseMove( const MouseEvent& rMEvt )
2071 PointerStyle ePtrStyle = PointerStyle::Arrow;
2073 mxPreviousHitTest.swap(mxCurrentHitTest);
2075 mxCurrentHitTest.reset(new RulerSelection);
2077 maHoverSelection.eType = RULER_TYPE_DONTKNOW;
2079 if (ImplHitTest( rMEvt.GetPosPixel(), mxCurrentHitTest.get() ))
2081 maHoverSelection = *mxCurrentHitTest.get();
2083 if (mxCurrentHitTest->bSize)
2085 if (mnWinStyle & WB_HORZ)
2087 if (mxCurrentHitTest->mnDragSize == RULER_DRAGSIZE_1)
2088 ePtrStyle = PointerStyle::TabSelectW;
2089 else if (mxCurrentHitTest->mnDragSize == RULER_DRAGSIZE_2)
2090 ePtrStyle = PointerStyle::TabSelectE;
2091 else
2092 ePtrStyle = PointerStyle::ESize;
2094 else
2096 if (mxCurrentHitTest->mnDragSize == RULER_DRAGSIZE_1)
2097 ePtrStyle = PointerStyle::WindowNSize;
2098 else if (mxCurrentHitTest->mnDragSize == RULER_DRAGSIZE_2)
2099 ePtrStyle = PointerStyle::WindowSSize;
2100 else
2101 ePtrStyle = PointerStyle::SSize;
2104 else if (mxCurrentHitTest->bSizeBar)
2106 if (mnWinStyle & WB_HORZ)
2107 ePtrStyle = PointerStyle::HSizeBar;
2108 else
2109 ePtrStyle = PointerStyle::VSizeBar;
2113 if (mxPreviousHitTest.get() != NULL && mxPreviousHitTest->eType != mxCurrentHitTest->eType)
2115 mbFormat = true;
2118 SetPointer( Pointer(ePtrStyle) );
2120 if (mbFormat)
2122 Invalidate(INVALIDATE_NOERASE);
2126 void Ruler::Tracking( const TrackingEvent& rTEvt )
2128 if ( rTEvt.IsTrackingEnded() )
2130 // reset the old state at cancel
2131 if ( rTEvt.IsTrackingCanceled() )
2133 mbDragCanceled = true;
2134 mbFormat = true;
2137 ImplEndDrag();
2139 else
2140 ImplDrag( rTEvt.GetMouseEvent().GetPosPixel() );
2143 void Ruler::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
2145 ImplDraw(rRenderContext);
2147 // consider extra field
2148 if (mnWinStyle & WB_EXTRAFIELD)
2149 ImplDrawExtra(rRenderContext, true);
2152 void Ruler::Resize()
2154 Size aWinSize = GetOutputSizePixel();
2156 long nNewHeight;
2157 if ( mnWinStyle & WB_HORZ )
2159 if ( aWinSize.Height() != mnHeight )
2160 nNewHeight = aWinSize.Height();
2161 else
2162 nNewHeight = 0;
2164 else
2166 if ( aWinSize.Width() != mnWidth )
2167 nNewHeight = aWinSize.Width();
2168 else
2169 nNewHeight = 0;
2172 mbFormat = true;
2174 // clear lines
2175 bool bVisible = IsReallyVisible();
2176 if ( bVisible && !mpData->pLines.empty() )
2178 mnUpdateFlags |= RULER_UPDATE_LINES;
2179 Invalidate(INVALIDATE_NOERASE);
2182 // recalculate some values if the height/width changes
2183 // extra field should always be updated
2184 ImplInitExtraField( mpData->bTextRTL );
2185 if ( nNewHeight )
2187 mbCalc = true;
2188 mnVirHeight = nNewHeight - mnBorderWidth - ( RULER_OFF * 2 );
2190 else
2192 if ( mpData->bAutoPageWidth )
2193 ImplUpdate( true );
2194 else if ( mbAutoWinWidth )
2195 mbCalc = true;
2198 // clear part of the border
2199 if ( bVisible )
2201 if ( nNewHeight )
2202 Invalidate(INVALIDATE_NOERASE);
2203 else if ( mpData->bAutoPageWidth )
2205 // only at AutoPageWidth muss we redraw
2206 Rectangle aRect;
2208 if ( mnWinStyle & WB_HORZ )
2210 if ( mnWidth < aWinSize.Width() )
2211 aRect.Left() = mnWidth - RULER_RESIZE_OFF;
2212 else
2213 aRect.Left() = aWinSize.Width() - RULER_RESIZE_OFF;
2214 aRect.Right() = aRect.Left() + RULER_RESIZE_OFF;
2215 aRect.Top() = RULER_OFF;
2216 aRect.Bottom() = RULER_OFF + mnVirHeight;
2218 else
2220 if ( mnHeight < aWinSize.Height() )
2221 aRect.Top() = mnHeight-RULER_RESIZE_OFF;
2222 else
2223 aRect.Top() = aWinSize.Height()-RULER_RESIZE_OFF;
2224 aRect.Bottom() = aRect.Top() + RULER_RESIZE_OFF;
2225 aRect.Left() = RULER_OFF;
2226 aRect.Right() = RULER_OFF + mnVirHeight;
2229 Invalidate(aRect, INVALIDATE_NOERASE);
2233 mnWidth = aWinSize.Width();
2234 mnHeight = aWinSize.Height();
2237 void Ruler::StateChanged( StateChangedType nType )
2239 Window::StateChanged( nType );
2241 if ( nType == StateChangedType::InitShow )
2242 Invalidate();
2243 else if ( nType == StateChangedType::UpdateMode )
2245 if ( IsReallyVisible() && IsUpdateMode() )
2246 Invalidate();
2248 else if ( (nType == StateChangedType::Zoom) ||
2249 (nType == StateChangedType::ControlFont) )
2251 ImplInitSettings( true, false, false );
2252 Invalidate();
2254 else if ( nType == StateChangedType::ControlForeground )
2256 ImplInitSettings( false, true, false );
2257 Invalidate();
2259 else if ( nType == StateChangedType::ControlBackground )
2261 ImplInitSettings( false, false, true );
2262 Invalidate();
2266 void Ruler::DataChanged( const DataChangedEvent& rDCEvt )
2268 Window::DataChanged( rDCEvt );
2270 if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
2271 (rDCEvt.GetType() == DataChangedEventType::DISPLAY) ||
2272 (rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) ||
2273 ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
2274 (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
2276 mbFormat = true;
2277 ImplInitSettings( true, true, true );
2278 Invalidate();
2282 bool Ruler::StartDrag()
2284 if ( maStartDragHdl.IsSet() )
2285 return maStartDragHdl.Call( this );
2286 else
2287 return false;
2290 void Ruler::Drag()
2292 maDragHdl.Call( this );
2295 void Ruler::EndDrag()
2297 maEndDragHdl.Call( this );
2300 void Ruler::Click()
2302 maClickHdl.Call( this );
2305 void Ruler::DoubleClick()
2307 maDoubleClickHdl.Call( this );
2310 void Ruler::ExtraDown()
2312 maExtraDownHdl.Call( this );
2315 void Ruler::Activate()
2317 mbActive = true;
2319 // update positionlies - draw is delayed
2320 mnUpdateFlags |= RULER_UPDATE_LINES;
2321 Invalidate(INVALIDATE_NOERASE);
2324 void Ruler::Deactivate()
2326 // clear positionlines
2327 Invalidate(INVALIDATE_NOERASE);
2329 mbActive = false;
2332 bool Ruler::StartDocDrag( const MouseEvent& rMEvt, RulerType eDragType )
2334 if ( !mbDrag )
2336 Point aMousePos = rMEvt.GetPosPixel();
2337 sal_uInt16 nMouseClicks = rMEvt.GetClicks();
2338 sal_uInt16 nMouseModifier = rMEvt.GetModifier();
2339 RulerSelection aHitTest;
2341 if(eDragType != RULER_TYPE_DONTKNOW)
2342 aHitTest.bExpandTest = true;
2344 // update ruler
2345 if ( mbFormat )
2347 if (!IsReallyVisible())
2349 // set mpData for ImplDocHitTest()
2350 ImplFormat(*this);
2353 Invalidate(INVALIDATE_NOERASE);
2356 if ( nMouseClicks == 1 )
2358 if ( ImplDocHitTest( aMousePos, eDragType, &aHitTest ) )
2360 Pointer aPtr;
2362 if ( aHitTest.bSize )
2364 if ( mnWinStyle & WB_HORZ )
2365 aPtr = Pointer( PointerStyle::ESize );
2366 else
2367 aPtr = Pointer( PointerStyle::SSize );
2369 else if ( aHitTest.bSizeBar )
2371 if ( mnWinStyle & WB_HORZ )
2372 aPtr = Pointer( PointerStyle::HSizeBar );
2373 else
2374 aPtr = Pointer( PointerStyle::VSizeBar );
2376 SetPointer( aPtr );
2377 return ImplStartDrag( &aHitTest, nMouseModifier );
2380 else if ( nMouseClicks == 2 )
2382 if ( ImplDocHitTest( aMousePos, eDragType, &aHitTest ) )
2384 mnDragPos = aHitTest.nPos;
2385 mnDragAryPos = aHitTest.nAryPos;
2387 eDragType = aHitTest.eType;
2389 DoubleClick();
2391 eDragType = RULER_TYPE_DONTKNOW;
2392 mnDragPos = 0;
2393 mnDragAryPos = 0;
2395 return true;
2399 return false;
2402 void Ruler::CancelDrag()
2404 if ( mbDrag )
2406 ImplDrag( Point( -1, -1 ) );
2407 ImplEndDrag();
2411 RulerType Ruler::GetType( const Point& rPos, sal_uInt16* pAryPos )
2413 RulerSelection aHitTest;
2415 // update ruler
2416 if ( IsReallyVisible() && mbFormat )
2418 Invalidate(INVALIDATE_NOERASE);
2421 (void)ImplHitTest(rPos, &aHitTest);
2423 // return values
2424 if ( pAryPos )
2425 *pAryPos = aHitTest.nAryPos;
2426 return aHitTest.eType;
2429 void Ruler::SetWinPos( long nNewOff, long nNewWidth )
2431 // should widths be automatically calculated
2432 if ( !nNewWidth )
2433 mbAutoWinWidth = true;
2434 else
2435 mbAutoWinWidth = false;
2437 mnWinOff = nNewOff;
2438 mnWinWidth = nNewWidth;
2439 ImplUpdate( true );
2442 void Ruler::SetPagePos( long nNewOff, long nNewWidth )
2444 // should we do anything?
2445 if ( (mpData->nPageOff == nNewOff) && (mpData->nPageWidth == nNewWidth) )
2446 return;
2448 // should widths be automatically calculated
2449 if ( !nNewWidth )
2450 mpData->bAutoPageWidth = true;
2451 else
2452 mpData->bAutoPageWidth = false;
2454 mpData->nPageOff = nNewOff;
2455 mpData->nPageWidth = nNewWidth;
2456 ImplUpdate( true );
2459 void Ruler::SetBorderPos( long nOff )
2461 if ( mnWinStyle & WB_BORDER )
2463 if ( mnBorderOff != nOff )
2465 mnBorderOff = nOff;
2467 if ( IsReallyVisible() && IsUpdateMode() )
2468 Invalidate(INVALIDATE_NOERASE);
2473 void Ruler::SetUnit( FieldUnit eNewUnit )
2475 if ( meUnit != eNewUnit )
2477 meUnit = eNewUnit;
2478 switch ( meUnit )
2480 case FUNIT_MM:
2481 mnUnitIndex = RULER_UNIT_MM;
2482 break;
2483 case FUNIT_CM:
2484 mnUnitIndex = RULER_UNIT_CM;
2485 break;
2486 case FUNIT_M:
2487 mnUnitIndex = RULER_UNIT_M;
2488 break;
2489 case FUNIT_KM:
2490 mnUnitIndex = RULER_UNIT_KM;
2491 break;
2492 case FUNIT_INCH:
2493 mnUnitIndex = RULER_UNIT_INCH;
2494 break;
2495 case FUNIT_FOOT:
2496 mnUnitIndex = RULER_UNIT_FOOT;
2497 break;
2498 case FUNIT_MILE:
2499 mnUnitIndex = RULER_UNIT_MILE;
2500 break;
2501 case FUNIT_POINT:
2502 mnUnitIndex = RULER_UNIT_POINT;
2503 break;
2504 case FUNIT_PICA:
2505 mnUnitIndex = RULER_UNIT_PICA;
2506 break;
2507 case FUNIT_CHAR:
2508 mnUnitIndex = RULER_UNIT_CHAR;
2509 break;
2510 case FUNIT_LINE:
2511 mnUnitIndex = RULER_UNIT_LINE;
2512 break;
2513 default:
2514 SAL_WARN( "svtools.control", "Ruler::SetUnit() - Wrong Unit" );
2515 break;
2518 maMapMode.SetMapUnit( aImplRulerUnitTab[mnUnitIndex].eMapUnit );
2519 ImplUpdate();
2523 void Ruler::SetZoom( const Fraction& rNewZoom )
2525 DBG_ASSERT( rNewZoom.GetNumerator(), "Ruler::SetZoom() with scale 0 is not allowed" );
2527 if ( maZoom != rNewZoom )
2529 maZoom = rNewZoom;
2530 maMapMode.SetScaleX( maZoom );
2531 maMapMode.SetScaleY( maZoom );
2532 ImplUpdate();
2536 void Ruler::SetExtraType( RulerExtra eNewExtraType, sal_uInt16 nStyle )
2538 if ( mnWinStyle & WB_EXTRAFIELD )
2540 meExtraType = eNewExtraType;
2541 mnExtraStyle = nStyle;
2542 if (IsReallyVisible() && IsUpdateMode())
2543 Invalidate();
2547 void Ruler::SetNullOffset( long nPos )
2549 if ( mpData->nNullOff != nPos )
2551 mpData->nNullOff = nPos;
2552 ImplUpdate();
2556 void Ruler::SetLeftFrameMargin( long nPos )
2558 if ( (mpData->nLeftFrameMargin != nPos) )
2560 mpData->nLeftFrameMargin = nPos;
2561 ImplUpdate();
2565 void Ruler::SetRightFrameMargin( long nPos )
2567 if ( (mpData->nRightFrameMargin != nPos) )
2569 mpData->nRightFrameMargin = nPos;
2570 ImplUpdate();
2574 void Ruler::SetMargin1( long nPos, sal_uInt16 nMarginStyle )
2576 if ( (mpData->nMargin1 != nPos) || (mpData->nMargin1Style != nMarginStyle) )
2578 mpData->nMargin1 = nPos;
2579 mpData->nMargin1Style = nMarginStyle;
2580 ImplUpdate();
2584 void Ruler::SetMargin2( long nPos, sal_uInt16 nMarginStyle )
2586 DBG_ASSERT( (nPos >= mpData->nMargin1) ||
2587 (mpData->nMargin1Style & RULER_STYLE_INVISIBLE) ||
2588 (mpData->nMargin2Style & RULER_STYLE_INVISIBLE),
2589 "Ruler::SetMargin2() - Margin2 < Margin1" );
2591 if ( (mpData->nMargin2 != nPos) || (mpData->nMargin2Style != nMarginStyle) )
2593 mpData->nMargin2 = nPos;
2594 mpData->nMargin2Style = nMarginStyle;
2595 ImplUpdate();
2599 void Ruler::SetLines( sal_uInt32 aLineArraySize, const RulerLine* pLineArray )
2601 // To determine if what has changed
2602 if ( mpData->pLines.size() == aLineArraySize )
2604 sal_uInt32 i = aLineArraySize;
2605 vector<RulerLine>::const_iterator aItr1 = mpData->pLines.begin();
2606 const RulerLine* pAry2 = pLineArray;
2607 while ( i )
2609 if ( (aItr1->nPos != pAry2->nPos) ||
2610 (aItr1->nStyle != pAry2->nStyle) )
2611 break;
2612 ++aItr1;
2613 ++pAry2;
2614 i--;
2616 if ( !i )
2617 return;
2620 // New values and new share issue
2621 bool bMustUpdate;
2622 if ( IsReallyVisible() && IsUpdateMode() )
2623 bMustUpdate = true;
2624 else
2625 bMustUpdate = false;
2627 // Delete old lines
2628 if ( bMustUpdate )
2629 Invalidate(INVALIDATE_NOERASE);
2631 // New data set
2632 if ( !aLineArraySize || !pLineArray )
2634 if ( mpData->pLines.empty() )
2635 return;
2636 mpData->pLines.clear();
2638 else
2640 if ( mpData->pLines.size() != aLineArraySize )
2642 mpData->pLines.resize(aLineArraySize);
2645 std::copy( pLineArray,
2646 pLineArray + aLineArraySize,
2647 mpData->pLines.begin() );
2649 if ( bMustUpdate )
2650 Invalidate(INVALIDATE_NOERASE);
2654 void Ruler::SetBorders( sal_uInt32 aBorderArraySize, const RulerBorder* pBorderArray )
2656 if ( !aBorderArraySize || !pBorderArray )
2658 if ( mpData->pBorders.empty() )
2659 return;
2660 mpData->pBorders.clear();
2662 else
2664 if ( mpData->pBorders.size() != aBorderArraySize )
2666 mpData->pBorders.resize(aBorderArraySize);
2668 else
2670 sal_uInt32 i = aBorderArraySize;
2671 const RulerBorder* pAry1 = &mpData->pBorders[0];
2672 const RulerBorder* pAry2 = pBorderArray;
2673 while ( i )
2675 if ( (pAry1->nPos != pAry2->nPos) ||
2676 (pAry1->nWidth != pAry2->nWidth) ||
2677 (pAry1->nStyle != pAry2->nStyle) )
2678 break;
2679 pAry1++;
2680 pAry2++;
2681 i--;
2683 if ( !i )
2684 return;
2686 std::copy( pBorderArray,
2687 pBorderArray + aBorderArraySize,
2688 mpData->pBorders.begin() );
2691 ImplUpdate();
2694 void Ruler::SetIndents( sal_uInt32 aIndentArraySize, const RulerIndent* pIndentArray )
2697 if ( !aIndentArraySize || !pIndentArray )
2699 if ( mpData->pIndents.empty() )
2700 return;
2701 mpData->pIndents.clear();
2703 else
2705 if ( mpData->pIndents.size() != aIndentArraySize )
2707 mpData->pIndents.resize(aIndentArraySize);
2709 else
2711 sal_uInt32 i = aIndentArraySize;
2712 const RulerIndent* pAry1 = &mpData->pIndents[0];
2713 const RulerIndent* pAry2 = pIndentArray;
2714 while ( i )
2716 if ( (pAry1->nPos != pAry2->nPos) ||
2717 (pAry1->nStyle != pAry2->nStyle) )
2718 break;
2719 pAry1++;
2720 pAry2++;
2721 i--;
2723 if ( !i )
2724 return;
2727 std::copy( pIndentArray,
2728 pIndentArray + aIndentArraySize,
2729 mpData->pIndents.begin() );
2732 ImplUpdate();
2735 void Ruler::SetTabs( sal_uInt32 aTabArraySize, const RulerTab* pTabArray )
2737 if ( aTabArraySize == 0 || pTabArray == NULL )
2739 if ( mpData->pTabs.empty() )
2740 return;
2741 mpData->pTabs.clear();
2743 else
2745 if ( mpData->pTabs.size() != aTabArraySize )
2747 mpData->pTabs.resize(aTabArraySize);
2749 else
2751 sal_uInt32 i = aTabArraySize;
2752 vector<RulerTab>::iterator aTabIterator = mpData->pTabs.begin();
2753 const RulerTab* pInputArray = pTabArray;
2754 while ( i )
2756 RulerTab& aCurrent = *aTabIterator;
2757 if ( aCurrent.nPos != pInputArray->nPos ||
2758 aCurrent.nStyle != pInputArray->nStyle )
2760 break;
2762 ++aTabIterator;
2763 pInputArray++;
2764 i--;
2766 if ( !i )
2767 return;
2769 std::copy(pTabArray, pTabArray + aTabArraySize, mpData->pTabs.begin());
2772 ImplUpdate();
2775 void Ruler::SetStyle( WinBits nStyle )
2777 if ( mnWinStyle != nStyle )
2779 mnWinStyle = nStyle;
2780 ImplInitExtraField( true );
2784 void Ruler::DrawTab(vcl::RenderContext& rRenderContext, const Color &rFillColor, const Point& rPos, sal_uInt16 nStyle)
2786 Point aPos(rPos);
2787 sal_uInt16 nTabStyle = nStyle & (RULER_TAB_STYLE | RULER_TAB_RTL);
2789 rRenderContext.Push(PushFlags::LINECOLOR | PushFlags::FILLCOLOR);
2790 rRenderContext.SetLineColor();
2791 rRenderContext.SetFillColor(rFillColor);
2792 ImplCenterTabPos(aPos, nTabStyle);
2793 ImplDrawRulerTab(rRenderContext, aPos, nTabStyle, nStyle);
2794 rRenderContext.Pop();
2797 void Ruler::SetTextRTL(bool bRTL)
2799 if(mpData->bTextRTL != (bool) bRTL)
2801 mpData->bTextRTL = bRTL;
2802 if ( IsReallyVisible() && IsUpdateMode() )
2803 ImplInitExtraField( true );
2808 long Ruler::GetPageOffset() const
2810 return mpData->nPageOff;
2813 long Ruler::GetNullOffset() const
2815 return mpData->nNullOff;
2818 long Ruler::GetMargin1() const
2820 return mpData->nMargin1;
2823 long Ruler::GetMargin2() const
2825 return mpData->nMargin2;
2829 bool Ruler::GetTextRTL()
2831 return mpData->bTextRTL;
2834 RulerUnitData Ruler::GetCurrentRulerUnit() const
2836 return aImplRulerUnitTab[mnUnitIndex];
2839 void Ruler::DrawTicks()
2841 mbFormat = true;
2842 Invalidate(INVALIDATE_NOERASE);
2845 uno::Reference< XAccessible > Ruler::CreateAccessible()
2847 vcl::Window* pParent = GetAccessibleParentWindow();
2848 OSL_ENSURE( pParent, "-SvxRuler::CreateAccessible(): No Parent!" );
2849 uno::Reference< XAccessible > xAccParent = pParent->GetAccessible();
2850 if( xAccParent.is() )
2852 // MT: Fixed compiler issue because the address from a temporary object was used.
2853 // BUT: Should it really be a Pointer, instead of const&???
2854 OUString aStr;
2855 if ( mnWinStyle & WB_HORZ )
2857 aStr = SvtResId(STR_SVT_ACC_RULER_HORZ_NAME);
2859 else
2861 aStr = SvtResId(STR_SVT_ACC_RULER_VERT_NAME);
2863 pAccContext = new SvtRulerAccessible( xAccParent, *this, aStr );
2864 pAccContext->acquire();
2865 this->SetAccessible(pAccContext);
2866 return pAccContext;
2868 else
2869 return uno::Reference< XAccessible >();
2872 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */