summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-11-24 09:14:05 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-11-24 14:06:22 +0100
commit8b8aa6bc010fffbcd47679aa101075d702741f69 (patch)
tree2a18d605cfbd0a5240949619dd19513345286fd7
parented0e7262f859adabc56a4f251f2ef1a66c98c3f5 (diff)
EPUB export: handle total table width
This is important when e.g. the col width are 50-50%, then without explicit total table width the table width won't be correct. Change-Id: I5ccd6dfb5b78c564485d54cda62e12f3d1ca36c1 Reviewed-on: https://gerrit.libreoffice.org/45204 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--external/libepubgen/libepubgen-epub3.patch.1219
-rw-r--r--writerperfect/qa/unit/EPUBExportTest.cxx39
-rw-r--r--writerperfect/qa/unit/data/writer/epubexport/table-width.fodt28
-rw-r--r--writerperfect/source/writer/exp/txtstyli.cxx41
-rw-r--r--writerperfect/source/writer/exp/txtstyli.hxx2
-rw-r--r--writerperfect/source/writer/exp/xmlfmt.cxx11
-rw-r--r--writerperfect/source/writer/exp/xmlfmt.hxx5
-rw-r--r--writerperfect/source/writer/exp/xmlimp.cxx16
-rw-r--r--writerperfect/source/writer/exp/xmlimp.hxx4
-rw-r--r--writerperfect/source/writer/exp/xmltbli.cxx23
-rw-r--r--writerperfect/source/writer/exp/xmltbli.hxx2
11 files changed, 367 insertions, 23 deletions
diff --git a/external/libepubgen/libepubgen-epub3.patch.1 b/external/libepubgen/libepubgen-epub3.patch.1
index 3ce4fe034f75..98ce658e5705 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -3097,3 +3097,222 @@ index 4de70e3..24ae1a5 100644
--
2.13.6
+From d5bd8c9078eeb63769ff1807be1a9571430eaed1 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna <vmiklos@collabora.co.uk>
+Date: Mon, 6 Nov 2017 10:19:32 +0100
+Subject: [PATCH] EPUBTableStyleManager: handle table props
+
+Other than column properties. Only width and relative width for now.
+---
+ src/lib/EPUBHTMLGenerator.cpp | 16 +++++--
+ src/lib/EPUBTableStyleManager.cpp | 87 ++++++++++++++++++++++++++++----------
+ src/lib/EPUBTableStyleManager.h | 12 +++++-
+ src/test/EPUBTextGeneratorTest.cpp | 27 ++++++++++++
+ 4 files changed, 114 insertions(+), 28 deletions(-)
+
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index 86b3ac2..e00bea8 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
++++ b/src/lib/EPUBHTMLGenerator.cpp
+@@ -846,10 +846,18 @@ void EPUBHTMLGenerator::openTable(const RVNGPropertyList &propList)
+ if (m_impl->m_ignore)
+ return;
+
+- const librevenge::RVNGPropertyListVector *columns = propList.child("librevenge:table-columns");
+- if (columns)
+- m_impl->m_tableManager.openTable(*columns);
+- m_impl->output().openElement("table", RVNGPropertyList());
++ m_impl->m_tableManager.openTable(propList);
++ RVNGPropertyList attrs;
++ switch (m_impl->m_stylesMethod)
++ {
++ case EPUB_STYLES_METHOD_CSS:
++ attrs.insert("class", m_impl->m_tableManager.getTableClass(propList).c_str());
++ break;
++ case EPUB_STYLES_METHOD_INLINE:
++ attrs.insert("style", m_impl->m_tableManager.getTableStyle(propList).c_str());
++ break;
++ }
++ m_impl->output().openElement("table", attrs);
+ m_impl->output().openElement("tbody", RVNGPropertyList());
+ }
+
+diff --git a/src/lib/EPUBTableStyleManager.cpp b/src/lib/EPUBTableStyleManager.cpp
+index 92078a2..d5e650c 100644
+--- a/src/lib/EPUBTableStyleManager.cpp
++++ b/src/lib/EPUBTableStyleManager.cpp
+@@ -23,34 +23,38 @@ using librevenge::RVNGPropertyList;
+ using librevenge::RVNGPropertyListVector;
+ using librevenge::RVNGString;
+
+-void EPUBTableStyleManager::openTable(RVNGPropertyListVector const &colList)
++void EPUBTableStyleManager::openTable(RVNGPropertyList const &propList)
+ {
+- std::vector<double> colWidths;
+- std::vector<double> relColWidths;
+- for (unsigned long i = 0; i < colList.count(); i++)
++ const librevenge::RVNGPropertyListVector *columns = propList.child("librevenge:table-columns");
++ if (columns)
+ {
+- RVNGPropertyList const &prop=colList[i];
+- double width=0;
+- if (prop["style:column-width"])
++ std::vector<double> colWidths;
++ std::vector<double> relColWidths;
++ for (unsigned long i = 0; i < columns->count(); i++)
+ {
+- librevenge::RVNGUnit unit=prop["style:column-width"]->getUnit();
+- if (unit==librevenge::RVNG_POINT)
+- width=prop["style:column-width"]->getDouble()/72.;
+- else if (unit==librevenge::RVNG_INCH)
+- width=prop["style:column-width"]->getDouble();
+- else if (unit==librevenge::RVNG_TWIP)
+- width=prop["style:column-width"]->getDouble()/1440.;
+- }
+- colWidths.push_back(width);
++ RVNGPropertyList const &prop=(*columns)[i];
++ double width=0;
++ if (prop["style:column-width"])
++ {
++ librevenge::RVNGUnit unit=prop["style:column-width"]->getUnit();
++ if (unit==librevenge::RVNG_POINT)
++ width=prop["style:column-width"]->getDouble()/72.;
++ else if (unit==librevenge::RVNG_INCH)
++ width=prop["style:column-width"]->getDouble();
++ else if (unit==librevenge::RVNG_TWIP)
++ width=prop["style:column-width"]->getDouble()/1440.;
++ }
++ colWidths.push_back(width);
+
+- if (prop["style:rel-column-width"])
+- {
+- width = prop["style:rel-column-width"]->getDouble();
+- relColWidths.push_back(width);
++ if (prop["style:rel-column-width"])
++ {
++ width = prop["style:rel-column-width"]->getDouble();
++ relColWidths.push_back(width);
++ }
+ }
++ m_columnWidthsStack.push_back(colWidths);
++ m_relColumnWidthsStack.push_back(relColWidths);
+ }
+- m_columnWidthsStack.push_back(colWidths);
+- m_relColumnWidthsStack.push_back(relColWidths);
+ }
+
+ void EPUBTableStyleManager::closeTable()
+@@ -160,6 +164,30 @@ std::string EPUBTableStyleManager::getRowStyle(RVNGPropertyList const &pList)
+ return s.str();
+ }
+
++std::string EPUBTableStyleManager::getTableClass(RVNGPropertyList const &pList)
++{
++ EPUBCSSProperties content;
++ extractTableProperties(pList, content);
++ ContentNameMap_t::const_iterator it=m_tableContentNameMap.find(content);
++ if (it != m_tableContentNameMap.end())
++ return it->second;
++ std::stringstream s;
++ s << "table" << m_tableContentNameMap.size();
++ m_tableContentNameMap[content]=s.str();
++ return s.str();
++}
++
++std::string EPUBTableStyleManager::getTableStyle(RVNGPropertyList const &pList)
++{
++ EPUBCSSProperties content;
++ extractTableProperties(pList, content);
++
++ std::stringstream s;
++ for (const auto &property : content)
++ s << property.first << ": " << property.second << "; ";
++ return s.str();
++}
++
+ void EPUBTableStyleManager::send(EPUBCSSSink &out)
+ {
+ for (ContentNameMap_t::const_iterator it=m_cellContentNameMap.begin(); m_cellContentNameMap.end() != it; ++it)
+@@ -175,6 +203,13 @@ void EPUBTableStyleManager::send(EPUBCSSSink &out)
+ fillPropertyList(it->first, props);
+ out.insertRule(("." + it->second).c_str(), props);
+ }
++
++ for (ContentNameMap_t::const_iterator it=m_tableContentNameMap.begin(); m_tableContentNameMap.end() != it; ++it)
++ {
++ RVNGPropertyList props;
++ fillPropertyList(it->first, props);
++ out.insertRule(("." + it->second).c_str(), props);
++ }
+ }
+
+ void EPUBTableStyleManager::extractCellProperties(RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const
+@@ -244,6 +279,14 @@ void EPUBTableStyleManager::extractRowProperties(RVNGPropertyList const &pList,
+ cssProps["height"] = pList["style:row-height"]->getStr().cstr();
+ }
+
++void EPUBTableStyleManager::extractTableProperties(RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const
++{
++ if (pList["style:rel-width"])
++ cssProps["width"] = pList["style:rel-width"]->getStr().cstr();
++ else if (pList["style:width"])
++ cssProps["width"] = pList["style:width"]->getStr().cstr();
++}
++
+ }
+
+ /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
+diff --git a/src/lib/EPUBTableStyleManager.h b/src/lib/EPUBTableStyleManager.h
+index 24ae1a5..ab1f9e6 100644
+--- a/src/lib/EPUBTableStyleManager.h
++++ b/src/lib/EPUBTableStyleManager.h
+@@ -32,7 +32,7 @@ class EPUBTableStyleManager
+
+ public:
+ //! constructor
+- EPUBTableStyleManager() : m_cellContentNameMap(), m_rowContentNameMap(), m_columnWidthsStack(), m_relColumnWidthsStack()
++ EPUBTableStyleManager() : m_cellContentNameMap(), m_rowContentNameMap(), m_tableContentNameMap(), m_columnWidthsStack(), m_relColumnWidthsStack()
+ {
+ }
+ //! destructor
+@@ -40,7 +40,7 @@ public:
+ {
+ }
+ //! open a table
+- void openTable(librevenge::RVNGPropertyListVector const &colList);
++ void openTable(librevenge::RVNGPropertyList const &propList);
+ //! close a table
+ void closeTable();
+ //! returns the class name corresponding to a propertylist
+@@ -51,6 +51,10 @@ public:
+ std::string getRowClass(librevenge::RVNGPropertyList const &pList);
+ //! returns the style string corresponding to a propertylist
+ std::string getRowStyle(librevenge::RVNGPropertyList const &pList);
++ //! returns the class name corresponding to a propertylist
++ std::string getTableClass(librevenge::RVNGPropertyList const &pList);
++ //! returns the style string corresponding to a propertylist
++ std::string getTableStyle(librevenge::RVNGPropertyList const &pList);
+ //! send the data to the sink
+ void send(EPUBCSSSink &out);
+ private:
+@@ -58,6 +62,8 @@ private:
+ void extractCellProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
+ //! convert a property list into a CSS property map
+ void extractRowProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
++ //! convert a property list into a CSS property map
++ void extractTableProperties(librevenge::RVNGPropertyList const &pList, EPUBCSSProperties &cssProps) const;
+ //! try to return the col width
+ bool getColumnsWidth(int i, int numSpanned, double &w) const;
+ //! try to return the relative col width
+@@ -66,6 +72,8 @@ private:
+ ContentNameMap_t m_cellContentNameMap;
+ //! a map row content -> name
+ ContentNameMap_t m_rowContentNameMap;
++ //! a map table content -> name
++ ContentNameMap_t m_tableContentNameMap;
+ //! a stack of column width (in inches )
+ std::vector<std::vector<double> > m_columnWidthsStack;
+ //! a stack of relative column width (in percents )
+--
+2.13.6
+
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx
index 49ef7297fa80..5f74ef71ea59 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -55,7 +55,7 @@ public:
/// Loads a CSS representation of the stream named rName in the exported package into rTree.
void parseCssExport(const OUString &rName, std::map< OString, std::vector<OString> > &rTree);
/// Loads a CSS style string into a map.
- static void parseCssStyle(const OUString &rStyle, std::map<OUString, OUString> &rCss);
+ static std::map<OUString, OUString> parseCssStyle(const OUString &rStyle);
void testOutlineLevel();
void testMimetype();
void testEPUB2();
@@ -81,6 +81,7 @@ public:
void testLink();
void testLinkCharFormat();
void testLinkNamedCharFormat();
+ void testTableWidth();
CPPUNIT_TEST_SUITE(EPUBExportTest);
CPPUNIT_TEST(testOutlineLevel);
@@ -108,6 +109,7 @@ public:
CPPUNIT_TEST(testLink);
CPPUNIT_TEST(testLinkCharFormat);
CPPUNIT_TEST(testLinkNamedCharFormat);
+ CPPUNIT_TEST(testTableWidth);
CPPUNIT_TEST_SUITE_END();
};
@@ -192,15 +194,19 @@ void EPUBExportTest::parseCssExport(const OUString &rName, std::map< OString, st
}
}
-void EPUBExportTest::parseCssStyle(const OUString &rStyle, std::map<OUString, OUString> &rCss)
+std::map<OUString, OUString> EPUBExportTest::parseCssStyle(const OUString &rStyle)
{
+ std::map<OUString, OUString> aCss;
+
for (const auto &rKeyValue : comphelper::string::split(rStyle, ';'))
{
OUString aKeyValue = rKeyValue.trim();
std::vector<OUString> aTokens = comphelper::string::split(aKeyValue, ':');
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aTokens.size());
- rCss[aTokens[0].trim()] = aTokens[1].trim();
+ aCss[aTokens[0].trim()] = aTokens[1].trim();
}
+
+ return aCss;
}
void EPUBExportTest::testOutlineLevel()
@@ -498,26 +504,20 @@ void EPUBExportTest::testTableCellBorder()
mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
OUString aStyle = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[1]", "style");
- std::map<OUString, OUString> aCss;
- parseCssStyle(aStyle, aCss);
// This failed, cell border wasn't exported.
- CPPUNIT_ASSERT_EQUAL(OUString("0.05pt solid #000000"), aCss["border-left"]);
+ CPPUNIT_ASSERT_EQUAL(OUString("0.05pt solid #000000"), EPUBExportTest::parseCssStyle(aStyle)["border-left"]);
}
namespace
{
double getCellWidth(const OUString &rStyle)
{
- std::map<OUString, OUString> aCss;
- EPUBExportTest::parseCssStyle(rStyle, aCss);
- return aCss["width"].toDouble();
+ return EPUBExportTest::parseCssStyle(rStyle)["width"].toDouble();
}
double getRowHeight(const OUString &rStyle)
{
- std::map<OUString, OUString> aCss;
- EPUBExportTest::parseCssStyle(rStyle, aCss);
- return aCss["height"].toDouble();
+ return EPUBExportTest::parseCssStyle(rStyle)["height"].toDouble();
}
}
@@ -575,9 +575,18 @@ void EPUBExportTest::testLinkNamedCharFormat()
assertXPath(mpXmlDoc, "//xhtml:p/xhtml:a", "href", "http://libreoffice.org/");
OUString aStyle = getXPath(mpXmlDoc, "//xhtml:p/xhtml:a/xhtml:span", "style");
- std::map<OUString, OUString> aCss;
- parseCssStyle(aStyle, aCss);
- CPPUNIT_ASSERT_EQUAL(OUString("#ff0000"), aCss["color"]);
+ CPPUNIT_ASSERT_EQUAL(OUString("#ff0000"), EPUBExportTest::parseCssStyle(aStyle)["color"]);
+}
+
+void EPUBExportTest::testTableWidth()
+{
+ createDoc("table-width.fodt", {});
+
+ mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
+
+ OUString aStyle = getXPath(mpXmlDoc, "//xhtml:table", "style");
+ // This failed, relative total width of table was lost.
+ CPPUNIT_ASSERT_EQUAL(OUString("50%"), EPUBExportTest::parseCssStyle(aStyle)["width"]);
}
CPPUNIT_TEST_SUITE_REGISTRATION(EPUBExportTest);
diff --git a/writerperfect/qa/unit/data/writer/epubexport/table-width.fodt b/writerperfect/qa/unit/data/writer/epubexport/table-width.fodt
new file mode 100644
index 000000000000..17793628df0a
--- /dev/null
+++ b/writerperfect/qa/unit/data/writer/epubexport/table-width.fodt
@@ -0,0 +1,28 @@
+<?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:oasis: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:automatic-styles>
+ <style:style style:name="Table1" style:family="table">
+ <style:table-properties style:width="8.795cm" style:rel-width="50%" table:align="left"/>
+ </style:style>
+ <style:style style:name="Table1.A" style:family="table-column">
+ <style:table-column-properties style:column-width="8.795cm" style:rel-column-width="4986*"/>
+ </style:style>
+ <style:style style:name="Table1.A1" style:family="table-cell">
+ <style:table-cell-properties fo:padding="0.097cm" fo:border="0.05pt solid #000000"/>
+ </style:style>
+ </office:automatic-styles>
+ <office:body>
+ <office:text>
+ <text:p>Before</text:p>
+ <table:table table:name="Table1" table:style-name="Table1">
+ <table:table-column table:style-name="Table1.A"/>
+ <table:table-row>
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p>In table</text:p>
+ </table:table-cell>
+ </table:table-row>
+ </table:table>
+ <text:p>After</text:p>
+ </office:text>
+ </office:body>
+</office:document>
diff --git a/writerperfect/source/writer/exp/txtstyli.cxx b/writerperfect/source/writer/exp/txtstyli.cxx
index 48f5f72beff8..c05d53cc87b9 100644
--- a/writerperfect/source/writer/exp/txtstyli.cxx
+++ b/writerperfect/source/writer/exp/txtstyli.cxx
@@ -75,6 +75,38 @@ void XMLTextPropertiesContext::startElement(const OUString &/*rName*/, const css
}
}
+/// Handler for <style:table-properties>.
+class XMLTablePropertiesContext : public XMLImportContext
+{
+public:
+ XMLTablePropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle);
+
+ void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
+
+private:
+ XMLStyleContext &mrStyle;
+};
+
+XMLTablePropertiesContext::XMLTablePropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle)
+ : XMLImportContext(rImport)
+ , mrStyle(rStyle)
+{
+}
+
+void XMLTablePropertiesContext::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);
+ if (sName == "style:rel-width")
+ // Make sure this is passed through as a string, and not parsed as a double.
+ mrStyle.GetTablePropertyList().insert(sName.getStr(), librevenge::RVNGPropertyFactory::newStringProp(sValue.getStr()));
+ else
+ mrStyle.GetTablePropertyList().insert(sName.getStr(), sValue.getStr());
+ }
+}
+
/// Handler for <style:table-row-properties>.
class XMLTableRowPropertiesContext : public XMLImportContext
{
@@ -177,6 +209,8 @@ rtl::Reference<XMLImportContext> XMLStyleContext::CreateChildContext(const OUStr
return new XMLTableColumnPropertiesContext(mrImport, *this);
if (rName == "style:table-row-properties")
return new XMLTableRowPropertiesContext(mrImport, *this);
+ if (rName == "style:table-properties")
+ return new XMLTablePropertiesContext(mrImport, *this);
return nullptr;
}
@@ -214,6 +248,8 @@ void XMLStyleContext::endElement(const OUString &/*rName*/)
m_rStyles.GetCurrentColumnStyles()[m_aName] = m_aColumnPropertyList;
if (m_aFamily == "table-row")
m_rStyles.GetCurrentRowStyles()[m_aName] = m_aRowPropertyList;
+ if (m_aFamily == "table")
+ m_rStyles.GetCurrentTableStyles()[m_aName] = m_aTablePropertyList;
}
librevenge::RVNGPropertyList &XMLStyleContext::GetTextPropertyList()
@@ -241,6 +277,11 @@ librevenge::RVNGPropertyList &XMLStyleContext::GetRowPropertyList()
return m_aRowPropertyList;
}
+librevenge::RVNGPropertyList &XMLStyleContext::GetTablePropertyList()
+{
+ return m_aTablePropertyList;
+}
+
} // namespace exp
} // namespace writerperfect
diff --git a/writerperfect/source/writer/exp/txtstyli.hxx b/writerperfect/source/writer/exp/txtstyli.hxx
index 6d0e2c1828a8..9855d459e360 100644
--- a/writerperfect/source/writer/exp/txtstyli.hxx
+++ b/writerperfect/source/writer/exp/txtstyli.hxx
@@ -36,6 +36,7 @@ public:
librevenge::RVNGPropertyList &GetCellPropertyList();
librevenge::RVNGPropertyList &GetColumnPropertyList();
librevenge::RVNGPropertyList &GetRowPropertyList();
+ librevenge::RVNGPropertyList &GetTablePropertyList();
private:
OUString m_aName;
@@ -45,6 +46,7 @@ private:
librevenge::RVNGPropertyList m_aCellPropertyList;
librevenge::RVNGPropertyList m_aColumnPropertyList;
librevenge::RVNGPropertyList m_aRowPropertyList;
+ librevenge::RVNGPropertyList m_aTablePropertyList;
XMLStylesContext &m_rStyles;
};
diff --git a/writerperfect/source/writer/exp/xmlfmt.cxx b/writerperfect/source/writer/exp/xmlfmt.cxx
index 2c73a9a8c968..23550616953b 100644
--- a/writerperfect/source/writer/exp/xmlfmt.cxx
+++ b/writerperfect/source/writer/exp/xmlfmt.cxx
@@ -23,13 +23,15 @@ XMLStylesContext::XMLStylesContext(XMLImport &rImport, std::map<OUString, librev
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> &rRowStyles,
+ std::map<OUString, librevenge::RVNGPropertyList> &rTableStyles)
: XMLImportContext(rImport),
m_rParagraphStyles(rParagraphStyles),
m_rTextStyles(rTextStyles),
m_rCellStyles(rCellStyles),
m_rColumnStyles(rColumnStyles),
- m_rRowStyles(rRowStyles)
+ m_rRowStyles(rRowStyles),
+ m_rTableStyles(rTableStyles)
{
}
@@ -65,6 +67,11 @@ std::map<OUString, librevenge::RVNGPropertyList> &XMLStylesContext::GetCurrentRo
return m_rRowStyles;
}
+std::map<OUString, librevenge::RVNGPropertyList> &XMLStylesContext::GetCurrentTableStyles()
+{
+ return m_rTableStyles;
+}
+
} // namespace exp
} // namespace writerperfect
diff --git a/writerperfect/source/writer/exp/xmlfmt.hxx b/writerperfect/source/writer/exp/xmlfmt.hxx
index 7ab31d1c7e97..74d4b20d84f0 100644
--- a/writerperfect/source/writer/exp/xmlfmt.hxx
+++ b/writerperfect/source/writer/exp/xmlfmt.hxx
@@ -29,7 +29,8 @@ public:
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> &rRowStyles,
+ std::map<OUString, librevenge::RVNGPropertyList> &rTableStyles);
rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
@@ -38,12 +39,14 @@ public:
std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentCellStyles();
std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentColumnStyles();
std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentRowStyles();
+ std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentTableStyles();
private:
std::map<OUString, librevenge::RVNGPropertyList> &m_rParagraphStyles;
std::map<OUString, librevenge::RVNGPropertyList> &m_rTextStyles;
std::map<OUString, librevenge::RVNGPropertyList> &m_rCellStyles;
std::map<OUString, librevenge::RVNGPropertyList> &m_rColumnStyles;
std::map<OUString, librevenge::RVNGPropertyList> &m_rRowStyles;
+ std::map<OUString, librevenge::RVNGPropertyList> &m_rTableStyles;
};
} // namespace exp
diff --git a/writerperfect/source/writer/exp/xmlimp.cxx b/writerperfect/source/writer/exp/xmlimp.cxx
index 806c3eaa35d0..0f6582ff7403 100644
--- a/writerperfect/source/writer/exp/xmlimp.cxx
+++ b/writerperfect/source/writer/exp/xmlimp.cxx
@@ -67,13 +67,15 @@ rtl::Reference<XMLImportContext> XMLOfficeDocContext::CreateChildContext(const O
mrImport.GetAutomaticTextStyles(),
mrImport.GetAutomaticCellStyles(),
mrImport.GetAutomaticColumnStyles(),
- mrImport.GetAutomaticRowStyles());
+ mrImport.GetAutomaticRowStyles(),
+ mrImport.GetAutomaticTableStyles());
else if (rName == "office:styles")
return new XMLStylesContext(mrImport, mrImport.GetParagraphStyles(),
mrImport.GetTextStyles(),
mrImport.GetCellStyles(),
mrImport.GetColumnStyles(),
- mrImport.GetRowStyles());
+ mrImport.GetRowStyles(),
+ mrImport.GetTableStyles());
return nullptr;
}
@@ -119,6 +121,11 @@ std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetAutomaticRowStyl
return maAutomaticRowStyles;
}
+std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetAutomaticTableStyles()
+{
+ return maAutomaticTableStyles;
+}
+
std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetTextStyles()
{
return maTextStyles;
@@ -144,6 +151,11 @@ std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetRowStyles()
return maRowStyles;
}
+std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetTableStyles()
+{
+ return maTableStyles;
+}
+
void XMLImport::startDocument()
{
mrGenerator.startDocument(librevenge::RVNGPropertyList());
diff --git a/writerperfect/source/writer/exp/xmlimp.hxx b/writerperfect/source/writer/exp/xmlimp.hxx
index a2efde2e10c7..7f690d86a165 100644
--- a/writerperfect/source/writer/exp/xmlimp.hxx
+++ b/writerperfect/source/writer/exp/xmlimp.hxx
@@ -45,6 +45,8 @@ class XMLImport : public cppu::WeakImplHelper
std::map<OUString, librevenge::RVNGPropertyList> maColumnStyles;
std::map<OUString, librevenge::RVNGPropertyList> maAutomaticRowStyles;
std::map<OUString, librevenge::RVNGPropertyList> maRowStyles;
+ std::map<OUString, librevenge::RVNGPropertyList> maAutomaticTableStyles;
+ std::map<OUString, librevenge::RVNGPropertyList> maTableStyles;
public:
XMLImport(librevenge::RVNGTextInterface &rGenerator);
@@ -57,11 +59,13 @@ public:
std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticCellStyles();
std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticColumnStyles();
std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticRowStyles();
+ std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticTableStyles();
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();
// XDocumentHandler
void SAL_CALL startDocument() override;
diff --git a/writerperfect/source/writer/exp/xmltbli.cxx b/writerperfect/source/writer/exp/xmltbli.cxx
index 19ea15d502a8..bec52dab0f22 100644
--- a/writerperfect/source/writer/exp/xmltbli.cxx
+++ b/writerperfect/source/writer/exp/xmltbli.cxx
@@ -183,10 +183,9 @@ rtl::Reference<XMLImportContext> XMLTableContext::CreateChildContext(const OUStr
if (!m_bTableOpened)
{
- librevenge::RVNGPropertyList aPropertyList;
if (!m_aColumns.empty())
- aPropertyList.insert("librevenge:table-columns", m_aColumns);
- mrImport.GetGenerator().openTable(aPropertyList);
+ m_aPropertyList.insert("librevenge:table-columns", m_aColumns);
+ mrImport.GetGenerator().openTable(m_aPropertyList);
m_bTableOpened = true;
}
@@ -198,6 +197,24 @@ rtl::Reference<XMLImportContext> XMLTableContext::CreateChildContext(const OUStr
return nullptr;
}
+void XMLTableContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs)
+{
+ for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i)
+ {
+ const OUString &rAttributeName = xAttribs->getNameByIndex(i);
+ const OUString &rAttributeValue = xAttribs->getValueByIndex(i);
+
+ if (rAttributeName == "table:style-name")
+ FillStyles(rAttributeValue, mrImport.GetAutomaticTableStyles(), mrImport.GetTableStyles(), m_aPropertyList);
+ else
+ {
+ OString sName = OUStringToOString(rAttributeName, RTL_TEXTENCODING_UTF8);
+ OString sValue = OUStringToOString(rAttributeValue, RTL_TEXTENCODING_UTF8);
+ m_aPropertyList.insert(sName.getStr(), sValue.getStr());
+ }
+ }
+}
+
void XMLTableContext::endElement(const OUString &/*rName*/)
{
mrImport.GetGenerator().closeTable();
diff --git a/writerperfect/source/writer/exp/xmltbli.hxx b/writerperfect/source/writer/exp/xmltbli.hxx
index c3671b433dab..01228ea9cdfe 100644
--- a/writerperfect/source/writer/exp/xmltbli.hxx
+++ b/writerperfect/source/writer/exp/xmltbli.hxx
@@ -25,10 +25,12 @@ public:
rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
+ void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
void SAL_CALL endElement(const OUString &rName) override;
private:
bool m_bTableOpened = false;
+ librevenge::RVNGPropertyList m_aPropertyList;
librevenge::RVNGPropertyListVector m_aColumns;
};