Fix OutputDevice members / stack allocation: slideshow, starmath, sd, sc.

Change-Id: I6d6d41b8a6501ce7d35c78e5b730ea45143d6b73
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index d71154d..d8980fc 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -577,13 +577,13 @@ void ScGlobal::InitTextHeight(SfxItemPool* pPool)
    }

    OutputDevice* pDefaultDev = Application::GetDefaultDevice();
    VirtualDevice aVirtWindow( *pDefaultDev );
    aVirtWindow.SetMapMode(MAP_PIXEL);
    ScopedVclPtr<VirtualDevice> pVirtWindow( new VirtualDevice( *pDefaultDev ) );
    pVirtWindow->SetMapMode(MAP_PIXEL);
    vcl::Font aDefFont;
    pPattern->GetFont(aDefFont, SC_AUTOCOL_BLACK, &aVirtWindow); // Font color doesn't matter here
    aVirtWindow.SetFont(aDefFont);
    pPattern->GetFont(aDefFont, SC_AUTOCOL_BLACK, pVirtWindow); // Font color doesn't matter here
    pVirtWindow->SetFont(aDefFont);
    sal_uInt16 nTest = static_cast<sal_uInt16>(
        aVirtWindow.PixelToLogic(Size(0, aVirtWindow.GetTextHeight()), MAP_TWIP).Height());
        pVirtWindow->PixelToLogic(Size(0, pVirtWindow->GetTextHeight()), MAP_TWIP).Height());

    if (nTest > nDefFontHeight)
        nDefFontHeight = nTest;
diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx
index 051b878..6f8971b 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -433,8 +433,8 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu
        // Factor is printer to display ratio
        double nPPTX = ScGlobal::nScreenPPTX * (double) aZoom / nOutputFactor;
        double nPPTY = ScGlobal::nScreenPPTY * (double) aZoom;
        VirtualDevice aVirtDev;
        sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoom, aZoom, &aVirtDev);
        ScopedVclPtr<VirtualDevice> pVirtDev( new VirtualDevice() );
        sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoom, aZoom, pVirtDev);
        aCxt.setExtraHeight(ScGlobal::nLastRowHeightExtra);
        mpDoc->SetOptimalHeight(aCxt, 0, nEndRow, 0);

diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index df4435a..5990bb1 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -337,13 +337,13 @@ bool ScTransferObj::GetData( const datatransfer::DataFlavor& rFlavor, const OUSt
            Rectangle aMMRect = pDoc->GetMMRect( aBlock.aStart.Col(), aBlock.aStart.Row(),
                                                 aBlock.aEnd.Col(), aBlock.aEnd.Row(),
                                                 aBlock.aStart.Tab() );
            VirtualDevice aVirtDev;
            aVirtDev.SetOutputSizePixel( aVirtDev.LogicToPixel( aMMRect.GetSize(), MAP_100TH_MM ) );
            ScopedVclPtr<VirtualDevice> pVirtDev( new VirtualDevice() );
            pVirtDev->SetOutputSizePixel( pVirtDev->LogicToPixel( aMMRect.GetSize(), MAP_100TH_MM ) );

            PaintToDev( &aVirtDev, pDoc, 1.0, aBlock, false );
            PaintToDev( pVirtDev, pDoc, 1.0, aBlock, false );

            aVirtDev.SetMapMode( MapMode( MAP_PIXEL ) );
            Bitmap aBmp = aVirtDev.GetBitmap( Point(), aVirtDev.GetOutputSize() );
            pVirtDev->SetMapMode( MapMode( MAP_PIXEL ) );
            Bitmap aBmp = pVirtDev->GetBitmap( Point(), pVirtDev->GetOutputSize() );
            bOK = SetBitmapEx( aBmp, rFlavor );
        }
        else if ( nFormat == SotClipboardFormatId::GDIMETAFILE )
@@ -358,17 +358,17 @@ bool ScTransferObj::GetData( const datatransfer::DataFlavor& rFlavor, const OUSt

            // like SvEmbeddedTransfer::GetData:
            GDIMetaFile     aMtf;
            VirtualDevice   aVDev;
            ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice() );
            MapMode         aMapMode( pEmbObj->GetMapUnit() );
            Rectangle       aVisArea( pEmbObj->GetVisArea( ASPECT_CONTENT ) );

            aVDev.EnableOutput( false );
            aVDev.SetMapMode( aMapMode );
            pVDev->EnableOutput( false );
            pVDev->SetMapMode( aMapMode );
            aMtf.SetPrefSize( aVisArea.GetSize() );
            aMtf.SetPrefMapMode( aMapMode );
            aMtf.Record( &aVDev );
            aMtf.Record( pVDev );

            pEmbObj->DoDraw( &aVDev, Point(), aVisArea.GetSize(), JobSetup(), ASPECT_CONTENT );
            pEmbObj->DoDraw( pVDev, Point(), aVisArea.GetSize(), JobSetup(), ASPECT_CONTENT );

            aMtf.Stop();
            aMtf.WindStart();
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index f7b0907..b166a31 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -2764,7 +2764,6 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos,
    if ( !bIncludeFiltered && pClipDoc->HasClipFilteredRows() )
        UnmergeCells( aPasteDest, false );

    VirtualDevice aVirtDev;
    bool bDestHeight = AdjustRowHeight(
                            ScRange( 0,nDestRow,nDestTab, MAXCOL,nDestEndRow,nDestEndTab ),
                            false );
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index f5a44e4..93a6aa3 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -1457,7 +1457,7 @@ bool ScDocShell::ConvertFrom( SfxMedium& rMedium )
        Fraction aZoom( 1, 1 );
        double nPPTX = ScGlobal::nScreenPPTX * (double) aZoom / GetOutputFactor(); // Factor is printer display ratio
        double nPPTY = ScGlobal::nScreenPPTY * (double) aZoom;
        VirtualDevice aVirtDev;
        ScopedVclPtr<VirtualDevice> pVirtDev( new VirtualDevice() );
        //  all sheets (for Excel import)
        SCTAB nTabCount = aDocument.GetTableCount();
        for (SCTAB nTab=0; nTab<nTabCount; nTab++)
