[Libreoffice-commits] core.git: 2 commits - cui/source include/svtools sc/source svtools/source svx/source sw/source

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Mon May 11 01:58:09 PDT 2015


 cui/source/tabpages/numpages.cxx                        |    3 
 include/svtools/tabbar.hxx                              |    7 
 include/svtools/valueset.hxx                            |  162 ++--
 sc/source/ui/sidebar/CellLineStyleControl.cxx           |    7 
 svtools/source/control/tabbar.cxx                       |  511 ++++++--------
 svtools/source/control/valueset.cxx                     |  568 ++++++++--------
 svx/source/dialog/svxbmpnumvalueset.cxx                 |    6 
 svx/source/sidebar/line/LineWidthControl.cxx            |    9 
 svx/source/sidebar/text/TextCharacterSpacingControl.cxx |   12 
 sw/source/ui/frmdlg/column.cxx                          |    7 
 sw/source/uibase/sidebar/PageColumnControl.cxx          |    3 
 sw/source/uibase/sidebar/PageMarginControl.cxx          |   10 
 sw/source/uibase/sidebar/PageOrientationControl.cxx     |    3 
 sw/source/uibase/sidebar/PageSizeControl.cxx            |    3 
 14 files changed, 681 insertions(+), 630 deletions(-)

New commits:
commit 2fa44119c802c39c4871e77726c01e6ba62a6262
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Mon May 11 17:55:36 2015 +0900

    refactor ValueSet to use RenderContext
    
    Change-Id: I3985804f8cfd1b6807bc02bef5af3e24e5cb3cbf

diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx
index f0a3089..c6e0f22 100644
--- a/cui/source/tabpages/numpages.cxx
+++ b/cui/source/tabpages/numpages.cxx
@@ -840,7 +840,8 @@ SvxBitmapPickTabPage::SvxBitmapPickTabPage(vcl::Window* pParent,
     else
     {
         m_pExamplesVS->Show();
-        m_pExamplesVS->Format();
+        m_pExamplesVS->SetFormat();
+        m_pExamplesVS->Invalidate();
     }
 }
 
diff --git a/include/svtools/valueset.hxx b/include/svtools/valueset.hxx
index b89bc18..7bb41f7 100644
--- a/include/svtools/valueset.hxx
+++ b/include/svtools/valueset.hxx
@@ -197,7 +197,7 @@ class SVT_DLLPUBLIC ValueSet : public Control
 {
 private:
 
-    ScopedVclPtr<VirtualDevice>   maVirDev;
+    ScopedVclPtr<VirtualDevice> maVirDev;
     Timer           maTimer;
     ValueItemList   mItemList;
     ValueSetItemPtr mpNoneItem;
@@ -248,13 +248,13 @@ private:
     SVT_DLLPRIVATE void         ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
     SVT_DLLPRIVATE void         ImplInitScrollBar();
     SVT_DLLPRIVATE void         ImplDeleteItems();
-    SVT_DLLPRIVATE void         ImplFormatItem( ValueSetItem* pItem, Rectangle aRect );
-    SVT_DLLPRIVATE void         ImplDrawItemText(const OUString& rStr);
-    SVT_DLLPRIVATE void         ImplDrawSelect( sal_uInt16 nItemId, const bool bFocus, const bool bDrawSel );
-    SVT_DLLPRIVATE void         ImplDrawSelect();
-    SVT_DLLPRIVATE void         ImplHideSelect( sal_uInt16 nItemId );
-    SVT_DLLPRIVATE void         ImplHighlightItem( sal_uInt16 nItemId, bool bIsSelection = true );
-    SVT_DLLPRIVATE void         ImplDraw();
+    SVT_DLLPRIVATE void         ImplFormatItem(vcl::RenderContext& rRenderContext, ValueSetItem* pItem, Rectangle aRect);
+    SVT_DLLPRIVATE void         ImplDrawItemText(vcl::RenderContext& rRenderContext, const OUString& rStr);
+    SVT_DLLPRIVATE void         ImplDrawSelect(vcl::RenderContext& rRenderContext, sal_uInt16 nItemId, const bool bFocus, const bool bDrawSel);
+    SVT_DLLPRIVATE void         ImplDrawSelect(vcl::RenderContext& rRenderContext);
+    SVT_DLLPRIVATE void         ImplHideSelect(sal_uInt16 nItemId);
+    SVT_DLLPRIVATE void         ImplHighlightItem(sal_uInt16 nItemId, bool bIsSelection = true);
+    SVT_DLLPRIVATE void         ImplDraw(vcl::RenderContext& rRenderContext);
     using Window::ImplScroll;
     SVT_DLLPRIVATE bool         ImplScroll( const Point& rPos );
     SVT_DLLPRIVATE size_t       ImplGetItem( const Point& rPoint, bool bMove = false ) const;
@@ -274,10 +274,7 @@ private:
     ValueSet & operator= (const ValueSet &) SAL_DELETED_FUNCTION;
 
 protected:
-
-    bool            StartDrag( const CommandEvent& rCEvt, vcl::Region& rRegion );
-
-protected:
+    bool StartDrag( const CommandEvent& rCEvt, vcl::Region& rRegion );
 
     virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() SAL_OVERRIDE;
 
@@ -293,7 +290,7 @@ public:
     virtual void    Tracking( const TrackingEvent& rMEvt ) SAL_OVERRIDE;
     virtual void    KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
     virtual void    Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
-    virtual void    Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
+    virtual void    Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
     virtual void    GetFocus() SAL_OVERRIDE;
     virtual void    LoseFocus() SAL_OVERRIDE;
     virtual void    Resize() SAL_OVERRIDE;
@@ -306,19 +303,14 @@ public:
     void            DoubleClick();
     virtual void    UserDraw( const UserDrawEvent& rUDEvt );
 
-    void            InsertItem( sal_uInt16 nItemId, const Image& rImage,
-                                size_t nPos = VALUESET_APPEND );
-    void            InsertItem( sal_uInt16 nItemId,
-                                const Image& rImage, const OUString& rStr,
-                                size_t nPos = VALUESET_APPEND );
-    void            InsertItem( sal_uInt16 nItemId,
-                                const Color& rColor, const OUString& rStr,
-                                size_t nPos = VALUESET_APPEND );
-    void            InsertItem( sal_uInt16 nItemId,
-                                size_t nPos = VALUESET_APPEND );
-    void            InsertItem( sal_uInt16 nItemId, const OUString& rStr,
-                                size_t nPos = VALUESET_APPEND );
-    void            RemoveItem( sal_uInt16 nItemId );
+    void            InsertItem(sal_uInt16 nItemId, const Image& rImage, size_t nPos = VALUESET_APPEND);
+    void            InsertItem(sal_uInt16 nItemId, const Image& rImage,
+                               const OUString& rStr, size_t nPos = VALUESET_APPEND);
+    void            InsertItem(sal_uInt16 nItemId, const Color& rColor,
+                               const OUString& rStr, size_t nPos = VALUESET_APPEND);
+    void            InsertItem(sal_uInt16 nItemId, size_t nPos = VALUESET_APPEND);
+    void            InsertItem(sal_uInt16 nItemId, const OUString& rStr, size_t nPos = VALUESET_APPEND);
+    void            RemoveItem(sal_uInt16 nItemId);
 
     void            Clear();
 
@@ -329,23 +321,49 @@ public:
     Rectangle       GetItemRect( sal_uInt16 nItemId ) const;
 
     void            EnableFullItemMode( bool bFullMode = true );
-    bool            IsFullItemModeEnabled() const { return mbFullMode; }
+    bool IsFullItemModeEnabled() const
+    {
+        return mbFullMode;
+    }
     void            SetColCount( sal_uInt16 nNewCols = 1 );
-    sal_uInt16          GetColCount() const { return mnUserCols; }
+    sal_uInt16 GetColCount() const
+    {
+        return mnUserCols;
+    }
     void            SetLineCount( sal_uInt16 nNewLines = 0 );
-    sal_uInt16          GetLineCount() const { return mnUserVisLines; }
-    void            SetItemWidth( long nItemWidth = 0 );
-    long            GetItemWidth() const { return mnUserItemWidth; }
-    void            SetItemHeight( long nLineHeight = 0 );
-    long            GetItemHeight() const { return mnUserItemHeight; }
-    sal_uInt16          GetFirstLine() const { return mnFirstLine; }
-
-    void            SelectItem( sal_uInt16 nItemId );
-    sal_uInt16          GetSelectItemId() const { return mnSelItemId; }
-    bool            IsItemSelected( sal_uInt16 nItemId ) const
-                        { return !mbNoSelection && (nItemId == mnSelItemId); }
-    void            SetNoSelection();
-    bool            IsNoSelection() const { return mbNoSelection; }
+    sal_uInt16 GetLineCount() const
+    {
+        return mnUserVisLines;
+    }
+    void SetItemWidth( long nItemWidth = 0 );
+    long GetItemWidth() const
+    {
+        return mnUserItemWidth;
+    }
+    void SetItemHeight( long nLineHeight = 0 );
+    long GetItemHeight() const
+    {
+        return mnUserItemHeight;
+    }
+    sal_uInt16          GetFirstLine() const
+    {
+        return mnFirstLine;
+    }
+
+    void SelectItem( sal_uInt16 nItemId );
+    sal_uInt16 GetSelectItemId() const
+    {
+        return mnSelItemId;
+    }
+    bool IsItemSelected( sal_uInt16 nItemId ) const
+    {
+        return !mbNoSelection && (nItemId == mnSelItemId);
+    }
+    void SetNoSelection();
+    bool IsNoSelection() const
+    {
+        return mbNoSelection;
+    }
 
     void            SetItemImage( sal_uInt16 nItemId, const Image& rImage );
     Image           GetItemImage( sal_uInt16 nItemId ) const;
@@ -356,32 +374,60 @@ public:
     void            SetItemText( sal_uInt16 nItemId, const OUString& rStr );
     OUString        GetItemText( sal_uInt16 nItemId ) const;
     void            SetColor( const Color& rColor );
-    void            SetColor() { SetColor( Color( COL_TRANSPARENT ) ); }
-    Color           GetColor() const { return maColor; }
-    bool            IsColor() const { return maColor.GetTransparency() == 0; }
+    void            SetColor()
+    {
+        SetColor(Color(COL_TRANSPARENT));
+    }
+    Color           GetColor() const
+    {
+        return maColor;
+    }
+    bool            IsColor() const
+    {
+        return maColor.GetTransparency() == 0;
+    }
 
     void            SetExtraSpacing( sal_uInt16 nNewSpacing );
-    sal_uInt16      GetExtraSpacing() { return mnSpacing; }
+    sal_uInt16      GetExtraSpacing()
+    {
+        return mnSpacing;
+    }
 
-    void            Format();
+    void            Format(vcl::RenderContext& rRenderContext);
+    void            SetFormat(bool bFormat = true);
 
     void            StartSelection();
     void            EndSelection();
 
-    Size            CalcWindowSizePixel( const Size& rItemSize,
-                                         sal_uInt16 nCalcCols = 0,
-                                         sal_uInt16 nCalcLines = 0 ) const;
-    Size            CalcItemSizePixel( const Size& rSize, bool bOut = true ) const;
+    Size            CalcWindowSizePixel(const Size& rItemSize,
+                                        sal_uInt16 nCalcCols = 0,
+                                        sal_uInt16 nCalcLines = 0) const;
+    Size            CalcItemSizePixel(const Size& rSize, bool bOut = true) const;
     long            GetScrollWidth() const;
 
-    void            SetSelectHdl( const Link<>& rLink ) { maSelectHdl = rLink; }
-    const Link<>&   GetSelectHdl() const { return maSelectHdl; }
-    void            SetDoubleClickHdl( const Link<>& rLink ) { maDoubleClickHdl = rLink; }
-    const Link<>&   GetDoubleClickHdl() const { return maDoubleClickHdl; }
-
-    void            SetHighlightHdl( const Link<>& rLink );
-
-    bool GetEdgeBlending() const { return mbEdgeBlending; }
+    void            SetSelectHdl(const Link<>& rLink)
+    {
+        maSelectHdl = rLink;
+    }
+    const Link<>&   GetSelectHdl() const
+    {
+        return maSelectHdl;
+    }
+    void            SetDoubleClickHdl(const Link<>& rLink)
+    {
+        maDoubleClickHdl = rLink;
+    }
+    const Link<>&   GetDoubleClickHdl() const
+    {
+        return maDoubleClickHdl;
+    }
+
+    void            SetHighlightHdl(const Link<>& rLink);
+
+    bool GetEdgeBlending() const
+    {
+        return mbEdgeBlending;
+    }
     void SetEdgeBlending(bool bNew);
 };
 
