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

Miklos Vajna vmiklos at collabora.co.uk
Mon Nov 27 11:12:32 UTC 2017


 external/libepubgen/libepubgen-epub3.patch.1                   |  232 ++++++++++
 writerperfect/qa/unit/EPUBExportTest.cxx                       |   12 
 writerperfect/qa/unit/data/writer/epubexport/image-border.fodt |   36 +
 writerperfect/source/writer/exp/XMLTextFrameContext.cxx        |   20 
 writerperfect/source/writer/exp/txtstyli.cxx                   |   45 +
 writerperfect/source/writer/exp/txtstyli.hxx                   |    2 
 writerperfect/source/writer/exp/xmlfmt.cxx                     |   25 -
 writerperfect/source/writer/exp/xmlfmt.hxx                     |    9 
 writerperfect/source/writer/exp/xmlimp.cxx                     |   24 -
 writerperfect/source/writer/exp/xmlimp.hxx                     |    4 
 10 files changed, 373 insertions(+), 36 deletions(-)

New commits:
commit d43aa095b47bfb7e82a3c5a7b3b5149550716640
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Nov 27 08:17:33 2017 +0100

    EPUB export: handle image borders
    
    This requires handling of graphic styles.
    
    Change-Id: I74d4ee882b91192da44d8d7bbd88c1a66e97695f
    Reviewed-on: https://gerrit.libreoffice.org/45305
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 b/external/libepubgen/libepubgen-epub3.patch.1
index 98ce658e5705..c28f1b49a633 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -3316,3 +3316,235 @@ index 24ae1a5..ab1f9e6 100644
 -- 
 2.13.6
 
