Fix OutputDevice members / stack allocation: desktop, sfx2, lwp.

Change-Id: I5563cfa35142f088533ae998d087dec669a13287
diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx
index a572429..94a616c 100644
--- a/cui/source/tabpages/tpline.cxx
+++ b/cui/source/tabpages/tpline.cxx
@@ -360,8 +360,8 @@ void SvxLineTabPage::InitSymbols(MenuButton* pButton)

    if(!pButton->GetPopupMenu()->GetPopupMenu( MN_SYMBOLS ) && pSymbolList)
    {
        VirtualDevice aVDev;
        aVDev.SetMapMode(MapMode(MAP_100TH_MM));
        ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice() );
        pVDev->SetMapMode(MapMode(MAP_100TH_MM));
        boost::scoped_ptr<SdrModel> pModel(new SdrModel);
        pModel->GetItemPool().FreezeIdRanges();
        // Page
@@ -370,7 +370,7 @@ void SvxLineTabPage::InitSymbols(MenuButton* pButton)
        pModel->InsertPage( pPage, 0 );
        {
        // 3D View
        boost::scoped_ptr<SdrView> pView(new SdrView( pModel.get(), &aVDev ));
        boost::scoped_ptr<SdrView> pView(new SdrView( pModel.get(), pVDev ));
        pView->hideMarkHandles();
        pView->ShowSdrPage(pPage);

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 186f60b..b7587d1 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -606,21 +606,21 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
#ifndef IOS
    InitSvpForLibreOfficeKit();

    VirtualDevice aDevice(0, Size(1, 1), (sal_uInt16)32);
    ScopedVclPtr<VirtualDevice> pDevice( new VirtualDevice(0, Size(1, 1), (sal_uInt16)32)) ;
    boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() );
    aDevice.SetOutputSizePixelScaleOffsetAndBuffer(
    pDevice->SetOutputSizePixelScaleOffsetAndBuffer(
                Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
                aBuffer, true );

    pDoc->paintTile(aDevice, nCanvasWidth, nCanvasHeight,
    pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight,
                    nTilePosX, nTilePosY, nTileWidth, nTileHeight);
#else
    SystemGraphicsData aData;
    aData.rCGContext = reinterpret_cast<CGContextRef>(pBuffer);
    // the Size argument is irrelevant, I hope
    VirtualDevice aDevice(&aData, Size(1, 1), (sal_uInt16)0);
    ScopedVclPtrInstance<VirtualDevice> pDevice(&aData, Size(1, 1), (sal_uInt16)0);

    pDoc->paintTile(aDevice, nCanvasWidth, nCanvasHeight,
    pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight,
                    nTilePosX, nTilePosY, nTileWidth, nTileHeight);
#endif

diff --git a/desktop/source/splash/splash.cxx b/desktop/source/splash/splash.cxx
index fd55c1d..cb1ed36 100644
--- a/desktop/source/splash/splash.cxx
+++ b/desktop/source/splash/splash.cxx
@@ -150,7 +150,7 @@ SplashScreen::SplashScreen()
    , _yoffset(18)
{
    loadConfig();
    _vdev.EnableRTL(IsRTLEnabled());
    _vdev->EnableRTL(IsRTLEnabled());
}

SplashScreen::~SplashScreen()
@@ -258,7 +258,7 @@ SplashScreen::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::sta
            SetScreenBitmap (_aIntroBmp);
        Size aSize = _aIntroBmp.GetSizePixel();
        SetOutputSizePixel( aSize );
        _vdev.SetOutputSizePixel( aSize );
        _vdev->SetOutputSizePixel( aSize );
        _height = aSize.Height();
        _width = aSize.Width();
        if (_width > 500)
@@ -615,7 +615,7 @@ void SplashScreen::Paint( const Rectangle&)
    //non native drawing
    // draw bitmap
    if (_bPaintBitmap)
        _vdev.DrawBitmapEx( Point(), _aIntroBmp );
        _vdev->DrawBitmapEx( Point(), _aIntroBmp );

    if (_bPaintProgress) {
        // draw progress...
@@ -623,20 +623,20 @@ void SplashScreen::Paint( const Rectangle&)
        if (length < 0) length = 0;

        // border
        _vdev.SetFillColor();
        _vdev.SetLineColor( _cProgressFrameColor );
        _vdev.DrawRect(Rectangle(_tlx, _tly, _tlx+_barwidth, _tly+_barheight));
        _vdev.SetFillColor( _cProgressBarColor );
        _vdev.SetLineColor();
        _vdev.DrawRect(Rectangle(_tlx+_barspace, _tly+_barspace, _tlx+_barspace+length, _tly+_barheight-_barspace));
        _vdev->SetFillColor();
        _vdev->SetLineColor( _cProgressFrameColor );
        _vdev->DrawRect(Rectangle(_tlx, _tly, _tlx+_barwidth, _tly+_barheight));
        _vdev->SetFillColor( _cProgressBarColor );
        _vdev->SetLineColor();
        _vdev->DrawRect(Rectangle(_tlx+_barspace, _tly+_barspace, _tlx+_barspace+length, _tly+_barheight-_barspace));
        vcl::Font aFont;
        aFont.SetSize(Size(0, 12));
        aFont.SetAlign(ALIGN_BASELINE);
        _vdev.SetFont(aFont);
        _vdev.SetTextColor(_cProgressTextColor);
        _vdev.DrawText(Point(_tlx, _textBaseline), _sProgressText);
        _vdev->SetFont(aFont);
        _vdev->SetTextColor(_cProgressTextColor);
        _vdev->DrawText(Point(_tlx, _textBaseline), _sProgressText);
    }
    DrawOutDev(Point(), GetOutputSizePixel(), Point(), _vdev.GetOutputSizePixel(), _vdev );
    DrawOutDev(Point(), GetOutputSizePixel(), Point(), _vdev->GetOutputSizePixel(), *_vdev.get() );
}


