xmloff/qa/unit/data/scale-width-redline.fodt | 170 +++++++++++++++++++++++++++ xmloff/qa/unit/text.cxx | 21 +++ xmloff/source/text/txtparae.cxx | 5 3 files changed, 196 insertions(+)
New commits: commit 02ae875f60a581a3b5c65c70db27b956e46457d8 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Jan 23 20:10:30 2023 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Jan 25 08:34:38 2023 +0000 tdf#150806 ODT export: fix fallback svg:width/height for zero layout size The reported problem was that once tracked changes is enabled and an image is deleted, its aspect ratio changes on save. What happens here is that the image's frame is marked as a redline deletion, so when the ODT export writes the file, it'll have a zero size. But this zero size is nothing we should take into account on save, XMLTextParagraphExport::addTextFrameAttributes() expected to always have a valid layout size if the LayoutSize property is available. Fix the problem by adding one more condition where we ignore the layout size, which was already there since commit 80550ade305b9e68c6281a258d162bc2c413713a (tdf#150990 ODT export: fix zero layout size of scale/scale images, 2022-09-20). Note that this way the written side will be the original one, so only the aspect ratio will be correct, but that was accepted as a compromise earlier. Change-Id: I108dc2428ce0cb07a044bfef216575fdba19267b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146043 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> (cherry picked from commit 713493c107e6a210ef9b87d033efd0614271483a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146032 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> 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 @@ +<?xml version='1.0' encoding='UTF-8'?> +<office:document xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:c alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext: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:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:rpt="http://openoffice.org/2005/report" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns: meta:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:meta><meta:generator>LibreOfficeDev/7.6.0.0.alpha0$Linux_X86_64 LibreOffice_project/2e076661cf81225e390a3f5c86171eebb74ebbed</meta:generator><dc:title>Getting Started with LibreOffice 4.2</dc:title><meta:creation-date>2010-01-04T08:31:18</meta:creation-date><meta:editing-cycles>369</meta:editing-cycles><meta:editing-duration>P2DT11H48M52S</meta:editing-duration><meta:initial-creator>Jean Hollis Weber</meta:initial-creator><dc:date>2023-01-23T16:28:26.015905461</dc:date><meta:document-statistic meta:table-count="0" meta:image-count="1" meta:object-count="0" meta:page-count="1" meta:paragraph-count="5" meta:word-count="7" meta:character-count="39" meta:non-whitespace-character-count="35"/><meta:user-defined meta:name="Info 1"/><meta:user-defined meta:name="Info 2"/><meta:user-defined meta:name="Info 3"/><meta:user-defined meta:name="Info 4"/><meta:template xlink:type="simple" xlink:actuate="onRequest" xlink:title="LO_3_4_book_template" xlink:href="../../../Library/Application %20Support/LibreOffice/3/user/template/LO_3_4_book_template.ott" meta:date="2012-04-21T15:17:30"/></office:meta> + <office:font-face-decls> + <style:font-face style:name="DejaVu Sans" svg:font-family="'DejaVu Sans'" style:font-family-generic="system" style:font-pitch="variable"/> + <style:font-face style:name="DejaVu Serif" svg:font-family="'DejaVu Serif'" style:font-adornments="Book" style:font-family-generic="roman" style:font-pitch="variable"/> + <style:font-face style:name="Liberation Sans2" svg:font-family="'Liberation Sans'" style:font-adornments="Italic" style:font-family-generic="swiss" style:font-pitch="variable"/> + <style:font-face style:name="Liberation Sans3" svg:font-family="'Liberation Sans'" style:font-adornments="Regular" style:font-family-generic="swiss" style:font-pitch="variable"/> + <style:font-face style:name="Lucidasans1" svg:font-family="Lucidasans" style:font-family-generic="system" style:font-pitch="variable"/> + <style:font-face style:name="Times New Roman" svg:font-family="'Times New Roman'" style:font-family-generic="roman" style:font-pitch="variable"/> + </office:font-face-decls> + <office:styles> + <style:default-style style:family="graphic"> + <style:graphic-properties svg:stroke-color="#000000" draw:fill-color="#99ccff" fo:wrap-option="wrap" draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" draw:start-line-spacing-vertical="0.283cm" draw:end-line-spacing-horizontal="0.283cm" draw:end-line-spacing-vertical="0.283cm" style:writing-mode="lr-tb" style:flow-with-text="false"/> + <style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:writing-mode="lr-tb" style:font-independent-line-spacing="false"> + <style:tab-stops/> + </style:paragraph-properties> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Times New Roman" fo:font-size="12pt" fo:language="en" fo:country="AU" style:letter-kerning="true" style:font-name-asian="DejaVu Sans" style:font-size-asian="12pt" style:language-asian="zxx" style:country-asian="none" style:font-name-complex="Lucidasans1" style:font-size-complex="12pt" style:language-complex="zxx" style:country-complex="none"/> + </style:default-style> + <style:default-style style:family="paragraph"> + <style:paragraph-properties fo:hyphenation-ladder-count="no-limit" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="0.635cm" style:writing-mode="page"/> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Times New Roman" fo:font-size="12pt" fo:language="en" fo:country="AU" style:letter-kerning="true" style:font-name-asian="DejaVu Sans" style:font-size-asian="12pt" style:language-asian="zxx" style:country-asian="none" style:font-name-complex="Lucidasans1" style:font-size-complex="12pt" style:language-complex="zxx" style:country-complex="none" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2" loext:hyphenation-no-caps="false" loext:hyphenation-no-last-word="false" loext:hyphenation-word-char-count="no-limit" loext:hyphenation-zone="no-limit"/> + </style:default-style> + <style:default-style style:family="table"> + <style:table-properties table:border-model="collapsing"/> + </style:default-style> + <style:default-style style:family="table-row"> + <style:table-row-properties fo:keep-together="auto"/> + </style:default-style> + <style:style style:name="Standard" style:family="paragraph" style:class="text" style:master-page-name=""> + <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0cm" fo:margin-bottom="0cm" style:contextual-spacing="false" fo:orphans="0" fo:widows="0" fo:text-indent="0cm" style:auto-text-indent="false" style:page-number="auto"/> + <style:text-properties style:font-name="Liberation Sans3" fo:font-family="'Liberation Sans'" style:font-style-name="Regular" style:font-family-generic="swiss" style:font-pitch="variable" fo:font-size="10.3000001907349pt" fo:language="en" fo:country="US"/> + </style:style> + <style:style style:name="Footnote_20_Symbol" style:display-name="Footnote Symbol" style:family="text"> + <style:text-properties style:font-name="DejaVu Serif" fo:font-family="'DejaVu Serif'" style:font-style-name="Book" style:font-family-generic="roman" style:font-pitch="variable"/> + </style:style> + <style:style style:name="Footnote_20_anchor" style:display-name="Footnote anchor" style:family="text"> + <style:text-properties style:text-position="super 80%" style:font-name="DejaVu Serif" fo:font-family="'DejaVu Serif'" style:font-style-name="Book" style:font-family-generic="roman" style:font-pitch="variable"/> + </style:style> + <style:style style:name="_5f__5f_XXX_5f__5f__5f_invalid" style:display-name="__XXX___invalid" style:family="text"/> + <style:style style:name="Line_20_numbering" style:display-name="Line numbering" style:family="text"/> + <style:style style:name="Graphics" style:family="graphic"> + <style:graphic-properties text:anchor-type="paragraph" svg:x="0cm" svg:y="0cm" style:wrap="none" style:vertical-pos="top" style:vertical-rel="paragraph" style:horizontal-pos="center" style:horizontal-rel="paragraph"/> + </style:style> + <style:style style:name="Frame" style:family="graphic"> + <style:graphic-properties text:anchor-type="paragraph" svg:x="0cm" svg:y="0cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0cm" fo:margin-bottom="0cm" style:wrap="parallel" style:number-wrapped-paragraphs="no-limit" style:wrap-contour="false" style:vertical-pos="top" style:vertical-rel="paragraph-content" style:horizontal-pos="center" style:horizontal-rel="paragraph-content" fo:padding="0cm" fo:border="none"/> + </style:style> + <text:outline-style style:name="Outline"> + <text:outline-level-style text:level="1" text:style-name="_5f__5f_XXX_5f__5f__5f_invalid" loext:num-list-format="%1%" style:num-format=""> + <style:list-level-properties text:min-label-distance="0.381cm"/> + </text:outline-level-style> + <text:outline-level-style text:level="2" text:style-name="_5f__5f_XXX_5f__5f__5f_invalid" loext:num-list-format="%2%" style:num-format=""> + <style:list-level-properties text:min-label-distance="0.381cm"/> + </text:outline-level-style> + <text:outline-level-style text:level="3" text:style-name="_5f__5f_XXX_5f__5f__5f_invalid" loext:num-list-format="%3%" style:num-format=""> + <style:list-level-properties text:min-label-distance="0.381cm"/> + </text:outline-level-style> + <text:outline-level-style text:level="4" text:style-name="_5f__5f_XXX_5f__5f__5f_invalid" loext:num-list-format="%4%" style:num-format=""> + <style:list-level-properties text:min-label-distance="0.381cm"/> + </text:outline-level-style> + <text:outline-level-style text:level="5" text:style-name="_5f__5f_XXX_5f__5f__5f_invalid" loext:num-list-format="%5%" style:num-format=""> + <style:list-level-properties text:min-label-distance="0.381cm"/> + </text:outline-level-style> + <text:outline-level-style text:level="6" text:style-name="_5f__5f_XXX_5f__5f__5f_invalid" loext:num-list-format="%6%" style:num-format=""> + <style:list-level-properties text:min-label-distance="0.381cm"/> + </text:outline-level-style> + <text:outline-level-style text:level="7" text:style-name="_5f__5f_XXX_5f__5f__5f_invalid" loext:num-list-format="%7%" style:num-format=""> + <style:list-level-properties text:min-label-distance="0.381cm"/> + </text:outline-level-style> + <text:outline-level-style text:level="8" text:style-name="_5f__5f_XXX_5f__5f__5f_invalid" loext:num-list-format="%8%" style:num-format=""> + <style:list-level-properties text:min-label-distance="0.381cm"/> + </text:outline-level-style> + <text:outline-level-style text:level="9" text:style-name="_5f__5f_XXX_5f__5f__5f_invalid" loext:num-list-format="%9%" style:num-format=""> + <style:list-level-properties text:min-label-distance="0.381cm"/> + </text:outline-level-style> + <text:outline-level-style text:level="10" text:style-name="_5f__5f_XXX_5f__5f__5f_invalid" loext:num-list-format="%10%" style:num-format=""> + <style:list-level-properties text:min-label-distance="0.381cm"/> + </text:outline-level-style> + </text:outline-style> + <text:notes-configuration text:note-class="footnote" text:citation-style-name="Footnote_20_Symbol" text:citation-body-style-name="Footnote_20_anchor" style:num-format="1" text:start-value="0" text:footnotes-position="page" text:start-numbering-at="document"/> + <text:notes-configuration text:note-class="endnote" style:num-format="i" text:start-value="0"/> + <text:linenumbering-configuration text:style-name="Line_20_numbering" text:number-lines="false" text:offset="0.499cm" style:num-format="1" text:number-position="left" text:increment="5"/> + </office:styles> + <office:automatic-styles> + <style:style style:name="P8" style:family="paragraph" style:parent-style-name="Standard" style:master-page-name="Standard"> + <style:paragraph-properties style:page-number="auto"/> + </style:style> + <style:style style:name="T5" style:family="text"> + <style:text-properties/> + </style:style> + <style:style style:name="fr1" style:family="graphic" style:parent-style-name="Frame"> + <style:graphic-properties style:wrap="none" style:vertical-pos="top" style:vertical-rel="baseline" style:horizontal-pos="center" style:horizontal-rel="paragraph" fo:padding="0cm" fo:border="none"/> + </style:style> + <style:style style:name="fr2" style:family="graphic" style:parent-style-name="Graphics"> + <style:graphic-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0cm" fo:margin-bottom="0cm" style:run-through="foreground" style:wrap="none" style:vertical-pos="top" style:vertical-rel="baseline" style:horizontal-pos="center" style:horizontal-rel="paragraph-content" fo:padding="0cm" fo:border="none" style:shadow="none" draw:shadow-opacity="100%" style:mirror="none" fo:clip="rect(0cm, 0cm, 0cm, 0cm)" draw:luminance="0%" draw:contrast="0%" draw:red="0%" draw:green="0%" draw:blue="0%" draw:gamma="100%" draw:color-inversion="false" draw:image-opacity="100%" draw:color-mode="standard" loext:rel-width-rel="paragraph"/> + </style:style> + <style:page-layout style:name="pm1"> + <style:page-layout-properties fo:page-width="20.999cm" fo:page-height="29.699cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" style:layout-grid-base-height="0.706cm" style:layout-grid-ruby-height="0.353cm" style:layout-grid-mode="none" style:layout-grid-ruby-below="false" style:layout-grid-print="false" style:layout-grid-display="false" style:footnote-max-height="0cm" loext:margin-gutter="0cm"> + <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="none" style:adjustment="left" style:rel-width="25%" style:color="#000000"/> + </style:page-layout-properties> + <style:header-style/> + <style:footer-style/> + </style:page-layout> + <style:page-layout style:name="pm2" style:page-usage="mirrored"> + <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="1.499cm" fo:margin-left="0.499cm" fo:margin-right="2.499cm" style:writing-mode="lr-tb" style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" style:layout-grid-base-height="0.706cm" style:layout-grid-ruby-height="0.353cm" style:layout-grid-mode="none" style:layout-grid-ruby-below="false" style:layout-grid-print="false" style:layout-grid-display="false" style:footnote-max-height="0cm" loext:margin-gutter="0cm"> + <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="none" style:adjustment="left" style:rel-width="25%" style:color="#000000"/> + </style:page-layout-properties> + <style:header-style/> + <style:footer-style> + <style:header-footer-properties fo:min-height="0.998cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0.499cm" fo:border-top="0.06pt solid #000000" fo:border-bottom="none" fo:border-left="none" fo:border-right="none" fo:padding="0cm" style:shadow="none" style:dynamic-spacing="false"/> + </style:footer-style> + </style:page-layout> + <style:page-layout style:name="pm3"> + <style:page-layout-properties fo:page-width="29.699cm" fo:page-height="20.999cm" style:num-format="1" style:print-orientation="landscape" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" style:layout-grid-base-height="0.706cm" style:layout-grid-ruby-height="0.353cm" style:layout-grid-mode="none" style:layout-grid-ruby-below="false" style:layout-grid-print="false" style:layout-grid-display="false" style:footnote-max-height="0cm" loext:margin-gutter="0cm"> + <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="none" style:adjustment="left" style:rel-width="25%" style:color="#000000"/> + </style:page-layout-properties> + <style:header-style/> + <style:footer-style/> + </style:page-layout> + <style:page-layout style:name="pm4" style:page-usage="left"> + <style:page-layout-properties fo:page-width="20.999cm" fo:page-height="29.699cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" style:layout-grid-base-height="0.706cm" style:layout-grid-ruby-height="0.353cm" style:layout-grid-mode="none" style:layout-grid-ruby-below="false" style:layout-grid-print="false" style:layout-grid-display="false" style:footnote-max-height="0cm" loext:margin-gutter="0cm"> + <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/> + </style:page-layout-properties> + <style:header-style/> + <style:footer-style/> + </style:page-layout> + <style:page-layout style:name="pm5" style:page-usage="right"> + <style:page-layout-properties fo:page-width="20.999cm" fo:page-height="29.699cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" style:layout-grid-base-height="0.706cm" style:layout-grid-ruby-height="0.353cm" style:layout-grid-mode="none" style:layout-grid-ruby-below="false" style:layout-grid-print="false" style:layout-grid-display="false" style:footnote-max-height="0cm" loext:margin-gutter="0cm"> + <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/> + </style:page-layout-properties> + <style:header-style/> + <style:footer-style/> + </style:page-layout> + <style:style style:name="dp1" style:family="drawing-page"> + <style:drawing-page-properties draw:background-size="full"/> + </style:style> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Standard" style:page-layout-name="pm1" draw:style-name="dp1"/> + </office:master-styles> + <office:body> + <office:text> + <office:forms form:automatic-focus="false" form:apply-design-mode="false"/> + <text:sequence-decls> + <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/> + <text:sequence-decl text:display-outline-level="0" text:name="Table"/> + <text:sequence-decl text:display-outline-level="0" text:name="Text"/> + <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/> + <text:sequence-decl text:display-outline-level="0" text:name="Figure"/> + <text:sequence-decl text:display-outline-level="0" text:name="Listing"/> + </text:sequence-decls> + <text:user-field-decls> + <text:user-field-decl office:value-type="float" office:value="1" text:name="MD"/> + </text:user-field-decls> + <text:p text:style-name="P8">before image</text:p> + <text:p text:style-name="P2"><draw:frame draw:style-name="fr1" draw:name="Frame45" text:anchor-type="as-char" svg:width="15.679cm" draw:z-index="0"> + <draw:text-box fo:min-height="5.456cm"> + <text:p text:style-name="P4"><draw:frame draw:style-name="fr2" draw:name="Image45" text:anchor-type="as-char" svg:width="15.679cm" style:rel-width="100%" svg:height="4.722cm" style:rel-height="scale" draw:z-index="1"><draw:image draw:mime-type="image/png"> + <office:binary-data>iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQAAAAA3bvkkAAAAEElEQVR4nGJgAQAAAP//AwAA + BgAFV7+r1AAAAABJRU5ErkJggg== + </office:binary-data> + </draw:image> + </draw:frame></text:p> + <text:p text:style-name="Standard">Figure <text:sequence text:ref-name="refFigure0" text:name="Figure" text:formula="ooow:Figure+1" style:num-format="1">1</text:sequence>: <text:span text:style-name="T5">caption</text:span></text:p> + </draw:text-box> + </draw:frame></text:p> + <text:p text:style-name="Standard">after image</text:p> + </office:text> + </office:body> +</office:document> diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx index 45f3323d92a5..9c30c2f81dee 100644 --- a/xmloff/qa/unit/text.cxx +++ b/xmloff/qa/unit/text.cxx @@ -871,6 +871,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 8c0d53e8da93..c534d4fc4dcf 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;