diff --git a/xmloff/qa/unit/data/scale-width-redline.fodt b/xmloff/qa/unit/data/scale-width-redline.fodt new file mode 100644 index 000000000000..6b98c6e27a34 --- /dev/null +++ b/xmloff/qa/unit/data/scale-width-redline.fodt @@ -0,0 +1,170 @@ + + + LibreOfficeDev/7.6.0.0.alpha0$Linux_X86_64 LibreOffice_project/2e076661cf81225e390a3f5c86171eebb74ebbedGetting Started with LibreOffice 4.22010-01-04T08:31:18369P2DT11H48M52SJean Hollis Weber2023-01-23T16:28:26.015905461 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + before image + + + + iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQAAAAA3bvkkAAAAEElEQVR4nGJgAQAAAP//AwAA + BgAFV7+r1AAAAABJRU5ErkJggg== + + + + Figure 1: caption + + + after image + + + diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx index 1710f47fb25c..f7155f546df3 100644 --- a/xmloff/qa/unit/text.cxx +++ b/xmloff/qa/unit/text.cxx @@ -886,6 +886,27 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testDropdownContentControlAutostyleExport) xStorable->storeToURL(maTempFile.GetURL(), aStoreProps); } +CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testScaleWidthRedline) +{ + // Given a document with change tracking enabled, one image is part of a delete redline: + loadFromURL(u"scale-width-redline.fodt"); + dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + dispatchCommand(mxComponent, ".uno:GoToEndOfLine", {}); + dispatchCommand(mxComponent, ".uno:EndOfParaSel", {}); + dispatchCommand(mxComponent, ".uno:Delete", {}); + + // When saving to ODT: + save("writer8"); + + // Then make sure that a non-zero size is written to the output: + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 6.1728in + // - Actual : 0in + // i.e. the deleted image had zero size, which is incorrect. + assertXPath(pXmlDoc, "//draw:frame[@draw:name='Image45']", "width", "6.1728in"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index f0f6360b4904..59e755f0e676 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -2873,6 +2873,11 @@ XMLShapeExportFlags XMLTextParagraphExport::addTextFrameAttributes( // invalid layout size we got. bUseLayoutSize = false; } + if (aLayoutSize.Width <= 0 || aLayoutSize.Height <= 0) + { + // This is broken, Writer frames have a minimal size, see MINFLY. + bUseLayoutSize = false; + } // svg:width sal_Int16 nWidthType = SizeType::FIX;