diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-08-11 13:57:07 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-08-11 15:17:57 +0200 |
commit | 9555b793082db56ff5b61708bbbd4d4a088ccf4b (patch) | |
tree | 80f21cc82f123bb1694e34fd65a594776175e345 /sw/qa/extras | |
parent | 54a9b4a20e5da303ed01e570a424f38b49ba911f (diff) |
tdf#162426: make sure to only output new tags after all attributes were written
In commit 03fe839d6e76ed8b1dfb65093ab59a8904852ff6 (html export: rework image
output to use HTML writer, 2014-09-22), optional export of linebreak tag was
implemented in the end of SwHTMLWriter::writeFrameFormatOptions. But it is
called in the middle of img arrtibutes output in OutHTML_ImageStart; so when
br was output, all following img attributes got discarded.
This makes writing the tag a separate function with appropriate name, which
is called after all attributes are already written.
Change-Id: I2a7df56e73150d93c565a7240c047b09f3336641
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171722
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/qa/extras')
-rw-r--r-- | sw/qa/extras/htmlexport/data/tdf162426_image_with_wrap_none.fodt | 20 | ||||
-rw-r--r-- | sw/qa/extras/htmlexport/htmlexport.cxx | 16 |
2 files changed, 36 insertions, 0 deletions
diff --git a/sw/qa/extras/htmlexport/data/tdf162426_image_with_wrap_none.fodt b/sw/qa/extras/htmlexport/data/tdf162426_image_with_wrap_none.fodt new file mode 100644 index 000000000000..9dc1f13101bd --- /dev/null +++ b/sw/qa/extras/htmlexport/data/tdf162426_image_with_wrap_none.fodt @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:styles> + <style:style style:name="Graphics" style:family="graphic"/> + </office:styles> + <office:automatic-styles> + <style:style style:name="fr1" style:family="graphic" style:parent-style-name="Graphics"> + <style:graphic-properties style:wrap="none"/> + </style:style> + </office:automatic-styles> + <office:body> + <office:text> + <text:p><draw:frame draw:style-name="fr1" text:anchor-type="char" svg:y="0" svg:width="1cm" svg:height="1cm"><draw:image draw:mime-type="image/png"> + <office:binary-data>iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX///+nxBvIAAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==</office:binary-data> + </draw:image> + </draw:frame></text:p> + </office:text> + </office:body> +</office:document>
\ No newline at end of file diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index 5de5ef5f155f..df5d90c30855 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -3432,6 +3432,22 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIF_162282) CPPUNIT_ASSERT_EQUAL(correctData, emfData); } +CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testHTML_162426) +{ + // Given a document with an image with style:wrap="none": + createSwDoc("tdf162426_image_with_wrap_none.fodt"); + // Before the fix, an assertion failed in HtmlWriter::attribute when exporting to HTML : + ExportToHTML(); + + xmlDocUniquePtr pDoc = parseXml(maTempFile); + CPPUNIT_ASSERT(pDoc); + + // Before the fix, the 'border' attribute was written after the 'img' tag was already closed, + // so without the asserion, this would fail with + // - In <>, XPath '/html/body/p/img' no attribute 'border' exist + assertXPath(pDoc, "/html/body/p/img"_ostr, "border"_ostr, u"0"_ustr); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); |