@@ -1480,7 +1480,7 @@ bool ScDocShell::ConvertFrom( SfxMedium& rMedium )
                        aColWidthParam[nCol].mbSimpleText = false;

                    sal_uInt16 nWidth = aDocument.GetOptimalColWidth(
                        nCol, nTab, &aVirtDev, nPPTX, nPPTY, aZoom, aZoom, false, &aMark,
                        nCol, nTab, pVirtDev, nPPTX, nPPTY, aZoom, aZoom, false, &aMark,
                        &aColWidthParam[nCol] );
                    aDocument.SetColWidth( nCol, nTab,
                        nWidth + (sal_uInt16)ScGlobal::nLastColWidthExtra );
diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx
index 2ee7231..60f2570 100644
--- a/sc/source/ui/docshell/docsh3.cxx
+++ b/sc/source/ui/docshell/docsh3.cxx
@@ -368,11 +368,11 @@ void ScDocShell::CalcOutputFactor()
    pRefDev->SetFont(aOldFont);
    pRefDev->SetMapMode(aOldMode);

    VirtualDevice aVirtWindow( *Application::GetDefaultDevice() );
    aVirtWindow.SetMapMode(MAP_PIXEL);
    pPattern->GetFont(aDefFont, SC_AUTOCOL_BLACK, &aVirtWindow);    // font color doesn't matter here
    aVirtWindow.SetFont(aDefFont);
    nWindowWidth = aVirtWindow.GetTextWidth(aTestString);
    ScopedVclPtr<VirtualDevice> pVirtWindow( new VirtualDevice( *Application::GetDefaultDevice() ) );
    pVirtWindow->SetMapMode(MAP_PIXEL);
    pPattern->GetFont(aDefFont, SC_AUTOCOL_BLACK, pVirtWindow);    // font color doesn't matter here
    pVirtWindow->SetFont(aDefFont);
    nWindowWidth = pVirtWindow->GetTextWidth(aTestString);
    nWindowWidth = (long) ( nWindowWidth / ScGlobal::nScreenPPTX * HMM_PER_TWIPS );

    if (nPrinterWidth && nWindowWidth)
diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx
index 23fa4ed..39e221a 100644
--- a/sc/source/ui/undo/undobase.cxx
+++ b/sc/source/ui/undo/undobase.cxx
@@ -257,7 +257,7 @@ bool ScBlockUndo::AdjustHeight()
{
    ScDocument& rDoc = pDocShell->GetDocument();

    VirtualDevice aVirtDev;
    ScopedVclPtr<VirtualDevice> pVirtDev( new VirtualDevice() );
    Fraction aZoomX( 1, 1 );
    Fraction aZoomY = aZoomX;
    double nPPTX, nPPTY;
@@ -277,7 +277,7 @@ bool ScBlockUndo::AdjustHeight()
        nPPTY = ScGlobal::nScreenPPTY;
    }

    sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoomX, aZoomY, &aVirtDev);
    sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoomX, aZoomY, pVirtDev);
    bool bRet = rDoc.SetOptimalHeight(
        aCxt, aBlockRange.aStart.Row(), aBlockRange.aEnd.Row(), aBlockRange.aStart.Tab());