+From 801367ee905aa70bb2ba2ad5b8257cd2a25bed9b Mon Sep 17 00:00:00 2001
+From: Miklos Vajna <vmiklos at collabora.co.uk>
+Date: Wed, 8 Nov 2017 10:50:11 +0100
+Subject: [PATCH] EPUBImageManager: add support for borders
+
+The properties are on the frame, but the inner binary object emits the
+"img" element that has the properties in XHTML. Solve this by
+maintaining a stack of currently opened frames, with their properties.
+---
+ src/lib/EPUBGenerator.cpp          |  1 +
+ src/lib/EPUBHTMLGenerator.cpp      | 26 ++++++++++++++++++++
+ src/lib/EPUBImageManager.cpp       | 50 ++++++++++++++++++++++++++++++++++++++
+ src/lib/EPUBImageManager.h         | 16 ++++++++++++
+ src/test/EPUBTextGeneratorTest.cpp | 26 ++++++++++++++++++++
+ 5 files changed, 119 insertions(+)
+
+diff --git a/src/lib/EPUBGenerator.cpp b/src/lib/EPUBGenerator.cpp
+index 75c3076..38c3188 100644
+--- a/src/lib/EPUBGenerator.cpp
++++ b/src/lib/EPUBGenerator.cpp
+@@ -230,6 +230,7 @@ void EPUBGenerator::writeStylesheet()
+   m_paragraphStyleManager.send(sink);
+   m_spanStyleManager.send(sink);
+   m_tableStyleManager.send(sink);
++  m_imageManager.send(sink);
+ 
+   sink.writeTo(*m_package, m_stylesheetPath.str().c_str());
+ }
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index e00bea8..4ffa55d 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
++++ b/src/lib/EPUBHTMLGenerator.cpp
+@@ -364,6 +364,7 @@ struct EPUBHTMLGeneratorImpl
+     , m_ignore(false)
+     , m_hasText(false)
+     , m_frameAnchorTypes()
++    , m_framePropertiesStack()
+     , m_stylesMethod(stylesMethod)
+     , m_actualSink()
+     , m_sinkStack()
+@@ -454,6 +455,7 @@ struct EPUBHTMLGeneratorImpl
+   bool m_hasText;
+ 
+   std::stack<std::string> m_frameAnchorTypes;
++  std::stack<RVNGPropertyList> m_framePropertiesStack;
+ 
+   EPUBStylesMethod m_stylesMethod;
+ 
+@@ -929,20 +931,29 @@ void EPUBHTMLGenerator::openFrame(const RVNGPropertyList &propList)
+ {
+   librevenge::RVNGPropertyList::Iter i(propList);
+   std::string anchorType;
++  RVNGPropertyList frameProperties;
+   for (i.rewind(); i.next();)
+   {
+     if (std::string("text:anchor-type") == i.key())
+       anchorType = i()->getStr().cstr();
++
++    // Remember the property for binary object purposes.
++    frameProperties.insert(i.key(), i()->clone());
+   }
+ 
+   if (anchorType == "page")
+     // Other anchor types are already inside a paragraph.
+     m_impl->output().openElement("p", RVNGPropertyList());
+   m_impl->m_frameAnchorTypes.push(anchorType);
++
++  m_impl->m_framePropertiesStack.push(frameProperties);
+ }
+ 
+ void EPUBHTMLGenerator::closeFrame()
+ {
++  if (!m_impl->m_framePropertiesStack.empty())
++    m_impl->m_framePropertiesStack.pop();
++
+   if (m_impl->m_frameAnchorTypes.empty())
+     return;
+ 
+@@ -970,6 +981,21 @@ void EPUBHTMLGenerator::insertBinaryObject(const RVNGPropertyList &propList)
+                            propList["librevenge:mime-type"]->getStr());
+ 
+   RVNGPropertyList attrs;
++
++  if (!m_impl->m_framePropertiesStack.empty())
++  {
++    RVNGPropertyList &frameProperties = m_impl->m_framePropertiesStack.top();
++    switch (m_impl->m_stylesMethod)
++    {
++    case EPUB_STYLES_METHOD_CSS:
++      attrs.insert("class", m_impl->m_imageManager.getImageClass(frameProperties).c_str());
++      break;
++    case EPUB_STYLES_METHOD_INLINE:
++      attrs.insert("style", m_impl->m_imageManager.getImageStyle(frameProperties).c_str());
++      break;
++    }
++  }
++
+   attrs.insert("src", path.relativeTo(m_impl->m_path).str().c_str());
+   // FIXME: use alternative repr. if available
+   attrs.insert("alt", path.str().c_str());
+diff --git a/src/lib/EPUBImageManager.cpp b/src/lib/EPUBImageManager.cpp
+index 0179cad..2311e76 100644
+--- a/src/lib/EPUBImageManager.cpp
++++ b/src/lib/EPUBImageManager.cpp
+@@ -16,6 +16,7 @@
+ #include "EPUBBinarySink.h"
+ #include "EPUBImageManager.h"
+ #include "EPUBManifest.h"
++#include "EPUBCSSSink.h"
+ 
+ namespace libepubgen
+ {
+@@ -68,6 +69,7 @@ EPUBImageManager::EPUBImageManager(EPUBManifest &manifest)
+   : m_manifest(manifest)
+   , m_map()
+   , m_number()
++  , m_imageContentNameMap()
+ {
+ }
+ 
+@@ -105,6 +107,54 @@ void EPUBImageManager::writeTo(EPUBPackage &package)
+   }
+ }
+ 
++std::string EPUBImageManager::getImageClass(librevenge::RVNGPropertyList const &pList)
++{
++  EPUBCSSProperties content;
++  extractImageProperties(pList, content);
++  ContentNameMap_t::const_iterator it=m_imageContentNameMap.find(content);
++  if (it != m_imageContentNameMap.end())
++    return it->second;
++  std::stringstream s;
++  s << "image" << m_imageContentNameMap.size();
++  m_imageContentNameMap[content]=s.str();
++  return s.str();
++}
++
++std::string EPUBImageManager::getImageStyle(librevenge::RVNGPropertyList const &pList)
++{
++  EPUBCSSProperties content;
++  extractImageProperties(pList, content);
++
++  std::stringstream s;
++  for (const auto &property : content)
++    s << property.first << ": " << property.second << "; ";
++  return s.str();
++}
++
++void EPUBImageManager::extractImageProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const
++{
++  // Extract borders.
++  static char const *(type[]) = {"border", "border-left", "border-top", "border-right", "border-bottom" };
++  for (int i = 0; i < 5; i++)
++  {
++    std::string field("fo:");
++    field+=type[i];
++    if (!pList[field.c_str()])
++      continue;
++    cssProps[type[i]] =  pList[field.c_str()]->getStr().cstr();
++  }
++}
++
++void EPUBImageManager::send(EPUBCSSSink &out)
++{
++  for (auto it = m_imageContentNameMap.begin(); m_imageContentNameMap.end() != it; ++it)
++  {
++    librevenge::RVNGPropertyList props;
++    fillPropertyList(it->first, props);
++    out.insertRule(("." + it->second).c_str(), props);
++  }
++}
++
+ }
+ 
+ /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
+diff --git a/src/lib/EPUBImageManager.h b/src/lib/EPUBImageManager.h
+index 21a1b37..c9f4236 100644
+--- a/src/lib/EPUBImageManager.h
++++ b/src/lib/EPUBImageManager.h
+@@ -12,8 +12,10 @@
+ 
+ #include <unordered_map>
+ 
++#include <boost/functional/hash.hpp>
+ #include <librevenge/librevenge.h>
+ 
++#include "EPUBCSSProperties.h"
+ #include "EPUBCounter.h"
+ #include "EPUBPath.h"
+ 
+@@ -22,6 +24,7 @@ namespace libepubgen
+ 
+ class EPUBManifest;
+ class EPUBPackage;
++class EPUBCSSSink;
+ 
+ class EPUBImageManager
+ {
+@@ -40,6 +43,7 @@ class EPUBImageManager
+   };
+ 
+   typedef std::unordered_map<librevenge::RVNGBinaryData, EPUBPath, BinaryDataHash, BinaryDataEqual> MapType_t;
++  typedef std::unordered_map<EPUBCSSProperties, std::string, boost::hash<EPUBCSSProperties>> ContentNameMap_t;
+ 
+ public:
+   explicit EPUBImageManager(EPUBManifest &manifest);
+@@ -48,10 +52,22 @@ public:
+ 
+   void writeTo(EPUBPackage &package);
+ 
++  //! returns the class name corresponding to a propertylist
++  std::string getImageClass(librevenge::RVNGPropertyList const &pList);
++  //! returns the style string corresponding to a propertylist
++  std::string getImageStyle(librevenge::RVNGPropertyList const &pList);
++  //! send the data to the sink
++  void send(EPUBCSSSink &out);
++
+ private:
++  //! convert a property list into a CSS property map
++  void extractImageProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
++
+   EPUBManifest &m_manifest;
+   MapType_t m_map;
+   EPUBCounter m_number;
++  //! a map image content -> name
++  ContentNameMap_t m_imageContentNameMap;
+ };
+ 
+ }
+-- 
+2.13.6
+
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx
index 5f74ef71ea59..18865e4d8c4b 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -73,6 +73,7 @@ public:
     void testSection();
     void testList();
     void testImage();
