[Libreoffice-commits] core.git: 15 commits - include/vcl sd/source starmath/source svx/workben sw/source vcl/source

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Fri May 15 01:10:58 PDT 2015


 include/vcl/menu.hxx                     |    2 
 sd/source/ui/dlg/headerfooterdlg.cxx     |   66 +++----
 sd/source/ui/view/ViewTabBar.cxx         |   28 +--
 starmath/source/view.cxx                 |   10 +
 svx/workben/pixelctl.cxx                 |   24 +-
 sw/source/core/bastyp/swtypes.cxx        |   16 -
 sw/source/ui/chrdlg/drpcps.cxx           |   68 ++++---
 sw/source/ui/envelp/envlop1.cxx          |   39 ++--
 sw/source/ui/envelp/labfmt.cxx           |  126 +++++++-------
 sw/source/ui/envelp/labfmt.hxx           |    2 
 sw/source/ui/frmdlg/frmpage.cxx          |   37 ++--
 sw/source/ui/misc/outline.cxx            |  112 +++++-------
 sw/source/ui/table/tautofmt.cxx          |  269 +++++++++++++++++--------------
 sw/source/uibase/frmdlg/colex.cxx        |   68 ++++---
 sw/source/uibase/inc/swruler.hxx         |    4 
 sw/source/uibase/misc/swruler.cxx        |   46 ++---
 vcl/source/control/ctrl.cxx              |   16 -
 vcl/source/window/menu.cxx               |   45 ++---
 vcl/source/window/menubarwindow.cxx      |   70 ++++----
 vcl/source/window/menubarwindow.hxx      |    2 
 vcl/source/window/menufloatingwindow.cxx |   30 +--
 21 files changed, 560 insertions(+), 520 deletions(-)

New commits:
commit 8c4b77ac55d1dadfdcdb5b54aac6523bd894ea36
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri May 15 17:05:14 2015 +0900

    partially refactor MenuBar to use RenderContext
    
    Change-Id: I91353f2a74cdcafbe53fec3bd3ee58883c21fec5

diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx
index b0d26d7..f4d57a4 100644
--- a/include/vcl/menu.hxx
+++ b/include/vcl/menu.hxx
@@ -186,7 +186,7 @@ protected:
     SAL_DLLPRIVATE sal_uInt16           ImplGetPrevVisible( sal_uInt16 nPos ) const;
     SAL_DLLPRIVATE sal_uInt16           ImplGetNextVisible( sal_uInt16 nPos ) const;
     SAL_DLLPRIVATE void             ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nOffY = 0, MenuItemData* pThisDataOnly = 0, bool bHighlighted = false, bool bLayout = false, bool bRollover = false ) const;
-    SAL_DLLPRIVATE void             ImplPaintMenuTitle( vcl::Window* pWin, const Rectangle& rRect ) const;
+    SAL_DLLPRIVATE void             ImplPaintMenuTitle(vcl::RenderContext&, const Rectangle& rRect) const;
     SAL_DLLPRIVATE void             ImplSelect();
     SAL_DLLPRIVATE void             ImplCallHighlight( sal_uInt16 nHighlightItem );
     SAL_DLLPRIVATE void             ImplCallEventListeners( sal_uLong nEvent, sal_uInt16 nPos );
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 1f563b6..7c99003 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -1783,39 +1783,40 @@ static OUString getShortenedString( const OUString& i_rLong, vcl::Window* i_pWin
     return aNonMnem;
 }
 
-void Menu::ImplPaintMenuTitle( vcl::Window* pWin, const Rectangle& rRect ) const
+void Menu::ImplPaintMenuTitle(vcl::RenderContext& rRenderContext, const Rectangle& rRect ) const
 {
     // Save previous graphical settings, set new one
-    pWin->Push( PushFlags::FONT | PushFlags::FILLCOLOR );
-    Color aBg = pWin->GetSettings().GetStyleSettings().GetMenuBarColor();
-    pWin->SetBackground( Wallpaper( aBg ) );
-    pWin->SetFillColor( aBg );
-    vcl::Font aFont = pWin->GetFont();
+    rRenderContext.Push(PushFlags::FONT | PushFlags::FILLCOLOR);
+    Color aBackgroundColor = rRenderContext.GetSettings().GetStyleSettings().GetMenuBarColor();
+    rRenderContext.SetBackground(Wallpaper(aBackgroundColor));
+    rRenderContext.SetFillColor(aBackgroundColor);
+    vcl::Font aFont = rRenderContext.GetFont();
     aFont.SetWeight(WEIGHT_BOLD);
-    pWin->SetFont(aFont);
+    rRenderContext.SetFont(aFont);
 
     // Draw background rectangle
-    Rectangle aBgRect( rRect );
+    Rectangle aBgRect(rRect);
     int nOuterSpaceX = ImplGetSVData()->maNWFData.mnMenuFormatBorderX;
-    aBgRect.setX( aBgRect.getX() + SPACE_AROUND_TITLE);
-    aBgRect.setWidth( aBgRect.getWidth() - 2 * SPACE_AROUND_TITLE - 2 * nOuterSpaceX );
-    aBgRect.setY( aBgRect.getY() + SPACE_AROUND_TITLE );
-    aBgRect.setHeight( nTitleHeight - 2 * SPACE_AROUND_TITLE );
-    pWin->DrawRect( aBgRect );
+    aBgRect.setX(aBgRect.getX() + SPACE_AROUND_TITLE);
+    aBgRect.setWidth(aBgRect.getWidth() - 2 * SPACE_AROUND_TITLE - 2 * nOuterSpaceX);
+    aBgRect.setY(aBgRect.getY() + SPACE_AROUND_TITLE);
+    aBgRect.setHeight(nTitleHeight - 2 * SPACE_AROUND_TITLE);
+    rRenderContext.DrawRect(aBgRect);
 
     // Draw the text centered
-    Point aTextTopLeft( rRect.TopLeft() );
-    long textWidth = pWin->GetTextWidth(aTitleText);
-    aTextTopLeft.X() += ( aBgRect.getWidth() - textWidth ) / 2;
+    Point aTextTopLeft(rRect.TopLeft());
+    long textWidth = rRenderContext.GetTextWidth(aTitleText);
+    aTextTopLeft.X() += (aBgRect.getWidth() - textWidth) / 2;
     aTextTopLeft.Y() += SPACE_AROUND_TITLE;
-    pWin->DrawText( aTextTopLeft, aTitleText, 0, aTitleText.getLength() );
+    rRenderContext.DrawText(aTextTopLeft, aTitleText, 0, aTitleText.getLength());
 
     // Restore
-    pWin->SetBackground();
-    pWin->Pop();
+    rRenderContext.SetBackground();
+    rRenderContext.Pop();
 }
 
-void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuItemData* pThisItemOnly, bool bHighlighted, bool bLayout, bool bRollover ) const
+void Menu::ImplPaint(vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuItemData* pThisItemOnly,
+                     bool bHighlighted, bool bLayout, bool bRollover) const
 {
     // for symbols: nFontHeight x nFontHeight
     long nFontHeight = pWin->GetTextHeight();
@@ -1846,8 +1847,8 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI
         mpLayoutData->m_aVisibleItemBoundRects.clear();
 
     // Paint title
-    if ( !pThisItemOnly && !IsMenuBar() && nTitleHeight > 0 )
-        ImplPaintMenuTitle( pWin, Rectangle( aTopLeft, aOutSz ) );
+    if (!pThisItemOnly && !IsMenuBar() && nTitleHeight > 0)
+        ImplPaintMenuTitle(*pWin/*rRenderContext*/, Rectangle(aTopLeft, aOutSz));
 
     for ( size_t n = 0; n < nCount; n++ )
     {
diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx
index 942f184..9701547 100644
--- a/vcl/source/window/menubarwindow.cxx
+++ b/vcl/source/window/menubarwindow.cxx
@@ -563,23 +563,25 @@ static int ImplGetTopDockingAreaHeight( vcl::Window *pWindow )
     return 0;
 }
 
-static void ImplAddNWFSeparator( vcl::Window *pThis, const MenubarValue& rMenubarValue )
+static void ImplAddNWFSeparator( vcl::RenderContext& rRenderContext, const MenubarValue& rMenubarValue )
 {
     // add a separator if
     // - we have an adjacent docking area
     // - and if toolbars would draw them as well (mbDockingAreaSeparateTB must not be set, see dockingarea.cxx)
-    if( rMenubarValue.maTopDockingAreaHeight && !ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB && !ImplGetSVData()->maNWFData.mbDockingAreaAvoidTBFrames )
+    if (rMenubarValue.maTopDockingAreaHeight
+      && !ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB
+      && !ImplGetSVData()->maNWFData.mbDockingAreaAvoidTBFrames)
     {
         // note: the menubar only provides the upper (dark) half of it, the rest (bright part) is drawn by the docking area
 
-        pThis->SetLineColor( pThis->GetSettings().GetStyleSettings().GetSeparatorColor() );
+        rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetSeparatorColor());
         Point aPt;
-        Rectangle aRect( aPt, pThis->GetOutputSizePixel() );
-        pThis->DrawLine( aRect.BottomLeft(), aRect.BottomRight() );
+        Rectangle aRect(aPt, rRenderContext.GetOutputSizePixel());
+        rRenderContext.DrawLine(aRect.BottomLeft(), aRect.BottomRight());
     }
 }
 
-void MenuBarWindow::HighlightItem( sal_uInt16 nPos, bool bHighlight )
+void MenuBarWindow::HighlightItem(sal_uInt16 nPos, bool bHighlight)
 {
     if( ! pMenu )
         return;
@@ -620,7 +622,7 @@ void MenuBarWindow::HighlightItem( sal_uInt16 nPos, bool bHighlight )
                                     OUString() );
                         }
 
-                        ImplAddNWFSeparator( this, aControlValue );
+                        ImplAddNWFSeparator(*this, aControlValue); // FIXME
 
                         // draw selected item
                         ControlState nState = ControlState::ENABLED;
@@ -663,7 +665,7 @@ void MenuBarWindow::HighlightItem( sal_uInt16 nPos, bool bHighlight )
                             DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRect, ControlState::ENABLED, aMenubarValue, OUString() );
                         }
 
-                        ImplAddNWFSeparator( this, aMenubarValue );
+                        ImplAddNWFSeparator(*this, aMenubarValue); // FIXME
                     }
                     else
                         Erase( aRect );
@@ -870,52 +872,56 @@ bool MenuBarWindow::HandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu )
     return bDone;
 }
 
-void MenuBarWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
+void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
 {
-    if( ! pMenu )
+    if (!pMenu)
         return;
 
+    const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+
     // no VCL paint if native menus
-    if( pMenu->ImplGetSalMenu() && pMenu->ImplGetSalMenu()->VisibleMenuBar() )
+    if (pMenu->ImplGetSalMenu() && pMenu->ImplGetSalMenu()->VisibleMenuBar())
     {
         ImplGetFrame()->DrawMenuBar();
         return;
     }
 
-    if( IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL) )
+    if (rRenderContext.IsNativeControlSupported(CTRL_MENUBAR, PART_ENTIRE_CONTROL))
     {
         MenubarValue aMenubarValue;
-        aMenubarValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this );
+        aMenubarValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight(this);
 
-        if ( !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() )
-            Erase();
+        if (!rStyleSettings.GetPersonaHeader().IsEmpty())
+            rRenderContext.Erase();
         else
         {
             Point aPt;
             Rectangle aCtrlRegion( aPt, GetOutputSizePixel() );
 
-            DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRegion, ControlState::ENABLED, aMenubarValue, OUString() );
+            rRenderContext.DrawNativeControl(CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRegion,
+                                             ControlState::ENABLED, aMenubarValue, OUString());
         }
 
-        ImplAddNWFSeparator( this, aMenubarValue );
+        ImplAddNWFSeparator(rRenderContext, aMenubarValue);
     }
-    SetFillColor( GetSettings().GetStyleSettings().GetMenuColor() );
-    pMenu->ImplPaint( this, 0 );
-    if ( nHighlightedItem != ITEMPOS_INVALID )
-        HighlightItem( nHighlightedItem, true );
+    rRenderContext.SetFillColor(rStyleSettings.GetMenuColor());
+
+    pMenu->ImplPaint(this, 0);
+    if (nHighlightedItem != ITEMPOS_INVALID)
+        HighlightItem(nHighlightedItem, true );
 
     // in high contrast mode draw a separating line on the lower edge
-    if( ! IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL) &&
-        GetSettings().GetStyleSettings().GetHighContrastMode() )
+    if (!rRenderContext.IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL) &&
+        rStyleSettings.GetHighContrastMode())
     {
-        Push( PushFlags::LINECOLOR | PushFlags::MAPMODE );
-        SetLineColor( Color( COL_WHITE ) );
-        SetMapMode( MapMode( MAP_PIXEL ) );
+        rRenderContext.Push(PushFlags::LINECOLOR | PushFlags::MAPMODE);
+        rRenderContext.SetLineColor(Color(COL_WHITE));
+        rRenderContext.SetMapMode(MapMode(MAP_PIXEL));
         Size aSize = GetSizePixel();
-        DrawLine( Point( 0, aSize.Height()-1 ), Point( aSize.Width()-1, aSize.Height()-1 ) );
-        Pop();
+        rRenderContext.DrawLine(Point(0, aSize.Height() - 1),
+                                Point(aSize.Width() - 1, aSize.Height() - 1));
+        rRenderContext.Pop();
     }
-
 }
 
 void MenuBarWindow::Resize()
@@ -1069,11 +1075,11 @@ void MenuBarWindow::GetFocus()
     }
 }
 
