diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-01-07 17:26:53 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-01-09 13:52:50 +0100 |
commit | ca54ad87c4fffe52f282fa4cba84952e6888cb62 (patch) | |
tree | 57e7ad691d079e446026a5a8549ad83ddb6586c2 | |
parent | 2f91acc6eab246179a35d957d876d78a3e5e327f (diff) |
sw: don't send LOK notifications about redlines during save
SwXMLWriter::Write_() sets redline flags to show insertion and hide
deletion, but it resets those flags before the function returns. So LOK
notifications for redline changes during save is not useful.
Conflicts:
sw/qa/extras/tiledrendering/tiledrendering.cxx
Change-Id: I4bf963bbe9c7003cbe85ea6c5538be733a3e3cdf
-rw-r--r-- | sw/inc/doc.hxx | 4 | ||||
-rw-r--r-- | sw/qa/extras/tiledrendering/data/redline-notification-during-save.odt | bin | 0 -> 6786 bytes | |||
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 21 | ||||
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 1 | ||||
-rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/basflt/shellio.cxx | 2 |
6 files changed, 31 insertions, 1 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index ac9cba92a09e..37e78fb0def3 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -342,6 +342,7 @@ private: frames need deletion. */ bool mbCopyIsMove : 1; //< TRUE: Copy is a hidden Move. bool mbInReading : 1; //< TRUE: Document is in the process of being read. + bool mbInWriting : 1; //< TRUE: Document is in the process of being written. bool mbInMailMerge : 1; //< TRUE: Document is in the process of being written by mail merge. bool mbInXMLImport : 1; //< TRUE: During xml import, attribute portion building is not necessary. bool mbUpdateTOX : 1; //< TRUE: After loading document, update TOX. @@ -975,6 +976,9 @@ public: bool IsInReading() const { return mbInReading; } void SetInReading( bool bNew ) { mbInReading = bNew; } + bool IsInWriting() const { return mbInWriting; } + void SetInWriting(bool bNew) { mbInWriting = bNew; } + bool IsInMailMerge() const { return mbInMailMerge; } void SetInMailMerge( bool bNew ) { mbInMailMerge = bNew; } diff --git a/sw/qa/extras/tiledrendering/data/redline-notification-during-save.odt b/sw/qa/extras/tiledrendering/data/redline-notification-during-save.odt Binary files differnew file mode 100644 index 000000000000..2bd9c814750c --- /dev/null +++ b/sw/qa/extras/tiledrendering/data/redline-notification-during-save.odt diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 08fc4d0736c7..86989cf4f7c9 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -11,6 +11,7 @@ #include <boost/property_tree/json_parser.hpp> #include <com/sun/star/frame/DispatchResultState.hpp> +#include <com/sun/star/frame/XStorable.hpp> #include <swmodeltestbase.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <comphelper/dispatchcommand.hxx> @@ -109,6 +110,7 @@ public: void testDeleteNodeRedlineCallback(); void testVisCursorInvalidation(); void testDeselectCustomShape(); + void testRedlineNotificationDuringSave(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -165,6 +167,7 @@ public: CPPUNIT_TEST(testDeleteNodeRedlineCallback); CPPUNIT_TEST(testVisCursorInvalidation); CPPUNIT_TEST(testDeselectCustomShape); + CPPUNIT_TEST(testRedlineNotificationDuringSave); CPPUNIT_TEST_SUITE_END(); private: @@ -2379,6 +2382,24 @@ void SwTiledRenderingTest::testDeselectCustomShape() comphelper::LibreOfficeKit::setActive(false); } +void SwTiledRenderingTest::testRedlineNotificationDuringSave() +{ + // Load a document with redlines which are hidden at a layout level. + // It's an empty document, just settings.xml and content.xml are custom. + comphelper::LibreOfficeKit::setActive(); + SwXTextDocument* pXTextDocument = createDoc("redline-notification-during-save.odt"); + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this); + + // Save the document. + utl::MediaDescriptor aMediaDescriptor; + aMediaDescriptor["FilterName"] <<= OUString("writer8"); + uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); + // Without the accompanying fix in place, this test would have never returned due to an infinite + // loop while sending not needed LOK notifications for redline changes during save. + xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 1d2fd5c6ef8a..2b52443a91d4 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -264,6 +264,7 @@ SwDoc::SwDoc() mbDtor(false), mbCopyIsMove(false), mbInReading(false), + mbInWriting(false), mbInMailMerge(false), mbInXMLImport(false), mbUpdateTOX(false), diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 03fbb0c39da6..28df676045c9 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -1218,7 +1218,9 @@ void SwTextNode::Update( } // Inform LOK clients about change in position of redlines (if any) - if (comphelper::LibreOfficeKit::isActive()) + // Don't emit notifications during save: redline flags are temporarily changed during save, but + // it's not useful to let clients know about such changes. + if (comphelper::LibreOfficeKit::isActive() && !GetDoc()->IsInWriting()) { const SwRedlineTable& rTable = GetDoc()->getIDocumentRedlineAccess().GetRedlineTable(); for (SwRedlineTable::size_type nRedlnPos = 0; nRedlnPos < rTable.size(); ++nRedlnPos) diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx index 8b66489885dd..ed665dd78cda 100644 --- a/sw/source/filter/basflt/shellio.cxx +++ b/sw/source/filter/basflt/shellio.cxx @@ -850,6 +850,7 @@ ErrCode SwWriter::Write( WriterRef const & rxWriter, const OUString* pRealFileNa const bool bOrigPurgeOle = pOutDoc->getIDocumentSettingAccess().get(DocumentSettingId::PURGE_OLE); pOutDoc->getIDocumentSettingAccess().set(DocumentSettingId::PURGE_OLE, false); + pOutDoc->SetInWriting(true); ErrCode nError = ERRCODE_NONE; if( pMedium ) nError = rxWriter->Write( *pPam, *pMedium, pRealFileName ); @@ -857,6 +858,7 @@ ErrCode SwWriter::Write( WriterRef const & rxWriter, const OUString* pRealFileNa nError = rxWriter->Write( *pPam, *pStrm, pRealFileName ); else if( xStg.is() ) nError = rxWriter->Write( *pPam, xStg, pRealFileName ); + pOutDoc->SetInWriting(false); pOutDoc->getIDocumentSettingAccess().set(DocumentSettingId::PURGE_OLE, bOrigPurgeOle ); |