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