-::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > MenuBarWindow::CreateAccessible()
+css::uno::Reference<css::accessibility::XAccessible> MenuBarWindow::CreateAccessible()
 {
-    ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAcc;
+    css::uno::Reference<css::accessibility::XAccessible> xAcc;
 
-    if ( pMenu )
+    if (pMenu)
         xAcc = pMenu->GetAccessible();
 
     return xAcc;
diff --git a/vcl/source/window/menubarwindow.hxx b/vcl/source/window/menubarwindow.hxx
index 5a6f2e9..2c664be 100644
--- a/vcl/source/window/menubarwindow.hxx
+++ b/vcl/source/window/menubarwindow.hxx
@@ -119,7 +119,7 @@ public:
     virtual void    MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     virtual void    MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     virtual void    KeyInput( const KeyEvent& rKEvent ) 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    Resize() SAL_OVERRIDE;
     virtual void    RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
 
diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx
index e4a9798..32acf47 100644
--- a/vcl/source/window/menufloatingwindow.cxx
+++ b/vcl/source/window/menufloatingwindow.cxx
@@ -1083,34 +1083,32 @@ void MenuFloatingWindow::KeyInput( const KeyEvent& rKEvent )
     }
 }
 
-void MenuFloatingWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
+void MenuFloatingWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
 {
-    if( ! pMenu )
+    if (!pMenu)
         return;
 
-    if( IsNativeControlSupported( CTRL_MENU_POPUP, PART_ENTIRE_CONTROL ) )
+    if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_ENTIRE_CONTROL))
     {
-        SetClipRegion();
+        rRenderContext.SetClipRegion();
         long nX = pMenu->pLogo ? pMenu->pLogo->aBitmap.GetSizePixel().Width() : 0;
-        Size aPxSize( GetOutputSizePixel() );
+        Size aPxSize(rRenderContext.GetOutputSizePixel());
         aPxSize.Width() -= nX;
-        ImplControlValue aVal( pMenu->nTextPos-GUTTERBORDER );
-        DrawNativeControl( CTRL_MENU_POPUP, PART_ENTIRE_CONTROL,
-                           Rectangle( Point( nX, 0 ), aPxSize ),
-                           ControlState::ENABLED,
-                           aVal,
-                           OUString() );
+        ImplControlValue aVal(pMenu->nTextPos - GUTTERBORDER);
+        rRenderContext.DrawNativeControl(CTRL_MENU_POPUP, PART_ENTIRE_CONTROL,
+                                         Rectangle(Point(nX, 0), aPxSize),
+                                         ControlState::ENABLED, aVal, OUString());
         InitMenuClipRegion();
     }
-    if ( IsScrollMenu() )
+    if (IsScrollMenu())
     {
         ImplDrawScroller( true );
         ImplDrawScroller( false );
     }
-    SetFillColor( GetSettings().GetStyleSettings().GetMenuColor() );
-    pMenu->ImplPaint( this, nScrollerHeight, ImplGetStartY() );
-    if ( nHighlightedItem != ITEMPOS_INVALID )
-        HighlightItem( nHighlightedItem, true );
+    rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuColor());
+    pMenu->ImplPaint(this, nScrollerHeight, ImplGetStartY());
+    if (nHighlightedItem != ITEMPOS_INVALID)
+        HighlightItem(nHighlightedItem, true);
 }
 
 void MenuFloatingWindow::ImplDrawScroller( bool bUp )
commit f6e2c4eb4a934dc36c5467cf2c7c8ecc05f2814a
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri May 15 17:03:15 2015 +0900

    cleanup Control::ImplInitSettings
    
    Change-Id: Ifb10da3006aa2b546945dec4ba76660c4b3f052f

diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx
index fb0020e..e74dc8f 100644
--- a/vcl/source/control/ctrl.cxx
+++ b/vcl/source/control/ctrl.cxx
@@ -422,22 +422,22 @@ void Control::ImplInitSettings( const bool _bFont, const bool _bForeground )
 {
     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
 
-    if ( _bFont )
+    if (_bFont)
     {
-        Font aFont( GetCanonicalFont( rStyleSettings ) );
-        if ( IsControlFont() )
-            aFont.Merge( GetControlFont() );
+        Font aFont(GetCanonicalFont(rStyleSettings));
+        if (IsControlFont())
+            aFont.Merge(GetControlFont());
         SetZoomedPointFont( aFont );
     }
 
-    if ( _bForeground || _bFont )
+    if (_bForeground || _bFont)
     {
         Color aColor;
-        if ( IsControlForeground() )
+        if (IsControlForeground())
             aColor = GetControlForeground();
         else
-            aColor = GetCanonicalTextColor( rStyleSettings );
-        SetTextColor( aColor );
+            aColor = GetCanonicalTextColor(rStyleSettings);
+        SetTextColor(aColor);
         SetTextFillColor();
     }
 }
commit 208616be2ca7cd17558db463e25e75b73d1bcc00
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri May 15 17:01:23 2015 +0900

    refactor BmpWindow (frmpage) to use RenderContext
    
    Change-Id: Ia2e946b272c587cbbdfdbc0935204c5854aa2a41

diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx
index faa0ff4..664e5c5 100644
--- a/sw/source/ui/frmdlg/frmpage.cxx
+++ b/sw/source/ui/frmdlg/frmpage.cxx
@@ -2663,24 +2663,25 @@ Size BmpWindow::GetOptimalSize() const
 
 VCL_BUILDER_FACTORY_ARGS(BmpWindow, 0)
 
