Related: tdf#155349 drop SetEndActionByVirDev from the html import

EndActionByVirDev only arises in the non-mainstream use html web document case and precedes the introduction of DoubleBuffer. It would be helpful to have one less corner case to consider.

Change-Id: Ibb9064cf5b37b1806f90c24ad9fbf84a8e37c0c3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151854
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 3c8bc31..656e473 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -137,8 +137,6 @@ class SW_DLLPUBLIC SwViewShell : public sw::Ring<SwViewShell>
    bool  mbFrameView       :1;  // If true it is a  (HTML-)Frame.
    bool  mbEnableSmooth    :1;  // Disable SmoothScroll, e.g. for drag
                                    // of scrollbars.
    bool  mbEndActionByVirDev:1; // Paints from EndAction always via virtual device
                                    // (e.g. when browsing).
    bool      mbShowHeaderSeparator:1; ///< Flag to say that we are showing the header control
    bool      mbShowFooterSeparator:1; ///< Flag to say that we are showing the footer control
    bool      mbHeaderFooterEdit:1;  ///< Flag to say that we are editing header or footer (according to the bShow(Header|Footer)Separator above)
@@ -204,9 +202,6 @@ public:
    bool ActionPend() const { return mnStartAction != 0; }
    bool IsInEndAction() const { return mbInEndAction; }

    void SetEndActionByVirDev( bool b ) { mbEndActionByVirDev = b; }
    bool IsEndActionByVirDev() const    { return mbEndActionByVirDev; }

    // The ActionCount for all Shells is temporarily set to zero and then
    // restored at the RootFrame via UNO.
    void    SetRestoreActions(sal_uInt16 nSet);
diff --git a/sw/source/core/doc/htmltbl.cxx b/sw/source/core/doc/htmltbl.cxx
index ffa1a63..4711a12 100644
--- a/sw/source/core/doc/htmltbl.cxx
+++ b/sw/source/core/doc/htmltbl.cxx
@@ -1684,8 +1684,8 @@ void SwHTMLTableLayout::Resize_( sal_uInt16 nAbsAvail, bool bRecalc )
    // Else we can set the widths, in which we have to run Pass 2 in each case.
    SetWidths( true, nAbsAvail );

    if ( pRoot && pRoot->IsCallbackActionEnabled() )
        pRoot->EndAllAction( true );    //True per VirDev (browsing is calmer)
    if (pRoot && pRoot->IsCallbackActionEnabled())
        pRoot->EndAllAction();
}

