include/sfx2/objsh.hxx | 14 ++++++++++++++ sfx2/source/doc/objstor.cxx | 2 ++ sw/inc/docsh.hxx | 13 ++++++++----- sw/source/uibase/app/docsh.cxx | 10 ++++------ 4 files changed, 28 insertions(+), 11 deletions(-)
New commits: commit 2036db5ecd227f97e0e5ab403de61b80fff93c38 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Jul 29 17:45:03 2020 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Thu Jul 30 00:02:32 2020 +0200 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.kagan...@collabora.com> diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx index 1bc1f5352c2c..6a5da58e3ae0 100644 --- a/include/sfx2/objsh.hxx +++ b/include/sfx2/objsh.hxx @@ -218,6 +218,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) @@ -775,6 +782,13 @@ public: /// Gets the certificate that is already picked by the user but not yet used for signing. css::uno::Reference<css::security::XCertificate> GetSignPDFCertificate() const; + + // 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 f3a6b22f0a11..0d4f04702d3c 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -1134,6 +1134,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 225305aec568..6dc7fdf21f35 100644 --- a/sw/inc/docsh.hxx +++ b/sw/inc/docsh.hxx @@ -319,16 +319,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 SAL_DLLPRIVATE 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 f323d7a53e80..9846c1748e1f 100644 --- a/sw/source/uibase/app/docsh.cxx +++ b/sw/source/uibase/app/docsh.cxx @@ -349,7 +349,7 @@ bool SwDocShell::Save() return !nErr.IsError(); } -SwDocShell::LockAllViewsGuard::LockAllViewsGuard(SwViewShell* pViewShell) +SwDocShell::LockAllViewsGuard_Impl::LockAllViewsGuard_Impl(SwViewShell* pViewShell) { if (!pViewShell) return; @@ -363,23 +363,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(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits