Move OutputDevice members to VclPtr: starmath, svx.

Change-Id: I1a5174334f41bc319e0806b9d324be64ba6d0135
diff --git a/include/svx/dialcontrol.hxx b/include/svx/dialcontrol.hxx
index 58ae42a..787a0ca2 100644
--- a/include/svx/dialcontrol.hxx
+++ b/include/svx/dialcontrol.hxx
@@ -124,9 +124,9 @@ public:
protected:
    struct DialControl_Impl
    {
        std::unique_ptr<DialControlBmp> mxBmpEnabled;
        std::unique_ptr<DialControlBmp> mxBmpDisabled;
        std::unique_ptr<DialControlBmp> mxBmpBuffered;
        ScopedVclPtr<DialControlBmp> mpBmpEnabled;
        ScopedVclPtr<DialControlBmp> mpBmpDisabled;
        ScopedVclPtr<DialControlBmp> mpBmpBuffered;
        Link                maModifyHdl;
        VclPtr<NumericField>       mpLinkField;
        sal_Int32           mnLinkedFieldValueMultiplyer;
diff --git a/include/svx/dlgctrl.hxx b/include/svx/dlgctrl.hxx
index 15794fa..9dd1241 100644
--- a/include/svx/dlgctrl.hxx
+++ b/include/svx/dlgctrl.hxx
@@ -358,8 +358,8 @@ class SdrModel;
class SvxPreviewBase : public Control
{
private:
    SdrModel*                                       mpModel;
    VirtualDevice*                                  mpBufferDevice;
    SdrModel*             mpModel;
    VclPtr<VirtualDevice> mpBufferDevice;

protected:
    void InitSettings(bool bForeground, bool bBackground);
diff --git a/include/svx/float3d.hxx b/include/svx/float3d.hxx
index 44d6280..4f12058 100644
--- a/include/svx/float3d.hxx
+++ b/include/svx/float3d.hxx
@@ -171,7 +171,7 @@ private:

    // Model, Page, View etc. for favourites
    FmFormModel*        pModel;
    VirtualDevice*      pVDev;
    VclPtr<VirtualDevice> pVDev;
    E3dView*            p3DView;

    SfxBindings*                pBindings;
diff --git a/include/svx/numvset.hxx b/include/svx/numvset.hxx
index 3742199..d4a13cb 100644
--- a/include/svx/numvset.hxx
+++ b/include/svx/numvset.hxx
@@ -53,7 +53,7 @@ class SVX_DLLPUBLIC SvxNumValueSet : public ValueSet
    sal_uInt16      nPageType;
    bool            bHTMLMode;
    Rectangle       aOrgRect;
    VirtualDevice*  pVDev;
    VclPtr<VirtualDevice> pVDev;

    com::sun::star::uno::Reference<com::sun::star::text::XNumberingFormatter> xFormatter;
    com::sun::star::lang::Locale aLocale;
diff --git a/starmath/inc/dialog.hxx b/starmath/inc/dialog.hxx
index 9a0bb75..df824c7 100644
--- a/starmath/inc/dialog.hxx
+++ b/starmath/inc/dialog.hxx
@@ -154,7 +154,7 @@ class SmFontTypeDialog : public ModalDialog
    VclPtr<MenuButton> m_pMenuButton;
    VclPtr<PushButton> m_pDefaultButton;

    OutputDevice       *pFontListDev;
    VclPtr<OutputDevice> pFontListDev;

    DECL_LINK(MenuSelectHdl, Menu *);
    DECL_LINK(DefaultButtonClickHdl, Button *);
@@ -359,7 +359,7 @@ class SmSymbolDialog : public ModalDialog
    OUString       aSymbolSetName;
    SymbolPtrVec_t      aSymbolSet;

    OutputDevice       *pFontListDev;
    VclPtr<OutputDevice> pFontListDev;

    DECL_LINK(SymbolSetChangeHdl, void*);
    DECL_LINK(SymbolChangeHdl, void*);
diff --git a/starmath/inc/smmod.hxx b/starmath/inc/smmod.hxx
index 7d26cd9..640d20f 100644
--- a/starmath/inc/smmod.hxx
+++ b/starmath/inc/smmod.hxx
@@ -90,7 +90,7 @@ class SmModule : public SfxModule, utl::ConfigurationListener
    SmConfig                *pConfig;
    SmLocalizedSymbolData   *pLocSymbolData;
    SvtSysLocale            *pSysLocale;
    VirtualDevice           *pVirtualDev;
    VclPtr<VirtualDevice>    pVirtualDev;

    void _CreateSysLocale() const;
    void _CreateVirtualDev() const;
diff --git a/starmath/inc/visitors.hxx b/starmath/inc/visitors.hxx
index 5ae1277..1d26ddc 100644
--- a/starmath/inc/visitors.hxx
+++ b/starmath/inc/visitors.hxx
@@ -144,7 +144,7 @@ public:
    }
private:
    SmCaretLine line;
    OutputDevice *pDev;
    VclPtr<OutputDevice> pDev;
    SmCaretPos pos;
protected:
    /** Default method for computing lines for pNodes */
diff --git a/starmath/source/smmod.cxx b/starmath/source/smmod.cxx
index e6b12c4..9390921 100644
--- a/starmath/source/smmod.cxx
+++ b/starmath/source/smmod.cxx
@@ -183,7 +183,7 @@ SmModule::~SmModule()
    delete pColorConfig;
    delete pLocSymbolData;
    delete pSysLocale;
    delete pVirtualDev;
    pVirtualDev.disposeAndClear();
}