+    void testImageBorder();
     void testTable();
     void testTableRowSpan();
     void testTableCellBorder();
@@ -101,6 +102,7 @@ public:
     CPPUNIT_TEST(testSection);
     CPPUNIT_TEST(testList);
     CPPUNIT_TEST(testImage);
+    CPPUNIT_TEST(testImageBorder);
     CPPUNIT_TEST(testTable);
     CPPUNIT_TEST(testTableRowSpan);
     CPPUNIT_TEST(testTableCellBorder);
@@ -481,6 +483,16 @@ void EPUBExportTest::testImage()
     assertXPath(mpXmlDoc, "//xhtml:p/xhtml:img", 1);
 }
 
+void EPUBExportTest::testImageBorder()
+{
+    createDoc("image-border.fodt", {});
+
+    mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
+    OUString aStyle = getXPath(mpXmlDoc, "//xhtml:img", "style");
+    // This failed, image had no border.
+    CPPUNIT_ASSERT_EQUAL(OUString("0.99pt dashed #ed1c24"), EPUBExportTest::parseCssStyle(aStyle)["border"]);
+}
+
 void EPUBExportTest::testTable()
 {
     createDoc("table.fodt", {});
diff --git a/writerperfect/qa/unit/data/writer/epubexport/image-border.fodt b/writerperfect/qa/unit/data/writer/epubexport/image-border.fodt
new file mode 100644
index 000000000000..cffe4d606839
--- /dev/null
+++ b/writerperfect/qa/unit/data/writer/epubexport/image-border.fodt
@@ -0,0 +1,36 @@
+<?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:styles>
+    <style:style style:name="Graphics" style:family="graphic">
+      <style:graphic-properties text:anchor-type="paragraph" svg:x="0cm" svg:y="0cm" style:wrap="dynamic" style:number-wrapped-paragraphs="no-limit" style:wrap-contour="false" style:vertical-pos="top" style:vertical-rel="paragraph" style:horizontal-pos="center" style:horizontal-rel="paragraph"/>
+    </style:style>
+  </office:styles>
+  <office:automatic-styles>
+    <style:style style:name="T1" style:family="text">
+      <style:text-properties fo:color="#000000" style:font-size-complex="12pt"/>
+    </style:style>
+    <style:style style:name="fr1" style:family="graphic" style:parent-style-name="Graphics">
+      <style:graphic-properties style:vertical-pos="top" style:vertical-rel="baseline" fo:padding="0.049cm" fo:border="0.99pt dashed #ed1c24" 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"/>
+    </style:style>
+  </office:automatic-styles>
+  <office:body>
+    <office:text>
+      <text:p text:style-name="Standard">before<text:span text:style-name="T1"><draw:frame draw:style-name="fr1" draw:name="Object0" text:anchor-type="as-char" svg:width="1.663cm" svg:height="1.663cm" draw:z-index="0"><draw:image loext:mime-type="image/png"><office:binary-data>iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAABGdBTUEAALGPC/xhBQAAAAFz
+        UkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAA
+        AAJiS0dEAACqjSMyAAAACW9GRnMAAAAGAAAAAAAMc1XTAAAACXBIWXMAAA3XAAAN1wFCKJt4
+        AAAACXZwQWcAAABMAAAAQACdMTgbAAABzUlEQVRo3u3ZPU/CQBjA8X+Jxs3ESUDj4iK+LA5+
+        BBfjqBE1cXB2MlFAEqMgxvhNNL4sLsK3UPQL6ObkoAETz+FKW2mxCPRYnucWUu76/OC59C49
+        cGOCKqrD9kHRc6ddPv7oW2WCwMh0nF63Myz7Tm8hPTNu0pgHMER3scepTbgK6enJNND83RLn
+        /878yRaPmgBZFDuMsNLeWB9gmFQHP77MIg9gsYciR50NFKvtjIy10yk84pSZA7DYpwR8scmF
+        QQCMuoQMpzbh0iAARrlnVn90CWHTsZcAiHPPdINQAuqsc2MQAAnKDUKWEhZ10twaBEDSJWQo
+        YlFj7S9CzwEegkXWIbQsRAQASFJhpplwbRAACS+hANRJBxMiAkDcJeQ4sQkBhYgMoJ+Ozlwo
+        2YQ7AJ6CRxyiUGnVy3hVKb0Af9v7hUG2Wy9TEQCUelFTDULB2S+YKYGOMcpM6UIccOQnRA6A
+        cSp6ibfI+wkGADBGpTEd8xz1AaAfTQ7huA8AvUw5hVjuA0D/C5OaMN8XACRZ8F0zCggKAQhA
+        AAIQgAAEIAABCEAAAhCAAAQgAAH4zg3feY4w3Xs44M5+oW0qvCWoGcvaIlM3x/f/ab+O738A
+        hOCNQr34oD4AAAAldEVYdGNyZWF0ZS1kYXRlADIwMTAtMTItMjBUMTc6MDg6MzYrMDE6MDB6
+        5RscAAAAJXRFWHRtb2RpZnktZGF0ZQAyMDEwLTEyLTIwVDE3OjA4OjM3KzAxOjAwgyNmnAAA
+        AABJRU5ErkJggg==
+       </office:binary-data></draw:image></draw:frame></text:span>after</text:p>
+    </office:text>
+  </office:body>
+</office:document>
diff --git a/writerperfect/source/writer/exp/XMLTextFrameContext.cxx b/writerperfect/source/writer/exp/XMLTextFrameContext.cxx
index 94c76b71be9a..556b6597cb42 100644
--- a/writerperfect/source/writer/exp/XMLTextFrameContext.cxx
+++ b/writerperfect/source/writer/exp/XMLTextFrameContext.cxx
@@ -10,6 +10,7 @@
 #include "XMLTextFrameContext.hxx"
 
 #include "XMLBase64ImportContext.hxx"
+#include "txtparai.hxx"
 #include "xmlimp.hxx"
 
 using namespace com::sun::star;
@@ -83,9 +84,24 @@ rtl::Reference<XMLImportContext> XMLTextFrameContext::CreateChildContext(const O
     return nullptr;
 }
 
-void XMLTextFrameContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/)
+void XMLTextFrameContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs)
 {
-    mrImport.GetGenerator().openFrame(librevenge::RVNGPropertyList());
+    librevenge::RVNGPropertyList aPropertyList;
+    for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i)
+    {
+        const OUString &rAttributeName = xAttribs->getNameByIndex(i);
+        const OUString &rAttributeValue = xAttribs->getValueByIndex(i);
+
+        if (rAttributeName == "draw:style-name")
+            FillStyles(rAttributeValue, mrImport.GetAutomaticGraphicStyles(), mrImport.GetGraphicStyles(), aPropertyList);
+        else
+        {
+            OString sName = OUStringToOString(rAttributeName, RTL_TEXTENCODING_UTF8);
+            OString sValue = OUStringToOString(rAttributeValue, RTL_TEXTENCODING_UTF8);
+            aPropertyList.insert(sName.getStr(), sValue.getStr());
+        }
+    }
+    mrImport.GetGenerator().openFrame(aPropertyList);
 }
 
 void XMLTextFrameContext::endElement(const OUString &/*rName*/)
