From 9f5e3b61e7b3a7dd3cca369d153b3993b10496ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Tue, 6 Dec 2016 15:17:38 +0000 Subject: [PATCH] Resolves: rhbz#1401082 gnome hangs opening a certain .docx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this seems to be a problem since.... commit 199eb08be994ef968eb38f4966bc27ef1756d382 Author: Miklos Vajna Date: Thu Jun 5 16:25:01 2014 +0200 SwAnchoredDrawObject::GetObjBoundRect: avoid SwDoc::SetModified() This is a const method, but it does a const_cast to still resize an object... if that's so, then we should ensure that the "is modified" flag of SwDoc is untouched. CppunitTest_sw_ooxmlimport's testChartSize is a reproducer for this, when shape text is imported as textbox. (note under gtk3 and wayland this isn't as noticable, there use export GDK_BACKEND=x11 to reproduce the freeze effect where even the mouse cursor doesn't move during part of the load) Change-Id: Ic0bd98b032dfe1255d79d8070d50f65fcfa676dd Reviewed-on: https://gerrit.libreoffice.org/31687 Tested-by: Jenkins Reviewed-by: Miklos Vajna (cherry picked from commit d393039655edf9bb884fc2956674badde59d2326) Reviewed-on: https://gerrit.libreoffice.org/31948 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sw/inc/IDocumentState.hxx | 3 +++ sw/source/core/doc/DocumentStateManager.cxx | 13 +++++++++++++ sw/source/core/inc/DocumentStateManager.hxx | 5 ++++- sw/source/core/layout/anchoreddrawobject.cxx | 7 ++++--- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/sw/inc/IDocumentState.hxx b/sw/inc/IDocumentState.hxx index a6fc748..41fa8e4 100644 --- a/sw/inc/IDocumentState.hxx +++ b/sw/inc/IDocumentState.hxx @@ -58,6 +58,9 @@ public: virtual void SetLoaded(bool b = true) = 0; + virtual bool IsEnableSetModified() const = 0; + virtual void SetEnableSetModified(bool bEnableSetModified) = 0; + protected: virtual ~IDocumentState() {}; }; diff --git a/sw/source/core/doc/DocumentStateManager.cxx b/sw/source/core/doc/DocumentStateManager.cxx index ede8ef9..cf755e1 100644 --- a/sw/source/core/doc/DocumentStateManager.cxx +++ b/sw/source/core/doc/DocumentStateManager.cxx @@ -29,6 +29,7 @@ namespace sw DocumentStateManager::DocumentStateManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwdoc ), + mbEnableSetModified(true), mbModified(false), mbLoaded(false), mbUpdateExpField(false), @@ -40,6 +41,8 @@ DocumentStateManager::DocumentStateManager( SwDoc& i_rSwdoc ) : void DocumentStateManager::SetModified() { + if (!IsEnableSetModified()) + return; m_rDoc.GetDocumentLayoutManager().ClearSwLayouterEntries(); // give the old and new modified state to the link // Bit 0: -> old state @@ -80,6 +83,16 @@ bool DocumentStateManager::IsModified() const return mbModified; } +bool DocumentStateManager::IsEnableSetModified() const +{ + return mbEnableSetModified; +} + +void DocumentStateManager::SetEnableSetModified(bool bEnableSetModified) +{ + mbEnableSetModified = bEnableSetModified; +} + bool DocumentStateManager::IsInCallModified() const { return mbInCallModified; diff --git a/sw/source/core/inc/DocumentStateManager.hxx b/sw/source/core/inc/DocumentStateManager.hxx index 1d67a36..f3ca7d9 100644 --- a/sw/source/core/inc/DocumentStateManager.hxx +++ b/sw/source/core/inc/DocumentStateManager.hxx @@ -38,6 +38,8 @@ public: void SetModified() SAL_OVERRIDE; void ResetModified() SAL_OVERRIDE; bool IsModified() const SAL_OVERRIDE; + bool IsEnableSetModified() const SAL_OVERRIDE; + void SetEnableSetModified(bool bEnableSetModified) SAL_OVERRIDE; bool IsInCallModified() const SAL_OVERRIDE; bool IsLoaded() const SAL_OVERRIDE; bool IsUpdateExpField() const SAL_OVERRIDE; @@ -51,9 +53,10 @@ public: private: SwDoc& m_rDoc; + bool mbEnableSetModified; //< FALSE: changing document modification status (temporarily) locked bool mbModified ; //< TRUE: document has changed. bool mbLoaded ; //< TRUE: Doc loaded. - bool mbUpdateExpField ; //< TRUE: Update expression fields. + bool mbUpdateExpField; //< TRUE: Update expression fields. bool mbNewDoc ; //< TRUE: new Doc. bool mbPageNums ; //< TRUE: There are virtual page numbers. bool mbInCallModified; //< TRUE: in Set/Reset-Modified link. diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx index 7051a2a..644d7e6 100644 --- a/sw/source/core/layout/anchoreddrawobject.cxx +++ b/sw/source/core/layout/anchoreddrawobject.cxx @@ -659,12 +659,13 @@ const SwRect SwAnchoredDrawObject::GetObjBoundRect() const if ( nTargetWidth != aCurrObjRect.GetWidth( ) || nTargetHeight != aCurrObjRect.GetHeight( ) ) { SwDoc* pDoc = const_cast(GetPageFrm()->GetFormat()->GetDoc()); - bool bModified = pDoc->getIDocumentState().IsModified(); + + bool bEnableSetModified = pDoc->getIDocumentState().IsEnableSetModified(); + pDoc->getIDocumentState().SetEnableSetModified(false); const_cast< SdrObject* >( GetDrawObj() )->Resize( aCurrObjRect.TopLeft(), Fraction( nTargetWidth, aCurrObjRect.GetWidth() ), Fraction( nTargetHeight, aCurrObjRect.GetHeight() ), false ); - if (!bModified) - pDoc->getIDocumentState().ResetModified(); + pDoc->getIDocumentState().SetEnableSetModified(bEnableSetModified); } } return GetDrawObj()->GetCurrentBoundRect(); -- 2.9.3