diff --git a/sc/source/ui/sidebar/CellLineStyleControl.cxx b/sc/source/ui/sidebar/CellLineStyleControl.cxx
index e23f4cd..9ef1f83 100644
--- a/sc/source/ui/sidebar/CellLineStyleControl.cxx
+++ b/sc/source/ui/sidebar/CellLineStyleControl.cxx
@@ -110,7 +110,8 @@ void CellLineStyleControl::SetAllNoSel()
 {
     maCellLineStyleValueSet->SelectItem(0);
     maCellLineStyleValueSet->SetNoSelection();
-    maCellLineStyleValueSet->Format();
+    maCellLineStyleValueSet->SetFormat();
+    maCellLineStyleValueSet->Invalidate();
     Invalidate();
     maCellLineStyleValueSet->StartSelection();
 }
@@ -251,8 +252,8 @@ void CellLineStyleControl::SetLineStyleSelect(sal_uInt16 out, sal_uInt16 in, sal
         maCellLineStyleValueSet->SetSelItem(0);
         mbVSfocus = false;
     }
-
-    maCellLineStyleValueSet->Format();
+    maCellLineStyleValueSet->SetFormat();
+    maCellLineStyleValueSet->Invalidate();
     maCellLineStyleValueSet->StartSelection();
 }
 
diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx
index 6b97b9c..617fde9 100644
--- a/svtools/source/control/valueset.cxx
+++ b/svtools/source/control/valueset.cxx
@@ -202,33 +202,33 @@ void ValueSet::ImplInitSettings( bool bFont, bool bForeground, bool bBackground
 
 void ValueSet::ImplInitScrollBar()
 {
-    if ( GetStyle() & WB_VSCROLL )
+    if (GetStyle() & WB_VSCROLL)
     {
-        if ( !mxScrollBar.get() )
+        if (!mxScrollBar.get())
         {
-            mxScrollBar.reset(VclPtr<ScrollBar>::Create( this, WB_VSCROLL | WB_DRAG ));
-            mxScrollBar->SetScrollHdl( LINK( this, ValueSet, ImplScrollHdl ) );
+            mxScrollBar.reset(VclPtr<ScrollBar>::Create(this, WB_VSCROLL | WB_DRAG));
+            mxScrollBar->SetScrollHdl(LINK(this, ValueSet, ImplScrollHdl));
         }
         else
         {
             // adapt the width because of the changed settings
-            long nScrBarWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
-            mxScrollBar->setPosSizePixel( 0, 0, nScrBarWidth, 0, WINDOW_POSSIZE_WIDTH );
+            long nScrBarWidth = Application::GetSettings().GetStyleSettings().GetScrollBarSize();
+            mxScrollBar->setPosSizePixel(0, 0, nScrBarWidth, 0, WINDOW_POSSIZE_WIDTH);
         }
     }
 }
 
-void ValueSet::ImplFormatItem( ValueSetItem* pItem, Rectangle aRect )
+void ValueSet::ImplFormatItem(vcl::RenderContext& rRenderContext, ValueSetItem* pItem, Rectangle aRect)
 {
     WinBits nStyle = GetStyle();
-    if ( nStyle & WB_ITEMBORDER )
+    if (nStyle & WB_ITEMBORDER)
     {
         aRect.Left()   += 1;
         aRect.Top()    += 1;
         aRect.Right()  -= 1;
         aRect.Bottom() -= 1;
 
-        if ( nStyle & WB_FLATVALUESET )
+        if (nStyle & WB_FLATVALUESET)
         {
             sal_Int32 nBorder = (nStyle & WB_DOUBLEBORDER) ? 2 : 1;
 
@@ -239,97 +239,97 @@ void ValueSet::ImplFormatItem( ValueSetItem* pItem, Rectangle aRect )
         }
         else
         {
-            DecorationView aView( maVirDev.get() );
-            aRect = aView.DrawFrame( aRect, mnFrameStyle );
+            DecorationView aView(maVirDev.get());
+            aRect = aView.DrawFrame(aRect, mnFrameStyle);
         }
     }
 
-    if ( pItem == mpNoneItem.get() )
+    if (pItem == mpNoneItem.get())
         pItem->maText = GetText();
 
-    if ( (aRect.GetHeight() > 0) && (aRect.GetWidth() > 0) )
+    if ((aRect.GetHeight() > 0) && (aRect.GetWidth() > 0))
     {
-        const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+        const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
 
-        if ( pItem == mpNoneItem.get() )
+        if (pItem == mpNoneItem.get())
         {
-            maVirDev->SetFont( GetFont() );
-            maVirDev->SetTextColor( ( nStyle & WB_MENUSTYLEVALUESET ) ? rStyleSettings.GetMenuTextColor() : rStyleSettings.GetWindowTextColor() );
+            maVirDev->SetFont(rRenderContext.GetFont());
+            maVirDev->SetTextColor((nStyle & WB_MENUSTYLEVALUESET) ? rStyleSettings.GetMenuTextColor() : rStyleSettings.GetWindowTextColor());
             maVirDev->SetTextFillColor();
-            maVirDev->SetFillColor( ( nStyle & WB_MENUSTYLEVALUESET ) ? rStyleSettings.GetMenuColor() : rStyleSettings.GetWindowColor() );
-            maVirDev->DrawRect( aRect );
-            Point   aTxtPos( aRect.Left() + 2, aRect.Top() );
-            long    nTxtWidth = GetTextWidth( pItem->maText );
-            if ( nStyle & WB_RADIOSEL )
+            maVirDev->SetFillColor((nStyle & WB_MENUSTYLEVALUESET) ? rStyleSettings.GetMenuColor() : rStyleSettings.GetWindowColor());
+            maVirDev->DrawRect(aRect);
+            Point aTxtPos(aRect.Left() + 2, aRect.Top());
+            long nTxtWidth = rRenderContext.GetTextWidth(pItem->maText);
+            if (nStyle & WB_RADIOSEL)
             {
                 aTxtPos.X() += 4;
                 aTxtPos.Y() += 4;
             }
-            if ( (aTxtPos.X()+nTxtWidth) > aRect.Right() )
+            if ((aTxtPos.X() + nTxtWidth) > aRect.Right())
             {
-                maVirDev->SetClipRegion( vcl::Region( aRect ) );
-                maVirDev->DrawText( aTxtPos, pItem->maText );
+                maVirDev->SetClipRegion(vcl::Region(aRect));
+                maVirDev->DrawText(aTxtPos, pItem->maText);
                 maVirDev->SetClipRegion();
             }
             else
-                maVirDev->DrawText( aTxtPos, pItem->maText );
+                maVirDev->DrawText(aTxtPos, pItem->maText);
         }
-        else if ( pItem->meType == VALUESETITEM_COLOR )
+        else if (pItem->meType == VALUESETITEM_COLOR)
         {
-            maVirDev->SetFillColor( pItem->maColor );
-            maVirDev->DrawRect( aRect );
+            maVirDev->SetFillColor(pItem->maColor);
+            maVirDev->DrawRect(aRect);
         }
         else
         {
-            if ( IsColor() )
-                maVirDev->SetFillColor( maColor );
-            else if ( nStyle & WB_MENUSTYLEVALUESET )
-                maVirDev->SetFillColor( rStyleSettings.GetMenuColor() );
-            else if ( IsEnabled() )
-                maVirDev->SetFillColor( rStyleSettings.GetWindowColor() );
+            if (IsColor())
+                maVirDev->SetFillColor(maColor);
+            else if (nStyle & WB_MENUSTYLEVALUESET)
+                maVirDev->SetFillColor(rStyleSettings.GetMenuColor());
+            else if (IsEnabled())
+                maVirDev->SetFillColor(rStyleSettings.GetWindowColor());
             else
-                maVirDev->SetFillColor( rStyleSettings.GetFaceColor() );
-            maVirDev->DrawRect( aRect );
+                maVirDev->SetFillColor(rStyleSettings.GetFaceColor());
+            maVirDev->DrawRect(aRect);
 
-            if ( pItem->meType == VALUESETITEM_USERDRAW )
+            if (pItem->meType == VALUESETITEM_USERDRAW)
             {
-                UserDrawEvent aUDEvt( maVirDev.get(), aRect, pItem->mnId );
-                UserDraw( aUDEvt );
+                UserDrawEvent aUDEvt(maVirDev.get(), aRect, pItem->mnId);
+                UserDraw(aUDEvt);
             }
             else
             {
-                Size    aImageSize = pItem->maImage.GetSizePixel();
-                Size    aRectSize = aRect.GetSize();
-                Point   aPos( aRect.Left(), aRect.Top() );
+                Size aImageSize = pItem->maImage.GetSizePixel();
+                Size  aRectSize = aRect.GetSize();
+                Point aPos(aRect.Left(), aRect.Top());
                 aPos.X() += (aRectSize.Width() - aImageSize.Width()) / 2;
                 aPos.Y() += (aRectSize.Height() - aImageSize.Height()) / 2;
 
                 sal_uInt16  nImageStyle  = 0;
-                if( !IsEnabled() )
+                if (!IsEnabled())
                     nImageStyle  |= IMAGE_DRAW_DISABLE;
 
-                if ( aImageSize.Width()  > aRectSize.Width() ||
-                     aImageSize.Height() > aRectSize.Height() )
+                if (aImageSize.Width()  > aRectSize.Width() ||
+                    aImageSize.Height() > aRectSize.Height())
                 {
-                    maVirDev->SetClipRegion( vcl::Region( aRect ) );
-                    maVirDev->DrawImage( aPos, pItem->maImage, nImageStyle);
+                    maVirDev->SetClipRegion(vcl::Region(aRect));
+                    maVirDev->DrawImage(aPos, pItem->maImage, nImageStyle);
                     maVirDev->SetClipRegion();
                 }
                 else
-                    maVirDev->DrawImage( aPos, pItem->maImage, nImageStyle );
+                    maVirDev->DrawImage(aPos, pItem->maImage, nImageStyle);
             }
         }
 
         const sal_uInt16 nEdgeBlendingPercent(GetEdgeBlending() ? rStyleSettings.GetEdgeBlending() : 0);
 
-        if(nEdgeBlendingPercent)
+        if (nEdgeBlendingPercent)
         {
             const Color& rTopLeft(rStyleSettings.GetEdgeBlendingTopLeftColor());
             const Color& rBottomRight(rStyleSettings.GetEdgeBlendingBottomRightColor());
             const sal_uInt8 nAlpha((nEdgeBlendingPercent * 255) / 100);
             const BitmapEx aBlendFrame(createBlendFrame(aRect.GetSize(), nAlpha, rTopLeft, rBottomRight));
 
-            if(!aBlendFrame.IsEmpty())
+            if (!aBlendFrame.IsEmpty())
             {
                 maVirDev->DrawBitmapEx(aRect.TopLeft(), aBlendFrame);
             }
@@ -342,19 +342,19 @@ Reference<XAccessible> ValueSet::CreateAccessible()
     return new ValueSetAcc( this, mbIsTransientChildrenDisabled );
 }
 
-void ValueSet::Format()
+void ValueSet::Format(vcl::RenderContext& rRenderContext)
 {
-    Size        aWinSize = GetOutputSizePixel();
-    size_t      nItemCount = mItemList.size();
-    WinBits     nStyle = GetStyle();
-    long        nTxtHeight = GetTextHeight();
-    long        nOff;
-    long        nNoneHeight;
-    long        nNoneSpace;
+    Size aWinSize = rRenderContext.GetOutputSizePixel();
+    size_t nItemCount = mItemList.size();
+    WinBits nStyle = GetStyle();
+    long nTxtHeight = rRenderContext.GetTextHeight();
+    long nOff;
+    long nNoneHeight;
+    long nNoneSpace;
     VclPtr<ScrollBar> xDeletedScrollBar;
 
     // consider the scrolling
-    if ( nStyle & WB_VSCROLL )
+    if (nStyle & WB_VSCROLL)
         ImplInitScrollBar();
     else
     {
@@ -363,9 +363,9 @@ void ValueSet::Format()
     }
 
     // calculate item offset
-    if ( nStyle & WB_ITEMBORDER )
+    if (nStyle & WB_ITEMBORDER)
     {
-        if ( nStyle & WB_DOUBLEBORDER )
+        if (nStyle & WB_DOUBLEBORDER)
             nOff = ITEM_OFFSET_DOUBLE;
         else
             nOff = ITEM_OFFSET;
@@ -389,11 +389,11 @@ void ValueSet::Format()
         mnTextOffset = 0;
 
     // consider offset and size, if NoneField does exist
-    if ( nStyle & WB_NONEFIELD )
+    if (nStyle & WB_NONEFIELD)
     {
         nNoneHeight = nTxtHeight + nOff;
         nNoneSpace = mnSpacing;
-        if ( nStyle & WB_RADIOSEL )
+        if (nStyle & WB_RADIOSEL)
             nNoneHeight += 8;
     }
     else
@@ -408,14 +408,14 @@ void ValueSet::Format()
     // calculate ScrollBar width
     long nScrBarWidth = 0;
     if (mxScrollBar.get())
-        nScrBarWidth = mxScrollBar->GetSizePixel().Width()+SCRBAR_OFFSET;
+        nScrBarWidth = mxScrollBar->GetSizePixel().Width() + SCRBAR_OFFSET;
 
     // calculate number of columns
     if (!mnUserCols)
     {
         if (mnUserItemWidth)
         {
-            mnCols = (sal_uInt16) ((aWinSize.Width() - nScrBarWidth + mnSpacing) / (mnUserItemWidth + mnSpacing));
+            mnCols = static_cast<sal_uInt16>((aWinSize.Width() - nScrBarWidth + mnSpacing) / (mnUserItemWidth + mnSpacing));
             if (mnCols <= 0)
                 mnCols = 1;
         }
@@ -445,7 +445,7 @@ void ValueSet::Format()
     else if (mnUserItemHeight)
     {
         mnVisLines = (nCalcHeight - nNoneSpace + mnSpacing) / (mnUserItemHeight + mnSpacing);
-        if ( !mnVisLines )
+        if (!mnVisLines)
             mnVisLines = 1;
     }
     else
@@ -453,34 +453,34 @@ void ValueSet::Format()
         mnVisLines = mnLines;
     }
 
-    if ( mnLines > mnVisLines )
+    if (mnLines > mnVisLines)
         mbScroll = true;
 
-    if ( mnLines <= mnVisLines )
+    if (mnLines <= mnVisLines)
     {
         mnFirstLine = 0;
     }
     else
     {
-        if ( mnFirstLine > (sal_uInt16)(mnLines - mnVisLines) )
-            mnFirstLine = (sal_uInt16)(mnLines - mnVisLines);
+        if (mnFirstLine > static_cast<sal_uInt16>(mnLines - mnVisLines))
+            mnFirstLine = static_cast<sal_uInt16>(mnLines - mnVisLines);
     }
 
     // calculate item size
     const long nColSpace  = (mnCols - 1) * static_cast<long>(mnSpacing);
     const long nLineSpace = ((mnVisLines - 1) * mnSpacing) + nNoneSpace;
-    if ( mnUserItemWidth && !mnUserCols )
+    if (mnUserItemWidth && !mnUserCols)
     {
         mnItemWidth = mnUserItemWidth;
-        if ( mnItemWidth > aWinSize.Width() - nScrBarWidth-nColSpace )
-            mnItemWidth = aWinSize.Width() - nScrBarWidth-nColSpace;
+        if (mnItemWidth > aWinSize.Width() - nScrBarWidth - nColSpace)
+            mnItemWidth = aWinSize.Width() - nScrBarWidth - nColSpace;
     }
     else
         mnItemWidth = (aWinSize.Width() - nScrBarWidth-nColSpace) / mnCols;
-    if ( mnUserItemHeight && !mnUserVisLines )
+    if (mnUserItemHeight && !mnUserVisLines)
     {
         mnItemHeight = mnUserItemHeight;
-        if ( mnItemHeight > nCalcHeight - nNoneSpace )
+        if (mnItemHeight > nCalcHeight - nNoneSpace)
             mnItemHeight = nCalcHeight - nNoneSpace;
     }
     else
@@ -490,18 +490,18 @@ void ValueSet::Format()
     }
 
     // Init VirDev
-    maVirDev->SetSettings( GetSettings() );
-    maVirDev->SetBackground( GetBackground() );
-    maVirDev->SetOutputSizePixel( aWinSize, true );
+    maVirDev->SetSettings(rRenderContext.GetSettings());
+    maVirDev->SetBackground(rRenderContext.GetBackground());
+    maVirDev->SetOutputSizePixel(aWinSize, true);
 
     // nothing is changed in case of too small items
-    if ( (mnItemWidth <= 0) ||
-         (mnItemHeight <= (( nStyle & WB_ITEMBORDER ) ? 4 : 2)) ||
-         !nItemCount )
+    if ((mnItemWidth <= 0) ||
+        (mnItemHeight <= ((nStyle & WB_ITEMBORDER) ? 4 : 2)) ||
+        !nItemCount)
     {
         mbHasVisibleItems = false;
 
-        if ( nStyle & WB_NONEFIELD )
+        if (nStyle & WB_NONEFIELD)
         {
             if (mpNoneItem.get())
             {
@@ -510,12 +510,12 @@ void ValueSet::Format()
             }
         }
 
-        for ( size_t i = 0; i < nItemCount; i++ )
+        for (size_t i = 0; i < nItemCount; i++)
         {
             mItemList[i]->mbVisible = false;
         }
 
-        if ( mxScrollBar.get() )
+        if (mxScrollBar.get())
             mxScrollBar->Hide();
     }
     else
@@ -523,7 +523,7 @@ void ValueSet::Format()
         mbHasVisibleItems = true;
 
         // determine Frame-Style
-        if ( nStyle & WB_DOUBLEBORDER )
+        if (nStyle & WB_DOUBLEBORDER)
             mnFrameStyle = FRAME_DRAW_DOUBLEIN;
         else
             mnFrameStyle = FRAME_DRAW_IN;
@@ -531,27 +531,34 @@ void ValueSet::Format()
         // determine selected color and width
         // if necessary change the colors, to make the selection
         // better detectable
-        const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
-        Color aHighColor( rStyleSettings.GetHighlightColor() );
-        if ( ((aHighColor.GetRed() > 0x80) || (aHighColor.GetGreen() > 0x80) ||
-              (aHighColor.GetBlue() > 0x80)) ||
-             ((aHighColor.GetRed() == 0x80) && (aHighColor.GetGreen() == 0x80) &&
-              (aHighColor.GetBlue() == 0x80)) )
+        const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+        Color aHighColor(rStyleSettings.GetHighlightColor());
+        if (((aHighColor.GetRed() > 0x80) || (aHighColor.GetGreen() > 0x80) ||
+             (aHighColor.GetBlue() > 0x80)) ||
+            ((aHighColor.GetRed() == 0x80) && (aHighColor.GetGreen() == 0x80) &&
+             (aHighColor.GetBlue() == 0x80)))
+        {
             mbBlackSel = true;
+        }
         else
+        {
             mbBlackSel = false;
-
+        }
         // draw the selection with double width if the items are bigger
-        if ( (nStyle & WB_DOUBLEBORDER) &&
-             ((mnItemWidth >= 25) && (mnItemHeight >= 20)) )
+        if ((nStyle & WB_DOUBLEBORDER) &&
+            ((mnItemWidth >= 25) && (mnItemHeight >= 20)))
+        {
             mbDoubleSel = true;
+        }
         else
+        {
             mbDoubleSel = false;
+        }
 
         // calculate offsets
         long nStartX;
         long nStartY;
-        if ( mbFullMode )
+        if (mbFullMode)
         {
             long nAllItemWidth = (mnItemWidth * mnCols) + nColSpace;
             long nAllItemHeight = (mnItemHeight * mnVisLines) + nNoneHeight + nLineSpace;
@@ -575,17 +582,17 @@ void ValueSet::Format()
             if (mpNoneItem.get() == NULL)
                 mpNoneItem.reset(new ValueSetItem(*this));
 
-            mpNoneItem->mnId            = 0;
-            mpNoneItem->meType          = VALUESETITEM_NONE;
-            mpNoneItem->mbVisible       = true;
-            maNoneItemRect.Left()       = x;
-            maNoneItemRect.Top()        = y;
-            maNoneItemRect.Right()      = maNoneItemRect.Left() + aWinSize.Width() - x - 1;
-            maNoneItemRect.Bottom()     = y+nNoneHeight - 1;
+            mpNoneItem->mnId = 0;
+            mpNoneItem->meType = VALUESETITEM_NONE;
+            mpNoneItem->mbVisible = true;
+            maNoneItemRect.Left() = x;
+            maNoneItemRect.Top()  = y;
+            maNoneItemRect.Right() = maNoneItemRect.Left() + aWinSize.Width() - x - 1;
+            maNoneItemRect.Bottom() = y + nNoneHeight - 1;
 
-            ImplFormatItem(mpNoneItem.get(), maNoneItemRect);
+            ImplFormatItem(rRenderContext, mpNoneItem.get(), maNoneItemRect);
 
-            y += nNoneHeight+nNoneSpace;
+            y += nNoneHeight + nNoneSpace;
         }
 
         // draw items
@@ -597,49 +604,49 @@ void ValueSet::Format()
         maItemListRect.Right() = x + mnCols * (mnItemWidth + mnSpacing) - mnSpacing - 1;
         maItemListRect.Bottom() = y + mnVisLines * (mnItemHeight + mnSpacing) - mnSpacing - 1;
 
-        if ( !mbFullMode )
+        if (!mbFullMode)
         {
             // If want also draw parts of items in the last line,
             // then we add one more line if parts of these line are
             // visible
-            if ( y + (mnVisLines * (mnItemHeight + mnSpacing)) < aWinSize.Height() )
+            if (y + (mnVisLines * (mnItemHeight + mnSpacing)) < aWinSize.Height())
                 nLastItem += mnCols;
             maItemListRect.Bottom() = aWinSize.Height() - y;
         }
-        for ( size_t i = 0; i < nItemCount; i++ )
+        for (size_t i = 0; i < nItemCount; i++)
         {
             ValueSetItem* pItem = mItemList[i];
 
-            if ( (i >= nFirstItem) && (i < nLastItem) )
+            if (i >= nFirstItem && i < nLastItem)
             {
-                if( !pItem->mbVisible && ImplHasAccessibleListeners() )
+                if (!pItem->mbVisible && ImplHasAccessibleListeners())
                 {
                     Any aOldAny;
                     Any aNewAny;
 
-                    aNewAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled );
+                    aNewAny <<= pItem->GetAccessible(mbIsTransientChildrenDisabled);
                     ImplFireAccessibleEvent(AccessibleEventId::CHILD, aOldAny, aNewAny);
                 }
 
                 pItem->mbVisible = true;
-                ImplFormatItem( pItem, Rectangle( Point(x, y), Size(mnItemWidth, mnItemHeight) ) );
+                ImplFormatItem(rRenderContext, pItem, Rectangle(Point(x, y), Size(mnItemWidth, mnItemHeight)));
 
-                if ( !((i + 1) % mnCols) )
+                if (!((i + 1) % mnCols))
                 {
                     x = nStartX;
-                    y += mnItemHeight+mnSpacing;
+                    y += mnItemHeight + mnSpacing;
                 }
                 else
-                    x += mnItemWidth+mnSpacing;
+                    x += mnItemWidth + mnSpacing;
             }
             else
             {
-                if( pItem->mbVisible && ImplHasAccessibleListeners() )
+                if (pItem->mbVisible && ImplHasAccessibleListeners())
                 {
                     Any aOldAny;
                     Any aNewAny;
 
-                    aOldAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled );
+                    aOldAny <<= pItem->GetAccessible(mbIsTransientChildrenDisabled);
                     ImplFireAccessibleEvent(AccessibleEventId::CHILD, aOldAny, aNewAny);
                 }
 
@@ -648,24 +655,24 @@ void ValueSet::Format()
         }
 
         // arrange ScrollBar, set values and show it
-        if ( mxScrollBar.get() )
+        if (mxScrollBar.get())
         {
-            Point   aPos( aWinSize.Width() - nScrBarWidth + SCRBAR_OFFSET, 0 );
-            Size    aSize( nScrBarWidth - SCRBAR_OFFSET, aWinSize.Height() );
+            Point   aPos(aWinSize.Width() - nScrBarWidth + SCRBAR_OFFSET, 0);
+            Size    aSize(nScrBarWidth - SCRBAR_OFFSET, aWinSize.Height());
             // If a none field is visible, then we center the scrollbar
-            if ( nStyle & WB_NONEFIELD )
+            if (nStyle & WB_NONEFIELD)
             {
                 aPos.Y() = nStartY + nNoneHeight + 1;
                 aSize.Height() = ((mnItemHeight + mnSpacing) * mnVisLines) - 2 - mnSpacing;
             }
-            mxScrollBar->SetPosSizePixel( aPos, aSize );
-            mxScrollBar->SetRangeMax( mnLines );
-            mxScrollBar->SetVisibleSize( mnVisLines );
-            mxScrollBar->SetThumbPos( (long)mnFirstLine );
+            mxScrollBar->SetPosSizePixel(aPos, aSize);
+            mxScrollBar->SetRangeMax(mnLines);
+            mxScrollBar->SetVisibleSize(mnVisLines);
+            mxScrollBar->SetThumbPos((long)mnFirstLine);
             long nPageSize = mnVisLines;
-            if ( nPageSize < 1 )
+            if (nPageSize < 1)
                 nPageSize = 1;
-            mxScrollBar->SetPageSize( nPageSize );
+            mxScrollBar->SetPageSize(nPageSize);
             mxScrollBar->Show();
         }
     }
@@ -676,54 +683,54 @@ void ValueSet::Format()
     xDeletedScrollBar.disposeAndClear();
 }
 
-void ValueSet::ImplDrawItemText(const OUString& rText)
+void ValueSet::ImplDrawItemText(vcl::RenderContext& rRenderContext, const OUString& rText)
 {
-    if ( !(GetStyle() & WB_NAMEFIELD) )
+    if (!(GetStyle() & WB_NAMEFIELD))
         return;
 
-    Size    aWinSize = GetOutputSizePixel();
-    long    nTxtWidth = GetTextWidth(rText);
-    long    nTxtOffset = mnTextOffset;
+    Size aWinSize = rRenderContext.GetOutputSizePixel();
+    long nTxtWidth = rRenderContext.GetTextWidth(rText);
+    long nTxtOffset = mnTextOffset;
 
     // delete rectangle and show text
-    if ( GetStyle() & WB_FLATVALUESET )
+    if (GetStyle() & WB_FLATVALUESET)
     {
-        const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
-        SetLineColor();
-        SetFillColor( rStyleSettings.GetFaceColor() );
-        DrawRect( Rectangle( Point( 0, nTxtOffset ), Point( aWinSize.Width(), aWinSize.Height() ) ) );
-        SetTextColor( rStyleSettings.GetButtonTextColor() );
+        const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+        rRenderContext.SetLineColor();
+        rRenderContext.SetFillColor(rStyleSettings.GetFaceColor());
+        rRenderContext.DrawRect(Rectangle(Point(0, nTxtOffset), Point(aWinSize.Width(), aWinSize.Height())));
+        rRenderContext.SetTextColor(rStyleSettings.GetButtonTextColor());
     }
     else
     {
         nTxtOffset += NAME_LINE_HEIGHT+NAME_LINE_OFF_Y;
-        Erase( Rectangle( Point( 0, nTxtOffset ), Point( aWinSize.Width(), aWinSize.Height() ) ) );
+        rRenderContext.Erase(Rectangle(Point(0, nTxtOffset), Point(aWinSize.Width(), aWinSize.Height())));
     }
-    DrawText( Point( (aWinSize.Width() - nTxtWidth) / 2, nTxtOffset + (NAME_OFFSET / 2) ), rText );
+    rRenderContext.DrawText(Point((aWinSize.Width() - nTxtWidth) / 2, nTxtOffset + (NAME_OFFSET / 2)), rText);
 }
 
-void ValueSet::ImplDrawSelect()
+void ValueSet::ImplDrawSelect(vcl::RenderContext& rRenderContext)
 {
-    if ( !IsReallyVisible() )
+    if (!IsReallyVisible())
         return;
 
     const bool bFocus = HasFocus();
-    const bool bDrawSel = !( (mbNoSelection && !mbHighlight) || (!mbDrawSelection && mbHighlight) );
+    const bool bDrawSel = !((mbNoSelection && !mbHighlight) || (!mbDrawSelection && mbHighlight));
 
-    if ( !bFocus && !bDrawSel )
+    if (!bFocus && !bDrawSel)
     {
-        ImplDrawItemText(OUString());
+        ImplDrawItemText(rRenderContext, OUString());
         return;
     }
 
-    ImplDrawSelect( mnSelItemId, bFocus, bDrawSel );
+    ImplDrawSelect(rRenderContext, mnSelItemId, bFocus, bDrawSel);
     if (mbHighlight)
     {
-        ImplDrawSelect( mnHighItemId, bFocus, bDrawSel );
+        ImplDrawSelect(rRenderContext, mnHighItemId, bFocus, bDrawSel);
     }
 }
 
-void ValueSet::ImplDrawSelect( sal_uInt16 nItemId, const bool bFocus, const bool bDrawSel )
+void ValueSet::ImplDrawSelect(vcl::RenderContext& rRenderContext, sal_uInt16 nItemId, const bool bFocus, const bool bDrawSel )
 {
     ValueSetItem* pItem;
     Rectangle aRect;
@@ -750,53 +757,53 @@ void ValueSet::ImplDrawSelect( sal_uInt16 nItemId, const bool bFocus, const bool
     if (pItem->mbVisible)
     {
         // draw selection
-        const StyleSettings&    rStyleSettings = GetSettings().GetStyleSettings();
-        Control::SetFillColor();
+        const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+        rRenderContext.SetFillColor();
 
-        Color aDoubleColor( rStyleSettings.GetHighlightColor() );
-        Color aSingleColor( rStyleSettings.GetHighlightTextColor() );
-        if( !mbDoubleSel )
+        Color aDoubleColor(rStyleSettings.GetHighlightColor());
+        Color aSingleColor(rStyleSettings.GetHighlightTextColor());
+        if (!mbDoubleSel)
         {
             /*
             *  #99777# contrast enhancement for thin mode
             */
             const Wallpaper& rWall = GetDisplayBackground();
-            if( ! rWall.IsBitmap() && ! rWall.IsGradient() )
+            if (!rWall.IsBitmap() && ! rWall.IsGradient())
             {
                 const Color& rBack = rWall.GetColor();
-                if( rBack.IsDark() && ! aDoubleColor.IsBright() )
+                if (rBack.IsDark() && ! aDoubleColor.IsBright())
                 {
-                    aDoubleColor = Color( COL_WHITE );
-                    aSingleColor = Color( COL_BLACK );
+                    aDoubleColor = Color(COL_WHITE);
+                    aSingleColor = Color(COL_BLACK);
                 }
-                else if( rBack.IsBright() && ! aDoubleColor.IsDark() )
+                else if (rBack.IsBright() && ! aDoubleColor.IsDark())
                 {
-                    aDoubleColor = Color( COL_BLACK );
-                    aSingleColor = Color( COL_WHITE );
+                    aDoubleColor = Color(COL_BLACK);
+                    aSingleColor = Color(COL_WHITE);
                 }
             }
         }
 
         // specify selection output
         WinBits nStyle = GetStyle();
-        if ( nStyle & WB_MENUSTYLEVALUESET )
+        if (nStyle & WB_MENUSTYLEVALUESET)
         {
-            if ( bFocus )
-                ShowFocus( aRect );
+            if (bFocus)
+                ShowFocus(aRect);
 
-            if ( bDrawSel )
+            if (bDrawSel)
             {
-                SetLineColor( mbBlackSel ? Color( COL_BLACK ) : aDoubleColor );
-                DrawRect( aRect );
+                rRenderContext.SetLineColor(mbBlackSel ? Color(COL_BLACK) : aDoubleColor);
+                rRenderContext.DrawRect(aRect);
             }
         }
-        else if ( nStyle & WB_RADIOSEL )
+        else if (nStyle & WB_RADIOSEL)
         {
             aRect.Left()   += 3;
             aRect.Top()    += 3;
             aRect.Right()  -= 3;
             aRect.Bottom() -= 3;
-            if ( nStyle & WB_DOUBLEBORDER )
+            if (nStyle & WB_DOUBLEBORDER)
             {
                 aRect.Left()++;
                 aRect.Top()++;
@@ -804,44 +811,44 @@ void ValueSet::ImplDrawSelect( sal_uInt16 nItemId, const bool bFocus, const bool
                 aRect.Bottom()--;
             }
 
-            if ( bFocus )
-                ShowFocus( aRect );
+            if (bFocus)
+                ShowFocus(aRect);
 
             aRect.Left()++;
             aRect.Top()++;
             aRect.Right()--;
             aRect.Bottom()--;
 
-            if ( bDrawSel )
+            if (bDrawSel)
             {
-                SetLineColor( aDoubleColor );
+                rRenderContext.SetLineColor(aDoubleColor);
                 aRect.Left()++;
                 aRect.Top()++;
                 aRect.Right()--;
                 aRect.Bottom()--;
-                DrawRect( aRect );
+                rRenderContext.DrawRect(aRect);
                 aRect.Left()++;
                 aRect.Top()++;
                 aRect.Right()--;
                 aRect.Bottom()--;
-                DrawRect( aRect );
+                rRenderContext.DrawRect(aRect);
             }
         }
         else
         {
-            if ( bDrawSel )
+            if (bDrawSel)
             {
-                SetLineColor( mbBlackSel ? Color( COL_BLACK ) : aDoubleColor );
-                DrawRect( aRect );
+                rRenderContext.SetLineColor(mbBlackSel ? Color(COL_BLACK) : aDoubleColor);
+                rRenderContext.DrawRect(aRect);
             }
-            if ( mbDoubleSel )
+            if (mbDoubleSel)
             {
                 aRect.Left()++;
                 aRect.Top()++;
                 aRect.Right()--;
                 aRect.Bottom()--;
-                if ( bDrawSel )
-                    DrawRect( aRect );
+                if (bDrawSel)
+                    rRenderContext.DrawRect(aRect);
             }
             aRect.Left()++;
             aRect.Top()++;
@@ -852,33 +859,33 @@ void ValueSet::ImplDrawSelect( sal_uInt16 nItemId, const bool bFocus, const bool
             aRect.Top()++;
             aRect.Right()--;
             aRect.Bottom()--;
-            if ( bDrawSel )
-                DrawRect( aRect );
-            if ( mbDoubleSel )
+            if (bDrawSel)
+                rRenderContext.DrawRect(aRect);
+            if (mbDoubleSel)
             {
                 aRect.Left()++;
                 aRect.Top()++;
                 aRect.Right()--;
                 aRect.Bottom()--;
-                if ( bDrawSel )
-                    DrawRect( aRect );
+                if (bDrawSel)
+                    rRenderContext.DrawRect(aRect);
             }
 
-            if ( bDrawSel )
+            if (bDrawSel)
             {
-                SetLineColor( mbBlackSel ? Color( COL_WHITE ) : aSingleColor );
+                rRenderContext.SetLineColor(mbBlackSel ? Color(COL_WHITE) : aSingleColor);
             }
             else
             {
-                SetLineColor( Color( COL_LIGHTGRAY ) );
+                rRenderContext.SetLineColor(Color(COL_LIGHTGRAY));
             }
-            DrawRect( aRect2 );
+            rRenderContext.DrawRect(aRect2);
 
-            if ( bFocus )
-                ShowFocus( aRect2 );
+            if (bFocus)
+                ShowFocus(aRect2);
         }
 
-        ImplDrawItemText(pItem->maText);
+        ImplDrawItemText(rRenderContext, pItem->maText);
     }
 }
 
@@ -924,96 +931,96 @@ void ValueSet::ImplHighlightItem( sal_uInt16 nItemId, bool bIsSelection )
 
         // remove the old selection and draw the new one
         ImplHideSelect( nOldItem );
-        ImplDrawSelect();
+        Invalidate();
         mbDrawSelection = true;
     }
 }
 
-void ValueSet::ImplDraw()
+void ValueSet::ImplDraw(vcl::RenderContext& rRenderContext)
 {
-    if ( mbFormat )
-        Format();
+    if (mbFormat)
+        Format(rRenderContext);
 
     HideFocus();
 
-    Point   aDefPos;
-    Size    aSize = maVirDev->GetOutputSizePixel();
+    Point aDefPos;
+    Size aSize = maVirDev->GetOutputSizePixel();
 
-    if ( mxScrollBar.get() && mxScrollBar->IsVisible() )
+    if (mxScrollBar.get() && mxScrollBar->IsVisible())
     {
-        Point   aScrPos = mxScrollBar->GetPosPixel();
-        Size    aScrSize = mxScrollBar->GetSizePixel();
-        Point   aTempPos( 0, aScrPos.Y() );
-        Size    aTempSize( aSize.Width(), aScrPos.Y() );
+        Point aScrPos = mxScrollBar->GetPosPixel();
+        Size aScrSize = mxScrollBar->GetSizePixel();
+        Point aTempPos(0, aScrPos.Y());
+        Size aTempSize(aSize.Width(), aScrPos.Y());
 
-        DrawOutDev( aDefPos, aTempSize, aDefPos, aTempSize, *maVirDev.get() );
+        rRenderContext.DrawOutDev(aDefPos, aTempSize, aDefPos, aTempSize, *maVirDev.get());
         aTempSize.Width()   = aScrPos.X() - 1;
         aTempSize.Height()  = aScrSize.Height();
-        DrawOutDev( aTempPos, aTempSize, aTempPos, aTempSize, *maVirDev.get() );
+        rRenderContext.DrawOutDev(aTempPos, aTempSize, aTempPos, aTempSize, *maVirDev.get());
         aTempPos.Y()        = aScrPos.Y() + aScrSize.Height();
         aTempSize.Width()   = aSize.Width();
         aTempSize.Height()  = aSize.Height() - aTempPos.Y();
-        DrawOutDev( aTempPos, aTempSize, aTempPos, aTempSize, *maVirDev.get() );
+        rRenderContext.DrawOutDev(aTempPos, aTempSize, aTempPos, aTempSize, *maVirDev.get());
     }
     else
-        DrawOutDev( aDefPos, aSize, aDefPos, aSize, *maVirDev.get() );
+        rRenderContext.DrawOutDev(aDefPos, aSize, aDefPos, aSize, *maVirDev.get());
 
     // draw parting line to the Namefield
-    if ( GetStyle() & WB_NAMEFIELD )
+    if (GetStyle() & WB_NAMEFIELD)
     {
-        if ( !(GetStyle() & WB_FLATVALUESET) )
+        if (!(GetStyle() & WB_FLATVALUESET))
         {
-            const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
-            Size aWinSize = GetOutputSizePixel();
-            Point aPos1( NAME_LINE_OFF_X, mnTextOffset+NAME_LINE_OFF_Y );
-            Point aPos2( aWinSize.Width() - (NAME_LINE_OFF_X * 2), mnTextOffset + NAME_LINE_OFF_Y );
-            if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
+            const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+            Size aWinSize = rRenderContext.GetOutputSizePixel();
+            Point aPos1(NAME_LINE_OFF_X, mnTextOffset + NAME_LINE_OFF_Y);
+            Point aPos2(aWinSize.Width() - (NAME_LINE_OFF_X * 2), mnTextOffset + NAME_LINE_OFF_Y);
+            if (!(rStyleSettings.GetOptions() & STYLE_OPTION_MONO))
             {
-                SetLineColor( rStyleSettings.GetShadowColor() );
-                DrawLine( aPos1, aPos2 );
+                rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
+                rRenderContext.DrawLine(aPos1, aPos2);
                 aPos1.Y()++;
                 aPos2.Y()++;
-                SetLineColor( rStyleSettings.GetLightColor() );
+                rRenderContext.SetLineColor(rStyleSettings.GetLightColor());
             }
             else
-                SetLineColor( rStyleSettings.GetWindowTextColor() );
-            DrawLine( aPos1, aPos2 );
+                rRenderContext.SetLineColor(rStyleSettings.GetWindowTextColor());
+            rRenderContext.DrawLine(aPos1, aPos2);
         }
     }
 
-    ImplDrawSelect();
+    ImplDrawSelect(rRenderContext);
 }
 
-bool ValueSet::ImplScroll( const Point& rPos )
+bool ValueSet::ImplScroll(const Point& rPos)
 {
-    if ( !mbScroll || !maItemListRect.IsInside(rPos) )
+    if (!mbScroll || !maItemListRect.IsInside(rPos))
         return false;
 
-    const long nScrollOffset = (mnItemHeight <= 16) ? SCROLL_OFFSET/2 : SCROLL_OFFSET;
+    const long nScrollOffset = (mnItemHeight <= 16) ? SCROLL_OFFSET / 2 : SCROLL_OFFSET;
     bool bScroll = false;
 
-    if ( rPos.Y() <= maItemListRect.Top()+nScrollOffset )
+    if (rPos.Y() <= maItemListRect.Top() + nScrollOffset)
     {
-        if ( mnFirstLine > 0 )
+        if (mnFirstLine > 0)
         {
             --mnFirstLine;
             bScroll = true;
         }
     }
-    else if ( rPos.Y() >= maItemListRect.Bottom()-nScrollOffset )
+    else if (rPos.Y() >= maItemListRect.Bottom() - nScrollOffset)
     {
-        if ( mnFirstLine < static_cast<sal_uInt16>(mnLines-mnVisLines) )
+        if (mnFirstLine < static_cast<sal_uInt16>(mnLines - mnVisLines))
         {
             ++mnFirstLine;
             bScroll = true;
         }
     }
 
-    if ( !bScroll )
+    if (!bScroll)
         return false;
 
     mbFormat = true;
-    ImplDraw();
+    Invalidate();
     return true;
 }
 
@@ -1109,7 +1116,7 @@ IMPL_LINK( ValueSet,ImplScrollHdl, ScrollBar*, pScrollBar )
     {
         mnFirstLine = nNewFirstLine;
         mbFormat = true;
-        ImplDraw();
+        Invalidate();
     }
     return 0;
 }
@@ -1253,8 +1260,8 @@ void ValueSet::KeyInput( const KeyEvent& rKeyEvent )
         return;
     }
 
