[Libreoffice-commits] core.git: 5 commits - include/svtools include/svx svtools/source svx/source vcl/source

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Wed Jun 3 04:48:32 PDT 2015


 include/svtools/ruler.hxx             |    9 -
 include/svx/ruler.hxx                 |    3 
 svtools/source/contnr/treelistbox.cxx |    2 
 svtools/source/control/ruler.cxx      |  248 +++++++++++++++-------------------
 svx/source/dialog/svxruler.cxx        |   46 ++----
 vcl/source/filter/graphicfilter.cxx   |   28 ++-
 vcl/source/window/window.cxx          |    3 
 7 files changed, 157 insertions(+), 182 deletions(-)

New commits:
commit f16d82ea8f1d2815faa978a4481c6b3c9c8705f8
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Wed Jun 3 20:21:05 2015 +0900

    make it possible to force enable double buffering for all widgets
    
    Change-Id: Ia0c8e9d8a22abaa2c06aea2a0f790dc34903ac37

diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 72433b0..8875195 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -743,7 +743,7 @@ WindowImpl::WindowImpl( WindowType nType )
     mbFill                              = true;
     mbSecondary                         = false;
     mbNonHomogeneous                    = false;
-    mbDoubleBuffering                   = false; // when we are not sure, assume it cannot do double-buffering via RenderContext
+    mbDoubleBuffering                   = getenv("VCL_DOUBLEBUFFERING_FORCE_ENABLE"); // when we are not sure, assume it cannot do double-buffering via RenderContext
 }
 
 WindowImpl::~WindowImpl()
@@ -3098,7 +3098,6 @@ void Window::Scroll( long nHorzScroll, long nVertScroll, ScrollFlags nFlags )
 void Window::Scroll( long nHorzScroll, long nVertScroll,
                      const Rectangle& rRect, ScrollFlags nFlags )
 {
-
     OutputDevice *pOutDev = GetOutDev();
     Rectangle aRect = pOutDev->ImplLogicToDevicePixel( rRect );
     aRect.Intersection( Rectangle( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) ) );
commit 2e4380a0773acb72c5ee30e976b8af6ece71396a
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Wed Jun 3 20:18:31 2015 +0900

    forgot to change the Invalidate to InvalidateEntry in treelistbox
    
    Change-Id: Ifa70abbecb6899d0e665039cecc2d9036ffc4b92

diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx
index f31f8c9..c698fe2 100644
--- a/svtools/source/contnr/treelistbox.cxx
+++ b/svtools/source/contnr/treelistbox.cxx
@@ -2675,7 +2675,7 @@ void SvTreeListBox::EditItemText(SvTreeListEntry* pEntry, SvLBoxString* pItem, c
     {
         pImp->ShowCursor( false );
         SelectListEntry( pEntry, false );
-        Invalidate();
+        pImp->InvalidateEntry(pEntry);
         SelectListEntry( pEntry, true );
         pImp->ShowCursor( true );
     }
commit 5ae10ae4df7180d4464f85586232cb7dc106ed5c
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Wed Jun 3 20:11:33 2015 +0900

    graphicfilter: store the funky animated GIF in a PNG as a GIF
    
    MS had a really bad idea to store an animated GIF inside a PNG for
    some reason. This situation was handled correctly in LO but we
    still pretended that this was a PNG file, which was causing
    confusion for some users that wanted to extract the image from
    the document. With this change we extract the animated GIF from
    the PNG and store just the GIF in the document.
    
    Change-Id: I4c70d118e8decd7aa1b108b6b1d725301904a35b

diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 0a8afa2..0a2cd01 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1455,21 +1455,28 @@ sal_uInt16 GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPat
             else
             {
                 // check if this PNG contains a GIF chunk!
-                const std::vector< vcl::PNGReader::ChunkData >&    rChunkData = aPNGReader.GetChunks();
-                std::vector< vcl::PNGReader::ChunkData >::const_iterator aIter( rChunkData.begin() );
-                std::vector< vcl::PNGReader::ChunkData >::const_iterator aEnd ( rChunkData.end() );
-                while( aIter != aEnd )
+                const std::vector<vcl::PNGReader::ChunkData>& rChunkData = aPNGReader.GetChunks();
+                std::vector<vcl::PNGReader::ChunkData>::const_iterator aIter(rChunkData.begin());
+                std::vector<vcl::PNGReader::ChunkData>::const_iterator aEnd(rChunkData.end());
+
+                while (aIter != aEnd)
                 {
                     // Microsoft Office is storing Animated GIFs in following chunk
-                    if ( aIter->nType == PMGCHUNG_msOG )
+                    if (aIter->nType == PMGCHUNG_msOG)
                     {
                         sal_uInt32 nChunkSize = aIter->aData.size();
-                        if ( nChunkSize > 11 )
+
+                        if (nChunkSize > 11)
                         {
-                            const std::vector< sal_uInt8 >& rData = aIter->aData;
-                            SvMemoryStream aIStrm( (void*)&rData[ 11 ], nChunkSize - 11, StreamMode::READ );
-                            ImportGIF( aIStrm, rGraphic );
-                            eLinkType = GFX_LINK_TYPE_NATIVE_PNG;
+                            const std::vector<sal_uInt8>& rData = aIter->aData;
+                            nGraphicContentSize = nChunkSize - 11;
+                            SvMemoryStream aIStrm(const_cast<sal_uInt8*>(&rData[11]), nGraphicContentSize, StreamMode::READ);
+                            pGraphicContent = new sal_uInt8[nGraphicContentSize];
+                            sal_uInt64 aCurrentPosition = aIStrm.Tell();
+                            aIStrm.Read(pGraphicContent, nGraphicContentSize);
+                            aIStrm.Seek(aCurrentPosition);
+                            ImportGIF(aIStrm, rGraphic);
+                            eLinkType = GFX_LINK_TYPE_NATIVE_GIF;
                             break;
                         }
                     }
@@ -1520,6 +1527,7 @@ sal_uInt16 GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPat
                 rIStream.Seek(nStreamPosition);
                 rIStream.Read(&aTwoBytes[0], 2);
                 rIStream.Seek(nStreamPosition);
+
                 if(aTwoBytes[0] == 0x1F && aTwoBytes[1] == 0x8B)
                 {
                     SvMemoryStream aMemStream;
commit f5e68baec68b545ce4e6a0b6dde58038e5d545fa
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Wed Jun 3 20:08:43 2015 +0900

    ruler: convert pCtrlItems to use vector of unique_ptr
    
    Change-Id: Icc6cf55c26d605fd068edf575613cde745385dd2

diff --git a/include/svx/ruler.hxx b/include/svx/ruler.hxx
index 01eaa6c..4968655 100644
--- a/include/svx/ruler.hxx
+++ b/include/svx/ruler.hxx
@@ -80,7 +80,8 @@ class SVX_DLLPUBLIC SvxRuler: public Ruler, public SfxListener
     friend class SvxRulerItem;
     using Window::Notify;
 
-    SvxRulerItem**      pCtrlItem;
+    std::vector<std::unique_ptr<SvxRulerItem> > pCtrlItems;
+
     std::unique_ptr<SvxLongLRSpaceItem> mxLRSpaceItem;    // left and right edge
     std::unique_ptr<SfxRectangleItem>   mxMinMaxItem;     // maxima for dragging
     std::unique_ptr<SvxLongULSpaceItem> mxULSpaceItem;    // upper and lower edge
diff --git a/svx/source/dialog/svxruler.cxx b/svx/source/dialog/svxruler.cxx
index 2565c95..18b18ae 100644
--- a/svx/source/dialog/svxruler.cxx
+++ b/svx/source/dialog/svxruler.cxx
@@ -223,7 +223,7 @@ SvxRuler::SvxRuler(
             SfxBindings &rBindings,      // associated Bindings
             WinBits nWinStyle) :         // StarView WinBits
     Ruler(pParent, nWinStyle),
-    pCtrlItem(new SvxRulerItem* [CTRL_ITEM_COUNT]),
+    pCtrlItems(CTRL_ITEM_COUNT),
     pEditWin(pWin),
     mxRulerImpl(new SvxRuler_Impl),
     bAppSetNullOffset(false),  // Is the 0-offset of the ruler set by the application?
@@ -252,42 +252,40 @@ SvxRuler::SvxRuler(
 {
     /* Constructor; Initialize data buffer; controller items are created */
 
-    memset(pCtrlItem, 0, sizeof(SvxRulerItem *) * CTRL_ITEM_COUNT);
-
     rBindings.EnterRegistrations();
 
     // Create Supported Items
     sal_uInt16 i = 0;
 
     // Page edges
-    pCtrlItem[i++] = new SvxRulerItem(SID_RULER_LR_MIN_MAX, *this, rBindings);
+    pCtrlItems[i++].reset(new SvxRulerItem(SID_RULER_LR_MIN_MAX, *this, rBindings));
     if((nWinStyle & WB_VSCROLL) == WB_VSCROLL)
     {
         bHorz = false;
-        pCtrlItem[i++] = new SvxRulerItem(SID_ATTR_LONG_ULSPACE, *this, rBindings);
+        pCtrlItems[i++].reset(new SvxRulerItem(SID_ATTR_LONG_ULSPACE, *this, rBindings));
     }
     else
     {
         bHorz = true;
-        pCtrlItem[i++] = new SvxRulerItem(SID_ATTR_LONG_LRSPACE, *this, rBindings);
+        pCtrlItems[i++].reset(new SvxRulerItem(SID_ATTR_LONG_LRSPACE, *this, rBindings));
     }
 
     // Page Position
-    pCtrlItem[i++] = new SvxRulerItem(SID_RULER_PAGE_POS, *this, rBindings);
+    pCtrlItems[i++].reset(new SvxRulerItem(SID_RULER_PAGE_POS, *this, rBindings));
 
     if(nFlags & SvxRulerSupportFlags::TABS)
     {
         sal_uInt16 nTabStopId = bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL;
-        pCtrlItem[i++] = new SvxRulerItem(nTabStopId, *this, rBindings);
+        pCtrlItems[i++].reset(new SvxRulerItem(nTabStopId, *this, rBindings));
         SetExtraType(RULER_EXTRA_TAB, nDefTabType);
     }
 
     if(nFlags & (SvxRulerSupportFlags::PARAGRAPH_MARGINS |SvxRulerSupportFlags::PARAGRAPH_MARGINS_VERTICAL))
     {
         if(bHorz)
-            pCtrlItem[i++] = new SvxRulerItem(SID_ATTR_PARA_LRSPACE, *this, rBindings);
+            pCtrlItems[i++].reset(new SvxRulerItem(SID_ATTR_PARA_LRSPACE, *this, rBindings));
         else
-            pCtrlItem[i++] = new SvxRulerItem(SID_ATTR_PARA_LRSPACE_VERTICAL, *this, rBindings);
+            pCtrlItems[i++].reset(new SvxRulerItem(SID_ATTR_PARA_LRSPACE_VERTICAL, *this, rBindings));
 
         mpIndents.resize(5 + INDENT_GAP);
 
@@ -306,15 +304,15 @@ SvxRuler::SvxRuler(
 
     if( (nFlags & SvxRulerSupportFlags::BORDERS) ==  SvxRulerSupportFlags::BORDERS )
     {
-        pCtrlItem[i++] = new SvxRulerItem(bHorz ? SID_RULER_BORDERS : SID_RULER_BORDERS_VERTICAL, *this, rBindings);
-        pCtrlItem[i++] = new SvxRulerItem(bHorz ? SID_RULER_ROWS : SID_RULER_ROWS_VERTICAL, *this, rBindings);
+        pCtrlItems[i++].reset(new SvxRulerItem(bHorz ? SID_RULER_BORDERS : SID_RULER_BORDERS_VERTICAL, *this, rBindings));
+        pCtrlItems[i++].reset(new SvxRulerItem(bHorz ? SID_RULER_ROWS : SID_RULER_ROWS_VERTICAL, *this, rBindings));
     }
 
-    pCtrlItem[i++] = new SvxRulerItem(SID_RULER_TEXT_RIGHT_TO_LEFT, *this, rBindings);
+    pCtrlItems[i++].reset(new SvxRulerItem(SID_RULER_TEXT_RIGHT_TO_LEFT, *this, rBindings));
 
     if( (nFlags & SvxRulerSupportFlags::OBJECT) == SvxRulerSupportFlags::OBJECT )
     {
-        pCtrlItem[i++] = new SvxRulerItem(SID_RULER_OBJECT, *this, rBindings );
+        pCtrlItems[i++].reset(new SvxRulerItem(SID_RULER_OBJECT, *this, rBindings));
         mpObjectBorders.resize(OBJECT_BORDER_COUNT);
         for(sal_uInt16 nBorder = 0; nBorder < OBJECT_BORDER_COUNT; ++nBorder)
         {
@@ -324,8 +322,8 @@ SvxRuler::SvxRuler(
         }
     }
 
-    pCtrlItem[i++] = new SvxRulerItem(SID_RULER_PROTECT, *this, rBindings );
-    pCtrlItem[i++] = new SvxRulerItem(SID_RULER_BORDER_DISTANCE, *this, rBindings);
+    pCtrlItems[i++].reset(new SvxRulerItem(SID_RULER_PROTECT, *this, rBindings));
+    pCtrlItems[i++].reset(new SvxRulerItem(SID_RULER_BORDER_DISTANCE, *this, rBindings));
     mxRulerImpl->nControlerItems=i;
 
     if( (nFlags & SvxRulerSupportFlags::SET_NULLOFFSET) == SvxRulerSupportFlags::SET_NULLOFFSET )
@@ -353,13 +351,7 @@ void SvxRuler::dispose()
 
     pBindings->EnterRegistrations();
 
-    if (pCtrlItem)
-    {
-        for(sal_uInt16 i = 0; i < CTRL_ITEM_COUNT  && pCtrlItem[i]; ++i)
-            delete pCtrlItem[i];
-        delete[] pCtrlItem;
-        pCtrlItem = NULL;
-    }
+    pCtrlItems.clear();
 
     pBindings->LeaveRegistrations();
 
@@ -1768,10 +1760,10 @@ void SvxRuler::SetActive(bool bOn)
         pBindings->EnterRegistrations();
         if(bOn)
             for(sal_uInt16 i=0;i<mxRulerImpl->nControlerItems;i++)
-                pCtrlItem[i]->ReBind();
+                pCtrlItems[i]->ReBind();
         else
             for(sal_uInt16 j=0;j<mxRulerImpl->nControlerItems;j++)
-                pCtrlItem[j]->UnBind();
+                pCtrlItems[j]->UnBind();
         pBindings->LeaveRegistrations();
     }
     bActive = bOn;
@@ -3383,8 +3375,8 @@ void SvxRuler::EndDrag()
     {
         for(sal_uInt16 i = 0; i < mxRulerImpl->nControlerItems; i++)
         {
-            pCtrlItem[i]->ClearCache();
-            pCtrlItem[i]->GetBindings().Invalidate(pCtrlItem[i]->GetId());
+            pCtrlItems[i]->ClearCache();
+            pCtrlItems[i]->GetBindings().Invalidate(pCtrlItems[i]->GetId());
         }
     }
 }
commit f64588a9238cf0cb122c43d927d73822eca3b6ae
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Wed Jun 3 17:49:41 2015 +0900

    tdf#91677 fix flickering ruler
    
    Change-Id: Ia14be98fbfd46871b2ac9bd42a07951d86722a8a

diff --git a/include/svtools/ruler.hxx b/include/svtools/ruler.hxx
index 4724334..27b1380 100644
--- a/include/svtools/ruler.hxx
+++ b/include/svtools/ruler.hxx
@@ -663,9 +663,10 @@ private:
 
     SvtRulerAccessible* pAccContext;
 
-    SVT_DLLPRIVATE void ImplVDrawLine( long nX1, long nY1, long nX2, long nY2 );
-    SVT_DLLPRIVATE void ImplVDrawRect( long nX1, long nY1, long nX2, long nY2 );
-    SVT_DLLPRIVATE void ImplVDrawText( long nX, long nY, const OUString& rText, long nMin = LONG_MIN, long nMax = LONG_MAX );
+    SVT_DLLPRIVATE void ImplVDrawLine(vcl::RenderContext& rRenderContext,  long nX1, long nY1, long nX2, long nY2 );
+    SVT_DLLPRIVATE void ImplVDrawRect(vcl::RenderContext& rRenderContext, long nX1, long nY1, long nX2, long nY2 );
+    SVT_DLLPRIVATE void ImplVDrawText(vcl::RenderContext& rRenderContext, long nX, long nY, const OUString& rText,
+                                      long nMin = LONG_MIN, long nMax = LONG_MAX );
 
     SVT_DLLPRIVATE void ImplDrawTicks(vcl::RenderContext& rRenderContext,
                                       long nMin, long nMax, long nStart, long nVirTop, long nVirBottom);
@@ -702,8 +703,6 @@ private:
     SVT_DLLPRIVATE void     ImplDrag( const Point& rPos );
     SVT_DLLPRIVATE void     ImplEndDrag();
 
-    DECL_DLLPRIVATE_LINK( ImplUpdateHdl, void* );
-
     Ruler (const Ruler &) SAL_DELETED_FUNCTION;
     Ruler& operator= (const Ruler &) SAL_DELETED_FUNCTION;
 
diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx
index 33d92f0..2d9aef0 100644
--- a/svtools/source/control/ruler.cxx
+++ b/svtools/source/control/ruler.cxx
@@ -45,7 +45,6 @@ using namespace ::com::sun::star::accessibility;
 #define RULER_VAR_SIZE      8
 
 #define RULER_UPDATE_LINES  0x01
-#define RULER_UPDATE_DRAW   0x02
 
 #define RULER_CLIP          150
 
@@ -343,7 +342,7 @@ void Ruler::dispose()
     Window::dispose();
 }
 
-void Ruler::ImplVDrawLine( long nX1, long nY1, long nX2, long nY2 )
+void Ruler::ImplVDrawLine(vcl::RenderContext& rRenderContext, long nX1, long nY1, long nX2, long nY2)
 {
     if ( nX1 < -RULER_CLIP )
     {
@@ -360,12 +359,12 @@ void Ruler::ImplVDrawLine( long nX1, long nY1, long nX2, long nY2 )
     }
 
     if ( mnWinStyle & WB_HORZ )
-        maVirDev->DrawLine( Point( nX1, nY1 ), Point( nX2, nY2 ) );
+        rRenderContext.DrawLine( Point( nX1, nY1 ), Point( nX2, nY2 ) );
     else
-        maVirDev->DrawLine( Point( nY1, nX1 ), Point( nY2, nX2 ) );
+        rRenderContext.DrawLine( Point( nY1, nX1 ), Point( nY2, nX2 ) );
 }
 
-void Ruler::ImplVDrawRect( long nX1, long nY1, long nX2, long nY2 )
+void Ruler::ImplVDrawRect(vcl::RenderContext& rRenderContext, long nX1, long nY1, long nX2, long nY2)
 {
     if ( nX1 < -RULER_CLIP )
     {
@@ -382,15 +381,15 @@ void Ruler::ImplVDrawRect( long nX1, long nY1, long nX2, long nY2 )
     }
 
     if ( mnWinStyle & WB_HORZ )
-        maVirDev->DrawRect( Rectangle( nX1, nY1, nX2, nY2 ) );
+        rRenderContext.DrawRect(Rectangle(nX1, nY1, nX2, nY2));
     else
-        maVirDev->DrawRect( Rectangle( nY1, nX1, nY2, nX2 ) );
+        rRenderContext.DrawRect(Rectangle(nY1, nX1, nY2, nX2));
 }
 
-void Ruler::ImplVDrawText( long nX, long nY, const OUString& rText, long nMin, long nMax )
+void Ruler::ImplVDrawText(vcl::RenderContext& rRenderContext, long nX, long nY, const OUString& rText, long nMin, long nMax)
 {
     Rectangle aRect;
-    maVirDev->GetTextBoundRect( aRect, rText );
+    rRenderContext.GetTextBoundRect(aRect, rText);
 
     long nShiftX = ( aRect.GetWidth() / 2 ) + aRect.Left();
     long nShiftY = ( aRect.GetHeight() / 2 ) + aRect.Top();
@@ -398,9 +397,9 @@ void Ruler::ImplVDrawText( long nX, long nY, const OUString& rText, long nMin, l
     if ( (nX > -RULER_CLIP) && (nX < mnVirWidth + RULER_CLIP) && ( nX < nMax - nShiftX ) && ( nX > nMin + nShiftX ) )
     {
         if ( mnWinStyle & WB_HORZ )
-            maVirDev->DrawText( Point( nX - nShiftX, nY - nShiftY ), rText );
+            rRenderContext.DrawText(Point(nX - nShiftX, nY - nShiftY), rText);
         else
-            maVirDev->DrawText( Point( nY - nShiftX, nX - nShiftY ), rText );
+            rRenderContext.DrawText(Point(nY - nShiftX, nX - nShiftY), rText);
     }
 }
 
@@ -463,6 +462,7 @@ void Ruler::ImplInvertLines(vcl::RenderContext& rRenderContext, bool bErase)
                 Invert(aRect);
             }
         }
+        mnUpdateFlags = 0;
     }
 }
 
@@ -486,7 +486,7 @@ void Ruler::ImplDrawTicks(vcl::RenderContext& rRenderContext, long nMin, long nM
 
     double nAcceptanceDelta = 0.0001;
 
-    Size aPixSize = maVirDev->LogicToPixel(Size(nTick4, nTick4), maMapMode);
+    Size aPixSize = rRenderContext.LogicToPixel(Size(nTick4, nTick4), maMapMode);
 
     if (mnUnitIndex == RULER_UNIT_CHAR)
     {
@@ -518,11 +518,11 @@ void Ruler::ImplDrawTicks(vcl::RenderContext& rRenderContext, long nMin, long nM
             aFont.SetOrientation(2700);
         else
             aFont.SetOrientation(900);
-        maVirDev->SetFont(aFont);
+        rRenderContext.SetFont(aFont);
         nTickWidth = aPixSize.Height();
     }
 
-    long nMaxWidth = maVirDev->PixelToLogic(Size(mpData->nPageWidth, 0), maMapMode).Width();
+    long nMaxWidth = rRenderContext.PixelToLogic(Size(mpData->nPageWidth, 0), maMapMode).Width();
     if (nMaxWidth < 0)
         nMaxWidth = -nMaxWidth;
 
@@ -532,7 +532,7 @@ void Ruler::ImplDrawTicks(vcl::RenderContext& rRenderContext, long nMin, long nM
         nMaxWidth /= aImplRulerUnitTab[mnUnitIndex].nTickUnit;
 
     OUString aNumString = OUString::number(nMaxWidth);
-    long nTxtWidth = GetTextWidth( aNumString );
+    long nTxtWidth = rRenderContext.GetTextWidth( aNumString );
     const long nTextOff = 4;
 
     // Determine the number divider for ruler drawn numbers - means which numbers
@@ -566,7 +566,7 @@ void Ruler::ImplDrawTicks(vcl::RenderContext& rRenderContext, long nMin, long nM
             }
 
             nTick4 = nOrgTick4 * nMulti;
-            aPixSize = maVirDev->LogicToPixel(Size(nTick4, nTick4), maMapMode);
+            aPixSize = rRenderContext.LogicToPixel(Size(nTick4, nTick4), maMapMode);
             if (mnWinStyle & WB_HORZ)
                 nTickWidth = aPixSize.Width();
             else
@@ -576,7 +576,7 @@ void Ruler::ImplDrawTicks(vcl::RenderContext& rRenderContext, long nMin, long nM
     }
     else
     {
-        maVirDev->SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetShadowColor());
+        rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetShadowColor());
     }
 
     if (!bNoTicks)
@@ -593,11 +593,11 @@ void Ruler::ImplDrawTicks(vcl::RenderContext& rRenderContext, long nMin, long nM
 
         Size nTickGapSize;
 
-        nTickGapSize = maVirDev->LogicToPixel(Size(nTickCount, nTickCount), maMapMode);
+        nTickGapSize = rRenderContext.LogicToPixel(Size(nTickCount, nTickCount), maMapMode);
         long nTickGap1 = mnWinStyle & WB_HORZ ? nTickGapSize.Width() : nTickGapSize.Height();
-        nTickGapSize = maVirDev->LogicToPixel(Size(nTick2, nTick2), maMapMode);
+        nTickGapSize = rRenderContext.LogicToPixel(Size(nTick2, nTick2), maMapMode);
         long nTickGap2 = mnWinStyle & WB_HORZ ? nTickGapSize.Width() : nTickGapSize.Height();
-        nTickGapSize = maVirDev->LogicToPixel(Size(nTick3, nTick3), maMapMode);
+        nTickGapSize = rRenderContext.LogicToPixel(Size(nTick3, nTick3), maMapMode);
         long nTickGap3 = mnWinStyle & WB_HORZ ? nTickGapSize.Width() : nTickGapSize.Height();
 
         while (((nStart - n) >= nMin) || ((nStart + n) <= nMax))
@@ -611,13 +611,13 @@ void Ruler::ImplDrawTicks(vcl::RenderContext& rRenderContext, long nMin, long nM
                     if ((mpData->nMargin1Style & RULER_STYLE_INVISIBLE) || (mpData->nMargin1 != 0))
                     {
                         aNumString = "0";
-                        ImplVDrawText(nStart, nCenter, aNumString);
+                        ImplVDrawText(rRenderContext, nStart, nCenter, aNumString);
                     }
                 }
             }
             else
             {
-                aPixSize = maVirDev->LogicToPixel(Size(nTick, nTick), maMapMode);
+                aPixSize = rRenderContext.LogicToPixel(Size(nTick, nTick), maMapMode);
 
                 if (mnWinStyle & WB_HORZ)
                     n = aPixSize.Width();
@@ -636,21 +636,23 @@ void Ruler::ImplDrawTicks(vcl::RenderContext& rRenderContext, long nMin, long nM
                         aNumString = OUString::number(nTick / aImplRulerUnitTab[mnUnitIndex].nTickUnit);
 
                     long nHorizontalLocation = nStart + n;
-                    ImplVDrawText(nHorizontalLocation, nCenter, aNumString, nMin, nMax);
+                    ImplVDrawText(rRenderContext, nHorizontalLocation, nCenter, aNumString, nMin, nMax);
 
                     if (nMin < nHorizontalLocation && nHorizontalLocation < nMax)
                     {
-                        ImplVDrawRect(nHorizontalLocation, nBottom, nHorizontalLocation + DPIOffset, nBottom - 1 * nScale);
-                        ImplVDrawRect(nHorizontalLocation, nTop,    nHorizontalLocation + DPIOffset, nTop + 1 * nScale);
+                        ImplVDrawRect(rRenderContext, nHorizontalLocation, nBottom, nHorizontalLocation + DPIOffset, nBottom - 1 * nScale);
+                        ImplVDrawRect(rRenderContext, nHorizontalLocation, nTop,    nHorizontalLocation + DPIOffset, nTop + 1 * nScale);
                     }
 
                     nHorizontalLocation = nStart - n;
-                    ImplVDrawText(nHorizontalLocation, nCenter, aNumString, nMin, nMax);
+                    ImplVDrawText(rRenderContext, nHorizontalLocation, nCenter, aNumString, nMin, nMax);
 
                     if (nMin < nHorizontalLocation && nHorizontalLocation < nMax)
                     {
-                        ImplVDrawRect(nHorizontalLocation, nBottom, nHorizontalLocation + DPIOffset, nBottom - 1 * nScale);
-                        ImplVDrawRect( nHorizontalLocation, nTop,    nHorizontalLocation + DPIOffset, nTop + 1 * nScale );
+                        ImplVDrawRect(rRenderContext, nHorizontalLocation, nBottom,
+                                                      nHorizontalLocation + DPIOffset, nBottom - 1 * nScale);
+                        ImplVDrawRect(rRenderContext, nHorizontalLocation, nTop,
+                                                      nHorizontalLocation + DPIOffset, nTop + 1 * nScale);
                     }
                 }
                 // Tick/Tick2 - Output (Strokes)
@@ -679,10 +681,10 @@ void Ruler::ImplDrawTicks(vcl::RenderContext& rRenderContext, long nMin, long nM
                         nT = nStart + n;
 
                         if (nT < nMax)
-                            ImplVDrawRect(nT, nT1, nT + DPIOffset, nT2);
+                            ImplVDrawRect(rRenderContext, nT, nT1, nT + DPIOffset, nT2);
                         nT = nStart - n;
                         if (nT > nMin)
-                            ImplVDrawRect(nT, nT1, nT + DPIOffset, nT2);
+                            ImplVDrawRect(rRenderContext, nT, nT1, nT + DPIOffset, nT2);
                     }
                 }
             }
@@ -713,21 +715,21 @@ void Ruler::ImplDrawBorders(vcl::RenderContext& rRenderContext, long nMin, long
         {
             if ((n2 - n1) > 3)
             {
-                maVirDev->SetLineColor();
-                maVirDev->SetFillColor(rStyleSettings.GetFaceColor());
-                ImplVDrawRect(n1, nVirTop, n2, nVirBottom);
+                rRenderContext.SetLineColor();
+                rRenderContext.SetFillColor(rStyleSettings.GetFaceColor());
+                ImplVDrawRect(rRenderContext, n1, nVirTop, n2, nVirBottom);
 
-                maVirDev->SetLineColor(rStyleSettings.GetLightColor());
-                ImplVDrawLine(n1 + 1, nVirTop, n1 + 1, nVirBottom);
-                ImplVDrawLine(n1,     nVirTop, n2,     nVirTop);
+                rRenderContext.SetLineColor(rStyleSettings.GetLightColor());
+                ImplVDrawLine(rRenderContext, n1 + 1, nVirTop, n1 + 1, nVirBottom);
+                ImplVDrawLine(rRenderContext, n1,     nVirTop, n2,     nVirTop);
 
-                maVirDev->SetLineColor(rStyleSettings.GetShadowColor());
-                ImplVDrawLine(n1,     nVirTop,    n1,     nVirBottom);
-                ImplVDrawLine(n1,     nVirBottom, n2,     nVirBottom);
-                ImplVDrawLine(n2 - 1, nVirTop,    n2 - 1, nVirBottom);
+                rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
+                ImplVDrawLine(rRenderContext, n1,     nVirTop,    n1,     nVirBottom);
+                ImplVDrawLine(rRenderContext, n1,     nVirBottom, n2,     nVirBottom);
+                ImplVDrawLine(rRenderContext, n2 - 1, nVirTop,    n2 - 1, nVirBottom);
 
-                maVirDev->SetLineColor(rStyleSettings.GetDarkShadowColor());
-                ImplVDrawLine(n2, nVirTop, n2, nVirBottom);
+                rRenderContext.SetLineColor(rStyleSettings.GetDarkShadowColor());
+                ImplVDrawLine(rRenderContext, n2, nVirTop, n2, nVirBottom);
 
                 if (mpData->pBorders[i].nStyle & RULER_BORDER_VARIABLE)
                 {
@@ -739,18 +741,18 @@ void Ruler::ImplDrawBorders(vcl::RenderContext& rRenderContext, long nMin, long
                         long nTemp4 = nTemp2 + RULER_VAR_SIZE - 1;
                         long nTempY = nTemp2;
 
-                        maVirDev->SetLineColor(rStyleSettings.GetLightColor());
+                        rRenderContext.SetLineColor(rStyleSettings.GetLightColor());
                         while (nTempY <= nTemp4)
                         {
-                            ImplVDrawLine(nTemp1, nTempY, nTemp3, nTempY);
+                            ImplVDrawLine(rRenderContext, nTemp1, nTempY, nTemp3, nTempY);
                             nTempY += 2;
                         }
 
                         nTempY = nTemp2 + 1;
-                        maVirDev->SetLineColor(rStyleSettings.GetShadowColor());
+                        rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
                         while (nTempY <= nTemp4)
                         {
-                            ImplVDrawLine(nTemp1, nTempY, nTemp3, nTempY);
+                            ImplVDrawLine(rRenderContext, nTemp1, nTempY, nTemp3, nTempY);
                             nTempY += 2;
                         }
                     }
@@ -760,31 +762,31 @@ void Ruler::ImplDrawBorders(vcl::RenderContext& rRenderContext, long nMin, long
                 {
                     if (n2 - n1 > RULER_VAR_SIZE + 10)
                     {
-                        maVirDev->SetLineColor(rStyleSettings.GetShadowColor());
-                        ImplVDrawLine(n1 + 4, nVirTop + 3, n1 + 4, nVirBottom - 3);
-                        ImplVDrawLine(n2 - 5, nVirTop + 3, n2 - 5, nVirBottom - 3);
-                        maVirDev->SetLineColor( rStyleSettings.GetLightColor());
-                        ImplVDrawLine(n1 + 5, nVirTop + 3, n1 + 5, nVirBottom - 3);
-                        ImplVDrawLine(n2 - 4, nVirTop + 3, n2 - 4, nVirBottom - 3);
+                        rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
+                        ImplVDrawLine(rRenderContext, n1 + 4, nVirTop + 3, n1 + 4, nVirBottom - 3);
+                        ImplVDrawLine(rRenderContext, n2 - 5, nVirTop + 3, n2 - 5, nVirBottom - 3);
+                        rRenderContext.SetLineColor(rStyleSettings.GetLightColor());
+                        ImplVDrawLine(rRenderContext, n1 + 5, nVirTop + 3, n1 + 5, nVirBottom - 3);
+                        ImplVDrawLine(rRenderContext, n2 - 4, nVirTop + 3, n2 - 4, nVirBottom - 3);
                     }
                 }
             }
             else
             {
                 n = n1 + ((n2 - n1) / 2);
-                maVirDev->SetLineColor(rStyleSettings.GetShadowColor());
+                rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
 
                 if (mpData->pBorders[i].nStyle & RULER_BORDER_SNAP)
-                    ImplVDrawLine(n, nVirTop, n, nVirBottom);
+                    ImplVDrawLine(rRenderContext, n, nVirTop, n, nVirBottom);
                 else if (mpData->pBorders[i].nStyle & RULER_BORDER_MARGIN)
-                    ImplVDrawLine(n, nVirTop, n, nVirBottom);
+                    ImplVDrawLine(rRenderContext, n, nVirTop, n, nVirBottom);
                 else
                 {
-                    ImplVDrawLine(n - 1, nVirTop, n - 1, nVirBottom);
-                    ImplVDrawLine(n + 1, nVirTop, n + 1, nVirBottom);
-                    maVirDev->SetLineColor();
-                    maVirDev->SetFillColor(rStyleSettings.GetWindowColor());
-                    ImplVDrawRect(n, nVirTop, n, nVirBottom);
+                    ImplVDrawLine(rRenderContext, n - 1, nVirTop, n - 1, nVirBottom);
+                    ImplVDrawLine(rRenderContext, n + 1, nVirTop, n + 1, nVirBottom);
+                    rRenderContext.SetLineColor();
+                    rRenderContext.SetFillColor(rStyleSettings.GetWindowColor());
+                    ImplVDrawRect(rRenderContext, n, nVirTop, n, nVirBottom);
                 }
             }
         }
@@ -798,9 +800,9 @@ void Ruler::ImplDrawIndent(vcl::RenderContext& rRenderContext, const Polygon& rP
     if (nStyle & RULER_STYLE_INVISIBLE)
         return;
 
-    maVirDev->SetLineColor(rStyleSettings.GetDarkShadowColor());
-    maVirDev->SetFillColor(bIsHit ? rStyleSettings.GetDarkShadowColor() : rStyleSettings.GetWorkspaceColor());
-    maVirDev->DrawPolygon(rPoly);
+    rRenderContext.SetLineColor(rStyleSettings.GetDarkShadowColor());
+    rRenderContext.SetFillColor(bIsHit ? rStyleSettings.GetDarkShadowColor() : rStyleSettings.GetWorkspaceColor());
+    rRenderContext.DrawPolygon(rPoly);
 }
 
 void Ruler::ImplDrawIndents(vcl::RenderContext& rRenderContext, long nMin, long nMax, long nVirTop, long nVirBottom)
@@ -827,8 +829,8 @@ void Ruler::ImplDrawIndents(vcl::RenderContext& rRenderContext, long nMin, long
             if (nIndentStyle == RULER_INDENT_BORDER)
             {
                 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
-                maVirDev->SetLineColor(rStyleSettings.GetShadowColor());
-                ImplVDrawLine(n, nVirTop + 1, n, nVirBottom - 1);
+                rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
+                ImplVDrawLine(rRenderContext, n, nVirTop + 1, n, nVirBottom - 1);
             }
             else if (nIndentStyle == RULER_INDENT_BOTTOM)
             {
@@ -1020,7 +1022,7 @@ void Ruler::ImplDrawTab(vcl::RenderContext& rRenderContext, const Point& rPos, s
     ImplDrawRulerTab(rRenderContext, rPos, nStyle, GetStyle());
 }
 
-void Ruler::ImplDrawTabs(vcl::RenderContext& /*rRenderContext*/, long nMin, long nMax, long nVirTop, long nVirBottom)
+void Ruler::ImplDrawTabs(vcl::RenderContext& rRenderContext, long nMin, long nMax, long nVirTop, long nVirBottom)
 {
     for (size_t i = 0; i < mpData->pTabs.size(); i++)
     {
@@ -1032,7 +1034,7 @@ void Ruler::ImplDrawTabs(vcl::RenderContext& /*rRenderContext*/, long nMin, long
         aPosition += +mpData->nNullVirOff;
         long nTopBottom = (GetStyle() & WB_RIGHT_ALIGNED) ? nVirTop : nVirBottom;
         if (nMin <= aPosition && aPosition <= nMax)
-            ImplDrawTab(*maVirDev.get(), Point( aPosition, nTopBottom ), mpData->pTabs[i].nStyle);
+            ImplDrawTab(rRenderContext, Point( aPosition, nTopBottom ), mpData->pTabs[i].nStyle);
     }
 }
 
@@ -1245,8 +1247,8 @@ void Ruler::ImplFormat(vcl::RenderContext& rRenderContext)
 
     // top/bottom border
     maVirDev->SetLineColor(rStyleSettings.GetShadowColor());
-    ImplVDrawLine(nVirLeft, nVirTop + 1, nM1,     nVirTop + 1); //top left line
-    ImplVDrawLine(nM2,      nVirTop + 1, nP2 - 1, nVirTop + 1); //top right line
+    ImplVDrawLine(*maVirDev.get(), nVirLeft, nVirTop + 1, nM1,     nVirTop + 1); //top left line
+    ImplVDrawLine(*maVirDev.get(), nM2,      nVirTop + 1, nP2 - 1, nVirTop + 1); //top right line
 
     nVirTop++;
     nVirBottom--;
@@ -1255,31 +1257,31 @@ void Ruler::ImplFormat(vcl::RenderContext& rRenderContext)
     maVirDev->SetLineColor();
     maVirDev->SetFillColor(rStyleSettings.GetDialogColor());
     if (nM1 > nVirLeft)
-        ImplVDrawRect(nP1, nVirTop + 1, nM1, nVirBottom); //left gray rectangle
+        ImplVDrawRect(*maVirDev.get(), nP1, nVirTop + 1, nM1, nVirBottom); //left gray rectangle
     if (nM2 < nP2)
-        ImplVDrawRect(nM2, nVirTop + 1, nP2, nVirBottom); //right gray rectangle
+        ImplVDrawRect(*maVirDev.get(), nM2, nVirTop + 1, nP2, nVirBottom); //right gray rectangle
     if (nM2 - nM1 > 0)
     {
         maVirDev->SetFillColor(rStyleSettings.GetWindowColor());
-        ImplVDrawRect(nM1 + 1, nVirTop, nM2 - 1, nVirBottom); //center rectangle
+        ImplVDrawRect(*maVirDev.get(), nM1 + 1, nVirTop, nM2 - 1, nVirBottom); //center rectangle
     }
     maVirDev->SetLineColor(rStyleSettings.GetShadowColor());
     if (nM1 > nVirLeft)
     {
-        ImplVDrawLine(nM1, nVirTop + 1, nM1, nVirBottom); //right line of the left rectangle
-        ImplVDrawLine(nP1, nVirBottom,  nM1, nVirBottom); //bottom line of the left rectangle
+        ImplVDrawLine(*maVirDev.get(), nM1, nVirTop + 1, nM1, nVirBottom); //right line of the left rectangle
+        ImplVDrawLine(*maVirDev.get(), nP1, nVirBottom,  nM1, nVirBottom); //bottom line of the left rectangle
         if (nP1 >= nVirLeft)
         {
-            ImplVDrawLine(nP1, nVirTop + 1, nP1,     nVirBottom); //left line of the left rectangle
-            ImplVDrawLine(nP1, nVirBottom,  nP1 + 1, nVirBottom); //?
+            ImplVDrawLine(*maVirDev.get(), nP1, nVirTop + 1, nP1,     nVirBottom); //left line of the left rectangle
+            ImplVDrawLine(*maVirDev.get(), nP1, nVirBottom,  nP1 + 1, nVirBottom); //?
         }
     }
     if (nM2 < nP2)
     {
-        ImplVDrawLine(nM2, nVirBottom,  nP2 - 1, nVirBottom); //bottom line of the right rectangle
-        ImplVDrawLine(nM2, nVirTop + 1, nM2,     nVirBottom); //left line of the right rectangle
+        ImplVDrawLine(*maVirDev.get(), nM2, nVirBottom,  nP2 - 1, nVirBottom); //bottom line of the right rectangle
+        ImplVDrawLine(*maVirDev.get(), nM2, nVirTop + 1, nM2,     nVirBottom); //left line of the right rectangle
         if (nP2 <= nVirRight + 1)
-            ImplVDrawLine(nP2 - 1, nVirTop + 1, nP2 - 1, nVirBottom); //right line of the right rectangle
+            ImplVDrawLine(*maVirDev.get(), nP2 - 1, nVirTop + 1, nP2 - 1, nVirBottom); //right line of the right rectangle
     }
 
     long nMin = nVirLeft;
@@ -1298,19 +1300,19 @@ void Ruler::ImplFormat(vcl::RenderContext& rRenderContext)
         nMax--;
 
     // Draw captions
-    ImplDrawTicks(rRenderContext, nMin, nMax, nStart, nVirTop, nVirBottom);
+    ImplDrawTicks(*maVirDev.get(), nMin, nMax, nStart, nVirTop, nVirBottom);
 
     // Draw borders
     if (!mpData->pBorders.empty())
-        ImplDrawBorders(rRenderContext, nVirLeft, nP2, nVirTop, nVirBottom);
+        ImplDrawBorders(*maVirDev.get(), nVirLeft, nP2, nVirTop, nVirBottom);
 
     // Draw indents
     if (!mpData->pIndents.empty())
-        ImplDrawIndents(rRenderContext, nVirLeft, nP2, nVirTop - 1, nVirBottom + 1);
+        ImplDrawIndents(*maVirDev.get(), nVirLeft, nP2, nVirTop - 1, nVirBottom + 1);
 
     // Tabs
     if (!mpData->pTabs.empty())
-        ImplDrawTabs(rRenderContext, nVirLeft, nP2, nVirTop-1, nVirBottom + 1);
+        ImplDrawTabs(*maVirDev.get(), nVirLeft, nP2, nVirTop-1, nVirBottom + 1);
 
     mbFormat = false;
 }
@@ -1467,7 +1469,7 @@ void Ruler::ImplUpdate( bool bMustCalc )
 {
     // clear lines in this place so they aren't considered at recalculation
     if (!mbFormat)
-        Invalidate();
+        Invalidate(InvalidateFlags::NoErase);
 
     // set flags
     if (bMustCalc)
@@ -1481,9 +1483,7 @@ void Ruler::ImplUpdate( bool bMustCalc )
     // otherwise trigger update
     if (IsReallyVisible() && IsUpdateMode())
     {
-        mnUpdateFlags |= RULER_UPDATE_DRAW;
-        if (!mnUpdateEvtId)
-            mnUpdateEvtId = Application::PostUserEvent(LINK( this, Ruler, ImplUpdateHdl), NULL, true);
+        Invalidate(InvalidateFlags::NoErase);
     }
 }
 
@@ -1876,10 +1876,10 @@ bool Ruler::ImplStartDrag( RulerSelection* pHitTest, sal_uInt16 nModifier )
     if (StartDrag())
     {
         // if the handler allows dragging, initialize dragging
-        Invalidate();
         mbDrag = true;
         mnStartDragPos = mnDragPos;
         StartTracking();
+        Invalidate(InvalidateFlags::NoErase);
         return true;
     }
     else
@@ -1946,7 +1946,7 @@ void Ruler::ImplDrag( const Point& rPos )
             Drag();
 
             // and redraw
-            Invalidate();
+            Invalidate(InvalidateFlags::NoErase);
 
             // reset the data as before cancel
             *mpDragData = aTempData;
@@ -1966,8 +1966,8 @@ void Ruler::ImplDrag( const Point& rPos )
         Drag();
 
         // redraw
-        if ( mbFormat )
-            Invalidate();
+        if (mbFormat)
+            Invalidate(InvalidateFlags::NoErase);
     }
 }
 
@@ -1996,26 +1996,7 @@ void Ruler::ImplEndDrag()
     mnStartDragPos  = 0;
 
     // redraw
-    Invalidate();
-}
-
-IMPL_LINK_NOARG(Ruler, ImplUpdateHdl)
-{
-    mnUpdateEvtId = 0;
-
-    // what should be updated
-    if (mnUpdateFlags & RULER_UPDATE_DRAW)
-    {
-        mnUpdateFlags = 0;
-        Invalidate();
-    }
-    else if (mnUpdateFlags & RULER_UPDATE_LINES)
-    {
-        mnUpdateFlags = 0;
-        Invalidate();
-    }
-
-    return 0;
+    Invalidate(InvalidateFlags::NoErase);
 }
 
 void Ruler::MouseButtonDown( const MouseEvent& rMEvt )
@@ -2029,8 +2010,7 @@ void Ruler::MouseButtonDown( const MouseEvent& rMEvt )
         // update ruler
         if ( mbFormat )
         {
-            Invalidate();
-            mnUpdateFlags &= ~RULER_UPDATE_DRAW;
+            Invalidate(InvalidateFlags::NoErase);
         }
 
         if ( maExtraRect.IsInside( aMousePos ) )
@@ -2090,6 +2070,8 @@ void Ruler::MouseMove( const MouseEvent& rMEvt )
 {
     PointerStyle ePtrStyle = PointerStyle::Arrow;
 
+    mxPreviousHitTest.swap(mxCurrentHitTest);
+
     mxCurrentHitTest.reset(new RulerSelection);
 
     maHoverSelection.eType = RULER_TYPE_DONTKNOW;
@@ -2128,19 +2110,17 @@ void Ruler::MouseMove( const MouseEvent& rMEvt )
         }
     }
 
-    if(mxPreviousHitTest.get() != NULL && mxPreviousHitTest->eType != mxCurrentHitTest->eType)
+    if (mxPreviousHitTest.get() != NULL && mxPreviousHitTest->eType != mxCurrentHitTest->eType)
     {
         mbFormat = true;
     }
 
     SetPointer( Pointer(ePtrStyle) );
 
-    if ( mbFormat )
+    if (mbFormat)
     {
-        Invalidate();
-        mnUpdateFlags &= ~RULER_UPDATE_DRAW;
+        Invalidate(InvalidateFlags::NoErase);
     }
-    mxPreviousHitTest.swap(mxCurrentHitTest);
 }
 
 void Ruler::Tracking( const TrackingEvent& rTEvt )
@@ -2189,16 +2169,15 @@ void Ruler::Resize()
             nNewHeight = 0;
     }
 
+    mbFormat = true;
+
     // clear lines
     bool bVisible = IsReallyVisible();
     if ( bVisible && !mpData->pLines.empty() )
     {
-        Invalidate();
         mnUpdateFlags |= RULER_UPDATE_LINES;
-        if ( !mnUpdateEvtId )
-            mnUpdateEvtId = Application::PostUserEvent( LINK( this, Ruler, ImplUpdateHdl ), NULL, true );
+        Invalidate(InvalidateFlags::NoErase);
     }
-    mbFormat = true;
 
     // recalculate some values if the height/width changes
     // extra field should always be updated
@@ -2220,7 +2199,7 @@ void Ruler::Resize()
     if ( bVisible )
     {
         if ( nNewHeight )
-            Invalidate();
+            Invalidate(InvalidateFlags::NoErase);
         else if ( mpData->bAutoPageWidth )
         {
             // only at AutoPageWidth muss we redraw
@@ -2247,7 +2226,7 @@ void Ruler::Resize()
                 aRect.Right()   = RULER_OFF + mnVirHeight;
             }
 
-            Invalidate( aRect );
+            Invalidate(aRect, InvalidateFlags::NoErase);
         }
     }
 
@@ -2339,14 +2318,13 @@ void Ruler::Activate()
 
     // update positionlies - draw is delayed
     mnUpdateFlags |= RULER_UPDATE_LINES;
-    if ( !mnUpdateEvtId )
-        mnUpdateEvtId = Application::PostUserEvent( LINK( this, Ruler, ImplUpdateHdl ), NULL, true );
+    Invalidate(InvalidateFlags::NoErase);
 }
 
 void Ruler::Deactivate()
 {
     // clear positionlines
-    Invalidate();
+    Invalidate(InvalidateFlags::NoErase);
 
     mbActive = false;
 }
