sw/inc/viewsh.hxx | 2 sw/source/core/view/vnew.cxx | 117 +++++++++++++++---------------------------- 2 files changed, 43 insertions(+), 76 deletions(-)
New commits: commit 34dce05c66200d7cce9981d17222ea7a25e850ed Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Tue Jul 1 11:49:19 2025 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Jul 1 13:04:37 2025 +0200 sw: factor out common code Change-Id: If92f5254d27426ada0b30b97e6d417f60bab1a0d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187232 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Tested-by: Jenkins diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index ce9bdd25bae9..8dda97a48bac 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -176,7 +176,7 @@ class SAL_DLLPUBLIC_RTTI SwViewShell : public sw::Ring<SwViewShell> SwRootFramePtr mpLayout; // Initialization; called by the diverse constructors. - void Init( const SwViewOption *pNewOpt ); + void Init( const SwViewOption *pNewOpt, tools::Long nFlags); inline void ResetInvalidRect(); diff --git a/sw/source/core/view/vnew.cxx b/sw/source/core/view/vnew.cxx index 6cd779c81f98..2a57a1e61bcc 100644 --- a/sw/source/core/view/vnew.cxx +++ b/sw/source/core/view/vnew.cxx @@ -44,8 +44,21 @@ #include <ndindex.hxx> #include <accessibilityoptions.hxx> -void SwViewShell::Init( const SwViewOption *pNewOpt ) +void SwViewShell::Init( const SwViewOption *pNewOpt, tools::Long const nFlags) { + // in order to suppress event handling in + // <SwDrawContact::Changed> during construction of <SwViewShell> instance + mbInConstructor = true; + + mbPaintInProgress = mbViewLocked = mbInEndAction = false; + mbPaintWorks = mbEnableSmooth = true; + mbPreview = 0 !=( VSHELLFLAG_ISPREVIEW & nFlags ); + + // i#38810 Do not reset modified state of document, + // if it's already been modified. + const bool bIsDocModified( mxDoc->getIDocumentState().IsModified() ); + OutputDevice* pOrigOut = mpOut; + mbDocSizeChgd = false; // We play it safe: Remove old font information whenever the printer @@ -146,45 +159,7 @@ void SwViewShell::Init( const SwViewOption *pNewOpt ) = tools::Rectangle(Point(aClientVisibleArea.X, aClientVisibleArea.Y), Size(aClientVisibleArea.Width, aClientVisibleArea.Height)); } -} - -/// CTor for the first Shell. -SwViewShell::SwViewShell( SwDoc& rDocument, vcl::Window *pWindow, - const SwViewOption *pNewOpt, OutputDevice *pOutput, - tools::Long nFlags ) - : - mpSfxViewShell( nullptr ), - mpImp( new SwViewShellImp( *this ) ), - mpWin( pWindow ), - mpOut( pOutput ? pOutput - : pWindow ? pWindow->GetOutDev() - : static_cast<OutputDevice*>(rDocument.getIDocumentDeviceAccess().getPrinter( true ))), - mpAccOptions( new SwAccessibilityOptions ), - mbShowHeaderSeparator( false ), - mbShowFooterSeparator( false ), - mbHeaderFooterEdit( false ), - mpTargetPaintWindow(nullptr), - mpBufferedOut(nullptr), - mxDoc( &rDocument ), - mnStartAction( 0 ), - mnLockPaint( 0 ), - mbSelectAll(false), - mbOutputToWindow(false), - mpPrePostOutDev(nullptr) -{ - // in order to suppress event handling in - // <SwDrawContact::Changed> during construction of <SwViewShell> instance - mbInConstructor = true; - mbPaintInProgress = mbViewLocked = mbInEndAction = false; - mbPaintWorks = mbEnableSmooth = true; - mbPreview = 0 !=( VSHELLFLAG_ISPREVIEW & nFlags ); - - // i#38810 Do not reset modified state of document, - // if it's already been modified. - const bool bIsDocModified( mxDoc->getIDocumentState().IsModified() ); - OutputDevice* pOrigOut = mpOut; - Init( pNewOpt ); // may change the Outdev (InitPrt()) mpOut = pOrigOut; // initialize print preview layout after layout @@ -216,6 +191,33 @@ SwViewShell::SwViewShell( SwDoc& rDocument, vcl::Window *pWindow, mbInConstructor = false; } +/// CTor for the first Shell. +SwViewShell::SwViewShell( SwDoc& rDocument, vcl::Window *pWindow, + const SwViewOption *pNewOpt, OutputDevice *pOutput, + tools::Long nFlags ) + : + mpSfxViewShell( nullptr ), + mpImp( new SwViewShellImp( *this ) ), + mpWin( pWindow ), + mpOut( pOutput ? pOutput + : pWindow ? pWindow->GetOutDev() + : static_cast<OutputDevice*>(rDocument.getIDocumentDeviceAccess().getPrinter( true ))), + mpAccOptions( new SwAccessibilityOptions ), + mbShowHeaderSeparator( false ), + mbShowFooterSeparator( false ), + mbHeaderFooterEdit( false ), + mpTargetPaintWindow(nullptr), + mpBufferedOut(nullptr), + mxDoc( &rDocument ), + mnStartAction( 0 ), + mnLockPaint( 0 ), + mbSelectAll(false), + mbOutputToWindow(false), + mpPrePostOutDev(nullptr) +{ + Init( pNewOpt, nFlags ); // may change the Outdev (InitPrt()) +} + /// CTor for further Shells on a document. SwViewShell::SwViewShell( SwViewShell& rShell, vcl::Window *pWindow, OutputDevice * pOutput, tools::Long const nFlags) @@ -240,45 +242,10 @@ SwViewShell::SwViewShell( SwViewShell& rShell, vcl::Window *pWindow, mbOutputToWindow(false), mpPrePostOutDev(nullptr) { - // in order to suppress event handling in - // <SwDrawContact::Changed> during construction of <SwViewShell> instance - mbInConstructor = true; - - mbPaintWorks = mbEnableSmooth = true; - mbPaintInProgress = mbViewLocked = mbInEndAction = false; - mbPreview = 0 !=( VSHELLFLAG_ISPREVIEW & nFlags ); - if( nFlags & VSHELLFLAG_SHARELAYOUT ) mpLayout = rShell.mpLayout; - CurrShell aCurr( this ); - - bool bModified = mxDoc->getIDocumentState().IsModified(); - - OutputDevice* pOrigOut = mpOut; - Init( rShell.GetViewOptions() ); // might change Outdev (InitPrt()) - mpOut = pOrigOut; - - if ( mbPreview ) - mpImp->InitPagePreviewLayout(); - - static_cast<SwHiddenTextFieldType*>(mxDoc->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::HiddenText ))-> - SetHiddenFlag( !mpOpt->IsShowHiddenField() ); - - // In Init a standard FrameFormat is created. - if( !bModified && !mxDoc->GetIDocumentUndoRedo().IsUndoNoResetModified() ) - { - mxDoc->getIDocumentState().ResetModified(); - } - - // extend format cache. - if ( SwTextFrame::GetTextCache()->GetCurMax() < 2550 ) - SwTextFrame::GetTextCache()->IncreaseMax( 100 ); - if( mpOpt->IsGridVisible() || getIDocumentDrawModelAccess().GetDrawModel() ) - Imp()->MakeDrawView(); - - mbInConstructor = false; - + Init( rShell.GetViewOptions(), nFlags ); // might change Outdev (InitPrt()) } SwViewShell::~SwViewShell()