-    if ( mbFormat )
-        Format();
+    if (mbFormat)
+        Invalidate();
 
     --nLastItem;
 
@@ -1414,30 +1421,30 @@ void ValueSet::Command( const CommandEvent& rCommandEvent )
     Control::Command( rCommandEvent );
 }
 
-void ValueSet::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
+void ValueSet::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
 {
-    if ( GetStyle() & WB_FLATVALUESET )
+    if (GetStyle() & WB_FLATVALUESET)
     {
-        const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
-        SetLineColor();
-        SetFillColor( rStyleSettings.GetFaceColor() );
+        const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+        rRenderContext.SetLineColor();
+        rRenderContext.SetFillColor(rStyleSettings.GetFaceColor());
         long nOffY = maVirDev->GetOutputSizePixel().Height();
-        Size aWinSize = GetOutputSizePixel();
-        DrawRect( Rectangle( Point( 0, nOffY ), Point( aWinSize.Width(), aWinSize.Height() ) ) );
+        Size aWinSize = rRenderContext.GetOutputSizePixel();
+        rRenderContext.DrawRect(Rectangle(Point(0, nOffY ), Point( aWinSize.Width(), aWinSize.Height())));
     }
 
-    ImplDraw();
+    ImplDraw(rRenderContext);
 }
 
 void ValueSet::GetFocus()
 {
     OSL_TRACE ("value set getting focus");
-    ImplDrawSelect();
+    Invalidate();
     Control::GetFocus();
 
     // Tell the accessible object that we got the focus.
-    ValueSetAcc* pAcc = ValueSetAcc::getImplementation( GetAccessible( false ) );
-    if( pAcc )
+    ValueSetAcc* pAcc = ValueSetAcc::getImplementation(GetAccessible(false));
+    if (pAcc)
         pAcc->GetFocus();
 }
 
@@ -1487,48 +1494,47 @@ void ValueSet::RequestHelp( const HelpEvent& rHelpEvent )
     Control::RequestHelp( rHelpEvent );
 }
 
-void ValueSet::StateChanged( StateChangedType nType )
+void ValueSet::StateChanged(StateChangedType nType)
 {
-    Control::StateChanged( nType );
+    Control::StateChanged(nType);
 
-    if ( nType == StateChangedType::InitShow )
+    if (nType == StateChangedType::InitShow)
     {
-        if ( mbFormat )
-            Format();
+        if (mbFormat)
+            Invalidate();
     }
-    else if ( nType == StateChangedType::UpdateMode )
+    else if (nType == StateChangedType::UpdateMode)
     {
-        if ( IsReallyVisible() && IsUpdateMode() )
+        if (IsReallyVisible() && IsUpdateMode())
             Invalidate();
     }
-    else if ( nType == StateChangedType::Text )
+    else if (nType == StateChangedType::Text)
     {
-        if ( mpNoneItem.get() && !mbFormat && IsReallyVisible() && IsUpdateMode() )
+        if (mpNoneItem.get() && !mbFormat && IsReallyVisible() && IsUpdateMode())
         {
-            ImplFormatItem(mpNoneItem.get(), maNoneItemRect);
-            Invalidate( maNoneItemRect );
+            Invalidate(maNoneItemRect);
         }
     }
-    else if ( (nType == StateChangedType::Zoom) ||
-              (nType == StateChangedType::ControlFont) )
+    else if ((nType == StateChangedType::Zoom) ||
+             (nType == StateChangedType::ControlFont))
     {
-        ImplInitSettings( true, false, false );
+        ImplInitSettings(true, false, false);
         Invalidate();
     }
-    else if ( nType == StateChangedType::ControlForeground )
+    else if (nType == StateChangedType::ControlForeground)
     {
-        ImplInitSettings( false, true, false );
+        ImplInitSettings(false, true, false);
         Invalidate();
     }
-    else if ( nType == StateChangedType::ControlBackground )
+    else if (nType == StateChangedType::ControlBackground)
     {
-        ImplInitSettings( false, false, true );
+        ImplInitSettings(false, false, true);
         Invalidate();
     }
-    else if ( (nType == StateChangedType::Style) || (nType == StateChangedType::Enable) )
+    else if ((nType == StateChangedType::Style) || (nType == StateChangedType::Enable))
     {
         mbFormat = true;
-        ImplInitSettings( false, false, true );
+        ImplInitSettings(false, false, true);
         Invalidate();
     }
 }
@@ -1836,13 +1842,13 @@ void ValueSet::SelectItem( sal_uInt16 nItemId )
             {
                 // redraw everything if the visible area has changed
                 mbFormat = true;
-                ImplDraw();
+                Invalidate();
             }
             else
             {
                 // remove old selection and draw the new one
                 ImplHideSelect( nOldItem );
-                ImplDrawSelect();
+                Invalidate();
             }
         }
 
@@ -1920,8 +1926,8 @@ void ValueSet::SetNoSelection()
     mbHighlight     = false;
     mbSelection     = false;
 
-    if ( IsReallyVisible() && IsUpdateMode() )
-        ImplDraw();
+    if (IsReallyVisible() && IsUpdateMode())
+        Invalidate();
 }
 
 void ValueSet::SetItemImage( sal_uInt16 nItemId, const Image& rImage )
@@ -1938,8 +1944,7 @@ void ValueSet::SetItemImage( sal_uInt16 nItemId, const Image& rImage )
     if ( !mbFormat && IsReallyVisible() && IsUpdateMode() )
     {
         const Rectangle aRect = ImplGetItemRect(nPos);
-        ImplFormatItem( pItem, aRect );
-        Invalidate( aRect );
+        Invalidate(aRect);
     }
     else
         mbFormat = true;
@@ -1969,7 +1974,6 @@ void ValueSet::SetItemColor( sal_uInt16 nItemId, const Color& rColor )
     if ( !mbFormat && IsReallyVisible() && IsUpdateMode() )
     {
         const Rectangle aRect = ImplGetItemRect(nPos);
-        ImplFormatItem( pItem, aRect );
         Invalidate( aRect );
     }
     else
@@ -2001,8 +2005,7 @@ void ValueSet::SetItemData( sal_uInt16 nItemId, void* pData )
         if ( !mbFormat && IsReallyVisible() && IsUpdateMode() )
         {
             const Rectangle aRect = ImplGetItemRect(nPos);
-            ImplFormatItem( pItem, aRect );
-            Invalidate( aRect );
+            Invalidate(aRect);
         }
         else
             mbFormat = true;
@@ -2039,15 +2042,15 @@ void ValueSet::SetItemText(sal_uInt16 nItemId, const OUString& rText)
 
     pItem->maText = rText;
 
-    if ( !mbFormat && IsReallyVisible() && IsUpdateMode() )
+    if (!mbFormat && IsReallyVisible() && IsUpdateMode())
     {
         sal_uInt16 nTempId = mnSelItemId;
 
-        if ( mbHighlight )
+        if (mbHighlight)
             nTempId = mnHighItemId;
 
-        if ( nTempId == nItemId )
-            ImplDrawItemText(pItem->maText);
+        if (nTempId == nItemId)
+            Invalidate();
     }
 
     if (ImplHasAccessibleListeners())
@@ -2072,8 +2075,8 @@ void ValueSet::SetColor( const Color& rColor )
 {
     maColor  = rColor;
     mbFormat = true;
-    if ( IsReallyVisible() && IsUpdateMode() )
-        ImplDraw();
+    if (IsReallyVisible() && IsUpdateMode())
+        Invalidate();
 }
 
 void ValueSet::SetExtraSpacing( sal_uInt16 nNewSpacing )
@@ -2109,6 +2112,11 @@ void ValueSet::EndSelection()
     mbSelection = false;
 }
 