-void BmpWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
+void BmpWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
 {
     Point aPntPos;
-    Size  aPntSz( GetSizePixel() );
-    Size  aGrfSize;
-    if(bGraphic)
-        aGrfSize = ::GetGraphicSizeTwip(aGraphic, this);
+    Size aPntSz(GetSizePixel());
+    Size aGrfSize;
+    if (bGraphic)
+        aGrfSize = ::GetGraphicSizeTwip(aGraphic, &rRenderContext);
     //it should show the default bitmap also if no graphic can be found
-    if(!aGrfSize.Width() && !aGrfSize.Height())
-        aGrfSize = PixelToLogic(aBmp.GetSizePixel());
+    if (!aGrfSize.Width() && !aGrfSize.Height())
+        aGrfSize = rRenderContext.PixelToLogic(aBmp.GetSizePixel());
 
     long nRelGrf = aGrfSize.Width() * 100L / aGrfSize.Height();
     long nRelWin = aPntSz.Width() * 100L / aPntSz.Height();
-    if(nRelGrf < nRelWin)
+    if (nRelGrf < nRelWin)
     {
         const long nWidth = aPntSz.Width();
         // if we use a replacement preview, try to draw at original size
-        if ( !bGraphic && ( aGrfSize.Width() <= aPntSz.Width() ) && ( aGrfSize.Height() <= aPntSz.Height() ) )
+        if (!bGraphic && (aGrfSize.Width() <= aPntSz.Width())
+                      && (aGrfSize.Height() <= aPntSz.Height()))
         {
             const long nHeight = aPntSz.Height();
             aPntSz.Width() = aGrfSize.Width();
@@ -2690,12 +2691,12 @@ void BmpWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle&
         else
             aPntSz.Width() = aPntSz.Height() * nRelGrf /100;
 
-        if(!bLeftAlign)
+        if (!bLeftAlign)
             aPntPos.X() += nWidth - aPntSz.Width() ;
     }
 
     // #i119307# clear window background, the graphic might have transparency
-    DrawRect(Rectangle(aPntPos, aPntSz));
+    rRenderContext.DrawRect(Rectangle(aPntPos, aPntSz));
 
     if (bHorz || bVert)
     {
@@ -2706,15 +2707,15 @@ void BmpWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle&
         if (bVert)
             nMirrorFlags |= BmpMirrorFlags::Horizontal;
         aTmpBmp.Mirror(nMirrorFlags);
-        DrawBitmapEx( aPntPos, aPntSz, aTmpBmp );
+        rRenderContext.DrawBitmapEx(aPntPos, aPntSz, aTmpBmp);
     }
     else if (bGraphic)  //draw unmirrored preview graphic
     {
-        aGraphic.Draw( this, aPntPos, aPntSz );
+        aGraphic.Draw(&rRenderContext, aPntPos, aPntSz);
     }
     else    //draw unmirrored stock sample image
     {
-        DrawBitmapEx( aPntPos, aPntSz, aBmp );
+        rRenderContext.DrawBitmapEx(aPntPos, aPntSz, aBmp);
     }
 }
 
@@ -2722,11 +2723,11 @@ BmpWindow::~BmpWindow()
 {
 }
 
-void BmpWindow::SetGraphic(const Graphic& rGrf)
+void BmpWindow::SetGraphic(const Graphic& rGraphic)
 {
-    aGraphic = rGrf;
-    Size aGrfSize = ::GetGraphicSizeTwip(aGraphic, this);
-    bGraphic = aGrfSize.Width() && aGrfSize.Height();
+    aGraphic = rGraphic;
+    Size aSize = aGraphic.GetPrefSize();
+    bGraphic = aSize.Width() && aSize.Height();
     Invalidate();
 }
 
commit 5a131306a746b111108daa88f7865a1fdf5c9c76
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri May 15 17:00:34 2015 +0900

    refactor NumberingPreview to use RenderContext
    
    Change-Id: Iacc9b85851ed3a8ad1bada5331dc850dc564ba5b

diff --git a/sw/source/ui/misc/outline.cxx b/sw/source/ui/misc/outline.cxx
index cf96bd7..b19993f 100644
--- a/sw/source/ui/misc/outline.cxx
+++ b/sw/source/ui/misc/outline.cxx
@@ -880,40 +880,36 @@ void SwOutlineSettingsTabPage::CheckForStartValue_Impl(sal_uInt16 nNumberingType
         m_pStartEdit->GetModifyHdl().Call(m_pStartEdit);
 }
 
-static long lcl_DrawBullet(vcl::RenderContext* pVDev,
-            const SwNumFmt& rFmt, long nXStart,
-            long nYStart, const Size& rSize)
+static long lcl_DrawBullet(vcl::RenderContext* pVDev, const SwNumFmt& rFmt, long nXStart, long nYStart, const Size& rSize)
 {
     vcl::Font aTmpFont(pVDev->GetFont());
 
     vcl::Font aFont(*rFmt.GetBulletFont());
     aFont.SetSize(rSize);
     aFont.SetTransparent(true);
-    pVDev->SetFont( aFont );
+    pVDev->SetFont(aFont);
     OUString aText(rFmt.GetBulletChar());
-    pVDev->DrawText( Point(nXStart, nYStart), aText );
+    pVDev->DrawText(Point(nXStart, nYStart), aText);
     const long nRet = pVDev->GetTextWidth(aText);
 
     pVDev->SetFont(aTmpFont);
     return nRet;
 }
 
-static long lcl_DrawGraphic(vcl::RenderContext* pVDev, const SwNumFmt &rFmt, long nXStart,
-                        long nYStart, long nDivision)
+static long lcl_DrawGraphic(vcl::RenderContext* pVDev, const SwNumFmt &rFmt, long nXStart, long nYStart, long nDivision)
 {
     const SvxBrushItem* pBrushItem = rFmt.GetBrush();
     long nRet = 0;
-    if(pBrushItem)
+    if (pBrushItem)
     {
-        const Graphic* pGrf = pBrushItem->GetGraphic();
-        if(pGrf)
+        const Graphic* pGraphic = pBrushItem->GetGraphic();
+        if (pGraphic)
         {
             Size aGSize( rFmt.GetGraphicSize());
             aGSize.Width() /= nDivision;
             nRet = aGSize.Width();
             aGSize.Height() /= nDivision;
-            pGrf->Draw( pVDev, Point(nXStart,nYStart),
-                    pVDev->PixelToLogic( aGSize ) );
+            pGraphic->Draw(pVDev, Point(nXStart, nYStart), pVDev->PixelToLogic(aGSize));
         }
     }
     return nRet;
@@ -922,20 +918,20 @@ static long lcl_DrawGraphic(vcl::RenderContext* pVDev, const SwNumFmt &rFmt, lon
 VCL_BUILDER_FACTORY(NumberingPreview)
 
 // paint numbering's preview
-void NumberingPreview::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& /*rRect*/ )
+void NumberingPreview::Paint(vcl::RenderContext& rRenderContext, const Rectangle& /*rRect*/)
 {
-    const Size aSize(PixelToLogic(GetOutputSizePixel()));
+    const Size aSize(rRenderContext.PixelToLogic(rRenderContext.GetOutputSizePixel()));
 
-    ScopedVclPtrInstance< VirtualDevice > pVDev(*this);
-    pVDev->SetMapMode(GetMapMode());
-    pVDev->SetOutputSize( aSize );
+    ScopedVclPtrInstance<VirtualDevice> pVDev(rRenderContext);
+    pVDev->SetMapMode(rRenderContext.GetMapMode());
+    pVDev->SetOutputSize(aSize);
 
     // #101524# OJ
-    pVDev->SetFillColor( GetSettings().GetStyleSettings().GetWindowColor() );
-    pVDev->SetLineColor( GetSettings().GetStyleSettings().GetButtonTextColor() );
+    pVDev->SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetWindowColor());
+    pVDev->SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetButtonTextColor());
     pVDev->DrawRect(Rectangle(Point(0,0), aSize));
 
-    if(pActNum)
+    if (pActNum)
     {
         long nWidthRelation = 30; // chapter dialog
         if(nPageWidth)
@@ -951,22 +947,21 @@ void NumberingPreview::Paint( vcl::RenderContext& /*rRenderContext*/, const Rect
         const long nXStep = aSize.Width() / (3 * MAXLEVEL * ((MAXLEVEL < 10) ? 2 : 1));
         const long nYStep = (aSize.Height() - 6)/ MAXLEVEL;
         long nYStart = 4;
-        aStdFont = OutputDevice::GetDefaultFont(
-                                    DefaultFontType::UI_SANS, GetAppLanguage(),
-                                    DEFAULTFONT_FLAGS_ONLYONE, this );
+        aStdFont = OutputDevice::GetDefaultFont(DefaultFontType::UI_SANS, GetAppLanguage(),
+                                                DEFAULTFONT_FLAGS_ONLYONE, &rRenderContext);
         // #101524# OJ
-        aStdFont.SetColor( SwViewOption::GetFontColor() );
+        aStdFont.SetColor(SwViewOption::GetFontColor());
 
         const long nFontHeight = nYStep * ( bPosition ? 15 : 6 ) / 10;
         aStdFont.SetSize(Size( 0, nFontHeight ));
 
         long nPreNum = pActNum->Get(0).GetStart();
 
-        if(bPosition)
+        if (bPosition)
         {
             const long nLineHeight = nFontHeight * 8 / 7;
             sal_uInt8 nStart = 0;
-            while( !(nActLevel & (1<<nStart)) )
+            while (!(nActLevel & (1 << nStart)))
             {
                 nStart++;
             }
@@ -974,8 +969,8 @@ void NumberingPreview::Paint( vcl::RenderContext& /*rRenderContext*/, const Rect
                 nStart--;
 
             SwNumberTree::tNumberVector aNumVector;
-            sal_uInt8 nEnd = std::min( (sal_uInt8)(nStart + 3), MAXLEVEL );
-            for( sal_uInt8 nLevel = nStart; nLevel < nEnd; ++nLevel )
+            sal_uInt8 nEnd = std::min(sal_uInt8(nStart + 3), MAXLEVEL);
+            for (sal_uInt8 nLevel = nStart; nLevel < nEnd; ++nLevel)
             {
                 const SwNumFmt &rFmt = pActNum->Get(nLevel);
                 aNumVector.push_back(rFmt.GetStart());
@@ -983,7 +978,7 @@ void NumberingPreview::Paint( vcl::RenderContext& /*rRenderContext*/, const Rect
                 long nXStart( 0 );
                 long nTextOffset( 0 );
                 long nNumberXPos( 0 );
-                if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
+                if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION)
                 {
                     nXStart = rFmt.GetAbsLSpace() / nWidthRelation;
                     nTextOffset = rFmt.GetCharTextDistance() / nWidthRelation;
@@ -995,21 +990,19 @@ void NumberingPreview::Paint( vcl::RenderContext& /*rRenderContext*/, const Rect
                     else
                         nNumberXPos = 0;
                 }
-                else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
+                else if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT)
                 {
-                    const long nTmpNumberXPos( ( rFmt.GetIndentAt() +
-                                                 rFmt.GetFirstLineIndent() ) /
-                                               nWidthRelation );
-                    nNumberXPos = ( nTmpNumberXPos < 0 ) ? 0 : nTmpNumberXPos;
+                    const long nTmpNumberXPos((rFmt.GetIndentAt() + rFmt.GetFirstLineIndent()) / nWidthRelation);
+                    nNumberXPos = (nTmpNumberXPos < 0) ? 0 : nTmpNumberXPos;
                 }
 
                 long nBulletWidth = 0;
-                if( SVX_NUM_BITMAP == rFmt.GetNumberingType() )
+                if (SVX_NUM_BITMAP == rFmt.GetNumberingType())
                 {
                     nBulletWidth = lcl_DrawGraphic(pVDev.get(), rFmt, nNumberXPos,
                                                    nYStart, nWidthRelation);
                 }
-                else if( SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType() )
+                else if (SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType())
                 {
                     nBulletWidth = lcl_DrawBullet(pVDev.get(), rFmt, nNumberXPos,
                                                   nYStart, aStdFont.GetSize());
@@ -1034,23 +1027,23 @@ void NumberingPreview::Paint( vcl::RenderContext& /*rRenderContext*/, const Rect
                     nBulletWidth += pVDev->GetTextWidth(aText);
                 }
 
-                long nTextXPos( 0 );
-                if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
+                long nTextXPos(0);
+                if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION)
                 {
                     nTextXPos = nXStart;
-                    if(nTextOffset < 0)
+                    if (nTextOffset < 0)
                          nTextXPos = nTextXPos + nTextOffset;
-                    if(nNumberXPos + nBulletWidth + nTextOffset > nTextXPos )
+                    if (nNumberXPos + nBulletWidth + nTextOffset > nTextXPos)
                         nTextXPos = nNumberXPos + nBulletWidth + nTextOffset;
                 }
-                else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
+                else if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT)
                 {
-                    switch ( rFmt.GetLabelFollowedBy() )
+                    switch (rFmt.GetLabelFollowedBy())
                     {
                         case SvxNumberFormat::LISTTAB:
                         {
                             nTextXPos = rFmt.GetListtabPos() / nWidthRelation;
-                            if ( nTextXPos < nNumberXPos + nBulletWidth )
+                            if (nTextXPos < nNumberXPos + nBulletWidth)
                             {
                                 nTextXPos = nNumberXPos + nBulletWidth;
                             }
@@ -1068,11 +1061,11 @@ void NumberingPreview::Paint( vcl::RenderContext& /*rRenderContext*/, const Rect
                 }
 
                 Rectangle aRect1(Point(nTextXPos, nYStart + nFontHeight / 2), Size(aSize.Width() / 2, 2));
-                pVDev->SetFillColor( GetSettings().GetStyleSettings().GetWindowColor() ); // Color( COL_BLACK ) );
-                pVDev->DrawRect( aRect1 );
+                pVDev->SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetWindowColor()); // Color( COL_BLACK ) );
+                pVDev->DrawRect(aRect1);
 
-                Rectangle aRect2(Point(nXStart, nYStart + nLineHeight + nFontHeight / 2 ), Size(aSize.Width() / 2, 2));
-                pVDev->DrawRect( aRect2 );
+                Rectangle aRect2(Point(nXStart, nYStart + nLineHeight + nFontHeight / 2), Size(aSize.Width() / 2, 2));
+                pVDev->DrawRect(aRect2);
                 nYStart += 2 * nLineHeight;
             }
         }
@@ -1080,32 +1073,29 @@ void NumberingPreview::Paint( vcl::RenderContext& /*rRenderContext*/, const Rect
         {
             SwNumberTree::tNumberVector aNumVector;
             const long nLineHeight = nFontHeight * 3 / 2;
-            for( sal_uInt8 nLevel = 0; nLevel < MAXLEVEL;
-                            ++nLevel, nYStart = nYStart + nYStep )
+            for (sal_uInt8 nLevel = 0; nLevel < MAXLEVEL; ++nLevel, nYStart = nYStart + nYStep)
             {
                 const SwNumFmt &rFmt = pActNum->Get(nLevel);
                 aNumVector.push_back(rFmt.GetStart());
-                long nXStart( 0 );
-                if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
+                long nXStart(0);
+                if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION)
                 {
                     nXStart = rFmt.GetAbsLSpace() / nWidthRelation;
                 }
-                else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
+                else if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT)
                 {
-                    const long nTmpXStart( ( rFmt.GetIndentAt() +
-                                             rFmt.GetFirstLineIndent() ) /
-                                           nWidthRelation );
-                    nXStart = ( nTmpXStart < 0 ) ? 0 : nTmpXStart;
+                    const long nTmpXStart((rFmt.GetIndentAt() + rFmt.GetFirstLineIndent() ) / nWidthRelation);
+                    nXStart = (nTmpXStart < 0) ? 0 : nTmpXStart;
                 }
                 nXStart /= 2;
                 nXStart += 2;
                 long nTextOffset;
-                if( SVX_NUM_BITMAP == rFmt.GetNumberingType() )
+                if (SVX_NUM_BITMAP == rFmt.GetNumberingType())
                 {
                     lcl_DrawGraphic(pVDev.get(), rFmt, nXStart, nYStart, nWidthRelation);
                     nTextOffset = nLineHeight + nXStep;
                 }
-                else if( SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType() )
+                else if (SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType())
                 {
                     nTextOffset =  lcl_DrawBullet(pVDev.get(), rFmt, nXStart, nYStart, aStdFont.GetSize());
                     nTextOffset += nXStep;
@@ -1113,7 +1103,7 @@ void NumberingPreview::Paint( vcl::RenderContext& /*rRenderContext*/, const Rect
                 else
                 {
                     pVDev->SetFont(aStdFont);
-                    if(pActNum->IsContinusNum())
+                    if (pActNum->IsContinusNum())
                         aNumVector[nLevel] = nPreNum;
                     // #128041#
                     OUString aText(pActNum->MakeNumString( aNumVector ));
@@ -1130,9 +1120,7 @@ void NumberingPreview::Paint( vcl::RenderContext& /*rRenderContext*/, const Rect
             }
         }
     }
-    DrawOutDev( Point(0,0), aSize,
-                Point(0,0), aSize,
-                        *pVDev );
+    rRenderContext.DrawOutDev(Point(0,0), aSize, Point(0,0), aSize, *pVDev);
 }
 
 NumberingPreview::~NumberingPreview()
commit 3bc76133106325e211b7e02c996dd6d040ca7354
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri May 15 16:59:33 2015 +0900

    cleanup MyWin
    
    Change-Id: I6b9606c6d1397cfe919a7a6c1922423fb8b68d5c

diff --git a/svx/workben/pixelctl.cxx b/svx/workben/pixelctl.cxx
index 0ce3dca..127b1be 100644
--- a/svx/workben/pixelctl.cxx
+++ b/svx/workben/pixelctl.cxx
@@ -82,18 +82,20 @@ class MyWin : public WorkWindow
     VclPtr<SvxPixelCtl> maPixelCtl;
 
 public:
-                MyWin( vcl::Window* pParent, WinBits nWinStyle );
-    virtual      ~MyWin() { disposeOnce(); }
+    MyWin(vcl::Window* pParent, WinBits nWinStyle);
+    virtual ~MyWin()
+    {
+        disposeOnce();
+    }
     virtual void dispose() SAL_OVERRIDE;
-    void        MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
-    void        MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
-    void        MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
-    void        KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
-    void        KeyUp( const KeyEvent& rKEvt ) SAL_OVERRIDE;
-    void        Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect ) SAL_OVERRIDE;
-    void        Resize() SAL_OVERRIDE;
-
-    bool        Close() SAL_OVERRIDE;
+    void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
+    void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
+    void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
+    void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
+    void KeyUp( const KeyEvent& rKEvt ) SAL_OVERRIDE;
+    void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
+    void Resize() SAL_OVERRIDE;
+    bool Close() SAL_OVERRIDE;
 };
 
 void Main()
commit adce48ab274285e9a8eb546b233db1c1e5a39537
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri May 15 16:59:11 2015 +0900

    cleanup GetGraphicSizeTwip
    
    Change-Id: I5f3c3c7826c867eaca8af0e2aa35c9919d8b1319

diff --git a/sw/source/core/bastyp/swtypes.cxx b/sw/source/core/bastyp/swtypes.cxx
index 35daca4..d22cc8d 100644
--- a/sw/source/core/bastyp/swtypes.cxx
+++ b/sw/source/core/bastyp/swtypes.cxx
@@ -78,21 +78,19 @@ IMPL_FIXEDMEMPOOL_NEWDEL( SwTableLineFmt )
 IMPL_FIXEDMEMPOOL_NEWDEL( SwTableBoxFmt )
 IMPL_FIXEDMEMPOOL_NEWDEL( _SwCursor_SavePos )
 
-Size GetGraphicSizeTwip( const Graphic& rGraphic, vcl::RenderContext* pOutDev )
+Size GetGraphicSizeTwip(const Graphic& rGraphic, vcl::RenderContext* pOutDev)
 {
-    const MapMode aMapTwip( MAP_TWIP );
-    Size aSize( rGraphic.GetPrefSize() );
-    if( MAP_PIXEL == rGraphic.GetPrefMapMode().GetMapUnit() )
+    const MapMode aMapTwip(MAP_TWIP);
+    Size aSize(rGraphic.GetPrefSize());
+    if (MAP_PIXEL == rGraphic.GetPrefMapMode().GetMapUnit())
     {
-        if( !pOutDev )
+        if (!pOutDev)
             pOutDev = Application::GetDefaultDevice();
-        aSize = pOutDev->PixelToLogic( aSize, aMapTwip );
+        aSize = pOutDev->PixelToLogic(aSize, aMapTwip);
     }
     else
     {
-        aSize = OutputDevice::LogicToLogic( aSize,
-                                            rGraphic.GetPrefMapMode(),
-                                            aMapTwip );
+        aSize = OutputDevice::LogicToLogic(aSize, rGraphic.GetPrefMapMode(), aMapTwip);
     }
     return aSize;
 }
commit fbd06b24c5cd4a560669e311a10ea37fc3834eac
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri May 15 16:58:32 2015 +0900

    refactor SwDropCapsPict to use RenderContext
    
    Change-Id: I6a68d22f9b7ded9d58a69057bf0f4197a67fd2e8

diff --git a/sw/source/ui/chrdlg/drpcps.cxx b/sw/source/ui/chrdlg/drpcps.cxx
index 825c7e2..cab734c 100644
--- a/sw/source/ui/chrdlg/drpcps.cxx
+++ b/sw/source/ui/chrdlg/drpcps.cxx
@@ -130,7 +130,7 @@ public:
     void SetDistance( sal_uInt16 nD );
     void SetValues( const OUString& rText, sal_uInt8 nLines, sal_uInt16 nDistance );
 
-    void        DrawPrev( const Point& rPt );
+    void DrawPrev(vcl::RenderContext& rRenderContext, const Point& rPt);
 };
 
 VCL_BUILDER_FACTORY_ARGS(SwDropCapsPict, WB_BORDER)
@@ -343,71 +343,77 @@ void SwDropCapsPict::UpdatePaintSettings()
     Invalidate();
 }
 
-void  SwDropCapsPict::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangle &/*rRect*/)
+void  SwDropCapsPict::Paint(vcl::RenderContext& rRenderContext, const Rectangle &/*rRect*/)
 {
     if (!IsVisible())
         return;
 
-    SetMapMode(MapMode(MAP_PIXEL));
-    SetLineColor();
+    rRenderContext.SetMapMode(MapMode(MAP_PIXEL));
+    rRenderContext.SetLineColor();
 
-    SetFillColor( maBackColor );
+    rRenderContext.SetFillColor(maBackColor);
 
-    Size aOutputSizePixel( GetOutputSizePixel() );
+    Size aOutputSizePixel(rRenderContext.GetOutputSizePixel());
 
     DrawRect(Rectangle(Point(0, 0), aOutputSizePixel ));
-    SetClipRegion(vcl::Region(Rectangle(
-        Point(BORDER, BORDER),
-        Size (aOutputSizePixel.Width () - 2 * BORDER,
-              aOutputSizePixel.Height() - 2 * BORDER))));
+    rRenderContext.SetClipRegion(vcl::Region(Rectangle(Point(BORDER, BORDER),
+                                                       Size (aOutputSizePixel.Width () - 2 * BORDER,
+                                                             aOutputSizePixel.Height() - 2 * BORDER))));
 
     OSL_ENSURE(mnLineH > 0, "We cannot make it that small");
     long nY0 = (aOutputSizePixel.Height() - (LINES * mnTotLineH)) / 2;
-    SetFillColor( maTextLineColor );
+
+    rRenderContext.SetFillColor(maTextLineColor);
+
     for (int i = 0; i < LINES; ++i)
-        DrawRect(Rectangle(Point(BORDER, nY0 + i * mnTotLineH), Size(aOutputSizePixel.Width() - 2 * BORDER, mnLineH)));
+    {
+        rRenderContext.DrawRect(Rectangle(Point(BORDER, nY0 + i * mnTotLineH),
+                                Size(aOutputSizePixel.Width() - 2 * BORDER, mnLineH)));
+    }
 
     // Text background with gap (240 twips ~ 1 line height)
     const long nDistW = (((static_cast<long>(mnDistance) * 100) / 240) * mnTotLineH) / 100;
-    SetFillColor( maBackColor );
+    rRenderContext.SetFillColor(maBackColor);
     if (mpPage && mpPage->m_pDropCapsBox->IsChecked())
     {
-        const Size aTextSize( maTextSize.Width()+nDistW, maTextSize.Height() );
-        DrawRect( Rectangle( Point( BORDER, nY0 ), aTextSize ) );
+        const Size aTextSize(maTextSize.Width() + nDistW, maTextSize.Height());
+        rRenderContext.DrawRect(Rectangle(Point(BORDER, nY0), aTextSize));
 
         // draw Text
-        DrawPrev( Point( BORDER, nY0 ) );
+        DrawPrev(rRenderContext, Point(BORDER, nY0));
     }
-
-    SetClipRegion();
+    rRenderContext.SetClipRegion();
 }
 
-void SwDropCapsPict::DrawPrev( const Point& rPt )
+void SwDropCapsPict::DrawPrev(vcl::RenderContext& rRenderContext, const Point& rPt)
 {
     Point aPt(rPt);
     InitPrinter();
 
-    vcl::Font   aOldFont = mpPrinter->GetFont();
-    sal_uInt16      nScript;
-    size_t      nIdx = 0;
-    sal_Int32  nStart;
-    sal_Int32  nEnd;
+    vcl::Font aOldFont = mpPrinter->GetFont();
+    sal_uInt16 nScript;
+    size_t nIdx = 0;
+    sal_Int32 nStart;
+    sal_Int32 nEnd;
+
     GetFirstScriptSegment(nStart, nEnd, nScript);
+
     do
     {
-        SvxFont&    rFnt = (nScript==css::i18n::ScriptType::ASIAN) ? maCJKFont : ((nScript==css::i18n::ScriptType::COMPLEX) ? maCTLFont : maFont);
-        mpPrinter->SetFont( rFnt );
+        SvxFont& rFnt = (nScript==css::i18n::ScriptType::ASIAN) ? maCJKFont : ((nScript==css::i18n::ScriptType::COMPLEX) ? maCTLFont : maFont);
+        mpPrinter->SetFont(rFnt);
 
-        rFnt.DrawPrev( this, mpPrinter, aPt, maText, nStart, nEnd - nStart );
+        rFnt.DrawPrev(&rRenderContext, mpPrinter, aPt, maText, nStart, nEnd - nStart);
 
         if (!maScriptChanges.empty())
-            aPt.X() += maScriptChanges[ nIdx ].textWidth;
+            aPt.X() += maScriptChanges[nIdx].textWidth;
 
-        if ( !GetNextScriptSegment(nIdx, nStart, nEnd, nScript) )
+        if (!GetNextScriptSegment(nIdx, nStart, nEnd, nScript))
             break;
     }
-    while( true );
-    mpPrinter->SetFont( aOldFont );
+    while(true);
+
+    mpPrinter->SetFont(aOldFont);
 }
 
 void SwDropCapsPict::CheckScript()
commit 961b141d6b224d723a0193510975b6f1478e1be5
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri May 15 16:57:36 2015 +0900

    refactor SwEnvPreview to use RenderContext
    
    Change-Id: Iebbcd09dcca109539ef32d44816b621b90624fb8

diff --git a/sw/source/ui/envelp/envlop1.cxx b/sw/source/ui/envelp/envlop1.cxx
index b552d03..9592b96 100644
--- a/sw/source/ui/envelp/envlop1.cxx
+++ b/sw/source/ui/envelp/envlop1.cxx
@@ -66,36 +66,35 @@ void SwEnvPreview::DataChanged( const DataChangedEvent& rDCEvt )
         SetBackground( GetSettings().GetStyleSettings().GetDialogColor() );
 }
 
