[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/sfx2 sfx2/source sw/inc sw/source

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Mon Mar 22 10:38:01 UTC 2021


 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 ee8ba74cdec6b081bb42bcb3167087f43b07be00
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Wed Jul 29 17:45:03 2020 +0300
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Mar 22 11:37:26 2021 +0100

    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 at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112825
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index 2d6a4c3cd2d3..9c331092bda1 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)
 
@@ -770,6 +777,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 2141a590b212..9e54c3771f92 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -1128,6 +1128,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 08eaf82c3e67..7c94345ba7d3 100644
--- a/sw/inc/docsh.hxx
+++ b/sw/inc/docsh.hxx
@@ -320,16 +320,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 151770695eeb..3704184eaf26 100644
--- a/sw/source/uibase/app/docsh.cxx
+++ b/sw/source/uibase/app/docsh.cxx
@@ -379,7 +379,7 @@ bool SwDocShell::Save()
     return !nErr.IsError();
 }
 
-SwDocShell::LockAllViewsGuard::LockAllViewsGuard(SwViewShell* pViewShell)
+SwDocShell::LockAllViewsGuard_Impl::LockAllViewsGuard_Impl(SwViewShell* pViewShell)
 {
     if (!pViewShell)
         return;
@@ -393,23 +393,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();


More information about the Libreoffice-commits mailing list