summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-03-08 09:03:39 +0100
committerDavid Tardon <dtardon@redhat.com>2016-04-05 06:50:26 +0000
commit707c8cc24ddb8df805947472f5438f8f9c866d2a (patch)
tree630468afb51e325bc4f9da3cd2516808e8534bc2
parent51b4af045d670c67f107922b2137fea49e042606 (diff)
tdf#97601 sw: don't mark an already modified chart as modified
Regression from commit e2b260fc98e833d4e64426b90992094f2da0498c (sw: let layout not mark embedded object as modified, 2014-06-03), an infinite loop was caused by: 1) SwDoc::SetOLEObjModified() triggering the maOLEModifiedIdle Idle 2) which at the end called SwWrtShell::CalcAndSetScale() 3) which at the end called chart::ChartModel::setModified() 4) where chart code called back into SwDoc::SetOLEObjModified() via the modification listener, and this happened again and again. The original fix wanted to avoid marking the document as modified without a user interaction, so fix the bug by only calling setModified() if it prevents a not-modified -> modified transition. This keeps the original bug fixed, but prevents the infinite loop, that is always a modified -> modified transition. (cherry picked from commit 078c00e3a3c971ac83154948d5f08462532b9dc6) Conflicts: sw/qa/extras/uiwriter/uiwriter.cxx Change-Id: I3b56a91afaacd3e0b7cb646a492fd15f1b5168ee Reviewed-on: https://gerrit.libreoffice.org/23731 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: David Tardon <dtardon@redhat.com>
-rw-r--r--sw/qa/extras/uiwriter/data/tdf97601.odtbin0 -> 14942 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx29
-rw-r--r--sw/source/uibase/wrtsh/wrtsh1.cxx4
3 files changed, 31 insertions, 2 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf97601.odt b/sw/qa/extras/uiwriter/data/tdf97601.odt
new file mode 100644
index 000000000000..d3995f261284
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf97601.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index f727c215a2b8..3a49c9ec1c9f 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -53,6 +53,8 @@
#include <com/sun/star/util/SearchFlags.hpp>
#include "com/sun/star/util/SearchAlgorithms.hpp"
#include "com/sun/star/i18n/TransliterationModulesExtra.hpp"
+#include <com/sun/star/chart2/data/XDataSource.hpp>
+#include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp>
#include <comphelper/propertysequence.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
@@ -97,6 +99,7 @@ public:
void testCp1000115();
void testTdf90003();
void testSearchWithTransliterate();
+ void testTdf97601();
void testTdf90362();
void testUndoCharAttribute();
void testTdf86639();
@@ -144,6 +147,7 @@ public:
CPPUNIT_TEST(testCp1000115);
CPPUNIT_TEST(testTdf90003);
CPPUNIT_TEST(testSearchWithTransliterate);
+ CPPUNIT_TEST(testTdf97601);
CPPUNIT_TEST(testTdf90362);
CPPUNIT_TEST(testUndoCharAttribute);
CPPUNIT_TEST(testTdf86639);
@@ -1005,6 +1009,31 @@ void SwUiWriterTest::testSearchWithTransliterate()
CPPUNIT_ASSERT_EQUAL(1,(int)case2);
}
+void SwUiWriterTest::testTdf97601()
+{
+ // Instructions from the bugreport to trigger an infinite loop.
+ createDoc("tdf97601.odt");
+ uno::Reference<text::XTextEmbeddedObjectsSupplier> xEmbeddedObjectsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xEmbeddedObjects = xEmbeddedObjectsSupplier->getEmbeddedObjects();
+ uno::Reference<beans::XPropertySet> xChart;
+ xEmbeddedObjects->getByName("myChart") >>= xChart;
+ uno::Reference<chart2::data::XDataSource> xChartComponent;
+ xChart->getPropertyValue("Component") >>= xChartComponent;
+ uno::Sequence< uno::Reference<chart2::data::XLabeledDataSequence> > aDataSequences = xChartComponent->getDataSequences();
+ uno::Reference<document::XEmbeddedObjectSupplier2> xChartState(xChart, uno::UNO_QUERY);
+ xChartState->getExtendedControlOverEmbeddedObject()->changeState(1);
+ uno::Reference<util::XModifiable> xDataSequenceModifiable(aDataSequences[2]->getValues(), uno::UNO_QUERY);
+ xDataSequenceModifiable->setModified(true);
+
+ // Make sure that the chart is marked as modified.
+ uno::Reference<util::XModifiable> xModifiable(xChartComponent, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(true, bool(xModifiable->isModified()));
+ calcLayout();
+ // This never returned.
+ Application::Reschedule(true);
+ Scheduler::ProcessTaskScheduling(false);
+}
+
void SwUiWriterTest::testTdf90362()
{
// First check if the end of the second paragraph is indeed protected.
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 37f0553ab2a0..9d68db3f79d0 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -652,7 +652,7 @@ void SwWrtShell::CalcAndSetScale( svt::EmbeddedObjectRef& xObj,
aSz.Width = aSize.Width();
aSz.Height = aSize.Height();
- // Action 'setVisualAreaSize' doesn't have to change the
+ // Action 'setVisualAreaSize' doesn't have to turn on the
// modified state of the document, either.
bool bModified = false;
uno::Reference<util::XModifiable> xModifiable(xObj->getComponent(), uno::UNO_QUERY);
@@ -660,7 +660,7 @@ void SwWrtShell::CalcAndSetScale( svt::EmbeddedObjectRef& xObj,
bModified = xModifiable->isModified();
xObj->setVisualAreaSize( nAspect, aSz );
xModifiable.set(xObj->getComponent(), uno::UNO_QUERY);
- if (xModifiable.is())
+ if (xModifiable.is() && xModifiable->isModified() && !bModified)
xModifiable->setModified(bModified);
// #i48419# - action 'UpdateReplacement' doesn't