diff --git a/lotuswordpro/source/filter/lwppagelayout.cxx b/lotuswordpro/source/filter/lwppagelayout.cxx
index d5b22e5..4464af3 100644
--- a/lotuswordpro/source/filter/lwppagelayout.cxx
+++ b/lotuswordpro/source/filter/lwppagelayout.cxx
@@ -640,12 +640,12 @@ void LwpPageLayout::GetWidthAndHeight(double& fWidth, double& fHeight)
    if(GetUsePrinterSettings())
    {
        //replaced by printer paper size
        Printer aPrinter;
        bool bScreen = aPrinter.IsDisplayPrinter();
        ScopedVclPtr<Printer> pPrinter( new Printer() );
        bool bScreen = pPrinter->IsDisplayPrinter();
        if (!bScreen)//Printer available
        {
            Size aPaperSize = aPrinter.GetPaperSize();
            aPaperSize = aPrinter.PixelToLogic( aPaperSize, MapMode( MAP_10TH_MM ) );
            Size aPaperSize = pPrinter->GetPaperSize();
            aPaperSize = pPrinter->PixelToLogic( aPaperSize, MapMode( MAP_10TH_MM ) );
            fWidth = static_cast<double>(aPaperSize.Width())/100;   //cm unit
            fHeight = static_cast<double>(aPaperSize.Height())/100;
        }
diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx
index cab9b33..17a7e35 100644
--- a/sfx2/source/dialog/backingwindow.cxx
+++ b/sfx2/source/dialog/backingwindow.cxx
@@ -395,15 +395,15 @@ void BackingWindow::Paint( const Rectangle& )
    DrawWallpaper( Rectangle( Point( 0, 0 ), GetOutputSizePixel() ), aBack );
    Pop();

    VirtualDevice aDev( *this );
    aDev.EnableRTL( IsRTLEnabled() );
    aDev.SetOutputSizePixel( maStartCentButtons.GetSize() );
    ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice( *this ) );
    pVDev->EnableRTL( IsRTLEnabled() );
    pVDev->SetOutputSizePixel( maStartCentButtons.GetSize() );
    Point aOffset( Point( 0, 0 ) - maStartCentButtons.TopLeft());
    aDev.DrawWallpaper( Rectangle( aOffset, GetOutputSizePixel() ), aBack );
    pVDev->DrawWallpaper( Rectangle( aOffset, GetOutputSizePixel() ), aBack );

    DrawOutDev( maStartCentButtons.TopLeft(), maStartCentButtons.GetSize(),
                Point( 0, 0 ), maStartCentButtons.GetSize(),
                aDev );
                *pVDev.get() );
}

bool BackingWindow::PreNotify( NotifyEvent& rNEvt )
diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx
index 2f5b220..3575957 100644
--- a/sfx2/source/doc/objcont.cxx
+++ b/sfx2/source/doc/objcont.cxx
@@ -127,11 +127,11 @@ SfxObjectShell::CreatePreviewMetaFile_Impl( bool bFullContent ) const

    std::shared_ptr<GDIMetaFile> xFile(new GDIMetaFile);

    VirtualDevice aDevice;
    aDevice.EnableOutput( false );
    ScopedVclPtr<VirtualDevice> pDevice( new VirtualDevice() );
    pDevice->EnableOutput( false );

    MapMode aMode( this->GetMapUnit() );
    aDevice.SetMapMode( aMode );
    pDevice->SetMapMode( aMode );
    xFile->SetPrefMapMode( aMode );

    Size aTmpSize;
@@ -151,7 +151,7 @@ SfxObjectShell::CreatePreviewMetaFile_Impl( bool bFullContent ) const
    DBG_ASSERT( aTmpSize.Height()*aTmpSize.Width(),
        "size of first page is 0, override GetFirstPageSize or set vis-area!" );

    xFile->Record( &aDevice );
    xFile->Record( pDevice );

    LanguageType eLang;
    SvtCTLOptions aCTLOptions;
@@ -162,9 +162,9 @@ SfxObjectShell::CreatePreviewMetaFile_Impl( bool bFullContent ) const
    else
        eLang = (LanguageType) Application::GetSettings().GetLanguageTag().getLanguageType();

    aDevice.SetDigitLanguage( eLang );
    pDevice->SetDigitLanguage( eLang );

    const_cast<SfxObjectShell*>(this)->DoDraw( &aDevice, Point(0,0), aTmpSize, JobSetup(), nAspect );
    const_cast<SfxObjectShell*>(this)->DoDraw( pDevice, Point(0,0), aTmpSize, JobSetup(), nAspect );

    xFile->Stop();