kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0001-Resolves-rhbz-1081176-don-t-jump-to-cursor-pos-when.patch

f085be
From 903652fafacf5268aeac4a702d52de44a8388652 Mon Sep 17 00:00:00 2001
f085be
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
f085be
Date: Fri, 11 Apr 2014 14:45:39 +0100
f085be
Subject: [PATCH] Resolves: rhbz#1081176: don't jump to cursor pos when...
f085be
f085be
launching a new window view of a document. This was happening because of
f085be
(temporary) activation of the modified flag (from updating the document stats
f085be
in the bottom bar) triggering a scrolll to the current cursor position of the
f085be
old document
f085be
f085be
Change-Id: I6e1a3c07b66ff6373345850d1449f17c1f0baa17
f085be
(cherry picked from commit e12184393f0591b5c5d9218062cc0a4bced6d4e6)
f085be
---
f085be
 sw/source/core/doc/doc.cxx | 39 ++++++++++++++++++++++++++++++++++++++-
f085be
 1 file changed, 38 insertions(+), 1 deletion(-)
f085be
f085be
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
f085be
index 6382d74..047b8b3 100644
f085be
--- a/sw/source/core/doc/doc.cxx
f085be
+++ b/sw/source/core/doc/doc.cxx
f085be
@@ -1650,6 +1650,40 @@ void SwDoc::CalculatePagePairsForProspectPrinting(
f085be
     // thus we are done here.
f085be
 }
f085be
 
f085be
+namespace
f085be
+{
f085be
+    class LockAllViews
f085be
+    {
f085be
+        std::vector<SwViewShell*> m_aViewWasUnLocked;
f085be
+        SwViewShell* m_pViewShell;
f085be
+    public:
f085be
+        LockAllViews(SwViewShell *pViewShell)
f085be
+            : m_pViewShell(pViewShell)
f085be
+        {
f085be
+            if (!m_pViewShell)
f085be
+                return;
f085be
+            SwViewShell *pSh = m_pViewShell;
f085be
+            do
f085be
+            {
f085be
+                if (!pSh->IsViewLocked())
f085be
+                {
f085be
+                    m_aViewWasUnLocked.push_back(pSh);
f085be
+                    pSh->LockView(true);
f085be
+                }
f085be
+                pSh = (SwViewShell*)pSh->GetNext();
f085be
+            } while (pSh != m_pViewShell);
f085be
+        }
f085be
+        ~LockAllViews()
f085be
+        {
f085be
+            for (std::vector<SwViewShell*>::iterator aI = m_aViewWasUnLocked.begin(); aI != m_aViewWasUnLocked.end(); ++aI)
f085be
+            {
f085be
+                SwViewShell *pSh = *aI;
f085be
+                pSh->LockView(false);
f085be
+            }
f085be
+        }
f085be
+    };
f085be
+}
f085be
+
f085be
 // returns true while there is more to do
f085be
 bool SwDoc::IncrementalDocStatCalculate(long nChars, bool bFields)
f085be
 {
f085be
@@ -1720,7 +1754,7 @@ bool SwDoc::IncrementalDocStatCalculate(long nChars, bool bFields)
f085be
     aStat[n++].Value <<= (sal_Int32)mpDocStat->nCharExcludingSpaces;
f085be
 
f085be
     // For e.g. autotext documents there is no pSwgInfo (#i79945)
f085be
-    SfxObjectShell * const pObjShell( GetDocShell() );
f085be
+    SwDocShell* pObjShell(GetDocShell());
f085be
     if (pObjShell)
f085be
     {
f085be
         const uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
f085be
@@ -1730,6 +1764,9 @@ bool SwDoc::IncrementalDocStatCalculate(long nChars, bool bFields)
f085be
         // #i96786#: do not set modified flag when updating statistics
f085be
         const bool bDocWasModified( IsModified() );
f085be
         const ModifyBlocker_Impl b(pObjShell);
f085be
+        // rhbz#1081176: don't jump to cursor pos because of (temporary)
f085be
+        // activation of modified flag triggering move to input position
f085be
+        LockAllViews aViewGuard((SwViewShell*)pObjShell->GetWrtShell());
f085be
         xDocProps->setDocumentStatistics(aStat);
f085be
         if (!bDocWasModified)
f085be
         {
f085be
-- 
f085be
1.8.5.3
f085be