diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2020-07-29 17:45:03 +0300 |
---|---|---|
committer | Gabor Kelemen <kelemeng@ubuntu.com> | 2022-07-04 15:09:10 +0200 |
commit | 9d7d48d3603c246cf00ed34fe5336d2c19cfcd47 (patch) | |
tree | cbf088ac7ea70052226c8ac18c2918d199cd145e | |
parent | Release 6.3.6.17 (diff) | |
download | core-9d7d48d3603c246cf00ed34fe5336d2c19cfcd47.tar.gz core-9d7d48d3603c246cf00ed34fe5336d2c19cfcd47.zip |
tdf#135244: move LockAllViews to SfxObjectShell
... so that it may be called from SfxObjectShell::SaveTo_Impl, and
handle export cases in addition to save (as) handled in tdf#41063.
Change-Id: Ie39196656dd1a95dcb6bab3ae8138c2f5c8729e6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99714
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | include/sfx2/objsh.hxx | 14 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 2 | ||||
-rw-r--r-- | sw/inc/docsh.hxx | 13 | ||||
-rw-r--r-- | sw/source/uibase/app/docsh.cxx | 10 |
4 files changed, 28 insertions, 11 deletions
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx index 4db1c5769e80..35210463240e 100644 --- a/include/sfx2/objsh.hxx +++ b/include/sfx2/objsh.hxx @@ -215,6 +215,13 @@ protected: // helper method void AddToRecentlyUsedList(); + // Parent class for actual guard objects that would do useful work + class LockAllViewsGuard + { + public: + virtual ~LockAllViewsGuard() {} + }; + public: SFX_DECL_INTERFACE(SFX_INTERFACE_SFXDOCSH) @@ -746,6 +753,13 @@ public: /** override this if you have a XmlIdRegistry. */ virtual const sfx2::IXmlIdRegistry* GetXmlIdRegistry() const { return nullptr; } + + // Lock all unlocked views, and returns a guard object which unlocks those views when destructed + virtual std::unique_ptr<LockAllViewsGuard> LockAllViews() + { + return std::make_unique<LockAllViewsGuard>(); + } + }; #define SFX_GLOBAL_CLASSID \ diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 36f58416a9e9..4b58cbe14ecb 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -1154,6 +1154,8 @@ bool SfxObjectShell::SaveTo_Impl UpdateDocInfoForSave(); ModifyBlocker_Impl aMod(this); + // tdf#41063, tdf#135244: prevent jumping to cursor at any temporary modification + auto aViewGuard(LockAllViews()); std::shared_ptr<const SfxFilter> pFilter = rMedium.GetFilter(); if ( !pFilter ) diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx index 291b20455c17..ba0a823ed258 100644 --- a/sw/inc/docsh.hxx +++ b/sw/inc/docsh.hxx @@ -322,16 +322,19 @@ public: void CallAutomationDocumentEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments); void RegisterAutomationDocumentObject(css::uno::Reference< ooo::vba::word::XDocument > const& xDocument); - class LockAllViewsGuard + // Lock all unlocked views, and returns a guard object which unlocks those views when destructed + virtual std::unique_ptr<LockAllViewsGuard> LockAllViews() override; + +protected: + class LockAllViewsGuard_Impl : public LockAllViewsGuard { std::vector<SwViewShell*> m_aViewWasUnLocked; public: - explicit LockAllViewsGuard(SwViewShell* pViewShell); - ~LockAllViewsGuard(); + explicit LockAllViewsGuard_Impl(SwViewShell* pViewShell); + ~LockAllViewsGuard_Impl(); }; - // Lock all unlocked views, and returns a guard object which unlocks those views when destructed - std::unique_ptr<LockAllViewsGuard> LockAllViews(); + }; /** Find the right DocShell and create a new one: diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx index 083b4ec6c648..a6a56fb33366 100644 --- a/sw/source/uibase/app/docsh.cxx +++ b/sw/source/uibase/app/docsh.cxx @@ -380,7 +380,7 @@ bool SwDocShell::Save() return !nErr.IsError(); } -SwDocShell::LockAllViewsGuard::LockAllViewsGuard(SwViewShell* pViewShell) +SwDocShell::LockAllViewsGuard_Impl::LockAllViewsGuard_Impl(SwViewShell* pViewShell) { if (!pViewShell) return; @@ -394,23 +394,21 @@ SwDocShell::LockAllViewsGuard::LockAllViewsGuard(SwViewShell* pViewShell) } } -SwDocShell::LockAllViewsGuard::~LockAllViewsGuard() +SwDocShell::LockAllViewsGuard_Impl::~LockAllViewsGuard_Impl() { for (SwViewShell* pShell : m_aViewWasUnLocked) pShell->LockView(false); } -std::unique_ptr<SwDocShell::LockAllViewsGuard> SwDocShell::LockAllViews() +std::unique_ptr<SfxObjectShell::LockAllViewsGuard> SwDocShell::LockAllViews() { - return std::make_unique<LockAllViewsGuard>(GetEditShell()); + return std::make_unique<LockAllViewsGuard_Impl>(GetEditShell()); } // Save using the Defaultformat bool SwDocShell::SaveAs( SfxMedium& rMedium ) { SwWait aWait( *this, true ); - // tdf#41063: prevent jumping to cursor at any temporary modification - auto aViewGuard(LockAllViews()); //#i3370# remove quick help to prevent saving of autocorrection suggestions if (m_pView) m_pView->GetEditWin().StopQuickHelp(); |