void SmModule::_CreateSysLocale() const
diff --git a/svx/inc/sdr/overlay/overlaymanagerbuffered.hxx b/svx/inc/sdr/overlay/overlaymanagerbuffered.hxx
index 4063d52..05db312 100644
--- a/svx/inc/sdr/overlay/overlaymanagerbuffered.hxx
+++ b/svx/inc/sdr/overlay/overlaymanagerbuffered.hxx
@@ -36,11 +36,11 @@ namespace sdr
        protected:
            // The VirtualDevice for draw window content buffering, this
            // is the view content without overlay
            VirtualDevice                           maBufferDevice;
            ScopedVclPtr<VirtualDevice>             mpBufferDevice;

            // #i73602# The VirtualDevice for OverlayPaint buffering. This
            // is an extra device to avoid flickering of overlay paints
            VirtualDevice                           maOutputBufferDevice;
            ScopedVclPtr<VirtualDevice>             mpOutputBufferDevice;

            // Idle for buffering
            Idle                                    maBufferIdle;
diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx
index ba5d023..95584d7 100644
--- a/svx/source/dialog/dlgctrl.cxx
+++ b/svx/source/dialog/dlgctrl.cxx
@@ -1843,7 +1843,7 @@ SvxPreviewBase::~SvxPreviewBase()
void SvxPreviewBase::dispose()
{
    delete mpModel;
    delete mpBufferDevice;
    mpBufferDevice.disposeAndClear();
    Control::dispose();
}

diff --git a/svx/source/dialog/fntctrl.cxx b/svx/source/dialog/fntctrl.cxx
index a633315..10da7e2 100644
--- a/svx/source/dialog/fntctrl.cxx
+++ b/svx/source/dialog/fntctrl.cxx
@@ -128,8 +128,8 @@ class FontPrevWin_Impl
    friend class SvxFontPrevWindow;

    SvxFont                         aFont;
    Printer*                        pPrinter;
    bool                        bDelPrinter;
    VclPtr<Printer>                 pPrinter;
    bool                            bDelPrinter;

    Reference < XBreakIterator >    xBreak;
    std::vector<sal_uIntPtr>        aTextWidth;
@@ -183,7 +183,7 @@ public:
        delete pColor;
        delete pBackColor;
        if( bDelPrinter )
            delete pPrinter;
            pPrinter.disposeAndClear();
    }

    void                CheckScript();
diff --git a/svx/source/dialog/frmsel.cxx b/svx/source/dialog/frmsel.cxx
index 305b226..3a8969d 100644
--- a/svx/source/dialog/frmsel.cxx
+++ b/svx/source/dialog/frmsel.cxx
@@ -209,6 +209,7 @@ FrameBorderType FrameBorder::GetKeyboardNeighbor( sal_uInt16 nKeyCode ) const
FrameSelectorImpl::FrameSelectorImpl( FrameSelector& rFrameSel ) :
    Resource( SVX_RES( RID_SVXSTR_BORDER_CONTROL ) ),
    mrFrameSel( rFrameSel ),
    mpVirDev( new VirtualDevice() ),
    maILArrows( 16 ),
    maLeft( FRAMEBORDER_LEFT ),
    maRight( FRAMEBORDER_RIGHT ),
@@ -346,7 +347,7 @@ void FrameSelectorImpl::InitGlobalGeometry()

    /*  The final size of the usable area. */
    mnCtrlSize = 2 * nBetwBordersSize + nFixedSize;
    maVirDev.SetOutputSizePixel( Size( mnCtrlSize, mnCtrlSize ) );
    mpVirDev->SetOutputSizePixel( Size( mnCtrlSize, mnCtrlSize ) );

    /*  Center the virtual device in the control. */
    maVirDevPos = Point( (aCtrlSize.Width() - mnCtrlSize) / 2, (aCtrlSize.Height() - mnCtrlSize) / 2 );
@@ -518,14 +519,14 @@ FrameBorder& FrameSelectorImpl::GetBorderAccess( FrameBorderType eBorder )
void FrameSelectorImpl::DrawBackground()
{
    // clear the area
    maVirDev.SetLineColor();
    maVirDev.SetFillColor( maBackCol );
    maVirDev.DrawRect( Rectangle( Point( 0, 0 ), maVirDev.GetOutputSizePixel() ) );
    mpVirDev->SetLineColor();
    mpVirDev->SetFillColor( maBackCol );
    mpVirDev->DrawRect( Rectangle( Point( 0, 0 ), mpVirDev->GetOutputSizePixel() ) );

    // draw the inner gray (or whatever color) rectangle
    maVirDev.SetLineColor();
    maVirDev.SetFillColor( maMarkCol );
    maVirDev.DrawRect( Rectangle(
    mpVirDev->SetLineColor();
    mpVirDev->SetFillColor( maMarkCol );
    mpVirDev->DrawRect( Rectangle(
        mnLine1 - mnFocusOffs, mnLine1 - mnFocusOffs, mnLine3 + mnFocusOffs, mnLine3 + mnFocusOffs ) );

    // draw the white space for enabled frame borders
@@ -533,9 +534,9 @@ void FrameSelectorImpl::DrawBackground()
    for( FrameBorderCIter aIt( maEnabBorders ); aIt.Is(); ++aIt )
        (*aIt)->MergeFocusToPolyPolygon( aPPoly );
    aPPoly.Optimize( PolyOptimizeFlags::CLOSE );
    maVirDev.SetLineColor( maBackCol );
    maVirDev.SetFillColor( maBackCol );
    maVirDev.DrawPolyPolygon( aPPoly );
    mpVirDev->SetLineColor( maBackCol );
    mpVirDev->SetFillColor( maBackCol );
    mpVirDev->DrawPolyPolygon( aPPoly );
}

void FrameSelectorImpl::DrawArrows( const FrameBorder& rBorder )
@@ -588,8 +589,8 @@ void FrameSelectorImpl::DrawArrows( const FrameBorder& rBorder )

    // Arrow or marker? Do not draw arrows into disabled control.
    sal_uInt16 nSelectAdd = (mrFrameSel.IsEnabled() && rBorder.IsSelected()) ? 0 : 8;
    maVirDev.DrawImage( aPos1, maILArrows.GetImage( nImgId1 + nSelectAdd ) );
    maVirDev.DrawImage( aPos2, maILArrows.GetImage( nImgId2 + nSelectAdd ) );
    mpVirDev->DrawImage( aPos1, maILArrows.GetImage( nImgId1 + nSelectAdd ) );
    mpVirDev->DrawImage( aPos2, maILArrows.GetImage( nImgId2 + nSelectAdd ) );
}

void FrameSelectorImpl::DrawAllArrows()
@@ -657,7 +658,7 @@ void FrameSelectorImpl::DrawAllFrameBorders()
            maArray.SetCellStyleDiag( nCol, nRow, maTLBR.GetUIStyle(), maBLTR.GetUIStyle() );

    // Let the helper array draw itself
    maArray.DrawArray( maVirDev );
    maArray.DrawArray( *mpVirDev.get() );
}

