diff options
-rw-r--r-- | sw/qa/extras/htmlexport/data/reqif-objdata-presentationdatasize.odt | bin | 0 -> 95777 bytes | |||
-rw-r--r-- | sw/qa/extras/htmlexport/htmlexport.cxx | 35 | ||||
-rw-r--r-- | sw/source/filter/html/htmlreqifreader.cxx | 4 |
3 files changed, 37 insertions, 2 deletions
diff --git a/sw/qa/extras/htmlexport/data/reqif-objdata-presentationdatasize.odt b/sw/qa/extras/htmlexport/data/reqif-objdata-presentationdatasize.odt Binary files differnew file mode 100644 index 000000000000..231a7c572a3a --- /dev/null +++ b/sw/qa/extras/htmlexport/data/reqif-objdata-presentationdatasize.odt diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index 08a21b6b7dd3..3746c3e7e786 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -255,6 +255,8 @@ public: OUString GetOlePath(); /// Parse the ole1 data out of an RTF fragment URL. void ParseOle1FromRtfUrl(const OUString& rRtfUrl, SvMemoryStream& rOle1); + /// Export using the C++ HTML export filter, with xhtmlns=reqif-xhtml. + void ExportToReqif(); }; OUString SwHtmlDomExportTest::GetOlePath() @@ -283,6 +285,16 @@ void SwHtmlDomExportTest::ParseOle1FromRtfUrl(const OUString& rRtfUrl, SvMemoryS CPPUNIT_ASSERT(rOle1.Tell()); } +void SwHtmlDomExportTest::ExportToReqif() +{ + uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aStoreProperties = { + comphelper::makePropertyValue("FilterName", OUString("HTML (StarWriter)")), + comphelper::makePropertyValue("FilterOptions", OUString("xhtmlns=reqif-xhtml")), + }; + xStorable->storeToURL(maTempFile.GetURL(), aStoreProperties); +} + char const DATA_DIRECTORY[] = "/sw/qa/extras/htmlexport/data/"; DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testFdo81276, "fdo81276.html") @@ -1354,6 +1366,29 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifAscharObjsize) CPPUNIT_ASSERT_EQUAL(static_cast<long>(4116), xReader->GetObjh()); } +CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifObjdataPresentationDataSize) +{ + // Given a document with an OLE2 embedded object, containing a preview: + OUString aURL + = m_directories.getURLFromSrc(DATA_DIRECTORY) + "reqif-objdata-presentationdatasize.odt"; + mxComponent = loadFromDesktop(aURL, "com.sun.star.text.TextDocument", {}); + + // When exporting to ReqIF: + ExportToReqif(); + + // Then make sure that the PresentationDataSize in the RTF's objdata blob is correct: + OUString aRtfUrl = GetOlePath(); + SvMemoryStream aOle1; + ParseOle1FromRtfUrl(aRtfUrl, aOle1); + OLE1Reader aOle1Reader(aOle1); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 565994 + // - Actual : 330240 (Linux) + // - Actual : 566034 (Windows, when Word is installed) + // because PresentationData was taken from the OLE2 stream but its size was taken from RTF. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(565994), aOle1Reader.m_nPresentationDataSize); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/html/htmlreqifreader.cxx b/sw/source/filter/html/htmlreqifreader.cxx index a59f56ee40ee..47cf2341e1e5 100644 --- a/sw/source/filter/html/htmlreqifreader.cxx +++ b/sw/source/filter/html/htmlreqifreader.cxx @@ -341,8 +341,8 @@ OString InsertOLE1Header(SvStream& rOle2, SvStream& rOle1, sal_uInt32& nWidth, s rOle1.WriteUInt32(nWidth); // Height. rOle1.WriteUInt32(nHeight * -1); - // PresentationDataSize - rOle1.WriteUInt32(8 + nPresentationData); + // PresentationDataSize: size of (reserved fields + pBytes). + rOle1.WriteUInt32(8 + nBytes); // Reserved1-4. rOle1.WriteUInt16(0x0008); rOle1.WriteUInt16(0x31b1); |