-void SwEnvPreview::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangle &)
+void SwEnvPreview::Paint(vcl::RenderContext& rRenderContext, const Rectangle &)
 {
-    const StyleSettings& rSettings = GetSettings().GetStyleSettings();
+    const StyleSettings& rSettings = rRenderContext.GetSettings().GetStyleSettings();
 
     const SwEnvItem& rItem =
-        static_cast<SwEnvDlg*>( GetParentDialog())->aEnvItem;
+        static_cast<SwEnvDlg*>(GetParentDialog())->aEnvItem;
 
     const long nPageW = std::max(rItem.lWidth, rItem.lHeight);
     const long nPageH = std::min(rItem.lWidth, rItem.lHeight);
 
     const float f = 0.8 * std::min(
-        static_cast<float>(GetOutputSizePixel().Width())/static_cast<float>(nPageW),
-        static_cast<float>(GetOutputSizePixel().Height())/static_cast<float>(nPageH));
+        float(rRenderContext.GetOutputSizePixel().Width()) / float(nPageW),
+        float(rRenderContext.GetOutputSizePixel().Height()) / float(nPageH));
 
     Color aBack = rSettings.GetWindowColor( );
     Color aFront = SwViewOption::GetFontColor();
-    Color aMedium = Color(  ( aBack.GetRed() + aFront.GetRed() ) / 2,
-                            ( aBack.GetGreen() + aFront.GetGreen() ) / 2,
-                            ( aBack.GetBlue() + aFront.GetBlue() ) / 2
-                        );
+    Color aMedium = Color((aBack.GetRed() + aFront.GetRed()) / 2,
+                          (aBack.GetGreen() + aFront.GetGreen()) / 2,
+                          (aBack.GetBlue() + aFront.GetBlue()) / 2);
 
-    SetLineColor( aFront );
+    rRenderContext.SetLineColor(aFront);
 
     // Envelope
     const long nW = static_cast<long>(f * nPageW);
     const long nH = static_cast<long>(f * nPageH);
-    const long nX = (GetOutputSizePixel().Width () - nW) / 2;
-    const long nY = (GetOutputSizePixel().Height() - nH) / 2;
-    SetFillColor( aBack );
-    DrawRect(Rectangle(Point(nX, nY), Size(nW, nH)));
+    const long nX = (rRenderContext.GetOutputSizePixel().Width () - nW) / 2;
+    const long nY = (rRenderContext.GetOutputSizePixel().Height() - nH) / 2;
+    rRenderContext.SetFillColor(aBack);
+    rRenderContext.DrawRect(Rectangle(Point(nX, nY), Size(nW, nH)));
 
     // Sender
     if (rItem.bSend)
@@ -104,9 +103,9 @@ void SwEnvPreview::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangle
         const long nSendY = nY + static_cast<long>(f * rItem.lSendFromTop );
         const long nSendW = static_cast<long>(f * (rItem.lAddrFromLeft - rItem.lSendFromLeft));
         const long nSendH = static_cast<long>(f * (rItem.lAddrFromTop  - rItem.lSendFromTop  - 566));
-        SetFillColor( aMedium );
+        rRenderContext.SetFillColor(aMedium);
 
-        DrawRect(Rectangle(Point(nSendX, nSendY), Size(nSendW, nSendH)));
+        rRenderContext.DrawRect(Rectangle(Point(nSendX, nSendY), Size(nSendW, nSendH)));
     }
 
     // Addressee
@@ -114,8 +113,8 @@ void SwEnvPreview::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangle
     const long nAddrY = nY + static_cast<long>(f * rItem.lAddrFromTop );
     const long nAddrW = static_cast<long>(f * (nPageW - rItem.lAddrFromLeft - 566));
     const long nAddrH = static_cast<long>(f * (nPageH - rItem.lAddrFromTop  - 566));
-    SetFillColor( aMedium );
-    DrawRect(Rectangle(Point(nAddrX, nAddrY), Size(nAddrW, nAddrH)));
+    rRenderContext.SetFillColor(aMedium);
+    rRenderContext.DrawRect(Rectangle(Point(nAddrX, nAddrY), Size(nAddrW, nAddrH)));
 
     // Stamp
     const long nStmpW = static_cast<long>(f * 1417 /* 2,5 cm */);
@@ -123,8 +122,8 @@ void SwEnvPreview::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangle
     const long nStmpX = nX + nW - static_cast<long>(f * 566) - nStmpW;
     const long nStmpY = nY + static_cast<long>(f * 566);
 