diff --git a/writerperfect/source/writer/exp/txtstyli.cxx b/writerperfect/source/writer/exp/txtstyli.cxx
index c05d53cc87b9..88c63aa9063f 100644
--- a/writerperfect/source/writer/exp/txtstyli.cxx
+++ b/writerperfect/source/writer/exp/txtstyli.cxx
@@ -75,6 +75,34 @@ void XMLTextPropertiesContext::startElement(const OUString &/*rName*/, const css
     }
 }
 
+/// Handler for <style:graphic-properties>.
+class XMLGraphicPropertiesContext : public XMLImportContext
+{
+public:
+    XMLGraphicPropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle);
+
+    void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
+
+private:
+    XMLStyleContext &mrStyle;
+};
+
+XMLGraphicPropertiesContext::XMLGraphicPropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle)
+    : XMLImportContext(rImport)
+    , mrStyle(rStyle)
+{
+}
+
+void XMLGraphicPropertiesContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs)
+{
+    for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i)
+    {
+        OString sName = OUStringToOString(xAttribs->getNameByIndex(i), RTL_TEXTENCODING_UTF8);
+        OString sValue = OUStringToOString(xAttribs->getValueByIndex(i), RTL_TEXTENCODING_UTF8);
+        mrStyle.GetGraphicPropertyList().insert(sName.getStr(), sValue.getStr());
+    }
+}
+
 /// Handler for <style:table-properties>.
 class XMLTablePropertiesContext : public XMLImportContext
 {
@@ -211,6 +239,8 @@ rtl::Reference<XMLImportContext> XMLStyleContext::CreateChildContext(const OUStr
         return new XMLTableRowPropertiesContext(mrImport, *this);
     if (rName == "style:table-properties")
         return new XMLTablePropertiesContext(mrImport, *this);
+    if (rName == "style:graphic-properties")
+        return new XMLGraphicPropertiesContext(mrImport, *this);
     return nullptr;
 }
 
@@ -242,14 +272,16 @@ void XMLStyleContext::endElement(const OUString &/*rName*/)
         m_rStyles.GetCurrentTextStyles()[m_aName] = m_aTextPropertyList;
     if (m_aFamily == "paragraph")
         m_rStyles.GetCurrentParagraphStyles()[m_aName] = m_aParagraphPropertyList;
-    if (m_aFamily == "table-cell")
+    else if (m_aFamily == "table-cell")
         m_rStyles.GetCurrentCellStyles()[m_aName] = m_aCellPropertyList;
-    if (m_aFamily == "table-column")
+    else if (m_aFamily == "table-column")
         m_rStyles.GetCurrentColumnStyles()[m_aName] = m_aColumnPropertyList;
-    if (m_aFamily == "table-row")
+    else if (m_aFamily == "table-row")
         m_rStyles.GetCurrentRowStyles()[m_aName] = m_aRowPropertyList;
-    if (m_aFamily == "table")
+    else if (m_aFamily == "table")
         m_rStyles.GetCurrentTableStyles()[m_aName] = m_aTablePropertyList;
+    else if (m_aFamily == "graphic")
+        m_rStyles.GetCurrentGraphicStyles()[m_aName] = m_aGraphicPropertyList;
 }
 
 librevenge::RVNGPropertyList &XMLStyleContext::GetTextPropertyList()
