summaryrefslogtreecommitdiff
path: root/writerperfect/source/writer/exp/xmltbli.cxx
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/source/writer/exp/xmltbli.cxx
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/source/writer/exp/xmltbli.cxx')
-rw-r--r--writerperfect/source/writer/exp/xmltbli.cxx94
1 files changed, 83 insertions, 11 deletions
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*/)