-    SetFillColor( aBack );
-    DrawRect(Rectangle(Point(nStmpX, nStmpY), Size(nStmpW, nStmpH)));
+    rRenderContext.SetFillColor(aBack);
+    rRenderContext.DrawRect(Rectangle(Point(nStmpX, nStmpY), Size(nStmpW, nStmpH)));
 }
 
 SwEnvDlg::SwEnvDlg(vcl::Window* pParent, const SfxItemSet& rSet,
commit 2c777ccca35f33cf19951578b0f4afb3cb7ed98a
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri May 15 16:57:04 2015 +0900

    refactor SwLabPreview to use RenderContext
    
    Change-Id: I3cf9be2e84904f88ab820d97ee56c39e990c8737

diff --git a/sw/source/ui/envelp/labfmt.cxx b/sw/source/ui/envelp/labfmt.cxx
index 6801e24..d578bf3 100644
--- a/sw/source/ui/envelp/labfmt.cxx
+++ b/sw/source/ui/envelp/labfmt.cxx
@@ -87,45 +87,48 @@ Size SwLabPreview::GetOptimalSize() const
 
 VCL_BUILDER_FACTORY(SwLabPreview)
 
-void SwLabPreview::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangle &)
+void SwLabPreview::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
 {
-    const Size aSz(GetOutputSizePixel());
+    const Size aSz(rRenderContext.GetOutputSizePixel());
 
-    const long lOutWPix   = aSz.Width ();
-    const long lOutHPix   = aSz.Height();
+    const long lOutWPix = aSz.Width ();
+    const long lOutHPix = aSz.Height();
 
     // Scale factor
-    const float fxpix = (float)(lOutWPix - (2 * (lLeftWidth + 15))) / (float)lOutWPix;
+    const double fxpix = double(lOutWPix - (2 * (lLeftWidth + 15))) / double(lOutWPix);
 
-    const long lOutWPix23 = (long)((float)lOutWPix * fxpix);
-    const long lOutHPix23 = (long)((float)lOutHPix * fxpix);
+    const long lOutWPix23 = long(double(lOutWPix) * fxpix);
+    const long lOutHPix23 = long(double(lOutHPix) * fxpix);
 
-    const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+    const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
     const Color& rWinColor = rStyleSettings.GetWindowColor();
     const Color& rFieldTextColor = SwViewOption::GetFontColor();
 
-    vcl::Font aFont = GetFont();
-    aFont.SetFillColor( rWinColor );
+    vcl::Font aFont = rRenderContext.GetFont();
+    aFont.SetFillColor(rWinColor);
     aFont.SetColor(rFieldTextColor);
-    SetFont(aFont);
+    rRenderContext.SetFont(aFont);
 
-    SetBackground(Wallpaper(rWinColor));
+    rRenderContext.SetBackground(Wallpaper(rWinColor));
 
-    SetLineColor(rWinColor);
-    SetFillColor(aGrayColor);
-    vcl::Font aPaintFont(GetFont());
+    rRenderContext.SetLineColor(rWinColor);
+    rRenderContext.SetFillColor(aGrayColor);
+    vcl::Font aPaintFont(rRenderContext.GetFont());
     aPaintFont.SetTransparent(false);
-    SetFont(aPaintFont);
+    rRenderContext.SetFont(aPaintFont);
 
     // size of region to be displayed
-    const long lDispW = aItem.lLeft + aItem.lHDist
-        + ((aItem.nCols == 1) ? aItem.lLeft : ROUND(aItem.lHDist/10.0));
-    const long lDispH = aItem.lUpper + aItem.lVDist
-        + ((aItem.nRows == 1) ? aItem.lUpper : ROUND(aItem.lVDist/10.0));
+    const long lDispW = aItem.lLeft + aItem.lHDist + ((aItem.nCols == 1)
+                            ? aItem.lLeft
+                            : ROUND(aItem.lHDist / 10.0));
+
+    const long lDispH = aItem.lUpper + aItem.lVDist + ((aItem.nRows == 1)
+                            ? aItem.lUpper
+                            : ROUND(aItem.lVDist / 10.0));
 
     // Scale factor
-    const float fx = (float) lOutWPix23 / std::max(1L, lDispW);
-    const float fy = (float) lOutHPix23 / std::max(1L, lDispH);
+    const float fx = float(lOutWPix23) / std::max(1L, lDispW);
+    const float fy = float(lOutHPix23) / std::max(1L, lDispH);
     const float f  = fx < fy ? fx : fy;
 
     // zero point
@@ -142,45 +145,44 @@ void SwLabPreview::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangle
     const long lY3 = lY0 + ROUND(f * (aItem.lUpper + aItem.lVDist ));
 
     // draw outline (area)
-    DrawRect(Rectangle(Point(lX0, lY0), Size(lOutlineW, lOutlineH)));
+    rRenderContext.DrawRect(Rectangle(Point(lX0, lY0), Size(lOutlineW, lOutlineH)));
 
     // draw outline (border)
-    SetLineColor(rFieldTextColor);
-    DrawLine(Point(lX0, lY0), Point(lX0 + lOutlineW - 1, lY0)); // Up
-    DrawLine(Point(lX0, lY0), Point(lX0, lY0 + lOutlineH - 1)); // Left
+    rRenderContext.SetLineColor(rFieldTextColor);
+    rRenderContext.DrawLine(Point(lX0, lY0), Point(lX0 + lOutlineW - 1, lY0)); // Up
+    rRenderContext.DrawLine(Point(lX0, lY0), Point(lX0, lY0 + lOutlineH - 1)); // Left
     if (aItem.nCols == 1)
-        DrawLine(Point(lX0 + lOutlineW - 1, lY0), Point(lX0 + lOutlineW - 1, lY0 + lOutlineH - 1)); // Right
+        rRenderContext.DrawLine(Point(lX0 + lOutlineW - 1, lY0), Point(lX0 + lOutlineW - 1, lY0 + lOutlineH - 1)); // Right
     if (aItem.nRows == 1)
-        DrawLine(Point(lX0, lY0 + lOutlineH - 1), Point(lX0 + lOutlineW - 1, lY0 + lOutlineH - 1)); // Down
+        rRenderContext.DrawLine(Point(lX0, lY0 + lOutlineH - 1), Point(lX0 + lOutlineW - 1, lY0 + lOutlineH - 1)); // Down
 
     // Labels
-    SetClipRegion(vcl::Region(Rectangle(Point(lX0, lY0), Size(lOutlineW, lOutlineH))));
-    SetFillColor( COL_LIGHTGRAYBLUE );
+    rRenderContext.SetClipRegion(vcl::Region(Rectangle(Point(lX0, lY0), Size(lOutlineW, lOutlineH))));
+    rRenderContext.SetFillColor(COL_LIGHTGRAYBLUE);
     const sal_Int32 nRows = std::min<sal_Int32>(2, aItem.nRows);
     const sal_Int32 nCols = std::min<sal_Int32>(2, aItem.nCols);
     for (sal_Int32 nRow = 0; nRow < nRows; ++nRow)
         for (sal_Int32 nCol = 0; nCol < nCols; ++nCol)
-            DrawRect(Rectangle(
-              Point(lX0 + ROUND(f * (aItem.lLeft  + nCol * aItem.lHDist)),
-                    lY0 + ROUND(f * (aItem.lUpper + nRow * aItem.lVDist))),
-              Size (ROUND(f * aItem.lWidth ),
-                    ROUND(f * aItem.lHeight))));
-    SetClipRegion();
+            rRenderContext.DrawRect(Rectangle(Point(lX0 + ROUND(f * (aItem.lLeft  + nCol * aItem.lHDist)),
+                                                    lY0 + ROUND(f * (aItem.lUpper + nRow * aItem.lVDist))),
+                                              Size(ROUND(f * aItem.lWidth),
+                                                   ROUND(f * aItem.lHeight))));
+    rRenderContext.SetClipRegion();
 
     // annotation: left border
     if (aItem.lLeft)
     {
         long lX = (lX0 + lX1) / 2;
-        DrawArrow(Point(lX0, lY0 - 5), Point(lX1, lY0 - 5), false);
-        DrawArrow(Point(lX, lY0 - 10), Point(lX, lY0 - 5), true);
-        DrawText(Point(lX1 - lLeftWidth, lY0 - 10 - lXHeight), aLeftStr);
+        DrawArrow(rRenderContext, Point(lX0, lY0 - 5), Point(lX1, lY0 - 5), false);
+        DrawArrow(rRenderContext, Point(lX, lY0 - 10), Point(lX, lY0 - 5), true);
+        rRenderContext.DrawText(Point(lX1 - lLeftWidth, lY0 - 10 - lXHeight), aLeftStr);
     }
 
     // annotation: upper border
     if (aItem.lUpper)
     {
-        DrawArrow(Point(lX0 - 5, lY0), Point(lX0 - 5, lY1), false);
-        DrawText(Point(lX0 - 10 - lUpperWidth, lY0 + ROUND(f*aItem.lUpper/2.0 - lXHeight/2.0)), aUpperStr);
+        DrawArrow(rRenderContext, Point(lX0 - 5, lY0), Point(lX0 - 5, lY1), false);
+        rRenderContext.DrawText(Point(lX0 - 10 - lUpperWidth, lY0 + ROUND(f*aItem.lUpper/2.0 - lXHeight/2.0)), aUpperStr);
     }
 
     // annotation: width and height
@@ -188,48 +190,48 @@ void SwLabPreview::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangle
         long lX = lX2 - lXWidth / 2 - lHeightWidth / 2;
         long lY = lY1 + lXHeight;
 
-        DrawLine(Point(lX1, lY), Point(lX2 - 1, lY));
-        DrawLine(Point(lX, lY1), Point(lX, lY2 - 1));
+        rRenderContext.DrawLine(Point(lX1, lY), Point(lX2 - 1, lY));
+        rRenderContext.DrawLine(Point(lX, lY1), Point(lX, lY2 - 1));
 
-        DrawText(Point(lX1 + lXWidth / 2, lY - lXHeight / 2), aWidthStr);
-        DrawText(Point(lX - lHeightWidth / 2, lY2 - lXHeight - lXHeight / 2), aHeightStr);
+        rRenderContext.DrawText(Point(lX1 + lXWidth / 2, lY - lXHeight / 2), aWidthStr);
+        rRenderContext.DrawText(Point(lX - lHeightWidth / 2, lY2 - lXHeight - lXHeight / 2), aHeightStr);
     }
 
     // annotation: horizontal gap
     if (aItem.nCols > 1)
     {
         long lX = (lX1 + lX3) / 2;
-        DrawArrow(Point(lX1, lY0 - 5), Point(lX3, lY0 - 5), false);
-        DrawArrow(Point(lX, lY0 - 10), Point(lX, lY0 - 5), true);
-        DrawText(Point(lX - lHDistWidth / 2, lY0 - 10 - lXHeight), aHDistStr);
+        DrawArrow(rRenderContext, Point(lX1, lY0 - 5), Point(lX3, lY0 - 5), false);
+        DrawArrow(rRenderContext, Point(lX, lY0 - 10), Point(lX, lY0 - 5), true);
+        rRenderContext.DrawText(Point(lX - lHDistWidth / 2, lY0 - 10 - lXHeight), aHDistStr);
     }
 
     // annotation: vertical gap
     if (aItem.nRows > 1)
     {
-        DrawArrow(Point(lX0 - 5, lY1), Point(lX0 - 5, lY3), false);
-        DrawText(Point(lX0 - 10 - lVDistWidth, lY1 + ROUND(f*aItem.lVDist/2.0 - lXHeight/2.0)), aVDistStr);
+        DrawArrow(rRenderContext, Point(lX0 - 5, lY1), Point(lX0 - 5, lY3), false);
+        rRenderContext.DrawText(Point(lX0 - 10 - lVDistWidth, lY1 + ROUND(f*aItem.lVDist/2.0 - lXHeight/2.0)), aVDistStr);
     }
 
     // annotation: columns
     {
         long lY = lY0 + lOutlineH + 4;
-        DrawArrow(Point(lX0, lY), Point(lX0 + lOutlineW - 1, lY), true);
-        DrawText(Point((lX0 + lX0 + lOutlineW - 1) / 2 - lColsWidth / 2, lY + 5), aColsStr);
+        DrawArrow(rRenderContext, Point(lX0, lY), Point(lX0 + lOutlineW - 1, lY), true);
+        rRenderContext.DrawText(Point((lX0 + lX0 + lOutlineW - 1) / 2 - lColsWidth / 2, lY + 5), aColsStr);
     }
 
     // annotation: lines
     {
         long lX = lX0 + lOutlineW + 4;
-        DrawArrow(Point(lX, lY0), Point(lX, lY0 + lOutlineH - 1), true);
-        DrawText(Point(lX + 5, (lY0 + lY0 + lOutlineH - 1 - lXHeight / 2) / 2), aRowsStr);
+        DrawArrow(rRenderContext, Point(lX, lY0), Point(lX, lY0 + lOutlineH - 1), true);
+        rRenderContext.DrawText(Point(lX + 5, (lY0 + lY0 + lOutlineH - 1 - lXHeight / 2) / 2), aRowsStr);
     }
 }
 
 // Arrow or interval character
-void SwLabPreview::DrawArrow(const Point &rP1, const Point &rP2, bool bArrow)
+void SwLabPreview::DrawArrow(vcl::RenderContext& rRenderContext, const Point &rP1, const Point &rP2, bool bArrow)
 {
-    DrawLine(rP1, rP2);
+    rRenderContext.DrawLine(rP1, rP2);
     if (bArrow)
     {
         Point aArr[3];
@@ -257,8 +259,8 @@ void SwLabPreview::DrawArrow(const Point &rP1, const Point &rP2, bool bArrow)
         }
 
         const Color& rFieldTextColor = SwViewOption::GetFontColor();
-        SetFillColor(rFieldTextColor);
-        DrawPolygon(Polygon(3, aArr));
+        rRenderContext.SetFillColor(rFieldTextColor);
+        rRenderContext.DrawPolygon(Polygon(3, aArr));
     }
     else
     {
@@ -266,14 +268,14 @@ void SwLabPreview::DrawArrow(const Point &rP1, const Point &rP2, bool bArrow)
         if (rP1.Y() == rP2.Y())
         {
             // Horizontal
-            DrawLine(Point(rP1.X(), rP1.Y() - 2), Point(rP1.X(), rP1.Y() + 2));
-            DrawLine(Point(rP2.X(), rP2.Y() - 2), Point(rP2.X(), rP2.Y() + 2));
+            rRenderContext.DrawLine(Point(rP1.X(), rP1.Y() - 2), Point(rP1.X(), rP1.Y() + 2));
+            rRenderContext.DrawLine(Point(rP2.X(), rP2.Y() - 2), Point(rP2.X(), rP2.Y() + 2));
         }
         else
         {
             // Vertical
-            DrawLine(Point(rP1.X() - 2, rP1.Y()), Point(rP1.X() + 2, rP1.Y()));
-            DrawLine(Point(rP2.X() - 2, rP2.Y()), Point(rP2.X() + 2, rP2.Y()));
+            rRenderContext.DrawLine(Point(rP1.X() - 2, rP1.Y()), Point(rP1.X() + 2, rP1.Y()));
+            rRenderContext.DrawLine(Point(rP2.X() - 2, rP2.Y()), Point(rP2.X() + 2, rP2.Y()));
         }
     }
 }
diff --git a/sw/source/ui/envelp/labfmt.hxx b/sw/source/ui/envelp/labfmt.hxx
index 9b409be..3097fd5 100644
--- a/sw/source/ui/envelp/labfmt.hxx
+++ b/sw/source/ui/envelp/labfmt.hxx
@@ -58,7 +58,7 @@ class SwLabPreview : public vcl::Window
 
     virtual Size GetOptimalSize() const SAL_OVERRIDE;
 
-    void DrawArrow(const Point& rP1, const Point& rP2, bool bArrow);
+    void DrawArrow(vcl::RenderContext& rRenderContext, const Point& rP1, const Point& rP2, bool bArrow);
 
 public:
 
commit 8d9dc648986c914c2f00a505ad15b91e04b47d9a
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri May 15 16:56:15 2015 +0900

    refactor AutoFmtPreview to use RenderContext
    
    Change-Id: I25e93ffd474d821a6b92f99327fe99e06bb89a62

diff --git a/sw/source/ui/table/tautofmt.cxx b/sw/source/ui/table/tautofmt.cxx
index 345c7be..cd2bbfe 100644
--- a/sw/source/ui/table/tautofmt.cxx
+++ b/sw/source/ui/table/tautofmt.cxx
@@ -58,12 +58,11 @@ public:
 
     virtual void Resize() SAL_OVERRIDE;
 protected:
-    virtual void Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect ) SAL_OVERRIDE;
+    virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
 
 private:
     SwTableAutoFmt          aCurData;
     ScopedVclPtr<VirtualDevice> aVD;
-    SvtScriptedTextHelper   aScriptedText;
     svx::frame::Array       maArray;            /// Implementation to draw the frame borders.
     bool                    bFitWidth;
     bool                    mbRTL;
@@ -81,38 +80,36 @@ private:
     const OUString          aStrSum;
     SvNumberFormatter*      pNumFmt;
 
-    uno::Reference< i18n::XBreakIterator >       m_xBreak;
+    uno::Reference<i18n::XBreakIterator> m_xBreak;
 
-    void    Init            ();
-    void    DoPaint         ( const Rectangle& rRect );
-    void    CalcCellArray   ( bool bFitWidth );
-    void    CalcLineMap     ();
-    void    PaintCells      ();
+    void    Init();
+    void    DoPaint(vcl::RenderContext& rRenderContext, const Rectangle& rRect);
+    void    CalcCellArray(bool bFitWidth);
+    void    CalcLineMap();
+    void    PaintCells(vcl::RenderContext& rRenderContext);
 
     sal_uInt8           GetFormatIndex( size_t nCol, size_t nRow ) const;
     const SvxBoxItem&   GetBoxItem( size_t nCol, size_t nRow ) const;
 
-    void                DrawString( size_t nCol, size_t nRow );
-    void                DrawStrings();
-    void                DrawBackground();
+    void DrawString(vcl::RenderContext& rRenderContext, size_t nCol, size_t nRow);
+    void DrawStrings(vcl::RenderContext& rRenderContext);
+    void DrawBackground(vcl::RenderContext& rRenderContext);
 