void FrameSelectorImpl::DrawVirtualDevice()
@@ -672,7 +673,7 @@ void FrameSelectorImpl::CopyVirDevToControl()
{
    if( mbFullRepaint )
        DrawVirtualDevice();
    mrFrameSel.DrawBitmap( maVirDevPos, maVirDev.GetBitmap( Point( 0, 0 ), maVirDev.GetOutputSizePixel() ) );
    mrFrameSel.DrawBitmap( maVirDevPos, mpVirDev->GetBitmap( Point( 0, 0 ), mpVirDev->GetOutputSizePixel() ) );
}

void FrameSelectorImpl::DrawAllTrackingRects()
@@ -686,7 +687,7 @@ void FrameSelectorImpl::DrawAllTrackingRects()
    }
    else
        // no frame border selected -> draw tracking rectangle around entire control
        aPPoly.Insert( Polygon( Rectangle( maVirDevPos, maVirDev.GetOutputSizePixel() ) ) );
        aPPoly.Insert( Polygon( Rectangle( maVirDevPos, mpVirDev->GetOutputSizePixel() ) ) );

    aPPoly.Optimize( PolyOptimizeFlags::CLOSE );
    for( sal_uInt16 nIdx = 0, nCount = aPPoly.Count(); nIdx < nCount; ++nIdx )
diff --git a/svx/source/dialog/svxbmpnumvalueset.cxx b/svx/source/dialog/svxbmpnumvalueset.cxx
index 7ac8567..32fbdd0 100644
--- a/svx/source/dialog/svxbmpnumvalueset.cxx
+++ b/svx/source/dialog/svxbmpnumvalueset.cxx
@@ -428,7 +428,7 @@ SvxNumValueSet::~SvxNumValueSet()

void SvxNumValueSet::dispose()
{
    delete pVDev;
    pVDev.disposeAndClear();
    ValueSet::dispose();
}