@@ -282,6 +314,11 @@ librevenge::RVNGPropertyList &XMLStyleContext::GetTablePropertyList()
     return m_aTablePropertyList;
 }
 
+librevenge::RVNGPropertyList &XMLStyleContext::GetGraphicPropertyList()
+{
+    return m_aGraphicPropertyList;
+}
+
 } // namespace exp
 } // namespace writerperfect
 
diff --git a/writerperfect/source/writer/exp/txtstyli.hxx b/writerperfect/source/writer/exp/txtstyli.hxx
index 9855d459e360..f3b3b6da38c9 100644
--- a/writerperfect/source/writer/exp/txtstyli.hxx
+++ b/writerperfect/source/writer/exp/txtstyli.hxx
@@ -37,6 +37,7 @@ public:
     librevenge::RVNGPropertyList &GetColumnPropertyList();
     librevenge::RVNGPropertyList &GetRowPropertyList();
     librevenge::RVNGPropertyList &GetTablePropertyList();
+    librevenge::RVNGPropertyList &GetGraphicPropertyList();
 
 private:
     OUString m_aName;
@@ -47,6 +48,7 @@ private:
     librevenge::RVNGPropertyList m_aColumnPropertyList;
     librevenge::RVNGPropertyList m_aRowPropertyList;
     librevenge::RVNGPropertyList m_aTablePropertyList;