-    void                MakeFonts( sal_uInt8 nIndex, vcl::Font& rFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont );
+    void MakeFonts(sal_uInt8 nIndex, vcl::Font& rFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont);
 };
 
 class SwStringInputDlg : public ModalDialog
 {
 public:
-            SwStringInputDlg(     vcl::Window* pParent,
-                            const OUString& rTitle,
-                            const OUString& rEditTitle,
-                            const OUString& rDefault );
-            virtual ~SwStringInputDlg();
+    SwStringInputDlg(vcl::Window* pParent, const OUString& rTitle,
+                     const OUString& rEditTitle, const OUString& rDefault );
+    virtual ~SwStringInputDlg();
     virtual void dispose() SAL_OVERRIDE;
 
     OUString GetInputString() const;
 
 private:
-    VclPtr<Edit>           m_pEdInput;   // Edit obtains the focus.
+    VclPtr<Edit> m_pEdInput; // Edit obtains the focus.
 };
 
 SwStringInputDlg::SwStringInputDlg(vcl::Window* pParent, const OUString& rTitle,
@@ -515,7 +512,6 @@ AutoFmtPreview::AutoFmtPreview(vcl::Window* pParent, WinBits nStyle) :
         Window          ( pParent, nStyle ),
         aCurData        ( OUString() ),
         aVD             ( VclPtr<VirtualDevice>::Create(*this) ),
-        aScriptedText   ( *aVD.get() ),
         bFitWidth       ( false ),
         mbRTL           ( false ),
         aStrJan         ( SW_RES( STR_JAN ) ),
@@ -630,93 +626,124 @@ const SvxBoxItem& AutoFmtPreview::GetBoxItem( size_t nCol, size_t nRow ) const
     return aCurData.GetBoxFmt( GetFormatIndex( nCol, nRow ) ).GetBox();
 }
 
-void AutoFmtPreview::DrawString( size_t nCol, size_t nRow )
+void AutoFmtPreview::DrawString(vcl::RenderContext& rRenderContext, size_t nCol, size_t nRow)
 {
     // Output of the cell text:
-    sal_uLong   nNum;
-    double  nVal;
+    sal_uLong nNum;
+    double nVal;
     OUString cellString;
-    sal_uInt8    nIndex = static_cast< sal_uInt8 >( maArray.GetCellIndex( nCol, nRow, mbRTL ) );
+    sal_uInt8 nIndex = static_cast<sal_uInt8>(maArray.GetCellIndex(nCol, nRow, mbRTL));
 
-    switch( nIndex )
+    switch(nIndex)
     {
-    case  1: cellString = aStrJan;          break;
-    case  2: cellString = aStrFeb;          break;
-    case  3: cellString = aStrMar;          break;
-    case  5: cellString = aStrNorth;        break;
-    case 10: cellString = aStrMid;          break;
-    case 15: cellString = aStrSouth;        break;
+    case 1:
+        cellString = aStrJan;
+        break;
+    case 2:
+        cellString = aStrFeb;
+        break;
+    case 3:
+        cellString = aStrMar;
+        break;
+    case 5:
+        cellString = aStrNorth;
+        break;
+    case 10:
+        cellString = aStrMid;
+        break;
+    case 15:
+        cellString = aStrSouth;
+        break;
     case  4:
-    case 20: cellString = aStrSum;          break;
-
-    case  6:
-    case  8:
+    case 20:
+        cellString = aStrSum;
+        break;
+    case 6:
+    case 8:
     case 16:
-    case 18:    nVal = nIndex;
+    case 18:
+        nVal = nIndex;
         nNum = 5;
         goto MAKENUMSTR;
     case 17:
-    case  7:    nVal = nIndex;
+    case 7:
+        nVal = nIndex;
         nNum = 6;
         goto MAKENUMSTR;
     case 11:
     case 12:
-    case 13:    nVal = nIndex;
+    case 13:
+        nVal = nIndex;
         nNum = 12 == nIndex ? 10 : 9;
         goto MAKENUMSTR;
+    case 9:
+        nVal = 21; nNum = 7;
+        goto MAKENUMSTR;
+    case 14:
+        nVal = 36; nNum = 11;
+        goto MAKENUMSTR;
+    case 19:
+        nVal = 51; nNum = 7;
+        goto MAKENUMSTR;
+    case 21:
+        nVal = 33; nNum = 13;
+        goto MAKENUMSTR;
+    case 22:
+        nVal = 36; nNum = 14;
+        goto MAKENUMSTR;
+    case 23:
+        nVal = 39; nNum = 13;
+        goto MAKENUMSTR;
+    case 24:
+        nVal = 108; nNum = 15;
+        goto MAKENUMSTR;
 
-    case  9:    nVal = 21; nNum = 7;    goto MAKENUMSTR;
-    case 14:    nVal = 36; nNum = 11;   goto MAKENUMSTR;
-    case 19:    nVal = 51; nNum = 7;    goto MAKENUMSTR;
-    case 21:    nVal = 33; nNum = 13;   goto MAKENUMSTR;
-    case 22:    nVal = 36; nNum = 14;   goto MAKENUMSTR;
-    case 23:    nVal = 39; nNum = 13;   goto MAKENUMSTR;
-    case 24:    nVal = 108; nNum = 15;  goto MAKENUMSTR;
 MAKENUMSTR:
-        if( aCurData.IsValueFormat() )
+        if (aCurData.IsValueFormat())
         {
             OUString sFmt;
             LanguageType eLng, eSys;
-            aCurData.GetBoxFmt( (sal_uInt8)nNum ).GetValueFormat( sFmt, eLng, eSys );
+            aCurData.GetBoxFmt(sal_uInt8(nNum)).GetValueFormat(sFmt, eLng, eSys);
 
             short nType;
             bool bNew;
             sal_Int32 nCheckPos;
-            sal_uInt32 nKey = pNumFmt->GetIndexPuttingAndConverting( sFmt, eLng,
-                                                                     eSys, nType, bNew, nCheckPos);
+            sal_uInt32 nKey = pNumFmt->GetIndexPuttingAndConverting(sFmt, eLng,
+                                                                    eSys, nType, bNew, nCheckPos);
             Color* pDummy;
-            pNumFmt->GetOutputString( nVal, nKey, cellString, &pDummy );
+            pNumFmt->GetOutputString(nVal, nKey, cellString, &pDummy);
         }
         else
-            cellString = OUString::number((sal_Int32)nVal);
+            cellString = OUString::number(sal_Int32(nVal));
         break;
 
     }
 
-    if( !cellString.isEmpty() )
+    if (!cellString.isEmpty())
     {
-        Size                aStrSize;
-        sal_uInt8           nFmtIndex       = GetFormatIndex( nCol, nRow );
-        Rectangle           cellRect        = maArray.GetCellRect( nCol, nRow );
-        Point               aPos            = cellRect.TopLeft();
-        long                nRightX         = 0;
-
-        Size theMaxStrSize( cellRect.GetWidth() - FRAME_OFFSET,
-                            cellRect.GetHeight() - FRAME_OFFSET );
-        if( aCurData.IsFont() )
+        SvtScriptedTextHelper aScriptedText(rRenderContext);
+        Size aStrSize;
+        sal_uInt8 nFmtIndex = GetFormatIndex( nCol, nRow );
+        Rectangle cellRect = maArray.GetCellRect( nCol, nRow );
+        Point aPos = cellRect.TopLeft();
+        long nRightX = 0;
+
+        Size theMaxStrSize(cellRect.GetWidth() - FRAME_OFFSET,
+                           cellRect.GetHeight() - FRAME_OFFSET);
+        if (aCurData.IsFont())
         {
             vcl::Font aFont, aCJKFont, aCTLFont;
-            MakeFonts( nFmtIndex, aFont, aCJKFont, aCTLFont );
-            aScriptedText.SetFonts( &aFont, &aCJKFont, &aCTLFont );
+            MakeFonts(nFmtIndex, aFont, aCJKFont, aCTLFont);
+            aScriptedText.SetFonts(&aFont, &aCJKFont, &aCTLFont);
         }
         else
             aScriptedText.SetDefaultFont();
 
-        aScriptedText.SetText( cellString, m_xBreak );
+        aScriptedText.SetText(cellString, m_xBreak);
         aStrSize = aScriptedText.GetTextSize();
 
-        if( aCurData.IsFont() &&
-            theMaxStrSize.Height() < aStrSize.Height() )
+        if (aCurData.IsFont() &&
+            theMaxStrSize.Height() < aStrSize.Height())
         {
                 // If the string in this font does not
                 // fit into the cell, the standard font
@@ -725,11 +752,11 @@ MAKENUMSTR:
                 aStrSize = aScriptedText.GetTextSize();
         }
 
-        while( theMaxStrSize.Width() <= aStrSize.Width() &&
-                cellString.getLength() > 1 )
+        while (theMaxStrSize.Width() <= aStrSize.Width() &&
+               cellString.getLength() > 1)
         {
-            cellString = cellString.copy(0, cellString.getLength() - 1 );
-            aScriptedText.SetText( cellString, m_xBreak );
+            cellString = cellString.copy(0, cellString.getLength() - 1);
+            aScriptedText.SetText(cellString, m_xBreak);
             aStrSize = aScriptedText.GetTextSize();
         }
 
@@ -739,12 +766,12 @@ MAKENUMSTR:
         aPos.Y() += (nRowHeight - aStrSize.Height()) / 2;
 
         // horizontal
-        if( mbRTL )
+        if (mbRTL)
             aPos.X() += nRightX;
         else if (aCurData.IsJustify())
         {
             const SvxAdjustItem& rAdj = aCurData.GetBoxFmt(nFmtIndex).GetAdjust();
-            switch ( rAdj.GetAdjust() )
+            switch (rAdj.GetAdjust())
             {
                 case SVX_ADJUST_LEFT:
                     aPos.X() += FRAME_OFFSET;
@@ -753,67 +780,67 @@ MAKENUMSTR:
                     aPos.X() += nRightX;
                     break;
                 default:
-                    aPos.X() += (cellRect.GetWidth() - aStrSize.Width())/2;
+                    aPos.X() += (cellRect.GetWidth() - aStrSize.Width()) / 2;
                     break;
             }
         }
         else
         {
             // Standard align:
-            if ( (nCol == 0) || (nIndex == 4) )
+            if (nCol == 0 || nIndex == 4)
             {
                 // Text-Label left or sum left aligned
                 aPos.X() += FRAME_OFFSET;
             }
             else
             {
-                    // numbers/dates right aligned
+                // numbers/dates right aligned
                 aPos.X() += nRightX;
             }
         }
 
-        aScriptedText.DrawText( aPos );
+        aScriptedText.DrawText(aPos);
     }
 }
 
 #undef FRAME_OFFSET
 
-void AutoFmtPreview::DrawStrings()
+void AutoFmtPreview::DrawStrings(vcl::RenderContext& rRenderContext)
 {
-    for( size_t nRow = 0; nRow < 5; ++nRow )
-        for( size_t nCol = 0; nCol < 5; ++nCol )
-            DrawString( nCol, nRow );
+    for (size_t nRow = 0; nRow < 5; ++nRow)
+        for (size_t nCol = 0; nCol < 5; ++nCol)
+            DrawString(rRenderContext, nCol, nRow);
 }
 
-void AutoFmtPreview::DrawBackground()
+void AutoFmtPreview::DrawBackground(vcl::RenderContext& rRenderContext)
 {
-    for( size_t nRow = 0; nRow < 5; ++nRow )
+    for (size_t nRow = 0; nRow < 5; ++nRow)
     {
-        for( size_t nCol = 0; nCol < 5; ++nCol )
+        for (size_t nCol = 0; nCol < 5; ++nCol)
         {
-            SvxBrushItem aBrushItem( aCurData.GetBoxFmt( GetFormatIndex( nCol, nRow ) ).GetBackground() );
+            SvxBrushItem aBrushItem(aCurData.GetBoxFmt(GetFormatIndex(nCol, nRow)).GetBackground());
 
-            aVD->Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR );
-            aVD->SetLineColor();
-            aVD->SetFillColor( aBrushItem.GetColor() );
-            aVD->DrawRect( maArray.GetCellRect( nCol, nRow ) );
-            aVD->Pop();
+            rRenderContext.Push(PushFlags::LINECOLOR | PushFlags::FILLCOLOR);
+            rRenderContext.SetLineColor();
+            rRenderContext.SetFillColor(aBrushItem.GetColor());
+            rRenderContext.DrawRect(maArray.GetCellRect(nCol, nRow));
+            rRenderContext.Pop();
         }
     }
 }
 
-void AutoFmtPreview::PaintCells()
+void AutoFmtPreview::PaintCells(vcl::RenderContext& rRenderContext)
 {
     // 1) background
-    if ( aCurData.IsBackground() )
-        DrawBackground();
+    if (aCurData.IsBackground())
+        DrawBackground(rRenderContext);
 
     // 2) values
-    DrawStrings();
+    DrawStrings(rRenderContext);
 
     // 3) border
-    if ( aCurData.IsFrame() )
-        maArray.DrawArray( *aVD.get() );
+    if (aCurData.IsFrame())
+        maArray.DrawArray(rRenderContext);
 }
 
 void AutoFmtPreview::Init()
@@ -877,56 +904,58 @@ void AutoFmtPreview::NotifyChange( const SwTableAutoFmt& rNewData )
     bFitWidth = aCurData.IsJustify();  // true;  //???
     CalcCellArray( bFitWidth );
     CalcLineMap();
-    DoPaint( Rectangle( Point(0,0), GetSizePixel() ) );
+    Invalidate(Rectangle(Point(0,0), GetSizePixel()));
 }
 
