[Libreoffice-commits] core.git: sw/qa xmloff/source

Michael Stahl mstahl at redhat.com
Tue Apr 7 14:01:28 PDT 2015


 sw/qa/extras/odfimport/data/tdf89802.fodt   |   56 ++++++++++++++++++++++++++++
 sw/qa/extras/odfimport/odfimport.cxx        |   12 ++++++
 xmloff/source/draw/XMLShapeStyleContext.cxx |   13 ++++++
 3 files changed, 81 insertions(+)

New commits:
commit db1d278dcc308c73eb5edebc20481c96e7f479d8
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Apr 7 22:20:49 2015 +0200

    tdf#89802: xmloff: fix ODF import of frame with empty style name ref
    
    draw:fill-gradient-name="" in the graphic properties now causes
    BaseFrameProperties_Impl::FillBaseProperties() to fail and prevent
    insertion of the SwXTextFrame.
    
    (regression from 6e61ecd09679a66060f932835622821d39e92f01)
    
    Change-Id: I9b4f3ddb0f0e1b3a80e86bbdc1af2dade1c8edf7

diff --git a/sw/qa/extras/odfimport/data/tdf89802.fodt b/sw/qa/extras/odfimport/data/tdf89802.fodt
new file mode 100644
index 0000000..3d8601b
--- /dev/null
+++ b/sw/qa/extras/odfimport/data/tdf89802.fodt
@@ -0,0 +1,56 @@
+<?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:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle: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:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oas
 is:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:
 experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:meta><meta:initial-creator>ms </meta:initial-creator><meta:creation-date>2015-04-07T22:24:25.374012080</meta:creation-date><dc:date>2015-04-07T22:25:28.460806924</dc:date><dc:creator>ms </dc:creator><meta:editing-duration>PT1M3S</meta:editing-duration><meta:editing-cycles>1</meta:editing-cycles><meta:document-statistic meta:table-count="0" meta:image-count="0" meta:object-count="0" meta:page-count="1" meta:paragraph-count="1" meta:word-count="1" meta:character-count="3" meta:non-whitespace-character-count="3"/><meta:generator>LibreOfficeDev/4.5.0.0.alpha0$Linux_X86_64 LibreOffice_project/52ae345470d8fa657817cf87b3e8e8c1b51bd7da</meta:generator></office:meta>
+ <office:font-face-decls>
+  <style:font-face style:name="Lohit Devanagari1" svg:font-family="'Lohit Devanagari'"/>
+  <style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable"/>
+  <style:font-face style:name="Liberation Sans" svg:font-family="'Liberation Sans'" style:font-family-generic="swiss" style:font-pitch="variable"/>
+  <style:font-face style:name="Lohit Devanagari" svg:font-family="'Lohit Devanagari'" style:font-family-generic="system" style:font-pitch="variable"/>
+  <style:font-face style:name="Source Han Sans CN Normal" svg:font-family="'Source Han Sans CN Normal'" style:font-family-generic="system" style:font-pitch="variable"/>
+ </office:font-face-decls>
+ <office:styles>
+  <style:default-style style:family="graphic">
+   <style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf" fo:wrap-option="no-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: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" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" fo:country="DE" style:letter-kerning="true" style:font-name-asian="Source Han Sans CN Normal" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lohit Devanagari" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN"/>
+  </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="1.251cm" style:writing-mode="page"/>
+   <style:text-properties style:use-window-font-color="true" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" fo:country="DE" style:letter-kerning="true" style:font-name-asian="Source Han Sans CN Normal" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lohit Devanagari" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/>
+  </style:default-style>
+  <style:style style:name="Standard" style:family="paragraph" style:class="text"/>
+ </office:styles>
+ <office:automatic-styles>
+  <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Frame_20_contents">
+   <style:text-properties officeooo:rsid="0007f24f" officeooo:paragraph-rsid="0007f24f"/>
+  </style:style>
+  <style:style style:name="fr1" style:family="graphic" style:parent-style-name="Frame">
+      <style:graphic-properties fo:margin-left="0.3cm" fo:margin-right="0.3cm" fo:margin-top="1.9cm" fo:margin-bottom="0.3cm" style:run-through="background" style:wrap="run-through" style:number-wrapped-paragraphs="no-limit" style:vertical-pos="from-top" style:vertical-rel="paragraph" style:horizontal-pos="center" style:horizontal-rel="paragraph" fo:background-color="#004586" style:background-transparency="25%" draw:fill="solid" draw:fill-gradient-name="">
+        <style:background-image/>
+        <style:columns fo:column-count="1" fo:column-gap="0cm"/>
+      </style:graphic-properties>
+  </style:style>
+  <style:page-layout style:name="pm1">
+   <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="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="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>
+ </office:automatic-styles>
+ <office:master-styles>
+  <style:master-page style:name="Standard" style:page-layout-name="pm1"/>
+ </office:master-styles>
+ <office:body>
+  <office:text>
+   <text:p text:style-name="Standard"><draw:frame draw:style-name="fr1" draw:name="Frame1" text:anchor-type="paragraph" svg:width="2cm" draw:z-index="0">
+     <draw:text-box fo:min-height="2.168cm">
+      <text:p text:style-name="P1">foo</text:p>
+     </draw:text-box>
+    </draw:frame></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 7c6e2e2..a4b467e 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -400,6 +400,18 @@ DECLARE_ODFIMPORT_TEST(testFdo82165, "fdo82165.odt")
     } catch (lang::IndexOutOfBoundsException const&) { }
 }
 
+DECLARE_ODFIMPORT_TEST(testTdf89802, "tdf89802.fodt")
+{
+    // the text frame was dropped during import
+    uno::Reference<text::XTextFramesSupplier> const xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> const xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
+    uno::Reference<beans::XPropertySet> const xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
+    sal_Int32 nValue(0);
+    xFrame->getPropertyValue("BackColor") >>= nValue;
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0x3f004586), nValue);
+}
+
 DECLARE_ODFIMPORT_TEST(testFdo37606, "fdo37606.odt")
 {
     SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
diff --git a/xmloff/source/draw/XMLShapeStyleContext.cxx b/xmloff/source/draw/XMLShapeStyleContext.cxx
index 720ac4c..fe1b6b9 100644
--- a/xmloff/source/draw/XMLShapeStyleContext.cxx
+++ b/xmloff/source/draw/XMLShapeStyleContext.cxx
@@ -238,6 +238,19 @@ void XMLShapeStyleContext::FillPropertySet( const Reference< beans::XPropertySet
             OUString sStyleName;
             rState.maValue >>= sStyleName;
             sStyleName = GetImport().GetStyleDisplayName( aFamilies[i], sStyleName );
+            // All of these attributes refer to something with draw:name
+            // of type styleName = NCName which is non-empty.
+            // tdf#89802: for Writer frames there would be no exception here but
+            // it will fail later on attach() and take out the entire frame
+            if (sStyleName.isEmpty())
+            {
+                Sequence<OUString> const seq{ sStyleName };
+                GetImport().SetError(
+                    XMLERROR_STYLE_PROP_VALUE | XMLERROR_FLAG_WARNING,
+                    seq, "empty style name reference", NULL );
+                break;
+            }
+
             try
             {
 


More information about the Libreoffice-commits mailing list