[Libreoffice-commits] core.git: sw/inc sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Jul 26 15:42:35 UTC 2018
sw/inc/docsh.hxx | 12 ++++++++
sw/source/core/doc/DocumentStatisticsManager.cxx | 31 -----------------------
sw/source/uibase/app/docsh.cxx | 28 ++++++++++++++++++++
3 files changed, 41 insertions(+), 30 deletions(-)
New commits:
commit e2a5932da7a3df9f6440f8326520061caa2342c1
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Thu Jul 26 16:14:46 2018 +1000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Jul 26 17:42:09 2018 +0200
tdf#41063: don't jump to cursor when saving
Reuse the fix from commits e12184393f0591b5c5d9218062cc0a4bced6d4e6
and 36c84fa3fbd03e5f651ba9d81e321566c8fcdbd0.
Change-Id: I5b7cdc321c6e30e994732d2c0295e494a172a2e2
Reviewed-on: https://gerrit.libreoffice.org/58034
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx
index 9a88de3abeb6..f2c17c1747c1 100644
--- a/sw/inc/docsh.hxx
+++ b/sw/inc/docsh.hxx
@@ -51,6 +51,7 @@ class IDocumentDeviceAccess;
class IDocumentChartDataProviderAccess;
class SwDocShell;
class SwDrawModel;
+class SwViewShell;
namespace svt
{
class EmbeddedObjectRef;
@@ -318,6 +319,17 @@ public:
void RegisterAutomationDocumentEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller);
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
+ {
+ std::vector<SwViewShell*> m_aViewWasUnLocked;
+
+ public:
+ explicit LockAllViewsGuard(SwViewShell* pViewShell);
+ ~LockAllViewsGuard();
+ };
+ // 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/core/doc/DocumentStatisticsManager.cxx b/sw/source/core/doc/DocumentStatisticsManager.cxx
index 0b8003283fb0..394aee67856a 100644
--- a/sw/source/core/doc/DocumentStatisticsManager.cxx
+++ b/sw/source/core/doc/DocumentStatisticsManager.cxx
@@ -39,35 +39,6 @@
using namespace ::com::sun::star;
-namespace
-{
- class LockAllViews
- {
- std::vector<SwViewShell*> m_aViewWasUnLocked;
- SwViewShell* m_pViewShell;
- public:
- explicit LockAllViews(SwViewShell *pViewShell)
- : m_pViewShell(pViewShell)
- {
- if (!m_pViewShell)
- return;
- for (SwViewShell& rShell : m_pViewShell->GetRingContainer())
- {
- if (!rShell.IsViewLocked())
- {
- m_aViewWasUnLocked.push_back(&rShell);
- rShell.LockView(true);
- }
- }
- }
- ~LockAllViews()
- {
- for(SwViewShell* pShell : m_aViewWasUnLocked)
- pShell->LockView(false);
- }
- };
-}
-
namespace sw
{
@@ -218,7 +189,7 @@ bool DocumentStatisticsManager::IncrementalDocStatCalculate(long nChars, bool bF
const ModifyBlocker_Impl b(pObjShell);
// rhbz#1081176: don't jump to cursor pos because of (temporary)
// activation of modified flag triggering move to input position
- LockAllViews aViewGuard(pObjShell->GetEditShell());
+ auto aViewGuard(pObjShell->LockAllViews());
xDocProps->setDocumentStatistics(aStat);
if (!bDocWasModified)
{
diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx
index 2a40bc1d12da..ee1fa8228b4d 100644
--- a/sw/source/uibase/app/docsh.cxx
+++ b/sw/source/uibase/app/docsh.cxx
@@ -130,6 +130,7 @@
#include <sal/log.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <o3tl/make_unique.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -382,10 +383,37 @@ bool SwDocShell::Save()
return !nErr.IsError();
}
+SwDocShell::LockAllViewsGuard::LockAllViewsGuard(SwViewShell* pViewShell)
+{
+ if (!pViewShell)
+ return;
+ for (SwViewShell& rShell : pViewShell->GetRingContainer())
+ {
+ if (!rShell.IsViewLocked())
+ {
+ m_aViewWasUnLocked.push_back(&rShell);
+ rShell.LockView(true);
+ }
+ }
+}
+
+SwDocShell::LockAllViewsGuard::~LockAllViewsGuard()
+{
+ for (SwViewShell* pShell : m_aViewWasUnLocked)
+ pShell->LockView(false);
+}
+
+std::unique_ptr<SwDocShell::LockAllViewsGuard> SwDocShell::LockAllViews()
+{
+ return o3tl::make_unique<LockAllViewsGuard>(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