summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sfx2/source/doc/objstor.cxx13
-rw-r--r--sw/CppunitTest_sw_odfexport.mk1
-rw-r--r--sw/qa/extras/odfexport/data/2_MathType3.docxbin0 -> 15260 bytes
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx30
4 files changed, 43 insertions, 1 deletions
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 722630f6db57..cbb3c8cef664 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -2280,8 +2280,19 @@ bool SfxObjectShell::ImportFrom(SfxMedium& rMedium,
if ( nState == embed::EmbedStates::LOADED || nState == embed::EmbedStates::RUNNING ) // means that the object is not active
{
uno::Reference< util::XModifiable > xModifiable( xObj->getComponent(), uno::UNO_QUERY );
- if ( xModifiable.is() )
+ if (xModifiable.is() && xModifiable->isModified())
+ {
+ uno::Reference<embed::XEmbedPersist> const xPers(xObj, uno::UNO_QUERY);
+ if (xPers.is())
+ { // store it before resetting modified!
+ xPers->storeOwn();
+ }
+ else
+ {
+ SAL_WARN("sfx.doc", "Modified object without persistence!");
+ }
xModifiable->setModified(sal_False);
+ }
}
}
}
diff --git a/sw/CppunitTest_sw_odfexport.mk b/sw/CppunitTest_sw_odfexport.mk
index c6434ac1574e..3757e015ec19 100644
--- a/sw/CppunitTest_sw_odfexport.mk
+++ b/sw/CppunitTest_sw_odfexport.mk
@@ -87,6 +87,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_odfexport,\
sd/util/sd \
svx/util/svxcore \
xmloff/source/transform/xof \
+ xmlscript/util/xmlscript \
))
$(eval $(call gb_CppunitTest_use_custom_headers,sw_odfexport,\
diff --git a/sw/qa/extras/odfexport/data/2_MathType3.docx b/sw/qa/extras/odfexport/data/2_MathType3.docx
new file mode 100644
index 000000000000..0694921b3918
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/2_MathType3.docx
Binary files differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index e61c08a33c06..5a661c1a058f 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -73,10 +73,40 @@ public:
pBatch->commit();
return pResetter;
}
+ if (OString(pFilename) == "2_MathType3.docx")
+ {
+ std::unique_ptr<Resetter> pResetter(new Resetter(
+ [this] () {
+ mpFilter = "writer8";
+ std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Cache::Writer::OLE_Objects::set(20, pBatch);
+ return pBatch->commit();
+ }));
+ mpFilter = "OpenDocument Text Flat XML"; // doesn't happen with ODF package
+ std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Cache::Writer::OLE_Objects::set(1, pBatch);
+ pBatch->commit();
+ return pResetter;
+ }
return nullptr;
}
};
+DECLARE_ODFEXPORT_TEST(testMathObjectFlatExport, "2_MathType3.docx")
+{
+ uno::Reference<util::XModifiable> xModifiable(mxComponent, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(!xModifiable->isModified());
+ // see preTest(), set the OLE cache to 1 for this test
+ // and the problem was that the formulas that were in the cache
+ // (the second one) were lost
+ OUString formula1(getFormula(getRun(getParagraph(1), 1)));
+ CPPUNIT_ASSERT_EQUAL(OUString(" size 12{1+1=2} {}"), formula1);
+ OUString formula2(getFormula(getRun(getParagraph(2), 1)));
+ CPPUNIT_ASSERT_EQUAL(OUString(" size 12{2+2=4} {}"), formula2);
+}
+
DECLARE_ODFEXPORT_TEST(testFramebackgrounds, "framebackgrounds.odt")
{
//Counting the Number of Frames and checking with the expected count