summaryrefslogtreecommitdiff
path: root/writerperfect
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-11-24 09:12:26 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-11-24 11:15:01 +0100
commitaf72d1b9d1745944cd7842905d2d8ac3f8d1d640 (patch)
tree69e196755befcc0b4ff3e5605ddbe0d99f46a794 /writerperfect
parentde523ce9b834b2d8f29409fe21d68b81ef314fe5 (diff)
EPUB export: handle cell width
By handling relative column widths in libepubgen (since LO may only know that one, when layout is not available) and parsing column properties in writerperfect. Change-Id: I8fae5f1a3c970b97c2b452f3c20eff0911a56ba8 Reviewed-on: https://gerrit.libreoffice.org/45202 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerperfect')
-rw-r--r--writerperfect/qa/unit/EPUBExportTest.cxx27
-rw-r--r--writerperfect/qa/unit/data/writer/epubexport/table-cell-width.fodt45
-rw-r--r--writerperfect/source/writer/exp/txtstyli.cxx37
-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.cxx94
-rw-r--r--writerperfect/source/writer/exp/xmltbli.hxx4
10 files changed, 228 insertions, 17 deletions
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx
index 31ad665a62a0..411aed3eac6b 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.
- void parseCssStyle(const OUString &rStyle, std::map<OUString, OUString> &rCss);
+ static void parseCssStyle(const OUString &rStyle, std::map<OUString, OUString> &rCss);
void testOutlineLevel();
void testMimetype();
void testEPUB2();
@@ -76,6 +76,7 @@ public:
void testTable();
void testTableRowSpan();
void testTableCellBorder();
+ void testTableCellWidth();
void testLink();
void testLinkCharFormat();
void testLinkNamedCharFormat();
@@ -101,6 +102,7 @@ public:
CPPUNIT_TEST(testTable);
CPPUNIT_TEST(testTableRowSpan);
CPPUNIT_TEST(testTableCellBorder);
+ CPPUNIT_TEST(testTableCellWidth);
CPPUNIT_TEST(testLink);
CPPUNIT_TEST(testLinkCharFormat);
CPPUNIT_TEST(testLinkNamedCharFormat);
@@ -500,6 +502,29 @@ void EPUBExportTest::testTableCellBorder()
CPPUNIT_ASSERT_EQUAL(OUString("0.05pt solid #000000"), aCss["border-left"]);
}
+namespace
+{
+double getCellWidth(const OUString &rStyle)
+{
+ std::map<OUString, OUString> aCss;
+ EPUBExportTest::parseCssStyle(rStyle, aCss);
+ return aCss["width"].toDouble();
+}
+}
+
+void EPUBExportTest::testTableCellWidth()
+{
+ createDoc("table-cell-width.fodt", {});
+
+ mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
+ OUString aStyle1 = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[1]", "style");
+ OUString aStyle2 = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[2]", "style");
+ OUString aStyle3 = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]/xhtml:td[3]", "style");
+ // These failed, all widths were 0.
+ CPPUNIT_ASSERT_GREATER(getCellWidth(aStyle2), getCellWidth(aStyle1));
+ CPPUNIT_ASSERT_GREATER(getCellWidth(aStyle3), getCellWidth(aStyle1));
+}
+
void EPUBExportTest::testLink()
{
createDoc("link.fodt", {});
diff --git a/writerperfect/qa/unit/data/writer/epubexport/table-cell-width.fodt b/writerperfect/qa/unit/data/writer/epubexport/table-cell-width.fodt
new file mode 100644
index 000000000000..345550928256
--- /dev/null
+++ b/writerperfect/qa/unit/data/writer/epubexport/table-cell-width.fodt
@@ -0,0 +1,45 @@
+<?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="17.59cm" table:align="margins" style:shadow="none"/>
+ </style:style>
+ <style:style style:name="Table1.A" style:family="table-column">
+ <style:table-column-properties style:column-width="8.999cm" style:rel-column-width="5102*"/>
+ </style:style>
+ <style:style style:name="Table1.B" style:family="table-column">
+ <style:table-column-properties style:column-width="4.191cm" style:rel-column-width="2376*"/>
+ </style:style>
+ <style:style style:name="Table1.C" style:family="table-column">
+ <style:table-column-properties style:column-width="4.399cm" style:rel-column-width="2494*"/>
+ </style:style>
+ <style:style style:name="Table1.A1" style:family="table-cell">
+ <style:table-cell-properties fo:padding="0.097cm" fo:border-left="1pt solid #000000" fo:border-right="none" fo:border-top="1pt solid #000000" fo:border-bottom="1pt solid #000000"/>
+ </style:style>
+ <style:style style:name="Table1.C1" style:family="table-cell">
+ <style:table-cell-properties fo:padding="0.097cm" fo:border="1pt 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-column table:style-name="Table1.B"/>
+ <table:table-column table:style-name="Table1.C"/>
+ <table:table-row>
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p>A1, this is wider</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p>B1, than this</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table1.C1" office:value-type="string">
+ <text:p>C1, or this</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 a6f04e20c39e..15889877e883 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:table-column-properties>.
+class XMLTableColumnPropertiesContext : public XMLImportContext
+{
+public:
+ XMLTableColumnPropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle);
+
+ void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
+
+private:
+ XMLStyleContext &mrStyle;
+};
+
+XMLTableColumnPropertiesContext::XMLTableColumnPropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle)
+ : XMLImportContext(rImport)
+ , mrStyle(rStyle)
+{
+}
+
+void XMLTableColumnPropertiesContext::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.GetColumnPropertyList().insert(sName.getStr(), sValue.getStr());
+ }
+}
+
/// Handler for <style:table-cell-properties>.
class XMLTableCellPropertiesContext : public XMLImportContext
{
@@ -117,6 +145,8 @@ rtl::Reference<XMLImportContext> XMLStyleContext::CreateChildContext(const OUStr
return new XMLTextPropertiesContext(mrImport, *this);
if (rName == "style:table-cell-properties")
return new XMLTableCellPropertiesContext(mrImport, *this);
+ if (rName == "style:table-column-properties")
+ return new XMLTableColumnPropertiesContext(mrImport, *this);
return nullptr;
}
@@ -150,6 +180,8 @@ void XMLStyleContext::endElement(const OUString &/*rName*/)
m_rStyles.GetCurrentParagraphStyles()[m_aName] = m_aParagraphPropertyList;
if (m_aFamily == "table-cell")
m_rStyles.GetCurrentCellStyles()[m_aName] = m_aCellPropertyList;
+ if (m_aFamily == "table-column")
+ m_rStyles.GetCurrentColumnStyles()[m_aName] = m_aColumnPropertyList;
}
librevenge::RVNGPropertyList &XMLStyleContext::GetTextPropertyList()
@@ -167,6 +199,11 @@ librevenge::RVNGPropertyList &XMLStyleContext::GetCellPropertyList()
return m_aCellPropertyList;
}
+librevenge::RVNGPropertyList &XMLStyleContext::GetColumnPropertyList()
+{
+ return m_aColumnPropertyList;
+}
+
} // namespace exp
} // namespace writerperfect
diff --git a/writerperfect/source/writer/exp/txtstyli.hxx b/writerperfect/source/writer/exp/txtstyli.hxx
index 8550cb66d879..1321beae9385 100644
--- a/writerperfect/source/writer/exp/txtstyli.hxx
+++ b/writerperfect/source/writer/exp/txtstyli.hxx
@@ -34,6 +34,7 @@ public:
librevenge::RVNGPropertyList &GetTextPropertyList();
librevenge::RVNGPropertyList &GetParagraphPropertyList();
librevenge::RVNGPropertyList &GetCellPropertyList();
+ librevenge::RVNGPropertyList &GetColumnPropertyList();
private:
OUString m_aName;
@@ -41,6 +42,7 @@ private:
librevenge::RVNGPropertyList m_aTextPropertyList;
librevenge::RVNGPropertyList m_aParagraphPropertyList;
librevenge::RVNGPropertyList m_aCellPropertyList;
+ librevenge::RVNGPropertyList m_aColumnPropertyList;
XMLStylesContext &m_rStyles;
};
diff --git a/writerperfect/source/writer/exp/xmlfmt.cxx b/writerperfect/source/writer/exp/xmlfmt.cxx
index 52698fec8740..c3854e5323c4 100644
--- a/writerperfect/source/writer/exp/xmlfmt.cxx
+++ b/writerperfect/source/writer/exp/xmlfmt.cxx
@@ -21,11 +21,13 @@ 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> &rCellStyles,
+ std::map<OUString, librevenge::RVNGPropertyList> &rColumnStyles)
: XMLImportContext(rImport),
m_rParagraphStyles(rParagraphStyles),
m_rTextStyles(rTextStyles),
- m_rCellStyles(rCellStyles)
+ m_rCellStyles(rCellStyles),
+ m_rColumnStyles(rColumnStyles)
{
}
@@ -51,6 +53,11 @@ std::map<OUString, librevenge::RVNGPropertyList> &XMLStylesContext::GetCurrentCe
return m_rCellStyles;
}
+std::map<OUString, librevenge::RVNGPropertyList> &XMLStylesContext::GetCurrentColumnStyles()
+{
+ return m_rColumnStyles;
+}
+
} // namespace exp
} // namespace writerperfect
diff --git a/writerperfect/source/writer/exp/xmlfmt.hxx b/writerperfect/source/writer/exp/xmlfmt.hxx
index cd89121b7dd5..5d575fa065d5 100644
--- a/writerperfect/source/writer/exp/xmlfmt.hxx
+++ b/writerperfect/source/writer/exp/xmlfmt.hxx
@@ -27,17 +27,20 @@ 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> &rCellStyles,
+ std::map<OUString, librevenge::RVNGPropertyList> &rColumnStyles);
rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentParagraphStyles();
std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentTextStyles();
std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentCellStyles();
+ std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentColumnStyles();
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;
};
} // namespace exp
diff --git a/writerperfect/source/writer/exp/xmlimp.cxx b/writerperfect/source/writer/exp/xmlimp.cxx
index 67b4fd713149..20e20e76f870 100644
--- a/writerperfect/source/writer/exp/xmlimp.cxx
+++ b/writerperfect/source/writer/exp/xmlimp.cxx
@@ -65,11 +65,13 @@ rtl::Reference<XMLImportContext> XMLOfficeDocContext::CreateChildContext(const O
else if (rName == "office:automatic-styles")
return new XMLStylesContext(mrImport, mrImport.GetAutomaticParagraphStyles(),
mrImport.GetAutomaticTextStyles(),
- mrImport.GetAutomaticCellStyles());
+ mrImport.GetAutomaticCellStyles(),
+ mrImport.GetAutomaticColumnStyles());
else if (rName == "office:styles")
return new XMLStylesContext(mrImport, mrImport.GetParagraphStyles(),
mrImport.GetTextStyles(),
- mrImport.GetCellStyles());
+ mrImport.GetCellStyles(),
+ mrImport.GetColumnStyles());
return nullptr;
}
@@ -105,6 +107,11 @@ std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetAutomaticCellSty
return maAutomaticCellStyles;
}
+std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetAutomaticColumnStyles()
+{
+ return maAutomaticColumnStyles;
+}
+
std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetTextStyles()
{
return maTextStyles;
@@ -120,6 +127,11 @@ std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetCellStyles()
return maCellStyles;
}
+std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetColumnStyles()
+{
+ return maColumnStyles;
+}
+
void XMLImport::startDocument()
{
mrGenerator.startDocument(librevenge::RVNGPropertyList());
diff --git a/writerperfect/source/writer/exp/xmlimp.hxx b/writerperfect/source/writer/exp/xmlimp.hxx
index 2540e4db8d22..8b833b1f7054 100644
--- a/writerperfect/source/writer/exp/xmlimp.hxx
+++ b/writerperfect/source/writer/exp/xmlimp.hxx
@@ -41,6 +41,8 @@ class XMLImport : public cppu::WeakImplHelper
std::map<OUString, librevenge::RVNGPropertyList> maParagraphStyles;
std::map<OUString, librevenge::RVNGPropertyList> maAutomaticCellStyles;
std::map<OUString, librevenge::RVNGPropertyList> maCellStyles;
+ std::map<OUString, librevenge::RVNGPropertyList> maAutomaticColumnStyles;
+ std::map<OUString, librevenge::RVNGPropertyList> maColumnStyles;
public:
XMLImport(librevenge::RVNGTextInterface &rGenerator);
@@ -51,9 +53,11 @@ public:
std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticTextStyles();
std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticParagraphStyles();
std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticCellStyles();
+ std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticColumnStyles();
std::map<OUString, librevenge::RVNGPropertyList> &GetTextStyles();
std::map<OUString, librevenge::RVNGPropertyList> &GetParagraphStyles();
std::map<OUString, librevenge::RVNGPropertyList> &GetCellStyles();
+ std::map<OUString, librevenge::RVNGPropertyList> &GetColumnStyles();
// XDocumentHandler
void SAL_CALL startDocument() override;
diff --git a/writerperfect/source/writer/exp/xmltbli.cxx b/writerperfect/source/writer/exp/xmltbli.cxx
index 15444bc33e0b..c698c9d1ce9c 100644
--- a/writerperfect/source/writer/exp/xmltbli.cxx
+++ b/writerperfect/source/writer/exp/xmltbli.cxx
@@ -20,20 +20,41 @@ namespace writerperfect
namespace exp
{
+/// Handler for <table:table-row>.
+class XMLTableRowContext : public XMLImportContext
+{
+public:
+ XMLTableRowContext(XMLImport &rImport);
+
+ rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
+ int GetColumn() const;
+ void SetColumn(int nColumn);
+
+ 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:
+ int m_nColumn = 0;
+};
+
/// Handler for <table:cell>.
class XMLTableCellContext : public XMLImportContext
{
public:
- XMLTableCellContext(XMLImport &rImport);
+ XMLTableCellContext(XMLImport &rImport, XMLTableRowContext &rRow);
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:
+ XMLTableRowContext &m_rRow;
};
-XMLTableCellContext::XMLTableCellContext(XMLImport &rImport)
- : XMLImportContext(rImport)
+XMLTableCellContext::XMLTableCellContext(XMLImport &rImport, XMLTableRowContext &rRow)
+ : XMLImportContext(rImport),
+ m_rRow(rRow)
{
}
@@ -59,7 +80,9 @@ void XMLTableCellContext::startElement(const OUString &/*rName*/, const css::uno
aPropertyList.insert(sName.getStr(), sValue.getStr());
}
}
+ aPropertyList.insert("librevenge:column", m_rRow.GetColumn());
mrImport.GetGenerator().openTableCell(aPropertyList);
+ m_rRow.SetColumn(m_rRow.GetColumn() + 1);
}
void XMLTableCellContext::endElement(const OUString &/*rName*/)
@@ -67,18 +90,38 @@ void XMLTableCellContext::endElement(const OUString &/*rName*/)
mrImport.GetGenerator().closeTableCell();
}
-/// Handler for <table:row>.
-class XMLTableRowContext : public XMLImportContext
+/// Handler for <table:table-column>.
+class XMLTableColumnContext : public XMLImportContext
{
public:
- XMLTableRowContext(XMLImport &rImport);
-
- rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
+ XMLTableColumnContext(XMLImport &rImport, librevenge::RVNGPropertyListVector &rColumns);
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:
+ librevenge::RVNGPropertyListVector &m_rColumns;
};
+XMLTableColumnContext::XMLTableColumnContext(XMLImport &rImport, librevenge::RVNGPropertyListVector &rColumns)
+ : XMLImportContext(rImport),
+ m_rColumns(rColumns)
+{
+}
+
+void XMLTableColumnContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs)
+{
+ 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 == "table:style-name")
+ FillStyles(rAttributeValue, mrImport.GetAutomaticColumnStyles(), mrImport.GetColumnStyles(), aPropertyList);
+ }
+ m_rColumns.append(aPropertyList);
+}
+
XMLTableRowContext::XMLTableRowContext(XMLImport &rImport)
: XMLImportContext(rImport)
{
@@ -87,9 +130,12 @@ XMLTableRowContext::XMLTableRowContext(XMLImport &rImport)
rtl::Reference<XMLImportContext> XMLTableRowContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/)
{
if (rName == "table:table-cell")
- return new XMLTableCellContext(mrImport);
+ return new XMLTableCellContext(mrImport, *this);
if (rName == "table:covered-table-cell")
+ {
+ ++m_nColumn;
mrImport.GetGenerator().insertCoveredTableCell(librevenge::RVNGPropertyList());
+ }
else
SAL_WARN("writerperfect", "XMLTableRowContext::CreateChildContext: unhandled " << rName);
return nullptr;
@@ -105,6 +151,16 @@ void XMLTableRowContext::endElement(const OUString &/*rName*/)
mrImport.GetGenerator().closeTableRow();
}
+int XMLTableRowContext::GetColumn() const
+{
+ return m_nColumn;
+}
+
+void XMLTableRowContext::SetColumn(int nColumn)
+{
+ m_nColumn = nColumn;
+}
+
XMLTableContext::XMLTableContext(XMLImport &rImport)
: XMLImportContext(rImport)
{
@@ -112,14 +168,30 @@ XMLTableContext::XMLTableContext(XMLImport &rImport)
rtl::Reference<XMLImportContext> XMLTableContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/)
{
+ if (rName == "table:table-column")
+ // Make sure columns are parsed before we open the table.
+ return new XMLTableColumnContext(mrImport, m_aColumns);
+
+ if (!m_bTableOpened)
+ {
+ librevenge::RVNGPropertyList aPropertyList;
+ if (!m_aColumns.empty())
+ aPropertyList.insert("librevenge:table-columns", m_aColumns);
+ mrImport.GetGenerator().openTable(aPropertyList);
+ m_bTableOpened = true;
+ }
+
if (rName == "table:table-row")
return new XMLTableRowContext(mrImport);
+
+ SAL_WARN("writerperfect", "XMLTableContext::CreateChildContext: unhandled " << rName);
+
return nullptr;
}
void XMLTableContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/)
{
- mrImport.GetGenerator().openTable(librevenge::RVNGPropertyList());
+ m_bTableOpened = false;
}
void XMLTableContext::endElement(const OUString &/*rName*/)
diff --git a/writerperfect/source/writer/exp/xmltbli.hxx b/writerperfect/source/writer/exp/xmltbli.hxx
index 07ae0a647181..8f0d06092f06 100644
--- a/writerperfect/source/writer/exp/xmltbli.hxx
+++ b/writerperfect/source/writer/exp/xmltbli.hxx
@@ -27,6 +27,10 @@ public:
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::RVNGPropertyListVector m_aColumns;
};
} // namespace exp