diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2019-08-26 20:57:10 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-08-27 09:15:23 +0200 |
commit | 28d67b792724a23015dec32fb0278b729f676736 (patch) | |
tree | 3ab8582c2ab326db25097ecdec5e0afbe1dad4af | |
parent | 5c50f1a2d4487b9303974c7cf39d6208192a0c96 (diff) |
tdf#107776 sw ODF shape import: make is-textbox check more strict
Regression from commit 9835a5823e0f559aabbc0e15ea126c82229c4bc7 (sw
textboxes: reimplement ODF import/export, 2014-10-04), the problem was
that we assumed graphic autostyles look like:
<style:style style:name="gr2" style:family="graphic">
for simple (non-text-box) content, and look like:
<style:style style:name="gr1" style:family="graphic" style:parent-style-name="Frame">
for complex (text-box) content.
Turns out it's valid to have other parent styles as well, e.g. Graphics,
which should not be imported as sw textboxes.
With this, the arrow at the bottom of page 3 of the bugdoc is now again
on top of the image, i.e. layout compatibility is restored.
Change-Id: Icbba8a23c5f66e63090f90e6581ebc98948cb80b
Reviewed-on: https://gerrit.libreoffice.org/78155
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | sw/qa/extras/odfimport/data/tdf107776.fodt | 29 | ||||
-rw-r--r-- | sw/qa/extras/odfimport/odfimport.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/draw/ximpshap.cxx | 3 |
3 files changed, 37 insertions, 1 deletions
diff --git a/sw/qa/extras/odfimport/data/tdf107776.fodt b/sw/qa/extras/odfimport/data/tdf107776.fodt new file mode 100644 index 000000000000..b59f1261778c --- /dev/null +++ b/sw/qa/extras/odfimport/data/tdf107776.fodt @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<office:document xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" 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:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ooo="http://openoffice.org/2004/office" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d: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:rpt="http://openoffice.org/2005/report" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:automatic-styles> + <style:style style:name="gr1" style:family="graphic" style:parent-style-name="Graphics"> + <style:graphic-properties draw:textarea-horizontal-align="justify" draw:textarea-vertical-align="middle" draw:auto-grow-height="false" fo:min-height="3.847cm" fo:min-width="7.207cm" style:run-through="foreground" style:wrap="run-through" style:number-wrapped-paragraphs="no-limit" style:vertical-pos="from-top" style:vertical-rel="paragraph" style:horizontal-pos="from-left" style:horizontal-rel="paragraph" draw:wrap-influence-on-position="once-concurrent" style:flow-with-text="false"/> + </style:style> + </office:automatic-styles> + <office:body> + <office:text> + <text:p><draw:custom-shape text:anchor-type="paragraph" draw:z-index="0" draw:name="Shape1" draw:style-name="gr1" svg:width="7.621cm" svg:height="4.261cm" svg:x="1.554cm" svg:y="2.235cm"> + <text:p>Simple content.</text:p> + <draw:enhanced-geometry svg:viewBox="0 0 21600 21600" draw:path-stretchpoint-x="10800" draw:path-stretchpoint-y="10800" draw:text-areas="?f3 ?f4 ?f5 ?f6" draw:type="round-rectangle" draw:modifiers="3600" draw:enhanced-path="M ?f7 0 X 0 ?f8 L 0 ?f9 Y ?f7 21600 L ?f10 21600 X 21600 ?f9 L 21600 ?f8 Y ?f10 0 Z N"> + <draw:equation draw:name="f0" draw:formula="45"/> + <draw:equation draw:name="f1" draw:formula="$0 *sin(?f0 *(pi/180))"/> + <draw:equation draw:name="f2" draw:formula="?f1 *3163/7636"/> + <draw:equation draw:name="f3" draw:formula="left+?f2 "/> + <draw:equation draw:name="f4" draw:formula="top+?f2 "/> + <draw:equation draw:name="f5" draw:formula="right-?f2 "/> + <draw:equation draw:name="f6" draw:formula="bottom-?f2 "/> + <draw:equation draw:name="f7" draw:formula="left+$0 "/> + <draw:equation draw:name="f8" draw:formula="top+$0 "/> + <draw:equation draw:name="f9" draw:formula="bottom-$0 "/> + <draw:equation draw:name="f10" draw:formula="right-$0 "/> + <draw:handle draw:handle-position="$0 top" draw:handle-switched="true" draw:handle-range-x-minimum="0" draw:handle-range-x-maximum="10800"/> + </draw:enhanced-geometry> + </draw:custom-shape></text:p> + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index cf55296e0555..629a7f194e62 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -663,6 +663,12 @@ DECLARE_ODFIMPORT_TEST(testSpellmenuRedline, "spellmenu-redline.odt") CPPUNIT_ASSERT_EQUAL(OString("prev"), rMenu.GetItemIdent(rMenu.GetItemId(rMenu.GetItemCount() - 1))); } +DECLARE_ODFIMPORT_TEST(testTdf107776, "tdf107776.fodt") +{ + // Shape with a Graphics parent style name was imported as textbox. + CPPUNIT_ASSERT(!getProperty<bool>(getShape(1), "TextBox")); +} + DECLARE_ODFIMPORT_TEST(testAnnotationFormatting, "annotation-formatting.odt") { uno::Reference<beans::XPropertySet> xTextField = getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 1), "TextField"); diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx index ec3c06ad1db2..15219b4fd23c 100644 --- a/xmloff/source/draw/ximpshap.cxx +++ b/xmloff/source/draw/ximpshap.cxx @@ -3671,7 +3671,8 @@ SdXMLCustomShapeContext::SdXMLCustomShapeContext( { rtl::Reference<XMLTextImportHelper> xTxtImport = GetImport().GetTextImport(); XMLPropStyleContext* pStyle = xTxtImport->FindAutoFrameStyle(aStyleName); - if (pStyle && !pStyle->GetParentName().isEmpty()) + // Note that this an API name, so intentionally not localized. + if (pStyle && pStyle->GetParentName() == "Frame") { mbTextBox = true; break; |