-void AutoFmtPreview::DoPaint( const Rectangle& /*rRect*/ )
+void AutoFmtPreview::DoPaint(vcl::RenderContext& rRenderContext, const Rectangle& /*rRect*/)
 {
     sal_uInt32 nOldDrawMode = aVD->GetDrawMode();
-    if( GetSettings().GetStyleSettings().GetHighContrastMode() )
-        aVD->SetDrawMode( DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
+    if (rRenderContext.GetSettings().GetStyleSettings().GetHighContrastMode())
+        aVD->SetDrawMode(DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT);
 
-    Bitmap  thePreview;
-    Point   aCenterPos;
-    Size    theWndSize = GetSizePixel();
-    Color   oldColor;
+    Bitmap thePreview;
+    Point aCenterPos;
+    Size theWndSize = GetSizePixel();
+    Color oldColor;
     vcl::Font aFont;
 
     aFont = aVD->GetFont();
     aFont.SetTransparent( true );
 
-    aVD->SetFont          ( aFont );
-    aVD->SetLineColor     ();
-    const Color& rWinColor = GetSettings().GetStyleSettings().GetWindowColor();
-    aVD->SetBackground    ( Wallpaper(rWinColor) );
-    aVD->SetFillColor     ( rWinColor );
-    aVD->SetOutputSizePixel  ( aPrvSize );
+    aVD->SetFont(aFont);
+    aVD->SetLineColor();
+    const Color& rWinColor = rRenderContext.GetSettings().GetStyleSettings().GetWindowColor();
+    aVD->SetBackground(Wallpaper(rWinColor));
+    aVD->SetFillColor(rWinColor);
+    aVD->SetOutputSizePixel(aPrvSize);
 
     // Draw cells on virtual device
     // and save the result
-    PaintCells();
-    thePreview = aVD->GetBitmap( Point(0,0), aPrvSize );
+    PaintCells(*aVD.get());
+    thePreview = aVD->GetBitmap(Point(0,0), aPrvSize);
 
     // Draw the Frame and center the preview:
     // (virtual Device for window output)
-    aVD->SetOutputSizePixel( theWndSize );
+    aVD->SetOutputSizePixel(theWndSize);
     oldColor = aVD->GetLineColor();
     aVD->SetLineColor();
-    aVD->DrawRect( Rectangle( Point(0,0), theWndSize ) );
-    SetLineColor( oldColor );
-    aCenterPos  = Point( (theWndSize.Width()  - aPrvSize.Width() ) / 2,
-                         (theWndSize.Height() - aPrvSize.Height()) / 2 );
-    aVD->DrawBitmap( aCenterPos, thePreview );
+    aVD->DrawRect(Rectangle(Point(0,0), theWndSize));
+
+    rRenderContext.SetLineColor(oldColor);
+
+    aCenterPos = Point((theWndSize.Width()  - aPrvSize.Width())  / 2,
+                       (theWndSize.Height() - aPrvSize.Height()) / 2);
+    aVD->DrawBitmap(aCenterPos, thePreview);
 
     // Output in the preview window:
-    DrawBitmap( Point(0,0), aVD->GetBitmap( Point(0,0), theWndSize ) );
+    rRenderContext.DrawBitmap(Point(0, 0), aVD->GetBitmap(Point(0,0), theWndSize));
 
-    aVD->SetDrawMode( nOldDrawMode );
+    aVD->SetDrawMode(nOldDrawMode);
 }
 
-void AutoFmtPreview::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect )
+void AutoFmtPreview::Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect )
 {
-    DoPaint( rRect );
+    DoPaint(rRenderContext, rRect);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 9bb59aab72d8226e0d31d71e52125b0a9474a30b
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri May 15 16:54:47 2015 +0900

    refactor SwColumnOnlyExample to use RenderContext
    
    Change-Id: I4c15bb0428005031ea3b4766eb4221ff48d91514

diff --git a/sw/source/uibase/frmdlg/colex.cxx b/sw/source/uibase/frmdlg/colex.cxx
index f4e7454..397d5fb 100644
--- a/sw/source/uibase/frmdlg/colex.cxx
+++ b/sw/source/uibase/frmdlg/colex.cxx
@@ -336,49 +336,49 @@ SwColumnOnlyExample::SwColumnOnlyExample(vcl::Window* pParent)
 
 VCL_BUILDER_FACTORY(SwColumnOnlyExample)
 
-void SwColumnOnlyExample::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& /*rRect*/ )
+void SwColumnOnlyExample::Paint(vcl::RenderContext& rRenderContext, const Rectangle& /*rRect*/)
 {
-    const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+    const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
     const Color& rFieldColor = rStyleSettings.GetFieldColor();
     const Color& rDlgColor = rStyleSettings.GetDialogColor();
     const Color& rFieldTextColor = SwViewOption::GetFontColor();
     Color aGrayColor(COL_LIGHTGRAY);
-    if(rFieldColor == aGrayColor)
+    if (rFieldColor == aGrayColor)
         aGrayColor.Invert();
 
-    Size aLogSize(PixelToLogic(GetOutputSizePixel()));
+    Size aLogSize(rRenderContext.PixelToLogic(rRenderContext.GetOutputSizePixel()));
     Rectangle aCompleteRect(Point(0,0), aLogSize);
-    SetLineColor(rDlgColor);
-    SetFillColor(rDlgColor);
-    DrawRect(aCompleteRect);
+    rRenderContext.SetLineColor(rDlgColor);
+    rRenderContext.SetFillColor(rDlgColor);
+    rRenderContext.DrawRect(aCompleteRect);
 
-    SetLineColor( rFieldTextColor );
-    Point aTL(  (aLogSize.Width() - m_aFrmSize.Width()) / 2,
-                (aLogSize.Height() - m_aFrmSize.Height()) / 2);
+    rRenderContext.SetLineColor(rFieldTextColor);
+    Point aTL((aLogSize.Width() - m_aFrmSize.Width()) / 2,
+              (aLogSize.Height() - m_aFrmSize.Height()) / 2);
     Rectangle aRect(aTL, m_aFrmSize);
 
     //draw a shadow rectangle
-    SetFillColor( Color(COL_GRAY) );
+    rRenderContext.SetFillColor(Color(COL_GRAY));
     Rectangle aShadowRect(aRect);
     aShadowRect.Move(aTL.Y(), aTL.Y());
-    DrawRect(aShadowRect);
+    rRenderContext.DrawRect(aShadowRect);
 
-    SetFillColor( rFieldColor );
-    DrawRect(aRect);
+    rRenderContext.SetFillColor(rFieldColor);
+    rRenderContext.DrawRect(aRect);
 
-    SetFillColor( aGrayColor );
+    rRenderContext.SetFillColor(aGrayColor);
 
     //column separator?
     long nLength = aLogSize.Height() - 2 * aTL.Y();
-    Point aUp( aTL );
-    Point aDown( aTL.X(), nLength );
+    Point aUp(aTL);
+    Point aDown(aTL.X(), nLength);
     bool bLines = false;
-    if(m_aCols.GetLineAdj() != COLADJ_NONE)
+    if (m_aCols.GetLineAdj() != COLADJ_NONE)
     {
         bLines = true;
 
         sal_uInt16 nPercent = m_aCols.GetLineHeight();
-        if( nPercent != 100 )
+        if (nPercent != 100)
         {
             nLength -= nLength * nPercent / 100;
             switch(m_aCols.GetLineAdj())
@@ -389,36 +389,37 @@ void SwColumnOnlyExample::Paint( vcl::RenderContext& /*rRenderContext*/, const R
                         aUp.Y() += nLength / 2;
                         aDown.Y() -= nLength / 2;
                 break;
-                default:; //prevent warning
+                default:
+                    break; //prevent warning
             }
         }
 
     }
     const SwColumns& rCols = m_aCols.GetColumns();
     sal_uInt16 nColCount = rCols.size();
-    if( nColCount )
+    if (nColCount)
     {
-        DrawRect(aRect);
-        SetFillColor( rFieldColor );
+        rRenderContext.DrawRect(aRect);
+        rRenderContext.SetFillColor(rFieldColor);
         Rectangle aFrmRect(aTL, m_aFrmSize);
         long nSum = aTL.X();
-        for(sal_uInt16 i = 0; i < nColCount; i++)
+        for (sal_uInt16 i = 0; i < nColCount; i++)
         {
             const SwColumn* pCol = &rCols[i];
-            aFrmRect.Left()    = nSum + pCol->GetLeft();//nSum + pCol->GetLeft() + aTL.X();
-            nSum              += pCol->GetWishWidth();
-            aFrmRect.Right()   = nSum - pCol->GetRight();
-            DrawRect(aFrmRect);
+            aFrmRect.Left() = nSum + pCol->GetLeft(); //nSum + pCol->GetLeft() + aTL.X();
+            nSum += pCol->GetWishWidth();
+            aFrmRect.Right() = nSum - pCol->GetRight();
+            rRenderContext.DrawRect(aFrmRect);
         }
-        if(bLines )
+        if (bLines)
         {
             nSum = aTL.X();
-            for(sal_uInt16 i = 0; i < nColCount - 1; i++)
+            for (sal_uInt16 i = 0; i < nColCount - 1; i++)
             {
                 nSum += rCols[i].GetWishWidth();
                 aUp.X() = nSum;
                 aDown.X() = nSum;
-                DrawLine(aUp, aDown);
+                rRenderContext.DrawLine(aUp, aDown);
             }
         }
     }
@@ -488,6 +489,7 @@ void SwPageGridExample::DrawPage(vcl::RenderContext& rRenderContext, const Point
                                  const bool bSecond, const bool bEnabled)
 {
     SwPageExample::DrawPage(rRenderContext, rOrg, bSecond, bEnabled);
+
     if (pGridItem && pGridItem->GetGridType())
     {
         //paint the grid now
@@ -549,7 +551,7 @@ void SwPageGridExample::DrawPage(vcl::RenderContext& rRenderContext, const Point
             aCharRect.Move(0, nYStart);
         }
 
-        if(pGridItem->IsRubyTextBelow())
+        if (pGridItem->IsRubyTextBelow())
             m_bVertical ? aRubyRect.Move(nBaseHeight, 0) : aRubyRect.Move(0, nBaseHeight);
         else
             m_bVertical ? aCharRect.Move(nRubyHeight, 0) : aCharRect.Move(0, nRubyHeight);
@@ -567,7 +569,7 @@ void SwPageGridExample::DrawPage(vcl::RenderContext& rRenderContext, const Point
             {
                 Point aStart = aCharRect.TopLeft();
                 Point aEnd = m_bVertical ? aCharRect.TopRight() : aCharRect.BottomLeft();
-                while(m_bVertical ? aStart.Y() < aRect.Bottom(): aStart.X() < aRect.Right())
+                while (m_bVertical ? aStart.Y() < aRect.Bottom(): aStart.X() < aRect.Right())
                 {
                     rRenderContext.DrawLine(aStart, aEnd);
                     if(m_bVertical)
commit 43ce2db6f65d267c940e20e6f4396bf2b85ec59f
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri May 15 16:52:37 2015 +0900

    refactor PresLayoutPreview to use RenderContext
    
    Change-Id: If810985c39985b836e907fe2ff350b84ebdf6054

diff --git a/sd/source/ui/dlg/headerfooterdlg.cxx b/sd/source/ui/dlg/headerfooterdlg.cxx
index 041d61a..3bd4437 100644
--- a/sd/source/ui/dlg/headerfooterdlg.cxx
+++ b/sd/source/ui/dlg/headerfooterdlg.cxx
@@ -72,17 +72,17 @@ private:
     Rectangle maOutRect;
 
 private:
-    void Paint( OutputDevice& aOut, SdrTextObj* pObj, bool bVisible, bool bDotted = false );
+    void Paint(vcl::RenderContext& rRenderContext, SdrTextObj* pObj, bool bVisible, bool bDotted = false);
 
 public:
-    PresLayoutPreview( vcl::Window* pParent );
+    PresLayoutPreview(vcl::Window* pParent);
     virtual ~PresLayoutPreview();
 
-    virtual void Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect ) SAL_OVERRIDE;
+    virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
     virtual Size GetOptimalSize() const SAL_OVERRIDE;
 
-    void init( SdPage* pMaster );
-    void update( HeaderFooterSettings& rSettings );
+    void init(SdPage* pMaster);
+    void update(HeaderFooterSettings& rSettings);
 };
 
 }
@@ -735,7 +735,7 @@ void PresLayoutPreview::update( HeaderFooterSettings& rSettings )
     Invalidate();
 }
 
-void PresLayoutPreview::Paint( OutputDevice& aOut, SdrTextObj* pObj, bool bVisible, bool bDotted /* = false*/ )
+void PresLayoutPreview::Paint(vcl::RenderContext& rRenderContext, SdrTextObj* pObj, bool bVisible, bool bDotted /* = false*/ )
 {
     // get object transformation
     basegfx::B2DHomMatrix aObjectTransform;
@@ -754,9 +754,9 @@ void PresLayoutPreview::Paint( OutputDevice& aOut, SdrTextObj* pObj, bool bVisib
     aGeometry.transform(aObjectTransform);
 
     // apply line pattern if wanted
-    if(bDotted)
+    if (bDotted)
     {
-        ::std::vector<double> aPattern;
+        std::vector<double> aPattern;
         static double fFactor(1.0);
         aPattern.push_back(3.0 * fFactor);
         aPattern.push_back(1.0 * fFactor);
@@ -771,20 +771,20 @@ void PresLayoutPreview::Paint( OutputDevice& aOut, SdrTextObj* pObj, bool bVisib
     svtools::ColorConfigValue aColor( aColorConfig.GetColorValue( bVisible ? svtools::FONTCOLOR : svtools::OBJECTBOUNDARIES ) );
 
     // paint at OutDev
-    aOut.SetLineColor(Color(aColor.nColor));
-    aOut.SetFillColor();
+    rRenderContext.SetLineColor(Color(aColor.nColor));
+    rRenderContext.SetFillColor();
 
-    for(sal_uInt32 a(0); a < aGeometry.count(); a++)
+    for (sal_uInt32 a(0); a < aGeometry.count(); a++)
     {
-        aOut.DrawPolyLine(aGeometry.getB2DPolygon(a));
+        rRenderContext.DrawPolyLine(aGeometry.getB2DPolygon(a));
     }
 }
 
-void PresLayoutPreview::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
+void PresLayoutPreview::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
 {
-    Push();
+    rRenderContext.Push();
 
-    maOutRect = Rectangle( Point(0,0), GetOutputSize() );
+    maOutRect = Rectangle(Point(0,0), rRenderContext.GetOutputSize());
 
     // calculate page size with correct aspect ratio
     int nWidth, nHeight;
@@ -805,12 +805,12 @@ void PresLayoutPreview::Paint( vcl::RenderContext& /*rRenderContext*/, const Rec
     maOutRect.Bottom() = maOutRect.Top() + nHeight - 1;
 
     // draw decoration frame
-    DecorationView aDecoView( this );
-    maOutRect = aDecoView.DrawFrame( maOutRect, DrawFrameStyle::In );
+    DecorationView aDecoView(&rRenderContext);
+    maOutRect = aDecoView.DrawFrame(maOutRect, DrawFrameStyle::In);
 
     // draw page background
-    SetFillColor( Color(COL_WHITE) );
-    DrawRect( maOutRect );
+    rRenderContext.SetFillColor(Color(COL_WHITE));
+    rRenderContext.DrawRect(maOutRect);
 
     // paint presentation objects from masterpage
     SdrTextObj* pMasterTitle = static_cast<SdrTextObj*>(mpMaster->GetPresObj( PRESOBJ_TITLE ));
@@ -820,20 +820,20 @@ void PresLayoutPreview::Paint( vcl::RenderContext& /*rRenderContext*/, const Rec
     SdrTextObj* pDate   = static_cast<SdrTextObj*>(mpMaster->GetPresObj( PRESOBJ_DATETIME ));
     SdrTextObj* pNumber = static_cast<SdrTextObj*>(mpMaster->GetPresObj( PRESOBJ_SLIDENUMBER ));
 
-    if( pMasterTitle )
-        Paint( *this, pMasterTitle, true, true );
-    if( pMasterOutline )
-        Paint( *this, pMasterOutline, true, true );
-    if( pHeader )
-        Paint( *this, pHeader, maSettings.mbHeaderVisible );
-    if( pFooter )
-        Paint( *this, pFooter, maSettings.mbFooterVisible );
-    if( pDate )
-        Paint( *this, pDate, maSettings.mbDateTimeVisible );
-    if( pNumber )
-        Paint( *this, pNumber, maSettings.mbSlideNumberVisible );
-
-    Pop();
+    if (pMasterTitle)
+        Paint(rRenderContext, pMasterTitle, true, true);
+    if (pMasterOutline)
+        Paint(rRenderContext, pMasterOutline, true, true);
+    if (pHeader)
+        Paint(rRenderContext, pHeader, maSettings.mbHeaderVisible);
+    if (pFooter)
+        Paint(rRenderContext, pFooter, maSettings.mbFooterVisible);
+    if (pDate)
+        Paint(rRenderContext, pDate, maSettings.mbDateTimeVisible);
+    if (pNumber)
+        Paint(rRenderContext, pNumber, maSettings.mbSlideNumberVisible);
+
+    rRenderContext.Pop();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 49480a1e26925fcd6862fea79b24638b243ba21f
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri May 15 16:49:22 2015 +0900

    refactor TabBarControl to use RenderContext
    
    Change-Id: Ie65fb06bfd5111a2d054018fd846f583606689f4

diff --git a/sd/source/ui/view/ViewTabBar.cxx b/sd/source/ui/view/ViewTabBar.cxx
index 72b4301..c32b92f 100644
--- a/sd/source/ui/view/ViewTabBar.cxx
+++ b/sd/source/ui/view/ViewTabBar.cxx
@@ -57,20 +57,17 @@ namespace sd {
 namespace {
 bool IsEqual (const TabBarButton& rButton1, const TabBarButton& rButton2)
 {
-    return (
-        (rButton1.ResourceId.is()
-            && rButton2.ResourceId.is()
-            && rButton1.ResourceId->compareTo(rButton2.ResourceId)==0)
+    return ((rButton1.ResourceId.is()
+                && rButton2.ResourceId.is()
+                && rButton1.ResourceId->compareTo(rButton2.ResourceId) == 0)
         || rButton1.ButtonLabel == rButton2.ButtonLabel);
 }
 
 class TabBarControl : public ::TabControl
 {
 public:
-    TabBarControl (
-        vcl::Window* pParentWindow,
-        const ::rtl::Reference<ViewTabBar>& rpViewTabBar);
-    virtual void Paint (vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect) SAL_OVERRIDE;
+    TabBarControl (vcl::Window* pParentWindow, const ::rtl::Reference<ViewTabBar>& rpViewTabBar);
+    virtual void Paint (vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
     virtual void ActivatePage() SAL_OVERRIDE;
 private:
     ::rtl::Reference<ViewTabBar> mpViewTabBar;
@@ -568,20 +565,21 @@ TabBarControl::TabBarControl (
 
 void TabBarControl::Paint (vcl::RenderContext& rRenderContext, const Rectangle& rRect)
 {
-    Color aOriginalFillColor (GetFillColor());
-    Color aOriginalLineColor (GetLineColor());
+    Color aOriginalFillColor(rRenderContext.GetFillColor());
+    Color aOriginalLineColor(rRenderContext.GetLineColor());
 
     // Because the actual window background is transparent--to avoid
     // flickering due to multiple background paintings by this and by child
     // windows--we have to paint the background for this control explicitly:
     // the actual control is not painted over its whole bounding box.
-    SetFillColor (GetSettings().GetStyleSettings().GetDialogColor());
-    SetLineColor ();
-    DrawRect (rRect);
+    rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetDialogColor());
+    rRenderContext.SetLineColor();
+    rRenderContext.DrawRect(rRect);
+
     ::TabControl::Paint(rRenderContext, rRect);
 
-    SetFillColor (aOriginalFillColor);
-    SetLineColor (aOriginalLineColor);
+    rRenderContext.SetFillColor(aOriginalFillColor);
+    rRenderContext.SetLineColor(aOriginalLineColor);
 }
 
 void TabBarControl::ActivatePage()
commit a18d743fbcad62111667b60a61284eff5ca0835a
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri May 15 16:48:26 2015 +0900

    refactor swruler to use RenderContext
    
    Change-Id: I16e1888900478c000c4437299357276e20c197c0

diff --git a/sw/source/uibase/inc/swruler.hxx b/sw/source/uibase/inc/swruler.hxx
index 8f5fb46..4136026 100644
--- a/sw/source/uibase/inc/swruler.hxx
+++ b/sw/source/uibase/inc/swruler.hxx
@@ -87,7 +87,7 @@ protected:
     /**
      * Paint the comment control on VirtualDevice.
      */
-    void DrawCommentControl();
+    void DrawCommentControl(vcl::RenderContext& rRenderContext);
     /**
      * Draw a little horizontal arrow tip on VirtualDevice.
      * \param nX left coordinate of arrow
@@ -95,7 +95,7 @@ protected:
      * \param Color arrow color
      * \param bPointRight if arrow should point to right. Otherwise, it will point left.
      */
-    void ImplDrawArrow(long nX, long nY, const Color& rColor, bool bPointRight);
+    void ImplDrawArrow(vcl::RenderContext& rRenderContext, long nX, long nY, const Color& rColor, bool bPointRight);
 
     /**
      * Update the tooltip text.
diff --git a/sw/source/uibase/misc/swruler.cxx b/sw/source/uibase/misc/swruler.cxx
index b462d36..665ca0f 100644
--- a/sw/source/uibase/misc/swruler.cxx
+++ b/sw/source/uibase/misc/swruler.cxx
@@ -63,19 +63,19 @@ void SwCommentRuler::dispose()
 void SwCommentRuler::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect)
 {
     SvxRuler::Paint(rRenderContext, rRect);
+
     // Don't draw if there is not any note
-    if ( mpViewShell->GetPostItMgr()
-         && mpViewShell->GetPostItMgr()->HasNotes() )
-        DrawCommentControl();
+    if (mpViewShell->GetPostItMgr() && mpViewShell->GetPostItMgr()->HasNotes())
+        DrawCommentControl(rRenderContext);
 }
 
-void SwCommentRuler::DrawCommentControl()
+void SwCommentRuler::DrawCommentControl(vcl::RenderContext& rRenderContext)
 {
-    const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+    const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
     bool bIsCollapsed = ! mpViewShell->GetPostItMgr()->ShowNotes();
 
     Rectangle aControlRect = GetCommentControlRegion();
-    maVirDev->SetOutputSizePixel( aControlRect.GetSize() );
+    maVirDev->SetOutputSizePixel(aControlRect.GetSize());
 
     // Paint comment control background
     // TODO Check if these are best colors to be used
@@ -148,30 +148,30 @@ void SwCommentRuler::DrawCommentControl()
 
     // Draw arrow
     // FIXME consistence of button colors. http://opengrok.libreoffice.org/xref/core/vcl/source/control/button.cxx#785
-    Color aArrowColor = GetFadedColor( Color( COL_BLACK ), rStyleSettings.GetShadowColor() );
-    ImplDrawArrow ( aArrowPos.X(), aArrowPos.Y(), aArrowColor, bArrowToRight );
+    Color aArrowColor = GetFadedColor(Color(COL_BLACK), rStyleSettings.GetShadowColor());
+    ImplDrawArrow(*maVirDev.get(), aArrowPos.X(), aArrowPos.Y(), aArrowColor, bArrowToRight);
 
     // Blit comment control
-    DrawOutDev( aControlRect.TopLeft(), aControlRect.GetSize(), Point(), aControlRect.GetSize(), *maVirDev.get() );
+    rRenderContext.DrawOutDev(aControlRect.TopLeft(), aControlRect.GetSize(), Point(), aControlRect.GetSize(), *maVirDev.get());
 }
 
-void SwCommentRuler::ImplDrawArrow(long nX, long nY, const Color& rColor, bool bPointRight)
+void SwCommentRuler::ImplDrawArrow(vcl::RenderContext& rRenderContext, long nX, long nY, const Color& rColor, bool bPointRight)
 {
-    maVirDev->SetLineColor();
-    maVirDev->SetFillColor( rColor );
-    if ( bPointRight )
+    rRenderContext.SetLineColor();
+    rRenderContext.SetFillColor(rColor);
+    if (bPointRight)
     {
-        maVirDev->DrawRect( Rectangle( nX+0, nY+0, nX+0, nY+6 ) );
-        maVirDev->DrawRect( Rectangle( nX+1, nY+1, nX+1, nY+5 ) );
-        maVirDev->DrawRect( Rectangle( nX+2, nY+2, nX+2, nY+4 ) );
-        maVirDev->DrawRect( Rectangle( nX+3, nY+3, nX+3, nY+3 ) );
+        rRenderContext.DrawRect(Rectangle(nX + 0, nY + 0, nX + 0, nY + 6) );
+        rRenderContext.DrawRect(Rectangle(nX + 1, nY + 1, nX + 1, nY + 5) );
+        rRenderContext.DrawRect(Rectangle(nX + 2, nY + 2, nX + 2, nY + 4) );
+        rRenderContext.DrawRect(Rectangle(nX + 3, nY + 3, nX + 3, nY + 3) );
     }
     else
     {
-        maVirDev->DrawRect( Rectangle( nX+0, nY+3, nX+0, nY+3 ) );
-        maVirDev->DrawRect( Rectangle( nX+1, nY+2, nX+1, nY+4 ) );
-        maVirDev->DrawRect( Rectangle( nX+2, nY+1, nX+2, nY+5 ) );
-        maVirDev->DrawRect( Rectangle( nX+3, nY+0, nX+3, nY+6 ) );
+        rRenderContext.DrawRect(Rectangle(nX + 0, nY + 3, nX + 0, nY + 3));
+        rRenderContext.DrawRect(Rectangle(nX + 1, nY + 2, nX + 1, nY + 4));
+        rRenderContext.DrawRect(Rectangle(nX + 2, nY + 1, nX + 2, nY + 5));
+        rRenderContext.DrawRect(Rectangle(nX + 3, nY + 0, nX + 3, nY + 6));
     }
 }
 
@@ -281,11 +281,11 @@ Rectangle SwCommentRuler::GetCommentControlRegion()
 
 Color SwCommentRuler::GetFadedColor(const Color &rHighColor, const Color &rLowColor)
 {
-    if ( ! maFadeTimer.IsActive() )
+    if (!maFadeTimer.IsActive())
         return mbIsHighlighted ? rHighColor : rLowColor;
 
     Color aColor = rHighColor;
-    aColor.Merge( rLowColor, mnFadeRate * 255/100.f );
+    aColor.Merge(rLowColor, mnFadeRate * 255 / 100.0f);
     return aColor;
 }
 
commit ce17f392522ac9d77bd9ffb409a349f5e65efa83
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri May 15 16:46:28 2015 +0900

    fix starmath tests
    
    Change-Id: I0fc6fc4a1ce71507f97797dcfe77a6d5b21e4b80

diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 12f5c4c..3633cb6 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -740,6 +740,16 @@ SmViewShell * SmCmdBoxWindow::GetView()
 
 void SmCmdBoxWindow::Resize()
 {
+     Rectangle aRect = Rectangle(Point(0, 0), GetOutputSizePixel());
+     aRect.Left()   += CMD_BOX_PADDING;
+     aRect.Top()    += CMD_BOX_PADDING_TOP;
+     aRect.Right()  -= CMD_BOX_PADDING;
+     aRect.Bottom() -= CMD_BOX_PADDING;
+
+    DecorationView aView(this);
+    aRect = aView.DrawFrame(aRect, DrawFrameStyle::In, DrawFrameFlags::NoDraw);
+
+    aEdit->SetPosSizePixel(aRect.TopLeft(), aRect.GetSize());
     SfxDockingWindow::Resize();
     Invalidate();
 }


More information about the Libreoffice-commits mailing list