LibreOffice Module svtools (master) 1
ruler.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <tools/debug.hxx>
21#include <tools/poly.hxx>
22#include <vcl/event.hxx>
23#include <vcl/settings.hxx>
24#include <vcl/vcllayout.hxx>
25#include <vcl/virdev.hxx>
26#include <vcl/ptrstyle.hxx>
27#include <sal/log.hxx>
28
29#include <svtools/ruler.hxx>
30#include <svtools/svtresid.hxx>
31#include <svtools/strings.hrc>
32#include <svtools/colorcfg.hxx>
33#include "accessibleruler.hxx"
34
35#include <memory>
36#include <vector>
37
38using namespace ::com::sun::star;
39using namespace ::com::sun::star::uno;
40using namespace ::com::sun::star::lang;
41using namespace ::com::sun::star::accessibility;
42
43#define RULER_OFF 3
44#define RULER_RESIZE_OFF 4
45#define RULER_MIN_SIZE 3
46
47#define RULER_VAR_SIZE 8
48
49#define RULER_UPDATE_LINES 0x01
50
51#define RULER_CLIP 150
52
53#define RULER_UNIT_MM 0
54#define RULER_UNIT_CM 1
55#define RULER_UNIT_M 2
56#define RULER_UNIT_KM 3
57#define RULER_UNIT_INCH 4
58#define RULER_UNIT_FOOT 5
59#define RULER_UNIT_MILE 6
60#define RULER_UNIT_POINT 7
61#define RULER_UNIT_PICA 8
62#define RULER_UNIT_CHAR 9
63#define RULER_UNIT_LINE 10
64#define RULER_UNIT_COUNT 11
65
66namespace
67{
72SalLayoutGlyphs* lcl_GetRulerTextGlyphs(const vcl::RenderContext& rRenderContext, const OUString& rText,
73 SalLayoutGlyphs& rTextGlyphs)
74{
75 if (rTextGlyphs.IsValid())
76 // Use pre-calculated result.
77 return &rTextGlyphs;
78
79 // Calculate glyph items.
80
81 std::unique_ptr<SalLayout> pLayout = rRenderContext.ImplLayout(
82 rText, 0, rText.getLength(), Point(0, 0), 0, {}, {}, SalLayoutFlags::GlyphItemsOnly);
83 if (!pLayout)
84 return nullptr;
85
86 // Remember the calculation result.
87 rTextGlyphs = pLayout->GetGlyphs();
88
89 return &rTextGlyphs;
90}
91}
92
94{
95 friend class Ruler;
96
97private:
98 std::vector<RulerLine> pLines;
99 std::vector<RulerBorder> pBorders;
100 std::vector<RulerIndent> pIndents;
101 std::vector<RulerTab> pTabs;
102
111 // In this context, "frame margin" means paragraph margins (indents)
118
119public:
121};
122
124 nNullVirOff (0),
125 nRulVirOff (0),
126 nRulWidth (0),
127 nPageOff (0),
128 nPageWidth (0),
129 nNullOff (0),
130 nMargin1 (0),
131 nMargin2 (0),
132 nLeftFrameMargin (0),
133 nRightFrameMargin (0),
134 nMargin1Style (RulerMarginStyle::NONE),
135 nMargin2Style (RulerMarginStyle::NONE),
136 bAutoPageWidth (true), // Page width == EditWin width
137 bTextRTL (false)
138{
139}
140
142{
143{ MapUnit::Map100thMM, 100, 25.0, 25.0, 50.0, 100.0, " mm" }, // MM
144{ MapUnit::Map100thMM, 1000, 100.0, 500.0, 1000.0, 1000.0, " cm" }, // CM
145{ MapUnit::MapMM, 1000, 10.0, 250.0, 500.0, 1000.0, " m" }, // M
146{ MapUnit::MapCM, 100000, 12500.0, 25000.0, 50000.0, 100000.0, " km" }, // KM
147{ MapUnit::Map1000thInch, 1000, 62.5, 125.0, 500.0, 1000.0, "\"" }, // INCH
148{ MapUnit::Map100thInch, 1200, 120.0, 120.0, 600.0, 1200.0, "'" }, // FOOT
149{ MapUnit::Map10thInch, 633600, 63360.0, 63360.0, 316800.0, 633600.0, " miles" }, // MILE
150{ MapUnit::MapPoint, 1, 12.0, 12.0, 12.0, 36.0, " pt" }, // POINT
151{ MapUnit::Map100thMM, 423, 423.0, 423.0, 423.0, 846.0, " pc" }, // PICA
152{ MapUnit::Map100thMM, 371, 371.0, 371.0, 371.0, 743.0, " ch" }, // CHAR
153{ MapUnit::Map100thMM, 551, 551.0, 551.0, 551.0, 1102.0, " li" } // LINE
154};
155
157{
158 0, // DPIScaleFactor to be set
159 7, // ruler_tab_width
160 6, // ruler_tab_height
161 2, // ruler_tab_height2
162 2, // ruler_tab_width2
163 8, // ruler_tab_cwidth
164 4, // ruler_tab_cwidth2
165 4, // ruler_tab_cwidth3
166 2, // ruler_tab_cwidth4
167 4, // ruler_tab_dheight
168 1, // ruler_tab_dheight2
169 5, // ruler_tab_dwidth
170 3, // ruler_tab_dwidth2
171 3, // ruler_tab_dwidth3
172 1, // ruler_tab_dwidth4
173 5 // ruler_tab_textoff
174};
175
176void Ruler::ImplInit( WinBits nWinBits )
177{
178 // Set default WinBits
179 if ( !(nWinBits & WB_VERT) )
180 {
181 nWinBits |= WB_HORZ;
182
183 // RTL: no UI mirroring for horizontal rulers, because
184 // the document is also not mirrored
185 EnableRTL( false );
186 }
187
188 // Initialize variables
189 mnWinStyle = nWinBits; // Window-Style
190 mnBorderOff = 0; // Border-Offset
191 mnWinOff = 0; // EditWinOffset
192 mnWinWidth = 0; // EditWinWidth
193 mnWidth = 0; // Window width
194 mnHeight = 0; // Window height
195 mnVirOff = 0; // Offset of VirtualDevice from top-left corner
196 mnVirWidth = 0; // width or height from VirtualDevice
197 mnVirHeight = 0; // height of width from VirtualDevice
198 mnDragPos = 0; // Drag-Position (Null point)
199 mnDragAryPos = 0; // Drag-Array-Index
200 mnDragSize = RulerDragSize::Move; // Did size change at dragging
201 mnDragModifier = 0; // Modifier key at dragging
202 mnExtraStyle = 0; // Style of Extra field
203 mnCharWidth = 371;
204 mnLineHeight = 551;
205 mbCalc = true; // Should recalculate page width
206 mbFormat = true; // Should redraw
207 mbDrag = false; // Currently at dragging
208 mbDragDelete = false; // Has mouse left the dragging area
209 mbDragCanceled = false; // Dragging cancelled?
210 mbAutoWinWidth = true; // EditWinWidth == RulerWidth
211 mbActive = true; // Is ruler active
212 mnUpdateFlags = 0; // What needs to be updated
213 mpData = mpSaveData.get(); // Pointer to normal data
214 meExtraType = RulerExtra::DontKnow; // What is in extra field
215 meDragType = RulerType::DontKnow; // Which element is dragged
216
217 // Initialize Units
219 meUnit = FieldUnit::CM;
220 maZoom = Fraction( 1, 1 );
221
222 // Recalculate border widths
223 if ( nWinBits & WB_BORDER )
224 mnBorderWidth = 1;
225 else
226 mnBorderWidth = 0;
227
228 // Settings
229 ImplInitSettings( true, true, true );
230
231 // Setup the default size
232 tools::Rectangle aRect;
233 GetOutDev()->GetTextBoundRect( aRect, "0123456789" );
234 tools::Long nDefHeight = aRect.GetHeight() + RULER_OFF * 2 + ruler_tab.textoff * 2 + mnBorderWidth;
235
236 Size aDefSize;
237 if ( nWinBits & WB_HORZ )
238 aDefSize.setHeight( nDefHeight );
239 else
240 aDefSize.setWidth( nDefHeight );
241 SetOutputSizePixel( aDefSize );
242 SetType(WindowType::RULER);
243}
244
245Ruler::Ruler( vcl::Window* pParent, WinBits nWinStyle ) :
246 Window( pParent, nWinStyle & WB_3DLOOK ),
250 mpData(nullptr),
252{
253 // Check to see if the ruler constructor has
254 // already been called before otherwise
255 // we end up with over-scaled elements
256 if (ruler_tab.DPIScaleFactor == 0)
257 {
274 }
275
276
277 ImplInit( nWinStyle );
278}
279
281{
282 disposeOnce();
283}
284
286{
287 mpSaveData.reset();
288 mpDragData.reset();
289 mxAccContext.clear();
290 Window::dispose();
291}
292
294{
295 if ( nX1 < -RULER_CLIP )
296 {
297 nX1 = -RULER_CLIP;
298 if ( nX2 < -RULER_CLIP )
299 return;
300 }
302 if ( nX2 > nClip )
303 {
304 nX2 = nClip;
305 if ( nX1 > nClip )
306 return;
307 }
308
309 if ( mnWinStyle & WB_HORZ )
310 rRenderContext.DrawLine( Point( nX1, nY1 ), Point( nX2, nY2 ) );
311 else
312 rRenderContext.DrawLine( Point( nY1, nX1 ), Point( nY2, nX2 ) );
313}
314
316{
317 if ( nX1 < -RULER_CLIP )
318 {
319 nX1 = -RULER_CLIP;
320 if ( nX2 < -RULER_CLIP )
321 return;
322 }
324 if ( nX2 > nClip )
325 {
326 nX2 = nClip;
327 if ( nX1 > nClip )
328 return;
329 }
330
331 if ( mnWinStyle & WB_HORZ )
332 rRenderContext.DrawRect(tools::Rectangle(nX1, nY1, nX2, nY2));
333 else
334 rRenderContext.DrawRect(tools::Rectangle(nY1, nX1, nY2, nX2));
335}
336
337void Ruler::ImplVDrawText(vcl::RenderContext& rRenderContext, tools::Long nX, tools::Long nY, const OUString& rText, tools::Long nMin, tools::Long nMax)
338{
339 tools::Rectangle aRect;
340 SalLayoutGlyphs* pTextLayout
341 = lcl_GetRulerTextGlyphs(rRenderContext, rText, maTextGlyphs[rText]);
342 rRenderContext.GetTextBoundRect(aRect, rText, 0, 0, -1, 0, {}, {}, pTextLayout);
343
344 tools::Long nShiftX = ( aRect.GetWidth() / 2 ) + aRect.Left();
345 tools::Long nShiftY = ( aRect.GetHeight() / 2 ) + aRect.Top();
346
347 if ( (nX > -RULER_CLIP) && (nX < mnVirWidth + RULER_CLIP) && ( nX < nMax - nShiftX ) && ( nX > nMin + nShiftX ) )
348 {
349 if ( mnWinStyle & WB_HORZ )
350 rRenderContext.DrawText(Point(nX - nShiftX, nY - nShiftY), rText, 0, -1, nullptr,
351 nullptr, pTextLayout);
352 else
353 rRenderContext.DrawText(Point(nY - nShiftX, nX - nShiftY), rText, 0, -1, nullptr,
354 nullptr, pTextLayout);
355 }
356}
357
359{
360 // Position lines
362 return;
363
364 tools::Long nNullWinOff = mpData->nNullVirOff + mnVirOff;
366 tools::Long nRulX2 = nRulX1 + mpData->nRulWidth;
367 tools::Long nY = (RULER_OFF * 2) + mnVirHeight - 1;
368
369 // Calculate rectangle
370 tools::Rectangle aRect;
371 if (mnWinStyle & WB_HORZ)
372 aRect.SetBottom( nY );
373 else
374 aRect.SetRight( nY );
375
376 // Draw lines
377 for (const RulerLine & rLine : mpData->pLines)
378 {
379 const tools::Long n = rLine.nPos + nNullWinOff;
380 if ((n >= nRulX1) && (n < nRulX2))
381 {
382 if (mnWinStyle & WB_HORZ )
383 {
384 aRect.SetLeft( n );
385 aRect.SetRight( n );
386 }
387 else
388 {
389 aRect.SetTop( n );
390 aRect.SetBottom( n );
391 }
392 tools::Rectangle aTempRect = aRect;
393
394 if (mnWinStyle & WB_HORZ)
395 aTempRect.SetBottom( RULER_OFF - 1 );
396 else
397 aTempRect.SetRight( RULER_OFF - 1 );
398
399 rRenderContext.Erase(aTempRect);
400
401 if (mnWinStyle & WB_HORZ)
402 {
403 aTempRect.SetBottom( aRect.Bottom() );
404 aTempRect.SetTop( aTempRect.Bottom() - RULER_OFF + 1 );
405 }
406 else
407 {
408 aTempRect.SetRight( aRect.Right() );
409 aTempRect.SetLeft( aTempRect.Right() - RULER_OFF + 1 );
410 }
411 rRenderContext.Erase(aTempRect);
412 GetOutDev()->Invert(aRect);
413 }
414 }
415 mnUpdateFlags = 0;
416}
417
419{
420 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
421 double nCenter = nTop + ((nBottom - nTop) / 2);
422
423 tools::Long nTickLength3 = (nBottom - nTop) * 0.5;
424 tools::Long nTickLength2 = nTickLength3 * 0.66;
425 tools::Long nTickLength1 = nTickLength2 * 0.66;
426
428 tools::Long DPIOffset = nScale - 1;
429
430 double nTick4 = aImplRulerUnitTab[mnUnitIndex].nTick4;
431 double nTick2 = 0;
432 double nTickCount = aImplRulerUnitTab[mnUnitIndex].nTick1 / nScale;
433 double nTickUnit = 0;
434 tools::Long nTickWidth;
435 bool bNoTicks = false;
436
437 Size aPixSize = rRenderContext.LogicToPixel(Size(nTick4, nTick4), maMapMode);
438
440 {
441 if (mnCharWidth == 0)
442 mnCharWidth = 371;
443 nTick4 = mnCharWidth * 2;
444 nTick2 = mnCharWidth;
445 nTickCount = mnCharWidth;
446 nTickUnit = mnCharWidth;
447 }
448 else if (mnUnitIndex == RULER_UNIT_LINE)
449 {
450 if (mnLineHeight == 0)
451 mnLineHeight = 551;
452 nTick4 = mnLineHeight * 2;
453 nTick2 = mnLineHeight;
454 nTickUnit = mnLineHeight;
455 nTickCount = mnLineHeight;
456 }
457
458 if (mnWinStyle & WB_HORZ)
459 {
460 nTickWidth = aPixSize.Width();
461 }
462 else
463 {
464 vcl::Font aFont = rRenderContext.GetFont();
466 aFont.SetOrientation(2700_deg10);
467 else
468 aFont.SetOrientation(900_deg10);
469 rRenderContext.SetFont(aFont);
470 nTickWidth = aPixSize.Height();
471 }
472
473 tools::Long nMaxWidth = rRenderContext.PixelToLogic(Size(mpData->nPageWidth, 0), maMapMode).Width();
474 if (nMaxWidth < 0)
475 nMaxWidth = -nMaxWidth;
476
478 nMaxWidth /= nTickUnit;
479 else
481
482 OUString aNumString = OUString::number(nMaxWidth);
483 tools::Long nTxtWidth = rRenderContext.GetTextWidth( aNumString );
484 const tools::Long nTextOff = 4;
485
486 // Determine the number divider for ruler drawn numbers - means which numbers
487 // should be shown on the ruler and which should be skipped because the ruler
488 // is not big enough to draw them
489 if (nTickWidth < nTxtWidth + nTextOff)
490 {
491 // Calculate the scale of the ruler
492 tools::Long nMulti = 1;
493 tools::Long nOrgTick4 = nTick4;
494
495 while (nTickWidth < nTxtWidth + nTextOff)
496 {
497 tools::Long nOldMulti = nMulti;
498 if (nTickWidth == 0)
499 nMulti *= 10;
500 else if (nMulti < 10)
501 nMulti++;
502 else if (nMulti < 100)
503 nMulti += 10;
504 else if (nMulti < 1000)
505 nMulti += 100;
506 else
507 nMulti += 1000;
508
509 // Overflow - in this case don't draw ticks and exit
510 if (nMulti < nOldMulti)
511 {
512 bNoTicks = true;
513 break;
514 }
515
516 nTick4 = nOrgTick4 * nMulti;
517 aPixSize = rRenderContext.LogicToPixel(Size(nTick4, nTick4), maMapMode);
518 if (mnWinStyle & WB_HORZ)
519 nTickWidth = aPixSize.Width();
520 else
521 nTickWidth = aPixSize.Height();
522 }
523 nTickCount = nTick4;
524 }
525 else
526 {
527 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
528 }
529
530 if (bNoTicks)
531 return;
532
533 tools::Long n = 0;
534 double nTick = 0.0;
535 double nTick3 = 0;
536
538 {
541 }
542
543 Size nTickGapSize;
544
545 nTickGapSize = rRenderContext.LogicToPixel(Size(nTickCount, nTickCount), maMapMode);
546 tools::Long nTickGap1 = mnWinStyle & WB_HORZ ? nTickGapSize.Width() : nTickGapSize.Height();
547 nTickGapSize = rRenderContext.LogicToPixel(Size(nTick2, nTick2), maMapMode);
548 tools::Long nTickGap2 = mnWinStyle & WB_HORZ ? nTickGapSize.Width() : nTickGapSize.Height();
549 nTickGapSize = rRenderContext.LogicToPixel(Size(nTick3, nTick3), maMapMode);
550 tools::Long nTickGap3 = mnWinStyle & WB_HORZ ? nTickGapSize.Width() : nTickGapSize.Height();
551
552 while (((nStart - n) >= nMin) || ((nStart + n) <= nMax))
553 {
554 // Null point
555 if (nTick == 0.0)
556 {
557 if (nStart > nMin)
558 {
559 // 0 is only painted when Margin1 is not equal to zero
561 {
562 aNumString = "0";
563 ImplVDrawText(rRenderContext, nStart, nCenter, aNumString);
564 }
565 }
566 }
567 else
568 {
569 aPixSize = rRenderContext.LogicToPixel(Size(nTick, nTick), maMapMode);
570
571 if (mnWinStyle & WB_HORZ)
572 n = aPixSize.Width();
573 else
574 n = aPixSize.Height();
575
576 // Tick4 - Output (Text)
577 double aStep = nTick / nTick4;
578 double aRest = std::abs(aStep - std::floor(aStep));
579 double nAcceptanceDelta = 0.0001;
580 rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
581
582 if (aRest < nAcceptanceDelta)
583 {
585 aNumString = OUString::number(nTick / nTickUnit);
586 else
587 aNumString = OUString::number(nTick / aImplRulerUnitTab[mnUnitIndex].nTickUnit);
588
589 tools::Long nHorizontalLocation = nStart + n;
590 ImplVDrawText(rRenderContext, nHorizontalLocation, nCenter, aNumString, nMin, nMax);
591
592 if (nMin < nHorizontalLocation && nHorizontalLocation < nMax)
593 {
594 ImplVDrawRect(rRenderContext, nHorizontalLocation, nBottom - 1 * nScale, nHorizontalLocation + DPIOffset, nBottom);
595 ImplVDrawRect(rRenderContext, nHorizontalLocation, nTop, nHorizontalLocation + DPIOffset, nTop + 1 * nScale);
596 }
597
598 nHorizontalLocation = nStart - n;
599 ImplVDrawText(rRenderContext, nHorizontalLocation, nCenter, aNumString, nMin, nMax);
600
601 if (nMin < nHorizontalLocation && nHorizontalLocation < nMax)
602 {
603 ImplVDrawRect(rRenderContext, nHorizontalLocation, nBottom,
604 nHorizontalLocation + DPIOffset, nBottom - 1 * nScale);
605 ImplVDrawRect(rRenderContext, nHorizontalLocation, nTop,
606 nHorizontalLocation + DPIOffset, nTop + 1 * nScale);
607 }
608 }
609 // Tick/Tick2 - Output (Strokes)
610 else
611 {
612 tools::Long nTickLength = nTickLength1;
613
614 aStep = (nTick / nTick2);
615 aRest = std::abs(aStep - std::floor(aStep));
616 if (aRest < nAcceptanceDelta)
617 nTickLength = nTickLength2;
618
619 aStep = (nTick / nTick3);
620 aRest = std::abs(aStep - std::floor(aStep));
621 if (aRest < nAcceptanceDelta )
622 nTickLength = nTickLength3;
623
624 if ((nTickLength == nTickLength1 && nTickGap1 > 6) ||
625 (nTickLength == nTickLength2 && nTickGap2 > 6) ||
626 (nTickLength == nTickLength3 && nTickGap3 > 6))
627 {
628 tools::Long nT1 = nCenter - (nTickLength / 2.0);
629 tools::Long nT2 = nT1 + nTickLength - 1;
630 tools::Long nT;
631
632 nT = nStart + n;
633
634 if (nT < nMax)
635 ImplVDrawRect(rRenderContext, nT, nT1, nT + DPIOffset, nT2);
636 nT = nStart - n;
637 if (nT > nMin)
638 ImplVDrawRect(rRenderContext, nT, nT1, nT + DPIOffset, nT2);
639 }
640 }
641 }
642 nTick += nTickCount;
643 }
644}
645
646void Ruler::ImplDrawBorders(vcl::RenderContext& rRenderContext, tools::Long nMin, tools::Long nMax, tools::Long nVirTop, tools::Long nVirBottom)
647{
648 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
652 tools::Long nTemp1;
653 tools::Long nTemp2;
654
655 for (std::vector<RulerBorder>::size_type i = 0; i < mpData->pBorders.size(); i++)
656 {
658 continue;
659
660 n1 = mpData->pBorders[i].nPos + mpData->nNullVirOff;
661 n2 = n1 + mpData->pBorders[i].nWidth;
662
663 if (((n1 >= nMin) && (n1 <= nMax)) || ((n2 >= nMin) && (n2 <= nMax)))
664 {
665 if ((n2 - n1) > 3)
666 {
667 rRenderContext.SetLineColor();
668 rRenderContext.SetFillColor(rStyleSettings.GetFaceColor());
669 ImplVDrawRect(rRenderContext, n1, nVirTop, n2, nVirBottom);
670
671 rRenderContext.SetLineColor(rStyleSettings.GetLightColor());
672 ImplVDrawLine(rRenderContext, n1 + 1, nVirTop, n1 + 1, nVirBottom);
673 ImplVDrawLine(rRenderContext, n1, nVirTop, n2, nVirTop);
674
675 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
676 ImplVDrawLine(rRenderContext, n1, nVirTop, n1, nVirBottom);
677 ImplVDrawLine(rRenderContext, n1, nVirBottom, n2, nVirBottom);
678 ImplVDrawLine(rRenderContext, n2 - 1, nVirTop, n2 - 1, nVirBottom);
679
680 rRenderContext.SetLineColor(rStyleSettings.GetDarkShadowColor());
681 ImplVDrawLine(rRenderContext, n2, nVirTop, n2, nVirBottom);
682
684 {
685 if (n2 - n1 > RULER_VAR_SIZE + 4)
686 {
687 nTemp1 = n1 + (((n2 - n1 + 1) - RULER_VAR_SIZE) / 2);
688 nTemp2 = nVirTop + (((nVirBottom - nVirTop + 1) - RULER_VAR_SIZE) / 2);
689 tools::Long nTemp3 = nTemp1 + RULER_VAR_SIZE - 1;
690 tools::Long nTemp4 = nTemp2 + RULER_VAR_SIZE - 1;
691 tools::Long nTempY = nTemp2;
692
693 rRenderContext.SetLineColor(rStyleSettings.GetLightColor());
694 while (nTempY <= nTemp4)
695 {
696 ImplVDrawLine(rRenderContext, nTemp1, nTempY, nTemp3, nTempY);
697 nTempY += 2;
698 }
699
700 nTempY = nTemp2 + 1;
701 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
702 while (nTempY <= nTemp4)
703 {
704 ImplVDrawLine(rRenderContext, nTemp1, nTempY, nTemp3, nTempY);
705 nTempY += 2;
706 }
707 }
708 }
709
711 {
712 if (n2 - n1 > RULER_VAR_SIZE + 10)
713 {
714 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
715 ImplVDrawLine(rRenderContext, n1 + 4, nVirTop + 3, n1 + 4, nVirBottom - 3);
716 ImplVDrawLine(rRenderContext, n2 - 5, nVirTop + 3, n2 - 5, nVirBottom - 3);
717 rRenderContext.SetLineColor(rStyleSettings.GetLightColor());
718 ImplVDrawLine(rRenderContext, n1 + 5, nVirTop + 3, n1 + 5, nVirBottom - 3);
719 ImplVDrawLine(rRenderContext, n2 - 4, nVirTop + 3, n2 - 4, nVirBottom - 3);
720 }
721 }
722 }
723 else
724 {
725 n = n1 + ((n2 - n1) / 2);
726 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
727
728 ImplVDrawLine(rRenderContext, n - 1, nVirTop, n - 1, nVirBottom);
729 ImplVDrawLine(rRenderContext, n + 1, nVirTop, n + 1, nVirBottom);
730 rRenderContext.SetLineColor();
731 rRenderContext.SetFillColor(rStyleSettings.GetWindowColor());
732 ImplVDrawRect(rRenderContext, n, nVirTop, n, nVirBottom);
733 }
734 }
735 }
736}
737
738void Ruler::ImplDrawIndent(vcl::RenderContext& rRenderContext, const tools::Polygon& rPoly, bool bIsHit)
739{
740 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
741
742 rRenderContext.SetLineColor(rStyleSettings.GetDarkShadowColor());
743 rRenderContext.SetFillColor(bIsHit ? rStyleSettings.GetDarkShadowColor() : rStyleSettings.GetWorkspaceColor());
744 tools::Polygon aPolygon(rPoly);
745 aPolygon.Optimize(PolyOptimizeFlags::CLOSE);
746 rRenderContext.DrawPolygon(aPolygon);
747}
748
749void Ruler::ImplDrawIndents(vcl::RenderContext& rRenderContext, tools::Long nMin, tools::Long nMax, tools::Long nVirTop, tools::Long nVirBottom)
750{
752 tools::Long nIndentHeight = (mnVirHeight / 2) - 1;
753 tools::Long nIndentWidth2 = nIndentHeight-3;
754
755 tools::Polygon aPoly(5);
756
757 for (std::vector<RulerIndent>::size_type j = 0; j < mpData->pIndents.size(); j++)
758 {
759 if (mpData->pIndents[j].bInvisible)
760 continue;
761
762 RulerIndentStyle nIndentStyle = mpData->pIndents[j].nStyle;
763
764 n = mpData->pIndents[j].nPos+mpData->nNullVirOff;
765
766 if ((n >= nMin) && (n <= nMax))
767 {
768 if (nIndentStyle == RulerIndentStyle::Bottom)
769 {
770 aPoly.SetPoint(Point(n + 0, nVirBottom - nIndentHeight), 0);
771 aPoly.SetPoint(Point(n - nIndentWidth2, nVirBottom - 3), 1);
772 aPoly.SetPoint(Point(n - nIndentWidth2, nVirBottom), 2);
773 aPoly.SetPoint(Point(n + nIndentWidth2, nVirBottom), 3);
774 aPoly.SetPoint(Point(n + nIndentWidth2, nVirBottom - 3), 4);
775 }
776 else
777 {
778 aPoly.SetPoint(Point(n + 0, nVirTop + nIndentHeight), 0);
779 aPoly.SetPoint(Point(n - nIndentWidth2, nVirTop + 3), 1);
780 aPoly.SetPoint(Point(n - nIndentWidth2, nVirTop), 2);
781 aPoly.SetPoint(Point(n + nIndentWidth2, nVirTop), 3);
782 aPoly.SetPoint(Point(n + nIndentWidth2, nVirTop + 3), 4);
783 }
784
785 if (0 == (mnWinStyle & WB_HORZ))
786 {
787 Point aTmp;
788 for (sal_uInt16 i = 0; i < 5; i++)
789 {
790 aTmp = aPoly[i];
791 Point aSet(nVirBottom - aTmp.Y(), aTmp.X());
792 aPoly[i] = aSet;
793 }
794 }
795 bool bIsHit = false;
796 if (mxCurrentHitTest != nullptr && mxCurrentHitTest->eType == RulerType::Indent)
797 {
798 bIsHit = mxCurrentHitTest->nAryPos == j;
799 }
800 else if(mbDrag && meDragType == RulerType::Indent)
801 {
802 bIsHit = mnDragAryPos == j;
803 }
804 ImplDrawIndent(rRenderContext, aPoly, bIsHit);
805 }
806 }
807}
808
809static void ImplCenterTabPos(Point& rPos, sal_uInt16 nTabStyle)
810{
811 bool bRTL = 0 != (nTabStyle & RULER_TAB_RTL);
812 nTabStyle &= RULER_TAB_STYLE;
813 rPos.AdjustY(ruler_tab.height/2 );
814
815 if ( (!bRTL && nTabStyle == RULER_TAB_LEFT) ||
816 ( bRTL && nTabStyle == RULER_TAB_RIGHT) )
817 {
818 rPos.AdjustX( -(ruler_tab.width / 2) );
819 }
820 else if ( (!bRTL && nTabStyle == RULER_TAB_RIGHT) ||
821 ( bRTL && nTabStyle == RULER_TAB_LEFT) )
822 {
823 rPos.AdjustX(ruler_tab.width / 2 );
824 }
825}
826
827static void lcl_RotateRect_Impl(tools::Rectangle& rRect, const tools::Long nReference, bool bRightAligned)
828{
829 if (rRect.IsEmpty())
830 return;
831
832 tools::Rectangle aTmp(rRect);
833 rRect.SetTop( aTmp.Left() );
834 rRect.SetBottom( aTmp.Right() );
835 rRect.SetLeft( aTmp.Top() );
836 rRect.SetRight( aTmp.Bottom() );
837
838 if (bRightAligned)
839 {
840 tools::Long nRef = 2 * nReference;
841 rRect.SetLeft( nRef - rRect.Left() );
842 rRect.SetRight( nRef - rRect.Right() );
843 }
844}
845
846static void ImplDrawRulerTab(vcl::RenderContext& rRenderContext, const Point& rPos,
847 sal_uInt16 nStyle, WinBits nWinBits)
848{
849 if (nStyle & RULER_STYLE_INVISIBLE)
850 return;
851
852 sal_uInt16 nTabStyle = nStyle & RULER_TAB_STYLE;
853 bool bRTL = 0 != (nStyle & RULER_TAB_RTL);
854
855 // Scale by the screen DPI scaling factor
856 // However when doing this some of the rectangles
857 // drawn become asymmetric due to the +1 offsets
858 sal_uInt16 DPIOffset = rRenderContext.GetDPIScaleFactor() - 1;
859
860 // A tabstop is drawn using three rectangles
861 tools::Rectangle aRect1; // A horizontal short line
862 tools::Rectangle aRect2; // A vertical short line
863 tools::Rectangle aRect3; // A small square
864
865 aRect3.SetEmpty();
866
867 if (nTabStyle == RULER_TAB_DEFAULT)
868 {
869 aRect1.SetLeft( rPos.X() - ruler_tab.dwidth2 + 1 );
870 aRect1.SetTop( rPos.Y() - ruler_tab.dheight2 + 1 );
871 aRect1.SetRight( rPos.X() - ruler_tab.dwidth2 + ruler_tab.dwidth + DPIOffset );
872 aRect1.SetBottom( rPos.Y() );
873
874 aRect2.SetLeft( rPos.X() - ruler_tab.dwidth2 + ruler_tab.dwidth3 );
875 aRect2.SetTop( rPos.Y() - ruler_tab.dheight + 1 );
876 aRect2.SetRight( rPos.X() - ruler_tab.dwidth2 + ruler_tab.dwidth3 + ruler_tab.dwidth4 - 1 );
877 aRect2.SetBottom( rPos.Y() );
878
879 }
880 else if ((!bRTL && nTabStyle == RULER_TAB_LEFT) || (bRTL && nTabStyle == RULER_TAB_RIGHT))
881 {
882 aRect1.SetLeft( rPos.X() );
883 aRect1.SetTop( rPos.Y() - ruler_tab.height2 + 1 );
884 aRect1.SetRight( rPos.X() + ruler_tab.width - 1 );
885 aRect1.SetBottom( rPos.Y() );
886
887 aRect2.SetLeft( rPos.X() );
888 aRect2.SetTop( rPos.Y() - ruler_tab.height + 1 );
889 aRect2.SetRight( rPos.X() + ruler_tab.width2 - 1 );
890 aRect2.SetBottom( rPos.Y() );
891 }
892 else if ((!bRTL && nTabStyle == RULER_TAB_RIGHT) || (bRTL && nTabStyle == RULER_TAB_LEFT))
893 {
894 aRect1.SetLeft( rPos.X() - ruler_tab.width + 1 );
895 aRect1.SetTop( rPos.Y() - ruler_tab.height2 + 1 );
896 aRect1.SetRight( rPos.X() );
897 aRect1.SetBottom( rPos.Y() );
898
899 aRect2.SetLeft( rPos.X() - ruler_tab.width2 + 1 );
900 aRect2.SetTop( rPos.Y() - ruler_tab.height + 1 );
901 aRect2.SetRight( rPos.X() );
902 aRect2.SetBottom( rPos.Y() );
903 }
904 else
905 {
906 aRect1.SetLeft( rPos.X() - ruler_tab.cwidth2 + 1 );
907 aRect1.SetTop( rPos.Y() - ruler_tab.height2 + 1 );
908 aRect1.SetRight( rPos.X() - ruler_tab.cwidth2 + ruler_tab.cwidth + DPIOffset );
909 aRect1.SetBottom( rPos.Y() );
910
911 aRect2.SetLeft( rPos.X() - ruler_tab.cwidth2 + ruler_tab.cwidth3 );
912 aRect2.SetTop( rPos.Y() - ruler_tab.height + 1 );
913 aRect2.SetRight( rPos.X() - ruler_tab.cwidth2 + ruler_tab.cwidth3 + ruler_tab.cwidth4 - 1 );
914 aRect2.SetBottom( rPos.Y() );
915
916 if (nTabStyle == RULER_TAB_DECIMAL)
917 {
918 aRect3.SetLeft( rPos.X() - ruler_tab.cwidth2 + ruler_tab.cwidth - 1 );
919 aRect3.SetTop( rPos.Y() - ruler_tab.height + 1 + 1 - DPIOffset );
920 aRect3.SetRight( rPos.X() - ruler_tab.cwidth2 + ruler_tab.cwidth + DPIOffset );
921 aRect3.SetBottom( rPos.Y() - ruler_tab.height + 1 + 2 );
922 }
923 }
924 if (0 == (nWinBits & WB_HORZ))
925 {
926 bool bRightAligned = 0 != (nWinBits & WB_RIGHT_ALIGNED);
927 lcl_RotateRect_Impl(aRect1, rPos.Y(), bRightAligned);
928 lcl_RotateRect_Impl(aRect2, rPos.Y(), bRightAligned);
929 lcl_RotateRect_Impl(aRect3, rPos.Y(), bRightAligned);
930 }
931 rRenderContext.DrawRect(aRect1);
932 rRenderContext.DrawRect(aRect2);
933
934 if (!aRect3.IsEmpty())
935 rRenderContext.DrawRect(aRect3);
936}
937
938void Ruler::ImplDrawTab(vcl::RenderContext& rRenderContext, const Point& rPos, sal_uInt16 nStyle)
939{
940 if (nStyle & RULER_STYLE_INVISIBLE)
941 return;
942
943 rRenderContext.SetLineColor();
944
945 if (nStyle & RULER_STYLE_DONTKNOW)
946 rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetFaceColor());
947 else
948 rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetDarkShadowColor());
949
950 if (mpData->bTextRTL)
951 nStyle |= RULER_TAB_RTL;
952
953 ImplDrawRulerTab(rRenderContext, rPos, nStyle, GetStyle());
954}
955
956void Ruler::ImplDrawTabs(vcl::RenderContext& rRenderContext, tools::Long nMin, tools::Long nMax, tools::Long nVirTop, tools::Long nVirBottom)
957{
958 for (const RulerTab & rTab : mpData->pTabs)
959 {
960 if (rTab.nStyle & RULER_STYLE_INVISIBLE)
961 continue;
962
963 tools::Long aPosition;
964 aPosition = rTab.nPos;
965 aPosition += +mpData->nNullVirOff;
966 tools::Long nTopBottom = (GetStyle() & WB_RIGHT_ALIGNED) ? nVirTop : nVirBottom;
967 if (nMin <= aPosition && aPosition <= nMax)
968 ImplDrawTab(rRenderContext, Point( aPosition, nTopBottom ), rTab.nStyle);
969 }
970}
971
972static int adjustSize(int nOrig)
973{
974 if (nOrig <= 0)
975 return 0;
976
977 // make sure we return an odd number, that looks better in the ruler
978 return ( (3*nOrig) / 8) * 2 + 1;
979}
980
982{
983 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
984
985 vcl::Font aFont = rStyleSettings.GetToolFont();
986 // make the font a bit smaller than default
987 Size aSize(adjustSize(aFont.GetFontSize().Width()), adjustSize(aFont.GetFontSize().Height()));
988 aFont.SetFontSize(aSize);
989
990 ApplyControlFont(rRenderContext, aFont);
991
994
995 Color aColor;
996 svtools::ColorConfig aColorConfig;
997 aColor = aColorConfig.GetColorValue(svtools::APPBACKGROUND).nColor;
998 ApplyControlBackground(rRenderContext, aColor);
999 // A hack to get it to change the non-ruler application background to change immediately
1000 if (aColor != maVirDev->GetBackground().GetColor())
1001 {
1002 maVirDev->SetBackground(aColor);
1003 Resize();
1004 }
1005}
1006
1007void Ruler::ImplInitSettings(bool bFont, bool bForeground, bool bBackground)
1008{
1009 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1010
1011 if (bFont)
1012 {
1013 vcl::Font aFont = rStyleSettings.GetToolFont();
1014 // make the font a bit smaller than default
1015 Size aSize(adjustSize(aFont.GetFontSize().Width()), adjustSize(aFont.GetFontSize().Height()));
1016 aFont.SetFontSize(aSize);
1017
1018 ApplyControlFont(*GetOutDev(), aFont);
1019 }
1020
1021 if (bForeground || bFont)
1022 {
1025 }
1026
1027 if (bBackground)
1028 {
1029 Color aColor;
1030 svtools::ColorConfig aColorConfig;
1031 aColor = aColorConfig.GetColorValue(svtools::APPBACKGROUND).nColor;
1033 }
1034
1035 maVirDev->SetSettings( GetSettings() );
1036 maVirDev->SetBackground( GetBackground() );
1037 vcl::Font aFont = GetFont();
1038
1039 if (mnWinStyle & WB_VERT)
1040 aFont.SetOrientation(900_deg10);
1041
1042 maVirDev->SetFont(aFont);
1043 maVirDev->SetTextColor(GetTextColor());
1044 maVirDev->SetTextFillColor(GetTextFillColor());
1045}
1046
1048{
1049 // calculate offset
1051 if ( mpData->nRulVirOff > mnVirOff )
1053 else
1054 mpData->nRulVirOff = 0;
1055 tools::Long nRulWinOff = mpData->nRulVirOff+mnVirOff;
1056
1057 // calculate non-visual part of the page
1058 tools::Long nNotVisPageWidth;
1059 if ( mpData->nPageOff < 0 )
1060 {
1061 nNotVisPageWidth = -(mpData->nPageOff);
1062 if ( nRulWinOff < mnWinOff )
1063 nNotVisPageWidth -= mnWinOff-nRulWinOff;
1064 }
1065 else
1066 nNotVisPageWidth = 0;
1067
1068 // calculate width
1069 if ( mnWinStyle & WB_HORZ )
1070 {
1071 if ( mbAutoWinWidth )
1073 if ( mpData->bAutoPageWidth )
1075 mpData->nRulWidth = std::min( mnWinWidth, mpData->nPageWidth-nNotVisPageWidth );
1076 if ( nRulWinOff+mpData->nRulWidth > mnWidth )
1077 mpData->nRulWidth = mnWidth-nRulWinOff;
1078 }
1079 else
1080 {
1081 if ( mbAutoWinWidth )
1083 if ( mpData->bAutoPageWidth )
1085 mpData->nRulWidth = std::min( mnWinWidth, mpData->nPageWidth-nNotVisPageWidth );
1086 if ( nRulWinOff+mpData->nRulWidth > mnHeight )
1087 mpData->nRulWidth = mnHeight-nRulWinOff;
1088 }
1089
1090 mbCalc = false;
1091}
1092
1093void Ruler::ImplFormat(vcl::RenderContext const & rRenderContext)
1094{
1095 // if already formatted, don't do it again
1096 if (!mbFormat)
1097 return;
1098
1099 // don't do anything if the window still has no size
1100 if (!mnVirWidth)
1101 return;
1102
1103 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
1104 tools::Long nP1; // pixel position of Page1
1105 tools::Long nP2; // pixel position of Page2
1106 tools::Long nM1; // pixel position of Margin1
1107 tools::Long nM2; // pixel position of Margin2
1108 tools::Long nVirTop; // top/left corner
1109 tools::Long nVirBottom; // bottom/right corner
1110 tools::Long nVirLeft; // left/top corner
1111 tools::Long nVirRight; // right/bottom corner
1112 tools::Long nNullVirOff; // for faster calculation
1113
1114 // calculate values
1115 if (mbCalc)
1116 ImplCalc();
1117
1119
1120 nNullVirOff = mpData->nNullVirOff;
1121 nVirLeft = mpData->nRulVirOff;
1122 nVirRight = nVirLeft + mpData->nRulWidth - 1;
1123 nVirTop = 0;
1124 nVirBottom = mnVirHeight - 1;
1125
1126 if (!IsReallyVisible())
1127 return;
1128
1129 Size aVirDevSize;
1130
1131 // initialize VirtualDevice
1132 if (mnWinStyle & WB_HORZ)
1133 {
1134 aVirDevSize.setWidth( mnVirWidth );
1135 aVirDevSize.setHeight( mnVirHeight );
1136 }
1137 else
1138 {
1139 aVirDevSize.setHeight( mnVirWidth );
1140 aVirDevSize.setWidth( mnVirHeight );
1141 }
1142 if (aVirDevSize != maVirDev->GetOutputSizePixel())
1143 maVirDev->SetOutputSizePixel(aVirDevSize);
1144 else
1145 maVirDev->Erase();
1146
1147 // calculate margins
1149 {
1150 nM1 = mpData->nMargin1 + nNullVirOff;
1152 {
1153 nP1 = nVirLeft;
1154 if (nM1 < nVirLeft)
1155 nP1--;
1156 }
1157 else
1158 nP1 = nNullVirOff - mpData->nNullOff;
1159 }
1160 else
1161 {
1162 nM1 = nVirLeft-1;
1163 nP1 = nM1;
1164 }
1166 {
1167 nM2 = mpData->nMargin2 + nNullVirOff;
1169 {
1170 nP2 = nVirRight;
1171 if (nM2 > nVirRight)
1172 nP2++;
1173 }
1174 else
1175 nP2 = nNullVirOff - mpData->nNullOff + mpData->nPageWidth;
1176 if (nM2 > nP2)
1177 nM2 = nP2;
1178 }
1179 else
1180 {
1181 nM2 = nVirRight+1;
1182 nP2 = nM2;
1183 }
1184
1185 // top/bottom border
1186 maVirDev->SetLineColor(rStyleSettings.GetShadowColor());
1187 ImplVDrawLine(*maVirDev, nVirLeft, nVirTop + 1, nM1, nVirTop + 1); //top left line
1188 ImplVDrawLine(*maVirDev, nM2, nVirTop + 1, nP2 - 1, nVirTop + 1); //top right line
1189
1190 nVirTop++;
1191 nVirBottom--;
1192
1193 // draw margin1, margin2 and in-between
1194 maVirDev->SetLineColor();
1195 maVirDev->SetFillColor(rStyleSettings.GetDialogColor());
1196 if (nM1 > nVirLeft)
1197 ImplVDrawRect(*maVirDev, nP1, nVirTop + 1, nM1, nVirBottom); //left gray rectangle
1198 if (nM2 < nP2)
1199 ImplVDrawRect(*maVirDev, nM2, nVirTop + 1, nP2, nVirBottom); //right gray rectangle
1200 if (nM2 - nM1 > 0)
1201 {
1202 maVirDev->SetFillColor(rStyleSettings.GetWindowColor());
1203 ImplVDrawRect(*maVirDev, nM1 + 1, nVirTop, nM2 - 1, nVirBottom); //center rectangle
1204 }
1205 maVirDev->SetLineColor(rStyleSettings.GetShadowColor());
1206 if (nM1 > nVirLeft)
1207 {
1208 ImplVDrawLine(*maVirDev, nM1, nVirTop + 1, nM1, nVirBottom); //right line of the left rectangle
1209 ImplVDrawLine(*maVirDev, nP1, nVirBottom, nM1, nVirBottom); //bottom line of the left rectangle
1210 if (nP1 >= nVirLeft)
1211 {
1212 ImplVDrawLine(*maVirDev, nP1, nVirTop + 1, nP1, nVirBottom); //left line of the left rectangle
1213 ImplVDrawLine(*maVirDev, nP1, nVirBottom, nP1 + 1, nVirBottom); //?
1214 }
1215 }
1216 if (nM2 < nP2)
1217 {
1218 ImplVDrawLine(*maVirDev, nM2, nVirBottom, nP2 - 1, nVirBottom); //bottom line of the right rectangle
1219 ImplVDrawLine(*maVirDev, nM2, nVirTop + 1, nM2, nVirBottom); //left line of the right rectangle
1220 if (nP2 <= nVirRight + 1)
1221 ImplVDrawLine(*maVirDev, nP2 - 1, nVirTop + 1, nP2 - 1, nVirBottom); //right line of the right rectangle
1222 }
1223
1224 tools::Long nMin = nVirLeft;
1225 tools::Long nMax = nP2;
1226 tools::Long nStart = 0;
1227
1228 if (mpData->bTextRTL)
1229 nStart = mpData->nRightFrameMargin + nNullVirOff;
1230 else
1231 nStart = mpData->nLeftFrameMargin + nNullVirOff;
1232
1233 if (nP1 > nVirLeft)
1234 nMin++;
1235
1236 if (nP2 < nVirRight)
1237 nMax--;
1238
1239 // Draw captions
1240 ImplDrawTicks(*maVirDev, nMin, nMax, nStart, nVirTop, nVirBottom);
1241
1242 // Draw borders
1243 if (!mpData->pBorders.empty())
1244 ImplDrawBorders(*maVirDev, nVirLeft, nP2, nVirTop, nVirBottom);
1245
1246 // Draw indents
1247 if (!mpData->pIndents.empty())
1248 ImplDrawIndents(*maVirDev, nVirLeft, nP2, nVirTop - 1, nVirBottom + 1);
1249
1250 // Tabs
1251 if (!mpData->pTabs.empty())
1252 ImplDrawTabs(*maVirDev, nVirLeft, nP2, nVirTop-1, nVirBottom + 1);
1253
1254 mbFormat = false;
1255}
1256
1257void Ruler::ImplInitExtraField( bool bUpdate )
1258{
1259 Size aWinSize = GetOutputSizePixel();
1260
1261 // extra field evaluate
1262 if ( mnWinStyle & WB_EXTRAFIELD )
1263 {
1268 if(mpData->bTextRTL)
1269 {
1270 if(mnWinStyle & WB_HORZ)
1271 maExtraRect.Move(aWinSize.Width() - maExtraRect.GetWidth() - maExtraRect.Left(), 0);
1272 else
1274 mnVirOff = 0;
1275 }
1276 else
1278
1279 }
1280 else
1281 {
1283 mnVirOff = 0;
1284 }
1285
1286 // mnVirWidth depends on mnVirOff
1287 if ( (mnVirWidth > RULER_MIN_SIZE) ||
1288 ((aWinSize.Width() > RULER_MIN_SIZE) && (aWinSize.Height() > RULER_MIN_SIZE)) )
1289 {
1290 if ( mnWinStyle & WB_HORZ )
1291 mnVirWidth = aWinSize.Width()-mnVirOff;
1292 else
1293 mnVirWidth = aWinSize.Height()-mnVirOff;
1294
1295 if ( mnVirWidth < RULER_MIN_SIZE )
1296 mnVirWidth = 0;
1297 }
1298
1299 if ( bUpdate )
1300 {
1301 mbCalc = true;
1302 mbFormat = true;
1303 Invalidate();
1304 }
1305}
1306
1308{
1309 if (mbFormat)
1310 {
1311 ImplFormat(rRenderContext);
1312 }
1313
1314 if (!IsReallyVisible())
1315 return;
1316
1317 // output the ruler to the virtual device
1318 Point aOffPos;
1319 Size aVirDevSize = maVirDev->GetOutputSizePixel();
1320
1321 if (mnWinStyle & WB_HORZ)
1322 {
1323 aOffPos.setX( mnVirOff );
1324 if (mpData->bTextRTL)
1325 aVirDevSize.AdjustWidth( -(maExtraRect.GetWidth()) );
1326
1327 aOffPos.setY( RULER_OFF );
1328 }
1329 else
1330 {
1331 aOffPos.setX( RULER_OFF );
1332 aOffPos.setY( mnVirOff );
1333 }
1334 rRenderContext.DrawOutDev(aOffPos, aVirDevSize, Point(), aVirDevSize, *maVirDev);
1335
1336 // redraw positionlines
1337 ImplInvertLines(rRenderContext);
1338}
1339
1341{
1342 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
1344 bool bEraseRect = false;
1345
1346 aRect.AdjustLeft(2 );
1347 aRect.AdjustTop(2 );
1348 aRect.AdjustRight( -2 );
1349 aRect.AdjustBottom( -2 );
1350
1352 {
1353 rRenderContext.SetFillColor(rStyleSettings.GetCheckedColor());
1354 bEraseRect = true;
1355 }
1356
1357 if (bEraseRect)
1358 {
1359 rRenderContext.SetLineColor();
1360 rRenderContext.DrawRect(aRect);
1361 }
1362
1363 // output content
1365 {
1366 rRenderContext.SetLineColor(rStyleSettings.GetButtonTextColor());
1367 rRenderContext.DrawLine(Point(aRect.Left() + 1, aRect.Top() + 4),
1368 Point(aRect.Right() - 1, aRect.Top() + 4));
1369 rRenderContext.DrawLine(Point(aRect.Left() + 4, aRect.Top() + 1),
1370 Point(aRect.Left() + 4, aRect.Bottom() - 1));
1371 }
1372 else if (meExtraType == RulerExtra::Tab)
1373 {
1374 sal_uInt16 nTabStyle = mnExtraStyle & RULER_TAB_STYLE;
1375 if (mpData->bTextRTL)
1376 nTabStyle |= RULER_TAB_RTL;
1377 Point aCenter = aRect.Center();
1378 Point aDraw(aCenter);
1379 ImplCenterTabPos(aDraw, nTabStyle);
1380 WinBits nWinBits = GetStyle();
1381 if (0 == (nWinBits & WB_HORZ))
1382 {
1383 if ((nWinBits & WB_RIGHT_ALIGNED) != 0)
1384 aDraw.setY( 2 * aCenter.Y() - aDraw.Y() );
1385
1386 if (mpData->bTextRTL)
1387 {
1388 tools::Long nTemp = aDraw.X();
1389 aDraw.setX( aDraw.Y() );
1390 aDraw.setY( nTemp );
1391 }
1392 }
1393 ImplDrawTab(rRenderContext, aDraw, nTabStyle);
1394 }
1395}
1396
1397void Ruler::ImplUpdate( bool bMustCalc )
1398{
1399 // clear lines in this place so they aren't considered at recalculation
1400 if (!mbFormat)
1401 Invalidate(InvalidateFlags::NoErase);
1402
1403 // set flags
1404 if (bMustCalc)
1405 mbCalc = true;
1406 mbFormat = true;
1407
1408 // abort if we are dragging as drag-handler will update the ruler after drag is finished
1409 if (mbDrag)
1410 return;
1411
1412 // otherwise trigger update
1413 if (IsReallyVisible() && IsUpdateMode())
1414 {
1415 Invalidate(InvalidateFlags::NoErase);
1416 }
1417}
1418
1419bool Ruler::ImplDoHitTest( const Point& rPos, RulerSelection* pHitTest,
1420 bool bRequireStyle, RulerIndentStyle nRequiredStyle ) const
1421{
1422 sal_Int32 i;
1423 sal_uInt16 nStyle;
1424 tools::Long nHitBottom;
1425 tools::Long nX;
1426 tools::Long nY;
1428
1429 if ( !mbActive )
1430 return false;
1431
1432 // determine positions
1433 bool bIsHori = 0 != (mnWinStyle & WB_HORZ);
1434 if ( bIsHori )
1435 {
1436 nX = rPos.X();
1437 nY = rPos.Y();
1438 }
1439 else
1440 {
1441 nX = rPos.Y();
1442 nY = rPos.X();
1443 }
1444 nHitBottom = mnVirHeight + (RULER_OFF * 2);
1445
1446 // #i32608#
1447 pHitTest->nAryPos = 0;
1448 pHitTest->mnDragSize = RulerDragSize::Move;
1449 pHitTest->bSize = false;
1450 pHitTest->bSizeBar = false;
1451
1452 // so that leftover tabs and indents are taken into account
1453 tools::Long nXExtraOff;
1454 if ( !mpData->pTabs.empty() || !mpData->pIndents.empty() )
1455 nXExtraOff = (mnVirHeight / 2) - 4;
1456 else
1457 nXExtraOff = 0;
1458
1459 // test if outside
1460 nX -= mnVirOff;
1461 if ( (nX < mpData->nRulVirOff - nXExtraOff) ||
1462 (nX > mpData->nRulVirOff + mpData->nRulWidth + nXExtraOff) ||
1463 (nY < 0) ||
1464 (nY > nHitBottom) )
1465 {
1466 pHitTest->nPos = 0;
1467 pHitTest->eType = RulerType::Outside;
1468 return false;
1469 }
1470
1471 nX -= mpData->nNullVirOff;
1472 pHitTest->nPos = nX;
1473 pHitTest->eType = RulerType::DontKnow;
1474
1475 // first test the tabs
1476 tools::Rectangle aRect;
1477 if ( !mpData->pTabs.empty() )
1478 {
1479 aRect.SetBottom( nHitBottom );
1480 aRect.SetTop( aRect.Bottom() - ruler_tab.height - RULER_OFF );
1481
1482 for ( i = mpData->pTabs.size() - 1; i >= 0; i-- )
1483 {
1484 nStyle = mpData->pTabs[i].nStyle;
1485 if ( !(nStyle & RULER_STYLE_INVISIBLE) )
1486 {
1487 nStyle &= RULER_TAB_STYLE;
1488
1489 // default tabs are only shown (no action)
1490 if ( nStyle != RULER_TAB_DEFAULT )
1491 {
1492 n1 = mpData->pTabs[i].nPos;
1493
1494 if ( nStyle == RULER_TAB_LEFT )
1495 {
1496 aRect.SetLeft( n1 );
1497 aRect.SetRight( n1 + ruler_tab.width - 1 );
1498 }
1499 else if ( nStyle == RULER_TAB_RIGHT )
1500 {
1501 aRect.SetRight( n1 );
1502 aRect.SetLeft( n1 - ruler_tab.width - 1 );
1503 }
1504 else
1505 {
1506 aRect.SetLeft( n1 - ruler_tab.cwidth2 + 1 );
1508 }
1509
1510 if ( aRect.Contains( Point( nX, nY ) ) )
1511 {
1512 pHitTest->eType = RulerType::Tab;
1513 pHitTest->nAryPos = i;
1514 return true;
1515 }
1516 }
1517 }
1518 }
1519 }
1520
1521 // Indents
1522 if ( !mpData->pIndents.empty() )
1523 {
1524 tools::Long nIndentHeight = (mnVirHeight / 2) - 1;
1525 tools::Long nIndentWidth2 = nIndentHeight - 3;
1526
1527 for ( i = mpData->pIndents.size(); i; i-- )
1528 {
1529 RulerIndentStyle nIndentStyle = mpData->pIndents[i-1].nStyle;
1530 if ( (! bRequireStyle || nIndentStyle == nRequiredStyle) &&
1531 !mpData->pIndents[i-1].bInvisible )
1532 {
1533 n1 = mpData->pIndents[i-1].nPos;
1534
1535 if ( (nIndentStyle == RulerIndentStyle::Bottom) != !bIsHori )
1536 {
1537 aRect.SetLeft( n1-nIndentWidth2 );
1538 aRect.SetRight( n1+nIndentWidth2 );
1539 aRect.SetTop( nHitBottom-nIndentHeight-RULER_OFF+1 );
1540 aRect.SetBottom( nHitBottom );
1541 }
1542 else
1543 {
1544 aRect.SetLeft( n1-nIndentWidth2 );
1545 aRect.SetRight( n1+nIndentWidth2 );
1546 aRect.SetTop( 0 );
1547 aRect.SetBottom( nIndentHeight+RULER_OFF-1 );
1548 }
1549
1550 if ( aRect.Contains( Point( nX, nY ) ) )
1551 {
1552 pHitTest->eType = RulerType::Indent;
1553 pHitTest->nAryPos = i-1;
1554 return true;
1555 }
1556 }
1557 }
1558 }
1559
1560 // test the borders
1561 int nBorderTolerance = 1;
1562 if(pHitTest->bExpandTest)
1563 {
1564 nBorderTolerance++;
1565 }
1566
1567 for ( i = mpData->pBorders.size(); i; i-- )
1568 {
1569 n1 = mpData->pBorders[i-1].nPos;
1570 tools::Long n2 = n1 + mpData->pBorders[i-1].nWidth;
1571
1572 // borders have at least 3 pixel padding
1573 if ( !mpData->pBorders[i-1].nWidth )
1574 {
1575 n1 -= nBorderTolerance;
1576 n2 += nBorderTolerance;
1577
1578 }
1579
1580 if ( (nX >= n1) && (nX <= n2) )
1581 {
1582 RulerBorderStyle nBorderStyle = mpData->pBorders[i-1].nStyle;
1583 if ( !(nBorderStyle & RulerBorderStyle::Invisible) )
1584 {
1585 pHitTest->eType = RulerType::Border;
1586 pHitTest->nAryPos = i-1;
1587
1588 if ( !(nBorderStyle & RulerBorderStyle::Sizeable) )
1589 {
1590 if ( nBorderStyle & RulerBorderStyle::Moveable )
1591 {
1592 pHitTest->bSizeBar = true;
1593 pHitTest->mnDragSize = RulerDragSize::Move;
1594 }
1595 }
1596 else
1597 {
1599 while ( nMOff*2 >= (n2-n1-RULER_MOUSE_BORDERMOVE) )
1600 {
1601 if ( nMOff < 2 )
1602 {
1603 nMOff = 0;
1604 break;
1605 }
1606 else
1607 nMOff--;
1608 }
1609
1610 if ( nX <= n1+nMOff )
1611 {
1612 pHitTest->bSize = true;
1613 pHitTest->mnDragSize = RulerDragSize::N1;
1614 }
1615 else if ( nX >= n2-nMOff )
1616 {
1617 pHitTest->bSize = true;
1618 pHitTest->mnDragSize = RulerDragSize::N2;
1619 }
1620 else
1621 {
1622 if ( nBorderStyle & RulerBorderStyle::Moveable )
1623 {
1624 pHitTest->bSizeBar = true;
1625 pHitTest->mnDragSize = RulerDragSize::Move;
1626 }
1627 }
1628 }
1629
1630 return true;
1631 }
1632 }
1633 }
1634
1635 // Margins
1636 int nMarginTolerance = pHitTest->bExpandTest ? nBorderTolerance : RULER_MOUSE_MARGINWIDTH;
1637
1639 {
1640 n1 = mpData->nMargin1;
1641 if ( (nX >= n1 - nMarginTolerance) && (nX <= n1 + nMarginTolerance) )
1642 {
1643 pHitTest->eType = RulerType::Margin1;
1644 pHitTest->bSize = true;
1645 return true;
1646 }
1647 }
1649 {
1650 n1 = mpData->nMargin2;
1651 if ( (nX >= n1 - nMarginTolerance) && (nX <= n1 + nMarginTolerance) )
1652 {
1653 pHitTest->eType = RulerType::Margin2;
1654 pHitTest->bSize = true;
1655 return true;
1656 }
1657 }
1658
1659 // test tabs again
1660 if ( !mpData->pTabs.empty() )
1661 {
1662 aRect.SetTop( RULER_OFF );
1663 aRect.SetBottom( nHitBottom );
1664
1665 for ( i = mpData->pTabs.size() - 1; i >= 0; i-- )
1666 {
1667 nStyle = mpData->pTabs[i].nStyle;
1668 if ( !(nStyle & RULER_STYLE_INVISIBLE) )
1669 {
1670 nStyle &= RULER_TAB_STYLE;
1671
1672 // default tabs are only shown (no action)
1673 if ( nStyle != RULER_TAB_DEFAULT )
1674 {
1675 n1 = mpData->pTabs[i].nPos;
1676
1677 if ( nStyle == RULER_TAB_LEFT )
1678 {
1679 aRect.SetLeft( n1 );
1680 aRect.SetRight( n1 + ruler_tab.width - 1 );
1681 }
1682 else if ( nStyle == RULER_TAB_RIGHT )
1683 {
1684 aRect.SetRight( n1 );
1685 aRect.SetLeft( n1 - ruler_tab.width - 1 );
1686 }
1687 else
1688 {
1689 aRect.SetLeft( n1 - ruler_tab.cwidth2 + 1 );
1691 }
1692
1693 aRect.AdjustLeft( -1 );
1694 aRect.AdjustRight( 1 );
1695
1696 if ( aRect.Contains( Point( nX, nY ) ) )
1697 {
1698 pHitTest->eType = RulerType::Tab;
1699 pHitTest->nAryPos = i;
1700 return true;
1701 }
1702 }
1703 }
1704 }
1705 }
1706
1707 return false;
1708}
1709
1710bool Ruler::ImplDocHitTest( const Point& rPos, RulerType eDragType,
1711 RulerSelection* pHitTest ) const
1712{
1713 Point aPos = rPos;
1714 bool bRequiredStyle = false;
1715 RulerIndentStyle nRequiredStyle = RulerIndentStyle::Top;
1716
1717 if (eDragType == RulerType::Indent)
1718 {
1719 bRequiredStyle = true;
1720 nRequiredStyle = RulerIndentStyle::Bottom;
1721 }
1722
1723 if ( mnWinStyle & WB_HORZ )
1724 aPos.AdjustX(mnWinOff );
1725 else
1726 aPos.AdjustY(mnWinOff );
1727
1728 if ( (eDragType == RulerType::Indent) || (eDragType == RulerType::DontKnow) )
1729 {
1730 if ( mnWinStyle & WB_HORZ )
1731 aPos.setY( RULER_OFF + 1 );
1732 else
1733 aPos.setX( RULER_OFF + 1 );
1734
1735 if ( ImplDoHitTest( aPos, pHitTest, bRequiredStyle, nRequiredStyle ) )
1736 {
1737 if ( (pHitTest->eType == eDragType) || (eDragType == RulerType::DontKnow) )
1738 return true;
1739 }
1740 }
1741
1742 if ( (eDragType == RulerType::Indent) ||
1743 (eDragType == RulerType::Tab) ||
1744 (eDragType == RulerType::DontKnow) )
1745 {
1746 if ( mnWinStyle & WB_HORZ )
1747 aPos.setY( mnHeight - RULER_OFF - 1 );
1748 else
1749 aPos.setX( mnWidth - RULER_OFF - 1 );
1750
1751 if ( ImplDoHitTest( aPos, pHitTest, bRequiredStyle, nRequiredStyle ) )
1752 {
1753 if ( (pHitTest->eType == eDragType) || (eDragType == RulerType::DontKnow) )
1754 return true;
1755 }
1756 }
1757
1758 if ( (eDragType == RulerType::Margin1) || (eDragType == RulerType::Margin2) ||
1759 (eDragType == RulerType::Border) || (eDragType == RulerType::DontKnow) )
1760 {
1761 if ( mnWinStyle & WB_HORZ )
1762 aPos.setY( RULER_OFF + (mnVirHeight / 2) );
1763 else
1764 aPos.setX( RULER_OFF + (mnVirHeight / 2) );
1765
1766 if ( ImplDoHitTest( aPos, pHitTest ) )
1767 {
1768 if ( (pHitTest->eType == eDragType) || (eDragType == RulerType::DontKnow) )
1769 return true;
1770 }
1771 }
1772
1773 pHitTest->eType = RulerType::DontKnow;
1774
1775 return false;
1776}
1777
1778bool Ruler::ImplStartDrag( RulerSelection const * pHitTest, sal_uInt16 nModifier )
1779{
1780 // don't trigger drag if a border that was clicked can not be changed
1781 if ( (pHitTest->eType == RulerType::Border) &&
1782 !pHitTest->bSize && !pHitTest->bSizeBar )
1783 return false;
1784
1785 // Set drag data
1786 meDragType = pHitTest->eType;
1787 mnDragPos = pHitTest->nPos;
1788 mnDragAryPos = pHitTest->nAryPos;
1789 mnDragSize = pHitTest->mnDragSize;
1790 mnDragModifier = nModifier;
1792 mpData = mpDragData.get();
1793
1794 // call handler
1795 if (StartDrag())
1796 {
1797 // if the handler allows dragging, initialize dragging
1798 mbDrag = true;
1800 StartTracking();
1801 Invalidate(InvalidateFlags::NoErase);
1802 return true;
1803 }
1804 else
1805 {
1806 // otherwise reset the data
1808 mnDragPos = 0;
1809 mnDragAryPos = 0;
1811 mnDragModifier = 0;
1812 mpData = mpSaveData.get();
1813 }
1814
1815 return false;
1816}
1817
1818void Ruler::ImplDrag( const Point& rPos )
1819{
1820 tools::Long nX;
1821 tools::Long nY;
1822 tools::Long nOutHeight;
1823
1824 if ( mnWinStyle & WB_HORZ )
1825 {
1826 nX = rPos.X();
1827 nY = rPos.Y();
1828 nOutHeight = mnHeight;
1829 }
1830 else
1831 {
1832 nX = rPos.Y();
1833 nY = rPos.X();
1834 nOutHeight = mnWidth;
1835 }
1836
1837 // calculate and fit X
1838 nX -= mnVirOff;
1839 if ( nX < mpData->nRulVirOff )
1840 {
1841 nX = mpData->nRulVirOff;
1842 }
1843 else if ( nX > mpData->nRulVirOff+mpData->nRulWidth )
1844 {
1846 }
1847 nX -= mpData->nNullVirOff;
1848
1849 // if upper or left from ruler, then consider old values
1850 mbDragDelete = false;
1851 if ( nY < 0 )
1852 {
1853 if ( !mbDragCanceled )
1854 {
1855 // reset the data
1856 mbDragCanceled = true;
1857 ImplRulerData aTempData = *mpDragData;
1859 mbCalc = true;
1860 mbFormat = true;
1861
1862 // call handler
1864 Drag();
1865
1866 // and redraw
1867 Invalidate(InvalidateFlags::NoErase);
1868
1869 // reset the data as before cancel
1870 *mpDragData = aTempData;
1871 }
1872 }
1873 else
1874 {
1875 mbDragCanceled = false;
1876
1877 // +2, so the tabs are not cleared too quickly
1878 if ( nY > nOutHeight + 2 )
1879 mbDragDelete = true;
1880
1881 mnDragPos = nX;
1882
1883 // call handler
1884 Drag();
1885
1886 // redraw
1887 if (mbFormat)
1888 Invalidate(InvalidateFlags::NoErase);
1889 }
1890}
1891
1893{
1894 // get values
1895 if ( mbDragCanceled )
1897 else
1899
1900 mpData = mpSaveData.get();
1901 mbDrag = false;
1902
1903 // call handler
1904 EndDrag();
1905
1906 // reset drag values
1908 mnDragPos = 0;
1909 mnDragAryPos = 0;
1911 mbDragCanceled = false;
1912 mbDragDelete = false;
1913 mnDragModifier = 0;
1914 mnStartDragPos = 0;
1915
1916 // redraw
1917 Invalidate(InvalidateFlags::NoErase);
1918}
1919
1921{
1922 if ( !rMEvt.IsLeft() || IsTracking() )
1923 return;
1924
1925 Point aMousePos = rMEvt.GetPosPixel();
1926 sal_uInt16 nMouseClicks = rMEvt.GetClicks();
1927 sal_uInt16 nMouseModifier = rMEvt.GetModifier();
1928
1929 // update ruler
1930 if ( mbFormat )
1931 {
1932 Invalidate(InvalidateFlags::NoErase);
1933 }
1934
1935 if ( maExtraRect.Contains( aMousePos ) )
1936 {
1937 ExtraDown();
1938 }
1939 else
1940 {
1941 RulerSelection aHitTest;
1942 bool bHitTestResult = ImplDoHitTest(aMousePos, &aHitTest);
1943
1944 if ( nMouseClicks == 1 )
1945 {
1946 if ( bHitTestResult )
1947 {
1948 ImplStartDrag( &aHitTest, nMouseModifier );
1949 }
1950 else
1951 {
1952 // calculate position inside of ruler area
1953 if ( aHitTest.eType == RulerType::DontKnow )
1954 {
1955 mnDragPos = aHitTest.nPos;
1956 Click();
1957 mnDragPos = 0;
1958
1959 // call HitTest again as a click, for example, could set a new tab
1960 if ( ImplDoHitTest(aMousePos, &aHitTest) )
1961 ImplStartDrag(&aHitTest, nMouseModifier);
1962 }
1963 }
1964 }
1965 else
1966 {
1967 if (bHitTestResult)
1968 {
1969 mnDragPos = aHitTest.nPos;
1970 mnDragAryPos = aHitTest.nAryPos;
1971 }
1972 meDragType = aHitTest.eType;
1973
1974 DoubleClick();
1975
1977 mnDragPos = 0;
1978 mnDragAryPos = 0;
1979 }
1980 }
1981}
1982
1983void Ruler::MouseMove( const MouseEvent& rMEvt )
1984{
1985 PointerStyle ePtrStyle = PointerStyle::Arrow;
1986
1988
1990
1992
1993 if (ImplDoHitTest( rMEvt.GetPosPixel(), mxCurrentHitTest.get() ))
1994 {
1996
1997 if (mxCurrentHitTest->bSize)
1998 {
1999 if (mnWinStyle & WB_HORZ)
2000 {
2001 if (mxCurrentHitTest->mnDragSize == RulerDragSize::N1)
2002 ePtrStyle = PointerStyle::TabSelectW;
2003 else if (mxCurrentHitTest->mnDragSize == RulerDragSize::N2)
2004 ePtrStyle = PointerStyle::TabSelectE;
2005 else
2006 ePtrStyle = PointerStyle::ESize;
2007 }
2008 else
2009 {
2010 if (mxCurrentHitTest->mnDragSize == RulerDragSize::N1)
2011 ePtrStyle = PointerStyle::WindowNSize;
2012 else if (mxCurrentHitTest->mnDragSize == RulerDragSize::N2)
2013 ePtrStyle = PointerStyle::WindowSSize;
2014 else
2015 ePtrStyle = PointerStyle::SSize;
2016 }
2017 }
2018 else if (mxCurrentHitTest->bSizeBar)
2019 {
2020 if (mnWinStyle & WB_HORZ)
2021 ePtrStyle = PointerStyle::HSizeBar;
2022 else
2023 ePtrStyle = PointerStyle::VSizeBar;
2024 }
2025 }
2026
2027 if (mxPreviousHitTest != nullptr && mxPreviousHitTest->eType != mxCurrentHitTest->eType)
2028 {
2029 mbFormat = true;
2030 }
2031
2032 SetPointer( ePtrStyle );
2033
2034 if (mbFormat)
2035 {
2036 Invalidate(InvalidateFlags::NoErase);
2037 }
2038}
2039
2040void Ruler::Tracking( const TrackingEvent& rTEvt )
2041{
2042 if ( rTEvt.IsTrackingEnded() )
2043 {
2044 // reset the old state at cancel
2045 if ( rTEvt.IsTrackingCanceled() )
2046 {
2047 mbDragCanceled = true;
2048 mbFormat = true;
2049 }
2050
2051 ImplEndDrag();
2052 }
2053 else
2054 ImplDrag( rTEvt.GetMouseEvent().GetPosPixel() );
2055}
2056
2058{
2059 ImplDraw(rRenderContext);
2060
2061 // consider extra field
2063 ImplDrawExtra(rRenderContext);
2064}
2065
2067{
2068 Size aWinSize = GetOutputSizePixel();
2069
2070 tools::Long nNewHeight;
2071 if ( mnWinStyle & WB_HORZ )
2072 {
2073 if ( aWinSize.Height() != mnHeight )
2074 nNewHeight = aWinSize.Height();
2075 else
2076 nNewHeight = 0;
2077 }
2078 else
2079 {
2080 if ( aWinSize.Width() != mnWidth )
2081 nNewHeight = aWinSize.Width();
2082 else
2083 nNewHeight = 0;
2084 }
2085
2086 mbFormat = true;
2087
2088 // clear lines
2089 bool bVisible = IsReallyVisible();
2090 if ( bVisible && !mpData->pLines.empty() )
2091 {
2093 Invalidate(InvalidateFlags::NoErase);
2094 }
2095
2096 // recalculate some values if the height/width changes
2097 // extra field should always be updated
2099 if ( nNewHeight )
2100 {
2101 mbCalc = true;
2102 mnVirHeight = nNewHeight - mnBorderWidth - ( RULER_OFF * 2 );
2103 }
2104 else
2105 {
2106 if ( mpData->bAutoPageWidth )
2107 ImplUpdate( true );
2108 else if ( mbAutoWinWidth )
2109 mbCalc = true;
2110 }
2111
2112 // clear part of the border
2113 if ( bVisible )
2114 {
2115 if ( nNewHeight )
2116 Invalidate(InvalidateFlags::NoErase);
2117 else if ( mpData->bAutoPageWidth )
2118 {
2119 // only at AutoPageWidth do we need to redraw
2120 tools::Rectangle aRect;
2121
2122 if ( mnWinStyle & WB_HORZ )
2123 {
2124 if ( mnWidth < aWinSize.Width() )
2125 aRect.SetLeft( mnWidth - RULER_RESIZE_OFF );
2126 else
2127 aRect.SetLeft( aWinSize.Width() - RULER_RESIZE_OFF );
2128 aRect.SetRight( aRect.Left() + RULER_RESIZE_OFF );
2129 aRect.SetTop( RULER_OFF );
2130 aRect.SetBottom( RULER_OFF + mnVirHeight );
2131 }
2132 else
2133 {
2134 if ( mnHeight < aWinSize.Height() )
2136 else
2137 aRect.SetTop( aWinSize.Height()-RULER_RESIZE_OFF );
2138 aRect.SetBottom( aRect.Top() + RULER_RESIZE_OFF );
2139 aRect.SetLeft( RULER_OFF );
2140 aRect.SetRight( RULER_OFF + mnVirHeight );
2141 }
2142
2143 Invalidate(aRect, InvalidateFlags::NoErase);
2144 }
2145 }
2146
2147 mnWidth = aWinSize.Width();
2148 mnHeight = aWinSize.Height();
2149}
2150
2152{
2153 Window::StateChanged( nType );
2154
2155 if ( nType == StateChangedType::InitShow )
2156 Invalidate();
2157 else if ( nType == StateChangedType::UpdateMode )
2158 {
2159 if ( IsReallyVisible() && IsUpdateMode() )
2160 Invalidate();
2161 }
2162 else if ( (nType == StateChangedType::Zoom) ||
2163 (nType == StateChangedType::ControlFont) )
2164 {
2165 ImplInitSettings( true, false, false );
2166 Invalidate();
2167 }
2168 else if ( nType == StateChangedType::ControlForeground )
2169 {
2170 ImplInitSettings( false, true, false );
2171 Invalidate();
2172 }
2173 else if ( nType == StateChangedType::ControlBackground )
2174 {
2175 ImplInitSettings( false, false, true );
2176 Invalidate();
2177 }
2178}
2179
2181{
2182 Window::DataChanged( rDCEvt );
2183
2184 if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
2185 (rDCEvt.GetType() == DataChangedEventType::DISPLAY) ||
2186 (rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) ||
2187 ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
2188 (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
2189 {
2190 mbFormat = true;
2191 ImplInitSettings( true, true, true );
2192 Invalidate();
2193 }
2194}
2195
2197{
2198 return false;
2199}
2200
2202{
2203}
2204
2206{
2207}
2208
2210{
2211}
2212
2214{
2215 maDoubleClickHdl.Call( this );
2216}
2217
2219{
2220}
2221
2223{
2224 mbActive = true;
2225
2226 // update positionlines - draw is delayed
2228 Invalidate(InvalidateFlags::NoErase);
2229}
2230
2232{
2233 // clear positionlines
2234 Invalidate(InvalidateFlags::NoErase);
2235
2236 mbActive = false;
2237}
2238
2239bool Ruler::StartDocDrag( const MouseEvent& rMEvt, RulerType eDragType )
2240{
2241 if ( !mbDrag )
2242 {
2243 Point aMousePos = rMEvt.GetPosPixel();
2244 sal_uInt16 nMouseClicks = rMEvt.GetClicks();
2245 sal_uInt16 nMouseModifier = rMEvt.GetModifier();
2246 RulerSelection aHitTest;
2247
2248 if(eDragType != RulerType::DontKnow)
2249 aHitTest.bExpandTest = true;
2250
2251 // update ruler
2252 if ( mbFormat )
2253 {
2254 if (!IsReallyVisible())
2255 {
2256 // set mpData for ImplDocHitTest()
2258 }
2259
2260 Invalidate(InvalidateFlags::NoErase);
2261 }
2262
2263 if ( nMouseClicks == 1 )
2264 {
2265 if ( ImplDocHitTest( aMousePos, eDragType, &aHitTest ) )
2266 {
2267 PointerStyle aPtr = PointerStyle::Arrow;
2268
2269 if ( aHitTest.bSize )
2270 {
2271 if ( mnWinStyle & WB_HORZ )
2272 aPtr = PointerStyle::ESize;
2273 else
2274 aPtr = PointerStyle::SSize;
2275 }
2276 else if ( aHitTest.bSizeBar )
2277 {
2278 if ( mnWinStyle & WB_HORZ )
2279 aPtr = PointerStyle::HSizeBar;
2280 else
2281 aPtr = PointerStyle::VSizeBar;
2282 }
2283 SetPointer( aPtr );
2284 return ImplStartDrag( &aHitTest, nMouseModifier );
2285 }
2286 }
2287 else if ( nMouseClicks == 2 )
2288 {
2289 if ( ImplDocHitTest( aMousePos, eDragType, &aHitTest ) )
2290 {
2291 mnDragPos = aHitTest.nPos;
2292 mnDragAryPos = aHitTest.nAryPos;
2293 }
2294
2295 DoubleClick();
2296
2297 mnDragPos = 0;
2298 mnDragAryPos = 0;
2299
2300 return true;
2301 }
2302 }
2303
2304 return false;
2305}
2306
2308{
2309 if ( mbDrag )
2310 {
2311 ImplDrag( Point( -1, -1 ) );
2312 ImplEndDrag();
2313 }
2314}
2315
2316RulerType Ruler::GetRulerType( const Point& rPos, sal_uInt16* pAryPos )
2317{
2318 RulerSelection aHitTest;
2319
2320 // update ruler
2321 if ( IsReallyVisible() && mbFormat )
2322 {
2323 Invalidate(InvalidateFlags::NoErase);
2324 }
2325
2326 (void)ImplDoHitTest(rPos, &aHitTest);
2327
2328 // return values
2329 if ( pAryPos )
2330 *pAryPos = aHitTest.nAryPos;
2331 return aHitTest.eType;
2332}
2333
2334void Ruler::SetWinPos( tools::Long nNewOff, tools::Long nNewWidth )
2335{
2336 // should widths be automatically calculated
2337 if ( !nNewWidth )
2338 mbAutoWinWidth = true;
2339 else
2340 mbAutoWinWidth = false;
2341
2342 mnWinOff = nNewOff;
2343 mnWinWidth = nNewWidth;
2344 ImplUpdate( true );
2345}
2346
2348{
2349 // should we do anything?
2350 if ( (mpData->nPageOff == nNewOff) && (mpData->nPageWidth == nNewWidth) )
2351 return;
2352
2353 // should widths be automatically calculated
2354 if ( !nNewWidth )
2355 mpData->bAutoPageWidth = true;
2356 else
2357 mpData->bAutoPageWidth = false;
2358
2359 mpData->nPageOff = nNewOff;
2360 mpData->nPageWidth = nNewWidth;
2361 ImplUpdate( true );
2362}
2363
2365{
2366 if ( mnWinStyle & WB_BORDER )
2367 {
2368 if ( mnBorderOff != nOff )
2369 {
2370 mnBorderOff = nOff;
2371
2372 if ( IsReallyVisible() && IsUpdateMode() )
2373 Invalidate(InvalidateFlags::NoErase);
2374 }
2375 }
2376}
2377
2379{
2380 if ( meUnit == eNewUnit )
2381 return;
2382
2383 meUnit = eNewUnit;
2384 switch ( meUnit )
2385 {
2386 case FieldUnit::MM:
2388 break;
2389 case FieldUnit::CM:
2391 break;
2392 case FieldUnit::M:
2394 break;
2395 case FieldUnit::KM:
2397 break;
2398 case FieldUnit::INCH:
2400 break;
2401 case FieldUnit::FOOT:
2403 break;
2404 case FieldUnit::MILE:
2406 break;
2407 case FieldUnit::POINT:
2409 break;
2410 case FieldUnit::PICA:
2412 break;
2413 case FieldUnit::CHAR:
2415 break;
2416 case FieldUnit::LINE:
2418 break;
2419 default:
2420 SAL_WARN( "svtools.control", "Ruler::SetUnit() - Wrong Unit" );
2421 break;
2422 }
2423
2425 ImplUpdate();
2426}
2427
2428void Ruler::SetZoom( const Fraction& rNewZoom )
2429{
2430 DBG_ASSERT( rNewZoom.GetNumerator(), "Ruler::SetZoom() with scale 0 is not allowed" );
2431
2432 if ( maZoom != rNewZoom )
2433 {
2434 maZoom = rNewZoom;
2437 ImplUpdate();
2438 }
2439}
2440
2441void Ruler::SetExtraType( RulerExtra eNewExtraType, sal_uInt16 nStyle )
2442{
2443 if ( mnWinStyle & WB_EXTRAFIELD )
2444 {
2445 meExtraType = eNewExtraType;
2446 mnExtraStyle = nStyle;
2447 if (IsReallyVisible() && IsUpdateMode())
2448 Invalidate();
2449 }
2450}
2451
2453{
2454 if ( mpData->nNullOff != nPos )
2455 {
2457 mpData->nNullOff = nPos;
2458 ImplUpdate();
2459 }
2460}
2461
2463{
2464 if ( mpData->nLeftFrameMargin != nPos )
2465 {
2467 ImplUpdate();
2468 }
2469}
2470
2472{
2473 if ( mpData->nRightFrameMargin != nPos )
2474 {
2476 ImplUpdate();
2477 }
2478}
2479
2481{
2482 if ( (mpData->nMargin1 != nPos) || (mpData->nMargin1Style != nMarginStyle) )
2483 {
2484 mpData->nMargin1 = nPos;
2485 mpData->nMargin1Style = nMarginStyle;
2486 ImplUpdate();
2487 }
2488}
2489
2491{
2492 DBG_ASSERT( (nPos >= mpData->nMargin1) ||
2495 "Ruler::SetMargin2() - Margin2 < Margin1" );
2496
2497 if ( (mpData->nMargin2 != nPos) || (mpData->nMargin2Style != nMarginStyle) )
2498 {
2499 mpData->nMargin2 = nPos;
2500 mpData->nMargin2Style = nMarginStyle;
2501 ImplUpdate();
2502 }
2503}
2504
2505void Ruler::SetLines( sal_uInt32 aLineArraySize, const RulerLine* pLineArray )
2506{
2507 // To determine if what has changed
2508 if ( mpData->pLines.size() == aLineArraySize )
2509 {
2510 sal_uInt32 i = aLineArraySize;
2511 std::vector<RulerLine>::const_iterator aItr1 = mpData->pLines.begin();
2512 const RulerLine* pAry2 = pLineArray;
2513 while ( i )
2514 {
2515 if ( aItr1->nPos != pAry2->nPos )
2516 break;
2517 ++aItr1;
2518 ++pAry2;
2519 i--;
2520 }
2521 if ( !i )
2522 return;
2523 }
2524
2525 // New values and new share issue
2526 bool bMustUpdate;
2527 bMustUpdate = IsReallyVisible() && IsUpdateMode();
2528
2529 // Delete old lines
2530 if ( bMustUpdate )
2531 Invalidate(InvalidateFlags::NoErase);
2532
2533 // New data set
2534 if ( !aLineArraySize || !pLineArray )
2535 {
2536 if ( mpData->pLines.empty() )
2537 return;
2538 mpData->pLines.clear();
2539 }
2540 else
2541 {
2542 if ( mpData->pLines.size() != aLineArraySize )
2543 {
2544 mpData->pLines.resize(aLineArraySize);
2545 }
2546
2547 std::copy( pLineArray,
2548 pLineArray + aLineArraySize,
2549 mpData->pLines.begin() );
2550
2551 if ( bMustUpdate )
2552 Invalidate(InvalidateFlags::NoErase);
2553 }
2554}
2555
2556void Ruler::SetBorders( sal_uInt32 aBorderArraySize, const RulerBorder* pBorderArray )
2557{
2558 if ( !aBorderArraySize || !pBorderArray )
2559 {
2560 if ( mpData->pBorders.empty() )
2561 return;
2562 mpData->pBorders.clear();
2563 }
2564 else
2565 {
2566 if ( mpData->pBorders.size() != aBorderArraySize )
2567 {
2568 mpData->pBorders.resize(aBorderArraySize);
2569 }
2570 else
2571 {
2572 sal_uInt32 i = aBorderArraySize;
2573 const RulerBorder* pAry1 = mpData->pBorders.data();
2574 const RulerBorder* pAry2 = pBorderArray;
2575 while ( i )
2576 {
2577 if ( (pAry1->nPos != pAry2->nPos) ||
2578 (pAry1->nWidth != pAry2->nWidth) ||
2579 (pAry1->nStyle != pAry2->nStyle) )
2580 break;
2581 pAry1++;
2582 pAry2++;
2583 i--;
2584 }
2585 if ( !i )
2586 return;
2587 }
2588 std::copy( pBorderArray,
2589 pBorderArray + aBorderArraySize,
2590 mpData->pBorders.begin() );
2591 }
2592
2593 ImplUpdate();
2594}
2595
2596void Ruler::SetIndents( sal_uInt32 aIndentArraySize, const RulerIndent* pIndentArray )
2597{
2598
2599 if ( !aIndentArraySize || !pIndentArray )
2600 {
2601 if ( mpData->pIndents.empty() )
2602 return;
2603 mpData->pIndents.clear();
2604 }
2605 else
2606 {
2607 if ( mpData->pIndents.size() != aIndentArraySize )
2608 {
2609 mpData->pIndents.resize(aIndentArraySize);
2610 }
2611 else
2612 {
2613 sal_uInt32 i = aIndentArraySize;
2614 const RulerIndent* pAry1 = mpData->pIndents.data();
2615 const RulerIndent* pAry2 = pIndentArray;
2616 while ( i )
2617 {
2618 if ( (pAry1->nPos != pAry2->nPos) ||
2619 (pAry1->nStyle != pAry2->nStyle) )
2620 break;
2621 pAry1++;
2622 pAry2++;
2623 i--;
2624 }
2625 if ( !i )
2626 return;
2627 }
2628
2629 std::copy( pIndentArray,
2630 pIndentArray + aIndentArraySize,
2631 mpData->pIndents.begin() );
2632 }
2633
2634 ImplUpdate();
2635}
2636
2637void Ruler::SetTabs( sal_uInt32 aTabArraySize, const RulerTab* pTabArray )
2638{
2639 if ( aTabArraySize == 0 || pTabArray == nullptr )
2640 {
2641 if ( mpData->pTabs.empty() )
2642 return;
2643 mpData->pTabs.clear();
2644 }
2645 else
2646 {
2647 if ( mpData->pTabs.size() != aTabArraySize )
2648 {
2649 mpData->pTabs.resize(aTabArraySize);
2650 }
2651 else
2652 {
2653 sal_uInt32 i = aTabArraySize;
2654 std::vector<RulerTab>::iterator aTabIterator = mpData->pTabs.begin();
2655 const RulerTab* pInputArray = pTabArray;
2656 while ( i )
2657 {
2658 RulerTab& aCurrent = *aTabIterator;
2659 if ( aCurrent.nPos != pInputArray->nPos ||
2660 aCurrent.nStyle != pInputArray->nStyle )
2661 {
2662 break;
2663 }
2664 ++aTabIterator;
2665 pInputArray++;
2666 i--;
2667 }
2668 if ( !i )
2669 return;
2670 }
2671 std::copy(pTabArray, pTabArray + aTabArraySize, mpData->pTabs.begin());
2672 }
2673
2674 ImplUpdate();
2675}
2676
2677const std::vector<RulerTab>& Ruler::GetTabs() const
2678{
2679 return mpData->pTabs;
2680}
2681
2683{
2684 if ( mnWinStyle != nStyle )
2685 {
2686 mnWinStyle = nStyle;
2687 ImplInitExtraField( true );
2688 }
2689}
2690
2691void Ruler::DrawTab(vcl::RenderContext& rRenderContext, const Color &rFillColor, const Point& rPos, sal_uInt16 nStyle)
2692{
2693 Point aPos(rPos);
2694 sal_uInt16 nTabStyle = nStyle & (RULER_TAB_STYLE | RULER_TAB_RTL);
2695
2697 rRenderContext.SetLineColor();
2698 rRenderContext.SetFillColor(rFillColor);
2699 ImplCenterTabPos(aPos, nTabStyle);
2700 ImplDrawRulerTab(rRenderContext, aPos, nTabStyle, nStyle);
2701 rRenderContext.Pop();
2702}
2703
2704void Ruler::SetTextRTL(bool bRTL)
2705{
2706 if(mpData->bTextRTL != bRTL)
2707 {
2708 mpData->bTextRTL = bRTL;
2709 if ( IsReallyVisible() && IsUpdateMode() )
2710 ImplInitExtraField( true );
2711 }
2712
2713}
2714
2716{
2717 return mpData->nPageOff;
2718}
2719
2721{
2722 return mpData->nNullOff;
2723}
2724
2726{
2727 return mpData->nMargin1;
2728}
2729
2731{
2732 return mpData->nMargin2;
2733}
2734
2735
2737{
2738 return mpData->bTextRTL;
2739}
2740
2742{
2744}
2745
2747{
2748 mbFormat = true;
2749 Invalidate(InvalidateFlags::NoErase);
2750}
2751
2752uno::Reference< XAccessible > Ruler::CreateAccessible()
2753{
2755 OSL_ENSURE( pParent, "-SvxRuler::CreateAccessible(): No Parent!" );
2756 uno::Reference< XAccessible > xAccParent = pParent->GetAccessible();
2757 if( xAccParent.is() )
2758 {
2759 // MT: Fixed compiler issue because the address from a temporary object was used.
2760 // BUT: Should it really be a Pointer, instead of const&???
2761 OUString aStr;
2762 if ( mnWinStyle & WB_HORZ )
2763 {
2764 aStr = SvtResId(STR_SVT_ACC_RULER_HORZ_NAME);
2765 }
2766 else
2767 {
2768 aStr = SvtResId(STR_SVT_ACC_RULER_VERT_NAME);
2769 }
2770 mxAccContext = new SvtRulerAccessible( xAccParent, *this, aStr );
2772 return mxAccContext;
2773 }
2774 else
2775 return uno::Reference< XAccessible >();
2776}
2777
2778/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const StyleSettings & GetStyleSettings() const
DataChangedEventType GetType() const
AllSettingsFlags GetFlags() const
sal_Int32 GetNumerator() const
bool bTextRTL
Definition: ruler.cxx:117
tools::Long nRulVirOff
Definition: ruler.cxx:104
tools::Long nNullVirOff
Definition: ruler.cxx:103
std::vector< RulerLine > pLines
Definition: ruler.cxx:98
tools::Long nRulWidth
Definition: ruler.cxx:105
std::vector< RulerIndent > pIndents
Definition: ruler.cxx:100
RulerMarginStyle nMargin2Style
Definition: ruler.cxx:115
tools::Long nMargin1
Definition: ruler.cxx:109
tools::Long nRightFrameMargin
Definition: ruler.cxx:113
tools::Long nLeftFrameMargin
Definition: ruler.cxx:112
RulerMarginStyle nMargin1Style
Definition: ruler.cxx:114
bool bAutoPageWidth
Definition: ruler.cxx:116
tools::Long nNullOff
Definition: ruler.cxx:108
tools::Long nMargin2
Definition: ruler.cxx:110
std::vector< RulerBorder > pBorders
Definition: ruler.cxx:99
tools::Long nPageWidth
Definition: ruler.cxx:107
std::vector< RulerTab > pTabs
Definition: ruler.cxx:101
tools::Long nPageOff
Definition: ruler.cxx:106
void SetScaleY(const Fraction &rScaleY)
void SetMapUnit(MapUnit eUnit)
void SetScaleX(const Fraction &rScaleX)
sal_uInt16 GetModifier() const
sal_uInt16 GetClicks() const
const Point & GetPosPixel() const
bool IsLeft() const
const vcl::Font & GetFont() const
float GetDPIScaleFactor() const
void SetFont(const vcl::Font &rNewFont)
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
void DrawRect(const tools::Rectangle &rRect)
void DrawLine(const Point &rStartPt, const Point &rEndPt)
bool GetTextBoundRect(tools::Rectangle &rRect, const OUString &rStr, sal_Int32 nBase=0, sal_Int32 nIndex=0, sal_Int32 nLen=-1, sal_uLong nLayoutWidth=0, KernArraySpan aDXArray=KernArraySpan(), o3tl::span< const sal_Bool > pKashidaArray={}, const SalLayoutGlyphs *pGlyphs=nullptr) const
void Invert(const tools::Rectangle &rRect, InvertFlags nFlags=InvertFlags::NONE)
void SetLineColor()
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
void DrawPolygon(const tools::Polygon &rPoly)
void SetFillColor()
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
SAL_DLLPRIVATE void DrawOutDev(const Point &, const Size &, const Point &, const Size &, const Printer &)=delete
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
std::unique_ptr< SalLayout > ImplLayout(const OUString &, sal_Int32 nIndex, sal_Int32 nLen, const Point &rLogicPos=Point(0, 0), tools::Long nLogicWidth=0, KernArraySpan aKernArray=KernArraySpan(), o3tl::span< const sal_Bool > pKashidaArray={}, SalLayoutFlags flags=SalLayoutFlags::NONE, vcl::text::TextLayoutCache const *=nullptr, const SalLayoutGlyphs *pGlyphs=nullptr) const
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
const AllSettings & GetSettings() const
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
Definition: ruler.hxx:609
SVT_DLLPRIVATE void ImplDrag(const Point &rPos)
Definition: ruler.cxx:1818
tools::Long mnVirWidth
Definition: ruler.hxx:619
tools::Long mnBorderOff
Definition: ruler.hxx:613
bool mbActive
Definition: ruler.hxx:647
RulerExtra meExtraType
Definition: ruler.hxx:637
Fraction maZoom
Definition: ruler.hxx:640
sal_uInt8 mnUpdateFlags
Definition: ruler.hxx:648
void SetPagePos(tools::Long nOff=0, tools::Long nWidth=0)
Definition: ruler.cxx:2347
virtual void MouseMove(const MouseEvent &rMEvt) override
Definition: ruler.cxx:1983
virtual bool StartDrag()
Definition: ruler.cxx:2196
void Activate() override
Definition: ruler.cxx:2222
bool mbFormat
Definition: ruler.hxx:642
SVT_DLLPRIVATE void ImplDrawExtra(vcl::RenderContext &rRenderContext)
Definition: ruler.cxx:1340
bool GetTextRTL() const
Definition: ruler.cxx:2736
tools::Long GetMargin1() const
Definition: ruler.cxx:2725
SVT_DLLPRIVATE void ImplDrawBorders(vcl::RenderContext &rRenderContext, tools::Long nMin, tools::Long nMax, tools::Long nVirTop, tools::Long nVirBottom)
Definition: ruler.cxx:646
SVT_DLLPRIVATE void ImplFormat(vcl::RenderContext const &rRenderContext)
Definition: ruler.cxx:1093
void SetTabs(sal_uInt32 n=0, const RulerTab *pTabAry=nullptr)
Definition: ruler.cxx:2637
SVT_DLLPRIVATE void ImplInitExtraField(bool bUpdate)
Definition: ruler.cxx:1257
RulerDragSize mnDragSize
Definition: ruler.hxx:631
virtual void Tracking(const TrackingEvent &rTEvt) override
Definition: ruler.cxx:2040
sal_uInt16 mnDragModifier
Definition: ruler.hxx:632
SVT_DLLPRIVATE bool ImplDocHitTest(const Point &rPos, RulerType eDragType, RulerSelection *pHitTest) const
Definition: ruler.cxx:1710
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: ruler.cxx:1920
SVT_DLLPRIVATE bool ImplDoHitTest(const Point &rPosition, RulerSelection *pHitTest, bool bRequiredStyle=false, RulerIndentStyle nRequiredStyle=RulerIndentStyle::Top) const
Definition: ruler.cxx:1419
void SetNullOffset(tools::Long nPos)
Definition: ruler.cxx:2452
SVT_DLLPRIVATE void ImplVDrawLine(vcl::RenderContext &rRenderContext, tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2)
Definition: ruler.cxx:293
virtual ~Ruler() override
Definition: ruler.cxx:280
SVT_DLLPRIVATE void ImplDrawIndents(vcl::RenderContext &rRenderContext, tools::Long nMin, tools::Long nMax, tools::Long nVirTop, tools::Long nVirBottom)
Definition: ruler.cxx:749
bool mbDragCanceled
Definition: ruler.hxx:645
std::unique_ptr< RulerSelection > mxPreviousHitTest
Definition: ruler.hxx:655
virtual void StateChanged(StateChangedType nStateChange) override
Definition: ruler.cxx:2151
tools::Long mnDragPos
Definition: ruler.hxx:623
SVT_DLLPRIVATE void ImplInit(WinBits nWinBits)
Definition: ruler.cxx:176
void SetWinPos(tools::Long nOff, tools::Long nWidth=0)
Definition: ruler.cxx:2334
bool mbDragDelete
Definition: ruler.hxx:644
ScopedVclPtr< VirtualDevice > maVirDev
Definition: ruler.hxx:611
bool mbDrag
Definition: ruler.hxx:643
void SetMargin2()
Definition: ruler.hxx:768
Ruler(const Ruler &)=delete
tools::Long mnWidth
Definition: ruler.hxx:616
FieldUnit meUnit
Definition: ruler.hxx:639
WinBits GetStyle() const
Definition: ruler.hxx:785
tools::Long mnVirHeight
Definition: ruler.hxx:620
void SetStyle(WinBits nStyle)
Definition: ruler.cxx:2682
tools::Long mnWinWidth
Definition: ruler.hxx:615
SVT_DLLPRIVATE void ImplUpdate(bool bMustCalc=false)
Definition: ruler.cxx:1397
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: ruler.cxx:2180
virtual void EndDrag()
Definition: ruler.cxx:2205
virtual void dispose() override
Definition: ruler.cxx:285
std::unique_ptr< RulerSelection > mxCurrentHitTest
Definition: ruler.hxx:654
virtual void Drag()
Definition: ruler.cxx:2201
static SVT_DLLPRIVATE void ImplDrawIndent(vcl::RenderContext &rRenderContext, const tools::Polygon &rPoly, bool bIsHit)
Definition: ruler.cxx:738
tools::Long mnHeight
Definition: ruler.hxx:617
tools::Long GetPageOffset() const
Definition: ruler.cxx:2715
std::unique_ptr< ImplRulerData > mpDragData
Definition: ruler.hxx:626
tools::Long GetNullOffset() const
Definition: ruler.cxx:2720
void SetLeftFrameMargin(tools::Long nPos)
Definition: ruler.cxx:2462
void SetIndents(sal_uInt32 n=0, const RulerIndent *pIndentAry=nullptr)
Definition: ruler.cxx:2596
void CancelDrag()
Definition: ruler.cxx:2307
static void DrawTab(vcl::RenderContext &rRenderContext, const Color &rFillColor, const Point &rPos, sal_uInt16 nStyle)
Definition: ruler.cxx:2691
void SetBorderPos(tools::Long nOff=0)
Definition: ruler.cxx:2364
bool StartDocDrag(const MouseEvent &rMEvt, RulerType eDragType)
Definition: ruler.cxx:2239
Link< Ruler *, void > maDoubleClickHdl
Definition: ruler.hxx:652
rtl::Reference< SvtRulerAccessible > mxAccContext
Definition: ruler.hxx:657
SVT_DLLPRIVATE void ImplCalc()
Definition: ruler.cxx:1047
virtual void Resize() override
Definition: ruler.cxx:2066
void SetLines(sal_uInt32 n=0, const RulerLine *pLineAry=nullptr)
Definition: ruler.cxx:2505
tools::Long mnStartDragPos
Definition: ruler.hxx:622
SVT_DLLPRIVATE void ImplInvertLines(vcl::RenderContext &rRenderContext)
Definition: ruler.cxx:358
SVT_DLLPRIVATE void ImplVDrawRect(vcl::RenderContext &rRenderContext, tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2)
Definition: ruler.cxx:315
tools::Long mnBorderWidth
Definition: ruler.hxx:621
tools::Long mnWinOff
Definition: ruler.hxx:614
ImplRulerData * mpData
Definition: ruler.hxx:625
SVT_DLLPRIVATE bool ImplStartDrag(RulerSelection const *pHitTest, sal_uInt16 nModifier)
Definition: ruler.cxx:1778
void SetMargin1()
Definition: ruler.hxx:765
const RulerUnitData & GetCurrentRulerUnit() const
Definition: ruler.cxx:2741
void SetExtraType(RulerExtra eNewExtraType, sal_uInt16 nStyle=0)
Definition: ruler.cxx:2441
SVT_DLLPRIVATE void ImplDraw(vcl::RenderContext &rRenderContext)
Definition: ruler.cxx:1307
void SetZoom(const Fraction &rNewZoom)
Definition: ruler.cxx:2428
SVT_DLLPRIVATE void ImplEndDrag()
Definition: ruler.cxx:1892
SVT_DLLPRIVATE void ImplInitSettings(bool bFont, bool bForeground, bool bBackground)
Definition: ruler.cxx:1007
SVT_DLLPRIVATE void ImplDrawTicks(vcl::RenderContext &rRenderContext, tools::Long nMin, tools::Long nMax, tools::Long nStart, tools::Long nVirTop, tools::Long nVirBottom)
Definition: ruler.cxx:418
RulerSelection maHoverSelection
Definition: ruler.hxx:650
void SetRightFrameMargin(tools::Long nPos)
Definition: ruler.cxx:2471
void SetBorders(sal_uInt32 n=0, const RulerBorder *pBrdAry=nullptr)
Definition: ruler.cxx:2556
void Deactivate() override
Definition: ruler.cxx:2231
tools::Long GetMargin2() const
Definition: ruler.cxx:2730
SVT_DLLPRIVATE void ImplDrawTab(vcl::RenderContext &rRenderContext, const Point &rPos, sal_uInt16 nStyle)
Definition: ruler.cxx:938
void DoubleClick()
Definition: ruler.cxx:2213
void DrawTicks()
Definition: ruler.cxx:2746
tools::Rectangle maExtraRect
Definition: ruler.hxx:627
void SetTextRTL(bool bRTL)
Definition: ruler.cxx:2704
const std::vector< RulerTab > & GetTabs() const
Definition: ruler.cxx:2677
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: ruler.cxx:981
tools::Long mnVirOff
Definition: ruler.hxx:618
std::map< OUString, SalLayoutGlyphs > maTextGlyphs
Definition: ruler.hxx:659
sal_uInt16 mnDragAryPos
Definition: ruler.hxx:630
SVT_DLLPRIVATE void ImplDrawTabs(vcl::RenderContext &rRenderContext, tools::Long nMin, tools::Long nMax, tools::Long nVirTop, tools::Long nVirBottom)
Definition: ruler.cxx:956
virtual void ExtraDown()
Definition: ruler.cxx:2218
RulerType GetRulerType(const Point &rPos, sal_uInt16 *pAryPos=nullptr)
Definition: ruler.cxx:2316
sal_uInt16 mnExtraStyle
Definition: ruler.hxx:633
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Definition: ruler.cxx:2752
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: ruler.cxx:2057
MapMode maMapMode
Definition: ruler.hxx:612
bool mbAutoWinWidth
Definition: ruler.hxx:646
void SetUnit(FieldUnit eNewUnit)
Definition: ruler.cxx:2378
tools::Long mnLineHeight
Definition: ruler.hxx:635
sal_uInt16 mnUnitIndex
Definition: ruler.hxx:629
bool mbCalc
Definition: ruler.hxx:641
SVT_DLLPRIVATE void ImplVDrawText(vcl::RenderContext &rRenderContext, tools::Long nX, tools::Long nY, const OUString &rText, tools::Long nMin=LONG_MIN, tools::Long nMax=LONG_MAX)
Definition: ruler.cxx:337
tools::Long mnCharWidth
Definition: ruler.hxx:634
WinBits mnWinStyle
Definition: ruler.hxx:628
std::unique_ptr< ImplRulerData > mpSaveData
Definition: ruler.hxx:624
virtual void Click()
Definition: ruler.cxx:2209
RulerType meDragType
Definition: ruler.hxx:638
bool IsValid() const
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
const Color & GetDarkShadowColor() const
const Color & GetWindowColor() const
const Color & GetShadowColor() const
const Color & GetWorkspaceColor() const
const Color & GetCheckedColor() const
const Color & GetLightColor() const
const vcl::Font & GetToolFont() const
const Color & GetDialogColor() const
const Color & GetFaceColor() const
const Color & GetButtonTextColor() const
bool IsTrackingEnded() const
bool IsTrackingCanceled() const
const MouseEvent & GetMouseEvent() const
ColorConfigValue GetColorValue(ColorConfigEntry eEntry, bool bSmart=true) const
Definition: colorcfg.cxx:478
void SetPoint(const Point &rPt, sal_uInt16 nPos)
void Optimize(PolyOptimizeFlags nOptimizeFlags)
constexpr Point Center() const
constexpr tools::Long GetWidth() const
bool Contains(const Point &rPOINT) const
constexpr void SetLeft(tools::Long v)
constexpr void SetTop(tools::Long v)
constexpr tools::Long Top() const
constexpr void SetRight(tools::Long v)
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
constexpr tools::Long Right() const
tools::Long AdjustTop(tools::Long nVertMoveDelta)
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
constexpr void SetBottom(tools::Long v)
constexpr tools::Long GetHeight() const
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
constexpr bool IsEmpty() const
void SetFontSize(const Size &)
void SetOrientation(Degree10 nLineOrientation)
const Size & GetFontSize() const
const Wallpaper & GetBackground() const
float GetDPIScaleFactor() const
bool IsReallyVisible() const
void StartTracking(StartTrackingFlags nFlags=StartTrackingFlags::NONE)
bool IsTracking() const
void ApplyControlBackground(vcl::RenderContext &rRenderContext, const Color &rDefaultColor)
void SetAccessible(const css::uno::Reference< css::accessibility::XAccessible > &)
bool IsUpdateMode() const
vcl::Window * GetAccessibleParentWindow() const
virtual void EnableRTL(bool bEnable=true)
virtual void SetOutputSizePixel(const Size &rNewSize)
const AllSettings & GetSettings() const
void SetTextFillColor()
::OutputDevice const * GetOutDev() const
const vcl::Font & GetFont() const
const Color & GetTextColor() const
css::uno::Reference< css::accessibility::XAccessible > GetAccessible(bool bCreate=true)
Size GetOutputSizePixel() const
Window(vcl::Window *pParent, WinBits nStyle=0)
virtual void SetPointer(PointerStyle)
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
void ApplyControlFont(vcl::RenderContext &rRenderContext, const vcl::Font &rDefaultFont)
void SetType(WindowType nType)
void ApplyControlForeground(vcl::RenderContext &rRenderContext, const Color &rDefaultColor)
Color GetTextFillColor() const
#define DBG_ASSERT(sCon, aError)
FieldUnit
sal_Int64 n
sal_Int32 nRef
sal_uInt16 nPos
#define SAL_WARN(area, stream)
MapUnit
aStr
int n2
int n1
NONE
int i
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
@ APPBACKGROUND
Definition: colorcfg.hxx:34
long Long
PointerStyle
QPRO_FUNC_TYPE nType
#define RULER_UNIT_MILE
Definition: ruler.cxx:59
#define RULER_VAR_SIZE
Definition: ruler.cxx:47
#define RULER_RESIZE_OFF
Definition: ruler.cxx:44
#define RULER_UNIT_MM
Definition: ruler.cxx:53
#define RULER_MIN_SIZE
Definition: ruler.cxx:45
static void ImplCenterTabPos(Point &rPos, sal_uInt16 nTabStyle)
Definition: ruler.cxx:809
static RulerTabData ruler_tab
Definition: ruler.cxx:156
#define RULER_UPDATE_LINES
Definition: ruler.cxx:49
#define RULER_UNIT_KM
Definition: ruler.cxx:56
#define RULER_UNIT_CHAR
Definition: ruler.cxx:62
#define RULER_UNIT_CM
Definition: ruler.cxx:54
#define RULER_UNIT_PICA
Definition: ruler.cxx:61
static int adjustSize(int nOrig)
Definition: ruler.cxx:972
static void ImplDrawRulerTab(vcl::RenderContext &rRenderContext, const Point &rPos, sal_uInt16 nStyle, WinBits nWinBits)
Definition: ruler.cxx:846
const RulerUnitData aImplRulerUnitTab[RULER_UNIT_COUNT]
Definition: ruler.cxx:141
#define RULER_CLIP
Definition: ruler.cxx:51
#define RULER_OFF
Definition: ruler.cxx:43
#define RULER_UNIT_POINT
Definition: ruler.cxx:60
#define RULER_UNIT_FOOT
Definition: ruler.cxx:58
#define RULER_UNIT_LINE
Definition: ruler.cxx:63
static void lcl_RotateRect_Impl(tools::Rectangle &rRect, const tools::Long nReference, bool bRightAligned)
Definition: ruler.cxx:827
#define RULER_UNIT_COUNT
Definition: ruler.cxx:64
#define RULER_UNIT_INCH
Definition: ruler.cxx:57
#define RULER_UNIT_M
Definition: ruler.cxx:55
constexpr auto RULER_MOUSE_BORDERMOVE
Definition: ruler.hxx:483
constexpr sal_uInt16 RULER_STYLE_DONTKNOW
Definition: ruler.hxx:474
constexpr sal_uInt16 RULER_TAB_STYLE
Definition: ruler.hxx:534
constexpr auto RULER_MOUSE_BORDERWIDTH
Definition: ruler.hxx:484
constexpr WinBits WB_EXTRAFIELD
Definition: ruler.hxx:462
RulerIndentStyle
Definition: ruler.hxx:517
RulerMarginStyle
Definition: ruler.hxx:488
constexpr sal_uInt16 RULER_TAB_DEFAULT
Definition: ruler.hxx:533
constexpr sal_uInt16 RULER_TAB_RIGHT
Definition: ruler.hxx:530
constexpr sal_uInt16 RULER_STYLE_HIGHLIGHT
Definition: ruler.hxx:473
constexpr sal_uInt16 RULER_STYLE_INVISIBLE
Definition: ruler.hxx:475
RulerExtra
Definition: ruler.hxx:471
constexpr sal_uInt16 RULER_TAB_RTL
Definition: ruler.hxx:535
constexpr sal_uInt16 RULER_TAB_LEFT
Definition: ruler.hxx:529
constexpr WinBits WB_RIGHT_ALIGNED
Definition: ruler.hxx:463
RulerType
Definition: ruler.hxx:467
constexpr auto RULER_MOUSE_MARGINWIDTH
Definition: ruler.hxx:485
constexpr sal_uInt16 RULER_TAB_DECIMAL
Definition: ruler.hxx:532
RulerBorderStyle
Definition: ruler.hxx:498
tools::Long nPos
Definition: ruler.hxx:510
tools::Long nWidth
Definition: ruler.hxx:511
RulerBorderStyle nStyle
Definition: ruler.hxx:512
RulerIndentStyle nStyle
Definition: ruler.hxx:524
tools::Long nPos
Definition: ruler.hxx:523
tools::Long nPos
Definition: ruler.hxx:546
bool bSizeBar
Definition: ruler.hxx:557
tools::Long nPos
Definition: ruler.hxx:552
RulerDragSize mnDragSize
Definition: ruler.hxx:555
sal_uInt16 nAryPos
Definition: ruler.hxx:554
bool bExpandTest
Definition: ruler.hxx:558
RulerType eType
Definition: ruler.hxx:553
sal_uInt16 dwidth
Definition: ruler.hxx:598
sal_uInt16 dwidth3
Definition: ruler.hxx:600
sal_uInt16 dwidth4
Definition: ruler.hxx:601
sal_uInt16 width2
Definition: ruler.hxx:591
sal_uInt16 cwidth2
Definition: ruler.hxx:593
sal_uInt16 textoff
Definition: ruler.hxx:602
sal_uInt16 cwidth
Definition: ruler.hxx:592
sal_uInt16 height
Definition: ruler.hxx:589
sal_uInt16 cwidth3
Definition: ruler.hxx:594
sal_uInt16 dwidth2
Definition: ruler.hxx:599
sal_uInt16 width
Definition: ruler.hxx:588
sal_uInt16 height2
Definition: ruler.hxx:590
sal_uInt16 cwidth4
Definition: ruler.hxx:595
sal_uInt16 DPIScaleFactor
Definition: ruler.hxx:587
sal_uInt16 dheight2
Definition: ruler.hxx:597
sal_uInt16 dheight
Definition: ruler.hxx:596
tools::Long nPos
Definition: ruler.hxx:539
sal_uInt16 nStyle
Definition: ruler.hxx:540
double nTick2
Definition: ruler.hxx:577
tools::Long nTickUnit
Definition: ruler.hxx:575
double nTick1
Definition: ruler.hxx:576
double nTick4
Definition: ruler.hxx:579
double nTick3
Definition: ruler.hxx:578
OUString SvtResId(TranslateId aId)
Definition: svtresid.cxx:24
bool bVisible
StateChangedType
sal_Int64 WinBits
WinBits const WB_VERT
WinBits const WB_3DLOOK
WinBits const WB_HORZ
WinBits const WB_BORDER