basctl/source/basicide/basidesh.cxx | 4 basctl/source/inc/basidesh.hxx | 2 include/sfx2/viewfac.hxx | 4 include/sfx2/viewsh.hxx | 8 - sc/source/ui/inc/prevwsh.hxx | 3 sc/source/ui/inc/tabvwsh.hxx | 3 sc/source/ui/view/prevwsh.cxx | 10 +- sc/source/ui/view/tabvwsh4.cxx | 9 -- sd/source/ui/inc/GraphicViewShellBase.hxx | 2 sd/source/ui/inc/ImpressViewShellBase.hxx | 2 sd/source/ui/inc/OutlineViewShellBase.hxx | 2 sd/source/ui/inc/PresentationViewShellBase.hxx | 2 sd/source/ui/inc/SlideSorterViewShellBase.hxx | 2 sd/source/ui/inc/ViewShellBase.hxx | 2 sd/source/ui/view/GraphicViewShellBase.cxx | 8 - sd/source/ui/view/ImpressViewShellBase.cxx | 8 - sd/source/ui/view/OutlineViewShellBase.cxx | 8 - sd/source/ui/view/PresentationViewShellBase.cxx | 10 +- sd/source/ui/view/SlideSorterViewShellBase.cxx | 8 - sd/source/ui/view/ViewShellBase.cxx | 10 +- sfx2/source/doc/sfxbasemodel.cxx | 4 sfx2/source/view/viewfac.cxx | 4 sfx2/source/view/viewsh.cxx | 12 +- starmath/inc/view.hxx | 2 starmath/source/view.cxx | 6 - sw/inc/view.hxx | 2 sw/qa/core/layout/data/floattable-vertoffset.docx |binary sw/qa/core/layout/flycnt.cxx | 45 ++++++++++ sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx | 11 ++ sw/source/uibase/inc/pview.hxx | 2 sw/source/uibase/inc/srcview.hxx | 2 sw/source/uibase/inc/wview.hxx | 2 sw/source/uibase/uiview/pview.cxx | 10 +- sw/source/uibase/uiview/srcview.cxx | 6 - sw/source/uibase/uiview/view.cxx | 8 - sw/source/uibase/web/wview.cxx | 4 36 files changed, 140 insertions(+), 87 deletions(-)
New commits: commit dc214bcff335024f21c208e239cc36232d611145 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Wed Feb 15 19:52:01 2023 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Thu Feb 16 09:24:57 2023 +0000 SfxViewShell never takes a null SfxViewFrame* Change-Id: I36f3a5c77a7fb2d3cf267184e403e6cd24dbd70b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147112 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx index ae61007c7bf8..0c3c5bb16de7 100644 --- a/basctl/source/basicide/basidesh.cxx +++ b/basctl/source/basicide/basidesh.cxx @@ -161,8 +161,8 @@ void basctl_Shell::InitInterface_Impl() unsigned Shell::nShellCount = 0; -Shell::Shell( SfxViewFrame* pFrame_, SfxViewShell* /* pOldShell */ ) : - SfxViewShell( pFrame_, SfxViewShellFlags::NO_NEWWINDOW ), +Shell::Shell( SfxViewFrame& rFrame_, SfxViewShell* /* pOldShell */ ) : + SfxViewShell( rFrame_, SfxViewShellFlags::NO_NEWWINDOW ), m_aCurDocument( ScriptDocument::getApplicationScriptDocument() ), aHScrollBar( VclPtr<ScrollAdaptor>::Create(&GetViewFrame()->GetWindow(), true) ), aVScrollBar( VclPtr<ScrollAdaptor>::Create(&GetViewFrame()->GetWindow(), false) ), diff --git a/basctl/source/inc/basidesh.hxx b/basctl/source/inc/basidesh.hxx index 7c8779d62d12..f907abe6f214 100644 --- a/basctl/source/inc/basidesh.hxx +++ b/basctl/source/inc/basidesh.hxx @@ -156,7 +156,7 @@ private: static void InitInterface_Impl(); public: - Shell( SfxViewFrame *pFrame, SfxViewShell *pOldSh ); + Shell(SfxViewFrame& rFrame, SfxViewShell *pOldSh); virtual ~Shell() override; BaseWindow* GetCurWindow() const { return pCurWin; } diff --git a/include/sfx2/viewfac.hxx b/include/sfx2/viewfac.hxx index efd511ea2b3d..c09791216f0e 100644 --- a/include/sfx2/viewfac.hxx +++ b/include/sfx2/viewfac.hxx @@ -27,7 +27,7 @@ class SfxViewFrame; class SfxViewShell; -typedef SfxViewShell* (*SfxViewCtor)(SfxViewFrame*, SfxViewShell*); +typedef SfxViewShell* (*SfxViewCtor)(SfxViewFrame&, SfxViewShell*); // CLASS ----------------------------------------------------------------- class SFX2_DLLPUBLIC SfxViewFactory @@ -36,7 +36,7 @@ public: SfxViewFactory( SfxViewCtor fnC, SfxInterfaceId nOrdinal, const char* asciiViewName ); - SfxViewShell* CreateInstance(SfxViewFrame *pViewFrame, SfxViewShell *pOldSh); + SfxViewShell* CreateInstance(SfxViewFrame& rViewFrame, SfxViewShell *pOldSh); SfxInterfaceId GetOrdinal() const { return nOrd; } /// returns a legacy view name. This is "view" with an appended ordinal/ID. diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx index a948f0f5baea..1e70f8301bda 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -128,15 +128,15 @@ class SfxViewFactory; private: \ static SfxViewFactory *s_pFactory; \ public: \ - static SfxViewShell *CreateInstance(SfxViewFrame *pFrame, SfxViewShell *pOldView); \ + static SfxViewShell *CreateInstance(SfxViewFrame& rFrame, SfxViewShell *pOldView); \ static void RegisterFactory( SfxInterfaceId nPrio ); \ static SfxViewFactory*Factory() { return s_pFactory; } \ static void InitFactory() #define SFX_IMPL_NAMED_VIEWFACTORY(Class, AsciiViewName) \ SfxViewFactory* Class::s_pFactory; \ - SfxViewShell* Class::CreateInstance(SfxViewFrame *pFrame, SfxViewShell *pOldView) \ - { return new Class(pFrame, pOldView); } \ + SfxViewShell* Class::CreateInstance(SfxViewFrame& rFrame, SfxViewShell *pOldView) \ + { return new Class(rFrame, pOldView); } \ void Class::RegisterFactory( SfxInterfaceId nPrio ) \ { \ s_pFactory = new SfxViewFactory(&CreateInstance,nPrio,AsciiViewName);\ @@ -211,7 +211,7 @@ private: public: - SfxViewShell( SfxViewFrame *pFrame, SfxViewShellFlags nFlags ); + SfxViewShell( SfxViewFrame& rFrame, SfxViewShellFlags nFlags ); virtual ~SfxViewShell() override; SfxInPlaceClient* GetIPClient() const; diff --git a/sc/source/ui/inc/prevwsh.hxx b/sc/source/ui/inc/prevwsh.hxx index c1260a7dbb0d..5c2a37c4a519 100644 --- a/sc/source/ui/inc/prevwsh.hxx +++ b/sc/source/ui/inc/prevwsh.hxx @@ -84,8 +84,7 @@ private: static void InitInterface_Impl(); public: - ScPreviewShell( SfxViewFrame* pViewFrame, - SfxViewShell* pOldSh ); + ScPreviewShell(SfxViewFrame& rViewFrame, SfxViewShell* pOldSh); virtual ~ScPreviewShell() override; diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index a1688fb11f83..31709a47c16a 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -225,8 +225,7 @@ private: public: /** -> Clone Method for Factory Created from a general shell and inherit as much as possible */ - ScTabViewShell( SfxViewFrame* pViewFrame, - SfxViewShell* pOldSh ); + ScTabViewShell(SfxViewFrame& rViewFrame, SfxViewShell* pOldSh); virtual ~ScTabViewShell() override; diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx index 5ae90d6be22a..a35122cbfad5 100644 --- a/sc/source/ui/view/prevwsh.cxx +++ b/sc/source/ui/view/prevwsh.cxx @@ -143,17 +143,17 @@ void ScPreviewShell::Construct( vcl::Window* pParent ) SetName("Preview"); } -ScPreviewShell::ScPreviewShell( SfxViewFrame* pViewFrame, - SfxViewShell* pOldSh ) : - SfxViewShell( pViewFrame, SfxViewShellFlags::HAS_PRINTOPTIONS ), - pDocShell( static_cast<ScDocShell*>(pViewFrame->GetObjectShell()) ), +ScPreviewShell::ScPreviewShell(SfxViewFrame& rViewFrame, + SfxViewShell* pOldSh) : + SfxViewShell(rViewFrame, SfxViewShellFlags::HAS_PRINTOPTIONS), + pDocShell( static_cast<ScDocShell*>(rViewFrame.GetObjectShell()) ), mpFrameWindow(nullptr), nSourceDesignMode( TRISTATE_INDET ), nMaxVertPos(0), nPrevHThumbPos(0), nPrevVThumbPos(0) { - Construct( &pViewFrame->GetWindow() ); + Construct(&rViewFrame.GetWindow()); SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::Printpreview)); if ( auto pTabViewShell = dynamic_cast<ScTabViewShell*>( pOldSh) ) diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index 63cbf1f2229a..43084c917971 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -1130,8 +1130,7 @@ IMPL_LINK_NOARG(ScTabViewShell, SimpleRefClose, const OUString*, void) static ScTabViewObj* lcl_GetViewObj( const ScTabViewShell& rShell ) { ScTabViewObj* pRet = nullptr; - SfxViewFrame* pViewFrame = rShell.GetViewFrame(); - if (pViewFrame) + if (SfxViewFrame* pViewFrame = rShell.GetViewFrame()) { SfxFrame& rFrame = pViewFrame->GetFrame(); uno::Reference<frame::XController> xController = rFrame.GetController(); @@ -1690,10 +1689,10 @@ void ScTabViewShell::Construct( TriState nForceDesignMode ) SetBorderPixel( aBorder ); } -ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame, +ScTabViewShell::ScTabViewShell( SfxViewFrame& rViewFrame, SfxViewShell* pOldSh ) : - SfxViewShell( pViewFrame, SfxViewShellFlags::HAS_PRINTOPTIONS ), - ScDBFunc( &pViewFrame->GetWindow(), static_cast<ScDocShell&>(*pViewFrame->GetObjectShell()), this ), + SfxViewShell(rViewFrame, SfxViewShellFlags::HAS_PRINTOPTIONS), + ScDBFunc( &rViewFrame.GetWindow(), static_cast<ScDocShell&>(*rViewFrame.GetObjectShell()), this ), eCurOST(OST_NONE), nDrawSfxId(0), aTarget(this), diff --git a/sd/source/ui/inc/GraphicViewShellBase.hxx b/sd/source/ui/inc/GraphicViewShellBase.hxx index 89a96cf51887..ffec962fc844 100644 --- a/sd/source/ui/inc/GraphicViewShellBase.hxx +++ b/sd/source/ui/inc/GraphicViewShellBase.hxx @@ -34,7 +34,7 @@ public: /** This constructor is used by the view factory of the SFX macros. */ - GraphicViewShellBase(SfxViewFrame* pFrame, SfxViewShell* pOldShell); + GraphicViewShellBase(SfxViewFrame& rFrame, SfxViewShell* pOldShell); virtual ~GraphicViewShellBase() override; /** Callback function for general slot calls. diff --git a/sd/source/ui/inc/ImpressViewShellBase.hxx b/sd/source/ui/inc/ImpressViewShellBase.hxx index 80070e7c8022..402013fa7ff9 100644 --- a/sd/source/ui/inc/ImpressViewShellBase.hxx +++ b/sd/source/ui/inc/ImpressViewShellBase.hxx @@ -34,7 +34,7 @@ public: /** This constructor is used by the view factory of the SFX macros. */ - ImpressViewShellBase(SfxViewFrame* pFrame, SfxViewShell* pOldShell); + ImpressViewShellBase(SfxViewFrame& rFrame, SfxViewShell* pOldShell); virtual ~ImpressViewShellBase() override; /** Callback function for general slot calls. diff --git a/sd/source/ui/inc/OutlineViewShellBase.hxx b/sd/source/ui/inc/OutlineViewShellBase.hxx index 13527d80dc7d..96458bba1b87 100644 --- a/sd/source/ui/inc/OutlineViewShellBase.hxx +++ b/sd/source/ui/inc/OutlineViewShellBase.hxx @@ -34,7 +34,7 @@ public: /** This constructor is used by the view factory of the SFX macros. */ - OutlineViewShellBase(SfxViewFrame* pFrame, SfxViewShell* pOldShell); + OutlineViewShellBase(SfxViewFrame& rFrame, SfxViewShell* pOldShell); virtual ~OutlineViewShellBase() override; }; diff --git a/sd/source/ui/inc/PresentationViewShellBase.hxx b/sd/source/ui/inc/PresentationViewShellBase.hxx index 684e5ee6166e..d8779c4a5029 100644 --- a/sd/source/ui/inc/PresentationViewShellBase.hxx +++ b/sd/source/ui/inc/PresentationViewShellBase.hxx @@ -34,7 +34,7 @@ public: /** This constructor is used by the view factory of the SFX macros. */ - PresentationViewShellBase(SfxViewFrame* pFrame, SfxViewShell* pOldShell); + PresentationViewShellBase(SfxViewFrame& rFrame, SfxViewShell* pOldShell); virtual ~PresentationViewShellBase() override; protected: diff --git a/sd/source/ui/inc/SlideSorterViewShellBase.hxx b/sd/source/ui/inc/SlideSorterViewShellBase.hxx index e1ca1b57b9d2..38bf64919881 100644 --- a/sd/source/ui/inc/SlideSorterViewShellBase.hxx +++ b/sd/source/ui/inc/SlideSorterViewShellBase.hxx @@ -34,7 +34,7 @@ public: /** This constructor is used by the view factory of the SFX macros. */ - SlideSorterViewShellBase(SfxViewFrame* pFrame, SfxViewShell* pOldShell); + SlideSorterViewShellBase(SfxViewFrame& rFrame, SfxViewShell* pOldShell); virtual ~SlideSorterViewShellBase() override; }; diff --git a/sd/source/ui/inc/ViewShellBase.hxx b/sd/source/ui/inc/ViewShellBase.hxx index 06b46514a487..ed80658d096c 100644 --- a/sd/source/ui/inc/ViewShellBase.hxx +++ b/sd/source/ui/inc/ViewShellBase.hxx @@ -67,7 +67,7 @@ public: terminates and before doing anything else. */ ViewShellBase ( - SfxViewFrame *pFrame, + SfxViewFrame& rFrame, SfxViewShell* pOldShell); virtual ~ViewShellBase() override; diff --git a/sd/source/ui/view/GraphicViewShellBase.cxx b/sd/source/ui/view/GraphicViewShellBase.cxx index 98706271ebf9..a3f8ece26c11 100644 --- a/sd/source/ui/view/GraphicViewShellBase.cxx +++ b/sd/source/ui/view/GraphicViewShellBase.cxx @@ -35,9 +35,9 @@ namespace sd // new GraphicViewShellBase object has been constructed. SfxViewFactory* GraphicViewShellBase::s_pFactory; -SfxViewShell* GraphicViewShellBase::CreateInstance(SfxViewFrame* pFrame, SfxViewShell* pOldView) +SfxViewShell* GraphicViewShellBase::CreateInstance(SfxViewFrame& rFrame, SfxViewShell* pOldView) { - GraphicViewShellBase* pBase = new GraphicViewShellBase(pFrame, pOldView); + GraphicViewShellBase* pBase = new GraphicViewShellBase(rFrame, pOldView); pBase->LateInit(framework::FrameworkHelper::msDrawViewURL); return pBase; } @@ -48,8 +48,8 @@ void GraphicViewShellBase::RegisterFactory(SfxInterfaceId nPrio) } void GraphicViewShellBase::InitFactory() { SFX_VIEW_REGISTRATION(GraphicDocShell); } -GraphicViewShellBase::GraphicViewShellBase(SfxViewFrame* _pFrame, SfxViewShell* pOldShell) - : ViewShellBase(_pFrame, pOldShell) +GraphicViewShellBase::GraphicViewShellBase(SfxViewFrame& _rFrame, SfxViewShell* pOldShell) + : ViewShellBase(_rFrame, pOldShell) { } diff --git a/sd/source/ui/view/ImpressViewShellBase.cxx b/sd/source/ui/view/ImpressViewShellBase.cxx index c28a00e7989d..929b607dbbdd 100644 --- a/sd/source/ui/view/ImpressViewShellBase.cxx +++ b/sd/source/ui/view/ImpressViewShellBase.cxx @@ -39,9 +39,9 @@ namespace sd { SfxViewFactory* ImpressViewShellBase::s_pFactory; SfxViewShell* ImpressViewShellBase::CreateInstance ( - SfxViewFrame *pFrame, SfxViewShell *pOldView) + SfxViewFrame& rFrame, SfxViewShell *pOldView) { - ImpressViewShellBase* pBase = new ImpressViewShellBase(pFrame, pOldView); + ImpressViewShellBase* pBase = new ImpressViewShellBase(rFrame, pOldView); pBase->LateInit(comphelper::LibreOfficeKit::isActive() ? framework::FrameworkHelper::msImpressViewURL : ""); return pBase; } @@ -56,9 +56,9 @@ void ImpressViewShellBase::InitFactory() } ImpressViewShellBase::ImpressViewShellBase ( - SfxViewFrame* _pFrame, + SfxViewFrame& _rFrame, SfxViewShell* pOldShell) - : ViewShellBase (_pFrame, pOldShell) + : ViewShellBase (_rFrame, pOldShell) { MasterPageObserver::Instance().RegisterDocument (*GetDocShell()->GetDoc()); } diff --git a/sd/source/ui/view/OutlineViewShellBase.cxx b/sd/source/ui/view/OutlineViewShellBase.cxx index 8da1bcbcae08..e3efb3ed59d5 100644 --- a/sd/source/ui/view/OutlineViewShellBase.cxx +++ b/sd/source/ui/view/OutlineViewShellBase.cxx @@ -34,9 +34,9 @@ class DrawDocShell; SfxViewFactory* OutlineViewShellBase::s_pFactory; SfxViewShell* OutlineViewShellBase::CreateInstance ( - SfxViewFrame *pFrame, SfxViewShell *pOldView) + SfxViewFrame& rFrame, SfxViewShell *pOldView) { - OutlineViewShellBase* pBase = new OutlineViewShellBase(pFrame, pOldView); + OutlineViewShellBase* pBase = new OutlineViewShellBase(rFrame, pOldView); pBase->LateInit(framework::FrameworkHelper::msOutlineViewURL); return pBase; } @@ -51,9 +51,9 @@ void OutlineViewShellBase::InitFactory() } OutlineViewShellBase::OutlineViewShellBase ( - SfxViewFrame* _pFrame, + SfxViewFrame& _rFrame, SfxViewShell* pOldShell) - : ImpressViewShellBase (_pFrame, pOldShell) + : ImpressViewShellBase (_rFrame, pOldShell) { } diff --git a/sd/source/ui/view/PresentationViewShellBase.cxx b/sd/source/ui/view/PresentationViewShellBase.cxx index 5a0f13d75881..525c0813d9d6 100644 --- a/sd/source/ui/view/PresentationViewShellBase.cxx +++ b/sd/source/ui/view/PresentationViewShellBase.cxx @@ -42,10 +42,10 @@ class DrawDocShell; SfxViewFactory* PresentationViewShellBase::s_pFactory; SfxViewShell* PresentationViewShellBase::CreateInstance ( - SfxViewFrame *_pFrame, SfxViewShell *pOldView) + SfxViewFrame& _rFrame, SfxViewShell *pOldView) { PresentationViewShellBase* pBase = - new PresentationViewShellBase(_pFrame, pOldView); + new PresentationViewShellBase(_rFrame, pOldView); pBase->LateInit(framework::FrameworkHelper::msPresentationViewURL); return pBase; } @@ -61,13 +61,13 @@ void PresentationViewShellBase::InitFactory() } PresentationViewShellBase::PresentationViewShellBase ( - SfxViewFrame* _pFrame, + SfxViewFrame& _rFrame, SfxViewShell* pOldShell) - : ViewShellBase (_pFrame, pOldShell) + : ViewShellBase (_rFrame, pOldShell) { // Hide the automatic (non-context sensitive) tool bars. Reference<beans::XPropertySet> xFrameSet ( - _pFrame->GetFrame().GetFrameInterface(), + _rFrame.GetFrame().GetFrameInterface(), UNO_QUERY); if (xFrameSet.is()) { diff --git a/sd/source/ui/view/SlideSorterViewShellBase.cxx b/sd/source/ui/view/SlideSorterViewShellBase.cxx index ecf679c981f2..3c5578e8a191 100644 --- a/sd/source/ui/view/SlideSorterViewShellBase.cxx +++ b/sd/source/ui/view/SlideSorterViewShellBase.cxx @@ -34,9 +34,9 @@ class DrawDocShell; SfxViewFactory* SlideSorterViewShellBase::s_pFactory; SfxViewShell* SlideSorterViewShellBase::CreateInstance ( - SfxViewFrame *pFrame, SfxViewShell *pOldView) + SfxViewFrame& rFrame, SfxViewShell *pOldView) { - SlideSorterViewShellBase* pBase = new SlideSorterViewShellBase(pFrame, pOldView); + SlideSorterViewShellBase* pBase = new SlideSorterViewShellBase(rFrame, pOldView); pBase->LateInit(framework::FrameworkHelper::msSlideSorterURL); return pBase; } @@ -53,9 +53,9 @@ void SlideSorterViewShellBase::InitFactory() } SlideSorterViewShellBase::SlideSorterViewShellBase ( - SfxViewFrame* _pFrame, + SfxViewFrame& _rFrame, SfxViewShell* pOldShell) - : ImpressViewShellBase (_pFrame, pOldShell) + : ImpressViewShellBase (_rFrame, pOldShell) { } diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx index a3a154ce0ee6..a4af703afb38 100644 --- a/sd/source/ui/view/ViewShellBase.cxx +++ b/sd/source/ui/view/ViewShellBase.cxx @@ -220,17 +220,17 @@ void ViewShellBase::InitInterface_Impl() } ViewShellBase::ViewShellBase ( - SfxViewFrame* _pFrame, + SfxViewFrame& _rFrame, SfxViewShell*) - : SfxViewShell (_pFrame, SfxViewShellFlags::HAS_PRINTOPTIONS), + : SfxViewShell(_rFrame, SfxViewShellFlags::HAS_PRINTOPTIONS), mpDocShell (nullptr), mpDocument (nullptr) { mpImpl.reset(new Implementation(*this)); - mpImpl->mpViewWindow = VclPtr<FocusForwardingWindow>::Create(_pFrame->GetWindow(),*this); + mpImpl->mpViewWindow = VclPtr<FocusForwardingWindow>::Create(_rFrame.GetWindow(),*this); mpImpl->mpViewWindow->SetBackground(Wallpaper()); - _pFrame->GetWindow().SetBackground(Application::GetSettings().GetStyleSettings().GetLightColor()); + _rFrame.GetWindow().SetBackground(Application::GetSettings().GetStyleSettings().GetLightColor()); // Set up the members in the correct order. if (auto pDrawDocShell = dynamic_cast< DrawDocShell *>( GetViewFrame()->GetObjectShell() )) @@ -242,7 +242,7 @@ ViewShellBase::ViewShellBase ( SetWindow(mpImpl->mpViewWindow.get()); // Hide the window to avoid complaints from Sfx...SwitchViewShell... - _pFrame->GetWindow().Hide(); + _rFrame.GetWindow().Hide(); } /** In this destructor the order in which some of the members are destroyed diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index dcc559fc4f87..84797484d3a3 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -4262,11 +4262,11 @@ Reference< frame::XController2 > SAL_CALL SfxBaseModel::createViewController( // determine the ViewFrame belonging to the given XFrame SfxViewFrame* pViewFrame = FindOrCreateViewFrame_Impl( i_rFrame, aViewCreationGuard ); - SAL_WARN_IF( !pViewFrame , "sfx.doc", "SfxBaseModel::createViewController: no frame?" ); + assert(pViewFrame && "SfxBaseModel::createViewController: no frame"); // delegate to SFX' view factory pViewFrame->GetBindings().ENTERREGISTRATIONS(); - SfxViewShell* pViewShell = pViewFactory->CreateInstance( pViewFrame, pOldViewShell ); + SfxViewShell* pViewShell = pViewFactory->CreateInstance(*pViewFrame, pOldViewShell); pViewFrame->GetBindings().LEAVEREGISTRATIONS(); ENSURE_OR_THROW( pViewShell, "invalid view shell provided by factory" ); diff --git a/sfx2/source/view/viewfac.cxx b/sfx2/source/view/viewfac.cxx index b83f4184725e..fbcb8c2c14f6 100644 --- a/sfx2/source/view/viewfac.cxx +++ b/sfx2/source/view/viewfac.cxx @@ -21,9 +21,9 @@ #include <sfx2/viewfrm.hxx> #include <sfx2/viewsh.hxx> -SfxViewShell *SfxViewFactory::CreateInstance(SfxViewFrame *pFrame, SfxViewShell *pOldSh ) +SfxViewShell *SfxViewFactory::CreateInstance(SfxViewFrame& rFrame, SfxViewShell *pOldSh) { - return (*fnCreate)(pFrame, pOldSh); + return (*fnCreate)(rFrame, pOldSh); } OUString SfxViewFactory::GetLegacyViewName() const diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index cd4ffe676f2b..535784ea6300 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -1054,14 +1054,14 @@ ViewShellDocId SfxViewShell::mnCurrentDocId(0); SfxViewShell::SfxViewShell ( - SfxViewFrame* pViewFrame, /* <SfxViewFrame>, which will be + SfxViewFrame& rViewFrame, /* <SfxViewFrame>, which will be displayed in this View */ SfxViewShellFlags nFlags /* See <SfxViewShell-Flags> */ ) : SfxShell(this) , pImpl( new SfxViewShell_Impl(nFlags, SfxViewShell::mnCurrentDocId) ) -, pFrame(pViewFrame) +, pFrame(&rViewFrame) , pWindow(nullptr) , bNoNewWindow( nFlags & SfxViewShellFlags::NO_NEWWINDOW ) , mbPrinterSettingsModified(false) @@ -1069,10 +1069,10 @@ SfxViewShell::SfxViewShell , maLOKLocale(LANGUAGE_NONE) , maLOKDeviceFormFactor(LOKDeviceFormFactor::UNKNOWN) { - SetMargin( pViewFrame->GetMargin_Impl() ); + SetMargin( rViewFrame.GetMargin_Impl() ); - SetPool( &pViewFrame->GetObjectShell()->GetPool() ); - StartListening(*pViewFrame->GetObjectShell()); + SetPool( &rViewFrame.GetObjectShell()->GetPool() ); + StartListening(*rViewFrame.GetObjectShell()); // Insert into list std::vector<SfxViewShell*> &rViewArr = SfxGetpApp()->GetViewShells_Impl(); @@ -1089,7 +1089,7 @@ SfxViewShell::SfxViewShell maLOKDeviceFormFactor = SfxLokHelper::getDeviceFormFactor(); - vcl::Window* pFrameWin = pViewFrame->GetWindow().GetFrameWindow(); + vcl::Window* pFrameWin = rViewFrame.GetWindow().GetFrameWindow(); if (pFrameWin && !pFrameWin->GetLOKNotifier()) pFrameWin->SetLOKNotifier(this, true); } diff --git a/starmath/inc/view.hxx b/starmath/inc/view.hxx index 41e28a44c3df..662923af0528 100644 --- a/starmath/inc/view.hxx +++ b/starmath/inc/view.hxx @@ -291,7 +291,7 @@ class SmViewShell final : public SfxViewShell public: - SmViewShell(SfxViewFrame *pFrame, SfxViewShell *pOldSh); + SmViewShell(SfxViewFrame& rFrame, SfxViewShell *pOldSh); virtual ~SmViewShell() override; SmDocShell * GetDoc() const diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index 1b51c8b71a6e..055805c8cc20 100644 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -2193,10 +2193,10 @@ private: }; } -SmViewShell::SmViewShell(SfxViewFrame *pFrame_, SfxViewShell *) - : SfxViewShell(pFrame_, SfxViewShellFlags::HAS_PRINTOPTIONS) +SmViewShell::SmViewShell(SfxViewFrame& rFrame_, SfxViewShell *) + : SfxViewShell(rFrame_, SfxViewShellFlags::HAS_PRINTOPTIONS) , mxGraphicWindow(VclPtr<SmGraphicWindow>::Create(*this)) - , maGraphicController(mxGraphicWindow->GetGraphicWidget(), SID_GRAPHIC_SM, pFrame_->GetBindings()) + , maGraphicController(mxGraphicWindow->GetGraphicWidget(), SID_GRAPHIC_SM, rFrame_.GetBindings()) , mbPasteState(false) , mbInsertIntoEditWindow(false) { diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx index c3ed0f5808d7..ff0099ace634 100644 --- a/sw/inc/view.hxx +++ b/sw/inc/view.hxx @@ -618,7 +618,7 @@ public: //apply Accessibility options void ApplyAccessibilityOptions(SvtAccessibilityOptions const & rAccessibilityOptions); - SwView(SfxViewFrame* pFrame, SfxViewShell*); + SwView(SfxViewFrame& rFrame, SfxViewShell*); virtual ~SwView() override; void NotifyDBChanged(); diff --git a/sw/source/uibase/inc/pview.hxx b/sw/source/uibase/inc/pview.hxx index f37a55863bb8..af0f31d94788 100644 --- a/sw/source/uibase/inc/pview.hxx +++ b/sw/source/uibase/inc/pview.hxx @@ -293,7 +293,7 @@ public: */ void SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos ); - SwPagePreview( SfxViewFrame* pFrame, SfxViewShell* ); + SwPagePreview(SfxViewFrame& rFrame, SfxViewShell*); virtual ~SwPagePreview() override; }; diff --git a/sw/source/uibase/inc/srcview.hxx b/sw/source/uibase/inc/srcview.hxx index caaecad67d6d..4b540aed2faa 100644 --- a/sw/source/uibase/inc/srcview.hxx +++ b/sw/source/uibase/inc/srcview.hxx @@ -56,7 +56,7 @@ private: static void InitInterface_Impl(); public: - SwSrcView(SfxViewFrame* pFrame, SfxViewShell*); + SwSrcView(SfxViewFrame& rFrame, SfxViewShell*); virtual ~SwSrcView() override; diff --git a/sw/source/uibase/inc/wview.hxx b/sw/source/uibase/inc/wview.hxx index 1aa807b2ff21..90ce5af8940f 100644 --- a/sw/source/uibase/inc/wview.hxx +++ b/sw/source/uibase/inc/wview.hxx @@ -36,7 +36,7 @@ private: static void InitInterface_Impl(); public: - SwWebView(SfxViewFrame* pFrame, SfxViewShell*); + SwWebView(SfxViewFrame& rFrame, SfxViewShell*); virtual ~SwWebView() override; }; diff --git a/sw/source/uibase/uiview/pview.cxx b/sw/source/uibase/uiview/pview.cxx index 84c1cf06680c..fd16c5b90725 100644 --- a/sw/source/uibase/uiview/pview.cxx +++ b/sw/source/uibase/uiview/pview.cxx @@ -1141,8 +1141,8 @@ void SwPagePreview::Init() pESh->ResetModified(); } -SwPagePreview::SwPagePreview(SfxViewFrame *pViewFrame, SfxViewShell* pOldSh): - SfxViewShell( pViewFrame, SWVIEWFLAGS ), +SwPagePreview::SwPagePreview(SfxViewFrame& rViewFrame, SfxViewShell* pOldSh): + SfxViewShell(rViewFrame, SWVIEWFLAGS), m_pViewWin( VclPtr<SwPagePreviewWin>::Create(&GetViewFrame()->GetWindow(), *this ) ), m_nNewPage(USHRT_MAX), m_sPageStr(SwResId(STR_PAGE)), @@ -1159,12 +1159,12 @@ SwPagePreview::SwPagePreview(SfxViewFrame *pViewFrame, SfxViewShell* pOldSh): SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::Printpreview)); - SfxObjectShell* pObjShell = pViewFrame->GetObjectShell(); + SfxObjectShell* pObjShell = rViewFrame.GetObjectShell(); if ( !pOldSh ) { // Exists already a view on the document? SfxViewFrame *pF = SfxViewFrame::GetFirst( pObjShell ); - if ( pF == pViewFrame ) + if (pF == &rViewFrame) pF = SfxViewFrame::GetNext( *pF, pObjShell ); if ( pF ) pOldSh = pF->GetViewShell(); @@ -1207,7 +1207,7 @@ SwPagePreview::SwPagePreview(SfxViewFrame *pViewFrame, SfxViewShell* pOldSh): pNew = new SwViewShell( *pVS, m_pViewWin, nullptr, VSHELLFLAG_ISPREVIEW ); else pNew = new SwViewShell( - *static_cast<SwDocShell*>(pViewFrame->GetObjectShell())->GetDoc(), + *static_cast<SwDocShell*>(rViewFrame.GetObjectShell())->GetDoc(), m_pViewWin, nullptr, nullptr, VSHELLFLAG_ISPREVIEW ); m_pViewWin->SetViewShell( pNew ); diff --git a/sw/source/uibase/uiview/srcview.cxx b/sw/source/uibase/uiview/srcview.cxx index 2a4487f9251f..bce3f54f3314 100644 --- a/sw/source/uibase/uiview/srcview.cxx +++ b/sw/source/uibase/uiview/srcview.cxx @@ -187,9 +187,9 @@ static OUString lcl_ConvertTabsToSpaces( const OUString& sLine ) return aRet; } -SwSrcView::SwSrcView(SfxViewFrame* pViewFrame, SfxViewShell*) : - SfxViewShell( pViewFrame, SWSRCVIEWFLAGS ), - m_aEditWin( VclPtr<SwSrcEditWindow>::Create( &pViewFrame->GetWindow(), this ) ), +SwSrcView::SwSrcView(SfxViewFrame& rViewFrame, SfxViewShell*) : + SfxViewShell( rViewFrame, SWSRCVIEWFLAGS ), + m_aEditWin( VclPtr<SwSrcEditWindow>::Create( &rViewFrame.GetWindow(), this ) ), m_bSourceSaved(false), m_eLoadEncoding(RTL_TEXTENCODING_DONTKNOW) { diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx index 0dad5e371de9..7d346e945e0d 100644 --- a/sw/source/uibase/uiview/view.cxx +++ b/sw/source/uibase/uiview/view.cxx @@ -746,13 +746,13 @@ void SwView::CheckReadonlySelection() } } -SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh ) - : SfxViewShell( _pFrame, SWVIEWFLAGS ), +SwView::SwView(SfxViewFrame& _rFrame, SfxViewShell* pOldSh) + : SfxViewShell(_rFrame, SWVIEWFLAGS), m_aTimer( "sw::SwView m_aTimer" ), m_nNewPage(USHRT_MAX), m_nOldPageNum(0), m_pNumRuleNodeFromDoc(nullptr), - m_pEditWin( VclPtr<SwEditWin>::Create( &_pFrame->GetWindow(), *this ) ), + m_pEditWin( VclPtr<SwEditWin>::Create( &_rFrame.GetWindow(), *this ) ), m_pShell(nullptr), m_pFormShell(nullptr), m_pHScrollbar(nullptr), @@ -821,7 +821,7 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh ) m_aTimer.SetTimeout( 120 ); - SwDocShell& rDocSh = dynamic_cast<SwDocShell&>(*_pFrame->GetObjectShell()); + SwDocShell& rDocSh = dynamic_cast<SwDocShell&>(*_rFrame.GetObjectShell()); bool bOldModifyFlag = rDocSh.IsEnableSetModified(); if (bOldModifyFlag) rDocSh.EnableSetModified( false ); diff --git a/sw/source/uibase/web/wview.cxx b/sw/source/uibase/web/wview.cxx index 2fa09630e65a..98be7a6508ea 100644 --- a/sw/source/uibase/web/wview.cxx +++ b/sw/source/uibase/web/wview.cxx @@ -81,8 +81,8 @@ void SwWebView::InitInterface_Impl() } -SwWebView::SwWebView(SfxViewFrame* _pFrame, SfxViewShell* _pShell) : - SwView(_pFrame, _pShell) +SwWebView::SwWebView(SfxViewFrame& _rFrame, SfxViewShell* _pShell) : + SwView(_rFrame, _pShell) { } commit 2f0b16a6a9bfff1646b14412e5918b6d483b9cdc Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Feb 16 08:49:47 2023 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Feb 16 09:24:55 2023 +0000 sw floattable: limit vertical position for the follows of split flys The bugdoc has 2 pages and the 2nd page had a fly frame with an unexpected vertical shift towards the bottom. The problem is that the floattable has a vertical offset defined, but Word only handles that on the first page of the split table, not on later pages. This makes sense: we split the table to multiple pages so that the content fits, an additional offset on follow pages would result in a lot of additional pages. Fix the problem by adjusting SwToContentAnchoredObjectPosition::CalcPosition(), so that the vertical offset is only applied on master flys, not on follow flys. This implicitly means that the behavior is unchanged for non-split flys, since those always have a first page, which is nicely consistent. Change-Id: I8c86cd2df6868cc5c1a10dfec359f3e02f5c1102 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147141 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/qa/core/layout/data/floattable-vertoffset.docx b/sw/qa/core/layout/data/floattable-vertoffset.docx new file mode 100644 index 000000000000..d71a587f9c1e Binary files /dev/null and b/sw/qa/core/layout/data/floattable-vertoffset.docx differ diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx index 2f1e1e54deac..f305c19ec5c1 100644 --- a/sw/qa/core/layout/flycnt.cxx +++ b/sw/qa/core/layout/flycnt.cxx @@ -82,6 +82,51 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyWithTable) // This failed, page 1 anchor had unexpected, leftover text. CPPUNIT_ASSERT(!pPage1Anchor->HasPara()); } + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyVertoffset) +{ + // Given a document with a floattable, split on 2 pages and a positive vertical offset: + SwFormatFlySplit::SetForce(true); + comphelper::ScopeGuard g([] { SwFormatFlySplit::SetForce(false); }); + createSwDoc("floattable-vertoffset.docx"); + + // When laying out that document: + calcLayout(); + + // Then make sure that the vert offset has an effect on the master fly, but not on follow flys: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast<SwPageFrame*>(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rPage1Objs.size()); + auto pPage1Fly = dynamic_cast<SwFlyAtContentFrame*>(rPage1Objs[0]); + CPPUNIT_ASSERT(pPage1Fly); + auto pPage1Anchor = dynamic_cast<SwTextFrame*>(pPage1->FindLastBodyContent()); + CPPUNIT_ASSERT(pPage1Anchor); + SwTwips nPage1AnchorTop = pPage1Anchor->getFrameArea().Top(); + SwTwips nPage1FlyTop = pPage1Fly->getFrameArea().Top(); + // First page, the vert offset should be there. This comes from word/document.xml: + // <w:tblpPr ... w:tblpY="1135"/> + CPPUNIT_ASSERT_EQUAL(static_cast<SwTwips>(1135), nPage1FlyTop - nPage1AnchorTop); + + // Also verify that the 2nd page has no such offset: + auto pPage2 = dynamic_cast<SwPageFrame*>(pPage1->GetNext()); + CPPUNIT_ASSERT(pPage2); + const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rPage2Objs.size()); + auto pPage2Fly = dynamic_cast<SwFlyAtContentFrame*>(rPage2Objs[0]); + CPPUNIT_ASSERT(pPage2Fly); + auto pPage2Anchor = dynamic_cast<SwTextFrame*>(pPage2->FindLastBodyContent()); + CPPUNIT_ASSERT(pPage2Anchor); + SwTwips nPage2AnchorTop = pPage2Anchor->getFrameArea().Top(); + SwTwips nPage2FlyTop = pPage2Fly->getFrameArea().Top(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 0 + // - Actual : 1135 + // i.e. the fly frame on the 2nd page was also shifted down in Writer, but not in Word. + CPPUNIT_ASSERT_EQUAL(static_cast<SwTwips>(0), nPage2FlyTop - nPage2AnchorTop); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx index 7a9dd8546a3a..1a58d3a650dd 100644 --- a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx +++ b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx @@ -190,6 +190,9 @@ void SwToContentAnchoredObjectPosition::CalcPosition() // determine frame the object position has to be oriented at. const SwTextFrame* pOrientFrame = &rAnchorTextFrame; const SwTextFrame* pAnchorFrameForVertPos; + // If true, this means that the anchored object is a split fly frame and it's not a master but + // one of the follows. + bool bFollowSplitFly = false; { // if object is at-character anchored, determine character-rectangle // and frame, position has to be oriented at. @@ -239,6 +242,8 @@ void SwToContentAnchoredObjectPosition::CalcPosition() if (pFollow) { pOrientFrame = pFollow; + // Anchored object has a precede, so it's a follow. + bFollowSplitFly = true; } } } @@ -588,6 +593,12 @@ void SwToContentAnchoredObjectPosition::CalcPosition() nVertOffsetToFrameAnchorPos += aRectFnSet.YDiff(nPageBottom, nTopOfOrient); } nRelPosY = nVertOffsetToFrameAnchorPos + aVert.GetPos(); + if (bFollowSplitFly) + { + // This is a follow of a split fly: shift it up to match the anchor position, + // because the vertical offset is meant to be handled only on the first page. + nRelPosY -= aVert.GetPos(); + } } // <pUpperOfOrientFrame>: layout frame, at which the position has to