+void ValueSet::SetFormat(bool bFormat)
+{
+    mbFormat = bFormat;
+}
+
 bool ValueSet::StartDrag( const CommandEvent& rEvent, vcl::Region& rRegion )
 {
     if ( rEvent.GetCommand() != COMMAND_STARTDRAG )
@@ -2254,9 +2262,9 @@ Size ValueSet::CalcItemSizePixel( const Size& rItemSize, bool bOut ) const
 
 long ValueSet::GetScrollWidth() const
 {
-    if ( GetStyle() & WB_VSCROLL )
+    if (GetStyle() & WB_VSCROLL)
     {
-        const_cast<ValueSet*>(this)->ImplInitScrollBar();
+        const_cast<ValueSet*>(this)->Invalidate();
         return mxScrollBar->GetSizePixel().Width() + SCRBAR_OFFSET;
     }
     else
diff --git a/svx/source/dialog/svxbmpnumvalueset.cxx b/svx/source/dialog/svxbmpnumvalueset.cxx
index 57a4d6d..1e9953f 100644
--- a/svx/source/dialog/svxbmpnumvalueset.cxx
+++ b/svx/source/dialog/svxbmpnumvalueset.cxx
@@ -503,7 +503,7 @@ void SvxBmpNumValueSet::dispose()
     SvxNumValueSet::dispose();
 }
 
-void SvxBmpNumValueSet::UserDraw( const UserDrawEvent& rUDEvt )
+void SvxBmpNumValueSet::UserDraw(const UserDrawEvent& rUDEvt)
 {
     SvxNumValueSet::UserDraw(rUDEvt);
 
@@ -536,10 +536,10 @@ void SvxBmpNumValueSet::UserDraw( const UserDrawEvent& rUDEvt )
 IMPL_LINK_NOARG_TYPED(SvxBmpNumValueSet, FormatHdl_Impl, Idle *, void)
 {
     // only when a graphics was not there, it needs to be formatted
-    if(bGrfNotFound)
+    if (bGrfNotFound)
     {
+        SetFormat();
         bGrfNotFound = false;
-        Format();
     }
     Invalidate();
 }
diff --git a/svx/source/sidebar/line/LineWidthControl.cxx b/svx/source/sidebar/line/LineWidthControl.cxx
index 6a0a8fa..f8b062e 100644
--- a/svx/source/sidebar/line/LineWidthControl.cxx
+++ b/svx/source/sidebar/line/LineWidthControl.cxx
@@ -265,7 +265,8 @@ void LineWidthControl::SetWidthSelect( long lValue, bool bValuable, SfxMapUnit e
         mbVSFocus = false;
         maVSWidth->SetSelItem(0);
     }
-    maVSWidth->Format();
+    maVSWidth->SetFormat();
+    maVSWidth->Invalidate();
     maVSWidth->StartSelection();
 }
 
@@ -304,7 +305,8 @@ IMPL_LINK(LineWidthControl, VSSelectHdl, void *, pControl)
             else
             {
                 maVSWidth->SetNoSelection();     //add , set no selection and keep the last select item
-                maVSWidth->Format();
+                maVSWidth->SetFormat();
+                maVSWidth->Invalidate();
                 Invalidate();
                 maVSWidth->StartSelection();
             }
@@ -326,7 +328,8 @@ IMPL_LINK(LineWidthControl, MFModifyHdl, void *, pControl)
         if(maVSWidth->GetSelItem())
         {
             maVSWidth->SetSelItem(0);
-            maVSWidth->Format();
+            maVSWidth->SetFormat();
+            maVSWidth->Invalidate();
             Invalidate();
             maVSWidth->StartSelection();
         }
diff --git a/svx/source/sidebar/text/TextCharacterSpacingControl.cxx b/svx/source/sidebar/text/TextCharacterSpacingControl.cxx
index 0e94ee4..45137f2 100644
--- a/svx/source/sidebar/text/TextCharacterSpacingControl.cxx
+++ b/svx/source/sidebar/text/TextCharacterSpacingControl.cxx
@@ -300,7 +300,8 @@ void TextCharacterSpacingControl::Rearrange(bool bLBAvailable,bool bAvailable, l
         maFTBy->Disable();
     }
     GetFocus();
-    maVSSpacing->Format();
+    maVSSpacing->SetFormat();
+    maVSSpacing->Invalidate();
     maVSSpacing->StartSelection();
 }
 IMPL_LINK(TextCharacterSpacingControl, VSSelHdl, void *, pControl)
@@ -365,7 +366,8 @@ IMPL_LINK(TextCharacterSpacingControl, VSSelHdl, void *, pControl)
             else
             {
                 maVSSpacing->SetNoSelection();       //add , set no selection and keep the last select item
-                maVSSpacing->Format();
+                maVSSpacing->SetFormat();
+                maVSSpacing->Invalidate();
                 Invalidate();
                 maVSSpacing->StartSelection();
             }
@@ -399,7 +401,8 @@ IMPL_LINK(TextCharacterSpacingControl, KerningSelectHdl, ListBox*,)
     {
         maVSSpacing->SetNoSelection();
         maVSSpacing->SelectItem(0);
-        maVSSpacing->Format();
+        maVSSpacing->SetFormat();
+        maVSSpacing->Invalidate();
         Invalidate();
         maVSSpacing->StartSelection();
     }
@@ -412,7 +415,8 @@ IMPL_LINK(TextCharacterSpacingControl, KerningModifyHdl, MetricField*,)
     {
         maVSSpacing->SetNoSelection();
         maVSSpacing->SelectItem(0);
-        maVSSpacing->Format();
+        maVSSpacing->SetFormat();
+        maVSSpacing->Invalidate();
         Invalidate();
         maVSSpacing->StartSelection();
     }
diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx
index acfd881..e7e0033 100644
--- a/sw/source/ui/frmdlg/column.cxx
+++ b/sw/source/ui/frmdlg/column.cxx
@@ -1349,9 +1349,9 @@ void SwColumnPage::SetInSection(bool bSet)
     m_pTextDirectionLB->Show(bSet);
 }
 
