Fix OutputDevice members / stack allocation: svx.

Change-Id: Id28aeb44b4c48fec944e21fed7a9acf9f7f8b68a
diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
index 7332449..1b69bc7 100644
--- a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
@@ -165,9 +165,9 @@ void CalculateHorizontalScalingFactor( const SdrObject* pCustomShape,
    aFont.SetOrientation( 0 );
    // initializing virtual device

    VirtualDevice aVirDev( 1 );
    aVirDev.SetMapMode( MAP_100TH_MM );
    aVirDev.SetFont( aFont );
    ScopedVclPtr<VirtualDevice> pVirDev( new VirtualDevice( 1 ) );
    pVirDev->SetMapMode( MAP_100TH_MM );
    pVirDev->SetFont( aFont );

    if ( nOutlinesCount2d & 1 )
        bSingleLineMode = true;
@@ -187,7 +187,7 @@ void CalculateHorizontalScalingFactor( const SdrObject* pCustomShape,
        std::vector< FWParagraphData >::const_iterator aParagraphIEnd( aTextAreaIter->vParagraphs.end() );
        while( aParagraphIter != aParagraphIEnd )
        {
            double fTextWidth = aVirDev.GetTextWidth( aParagraphIter->aString );
            double fTextWidth = pVirDev->GetTextWidth( aParagraphIter->aString );
            if ( fTextWidth > 0.0 )
            {
                double fScale = fWidth / fTextWidth;
@@ -259,12 +259,12 @@ void GetTextAreaOutline( const FWData& rFWData, const SdrObject* pCustomShape, F
            aFont.SetWeight( rWeightItem.GetWeight() );

            // initializing virtual device
            VirtualDevice aVirDev( 1 );
            aVirDev.SetMapMode( MAP_100TH_MM );
            aVirDev.SetFont( aFont );
            aVirDev.EnableRTL( true );
            ScopedVclPtr<VirtualDevice> pVirDev( new VirtualDevice( 1 ) );
            pVirDev->SetMapMode( MAP_100TH_MM );
            pVirDev->SetFont( aFont );
            pVirDev->EnableRTL( true );
            if ( aParagraphIter->nFrameDirection == FRMDIR_HORI_RIGHT_TOP )
                aVirDev.SetLayoutMode( TEXT_LAYOUT_BIDI_RTL );
                pVirDev->SetLayoutMode( TEXT_LAYOUT_BIDI_RTL );

            const SvxCharScaleWidthItem& rCharScaleWidthItem = static_cast<const SvxCharScaleWidthItem&>(pCustomShape->GetMergedItem( EE_CHAR_FONTWIDTH ));
            sal_uInt16 nCharScaleWidth = rCharScaleWidthItem.GetValue();
@@ -282,9 +282,9 @@ void GetTextAreaOutline( const FWData& rFWData, const SdrObject* pCustomShape, F
                {
                    FWCharacterData aCharacterData;
                    OUString aCharText( (sal_Unicode)rText[ i ] );
                    if ( aVirDev.GetTextOutlines( aCharacterData.vOutlines, aCharText, 0, 0, -1, true, nWidth, pDXArry ) )
                    if ( pVirDev->GetTextOutlines( aCharacterData.vOutlines, aCharText, 0, 0, -1, true, nWidth, pDXArry ) )
                    {
                        sal_Int32 nTextWidth = aVirDev.GetTextWidth( aCharText);
                        sal_Int32 nTextWidth = pVirDev->GetTextWidth( aCharText);
                        std::vector< tools::PolyPolygon >::iterator aOutlineIter = aCharacterData.vOutlines.begin();
                        std::vector< tools::PolyPolygon >::iterator aOutlineIEnd = aCharacterData.vOutlines.end();
                        if ( aOutlineIter == aOutlineIEnd )
@@ -334,13 +334,13 @@ void GetTextAreaOutline( const FWData& rFWData, const SdrObject* pCustomShape, F
                if ( ( nCharScaleWidth != 100 ) && nCharScaleWidth )
                {   // applying character spacing
                    pDXArry = new long[ rText.getLength() ];
                    aVirDev.GetTextArray( rText, pDXArry);
                    FontMetric aFontMetric( aVirDev.GetFontMetric() );
                    pVirDev->GetTextArray( rText, pDXArry);
                    FontMetric aFontMetric( pVirDev->GetFontMetric() );
                    aFont.SetWidth( (sal_Int32)( (double)aFontMetric.GetWidth() * ( (double)100 / (double)nCharScaleWidth ) ) );
                    aVirDev.SetFont( aFont );
                    pVirDev->SetFont( aFont );
                }
                FWCharacterData aCharacterData;
                if ( aVirDev.GetTextOutlines( aCharacterData.vOutlines, rText, 0, 0, -1, true, nWidth, pDXArry ) )
                if ( pVirDev->GetTextOutlines( aCharacterData.vOutlines, rText, 0, 0, -1, true, nWidth, pDXArry ) )
                {
                    aParagraphIter->vCharacters.push_back( aCharacterData );
                }
diff --git a/svx/source/dialog/_bmpmask.cxx b/svx/source/dialog/_bmpmask.cxx
index 6eb9fcf..bb95f7ee 100644
--- a/svx/source/dialog/_bmpmask.cxx
+++ b/svx/source/dialog/_bmpmask.cxx
@@ -1006,22 +1006,22 @@ Animation SvxBmpMask::ImpReplaceTransparency( const Animation& rAnim, const Colo

GDIMetaFile SvxBmpMask::ImpReplaceTransparency( const GDIMetaFile& rMtf, const Color& rColor )
{
    VirtualDevice   aVDev;
    ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice() );
    GDIMetaFile     aMtf;
    const MapMode&  rPrefMap = rMtf.GetPrefMapMode();
    const Size&     rPrefSize = rMtf.GetPrefSize();
    const size_t    nActionCount = rMtf.GetActionSize();

    aVDev.EnableOutput( false );
    aMtf.Record( &aVDev );
    pVDev->EnableOutput( false );
    aMtf.Record( pVDev );
    aMtf.SetPrefSize( rPrefSize );
    aMtf.SetPrefMapMode( rPrefMap );
    aVDev.SetLineColor( rColor );
    aVDev.SetFillColor( rColor );
    pVDev->SetLineColor( rColor );
    pVDev->SetFillColor( rColor );

    // retrieve one action at the time; first
    // set the whole area to the replacement color.
    aVDev.DrawRect( Rectangle( rPrefMap.GetOrigin(), rPrefSize ) );
    pVDev->DrawRect( Rectangle( rPrefMap.GetOrigin(), rPrefSize ) );
    for ( size_t i = 0; i < nActionCount; i++ )
    {
        MetaAction* pAct = rMtf.GetAction( i );
diff --git a/svx/source/dialog/_contdlg.cxx b/svx/source/dialog/_contdlg.cxx
index df4dd3e..b7350ae 100644
--- a/svx/source/dialog/_contdlg.cxx
+++ b/svx/source/dialog/_contdlg.cxx
@@ -113,16 +113,16 @@ tools::PolyPolygon SvxContourDlg::CreateAutoContour( const Graphic& rGraphic,
    {
        if( rGraphic.IsAnimated() )
        {
            VirtualDevice       aVDev;
            ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice() );
            MapMode             aTransMap;
            const Animation     aAnim( rGraphic.GetAnimation() );
            const Size&         rSizePix = aAnim.GetDisplaySizePixel();
            const sal_uInt16        nCount = aAnim.Count();

            if ( aVDev.SetOutputSizePixel( rSizePix ) )
            if ( pVDev->SetOutputSizePixel( rSizePix ) )
            {
                aVDev.SetLineColor( Color( COL_BLACK ) );
                aVDev.SetFillColor( Color( COL_BLACK ) );
                pVDev->SetLineColor( Color( COL_BLACK ) );
                pVDev->SetFillColor( Color( COL_BLACK ) );

                for( sal_uInt16 i = 0; i < nCount; i++ )
                {
@@ -131,13 +131,13 @@ tools::PolyPolygon SvxContourDlg::CreateAutoContour( const Graphic& rGraphic,
                    // Push Polygon output to the right place; this is the
                    // offset of the sub-image within the total animation
                    aTransMap.SetOrigin( Point( rStepBmp.aPosPix.X(), rStepBmp.aPosPix.Y() ) );
                    aVDev.SetMapMode( aTransMap );
                    aVDev.DrawPolyPolygon( CreateAutoContour( rStepBmp.aBmpEx, pRect, nFlags ) );
                    pVDev->SetMapMode( aTransMap );
                    pVDev->DrawPolyPolygon( CreateAutoContour( rStepBmp.aBmpEx, pRect, nFlags ) );
                }

                aTransMap.SetOrigin( Point() );
                aVDev.SetMapMode( aTransMap );
                aBmp = aVDev.GetBitmap( Point(), rSizePix );
                pVDev->SetMapMode( aTransMap );
                aBmp = pVDev->GetBitmap( Point(), rSizePix );
                aBmp.Convert( BMP_CONVERSION_1BIT_THRESHOLD );
            }
        }
@@ -152,8 +152,8 @@ tools::PolyPolygon SvxContourDlg::CreateAutoContour( const Graphic& rGraphic,
    else if( rGraphic.GetType() != GRAPHIC_NONE )
    {
        const Graphic   aTmpGrf( rGraphic.GetGDIMetaFile().GetMonochromeMtf( Color( COL_BLACK ) ) );
        VirtualDevice   aVDev;
        Size            aSizePix( aVDev.LogicToPixel( aTmpGrf.GetPrefSize(), aTmpGrf.GetPrefMapMode() ) );
        ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice() );
        Size            aSizePix( pVDev->LogicToPixel( aTmpGrf.GetPrefSize(), aTmpGrf.GetPrefMapMode() ) );

        if( aSizePix.Width() && aSizePix.Height() && ( aSizePix.Width() > 512 || aSizePix.Height() > 512 ) )
        {
@@ -165,11 +165,11 @@ tools::PolyPolygon SvxContourDlg::CreateAutoContour( const Graphic& rGraphic,
                aSizePix.Height() = FRound( ( aSizePix.Width() = 512 ) / fWH );
        }

        if( aVDev.SetOutputSizePixel( aSizePix ) )
        if( pVDev->SetOutputSizePixel( aSizePix ) )
        {
            const Point aPt;
            aTmpGrf.Draw( &aVDev, aPt, aSizePix );
            aBmp = aVDev.GetBitmap( aPt, aSizePix );
            aTmpGrf.Draw( pVDev, aPt, aSizePix );
            aBmp = pVDev->GetBitmap( aPt, aSizePix );
        }

        nContourFlags |= XOUTBMP_CONTOUR_EDGEDETECT;
diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx
index 87d7061..ba5d023 100644
--- a/svx/source/dialog/dlgctrl.cxx
+++ b/svx/source/dialog/dlgctrl.cxx
@@ -1439,8 +1439,8 @@ namespace
    {
        if(!rBitmapEx.IsEmpty() && rSize.Width() > 0 && rSize.Height() > 0)
        {
            VirtualDevice aVirtualDevice;
            aVirtualDevice.SetOutputSizePixel(rSize);
            ScopedVclPtr<VirtualDevice> pVirtualDevice( new VirtualDevice() );
            pVirtualDevice->SetOutputSizePixel(rSize);

            if(rBitmapEx.IsTransparent())
            {
@@ -1453,19 +1453,19 @@ namespace
                    static const Color aW(COL_WHITE);
                    static const Color aG(0xef, 0xef, 0xef);

                    aVirtualDevice.DrawCheckered(aNull, rSize, nLen, aW, aG);
                    pVirtualDevice->DrawCheckered(aNull, rSize, nLen, aW, aG);
                }
                else
                {
                    aVirtualDevice.SetBackground(rStyleSettings.GetFieldColor());
                    aVirtualDevice.Erase();
                    pVirtualDevice->SetBackground(rStyleSettings.GetFieldColor());
                    pVirtualDevice->Erase();
                }
            }

            if(rBitmapEx.GetSizePixel().Width() >= rSize.Width() && rBitmapEx.GetSizePixel().Height() >= rSize.Height())
            {
                rBitmapEx.Scale(rSize, BMP_SCALE_DEFAULT);
                aVirtualDevice.DrawBitmapEx(Point(0, 0), rBitmapEx);
                pVirtualDevice->DrawBitmapEx(Point(0, 0), rBitmapEx);
            }
            else
            {
@@ -1475,14 +1475,14 @@ namespace
                {
                    for(sal_Int32 x(0); x < rSize.Width(); x += aBitmapSize.Width())
                    {
                        aVirtualDevice.DrawBitmapEx(
                        pVirtualDevice->DrawBitmapEx(
                            Point(x, y),
                            rBitmapEx);
                    }
                }
            }

            rBitmapEx = aVirtualDevice.GetBitmap(Point(0, 0), rSize);
            rBitmapEx = pVirtualDevice->GetBitmap(Point(0, 0), rSize);
        }
    }
} // end of anonymous namespace
@@ -1710,7 +1710,7 @@ void LineEndLB::Fill( const XLineEndListRef &pList, bool bStart )
        return;

    long nCount = pList->Count();
    VirtualDevice aVD;
    ScopedVclPtrInstance<VirtualDevice> pVD;
    SetUpdateMode( false );

    for( long i = 0; i < nCount; i++ )
@@ -1720,10 +1720,10 @@ void LineEndLB::Fill( const XLineEndListRef &pList, bool bStart )
        if( !aBitmap.IsEmpty() )
        {
            Size aBmpSize( aBitmap.GetSizePixel() );
            aVD.SetOutputSizePixel( aBmpSize, false );
            aVD.DrawBitmap( Point(), aBitmap );
            pVD->SetOutputSizePixel( aBmpSize, false );
            pVD->DrawBitmap( Point(), aBitmap );
            InsertEntry( pEntry->GetName(),
                Image(aVD.GetBitmap(
                Image(pVD->GetBitmap(
                    (bStart) ? Point() : Point(aBmpSize.Width() / 2, 0),
                    Size(aBmpSize.Width() / 2, aBmpSize.Height()))));
            //delete pBitmap;
@@ -1740,14 +1740,14 @@ void LineEndLB::Append( const XLineEndEntry& rEntry, const Bitmap& rBitmap, bool
{
    if(!rBitmap.IsEmpty())
    {
        VirtualDevice aVD;
        ScopedVclPtr<VirtualDevice> pVD( new VirtualDevice() );
        const Size aBmpSize(rBitmap.GetSizePixel());

        aVD.SetOutputSizePixel(aBmpSize, false);
        aVD.DrawBitmap(Point(), rBitmap);
        pVD->SetOutputSizePixel(aBmpSize, false);
        pVD->DrawBitmap(Point(), rBitmap);
        InsertEntry(
            rEntry.GetName(),
            Image(aVD.GetBitmap(
            Image(pVD->GetBitmap(
                (bStart) ? Point() : Point(aBmpSize.Width() / 2, 0),
                Size(aBmpSize.Width() / 2, aBmpSize.Height()))));
    }
@@ -1765,14 +1765,14 @@ void LineEndLB::Modify( const XLineEndEntry& rEntry, sal_Int32 nPos, const Bitma

    if(!rBitmap.IsEmpty())
    {
        VirtualDevice aVD;
        ScopedVclPtr<VirtualDevice> pVD( new VirtualDevice() );
        const Size aBmpSize(rBitmap.GetSizePixel());

        aVD.SetOutputSizePixel(aBmpSize, false);
        aVD.DrawBitmap(Point(), rBitmap);
        pVD->SetOutputSizePixel(aBmpSize, false);
        pVD->DrawBitmap(Point(), rBitmap);
        InsertEntry(
            rEntry.GetName(),
            Image(aVD.GetBitmap(
            Image(pVD->GetBitmap(
                    (bStart) ? Point() : Point(aBmpSize.Width() / 2, 0),
                    Size(aBmpSize.Width() / 2, aBmpSize.Height()))),
            nPos);
diff --git a/svx/source/dialog/svxruler.cxx b/svx/source/dialog/svxruler.cxx
index 120b5ac..6930ee9 100644
--- a/svx/source/dialog/svxruler.cxx
+++ b/svx/source/dialog/svxruler.cxx
@@ -3457,23 +3457,23 @@ void SvxRuler::Command( const CommandEvent& rCommandEvent )
        {
            PopupMenu aMenu;
            aMenu.SetSelectHdl(LINK(this, SvxRuler, TabMenuSelect));
            VirtualDevice aDev;
            ScopedVclPtrInstance<VirtualDevice()
            const Size aSz(ruler_tab_svx.width + 2, ruler_tab_svx.height + 2);
            aDev.SetOutputSize(aSz);
            aDev.SetBackground(Wallpaper(Color(COL_WHITE)));
            Color aFillColor(aDev.GetSettings().GetStyleSettings().GetShadowColor());
            pDev->SetOutputSize(aSz);
            pDev->SetBackground(Wallpaper(Color(COL_WHITE)));
            Color aFillColor(pDev->GetSettings().GetStyleSettings().GetShadowColor());
            const Point aPt(aSz.Width() / 2, aSz.Height() / 2);

            for ( sal_uInt16 i = RULER_TAB_LEFT; i < RULER_TAB_DEFAULT; ++i )
            {
                sal_uInt16 nStyle = bRTL ? i|RULER_TAB_RTL : i;
                nStyle |= static_cast<sal_uInt16>(bHorz ? WB_HORZ : WB_VERT);
                DrawTab(&aDev, aFillColor, aPt, nStyle);
                DrawTab(pDev, aFillColor, aPt, nStyle);
                aMenu.InsertItem(i + 1,
                                 ResId(RID_SVXSTR_RULER_START + i, DIALOG_MGR()).toString(),
                                 Image(aDev.GetBitmap(Point(), aSz), Color(COL_WHITE)));
                                 Image(pDev->GetBitmap(Point(), aSz), Color(COL_WHITE)));
                aMenu.CheckItem(i + 1, i == mpTabs[mxRulerImpl->nIdx + TAB_GAP].nStyle);
                aDev.SetOutputSize(aSz); // delete device
                pDev->SetOutputSize(aSz); // delete device
            }
            aMenu.Execute( this, rCommandEvent.GetMousePosPixel() );
        }
diff --git a/svx/source/gallery2/galobj.cxx b/svx/source/gallery2/galobj.cxx
index 3205a9c..73e9b37 100644
--- a/svx/source/gallery2/galobj.cxx
+++ b/svx/source/gallery2/galobj.cxx
@@ -484,8 +484,8 @@ bool SgaObjectSvDraw::CreateThumb( const FmFormModel& rModel )

            if(aObjRect.GetWidth() && aObjRect.GetHeight())
            {
                VirtualDevice aVDev;
                FmFormView aView(const_cast< FmFormModel* >(&rModel), &aVDev);
                ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice() );
                FmFormView aView(const_cast< FmFormModel* >(&rModel), pVDev);

                aView.ShowSdrPage(const_cast< FmFormPage* >(pPage));
                aView.MarkAllObj();
diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx
index f037a0b..90243833 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -808,9 +808,9 @@ bool GalleryTheme::GetGraphic( sal_uIntPtr nPos, Graphic& rGraphic, bool bProgre
                            bRet = true;
                        else
                        {
                            VirtualDevice aVDev;
                            aVDev.SetMapMode( MapMode( MAP_100TH_MM ) );
                            FmFormView aView( aModel.GetModel(), &aVDev );
                            ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice() );
                            pVDev->SetMapMode( MapMode( MAP_100TH_MM ) );
                            FmFormView aView( aModel.GetModel(), pVDev );

                            aView.hideMarkHandles();
                            aView.ShowSdrPage(aView.GetModel()->GetPage(0));
diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx
index 70734e9..133b7ca 100644
--- a/svx/source/svdraw/svdfmtf.cxx
+++ b/svx/source/svdraw/svdfmtf.cxx
@@ -1558,12 +1558,12 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct)
        else
        {
            // gradient transparence
            VirtualDevice aVDev;
            ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice() );

            aVDev.SetOutputSizePixel(aBitmapEx.GetBitmap().GetSizePixel());
            aVDev.DrawGradient(Rectangle(Point(0, 0), aVDev.GetOutputSizePixel()), rGradient);
            pVDev->SetOutputSizePixel(aBitmapEx.GetBitmap().GetSizePixel());
            pVDev->DrawGradient(Rectangle(Point(0, 0), pVDev->GetOutputSizePixel()), rGradient);

            aNewMask = AlphaMask(aVDev.GetBitmap(Point(0, 0), aVDev.GetOutputSizePixel()));
            aNewMask = AlphaMask(pVDev->GetBitmap(Point(0, 0), pVDev->GetOutputSizePixel()));
            bHasNewMask = true;
        }

diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index d3f9a93..4244aa2 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -1026,14 +1026,14 @@ GDIMetaFile SdrGrafObj::getMetafileFromEmbeddedSvg() const

    if(isEmbeddedSvg() && GetModel())
    {
        VirtualDevice aOut;
        ScopedVclPtr<VirtualDevice> pOut( new VirtualDevice() );
        const Rectangle aBoundRect(GetCurrentBoundRect());
        const MapMode aMap(GetModel()->GetScaleUnit(), Point(), GetModel()->GetScaleFraction(), GetModel()->GetScaleFraction());

        aOut.EnableOutput(false);
        aOut.SetMapMode(aMap);
        aRetval.Record(&aOut);
        SingleObjectPainter(aOut);
        pOut->EnableOutput(false);
        pOut->SetMapMode(aMap);
        aRetval.Record(pOut);
        SingleObjectPainter(*pOut.get());
        aRetval.Stop();
        aRetval.WindStart();
        aRetval.Move(-aBoundRect.Left(), -aBoundRect.Top());
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index 116efe2..61a9fb2 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -1877,12 +1877,12 @@ GDIMetaFile* SdrTextObj::GetTextScrollMetaFileAndRectangle(

    // create the MetaFile
    pRetval = new GDIMetaFile;
    VirtualDevice aBlackHole;
    aBlackHole.EnableOutput(false);
    pRetval->Record(&aBlackHole);
    ScopedVclPtr<VirtualDevice> pBlackHole(new VirtualDevice());
    pBlackHole->EnableOutput(false);
    pRetval->Record(pBlackHole);
    Point aPaintPos = aPaintRect.TopLeft();

    rOutliner.Draw(&aBlackHole, aPaintPos);
    rOutliner.Draw(pBlackHole, aPaintPos);

    pRetval->Stop();
    pRetval->WindStart();
diff --git a/svx/source/svdraw/svdtrans.cxx b/svx/source/svdraw/svdtrans.cxx
index e95b56aa..d9ffbda 100644
--- a/svx/source/svdraw/svdtrans.cxx
+++ b/svx/source/svdraw/svdtrans.cxx
@@ -634,17 +634,17 @@ FrPair GetInchOrMM(MapUnit eU)
        case MAP_MM         : return FrPair(   1,1);
        case MAP_CM         : return FrPair(   1,10);
        case MAP_PIXEL      : {
            VirtualDevice aVD;
            aVD.SetMapMode(MapMode(MAP_100TH_MM));
            Point aP(aVD.PixelToLogic(Point(64,64))); // 64 pixels for more accuracy
            ScopedVclPtr<VirtualDevice> pVD( new VirtualDevice() );
            pVD->SetMapMode(MapMode(MAP_100TH_MM));
            Point aP(pVD->PixelToLogic(Point(64,64))); // 64 pixels for more accuracy
            return FrPair(6400,aP.X(),6400,aP.Y());
        }
        case MAP_APPFONT: case MAP_SYSFONT: {
            VirtualDevice aVD;
            aVD.SetMapMode(MapMode(eU));
            Point aP(aVD.LogicToPixel(Point(32,32))); // 32 units for more accuracy
            aVD.SetMapMode(MapMode(MAP_100TH_MM));
            aP=aVD.PixelToLogic(aP);
            ScopedVclPtr<VirtualDevice> pVD( new VirtualDevice() );
            pVD->SetMapMode(MapMode(eU));
            Point aP(pVD->LogicToPixel(Point(32,32))); // 32 units for more accuracy
            pVD->SetMapMode(MapMode(MAP_100TH_MM));
            aP=pVD->PixelToLogic(aP);
            return FrPair(3200,aP.X(),3200,aP.Y());
        }
        default: break;
diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx
index 194231e..569d5a1 100644
--- a/svx/source/svdraw/svdxcgv.cxx
+++ b/svx/source/svdraw/svdxcgv.cxx
@@ -553,16 +553,16 @@ GDIMetaFile SdrExchangeView::GetMarkedObjMetaFile(bool bNoVDevIfOneMtfMarked) co

        if( !aMtf.GetActionSize() )
        {
            VirtualDevice aOut;
            ScopedVclPtr<VirtualDevice> pOut(new VirtualDevice());
            const Size aDummySize(2, 2);

            aOut.SetOutputSizePixel(aDummySize);
            aOut.EnableOutput(false);
            aOut.SetMapMode(aMap);
            pOut->SetOutputSizePixel(aDummySize);
            pOut->EnableOutput(false);
            pOut->SetMapMode(aMap);
            aMtf.Clear();
            aMtf.Record(&aOut);
            aMtf.Record(pOut);

            DrawMarkedObj(aOut);
            DrawMarkedObj(*pOut.get());

            aMtf.Stop();
            aMtf.WindStart();
@@ -640,7 +640,7 @@ Graphic SdrExchangeView::GetObjGraphic( const SdrModel* pModel, const SdrObject*
        // if graphic could not be retrieved => go the hard way and create a MetaFile
        if( ( GRAPHIC_NONE == aRet.GetType() ) || ( GRAPHIC_DEFAULT == aRet.GetType() ) )
        {
            VirtualDevice   aOut;
            ScopedVclPtr<VirtualDevice> pOut(new VirtualDevice());
            GDIMetaFile     aMtf;
            const Rectangle aBoundRect( pObj->GetCurrentBoundRect() );
            const MapMode   aMap( pModel->GetScaleUnit(),
@@ -648,10 +648,10 @@ Graphic SdrExchangeView::GetObjGraphic( const SdrModel* pModel, const SdrObject*
                                  pModel->GetScaleFraction(),
                                  pModel->GetScaleFraction() );

            aOut.EnableOutput( false );
            aOut.SetMapMode( aMap );
            aMtf.Record( &aOut );
            pObj->SingleObjectPainter( aOut );
            pOut->EnableOutput( false );
            pOut->SetMapMode( aMap );
            aMtf.Record( pOut );
            pObj->SingleObjectPainter( *pOut.get() );
            aMtf.Stop();
            aMtf.WindStart();

diff --git a/svx/source/tbxctrls/colrctrl.cxx b/svx/source/tbxctrls/colrctrl.cxx
index 6a631dc..df7954b 100644
--- a/svx/source/tbxctrls/colrctrl.cxx
+++ b/svx/source/tbxctrls/colrctrl.cxx
@@ -277,15 +277,15 @@ void SvxColorDockingWindow::FillValueSet()
        const Size aColorSize(aColorSet->getEntryEdgeLength(), aColorSet->getEntryEdgeLength());
        long nPtX = aColorSize.Width() - 1;
        long nPtY = aColorSize.Height() - 1;
        VirtualDevice aVD;
        ScopedVclPtr<VirtualDevice> pVD(new VirtualDevice());

        aVD.SetOutputSizePixel( aColorSize );
        aVD.SetLineColor( Color( COL_BLACK ) );
        aVD.SetBackground( Wallpaper( Color( COL_WHITE ) ) );
        aVD.DrawLine( Point(), Point( nPtX, nPtY ) );
        aVD.DrawLine( Point( 0, nPtY ), Point( nPtX, 0 ) );
        pVD->SetOutputSizePixel( aColorSize );
        pVD->SetLineColor( Color( COL_BLACK ) );
        pVD->SetBackground( Wallpaper( Color( COL_WHITE ) ) );
        pVD->DrawLine( Point(), Point( nPtX, nPtY ) );
        pVD->DrawLine( Point( 0, nPtY ), Point( nPtX, 0 ) );

        Bitmap aBmp( aVD.GetBitmap( Point(), aColorSize ) );
        Bitmap aBmp( pVD->GetBitmap( Point(), aColorSize ) );

        aColorSet->InsertItem( (sal_uInt16)1, Image(aBmp), SVX_RESSTR( RID_SVXSTR_INVISIBLE ) );

diff --git a/svx/source/tbxctrls/fontworkgallery.cxx b/svx/source/tbxctrls/fontworkgallery.cxx
index a045c1f..2ee00f7 100644
--- a/svx/source/tbxctrls/fontworkgallery.cxx
+++ b/svx/source/tbxctrls/fontworkgallery.cxx
@@ -124,7 +124,7 @@ void FontWorkGalleryDialog::initFavorites(sal_uInt16 nThemeId)

        if (GalleryExplorer::GetSdrObj(nThemeId, nModelPos, pModel, &aThumb) && !!aThumb)
        {
            VirtualDevice aVDev;
            ScopedVclPtr<VirtualDevice> pVDev(new VirtualDevice());
            const Point aNull(0, 0);

            if (GetDPIScaleFactor() > 1)
@@ -132,7 +132,7 @@ void FontWorkGalleryDialog::initFavorites(sal_uInt16 nThemeId)

            const Size aSize(aThumb.GetSizePixel());

            aVDev.SetOutputSizePixel(aSize);
            pVDev->SetOutputSizePixel(aSize);

            if(rStyleSettings.GetPreviewUsesCheckeredBackground())
            {
@@ -140,16 +140,16 @@ void FontWorkGalleryDialog::initFavorites(sal_uInt16 nThemeId)
                static const Color aW(COL_WHITE);
                static const Color aG(0xef, 0xef, 0xef);

                aVDev.DrawCheckered(aNull, aSize, nLen, aW, aG);
                pVDev->DrawCheckered(aNull, aSize, nLen, aW, aG);
            }
            else
            {
                aVDev.SetBackground(rStyleSettings.GetFieldColor());
                aVDev.Erase();
                pVDev->SetBackground(rStyleSettings.GetFieldColor());
                pVDev->Erase();
            }

            aVDev.DrawBitmapEx(aNull, aThumb);
            maFavoritesHorizontal.push_back(aVDev.GetBitmap(aNull, aSize));
            pVDev->DrawBitmapEx(aNull, aThumb);
            maFavoritesHorizontal.push_back(pVDev->GetBitmap(aNull, aSize));
        }
    }

diff --git a/svx/source/tbxctrls/linectrl.cxx b/svx/source/tbxctrls/linectrl.cxx
index d6e5fe4..eb19aa1 100644
--- a/svx/source/tbxctrls/linectrl.cxx
+++ b/svx/source/tbxctrls/linectrl.cxx
@@ -401,7 +401,7 @@ void SvxLineEndWindow::FillValueSet()
    if( pLineEndList.is() )
    {
        XLineEndEntry*      pEntry  = NULL;
        VirtualDevice       aVD;
        ScopedVclPtr<VirtualDevice> pVD(new VirtualDevice());

        long nCount = pLineEndList->Count();

@@ -414,14 +414,14 @@ void SvxLineEndWindow::FillValueSet()
        OSL_ENSURE( !aBmp.IsEmpty(), "UI bitmap was not created" );

        aBmpSize = aBmp.GetSizePixel();
        aVD.SetOutputSizePixel( aBmpSize, false );
        pVD->SetOutputSizePixel( aBmpSize, false );
        aBmpSize.Width() = aBmpSize.Width() / 2;
        Point aPt0( 0, 0 );
        Point aPt1( aBmpSize.Width(), 0 );

        aVD.DrawBitmap( Point(), aBmp );
        aLineEndSet->InsertItem(1, Image(aVD.GetBitmap(aPt0, aBmpSize)), pEntry->GetName());
        aLineEndSet->InsertItem(2, Image(aVD.GetBitmap(aPt1, aBmpSize)), pEntry->GetName());
        pVD->DrawBitmap( Point(), aBmp );
        aLineEndSet->InsertItem(1, Image(pVD->GetBitmap(aPt0, aBmpSize)), pEntry->GetName());
        aLineEndSet->InsertItem(2, Image(pVD->GetBitmap(aPt1, aBmpSize)), pEntry->GetName());

        delete pLineEndList->Remove( nCount );

@@ -432,11 +432,11 @@ void SvxLineEndWindow::FillValueSet()
            aBmp = pLineEndList->GetUiBitmap( i );
            OSL_ENSURE( !aBmp.IsEmpty(), "UI bitmap was not created" );

            aVD.DrawBitmap( aPt0, aBmp );
            pVD->DrawBitmap( aPt0, aBmp );
            aLineEndSet->InsertItem((sal_uInt16)((i+1L)*2L+1L),
                    Image(aVD.GetBitmap(aPt0, aBmpSize)), pEntry->GetName());
                    Image(pVD->GetBitmap(aPt0, aBmpSize)), pEntry->GetName());
            aLineEndSet->InsertItem((sal_uInt16)((i+2L)*2L),
                    Image(aVD.GetBitmap(aPt1, aBmpSize)), pEntry->GetName());
                    Image(pVD->GetBitmap(aPt1, aBmpSize)), pEntry->GetName());
        }
        nLines = std::min( (sal_uInt16)(nCount + 1), (sal_uInt16) MAX_LINES );
        aLineEndSet->SetLineCount( nLines );