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

Miklos Vajna vmiklos at collabora.co.uk
Wed Sep 6 07:06:29 UTC 2017


 writerperfect/qa/unit/EPUBExportTest.cxx                          |   14 +++++++
 writerperfect/qa/unit/data/writer/epubexport/char-namedstyle.fodt |   16 ++++++++
 writerperfect/source/writer/exp/txtparai.cxx                      |   20 +++++++---
 3 files changed, 45 insertions(+), 5 deletions(-)

New commits:
commit 4f7034b64cd6ae6cd7bc2ef99d29709ab6117a31
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 5 20:16:49 2017 +0200

    EPUB export: handle text properties from text styles
    
    This is the last combination of style -> direct inheritance that was not
    handled previously.
    
    Change-Id: Ie92b38b89a13b81f09cd7300b0d1b939cda3d8ff
    Reviewed-on: https://gerrit.libreoffice.org/41952
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx
index 8ab03f6df48e..1b57655180b0 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -55,6 +55,7 @@ public:
     void testParaAutostyleCharProps();
     void testMeta();
     void testParaNamedstyle();
+    void testCharNamedstyle();
 
     CPPUNIT_TEST_SUITE(EPUBExportTest);
     CPPUNIT_TEST(testOutlineLevel);
@@ -65,6 +66,7 @@ public:
     CPPUNIT_TEST(testParaAutostyleCharProps);
     CPPUNIT_TEST(testMeta);
     CPPUNIT_TEST(testParaNamedstyle);
+    CPPUNIT_TEST(testCharNamedstyle);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -232,6 +234,18 @@ void EPUBExportTest::testParaNamedstyle()
     assertXPath(mpXmlDoc, "//xhtml:p[2]/xhtml:span", "class", "span1");
 }
 
+void EPUBExportTest::testCharNamedstyle()
+{
+    createDoc("char-namedstyle.fodt", {});
+
+    mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
+
+    // Test character properties from named text style.
+    assertXPath(mpXmlDoc, "//xhtml:p/xhtml:span[1]", "class", "span0");
+    // This failed, character properties from text style were not exported.
+    assertXPath(mpXmlDoc, "//xhtml:p/xhtml:span[2]", "class", "span1");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(EPUBExportTest);
 
 }
diff --git a/writerperfect/qa/unit/data/writer/epubexport/char-namedstyle.fodt b/writerperfect/qa/unit/data/writer/epubexport/char-namedstyle.fodt
new file mode 100644
index 000000000000..5a1b3823dd18
--- /dev/null
+++ b/writerperfect/qa/unit/data/writer/epubexport/char-namedstyle.fodt
@@ -0,0 +1,16 @@
+<?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:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
+  <office:font-face-decls>
+    <style:font-face style:name="Liberation Mono" svg:font-family="'Liberation Mono'" style:font-family-generic="modern" style:font-pitch="fixed"/>
+  </office:font-face-decls>
+  <office:styles>
+    <style:style style:name="Source_20_Text" style:display-name="Source Text" style:family="text">
+      <style:text-properties style:font-name="Liberation Mono" fo:font-family="'Liberation Mono'" style:font-family-generic="modern" style:font-pitch="fixed"/>
+    </style:style>
+  </office:styles>
+  <office:body>
+    <office:text>
+      <text:p>Foo<text:span text:style-name="Source_20_Text">bar</text:span></text:p>
+    </office:text>
+  </office:body>
+</office:document>
diff --git a/writerperfect/source/writer/exp/txtparai.cxx b/writerperfect/source/writer/exp/txtparai.cxx
index 932ae744f4e9..31ab25f43cad 100644
--- a/writerperfect/source/writer/exp/txtparai.cxx
+++ b/writerperfect/source/writer/exp/txtparai.cxx
@@ -55,13 +55,23 @@ void XMLSpanContext::startElement(const OUString &/*rName*/, const css::uno::Ref
         {
             // Reference to an automatic text style, try to look it up.
             auto itStyle = mrImport.GetAutomaticTextStyles().find(rAttributeValue);
-            if (itStyle == mrImport.GetAutomaticTextStyles().end())
+            if (itStyle != mrImport.GetAutomaticTextStyles().end())
+            {
+                // Apply properties directly, librevenge has no notion of automatic styles.
+                librevenge::RVNGPropertyList::Iter itProp(itStyle->second);
+                for (itProp.rewind(); itProp.next();)
+                    aPropertyList.insert(itProp.key(), itProp()->clone());
                 continue;
+            }
 
-            // Apply properties directly, librevenge has no notion of automatic styles.
-            librevenge::RVNGPropertyList::Iter itProp(itStyle->second);
-            for (itProp.rewind(); itProp.next();)
-                aPropertyList.insert(itProp.key(), itProp()->clone());
+            itStyle = mrImport.GetTextStyles().find(rAttributeValue);
+            if (itStyle != mrImport.GetTextStyles().end())
+            {
+                // Apply properties from text style.
+                librevenge::RVNGPropertyList::Iter itProp(itStyle->second);
+                for (itProp.rewind(); itProp.next();)
+                    aPropertyList.insert(itProp.key(), itProp()->clone());
+            }
         }
         else
         {


More information about the Libreoffice-commits mailing list