IMPL_LINK_NOARG( SwHTMLTableLayout, DelayedResize_Impl, Timer*, void )
diff --git a/sw/source/core/inc/rootfrm.hxx b/sw/source/core/inc/rootfrm.hxx
index 0caf401..80e104c9 100644
--- a/sw/source/core/inc/rootfrm.hxx
+++ b/sw/source/core/inc/rootfrm.hxx
@@ -223,7 +223,7 @@ public:
     * automatically in the EndAllAction.
     */
    void StartAllAction();
    void EndAllAction( bool bVirDev = false );
    void EndAllAction();

    /**
     * Certain UNO Actions (e.g. table cursor) require that all Actions are reset temporarily
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index c38201a..6f11380 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -1929,15 +1929,13 @@ void SwRootFrame::StartAllAction()
        }
}

void SwRootFrame::EndAllAction( bool bVirDev )
void SwRootFrame::EndAllAction()
{
    if ( !GetCurrShell() )
        return;

    for(SwViewShell& rSh : GetCurrShell()->GetRingContainer())
    {
        const bool bOldEndActionByVirDev = rSh.IsEndActionByVirDev();
        rSh.SetEndActionByVirDev( bVirDev );
        if ( auto pCursorShell = dynamic_cast<SwCursorShell*>( &rSh) )
        {
            pCursorShell->EndAction();
@@ -1947,7 +1945,6 @@ void SwRootFrame::EndAllAction( bool bVirDev )
        }
        else
            rSh.EndAction();
        rSh.SetEndActionByVirDev( bOldEndActionByVirDev );
    }
}

diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index a6197e9..16717f4 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -337,71 +337,12 @@ void SwViewShell::ImplEndAction( const bool bIdleEnd )
                oRegion->LimitToOrigin();
                oRegion->Compress( SwRegionRects::CompressFuzzy );

                ScopedVclPtr<VirtualDevice> pVout;
                while ( !oRegion->empty() )
                {
                    SwRect aRect( oRegion->back() );
                    oRegion->pop_back();

                    bool bPaint = true;
                    if ( IsEndActionByVirDev() )
                    {
                        //create virtual device and set.
                        if ( !pVout )
                            pVout = VclPtr<VirtualDevice>::Create( *GetOut() );
                        MapMode aMapMode( GetOut()->GetMapMode() );
                        pVout->SetMapMode( aMapMode );

                        bool bSizeOK = true;

                        tools::Rectangle aTmp1( aRect.SVRect() );
                        aTmp1 = GetOut()->LogicToPixel( aTmp1 );
                        tools::Rectangle aTmp2( GetOut()->PixelToLogic( aTmp1 ) );
                        if ( aTmp2.Left() > aRect.Left() )
                            aTmp1.SetLeft( std::max( tools::Long(0), aTmp1.Left() - 1 ) );
                        if ( aTmp2.Top() > aRect.Top() )
                            aTmp1.SetTop( std::max<tools::Long>( 0, aTmp1.Top() - 1 ) );
                        aTmp1.AdjustRight(1 );
                        aTmp1.AdjustBottom(1 );
                        aTmp1 = GetOut()->PixelToLogic( aTmp1 );
                        aRect = SwRect( aTmp1 );

                        const Size aTmp( pVout->GetOutputSize() );
                        if ( aTmp.Height() < aRect.Height() ||
                             aTmp.Width()  < aRect.Width() )
                        {
                            bSizeOK = pVout->SetOutputSize( aRect.SSize() );
                        }
                        if ( bSizeOK )
                        {
                            bPaint = false;

                            // --> OD 2007-07-26 #i79947#
                            // #i72754# start Pre/PostPaint encapsulation before mpOut is changed to the buffering VDev
                            const vcl::Region aRepaintRegion(aRect.SVRect());
                            DLPrePaint2(aRepaintRegion);
                            // <--

                            OutputDevice  *pOld = GetOut();
                            pVout->SetLineColor( pOld->GetLineColor() );
                            pVout->SetFillColor( pOld->GetFillColor() );
                            Point aOrigin( aRect.Pos() );
                            aOrigin.setX( -aOrigin.X() ); aOrigin.setY( -aOrigin.Y() );
                            aMapMode.SetOrigin( aOrigin );
                            pVout->SetMapMode( aMapMode );

                            mpOut = pVout.get();
                            if ( bPaintsFromSystem )
                                PaintDesktop(*mpOut, aRect);
                            pCurrentLayout->PaintSwFrame( *mpOut, aRect );
                            pOld->DrawOutDev( aRect.Pos(), aRect.SSize(),
                                              aRect.Pos(), aRect.SSize(), *pVout );
                            mpOut = pOld;

                            // #i72754# end Pre/PostPaint encapsulation when mpOut is back and content is painted
                            DLPostPaint2(true);
                        }
                    }
                    const bool bPaint = true;
                    if ( bPaint )
                    {
                        if (GetWin()->SupportsDoubleBuffering())
diff --git a/sw/source/core/view/vnew.cxx b/sw/source/core/view/vnew.cxx
index b841134..0d097f0 100644
--- a/sw/source/core/view/vnew.cxx
+++ b/sw/source/core/view/vnew.cxx
@@ -168,8 +168,7 @@ SwViewShell::SwViewShell( SwDoc& rDocument, vcl::Window *pWindow,
    // <SwDrawContact::Changed> during construction of <SwViewShell> instance
    mbInConstructor = true;

    mbPaintInProgress = mbViewLocked = mbInEndAction = mbFrameView =
    mbEndActionByVirDev = false;
    mbPaintInProgress = mbViewLocked = mbInEndAction = mbFrameView = false;
    mbPaintWorks = mbEnableSmooth = true;
    mbPreview = 0 !=( VSHELLFLAG_ISPREVIEW & nFlags );

@@ -238,8 +237,7 @@ SwViewShell::SwViewShell( SwViewShell& rShell, vcl::Window *pWindow,
    mbInConstructor = true;

    mbPaintWorks = mbEnableSmooth = true;
    mbPaintInProgress = mbViewLocked = mbInEndAction = mbFrameView =
    mbEndActionByVirDev = false;
    mbPaintInProgress = mbViewLocked = mbInEndAction = mbFrameView = false;
    mbPreview = 0 !=( VSHELLFLAG_ISPREVIEW & nFlags );

    if( nFlags & VSHELLFLAG_SHARELAYOUT )
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index cfc4a6d..e32eb6e 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -2683,10 +2683,7 @@ SwViewShell *SwHTMLParser::CallEndAction( bool bChkAction, bool bChkPtr )
        // Already scrolled?, then make sure that the view doesn't move!
        const bool bOldLock = m_pActionViewShell->IsViewLocked();
        m_pActionViewShell->LockView( true );
        const bool bOldEndActionByVirDev = m_pActionViewShell->IsEndActionByVirDev();
        m_pActionViewShell->SetEndActionByVirDev( true );
        pEditShell->EndAction();
        m_pActionViewShell->SetEndActionByVirDev( bOldEndActionByVirDev );
        m_pActionViewShell->LockView( bOldLock );

        // bChkJumpMark is only set when the object was also found