@@ -355,7 +355,7 @@ void ScMultiBlockUndo::AdjustHeight()
{
    ScDocument& rDoc = pDocShell->GetDocument();

    VirtualDevice aVirtDev;
    ScopedVclPtr<VirtualDevice> pVirtDev( new VirtualDevice() );
    Fraction aZoomX( 1, 1 );
    Fraction aZoomY = aZoomX;
    double nPPTX, nPPTY;
@@ -375,7 +375,7 @@ void ScMultiBlockUndo::AdjustHeight()
        nPPTY = ScGlobal::nScreenPPTY;
    }

    sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoomX, aZoomY, &aVirtDev);
    sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoomX, aZoomY, pVirtDev);
    for (size_t i = 0, n = maBlockRanges.size(); i < n; ++i)
    {
        const ScRange& r = *maBlockRanges[i];
diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index 15e0a90..d6817c7 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -1182,11 +1182,11 @@ void ScUndoDragDrop::PaintArea( ScRange aRange, sal_uInt16 nExtFlags ) const

    if (pViewShell)
    {
        VirtualDevice aVirtDev;
        ScopedVclPtr<VirtualDevice> pVirtDev( new VirtualDevice() );
        ScViewData& rViewData = pViewShell->GetViewData();
        sc::RowHeightContext aCxt(
            rViewData.GetPPTX(), rViewData.GetPPTY(), rViewData.GetZoomX(), rViewData.GetZoomY(),
            &aVirtDev);
            pVirtDev);

        if (rDoc.SetOptimalHeight(aCxt, aRange.aStart.Row(), aRange.aEnd.Row(), aRange.aStart.Tab()))
        {
diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index 5b76505..85ae2b8 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -841,7 +841,7 @@ void ScUndoAutoFormat::Redo()

    if (bSize)
    {
        VirtualDevice aVirtDev;
        ScopedVclPtr<VirtualDevice> pVirtDev( new VirtualDevice() );
        Fraction aZoomX(1,1);
        Fraction aZoomY = aZoomX;
        double nPPTX,nPPTY;
@@ -863,7 +863,7 @@ void ScUndoAutoFormat::Redo()

        bool bFormula = false;  // remember

        sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoomX, aZoomY, &aVirtDev);
        sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoomX, aZoomY, pVirtDev);
        for (SCTAB nTab=nStartZ; nTab<=nEndZ; nTab++)
        {
            ScMarkData aDestMark;
@@ -886,7 +886,7 @@ void ScUndoAutoFormat::Redo()
                if (!rDoc.ColHidden(nCol, nTab))
                {
                    sal_uInt16 nThisSize = STD_EXTRA_WIDTH + rDoc.GetOptimalColWidth( nCol, nTab,
                                                &aVirtDev, nPPTX, nPPTY, aZoomX, aZoomY, bFormula,
                                                pVirtDev, nPPTX, nPPTY, aZoomX, aZoomY, bFormula,
                                                &aDestMark );
                    rDoc.SetColWidth( nCol, nTab, nThisSize );
                    rDoc.ShowCol( nCol, nTab, true );
diff --git a/sc/source/ui/undo/undostyl.cxx b/sc/source/ui/undo/undostyl.cxx
index 41f733a..96fbf37 100644
--- a/sc/source/ui/undo/undostyl.cxx
+++ b/sc/source/ui/undo/undostyl.cxx
@@ -106,12 +106,12 @@ static void lcl_DocStyleChanged( ScDocument* pDoc, SfxStyleSheetBase* pStyle, bo
{
    //! move to document or docshell

    VirtualDevice aVDev;
    Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP );
    ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice() );
    Point aLogic = pVDev->LogicToPixel( Point(1000,1000), MAP_TWIP );
    double nPPTX = aLogic.X() / 1000.0;
    double nPPTY = aLogic.Y() / 1000.0;
    Fraction aZoom(1,1);
    pDoc->StyleSheetChanged( pStyle, bRemoved, &aVDev, nPPTX, nPPTY, aZoom, aZoom );
    pDoc->StyleSheetChanged( pStyle, bRemoved, pVDev, nPPTX, nPPTY, aZoom, aZoom );

    ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
    if (pHdl)
diff --git a/sc/source/ui/unoobj/styleuno.cxx b/sc/source/ui/unoobj/styleuno.cxx
index 97cf574..3a6cdaa 100644
--- a/sc/source/ui/unoobj/styleuno.cxx
+++ b/sc/source/ui/unoobj/styleuno.cxx
@@ -755,12 +755,12 @@ void SAL_CALL ScStyleFamilyObj::removeByName( const OUString& aName )
            if ( eFamily == SFX_STYLE_FAMILY_PARA )
            {
                // wie ScViewFunc::RemoveStyleSheetInUse
                VirtualDevice aVDev;
                Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP );
                ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice() );
                Point aLogic = pVDev->LogicToPixel( Point(1000,1000), MAP_TWIP );
                double nPPTX = aLogic.X() / 1000.0;
                double nPPTY = aLogic.Y() / 1000.0;
                Fraction aZoom(1,1);
                rDoc.StyleSheetChanged( pStyle, false, &aVDev, nPPTX, nPPTY, aZoom, aZoom );
                rDoc.StyleSheetChanged( pStyle, false, pVDev, nPPTX, nPPTY, aZoom, aZoom );
                pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT );
                pDocShell->SetDocumentModified();

@@ -1096,12 +1096,12 @@ void SAL_CALL ScStyleObj::setParentStyle( const OUString& rParentStyle )
            {
                //  Zeilenhoehen anpassen...

                VirtualDevice aVDev;
                Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP );
                ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice() );
                Point aLogic = pVDev->LogicToPixel( Point(1000,1000), MAP_TWIP );
                double nPPTX = aLogic.X() / 1000.0;
                double nPPTY = aLogic.Y() / 1000.0;
                Fraction aZoom(1,1);
                rDoc.StyleSheetChanged( pStyle, false, &aVDev, nPPTX, nPPTY, aZoom, aZoom );
                rDoc.StyleSheetChanged( pStyle, false, pVDev, nPPTX, nPPTY, aZoom, aZoom );

                if (!rDoc.IsImportingXML())
                {
@@ -1463,12 +1463,12 @@ void SAL_CALL ScStyleObj::setAllPropertiesToDefault()
        {
            //  row heights

            VirtualDevice aVDev;
            Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP );
            ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice() );
            Point aLogic = pVDev->LogicToPixel( Point(1000,1000), MAP_TWIP );
            double nPPTX = aLogic.X() / 1000.0;
            double nPPTY = aLogic.Y() / 1000.0;
            Fraction aZoom(1,1);
            rDoc.StyleSheetChanged( pStyle, false, &aVDev, nPPTX, nPPTY, aZoom, aZoom );
            rDoc.StyleSheetChanged( pStyle, false, pVDev, nPPTX, nPPTY, aZoom, aZoom );

            if (!rDoc.IsImportingXML())
            {
@@ -1845,12 +1845,12 @@ void ScStyleObj::SetOnePropertyValue( const OUString& rPropertyName, const SfxIt
        {
            //  Zeilenhoehen anpassen...

            VirtualDevice aVDev;
            Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP );
            ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice() );
            Point aLogic = pVDev->LogicToPixel( Point(1000,1000), MAP_TWIP );
            double nPPTX = aLogic.X() / 1000.0;
            double nPPTY = aLogic.Y() / 1000.0;
            Fraction aZoom(1,1);
            rDoc.StyleSheetChanged( pStyle, false, &aVDev, nPPTX, nPPTY, aZoom, aZoom );
            rDoc.StyleSheetChanged( pStyle, false, pVDev, nPPTX, nPPTY, aZoom, aZoom );

            if (!rDoc.IsImportingXML())
            {
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 9e1a7e1..c3942f0 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1403,9 +1403,9 @@ void ScViewFunc::RemoveStyleSheetInUse( const SfxStyleSheetBase* pStyleSheet )

    ScDocShellModificator aModificator( *pDocSh );

    VirtualDevice aVirtDev;
    aVirtDev.SetMapMode(MAP_PIXEL);
    pDoc->StyleSheetChanged( pStyleSheet, true, &aVirtDev,
    ScopedVclPtr<VirtualDevice> pVirtDev( new VirtualDevice() );
    pVirtDev->SetMapMode(MAP_PIXEL);
    pDoc->StyleSheetChanged( pStyleSheet, true, pVirtDev,
                                rViewData.GetPPTX(),
                                rViewData.GetPPTY(),
                                rViewData.GetZoomX(),
@@ -1429,9 +1429,9 @@ void ScViewFunc::UpdateStyleSheetInUse( const SfxStyleSheetBase* pStyleSheet )

    ScDocShellModificator aModificator( *pDocSh );

    VirtualDevice aVirtDev;
    aVirtDev.SetMapMode(MAP_PIXEL);
    pDoc->StyleSheetChanged( pStyleSheet, false, &aVirtDev,
    ScopedVclPtr<VirtualDevice> pVirtDev( new VirtualDevice() );
    pVirtDev->SetMapMode(MAP_PIXEL);
    pDoc->StyleSheetChanged( pStyleSheet, false, pVirtDev,
                                rViewData.GetPPTX(),
                                rViewData.GetPPTY(),
                                rViewData.GetZoomX(),
diff --git a/sd/source/filter/html/buttonset.cxx b/sd/source/filter/html/buttonset.cxx
index fbc76de..40464ca 100644
--- a/sd/source/filter/html/buttonset.cxx
+++ b/sd/source/filter/html/buttonset.cxx
@@ -197,8 +197,8 @@ bool ButtonSetImpl::getPreview( int nSet, const std::vector< OUString >& rButton

        std::vector< Graphic > aGraphics;

        VirtualDevice aDev;
        aDev.SetMapMode(MapMode(MAP_PIXEL));
        ScopedVclPtr<VirtualDevice> pDev( new VirtualDevice() );
        pDev->SetMapMode(MapMode(MAP_PIXEL));

        Size aSize;
        std::vector< OUString >::const_iterator aIter( rButtons.begin() );
@@ -210,7 +210,7 @@ bool ButtonSetImpl::getPreview( int nSet, const std::vector< OUString >& rButton

            aGraphics.push_back(aGraphic);

            Size aGraphicSize( aGraphic.GetSizePixel( &aDev ) );
            Size aGraphicSize( aGraphic.GetSizePixel( pDev ) );
            aSize.Width() += aGraphicSize.Width();

            if( aSize.Height() < aGraphicSize.Height() )
@@ -220,7 +220,7 @@ bool ButtonSetImpl::getPreview( int nSet, const std::vector< OUString >& rButton
                aSize.Width() += 3;
        }

        aDev.SetOutputSizePixel( aSize );
        pDev->SetOutputSizePixel( aSize );

        Point aPos;

@@ -229,12 +229,12 @@ bool ButtonSetImpl::getPreview( int nSet, const std::vector< OUString >& rButton
        {
            Graphic aGraphic( (*aGraphIter++) );

            aGraphic.Draw( &aDev, aPos );
            aGraphic.Draw( pDev, aPos );

            aPos.X() += aGraphic.GetSizePixel().Width() + 3;
        }

        rImage = Image( aDev.GetBitmapEx( Point(), aSize ) );
        rImage = Image( pDev->GetBitmapEx( Point(), aSize ) );
        return true;
    }
    return false;
diff --git a/sd/source/ui/annotations/annotationtag.cxx b/sd/source/ui/annotations/annotationtag.cxx
index 610ed61..62ee8da 100644
--- a/sd/source/ui/annotations/annotationtag.cxx
+++ b/sd/source/ui/annotations/annotationtag.cxx
@@ -515,19 +515,19 @@ void AnnotationTag::deselect()

BitmapEx AnnotationTag::CreateAnnotationBitmap( bool bSelected )
{
    VirtualDevice aVDev;
    ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice() );

    OUString sAuthor( getInitials( mxAnnotation->getAuthor() ) );
    sAuthor += OUString( ' ' );
    sAuthor += OUString::number( mnIndex );

    aVDev.SetFont( mrFont );
    pVDev->SetFont( mrFont );

    const int BORDER_X = 4; // pixels
    const int BORDER_Y = 4; // pixels

    maSize = Size( aVDev.GetTextWidth( sAuthor ) + 2*BORDER_X, aVDev.GetTextHeight() + 2*BORDER_Y );
    aVDev.SetOutputSizePixel( maSize, false );
    maSize = Size( pVDev->GetTextWidth( sAuthor ) + 2*BORDER_X, pVDev->GetTextHeight() + 2*BORDER_Y );
    pVDev->SetOutputSizePixel( maSize, false );

    Color aBorderColor( maColor );

@@ -549,14 +549,14 @@ BitmapEx AnnotationTag::CreateAnnotationBitmap( bool bSelected )

    Point aPos;
    Rectangle aBorderRect( aPos, maSize );
    aVDev.SetLineColor(aBorderColor);
    aVDev.SetFillColor(maColor);
    aVDev.DrawRect( aBorderRect );
    pVDev->SetLineColor(aBorderColor);
    pVDev->SetFillColor(maColor);
    pVDev->DrawRect( aBorderRect );

    aVDev.SetTextColor( maColor.IsDark() ? COL_WHITE : COL_BLACK );
    aVDev.DrawText( Point( BORDER_X, BORDER_Y ), sAuthor );
    pVDev->SetTextColor( maColor.IsDark() ? COL_WHITE : COL_BLACK );
    pVDev->DrawText( Point( BORDER_X, BORDER_Y ), sAuthor );

    return aVDev.GetBitmapEx( aPos, maSize );
    return pVDev->GetBitmapEx( aPos, maSize );
}

void AnnotationTag::OpenPopup( bool bEdit )
diff --git a/sd/source/ui/dlg/animobjs.cxx b/sd/source/ui/dlg/animobjs.cxx
index a5d0109..6b79455 100644
--- a/sd/source/ui/dlg/animobjs.cxx
+++ b/sd/source/ui/dlg/animobjs.cxx
@@ -548,23 +548,23 @@ void AnimationWindow::UpdateControl(bool const bDisableCtrls)
            static_cast<SdrObject*>(pPage->GetObj(m_nCurrentFrame));
        if( pObject )
        {
            VirtualDevice   aVD;
            ScopedVclPtr<VirtualDevice> pVD(new VirtualDevice());
            Rectangle       aObjRect( pObject->GetCurrentBoundRect() );
            Size            aObjSize( aObjRect.GetSize() );
            Point           aOrigin( Point( -aObjRect.Left(), -aObjRect.Top() ) );
            MapMode         aMap( aVD.GetMapMode() );
            MapMode         aMap( pVD->GetMapMode() );
            aMap.SetMapUnit( MAP_100TH_MM );
            aMap.SetOrigin( aOrigin );
            aVD.SetMapMode( aMap );
            aVD.SetOutputSize( aObjSize );
            pVD->SetMapMode( aMap );
            pVD->SetOutputSize( aObjSize );
            const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
            aVD.SetBackground( Wallpaper( rStyles.GetFieldColor() ) );
            aVD.SetDrawMode( rStyles.GetHighContrastMode()
            pVD->SetBackground( Wallpaper( rStyles.GetFieldColor() ) );
            pVD->SetDrawMode( rStyles.GetHighContrastMode()
                ? ViewShell::OUTPUT_DRAWMODE_CONTRAST
                : ViewShell::OUTPUT_DRAWMODE_COLOR );
            aVD.Erase();
            pObject->SingleObjectPainter( aVD );
            aBmp = BitmapEx( aVD.GetBitmap( aObjRect.TopLeft(), aObjSize ) );
            pVD->Erase();
            pObject->SingleObjectPainter( *pVD.get() );
            aBmp = BitmapEx( pVD->GetBitmap( aObjRect.TopLeft(), aObjSize ) );
        }

        m_pCtlDisplay->SetBitmapEx(&aBmp);
diff --git a/sd/source/ui/dlg/docprev.cxx b/sd/source/ui/dlg/docprev.cxx
index 9669499..f772bb9 100644
--- a/sd/source/ui/dlg/docprev.cxx
+++ b/sd/source/ui/dlg/docprev.cxx
@@ -241,17 +241,17 @@ void SdDocPreviewWin::updateViewSettings()

            pMtf = new GDIMetaFile;

            VirtualDevice       aVDev;
            ScopedVclPtr<VirtualDevice> pVDev(new VirtualDevice());

            const Fraction      aFrac( pDoc->GetScaleFraction() );
            const MapMode       aMap( pDoc->GetScaleUnit(), Point(), aFrac, aFrac );

            aVDev.SetMapMode( aMap );
            pVDev->SetMapMode( aMap );

            // Disable output, as we only want to record a metafile
            aVDev.EnableOutput( false );
            pVDev->EnableOutput( false );

            pMtf->Record( &aVDev );
            pMtf->Record( pVDev );

            ::sd::DrawView* pView = new ::sd::DrawView(pDocShell, this, NULL);

@@ -267,18 +267,18 @@ void SdDocPreviewWin::updateViewSettings()
            const Rectangle aClipRect( aNewOrg, aNewSize );
            MapMode         aVMap( aMap );

            aVDev.Push();
            pVDev->Push();
            aVMap.SetOrigin( Point( -aNewOrg.X(), -aNewOrg.Y() ) );
            aVDev.SetRelativeMapMode( aVMap );
            aVDev.IntersectClipRegion( aClipRect );
            pVDev->SetRelativeMapMode( aVMap );
            pVDev->IntersectClipRegion( aClipRect );

        // Use new StandardCheckVisisbilityRedirector
        StandardCheckVisisbilityRedirector aRedirector;
        const Rectangle aRedrawRectangle = Rectangle( Point(), aNewSize );
        vcl::Region aRedrawRegion(aRedrawRectangle);
        pView->SdrPaintView::CompleteRedraw(&aVDev,aRedrawRegion,&aRedirector);
        pView->SdrPaintView::CompleteRedraw(pVDev,aRedrawRegion,&aRedirector);

            aVDev.Pop();
            pVDev->Pop();

            pMtf->Stop();
            pMtf->WindStart();
diff --git a/sd/source/ui/docshell/docshel2.cxx b/sd/source/ui/docshell/docshel2.cxx
index 1646ed3..769d015 100644
--- a/sd/source/ui/docshell/docshel2.cxx
+++ b/sd/source/ui/docshell/docshel2.cxx
@@ -193,26 +193,26 @@ Bitmap DrawDocShell::GetPagePreviewBitmap(SdPage* pPage, sal_uInt16 nMaxEdgePixe
    MapMode         aMapMode( MAP_100TH_MM );
    const Size      aSize( pPage->GetSize() );
    const Point     aNullPt;
    VirtualDevice   aVDev( *Application::GetDefaultDevice() );
    ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice( *Application::GetDefaultDevice() ) );

    aVDev.SetMapMode( aMapMode );
    pVDev->SetMapMode( aMapMode );

    const Size  aPixSize( aVDev.LogicToPixel( aSize ) );
    const Size  aPixSize( pVDev->LogicToPixel( aSize ) );
    const sal_uLong nMaxEdgePix = std::max( aPixSize.Width(), aPixSize.Height() );
    Fraction    aFrac( nMaxEdgePixel, nMaxEdgePix );

    aMapMode.SetScaleX( aFrac );
    aMapMode.SetScaleY( aFrac );
    aVDev.SetMapMode( aMapMode );
    aVDev.SetOutputSize( aSize );
    pVDev->SetMapMode( aMapMode );
    pVDev->SetOutputSize( aSize );

    // that we also get the dark lines at the right and bottom page margin
    aFrac = Fraction( nMaxEdgePixel - 1, nMaxEdgePix );
    aMapMode.SetScaleX( aFrac );
    aMapMode.SetScaleY( aFrac );
    aVDev.SetMapMode( aMapMode );
    pVDev->SetMapMode( aMapMode );

    ClientView* pView = new ClientView( this, &aVDev, NULL );
    ClientView* pView = new ClientView( this, pVDev, NULL );
    FrameView*      pFrameView = GetFrameView();
    pView->ShowSdrPage( pPage );

@@ -263,14 +263,14 @@ Bitmap DrawDocShell::GetPagePreviewBitmap(SdPage* pPage, sal_uInt16 nMaxEdgePixe
            pView->SetActiveLayer( pFrameView->GetActiveLayer() );
    }

    pView->CompleteRedraw( &aVDev, vcl::Region(Rectangle(aNullPt, aSize)) );
    pView->CompleteRedraw( pVDev, vcl::Region(Rectangle(aNullPt, aSize)) );

    // IsRedrawReady() always gives sal_True while ( !pView->IsRedrawReady() ) {}
    delete pView;

    aVDev.SetMapMode( MapMode() );
    pVDev->SetMapMode( MapMode() );

    Bitmap aPreview( aVDev.GetBitmap( aNullPt, aVDev.GetOutputSizePixel() ) );
    Bitmap aPreview( pVDev->GetBitmap( aNullPt, pVDev->GetOutputSizePixel() ) );

    DBG_ASSERT(!!aPreview, "Preview-Bitmap could not be generated");

diff --git a/sd/source/ui/slideshow/showwin.cxx b/sd/source/ui/slideshow/showwin.cxx
index 2dacb9c..6d67c9a 100644
--- a/sd/source/ui/slideshow/showwin.cxx
+++ b/sd/source/ui/slideshow/showwin.cxx
@@ -504,18 +504,18 @@ void ShowWindow::DrawPauseScene( bool bTimeoutOnly )
    if( SLIDE_NO_TIMEOUT != mnPauseTimeout )
    {
        MapMode         aVMap( rMap );
        VirtualDevice   aVDev( *this );
        ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice( *this ) );

        aVMap.SetOrigin( Point() );
        aVDev.SetMapMode( aVMap );
        aVDev.SetBackground( Wallpaper( Color( COL_BLACK ) ) );
        pVDev->SetMapMode( aVMap );
        pVDev->SetBackground( Wallpaper( Color( COL_BLACK ) ) );

        // set font first, to determine real output height
        aVDev.SetFont( aFont );
        pVDev->SetFont( aFont );

        const Size aVDevSize( aOutSize.Width(), aVDev.GetTextHeight() );
        const Size aVDevSize( aOutSize.Width(), pVDev->GetTextHeight() );

        if( aVDev.SetOutputSize( aVDevSize ) )
        if( pVDev->SetOutputSize( aVDevSize ) )
        {
            // Note: if performance gets an issue here, we can use NumberFormatter directly
            SvtSysLocale                aSysLocale;
@@ -524,8 +524,8 @@ void ShowWindow::DrawPauseScene( bool bTimeoutOnly )
            aText += " ( ";
            aText += aLocaleData.getDuration( ::tools::Time( 0, 0, mnPauseTimeout ) );
            aText += " )";
            aVDev.DrawText( Point( aOffset.Width(), 0 ), aText );
            DrawOutDev( Point( aOutOrg.X(), aOffset.Height() ), aVDevSize, Point(), aVDevSize, aVDev );
            pVDev->DrawText( Point( aOffset.Width(), 0 ), aText );
            DrawOutDev( Point( aOutOrg.X(), aOffset.Height() ), aVDevSize, Point(), aVDevSize, *pVDev.get() );
            bDrawn = true;
        }
    }
diff --git a/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx b/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx
index 6862a69..ea82e2a 100644
--- a/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx
+++ b/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx
@@ -134,19 +134,19 @@ void InsertionIndicatorOverlay::Create (

    // Create virtual devices for bitmap and mask whose bitmaps later be
    // combined to form the BitmapEx of the icon.
    VirtualDevice aContent (
    ScopedVclPtr<VirtualDevice> pContent( new VirtualDevice (
        *mrSlideSorter.GetContentWindow(),
        0,
        0);
    aContent.SetOutputSizePixel(aIconSize);
        0) );
    pContent->SetOutputSizePixel(aIconSize);

    aContent.SetFillColor();
    aContent.SetLineColor(pTheme->GetColor(Theme::Color_PreviewBorder));
    const Point aOffset = PaintRepresentatives(aContent, aPreviewSize, nOffset, rRepresentatives);
    pContent->SetFillColor();
    pContent->SetLineColor(pTheme->GetColor(Theme::Color_PreviewBorder));
    const Point aOffset = PaintRepresentatives(*pContent.get(), aPreviewSize, nOffset, rRepresentatives);

    PaintPageCount(aContent, nSelectionCount, aPreviewSize, aOffset);
    PaintPageCount(*pContent.get(), nSelectionCount, aPreviewSize, aOffset);

    maIcon = aContent.GetBitmapEx(Point(0,0), aIconSize);
    maIcon = pContent->GetBitmapEx(Point(0,0), aIconSize);
    maIcon.Scale(aIconSize);
}

diff --git a/slideshow/source/engine/rehearsetimingsactivity.cxx b/slideshow/source/engine/rehearsetimingsactivity.cxx
index 72d6db2..ad3535f 100644
--- a/slideshow/source/engine/rehearsetimingsactivity.cxx
+++ b/slideshow/source/engine/rehearsetimingsactivity.cxx
@@ -159,13 +159,13 @@ RehearseTimingsActivity::RehearseTimingsActivity( const SlideShowContext& rConte
    maFont.SetColor( COL_BLACK );

    // determine sprite size (in pixel):
    VirtualDevice blackHole;
    blackHole.EnableOutput(false);
    blackHole.SetFont( maFont );
    blackHole.SetMapMode( MAP_PIXEL );
    ScopedVclPtr<VirtualDevice> blackHole( new VirtualDevice() );
    blackHole->EnableOutput(false);
    blackHole->SetFont( maFont );
    blackHole->SetMapMode( MAP_PIXEL );
    Rectangle rect;
    const FontMetric metric( blackHole.GetFontMetric() );
    blackHole.GetTextBoundRect( rect, OUString("XX:XX:XX") );
    const FontMetric metric( blackHole->GetFontMetric() );
    blackHole->GetTextBoundRect( rect, OUString("XX:XX:XX") );
    maSpriteSizePixel.setX( rect.getWidth() * 12 / 10 );
    maSpriteSizePixel.setY( metric.GetLineHeight() * 11 / 10 );
    mnYOffset = (metric.GetAscent() + (metric.GetLineHeight() / 20));
@@ -444,30 +444,30 @@ void RehearseTimingsActivity::paint( cppcanvas::CanvasSharedPtr const & canvas )

    // create the MetaFile:
    GDIMetaFile metaFile;
    VirtualDevice blackHole;
    metaFile.Record( &blackHole );
    ScopedVclPtr<VirtualDevice> blackHole( new VirtualDevice() );
    metaFile.Record( blackHole );
    metaFile.SetPrefSize( Size( 1, 1 ) );
    blackHole.EnableOutput(false);
    blackHole.SetMapMode( MAP_PIXEL );
    blackHole.SetFont( maFont );
    blackHole->EnableOutput(false);
    blackHole->SetMapMode( MAP_PIXEL );
    blackHole->SetFont( maFont );
    Rectangle rect = Rectangle( 0,0,
                                maSpriteSizePixel.getX(),
                                maSpriteSizePixel.getY());
    if (mbDrawPressed)
    {
        blackHole.SetTextColor( COL_BLACK );
        blackHole.SetFillColor( COL_LIGHTGRAY );
        blackHole.SetLineColor( COL_GRAY );
        blackHole->SetTextColor( COL_BLACK );
        blackHole->SetFillColor( COL_LIGHTGRAY );
        blackHole->SetLineColor( COL_GRAY );
    }
    else
    {
        blackHole.SetTextColor( COL_BLACK );
        blackHole.SetFillColor( COL_WHITE );
        blackHole.SetLineColor( COL_GRAY );
        blackHole->SetTextColor( COL_BLACK );
        blackHole->SetFillColor( COL_WHITE );
        blackHole->SetLineColor( COL_GRAY );
    }
    blackHole.DrawRect( rect );
    blackHole.GetTextBoundRect( rect, time );
    blackHole.DrawText(
    blackHole->DrawRect( rect );
    blackHole->GetTextBoundRect( rect, time );
    blackHole->DrawText(
        Point( (maSpriteSizePixel.getX() - rect.getWidth()) / 2,
               mnYOffset ), time );

diff --git a/slideshow/source/engine/shapes/gdimtftools.cxx b/slideshow/source/engine/shapes/gdimtftools.cxx
index f3a52ca..b4a7833 100644
--- a/slideshow/source/engine/shapes/gdimtftools.cxx
+++ b/slideshow/source/engine/shapes/gdimtftools.cxx
@@ -286,14 +286,14 @@ bool getAnimationFromGraphic( VectorOfMtfAnimationFrames&   o_rFrames,
    // normalize animations to n bitmaps of same size. An Animation,
    // though, can contain bitmaps of varying sizes and different
    // update modes)
    VirtualDevice aVDev;
    aVDev.SetOutputSizePixel( aAnimSize );
    aVDev.EnableMapMode( false );
    ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice() );
    pVDev->SetOutputSizePixel( aAnimSize );
    pVDev->EnableMapMode( false );

    // setup mask VDev (alpha VDev is currently rather slow)
    VirtualDevice aVDevMask;
    aVDevMask.SetOutputSizePixel( aAnimSize );
    aVDevMask.EnableMapMode( false );
    ScopedVclPtr<VirtualDevice> pVDevMask( new VirtualDevice() );
    pVDevMask->SetOutputSizePixel( aAnimSize );
    pVDevMask->EnableMapMode( false );

    switch( aAnimation.GetCycleMode() )
    {
@@ -329,23 +329,23 @@ bool getAnimationFromGraphic( VectorOfMtfAnimationFrames&   o_rFrames,
        {
            case DISPOSE_NOT:
            {
                aVDev.DrawBitmapEx(rAnimBmp.aPosPix,
                pVDev->DrawBitmapEx(rAnimBmp.aPosPix,
                                   rAnimBmp.aBmpEx);
                Bitmap aMask = rAnimBmp.aBmpEx.GetMask();

                if( aMask.IsEmpty() )
                {
                    const Rectangle aRect(aEmptyPoint,
                                          aVDevMask.GetOutputSizePixel());
                                          pVDevMask->GetOutputSizePixel());
                    const Wallpaper aWallpaper(COL_BLACK);
                    aVDevMask.DrawWallpaper(aRect,
                    pVDevMask->DrawWallpaper(aRect,
                                            aWallpaper);
                }
                else
                {
                    BitmapEx aTmpMask = BitmapEx(aMask,
                                                 aMask);
                    aVDevMask.DrawBitmapEx(rAnimBmp.aPosPix,
                    pVDevMask->DrawBitmapEx(rAnimBmp.aPosPix,
                                           aTmpMask );
                }
                break;
@@ -357,35 +357,35 @@ bool getAnimationFromGraphic( VectorOfMtfAnimationFrames&   o_rFrames,
                const Bitmap aMask(rAnimBmp.aBmpEx.GetMask());
                const Bitmap aContent(rAnimBmp.aBmpEx.GetBitmap());

                aVDevMask.Erase();
                aVDev.DrawBitmap(rAnimBmp.aPosPix, aContent);
                pVDevMask->Erase();
                pVDev->DrawBitmap(rAnimBmp.aPosPix, aContent);

                if(aMask.IsEmpty())
                {
                    const Rectangle aRect(rAnimBmp.aPosPix, aContent.GetSizePixel());
                    aVDevMask.SetFillColor(COL_BLACK);
                    aVDevMask.SetLineColor();
                    aVDevMask.DrawRect(aRect);
                    pVDevMask->SetFillColor(COL_BLACK);
                    pVDevMask->SetLineColor();
                    pVDevMask->DrawRect(aRect);
                }
                else
                {
                    aVDevMask.DrawBitmap(rAnimBmp.aPosPix, aMask);
                    pVDevMask->DrawBitmap(rAnimBmp.aPosPix, aMask);
                }
                break;
            }

            case DISPOSE_FULL:
            {
                aVDev.DrawBitmapEx(rAnimBmp.aPosPix,
                pVDev->DrawBitmapEx(rAnimBmp.aPosPix,
                                   rAnimBmp.aBmpEx);
                break;
            }

            case DISPOSE_PREVIOUS :
            {
                aVDev.DrawBitmapEx(rAnimBmp.aPosPix,
                pVDev->DrawBitmapEx(rAnimBmp.aPosPix,
                                   rAnimBmp.aBmpEx);
                aVDevMask.DrawBitmap(rAnimBmp.aPosPix,
                pVDevMask->DrawBitmap(rAnimBmp.aPosPix,
                                     rAnimBmp.aBmpEx.GetMask());
                break;
            }
@@ -397,10 +397,10 @@ bool getAnimationFromGraphic( VectorOfMtfAnimationFrames&   o_rFrames,
        pMtf->AddAction(
            new MetaBmpExAction( aEmptyPoint,
                                 BitmapEx(
                                     aVDev.GetBitmap(
                                     pVDev->GetBitmap(
                                         aEmptyPoint,
                                         aAnimSize ),
                                     aVDevMask.GetBitmap(
                                     pVDevMask->GetBitmap(
                                         aEmptyPoint,
                                         aAnimSize ))));

diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
index 4e4de16..424e10c 100644
--- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx
+++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
@@ -519,12 +519,12 @@ void Test::testBinomInBinHor()
    pTree->Prepare(xDocShRef->GetFormat(), *xDocShRef);

    SmCursor aCursor(pTree, xDocShRef);
    VirtualDevice aOutputDevice;
    ScopedVclPtr<VirtualDevice> pOutputDevice( new VirtualDevice() );

    // move forward (more than) enough places to be at the end
    int i;
    for (i = 0; i < 8; ++i)
        aCursor.Move(&aOutputDevice, MoveRight);
        aCursor.Move(pOutputDevice, MoveRight);

    // tack +d on the end, which will put the binom into an SmBinHorNode
    aCursor.InsertElement(PlusElement);
@@ -547,18 +547,18 @@ void Test::testBinVerInUnary()
    pTree->Prepare(xDocShRef->GetFormat(), *xDocShRef);

    SmCursor aCursor(pTree, xDocShRef);
    VirtualDevice aOutputDevice;
    ScopedVclPtr<VirtualDevice> pOutputDevice( new VirtualDevice() );

    // move forward (more than) enough places to be at the end
    int i;
    for (i = 0; i < 3; ++i)
        aCursor.Move(&aOutputDevice, MoveRight);
        aCursor.Move(pOutputDevice, MoveRight);

    // select the operand
    aCursor.Move(&aOutputDevice, MoveLeft, false);
    aCursor.Move(pOutputDevice, MoveLeft, false);
    // set up a fraction
    aCursor.InsertFraction();
    aCursor.Move(&aOutputDevice, MoveDown);
    aCursor.Move(pOutputDevice, MoveDown);
    aCursor.InsertText("2");

    sExpected += " - { 1 over 2 } ";
@@ -576,7 +576,7 @@ void Test::testBinHorInSubSup()
    pTree->Prepare(xDocShRef->GetFormat(), *xDocShRef);

    SmCursor aCursor(pTree, xDocShRef);
    VirtualDevice aOutputDevice;
    ScopedVclPtr<VirtualDevice> pOutputDevice( new VirtualDevice() );

    // Insert an RSup expression with a BinHor for the exponent
    aCursor.InsertText("a");
@@ -586,7 +586,7 @@ void Test::testBinHorInSubSup()
    aCursor.InsertText("c");

    // Move to the end and add d to the expression
    aCursor.Move(&aOutputDevice, MoveRight);
    aCursor.Move(pOutputDevice, MoveRight);
    aCursor.InsertElement(PlusElement);
    aCursor.InsertText("d");

@@ -604,30 +604,30 @@ void Test::testUnaryInMixedNumberAsNumerator()
    pTree->Prepare(xDocShRef->GetFormat(), *xDocShRef);

    SmCursor aCursor(pTree, xDocShRef);
    VirtualDevice aOutputDevice;
    ScopedVclPtr<VirtualDevice> pOutputDevice( new VirtualDevice() );

    // move forward (more than) enough places to be at the end
    for (size_t i = 0; i < 3; ++i)
        aCursor.Move(&aOutputDevice, MoveRight);
        aCursor.Move(pOutputDevice, MoveRight);

    // Select the whole Unary Horizontal Node
    aCursor.Move(&aOutputDevice, MoveLeft, false);
    aCursor.Move(&aOutputDevice, MoveLeft, false);
    aCursor.Move(pOutputDevice, MoveLeft, false);
    aCursor.Move(pOutputDevice, MoveLeft, false);

    // Set up a fraction
    aCursor.InsertFraction();
    aCursor.Move(&aOutputDevice, MoveDown);
    aCursor.Move(pOutputDevice, MoveDown);
    aCursor.InsertText("2");

    // Move left and turn this into a mixed number
    // (bad form, but this could happen right?)
    aCursor.Move(&aOutputDevice, MoveLeft);
    aCursor.Move(&aOutputDevice, MoveLeft);
    aCursor.Move(pOutputDevice, MoveLeft);
    aCursor.Move(pOutputDevice, MoveLeft);
    aCursor.InsertText("2");

    // move forward (more than) enough places to be at the end
    for (size_t i = 0; i < 8; ++i)
        aCursor.Move(&aOutputDevice, MoveRight);
        aCursor.Move(pOutputDevice, MoveRight);

    // add 4 to the end
    aCursor.InsertElement(PlusElement);