+    librevenge::RVNGPropertyList m_aGraphicPropertyList;
     XMLStylesContext &m_rStyles;
 };
 
diff --git a/writerperfect/source/writer/exp/xmlfmt.cxx b/writerperfect/source/writer/exp/xmlfmt.cxx
index 23550616953b..02f96f691e9b 100644
--- a/writerperfect/source/writer/exp/xmlfmt.cxx
+++ b/writerperfect/source/writer/exp/xmlfmt.cxx
@@ -19,19 +19,15 @@ namespace writerperfect
 namespace exp
 {
 
-XMLStylesContext::XMLStylesContext(XMLImport &rImport, std::map<OUString, librevenge::RVNGPropertyList> &rParagraphStyles,
-                                   std::map<OUString, librevenge::RVNGPropertyList> &rTextStyles,
-                                   std::map<OUString, librevenge::RVNGPropertyList> &rCellStyles,
-                                   std::map<OUString, librevenge::RVNGPropertyList> &rColumnStyles,
-                                   std::map<OUString, librevenge::RVNGPropertyList> &rRowStyles,
-                                   std::map<OUString, librevenge::RVNGPropertyList> &rTableStyles)
+XMLStylesContext::XMLStylesContext(XMLImport &rImport, bool bAutomatic)
     : XMLImportContext(rImport),
-      m_rParagraphStyles(rParagraphStyles),
-      m_rTextStyles(rTextStyles),
-      m_rCellStyles(rCellStyles),
-      m_rColumnStyles(rColumnStyles),
-      m_rRowStyles(rRowStyles),
-      m_rTableStyles(rTableStyles)
+      m_rParagraphStyles(bAutomatic ? mrImport.GetAutomaticParagraphStyles() : mrImport.GetParagraphStyles()),
+      m_rTextStyles(bAutomatic ? mrImport.GetAutomaticTextStyles() : mrImport.GetTextStyles()),
+      m_rCellStyles(bAutomatic ? mrImport.GetAutomaticCellStyles() : mrImport.GetCellStyles()),
+      m_rColumnStyles(bAutomatic ? mrImport.GetAutomaticColumnStyles() : mrImport.GetColumnStyles()),
+      m_rRowStyles(bAutomatic ? mrImport.GetAutomaticRowStyles() : mrImport.GetRowStyles()),
+      m_rTableStyles(bAutomatic ? mrImport.GetAutomaticTableStyles() : mrImport.GetTableStyles()),
+      m_rGraphicStyles(bAutomatic ? mrImport.GetAutomaticGraphicStyles() : mrImport.GetGraphicStyles())
 {
 }
 
@@ -72,6 +68,11 @@ std::map<OUString, librevenge::RVNGPropertyList> &XMLStylesContext::GetCurrentTa
     return m_rTableStyles;
 }
 