-void ColumnValueSet::UserDraw( const UserDrawEvent& rUDEvt )
+void ColumnValueSet::UserDraw(const UserDrawEvent& rUDEvt)
 {
-    OutputDevice*  pDev = rUDEvt.GetDevice();
+    OutputDevice* pDev = rUDEvt.GetDevice();
     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
 
     Rectangle aRect = rUDEvt.GetRect();
@@ -1419,7 +1419,8 @@ void ColumnValueSet::DataChanged( const DataChangedEvent& rDCEvt )
     if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
          (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
     {
-        Format();
+        SetFormat();
+        Invalidate();
     }
     ValueSet::DataChanged( rDCEvt );
 }
diff --git a/sw/source/uibase/sidebar/PageColumnControl.cxx b/sw/source/uibase/sidebar/PageColumnControl.cxx
index db1c856..2c37741 100644
--- a/sw/source/uibase/sidebar/PageColumnControl.cxx
+++ b/sw/source/uibase/sidebar/PageColumnControl.cxx
@@ -66,7 +66,8 @@ PageColumnControl::PageColumnControl(
     mpColumnValueSet->SetSelectHdl( LINK(this, PageColumnControl,ImplColumnHdl ) );
     mpColumnValueSet->Show();
     mpColumnValueSet->SelectItem( mnColumnType );
-    mpColumnValueSet->Format();
+    mpColumnValueSet->SetFormat();
+    mpColumnValueSet->Invalidate();
     mpColumnValueSet->StartSelection();
 
     maMoreButton->SetClickHdl( LINK( this, PageColumnControl, MoreButtonClickHdl_Impl ) );
diff --git a/sw/source/uibase/sidebar/PageMarginControl.cxx b/sw/source/uibase/sidebar/PageMarginControl.cxx
index 4293b03..5a80668 100644
--- a/sw/source/uibase/sidebar/PageMarginControl.cxx
+++ b/sw/source/uibase/sidebar/PageMarginControl.cxx
@@ -318,8 +318,8 @@ void PageMarginControl::SelectValueSetItem()
     {
         mpMarginValueSet->SelectItem(0);
     }
-
-    mpMarginValueSet->Format();
+    mpMarginValueSet->SetFormat();
+    mpMarginValueSet->Invalidate();
     mpMarginValueSet->StartSelection();
 };
 
@@ -405,7 +405,8 @@ IMPL_LINK( PageMarginControl, ModifyLRMarginHdl, MetricField *, )
 {
     mpMarginValueSet->SetNoSelection();
     mpMarginValueSet->SelectItem(0);
-    mpMarginValueSet->Format();
+    mpMarginValueSet->SetFormat();
+    mpMarginValueSet->Invalidate();
     mpMarginValueSet->StartSelection();
 
     mnPageLeftMargin = GetCoreValue( *maLeftMarginEdit.get(), meUnit );
@@ -419,7 +420,8 @@ IMPL_LINK( PageMarginControl, ModifyULMarginHdl, MetricField *, )
 {
     mpMarginValueSet->SetNoSelection();
     mpMarginValueSet->SelectItem(0);
-    mpMarginValueSet->Format();
+    mpMarginValueSet->SetFormat();
+    mpMarginValueSet->Invalidate();
     mpMarginValueSet->StartSelection();
 
     mnPageTopMargin = GetCoreValue( *maTopMarginEdit.get(), meUnit );
diff --git a/sw/source/uibase/sidebar/PageOrientationControl.cxx b/sw/source/uibase/sidebar/PageOrientationControl.cxx
index 3bc07bb..1c3dc35 100644
--- a/sw/source/uibase/sidebar/PageOrientationControl.cxx
+++ b/sw/source/uibase/sidebar/PageOrientationControl.cxx
@@ -55,7 +55,8 @@ PageOrientationControl::PageOrientationControl(
     mpOrientationValueSet->Show();
     mpOrientationValueSet->SelectItem( mbLandscape ? 2 : 1 );
     mpOrientationValueSet->GrabFocus();
-    mpOrientationValueSet->Format();
+    mpOrientationValueSet->SetFormat();
+    mpOrientationValueSet->Invalidate();
     mpOrientationValueSet->StartSelection();
 
     FreeResource();
diff --git a/sw/source/uibase/sidebar/PageSizeControl.cxx b/sw/source/uibase/sidebar/PageSizeControl.cxx
index 0b287f8..48f1b0a 100644
--- a/sw/source/uibase/sidebar/PageSizeControl.cxx
+++ b/sw/source/uibase/sidebar/PageSizeControl.cxx
@@ -132,7 +132,8 @@ PageSizeControl::PageSizeControl(
     mpSizeValueSet->Show();
 
     mpSizeValueSet->SelectItem( nSelectedItem );
-    mpSizeValueSet->Format();
+    mpSizeValueSet->SetFormat();
+    mpSizeValueSet->Invalidate();
     mpSizeValueSet->StartSelection();
 
     maMoreButton->SetClickHdl( LINK( this, PageSizeControl, MoreButtonClickHdl_Impl ) );
commit fb8f83c12e991ad01f049332c022697736d03986
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Mon May 11 14:33:01 2015 +0900

    refactor TabBar to use RenderContext
    
    Change-Id: Id29cbf407fe96fceb326b1197991baf4698e5177

diff --git a/include/svtools/tabbar.hxx b/include/svtools/tabbar.hxx
index 04e5207..b1b692b 100644
--- a/include/svtools/tabbar.hxx
+++ b/include/svtools/tabbar.hxx
@@ -358,8 +358,9 @@ private:
     using Window::ImplInit;
     SVT_DLLPRIVATE void            ImplInit( WinBits nWinStyle );
     SVT_DLLPRIVATE void            ImplInitSettings( bool bFont, bool bBackground );
-    SVT_DLLPRIVATE void            ImplGetColors( Color& rFaceColor, Color& rFaceTextColor,
-                                   Color& rSelectColor, Color& rSelectTextColor );
+    SVT_DLLPRIVATE void            ImplGetColors(const StyleSettings& rStyleSettings,
+                                                 Color& rFaceColor, Color& rFaceTextColor,
+                                                 Color& rSelectColor, Color& rSelectTextColor);
     SVT_DLLPRIVATE void            ImplShowPage( sal_uInt16 nPos );
     SVT_DLLPRIVATE bool            ImplCalcWidth();
     SVT_DLLPRIVATE void            ImplFormat();
@@ -369,7 +370,7 @@ private:
     SVT_DLLPRIVATE void            ImplSelect();
     SVT_DLLPRIVATE void            ImplActivatePage();
     SVT_DLLPRIVATE bool            ImplDeactivatePage();
-    SVT_DLLPRIVATE void            ImplPrePaint();
+    SVT_DLLPRIVATE void            ImplPrePaint(vcl::RenderContext& rRenderContext);
     SVT_DLLPRIVATE ImplTabBarItem* ImplGetLastTabBarItem( sal_uInt16 nItemCount );
     SVT_DLLPRIVATE Rectangle       ImplGetInsertTabRect(ImplTabBarItem* pItem) const;
 
diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx
index ea11afc..ae62dc1 100644
--- a/svtools/source/control/tabbar.cxx
+++ b/svtools/source/control/tabbar.cxx
@@ -36,7 +36,9 @@
 #include <limits>
 #include <utility>
 
-namespace {
+namespace
+{
+
 #define TABBAR_DRAG_SCROLLOFF   5
 #define TABBAR_MINSIZE          5
 
@@ -44,6 +46,181 @@ const sal_uInt16 ADDNEWPAGE_AREAWIDTH = 10;
 const sal_uInt16 INSERT_TAB_WIDTH = 32;
 const sal_uInt16 BUTTON_MARGIN = 6;
 
+class TabDrawer
+{
+private:
+    TabBar& mrParent;
+    vcl::RenderContext& mrRenderContext;
+    const StyleSettings&  mrStyleSettings;
+
+    Rectangle maRect;
+
+    Color maSelectedColor;
+    Color maCustomColor;
+    Color maUnselectedColor;
+
+    bool mbSelected:1;
+    bool mbCustomColored:1;
+    bool mbSpecialTab:1;
+    bool mbEnabled:1;
+
+public:
+    explicit TabDrawer(TabBar& rParent, vcl::RenderContext& rRenderContext)
+        : mrParent(rParent)
+        , mrRenderContext(rRenderContext)
+        , mrStyleSettings(rRenderContext.GetSettings().GetStyleSettings())
+        , mbSelected(false)
+        , mbCustomColored(false)
+        , mbSpecialTab(false)
+        , mbEnabled(false)
+    {
+    }
+
+    void drawOutputAreaBorder()
+    {
+        WinBits nWinStyle = mrParent.GetStyle();
+
+        // draw extra line if above and below border
+        if ((nWinStyle & WB_BORDER) || (nWinStyle & WB_TOPBORDER))
+        {
+            Size aOutputSize = mrRenderContext.GetOutputSizePixel();
+            Rectangle aOutRect = mrParent.GetPageArea();
+
+            // also draw border in 3D for 3D-tabs
+            if (nWinStyle & WB_3DTAB)
+            {
+                mrRenderContext.SetLineColor(mrStyleSettings.GetShadowColor());
+                mrRenderContext.DrawLine(Point(aOutRect.Left(), 0), Point(aOutputSize.Width(), 0));
+            }
+
+            // draw border (line above and line below)
+            mrRenderContext.SetLineColor(mrStyleSettings.GetDarkShadowColor());
+            mrRenderContext.DrawLine(aOutRect.TopLeft(), Point(aOutputSize.Width() - 1, aOutRect.Top()));
+        }
+    }
+
+    void drawOuterFrame()
+    {
+        mrRenderContext.SetLineColor(mrStyleSettings.GetDarkShadowColor());
+
+        // set correct FillInBrush depending on status
+        if (mbSelected)
+        {
+            // Currently selected Tab
+            mrRenderContext.SetFillColor(maSelectedColor);
+        }
+        else if (mbCustomColored)
+        {
+            mrRenderContext.SetFillColor(maCustomColor);
+        }
+        else
+        {
+            mrRenderContext.SetFillColor(maUnselectedColor);
+        }
+
+        mrRenderContext.DrawRect(maRect);
+    }
+
+    void drawText(const OUString& aText)
+    {
+        Rectangle aRect = maRect;
+        long nTextWidth = mrRenderContext.GetTextWidth(aText);
+        long nTextHeight = mrRenderContext.GetTextHeight();
+        Point aPos = aRect.TopLeft();
+        aPos.X() += (aRect.getWidth()  - nTextWidth) / 2;
+        aPos.Y() += (aRect.getHeight() - nTextHeight) / 2;
+
+        if (mbEnabled)
+            mrRenderContext.DrawText(aPos, aText);
+        else
+            mrRenderContext.DrawCtrlText(aPos, aText, 0, aText.getLength(), (TEXT_DRAW_DISABLE | TEXT_DRAW_MNEMONIC));
+    }
+
+    void drawOverTopBorder()
+    {
+        Point aTopLeft  = maRect.TopLeft()  + Point(1, 0);
+        Point aTopRight = maRect.TopRight() + Point(-1, 0);
+
+        Rectangle aDelRect(aTopLeft, aTopRight);
+        mrRenderContext.DrawRect(aDelRect);
+    }
+
+    void drawColorLine()
+    {
+        mrRenderContext.SetFillColor(maCustomColor);
+        mrRenderContext.SetLineColor(maCustomColor);
+
+        Rectangle aLineRect(maRect.BottomLeft(), maRect.BottomRight());
+        aLineRect.Top() -= 3;
+
+        mrRenderContext.DrawRect(aLineRect);
+    }
+
+    void drawTab()
+    {
+        drawOuterFrame();
+
+        if (mbCustomColored && mbSelected)
+        {
+            drawColorLine();
+        }
+    }
+
+    void drawPlusImage()
+    {
+        DecorationView aDecorationView(&mrRenderContext);
+        sal_Int32 aScaleFactor = mrRenderContext.GetDPIScaleFactor();
+        Size aSize(12 * aScaleFactor, 12 * aScaleFactor);
+
+        Point aPosition = maRect.TopLeft();
+        long nXOffSet = (maRect.GetWidth() - aSize.Width()) / 2;
+        long nYOffset = (maRect.GetHeight() - aSize.Height()) / 2;
+        aPosition += Point(nXOffSet, nYOffset);
+
+        aDecorationView.DrawSymbol(Rectangle(aPosition, aSize), SymbolType::PLUS, mrStyleSettings.GetDarkShadowColor());
+    }
+
+    void setRect(const Rectangle& rRect)
+    {
+        maRect = rRect;
+    }
+
+    void setSelected(bool bSelected)
+    {
+        mbSelected = bSelected;
+    }
+
+    void setCustomColored(bool bCustomColored)
+    {
+        mbCustomColored = bCustomColored;
+    }
+
+    void setSpecialTab(bool bSpecialTab)
+    {
+        mbSpecialTab = bSpecialTab;
+    }
+
+    void setEnabled(bool bEnabled)
+    {
+        mbEnabled = bEnabled;
+    }
+
+    void setSelectedFillColor(const Color& rColor)
+    {
+        maSelectedColor = rColor;
+    }
+
+    void setUnselectedFillColor(const Color& rColor)
+    {
+        maUnselectedColor = rColor;
+    }
+
+    void setCustomColor(const Color& rColor)
+    {
+        maCustomColor = rColor;
+    }
+};
+
 } // anonymous namespace
 
 struct ImplTabBarItem
@@ -221,10 +398,10 @@ void ImplTabSizer::Tracking( const TrackingEvent& rTEvt )
         ImplTrack( OutputToScreenPixel( rTEvt.GetMouseEvent().GetPosPixel() ) );
 }
 
-void ImplTabSizer::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
+void ImplTabSizer::Paint( vcl::RenderContext& rRenderContext, const Rectangle& )
 {
-    DecorationView aDecoView(this);
-    Rectangle aOutputRect(Point(0, 0), GetOutputSizePixel());
+    DecorationView aDecoView(&rRenderContext);
+    Rectangle aOutputRect(Point(0, 0), rRenderContext.GetOutputSizePixel());
     aDecoView.DrawHandle(aOutputRect, true);
 }
 
@@ -494,31 +671,30 @@ void TabBar::ImplInitSettings( bool bFont, bool bBackground )
     }
 }
 
-void TabBar::ImplGetColors( Color& rFaceColor, Color& rFaceTextColor,
-                            Color& rSelectColor, Color& rSelectTextColor )
+void TabBar::ImplGetColors(const StyleSettings& rStyleSettings,
+                           Color& rFaceColor, Color& rFaceTextColor,
+                           Color& rSelectColor, Color& rSelectTextColor)
 {
-    const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
-
-    if ( IsControlBackground() )
+    if (IsControlBackground())
         rFaceColor = GetControlBackground();
     else
         rFaceColor = rStyleSettings.GetInactiveTabColor();
-    if ( IsControlForeground() )
+    if (IsControlForeground())
         rFaceTextColor = GetControlForeground();
     else
         rFaceTextColor = rStyleSettings.GetButtonTextColor();
-    if ( mbSelColor )
+    if (mbSelColor)
         rSelectColor = maSelColor;
     else
         rSelectColor = rStyleSettings.GetActiveTabColor();
-    if ( mbSelTextColor )
+    if (mbSelTextColor)
         rSelectTextColor = maSelTextColor;
     else
         rSelectTextColor = rStyleSettings.GetWindowTextColor();
 
     // For 3D-tabs the selection- and face-colours are swapped,
     // as the selected tabs should appear in 3D
-    if ( mnWinStyle & WB_3DTAB )
+    if (mnWinStyle & WB_3DTAB)
     {
         using std::swap;
         swap(rFaceColor, rSelectColor);
@@ -1017,233 +1193,33 @@ void TabBar::MouseButtonUp( const MouseEvent& rMEvt )
     Window::MouseButtonUp( rMEvt );
 }
 
-namespace {
-
-class TabBarPaintGuard
+void TabBar::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rect)
 {
-public:
-    explicit TabBarPaintGuard(TabBar& rParent) :
-        mrParent(rParent),
-        maFont(rParent.GetFont())
-    {
-        // #i36013# exclude push buttons from painting area
-        mrParent.SetClipRegion( vcl::Region(mrParent.GetPageArea()) );
-    }
-
-    ~TabBarPaintGuard()
+    if (rRenderContext.IsNativeControlSupported(CTRL_WINDOW_BACKGROUND,PART_ENTIRE_CONTROL))
     {
-        // Restore original font.
-        mrParent.SetFont(maFont);
-        // remove clip region
-        mrParent.SetClipRegion();
+        rRenderContext.DrawNativeControl(CTRL_WINDOW_BACKGROUND,PART_ENTIRE_CONTROL,rect,
+                                         ControlState::ENABLED,ImplControlValue(0),OUString());
     }
-private:
-    TabBar&   mrParent;
-    vcl::Font maFont;
-};
-
-class TabDrawer
-{
-public:
-
-    explicit TabDrawer(TabBar& rParent) :
-        mrParent(rParent),
-        mpStyleSettings(&mrParent.GetSettings().GetStyleSettings()),
-        mbSelected(false),
-        mbCustomColored(false),
-        mbSpecialTab(false),
-        mbEnabled(false)
-    {
-    }
-
-    void drawOutputAreaBorder()
-    {
-        WinBits nWinStyle = mrParent.GetStyle();
-
-        // draw extra line if above and below border
-        if ((nWinStyle & WB_BORDER) || (nWinStyle & WB_TOPBORDER))
-        {
-            Size aOutputSize = mrParent.GetOutputSizePixel();
-            Rectangle aOutRect = mrParent.GetPageArea();
-
-            // also draw border in 3D for 3D-tabs
-            if (nWinStyle & WB_3DTAB)
-            {
-                mrParent.SetLineColor(mpStyleSettings->GetShadowColor());
-                mrParent.DrawLine(Point(aOutRect.Left(), 0), Point(aOutputSize.Width(), 0));
-            }
-
-            // draw border (line above and line below)
-            mrParent.SetLineColor(mpStyleSettings->GetDarkShadowColor());
-            mrParent.DrawLine(aOutRect.TopLeft(), Point(aOutputSize.Width() - 1, aOutRect.Top()));
-        }
-    }
-
-    void drawOuterFrame()
-    {
-        mrParent.SetLineColor(mpStyleSettings->GetDarkShadowColor());
-
-        // set correct FillInBrush depending on status
-        if (mbSelected)
-        {
-            // Currently selected Tab
-            mrParent.SetFillColor(maSelectedColor);
-        }
-        else if (mbCustomColored)
-        {
-            mrParent.SetFillColor(maCustomColor);
-        }
-        else
-        {
-            mrParent.SetFillColor(maUnselectedColor);
-        }
-
-        mrParent.DrawRect(maRect);
-    }
-
-    void drawText(const OUString& aText)
-    {
-        Rectangle aRect = maRect;
-        long nTextWidth = mrParent.GetTextWidth(aText);
-        long nTextHeight = mrParent.GetTextHeight();
-        Point aPos = aRect.TopLeft();
-        aPos.X() += (aRect.getWidth()  - nTextWidth) / 2;
-        aPos.Y() += (aRect.getHeight() - nTextHeight) / 2;
-
-        if (mbEnabled)
-            mrParent.DrawText(aPos, aText);
-        else
-            mrParent.DrawCtrlText(aPos, aText, 0, aText.getLength(),
-                                    (TEXT_DRAW_DISABLE | TEXT_DRAW_MNEMONIC));
-    }
-
-    void drawOverTopBorder()
-    {
-        Point aTopLeft  = maRect.TopLeft()  + Point(1, 0);
-        Point aTopRight = maRect.TopRight() + Point(-1, 0);
-
-        Rectangle aDelRect(aTopLeft, aTopRight);
-        mrParent.DrawRect(aDelRect);
-    }
-
-    void drawColorLine()
-    {
-        mrParent.SetFillColor(maCustomColor);
-        mrParent.SetLineColor(maCustomColor);
-
-        Rectangle aLineRect(maRect.BottomLeft(), maRect.BottomRight());
-        aLineRect.Top() -= 3;
-
-        mrParent.DrawRect(aLineRect);
-    }
-
-    void drawTab()
-    {
-        drawOuterFrame();
-
-        if (mbCustomColored && mbSelected)
-        {
-            drawColorLine();
-        }
-    }
-
-    void drawPlusImage()
-    {
-        const StyleSettings& rStyleSettings = mrParent.GetSettings().GetStyleSettings();
-
-        DecorationView aDecorationView(&mrParent);
-        sal_Int32 aScaleFactor = mrParent.GetDPIScaleFactor();
-        Size aSize(12 * aScaleFactor, 12 * aScaleFactor);
-
-        Point aPosition = maRect.TopLeft();
-        long nXOffSet = (maRect.GetWidth() - aSize.Width()) / 2;
-        long nYOffset = (maRect.GetHeight() - aSize.Height()) / 2;
-        aPosition += Point(nXOffSet, nYOffset);
-
-        aDecorationView.DrawSymbol(Rectangle(aPosition, aSize), SymbolType::PLUS, rStyleSettings.GetDarkShadowColor());
-    }
-
-    void setRect(const Rectangle& rRect)
-    {
-        maRect = rRect;
-    }
-
-    void setSelected(bool bSelected)
-    {
-        mbSelected = bSelected;
-    }
-
-    void setCustomColored(bool bCustomColored)
-    {
-        mbCustomColored = bCustomColored;
-    }
-
-    void setSpecialTab(bool bSpecialTab)
-    {
-        mbSpecialTab = bSpecialTab;
-    }
-
-    void setEnabled(bool bEnabled)
-    {
-        mbEnabled = bEnabled;
-    }
-
-    void setSelectedFillColor(const Color& rColor)
-    {
-        maSelectedColor = rColor;
-    }
-
-    void setUnselectedFillColor(const Color& rColor)
-    {
-        maUnselectedColor = rColor;
-    }
-
-    void setCustomColor(const Color& rColor)
-    {
-        maCustomColor = rColor;
-    }
-
-private:
-    TabBar&         mrParent;
-    const StyleSettings*  mpStyleSettings;
-
-    Rectangle       maRect;
-
-    Color       maSelectedColor;
-    Color       maCustomColor;
-    Color       maUnselectedColor;
-
-    bool        mbSelected:1;
-    bool        mbCustomColored:1;
-    bool        mbSpecialTab:1;
-    bool        mbEnabled:1;
-};
-
-} // anonymous namespace
-
-void TabBar::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rect )
-{
-    if(IsNativeControlSupported(CTRL_WINDOW_BACKGROUND,PART_ENTIRE_CONTROL))
-        DrawNativeControl(CTRL_WINDOW_BACKGROUND,PART_ENTIRE_CONTROL,rect,
-                ControlState::ENABLED,ImplControlValue(0),OUString());
-
     // calculate items and emit
     sal_uInt16 nItemCount = mpImpl->getItemSize();
     if (!nItemCount)
         return;
 
-    ImplPrePaint();
+    ImplPrePaint(rRenderContext);
 
     Color aFaceColor, aSelectColor, aFaceTextColor, aSelectTextColor;
-    ImplGetColors( aFaceColor, aFaceTextColor, aSelectColor, aSelectTextColor );
+    const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+    ImplGetColors(rStyleSettings, aFaceColor, aFaceTextColor, aSelectColor, aSelectTextColor);
+
+    rRenderContext.Push(PushFlags::FONT | PushFlags::CLIPREGION);
+    rRenderContext.SetClipRegion(vcl::Region(GetPageArea()));
 
     // select font
-    vcl::Font aFont = GetFont();
+    vcl::Font aFont = rRenderContext.GetFont();
     vcl::Font aLightFont = aFont;
-    aLightFont.SetWeight( WEIGHT_NORMAL );
+    aLightFont.SetWeight(WEIGHT_NORMAL);
 
-    TabBarPaintGuard aGuard(*this);
-    TabDrawer aDrawer(*this);
+    TabDrawer aDrawer(*this, rRenderContext);
 
     aDrawer.setSelectedFillColor(aSelectColor);
     aDrawer.setUnselectedFillColor(aFaceColor);
@@ -1262,23 +1238,22 @@ void TabBar::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rec
         aDrawer.drawPlusImage();
     }
 
-    const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     ImplTabBarItem* pCurItem = NULL;
-    while ( pItem )
+    while (pItem)
     {
         // emit CurrentItem last, as it covers all others
-        if ( !pCurItem && (pItem->mnId == mnCurPageId) )
+        if (!pCurItem && (pItem->mnId == mnCurPageId))
         {
             pCurItem = pItem;
             pItem = prev();
-            if ( !pItem )
+            if (!pItem)
                 pItem = pCurItem;
             continue;
         }
 
         bool bCurrent = pItem == pCurItem;
 
-        if ( !pItem->maRect.IsEmpty() )
+        if (!pItem->maRect.IsEmpty())
         {
             Rectangle aRect = pItem->maRect;
             bool bSelected = pItem->IsSelected(pCurItem);
@@ -1286,8 +1261,7 @@ void TabBar::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rec
             bool bCustomBgColor = !pItem->IsDefaultTabBgColor() && !rStyleSettings.GetHighContrastMode();
             bool bSpecialTab = (pItem->mnBits & TPB_SPECIAL);
             bool bEnabled = pItem->mbEnable;
-            OUString aText = pItem->mbShort ?
-                GetEllipsisString(pItem->maText, mnCurMaxWidth, TEXT_DRAW_ENDELLIPSIS) : pItem->maText;
+            OUString aText = pItem->mbShort ? rRenderContext.GetEllipsisString(pItem->maText, mnCurMaxWidth, TEXT_DRAW_ENDELLIPSIS) : pItem->maText;
 
             aDrawer.setRect(aRect);
             aDrawer.setSelected(bSelected);
@@ -1298,30 +1272,30 @@ void TabBar::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rec
             aDrawer.drawTab();
 
             // actual page is drawn using a bold font
-            if ( bCurrent )
-                SetFont( aFont );
+            if (bCurrent)
+                rRenderContext.SetFont(aFont);
             else
-                SetFont( aLightFont );
+                rRenderContext.SetFont(aLightFont);
 
             // Set the correct FillInBrush depending on status
 
-            if ( bSelected )
-                SetTextColor( aSelectTextColor );
-            else if ( bCustomBgColor )
-                SetTextColor( pItem->maTabTextColor );
+            if (bSelected)
+                rRenderContext.SetTextColor(aSelectTextColor);
+            else if (bCustomBgColor)
+                rRenderContext.SetTextColor(pItem->maTabTextColor);
             else
-                SetTextColor( aFaceTextColor );
+                rRenderContext.SetTextColor(aFaceTextColor);
 
             // This tab is "special", and a special tab needs a blue text.
             if (bSpecialTab)
-                SetTextColor(Color(COL_LIGHTBLUE));
+                rRenderContext.SetTextColor(Color(COL_LIGHTBLUE));
 
             aDrawer.drawText(aText);
 
-            if ( bCurrent )
+            if (bCurrent)
             {
-                SetLineColor();
-                SetFillColor(aSelectColor);
+                rRenderContext.SetLineColor();
+                rRenderContext.SetFillColor(aSelectColor);
                 aDrawer.drawOverTopBorder();
                 return;
             }
@@ -1330,13 +1304,13 @@ void TabBar::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rec
         }
         else
         {
-            if ( bCurrent )
+            if (bCurrent)
                 return;
 
             pItem = NULL;
         }
 
-        if ( !pItem )
+        if (!pItem)
             pItem = pCurItem;
     }
 }
@@ -1624,7 +1598,7 @@ bool TabBar::ImplDeactivatePage()
     return nRet;
 }
 