diff --git a/svx/source/engine3d/float3d.cxx b/svx/source/engine3d/float3d.cxx
index f413b14..4ee0b01 100644
--- a/svx/source/engine3d/float3d.cxx
+++ b/svx/source/engine3d/float3d.cxx
@@ -331,7 +331,7 @@ Svx3DWin::~Svx3DWin()
void Svx3DWin::dispose()
{
    delete p3DView;
    delete pVDev;
    pVDev.disposeAndClear();
    delete pModel;

    delete pControllerItem;
diff --git a/svx/source/form/fmobj.cxx b/svx/source/form/fmobj.cxx
index 7d7bd1b..8c481a0 100644
--- a/svx/source/form/fmobj.cxx
+++ b/svx/source/form/fmobj.cxx
@@ -112,7 +112,7 @@ void FmFormObj::impl_checkRefDevice_nothrow( bool _force )
        return;

    OutputDevice* pCurrentRefDevice = pFormModel ? pFormModel->GetRefDevice() : NULL;
    if ( ( m_pLastKnownRefDevice == pCurrentRefDevice ) && !_force )
    if ( ( m_pLastKnownRefDevice.get() == pCurrentRefDevice ) && !_force )
        return;

    Reference< XControlModel > xControlModel( GetUnoControlModel() );
@@ -120,7 +120,7 @@ void FmFormObj::impl_checkRefDevice_nothrow( bool _force )
        return;

    m_pLastKnownRefDevice = pCurrentRefDevice;
    if ( m_pLastKnownRefDevice == NULL )
    if ( !m_pLastKnownRefDevice )
        return;

    try
diff --git a/svx/source/inc/fmobj.hxx b/svx/source/inc/fmobj.hxx
index 01ff874..38ff2b6 100644
--- a/svx/source/inc/fmobj.hxx
+++ b/svx/source/inc/fmobj.hxx
@@ -42,7 +42,7 @@ class SVX_DLLPUBLIC FmFormObj: public SdrUnoObj
    ::com::sun::star::uno::Reference< ::com::sun::star::form::XForms >                  m_xEnvironmentHistory;
    sal_Int32           m_nPos;

    OutputDevice*       m_pLastKnownRefDevice;
    VclPtr<OutputDevice>   m_pLastKnownRefDevice;
                            // the last ref device we know, as set at the model
                            // only to be used for comparison with the current ref device!

diff --git a/svx/source/inc/frmselimpl.hxx b/svx/source/inc/frmselimpl.hxx
index 702b2c4..51d94e1 100644
--- a/svx/source/inc/frmselimpl.hxx
+++ b/svx/source/inc/frmselimpl.hxx
@@ -97,7 +97,7 @@ struct FrameSelectorImpl : public Resource
    typedef std::vector< XAccessibleRef >               XAccessibleRefVec;

    FrameSelector&      mrFrameSel;     /// The control itself.
    VirtualDevice       maVirDev;       /// For all buffered drawing operations.
    ScopedVclPtr<VirtualDevice> mpVirDev; /// For all buffered drawing operations.
    ImageList           maILArrows;     /// Arrows in current system colors.
    Color               maBackCol;      /// Background color.
    Color               maArrowCol;     /// Selection arrow color.
diff --git a/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx
index c59fdb2..1ad7f6e 100644
--- a/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx
+++ b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx
@@ -521,7 +521,7 @@ namespace sdr { namespace contact {
        Reference< XContainer >         m_xContainer;

        /// the output device for which the control was created
        const OutputDevice*             m_pOutputDeviceForWindow;
        VclPtr<OutputDevice>            m_pOutputDeviceForWindow;

        /// flag indicating whether the control is currently visible
        bool                            m_bControlIsVisible;
@@ -1038,7 +1038,7 @@ namespace sdr { namespace contact {

        if ( m_aControl.is() )
        {
            if ( m_pOutputDeviceForWindow == &_rDevice )
            if ( m_pOutputDeviceForWindow.get() == const_cast<OutputDevice *>( &_rDevice ) )
                return true;

            // Somebody requested a control for a new device, which means either of
@@ -1062,7 +1062,7 @@ namespace sdr { namespace contact {
        if ( !createControlForDevice( _rPageView, _rDevice, *pUnoObject, _rInitialViewTransformation, m_aZoomLevelNormalization, aControl ) )
            return false;

        m_pOutputDeviceForWindow = &_rDevice;
        m_pOutputDeviceForWindow = const_cast< OutputDevice * >( &_rDevice );
        m_aControl = aControl;
        m_xContainer.set(_rPageView.getControlContainer( _rDevice ), css::uno::UNO_QUERY);
        DBG_ASSERT( (   m_xContainer.is()                                           // either have a XControlContainer
diff --git a/svx/source/sdr/overlay/overlaymanagerbuffered.cxx b/svx/source/sdr/overlay/overlaymanagerbuffered.cxx
index 518db4a..0213942 100644
--- a/svx/source/sdr/overlay/overlaymanagerbuffered.cxx
+++ b/svx/source/sdr/overlay/overlaymanagerbuffered.cxx
@@ -38,46 +38,46 @@ namespace sdr
    {
        void OverlayManagerBuffered::ImpPrepareBufferDevice()
        {
            // compare size of maBufferDevice with size of visible area
            if(maBufferDevice.GetOutputSizePixel() != getOutputDevice().GetOutputSizePixel())
            // compare size of mpBufferDevice with size of visible area
            if(mpBufferDevice->GetOutputSizePixel() != getOutputDevice().GetOutputSizePixel())
            {
                // set new buffer size, copy as much content as possible (use bool parameter for vcl).
                // Newly uncovered regions will be repainted.
                maBufferDevice.SetOutputSizePixel(getOutputDevice().GetOutputSizePixel(), false);
                mpBufferDevice->SetOutputSizePixel(getOutputDevice().GetOutputSizePixel(), false);
            }

            // compare the MapModes for zoom/scroll changes
            if(maBufferDevice.GetMapMode() != getOutputDevice().GetMapMode())
            if(mpBufferDevice->GetMapMode() != getOutputDevice().GetMapMode())
            {
                const bool bZoomed(
                    maBufferDevice.GetMapMode().GetScaleX() != getOutputDevice().GetMapMode().GetScaleX()
                    || maBufferDevice.GetMapMode().GetScaleY() != getOutputDevice().GetMapMode().GetScaleY());
                    mpBufferDevice->GetMapMode().GetScaleX() != getOutputDevice().GetMapMode().GetScaleX()
                    || mpBufferDevice->GetMapMode().GetScaleY() != getOutputDevice().GetMapMode().GetScaleY());

                if(!bZoomed)
                {
                    const Point& rOriginOld = maBufferDevice.GetMapMode().GetOrigin();
                    const Point& rOriginOld = mpBufferDevice->GetMapMode().GetOrigin();
                    const Point& rOriginNew = getOutputDevice().GetMapMode().GetOrigin();
                    const bool bScrolled(rOriginOld != rOriginNew);

                    if(bScrolled)
                    {
                        // get pixel bounds
                        const Point aOriginOldPixel(maBufferDevice.LogicToPixel(rOriginOld));
                        const Point aOriginNewPixel(maBufferDevice.LogicToPixel(rOriginNew));
                        const Size aOutputSizePixel(maBufferDevice.GetOutputSizePixel());
                        const Point aOriginOldPixel(mpBufferDevice->LogicToPixel(rOriginOld));
                        const Point aOriginNewPixel(mpBufferDevice->LogicToPixel(rOriginNew));
                        const Size aOutputSizePixel(mpBufferDevice->GetOutputSizePixel());

                        // remember and switch off MapMode
                        const bool bMapModeWasEnabled(maBufferDevice.IsMapModeEnabled());
                        maBufferDevice.EnableMapMode(false);
                        const bool bMapModeWasEnabled(mpBufferDevice->IsMapModeEnabled());
                        mpBufferDevice->EnableMapMode(false);

                        // scroll internally buffered stuff
                        const Point aDestinationOffsetPixel(aOriginNewPixel - aOriginOldPixel);
                        maBufferDevice.DrawOutDev(
                        mpBufferDevice->DrawOutDev(
                            aDestinationOffsetPixel, aOutputSizePixel, // destination
                            Point(), aOutputSizePixel); // source

                        // restore MapMode
                        maBufferDevice.EnableMapMode(bMapModeWasEnabled);
                        mpBufferDevice->EnableMapMode(bMapModeWasEnabled);

                        // scroll remembered region, too.
                        if(!maBufferRememberedRangePixel.isEmpty())
@@ -91,13 +91,13 @@ namespace sdr
                }

                // copy new MapMode
                maBufferDevice.SetMapMode(getOutputDevice().GetMapMode());
                mpBufferDevice->SetMapMode(getOutputDevice().GetMapMode());
            }

            // #i29186#
            maBufferDevice.SetDrawMode(getOutputDevice().GetDrawMode());
            maBufferDevice.SetSettings(getOutputDevice().GetSettings());
            maBufferDevice.SetAntialiasing(getOutputDevice().GetAntialiasing());
            mpBufferDevice->SetDrawMode(getOutputDevice().GetDrawMode());
            mpBufferDevice->SetSettings(getOutputDevice().GetSettings());
            mpBufferDevice->SetAntialiasing(getOutputDevice().GetAntialiasing());
        }

        void OverlayManagerBuffered::ImpRestoreBackground() const
@@ -114,9 +114,9 @@ namespace sdr
        {
            // MapModes off
            const bool bMapModeWasEnabledDest(getOutputDevice().IsMapModeEnabled());
            const bool bMapModeWasEnabledSource(maBufferDevice.IsMapModeEnabled());
            const bool bMapModeWasEnabledSource(mpBufferDevice->IsMapModeEnabled());
            getOutputDevice().EnableMapMode(false);
            const_cast<OverlayManagerBuffered*>(this)->maBufferDevice.EnableMapMode(false);
            const_cast<OverlayManagerBuffered*>(this)->mpBufferDevice->EnableMapMode(false);

            // local region
            RectangleVector aRectangles;
@@ -143,12 +143,12 @@ namespace sdr
                getOutputDevice().DrawOutDev(
                    aTopLeft, aSize, // destination
                    aTopLeft, aSize, // source
                    maBufferDevice);
                    *mpBufferDevice.get());
            }

            // restore MapModes
            getOutputDevice().EnableMapMode(bMapModeWasEnabledDest);
            const_cast<OverlayManagerBuffered*>(this)->maBufferDevice.EnableMapMode(bMapModeWasEnabledSource);
            const_cast<OverlayManagerBuffered*>(this)->maBufferDevice->EnableMapMode(bMapModeWasEnabledSource);
        }

        void OverlayManagerBuffered::ImpSaveBackground(const vcl::Region& rRegion, OutputDevice* pPreRenderDevice)
@@ -176,14 +176,14 @@ namespace sdr
            }

            // also limit to buffer size
            const Rectangle aBufferDeviceRectanglePixel(Point(), maBufferDevice.GetOutputSizePixel());
            const Rectangle aBufferDeviceRectanglePixel(Point(), mpBufferDevice->GetOutputSizePixel());
            aRegion.Intersect(aBufferDeviceRectanglePixel);

            // MapModes off
            const bool bMapModeWasEnabledDest(rSource.IsMapModeEnabled());
            const bool bMapModeWasEnabledSource(maBufferDevice.IsMapModeEnabled());
            const bool bMapModeWasEnabledSource(mpBufferDevice->IsMapModeEnabled());
            rSource.EnableMapMode(false);
            maBufferDevice.EnableMapMode(false);
            mpBufferDevice->EnableMapMode(false);

            // prepare to iterate over the rectangles from the region in pixels
            RectangleVector aRectangles;
@@ -195,7 +195,7 @@ namespace sdr
                const Point aTopLeft(aRectIter->TopLeft());
                const Size aSize(aRectIter->GetSize());

                maBufferDevice.DrawOutDev(
                mpBufferDevice->DrawOutDev(
                    aTopLeft, aSize, // destination
                    aTopLeft, aSize, // source
                    rSource);
@@ -203,7 +203,7 @@ namespace sdr

            // restore MapModes
            rSource.EnableMapMode(bMapModeWasEnabledDest);
            maBufferDevice.EnableMapMode(bMapModeWasEnabledSource);
            mpBufferDevice->EnableMapMode(bMapModeWasEnabledSource);
        }

        IMPL_LINK(OverlayManagerBuffered, ImpBufferTimerHandler, AutoTimer*, /*pTimer*/)
@@ -241,20 +241,20 @@ namespace sdr

                if(DoRefreshWithPreRendering())
                {
                    // #i73602# ensure valid and sized maOutputBufferDevice
                    const Size aDestinationSizePixel(maBufferDevice.GetOutputSizePixel());
                    const Size aOutputBufferSizePixel(maOutputBufferDevice.GetOutputSizePixel());
                    // #i73602# ensure valid and sized mpOutputBufferDevice
                    const Size aDestinationSizePixel(mpBufferDevice->GetOutputSizePixel());
                    const Size aOutputBufferSizePixel(mpOutputBufferDevice->GetOutputSizePixel());

                    if(aDestinationSizePixel != aOutputBufferSizePixel)
                    {
                        maOutputBufferDevice.SetOutputSizePixel(aDestinationSizePixel);
                        mpOutputBufferDevice->SetOutputSizePixel(aDestinationSizePixel);
                    }

                    maOutputBufferDevice.SetMapMode(getOutputDevice().GetMapMode());
                    maOutputBufferDevice.EnableMapMode(false);
                    maOutputBufferDevice.SetDrawMode(maBufferDevice.GetDrawMode());
                    maOutputBufferDevice.SetSettings(maBufferDevice.GetSettings());
                    maOutputBufferDevice.SetAntialiasing(maBufferDevice.GetAntialiasing());
                    mpOutputBufferDevice->SetMapMode(getOutputDevice().GetMapMode());
                    mpOutputBufferDevice->EnableMapMode(false);
                    mpOutputBufferDevice->SetDrawMode(mpBufferDevice->GetDrawMode());
                    mpOutputBufferDevice->SetSettings(mpBufferDevice->GetSettings());
                    mpOutputBufferDevice->SetAntialiasing(mpBufferDevice->GetAntialiasing());

                    // calculate sizes
                    Rectangle aRegionRectanglePixel(
@@ -289,23 +289,23 @@ namespace sdr
                    const Size aSize(aRegionRectanglePixel.GetSize());

                    {
                        const bool bMapModeWasEnabledDest(maBufferDevice.IsMapModeEnabled());
                        maBufferDevice.EnableMapMode(false);
                        const bool bMapModeWasEnabledDest(mpBufferDevice->IsMapModeEnabled());
                        mpBufferDevice->EnableMapMode(false);

                        maOutputBufferDevice.DrawOutDev(
                        mpOutputBufferDevice->DrawOutDev(
                            aTopLeft, aSize, // destination
                            aTopLeft, aSize, // source
                            maBufferDevice);
                            *mpBufferDevice.get());

                        // restore MapModes
                        maBufferDevice.EnableMapMode(bMapModeWasEnabledDest);
                        mpBufferDevice->EnableMapMode(bMapModeWasEnabledDest);
                    }

                    // paint overlay content for remembered region, use
                    // method from base class directly
                    maOutputBufferDevice.EnableMapMode(true);
                    OverlayManager::ImpDrawMembers(aBufferRememberedRangeLogic, maOutputBufferDevice);
                    maOutputBufferDevice.EnableMapMode(false);
                    mpOutputBufferDevice->EnableMapMode(true);
                    OverlayManager::ImpDrawMembers(aBufferRememberedRangeLogic, *mpOutputBufferDevice.get());
                    mpOutputBufferDevice->EnableMapMode(false);

                    // copy to output
                    {
@@ -315,7 +315,7 @@ namespace sdr
                        getOutputDevice().DrawOutDev(
                            aTopLeft, aSize, // destination
                            aTopLeft, aSize, // source
                            maOutputBufferDevice);
                            *mpOutputBufferDevice.get());

                        // debug
                        /*getOutputDevice().SetLineColor(COL_RED);
@@ -381,6 +381,8 @@ namespace sdr
            const SdrModel* pModel,
            bool bRefreshWithPreRendering)
        :   OverlayManager(rOutputDevice, pModel),
            mpBufferDevice(new VirtualDevice()),
            mpOutputBufferDevice(new VirtualDevice()),
            mbRefreshWithPreRendering(bRefreshWithPreRendering)
        {
            // Init timer
@@ -432,7 +434,7 @@ namespace sdr
        void OverlayManagerBuffered::copyArea(const Point& rDestPt, const Point& rSrcPt, const Size& rSrcSize)
        {
            // scroll local buffered area
            maBufferDevice.CopyArea(rDestPt, rSrcPt, rSrcSize);
            mpBufferDevice->CopyArea(rDestPt, rSrcPt, rSrcSize);
        }

        void OverlayManagerBuffered::restoreBackground(const vcl::Region& rRegion) const
diff --git a/svx/source/sidebar/line/LineWidthValueSet.cxx b/svx/source/sidebar/line/LineWidthValueSet.cxx
index c57196f..532a11c 100644
--- a/svx/source/sidebar/line/LineWidthValueSet.cxx
+++ b/svx/source/sidebar/line/LineWidthValueSet.cxx
@@ -46,14 +46,11 @@ LineWidthValueSet::~LineWidthValueSet()

void LineWidthValueSet::dispose()
{
    delete pVDev;
    pVDev.disposeAndClear();
    delete[] strUnit;
    ValueSet::dispose();
}




void LineWidthValueSet::SetUnit(OUString* str)
{
    for(int i = 0; i < 9; i++)
diff --git a/svx/source/sidebar/line/LineWidthValueSet.hxx b/svx/source/sidebar/line/LineWidthValueSet.hxx
index 55901d2..7cb0203 100644
--- a/svx/source/sidebar/line/LineWidthValueSet.hxx
+++ b/svx/source/sidebar/line/LineWidthValueSet.hxx
@@ -41,7 +41,7 @@ public:
    virtual void    UserDraw( const UserDrawEvent& rUDEvt ) SAL_OVERRIDE;

protected:
    VirtualDevice*  pVDev;
    VclPtr<VirtualDevice> pVDev;
    sal_uInt16          nSelItem;
    OUString*      strUnit;
    Image           imgCus;
diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx
index 133b7ca..7577db5 100644
--- a/svx/source/svdraw/svdfmtf.cxx
+++ b/svx/source/svdraw/svdfmtf.cxx
@@ -78,7 +78,7 @@ ImpSdrGDIMetaFileImport::ImpSdrGDIMetaFileImport(
    SdrLayerID nLay,
    const Rectangle& rRect)
:   maTmpList(),
    maVD(),
    mpVD(new VirtualDevice()),
    maScaleRect(rRect),
    mnMapScalingOfs(0),
    mpLineAttr(0),
@@ -105,10 +105,10 @@ ImpSdrGDIMetaFileImport::ImpSdrGDIMetaFileImport(
    mbLastObjWasLine(false),
    maClip()
{
    maVD.EnableOutput(false);
    maVD.SetLineColor();
    maVD.SetFillColor();
    maOldLineColor.SetRed( maVD.GetLineColor().GetRed() + 1 );
    mpVD->EnableOutput(false);
    mpVD->SetLineColor();
    mpVD->SetFillColor();
    maOldLineColor.SetRed( mpVD->GetLineColor().GetRed() + 1 );
    mpLineAttr = new SfxItemSet(rModel.GetItemPool(), XATTR_LINE_FIRST, XATTR_LINE_LAST, 0, 0);
    mpFillAttr = new SfxItemSet(rModel.GetItemPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0, 0);
    mpTextAttr = new SfxItemSet(rModel.GetItemPool(), EE_ITEMS_START, EE_ITEMS_END, 0, 0);
@@ -340,12 +340,12 @@ void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr
            mpLineAttr->Put(XLineWidthItem(0));
        }

        maOldLineColor = maVD.GetLineColor();
        maOldLineColor = mpVD->GetLineColor();

        if(maVD.IsLineColor())
        if(mpVD->IsLineColor())
        {
            mpLineAttr->Put(XLineStyleItem(drawing::LineStyle_SOLID));
            mpLineAttr->Put(XLineColorItem(OUString(), maVD.GetLineColor()));
            mpLineAttr->Put(XLineColorItem(OUString(), mpVD->GetLineColor()));
        }
        else
        {
@@ -390,10 +390,10 @@ void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr

    if(bFill)
    {
        if(maVD.IsFillColor())
        if(mpVD->IsFillColor())
        {
            mpFillAttr->Put(XFillStyleItem(drawing::FillStyle_SOLID));
            mpFillAttr->Put(XFillColorItem(OUString(), maVD.GetFillColor()));
            mpFillAttr->Put(XFillColorItem(OUString(), mpVD->GetFillColor()));
        }
        else
        {
@@ -407,7 +407,7 @@ void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr

    if(bText && mbFntDirty)
    {
        vcl::Font aFnt(maVD.GetFont());
        vcl::Font aFnt(mpVD->GetFont());
        const sal_uInt32 nHeight(FRound(aFnt.GetSize().Height() * mfScaleY));

        mpTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(), aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO ) );
@@ -429,7 +429,7 @@ void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr

        mpTextAttr->Put(SvxWordLineModeItem(aFnt.IsWordLineMode(), EE_CHAR_WLM));
        mpTextAttr->Put(SvxContourItem(aFnt.IsOutline(), EE_CHAR_OUTLINE));
        mpTextAttr->Put(SvxColorItem(maVD.GetTextColor(), EE_CHAR_COLOR));
        mpTextAttr->Put(SvxColorItem(mpVD->GetTextColor(), EE_CHAR_COLOR));
        //... svxfont textitem svditext
        mbFntDirty = false;
    }
@@ -779,7 +779,7 @@ bool ImpSdrGDIMetaFileImport::CheckLastLineMerge(const basegfx::B2DPolygon& rSrc
    }

    // #i73407# reformulation to use new B2DPolygon classes
    if(mbLastObjWasLine && (maOldLineColor == maVD.GetLineColor()) && rSrcPoly.count())
    if(mbLastObjWasLine && (maOldLineColor == mpVD->GetLineColor()) && rSrcPoly.count())
    {
        SdrObject* pTmpObj = maTmpList.size() ? maTmpList[maTmpList.size() - 1] : 0;
        SdrPathObj* pLastPoly = dynamic_cast< SdrPathObj* >(pTmpObj);
@@ -871,9 +871,9 @@ bool ImpSdrGDIMetaFileImport::CheckLastPolyLineAndFillMerge(const basegfx::B2DPo

void ImpSdrGDIMetaFileImport::checkClip()
{
    if(maVD.IsClipRegion())
    if(mpVD->IsClipRegion())
    {
        maClip = maVD.GetClipRegion().GetAsB2DPolyPolygon();
        maClip = mpVD->GetClipRegion().GetAsB2DPolyPolygon();

        if(isClip())
        {
@@ -984,12 +984,12 @@ void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const OUString& rSt
{
    // calc text box size, add 5% to make it fit safely

    FontMetric aFontMetric( maVD.GetFontMetric() );
    vcl::Font aFnt( maVD.GetFont() );
    FontMetric aFontMetric( mpVD->GetFontMetric() );
    vcl::Font aFnt( mpVD->GetFont() );
    FontAlign eAlg( aFnt.GetAlign() );

    sal_Int32 nTextWidth = (sal_Int32)( maVD.GetTextWidth( rStr ) * mfScaleX );
    sal_Int32 nTextHeight = (sal_Int32)( maVD.GetTextHeight() * mfScaleY );
    sal_Int32 nTextWidth = (sal_Int32)( mpVD->GetTextWidth( rStr ) * mfScaleX );
    sal_Int32 nTextHeight = (sal_Int32)( mpVD->GetTextHeight() * mfScaleY );

    Point aPos( FRound(rPos.X() * mfScaleX + maOfs.X()), FRound(rPos.Y() * mfScaleY + maOfs.Y()) );
    Size aSize( nTextWidth, nTextHeight );
@@ -1168,13 +1168,13 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaHatchAction& rAct )

void ImpSdrGDIMetaFileImport::DoAction(MetaLineColorAction& rAct)
{
    rAct.Execute(&maVD);
    rAct.Execute(mpVD);
}

void ImpSdrGDIMetaFileImport::DoAction(MetaMapModeAction& rAct)
{
    MapScaling();
    rAct.Execute(&maVD);
    rAct.Execute(mpVD);
    mbLastObjWasPolyWithoutLine = false;
    mbLastObjWasLine = false;
}
@@ -1182,7 +1182,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaMapModeAction& rAct)
void ImpSdrGDIMetaFileImport::MapScaling()
{
    const size_t nCount(maTmpList.size());
    const MapMode& rMap = maVD.GetMapMode();
    const MapMode& rMap = mpVD->GetMapMode();
    Point aMapOrg( rMap.GetOrigin() );
    bool bMov2(aMapOrg.X() != 0 || aMapOrg.Y() != 0);

@@ -1276,7 +1276,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaTextRectAction& rAct)
{
    GDIMetaFile aTemp;

    maVD.AddTextRectActions(rAct.GetRect(), rAct.GetText(), rAct.GetStyle(), aTemp);
    mpVD->AddTextRectActions(rAct.GetRect(), rAct.GetText(), rAct.GetStyle(), aTemp);
    DoLoopActions(aTemp, 0, 0);
}

diff --git a/svx/source/svdraw/svdfmtf.hxx b/svx/source/svdraw/svdfmtf.hxx
index 3e317fe..fbdfaef 100644
--- a/svx/source/svdraw/svdfmtf.hxx
+++ b/svx/source/svdraw/svdfmtf.hxx
@@ -45,7 +45,7 @@ class ImpSdrGDIMetaFileImport
{
protected:
    ::std::vector< SdrObject* > maTmpList;
    VirtualDevice               maVD;
    ScopedVclPtr<VirtualDevice> mpVD;
    Rectangle                   maScaleRect;
    size_t                      mnMapScalingOfs; // from here on, not edited with MapScaling
    SfxItemSet*                 mpLineAttr;
@@ -106,18 +106,18 @@ protected:
    void DoAction(MetaHatchAction           & rAct);
    void DoAction(MetaLineColorAction       & rAct);
    void DoAction(MetaMapModeAction         & rAct);
    void DoAction(MetaFillColorAction       & rAct) { rAct.Execute(&maVD); }
    void DoAction(MetaTextColorAction       & rAct) { rAct.Execute(&maVD); }
    void DoAction(MetaTextFillColorAction   & rAct) { rAct.Execute(&maVD); }
    void DoAction(MetaFontAction            & rAct) { rAct.Execute(&maVD); mbFntDirty = true; }
    void DoAction(MetaTextAlignAction       & rAct) { rAct.Execute(&maVD); mbFntDirty = true; }
    void DoAction(MetaClipRegionAction      & rAct) { rAct.Execute(&maVD); checkClip(); }
    void DoAction(MetaRasterOpAction        & rAct) { rAct.Execute(&maVD); }
    void DoAction(MetaPushAction            & rAct) { rAct.Execute(&maVD); checkClip(); }
    void DoAction(MetaPopAction             & rAct) { rAct.Execute(&maVD); mbFntDirty = true; checkClip(); }
    void DoAction(MetaMoveClipRegionAction  & rAct) { rAct.Execute(&maVD); checkClip(); }
    void DoAction(MetaISectRectClipRegionAction& rAct) { rAct.Execute(&maVD); checkClip(); }
    void DoAction(MetaISectRegionClipRegionAction& rAct) { rAct.Execute(&maVD); checkClip(); }
    void DoAction(MetaFillColorAction       & rAct) { rAct.Execute(mpVD); }
    void DoAction(MetaTextColorAction       & rAct) { rAct.Execute(mpVD); }
    void DoAction(MetaTextFillColorAction   & rAct) { rAct.Execute(mpVD); }
    void DoAction(MetaFontAction            & rAct) { rAct.Execute(mpVD); mbFntDirty = true; }
    void DoAction(MetaTextAlignAction       & rAct) { rAct.Execute(mpVD); mbFntDirty = true; }
    void DoAction(MetaClipRegionAction      & rAct) { rAct.Execute(mpVD); checkClip(); }
    void DoAction(MetaRasterOpAction        & rAct) { rAct.Execute(mpVD); }
    void DoAction(MetaPushAction            & rAct) { rAct.Execute(mpVD); checkClip(); }
    void DoAction(MetaPopAction             & rAct) { rAct.Execute(mpVD); mbFntDirty = true; checkClip(); }
    void DoAction(MetaMoveClipRegionAction  & rAct) { rAct.Execute(mpVD); checkClip(); }
    void DoAction(MetaISectRectClipRegionAction& rAct) { rAct.Execute(mpVD); checkClip(); }
    void DoAction(MetaISectRegionClipRegionAction& rAct) { rAct.Execute(mpVD); checkClip(); }

    // #i125211# The MetaCommentAction needs to advance (if used), thus
    // give current metafile and index which may be changed
@@ -134,14 +134,14 @@ protected:
    void DoAction(MetaWallpaperAction& rAct);
    void DoAction(MetaTransparentAction& rAct);
    void DoAction(MetaEPSAction& rAct);
    void DoAction(MetaRefPointAction& rAct)  { rAct.Execute(&maVD); }
    void DoAction(MetaTextLineColorAction& rAct)  { rAct.Execute(&maVD); mbFntDirty = true; }
    void DoAction(MetaRefPointAction& rAct)  { rAct.Execute(mpVD); }
    void DoAction(MetaTextLineColorAction& rAct)  { rAct.Execute(mpVD); mbFntDirty = true; }
    void DoAction(MetaTextLineAction& rAct);
    void DoAction(MetaFloatTransparentAction& rAct);
    void DoAction(MetaGradientExAction& rAct);
    void DoAction(MetaLayoutModeAction& rAct)  { rAct.Execute(&maVD); mbFntDirty = true; }
    void DoAction(MetaTextLanguageAction& rAct)  { rAct.Execute(&maVD); mbFntDirty = true; }
    void DoAction(MetaOverlineColorAction& rAct)  { rAct.Execute(&maVD); mbFntDirty = true; }
    void DoAction(MetaLayoutModeAction& rAct)  { rAct.Execute(mpVD); mbFntDirty = true; }
    void DoAction(MetaTextLanguageAction& rAct)  { rAct.Execute(mpVD); mbFntDirty = true; }
    void DoAction(MetaOverlineColorAction& rAct)  { rAct.Execute(mpVD); mbFntDirty = true; }

    void ImportText(const Point& rPos, const OUString& rStr, const MetaAction& rAct);
    void SetAttributes(SdrObject* pObj, bool bForceTextAttr = false);