+std::map<OUString, librevenge::RVNGPropertyList> &XMLStylesContext::GetCurrentGraphicStyles()
+{
+    return m_rGraphicStyles;
+}
+
 } // namespace exp
 } // namespace writerperfect
 
diff --git a/writerperfect/source/writer/exp/xmlfmt.hxx b/writerperfect/source/writer/exp/xmlfmt.hxx
index 74d4b20d84f0..f4d82273b4f1 100644
--- a/writerperfect/source/writer/exp/xmlfmt.hxx
+++ b/writerperfect/source/writer/exp/xmlfmt.hxx
@@ -25,12 +25,7 @@ namespace exp
 class XMLStylesContext : public XMLImportContext
 {
 public:
-    XMLStylesContext(XMLImport &rImport, std::map<OUString, librevenge::RVNGPropertyList> &rParagraphStyles,
-                     std::map<OUString, librevenge::RVNGPropertyList> &rTextStyles,
-                     std::map<OUString, librevenge::RVNGPropertyList> &rCellStyles,
-                     std::map<OUString, librevenge::RVNGPropertyList> &rColumnStyles,
-                     std::map<OUString, librevenge::RVNGPropertyList> &rRowStyles,
-                     std::map<OUString, librevenge::RVNGPropertyList> &rTableStyles);
+    XMLStylesContext(XMLImport &rImport, bool bAutomatic);
 
     rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
 
@@ -40,6 +35,7 @@ public:
     std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentColumnStyles();
     std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentRowStyles();
     std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentTableStyles();
+    std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentGraphicStyles();
 private:
     std::map<OUString, librevenge::RVNGPropertyList> &m_rParagraphStyles;
     std::map<OUString, librevenge::RVNGPropertyList> &m_rTextStyles;
@@ -47,6 +43,7 @@ private:
     std::map<OUString, librevenge::RVNGPropertyList> &m_rColumnStyles;
     std::map<OUString, librevenge::RVNGPropertyList> &m_rRowStyles;
     std::map<OUString, librevenge::RVNGPropertyList> &m_rTableStyles;
+    std::map<OUString, librevenge::RVNGPropertyList> &m_rGraphicStyles;
 };
 
 } // namespace exp