-void TabBar::ImplPrePaint()
+void TabBar::ImplPrePaint(vcl::RenderContext& /*rRenderContext*/)
 {
     sal_uInt16 nItemCount = mpImpl->getItemSize();
     if (!nItemCount)
@@ -1635,20 +1609,20 @@ void TabBar::ImplPrePaint()
     ImplFormat();
 
     // assure the actual tabpage becomes visible at first format
-    if ( mbFirstFormat )
+    if (mbFirstFormat)
     {
         mbFirstFormat = false;
 
-        if ( mnCurPageId && (mnFirstPos == 0) && !mbDropPos )
+        if (mnCurPageId && (mnFirstPos == 0) && !mbDropPos)
         {
             ImplTabBarItem* pItem = mpImpl->mpItemList[GetPagePos(mnCurPageId)];
-            if ( pItem->maRect.IsEmpty() )
+            if (pItem->maRect.IsEmpty())
             {
                 // set mbDropPos (or misuse) to prevent Invalidate()
                 mbDropPos = true;
-                SetFirstPageId( mnCurPageId );
+                SetFirstPageId(mnCurPageId);
                 mbDropPos = false;
-                if ( mnFirstPos != 0 )
+                if (mnFirstPos != 0)
                     ImplFormat();
             }
         }
@@ -2164,16 +2138,16 @@ bool TabBar::IsPageSelected( sal_uInt16 nPageId ) const
         return false;
 }
 
-bool TabBar::StartEditMode( sal_uInt16 nPageId )
+bool TabBar::StartEditMode(sal_uInt16 nPageId)
 {
     sal_uInt16 nPos = GetPagePos( nPageId );
     if (mpImpl->mpEdit || (nPos == PAGE_NOT_FOUND) || (mnLastOffX < 8))
         return false;
 
     mnEditId = nPageId;
-    if ( StartRenaming() )
+    if (StartRenaming())
     {
-        ImplShowPage( nPos );
+        ImplShowPage(nPos);
         ImplFormat();
         Update();
 
@@ -2181,11 +2155,11 @@ bool TabBar::StartEditMode( sal_uInt16 nPageId )
         Rectangle aRect = GetPageRect( mnEditId );
         long nX = aRect.Left();
         long nWidth = aRect.GetWidth();
-        if ( mnEditId != GetCurPageId() )
+        if (mnEditId != GetCurPageId())
             nX += 1;
-        if ( nX+nWidth > mnLastOffX )
+        if (nX + nWidth > mnLastOffX)
             nWidth = mnLastOffX-nX;
-        if ( nWidth < 3 )
+        if (nWidth < 3)
         {
             nX = aRect.Left();
             nWidth = aRect.GetWidth();
@@ -2193,16 +2167,21 @@ bool TabBar::StartEditMode( sal_uInt16 nPageId )
         mpImpl->mpEdit->SetText(GetPageText(mnEditId));
         mpImpl->mpEdit->setPosSizePixel(nX, aRect.Top() + mnOffY + 1, nWidth, aRect.GetHeight() - 3);
         vcl::Font aFont = GetPointFont();
+
         Color   aForegroundColor;
         Color   aBackgroundColor;
         Color   aFaceColor;
         Color   aSelectColor;
         Color   aFaceTextColor;
         Color   aSelectTextColor;
-        ImplGetColors( aFaceColor, aFaceTextColor, aSelectColor, aSelectTextColor );
-        if ( mnEditId != GetCurPageId() )
-            aFont.SetWeight( WEIGHT_LIGHT );
-        if ( IsPageSelected( mnEditId ) || (mnEditId == GetCurPageId()) )
+
+        ImplGetColors(Application::GetSettings().GetStyleSettings(), aFaceColor, aFaceTextColor, aSelectColor, aSelectTextColor);
+
+        if (mnEditId != GetCurPageId())
+        {
+            aFont.SetWeight(WEIGHT_LIGHT);
+        }
+        if (IsPageSelected(mnEditId) || mnEditId == GetCurPageId())
         {
             aForegroundColor = aSelectTextColor;
             aBackgroundColor = aSelectColor;
@@ -2212,8 +2191,10 @@ bool TabBar::StartEditMode( sal_uInt16 nPageId )
             aForegroundColor = aFaceTextColor;
             aBackgroundColor = aFaceColor;
         }
-        if ( GetPageBits( mnEditId ) & TPB_SPECIAL )
-            aForegroundColor = Color( COL_LIGHTBLUE );
+        if (GetPageBits( mnEditId ) & TPB_SPECIAL)
+        {
+            aForegroundColor = Color(COL_LIGHTBLUE);
+        }
         mpImpl->mpEdit->SetControlFont(aFont);
         mpImpl->mpEdit->SetControlForeground(aForegroundColor);
         mpImpl->mpEdit->SetControlBackground(aBackgroundColor);


More information about the Libreoffice-commits mailing list