@@ -2366,8 +2344,7 @@ bool Ruler::StartDocDrag( const MouseEvent& rMEvt, RulerType eDragType )
         // update ruler
         if ( mbFormat )
         {
-            Invalidate();
-            mnUpdateFlags &= ~RULER_UPDATE_DRAW;
+            Invalidate(InvalidateFlags::NoErase);
         }
 
         if ( nMouseClicks == 1 )
@@ -2432,8 +2409,7 @@ RulerType Ruler::GetType( const Point& rPos, sal_uInt16* pAryPos )
     // update ruler
     if ( IsReallyVisible() && mbFormat )
     {
-        Invalidate();
-        mnUpdateFlags &= ~RULER_UPDATE_DRAW;
+        Invalidate(InvalidateFlags::NoErase);
     }
 
     (void)ImplHitTest(rPos, &aHitTest);
@@ -2483,7 +2459,7 @@ void Ruler::SetBorderPos( long nOff )
             mnBorderOff = nOff;
 
             if ( IsReallyVisible() && IsUpdateMode() )
-                Invalidate();
+                Invalidate(InvalidateFlags::NoErase);
         }
     }
 }
@@ -2558,7 +2534,7 @@ void Ruler::SetExtraType( RulerExtra eNewExtraType, sal_uInt16 nStyle )
         meExtraType  = eNewExtraType;
         mnExtraStyle = nStyle;
         if (IsReallyVisible() && IsUpdateMode())
-            Invalidate();
+            Invalidate(InvalidateFlags::NoErase);
     }
 }
 
@@ -2644,7 +2620,7 @@ void Ruler::SetLines( sal_uInt32 aLineArraySize, const RulerLine* pLineArray )
 
     // Delete old lines
     if ( bMustUpdate )
-        Invalidate();
+        Invalidate(InvalidateFlags::NoErase);
 
     // New data set
     if ( !aLineArraySize || !pLineArray )
@@ -2665,7 +2641,7 @@ void Ruler::SetLines( sal_uInt32 aLineArraySize, const RulerLine* pLineArray )
                    mpData->pLines.begin() );
 
         if ( bMustUpdate )
-            Invalidate();
+            Invalidate(InvalidateFlags::NoErase);
     }
 }
 
@@ -2857,7 +2833,7 @@ RulerUnitData Ruler::GetCurrentRulerUnit() const
 void Ruler::DrawTicks()
 {
     mbFormat = true;
-    Invalidate();
+    Invalidate(InvalidateFlags::NoErase);
 }
 
 uno::Reference< XAccessible > Ruler::CreateAccessible()


More information about the Libreoffice-commits mailing list