diff --git a/writerperfect/source/writer/exp/xmlimp.cxx b/writerperfect/source/writer/exp/xmlimp.cxx
index 0f6582ff7403..b301cb3deb0f 100644
--- a/writerperfect/source/writer/exp/xmlimp.cxx
+++ b/writerperfect/source/writer/exp/xmlimp.cxx
@@ -63,19 +63,9 @@ rtl::Reference<XMLImportContext> XMLOfficeDocContext::CreateChildContext(const O
     else if (rName == "office:meta")
         return new XMLMetaDocumentContext(mrImport);
     else if (rName == "office:automatic-styles")
-        return new XMLStylesContext(mrImport, mrImport.GetAutomaticParagraphStyles(),
-                                    mrImport.GetAutomaticTextStyles(),
-                                    mrImport.GetAutomaticCellStyles(),
-                                    mrImport.GetAutomaticColumnStyles(),
-                                    mrImport.GetAutomaticRowStyles(),
-                                    mrImport.GetAutomaticTableStyles());
+        return new XMLStylesContext(mrImport, /*bAutomatic=*/true);
     else if (rName == "office:styles")
-        return new XMLStylesContext(mrImport, mrImport.GetParagraphStyles(),
-                                    mrImport.GetTextStyles(),
-                                    mrImport.GetCellStyles(),
-                                    mrImport.GetColumnStyles(),
-                                    mrImport.GetRowStyles(),
-                                    mrImport.GetTableStyles());
+        return new XMLStylesContext(mrImport, /*bAutomatic=*/false);
     return nullptr;
 }
 
@@ -126,6 +116,11 @@ std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetAutomaticTableSt
     return maAutomaticTableStyles;
 }
 
+std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetAutomaticGraphicStyles()
+{
+    return maAutomaticGraphicStyles;
+}
+
 std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetTextStyles()
 {
     return maTextStyles;
@@ -156,6 +151,11 @@ std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetTableStyles()
     return maTableStyles;
 }
 
+std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetGraphicStyles()
+{
+    return maGraphicStyles;
+}
+
 void XMLImport::startDocument()
 {
     mrGenerator.startDocument(librevenge::RVNGPropertyList());
diff --git a/writerperfect/source/writer/exp/xmlimp.hxx b/writerperfect/source/writer/exp/xmlimp.hxx
index 7f690d86a165..e1b80571d278 100644
--- a/writerperfect/source/writer/exp/xmlimp.hxx
+++ b/writerperfect/source/writer/exp/xmlimp.hxx
@@ -47,6 +47,8 @@ class XMLImport : public cppu::WeakImplHelper
     std::map<OUString, librevenge::RVNGPropertyList> maRowStyles;
     std::map<OUString, librevenge::RVNGPropertyList> maAutomaticTableStyles;
     std::map<OUString, librevenge::RVNGPropertyList> maTableStyles;
+    std::map<OUString, librevenge::RVNGPropertyList> maAutomaticGraphicStyles;
+    std::map<OUString, librevenge::RVNGPropertyList> maGraphicStyles;
 
 public:
     XMLImport(librevenge::RVNGTextInterface &rGenerator);
@@ -60,12 +62,14 @@ public:
     std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticColumnStyles();
     std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticRowStyles();
     std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticTableStyles();
+    std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticGraphicStyles();
     std::map<OUString, librevenge::RVNGPropertyList> &GetTextStyles();
     std::map<OUString, librevenge::RVNGPropertyList> &GetParagraphStyles();
     std::map<OUString, librevenge::RVNGPropertyList> &GetCellStyles();
     std::map<OUString, librevenge::RVNGPropertyList> &GetColumnStyles();
     std::map<OUString, librevenge::RVNGPropertyList> &GetRowStyles();
     std::map<OUString, librevenge::RVNGPropertyList> &GetTableStyles();
+    std::map<OUString, librevenge::RVNGPropertyList> &GetGraphicStyles();
 
     // XDocumentHandler
     void SAL_CALL startDocument() override;


More information about the Libreoffice-commits mailing list