summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--writerperfect/qa/unit/EPUBExportTest.cxx20
-rw-r--r--writerperfect/qa/unit/data/writer/epubexport/table-row-height.fodt42
-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.cxx18
-rw-r--r--writerperfect/source/writer/exp/xmltbli.hxx1
10 files changed, 143 insertions, 13 deletions
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx
index 411aed3eac6b..49ef7297fa80 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -77,6 +77,7 @@ public:
void testTableRowSpan();
void testTableCellBorder();
void testTableCellWidth();
+ void testTableRowHeight();
void testLink();
void testLinkCharFormat();
void testLinkNamedCharFormat();
@@ -103,6 +104,7 @@ public:
CPPUNIT_TEST(testTableRowSpan);
CPPUNIT_TEST(testTableCellBorder);
CPPUNIT_TEST(testTableCellWidth);
+ CPPUNIT_TEST(testTableRowHeight);
CPPUNIT_TEST(testLink);
CPPUNIT_TEST(testLinkCharFormat);
CPPUNIT_TEST(testLinkNamedCharFormat);
@@ -510,6 +512,13 @@ double getCellWidth(const OUString &rStyle)
EPUBExportTest::parseCssStyle(rStyle, aCss);
return aCss["width"].toDouble();
}
+
+double getRowHeight(const OUString &rStyle)
+{
+ std::map<OUString, OUString> aCss;
+ EPUBExportTest::parseCssStyle(rStyle, aCss);
+ return aCss["height"].toDouble();
+}
}
void EPUBExportTest::testTableCellWidth()
@@ -525,6 +534,17 @@ void EPUBExportTest::testTableCellWidth()
CPPUNIT_ASSERT_GREATER(getCellWidth(aStyle3), getCellWidth(aStyle1));
}
+void EPUBExportTest::testTableRowHeight()
+{
+ createDoc("table-row-height.fodt", {});
+
+ mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
+ OUString aStyle1 = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[1]", "style");
+ OUString aStyle2 = getXPath(mpXmlDoc, "//xhtml:table/xhtml:tbody/xhtml:tr[2]", "style");
+ // These failed, both heights were 0.
+ CPPUNIT_ASSERT_GREATER(getRowHeight(aStyle2), getRowHeight(aStyle1));
+}
+
void EPUBExportTest::testLink()
{
createDoc("link.fodt", {});
diff --git a/writerperfect/qa/unit/data/writer/epubexport/table-row-height.fodt b/writerperfect/qa/unit/data/writer/epubexport/table-row-height.fodt
new file mode 100644
index 000000000000..28b06a4290da
--- /dev/null
+++ b/writerperfect/qa/unit/data/writer/epubexport/table-row-height.fodt
@@ -0,0 +1,42 @@
+<?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:style>
+ <style:style style:name="Table1.A" style:family="table-column">
+ <style:table-column-properties style:column-width="17.59cm" style:rel-column-width="65535*"/>
+ </style:style>
+ <style:style style:name="Table1.1" style:family="table-row">
+ <style:table-row-properties style:row-height="2cm"/>
+ </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>
+ <style:style style:name="Table1.2" style:family="table-row">
+ <style:table-row-properties style:row-height="1cm"/>
+ </style:style>
+ <style:style style:name="Table1.A2" style:family="table-cell">
+ <style:table-cell-properties fo:padding="0.097cm" fo:border-left="0.05pt solid #000000" fo:border-right="0.05pt solid #000000" fo:border-top="none" fo:border-bottom="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:style-name="Table1.1">
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p>This row has a larger height</text:p>
+ </table:table-cell>
+ </table:table-row>
+ <table:table-row table:style-name="Table1.2">
+ <table:table-cell table:style-name="Table1.A2" office:value-type="string">
+ <text:p>Than this one.</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 15889877e883..48f5f72beff8 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-row-properties>.
+class XMLTableRowPropertiesContext : public XMLImportContext
+{
+public:
+ XMLTableRowPropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle);
+
+ void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
+
+private:
+ XMLStyleContext &mrStyle;
+};
+
+XMLTableRowPropertiesContext::XMLTableRowPropertiesContext(XMLImport &rImport, XMLStyleContext &rStyle)
+ : XMLImportContext(rImport)
+ , mrStyle(rStyle)
+{
+}
+
+void XMLTableRowPropertiesContext::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.GetRowPropertyList().insert(sName.getStr(), sValue.getStr());
+ }
+}
+
/// Handler for <style:table-column-properties>.
class XMLTableColumnPropertiesContext : public XMLImportContext
{
@@ -147,6 +175,8 @@ rtl::Reference<XMLImportContext> XMLStyleContext::CreateChildContext(const OUStr
return new XMLTableCellPropertiesContext(mrImport, *this);
if (rName == "style:table-column-properties")
return new XMLTableColumnPropertiesContext(mrImport, *this);
+ if (rName == "style:table-row-properties")
+ return new XMLTableRowPropertiesContext(mrImport, *this);
return nullptr;
}
@@ -182,6 +212,8 @@ void XMLStyleContext::endElement(const OUString &/*rName*/)
m_rStyles.GetCurrentCellStyles()[m_aName] = m_aCellPropertyList;
if (m_aFamily == "table-column")
m_rStyles.GetCurrentColumnStyles()[m_aName] = m_aColumnPropertyList;
+ if (m_aFamily == "table-row")
+ m_rStyles.GetCurrentRowStyles()[m_aName] = m_aRowPropertyList;
}
librevenge::RVNGPropertyList &XMLStyleContext::GetTextPropertyList()
@@ -204,6 +236,11 @@ librevenge::RVNGPropertyList &XMLStyleContext::GetColumnPropertyList()
return m_aColumnPropertyList;
}
+librevenge::RVNGPropertyList &XMLStyleContext::GetRowPropertyList()
+{
+ return m_aRowPropertyList;
+}
+
} // namespace exp
} // namespace writerperfect
diff --git a/writerperfect/source/writer/exp/txtstyli.hxx b/writerperfect/source/writer/exp/txtstyli.hxx
index 1321beae9385..6d0e2c1828a8 100644
--- a/writerperfect/source/writer/exp/txtstyli.hxx
+++ b/writerperfect/source/writer/exp/txtstyli.hxx
@@ -35,6 +35,7 @@ public:
librevenge::RVNGPropertyList &GetParagraphPropertyList();
librevenge::RVNGPropertyList &GetCellPropertyList();
librevenge::RVNGPropertyList &GetColumnPropertyList();
+ librevenge::RVNGPropertyList &GetRowPropertyList();
private:
OUString m_aName;
@@ -43,6 +44,7 @@ private:
librevenge::RVNGPropertyList m_aParagraphPropertyList;
librevenge::RVNGPropertyList m_aCellPropertyList;
librevenge::RVNGPropertyList m_aColumnPropertyList;
+ librevenge::RVNGPropertyList m_aRowPropertyList;
XMLStylesContext &m_rStyles;
};
diff --git a/writerperfect/source/writer/exp/xmlfmt.cxx b/writerperfect/source/writer/exp/xmlfmt.cxx
index c3854e5323c4..2c73a9a8c968 100644
--- a/writerperfect/source/writer/exp/xmlfmt.cxx
+++ b/writerperfect/source/writer/exp/xmlfmt.cxx
@@ -22,12 +22,14 @@ 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> &rColumnStyles,
+ std::map<OUString, librevenge::RVNGPropertyList> &rRowStyles)
: XMLImportContext(rImport),
m_rParagraphStyles(rParagraphStyles),
m_rTextStyles(rTextStyles),
m_rCellStyles(rCellStyles),
- m_rColumnStyles(rColumnStyles)
+ m_rColumnStyles(rColumnStyles),
+ m_rRowStyles(rRowStyles)
{
}
@@ -58,6 +60,11 @@ std::map<OUString, librevenge::RVNGPropertyList> &XMLStylesContext::GetCurrentCo
return m_rColumnStyles;
}
+std::map<OUString, librevenge::RVNGPropertyList> &XMLStylesContext::GetCurrentRowStyles()
+{
+ return m_rRowStyles;
+}
+
} // namespace exp
} // namespace writerperfect
diff --git a/writerperfect/source/writer/exp/xmlfmt.hxx b/writerperfect/source/writer/exp/xmlfmt.hxx
index 5d575fa065d5..7ab31d1c7e97 100644
--- a/writerperfect/source/writer/exp/xmlfmt.hxx
+++ b/writerperfect/source/writer/exp/xmlfmt.hxx
@@ -28,7 +28,8 @@ 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> &rColumnStyles,
+ std::map<OUString, librevenge::RVNGPropertyList> &rRowStyles);
rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
@@ -36,11 +37,13 @@ public:
std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentTextStyles();
std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentCellStyles();
std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentColumnStyles();
+ std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentRowStyles();
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;
};
} // namespace exp
diff --git a/writerperfect/source/writer/exp/xmlimp.cxx b/writerperfect/source/writer/exp/xmlimp.cxx
index 20e20e76f870..806c3eaa35d0 100644
--- a/writerperfect/source/writer/exp/xmlimp.cxx
+++ b/writerperfect/source/writer/exp/xmlimp.cxx
@@ -66,12 +66,14 @@ rtl::Reference<XMLImportContext> XMLOfficeDocContext::CreateChildContext(const O
return new XMLStylesContext(mrImport, mrImport.GetAutomaticParagraphStyles(),
mrImport.GetAutomaticTextStyles(),
mrImport.GetAutomaticCellStyles(),
- mrImport.GetAutomaticColumnStyles());
+ mrImport.GetAutomaticColumnStyles(),
+ mrImport.GetAutomaticRowStyles());
else if (rName == "office:styles")
return new XMLStylesContext(mrImport, mrImport.GetParagraphStyles(),
mrImport.GetTextStyles(),
mrImport.GetCellStyles(),
- mrImport.GetColumnStyles());
+ mrImport.GetColumnStyles(),
+ mrImport.GetRowStyles());
return nullptr;
}
@@ -112,6 +114,11 @@ std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetAutomaticColumnS
return maAutomaticColumnStyles;
}
+std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetAutomaticRowStyles()
+{
+ return maAutomaticRowStyles;
+}
+
std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetTextStyles()
{
return maTextStyles;
@@ -132,6 +139,11 @@ std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetColumnStyles()
return maColumnStyles;
}
+std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetRowStyles()
+{
+ return maRowStyles;
+}
+
void XMLImport::startDocument()
{
mrGenerator.startDocument(librevenge::RVNGPropertyList());
diff --git a/writerperfect/source/writer/exp/xmlimp.hxx b/writerperfect/source/writer/exp/xmlimp.hxx
index 8b833b1f7054..a2efde2e10c7 100644
--- a/writerperfect/source/writer/exp/xmlimp.hxx
+++ b/writerperfect/source/writer/exp/xmlimp.hxx
@@ -43,6 +43,8 @@ class XMLImport : public cppu::WeakImplHelper
std::map<OUString, librevenge::RVNGPropertyList> maCellStyles;
std::map<OUString, librevenge::RVNGPropertyList> maAutomaticColumnStyles;
std::map<OUString, librevenge::RVNGPropertyList> maColumnStyles;
+ std::map<OUString, librevenge::RVNGPropertyList> maAutomaticRowStyles;
+ std::map<OUString, librevenge::RVNGPropertyList> maRowStyles;
public:
XMLImport(librevenge::RVNGTextInterface &rGenerator);
@@ -54,10 +56,12 @@ public:
std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticParagraphStyles();
std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticCellStyles();
std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticColumnStyles();
+ std::map<OUString, librevenge::RVNGPropertyList> &GetAutomaticRowStyles();
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();
// XDocumentHandler
void SAL_CALL startDocument() override;
diff --git a/writerperfect/source/writer/exp/xmltbli.cxx b/writerperfect/source/writer/exp/xmltbli.cxx
index c698c9d1ce9c..19ea15d502a8 100644
--- a/writerperfect/source/writer/exp/xmltbli.cxx
+++ b/writerperfect/source/writer/exp/xmltbli.cxx
@@ -141,9 +141,18 @@ rtl::Reference<XMLImportContext> XMLTableRowContext::CreateChildContext(const OU
return nullptr;
}
-void XMLTableRowContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/)
+void XMLTableRowContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs)
{
- mrImport.GetGenerator().openTableRow(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 == "table:style-name")
+ FillStyles(rAttributeValue, mrImport.GetAutomaticRowStyles(), mrImport.GetRowStyles(), aPropertyList);
+ }
+ mrImport.GetGenerator().openTableRow(aPropertyList);
}
void XMLTableRowContext::endElement(const OUString &/*rName*/)
@@ -189,11 +198,6 @@ rtl::Reference<XMLImportContext> XMLTableContext::CreateChildContext(const OUStr
return nullptr;
}
-void XMLTableContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/)
-{
- m_bTableOpened = false;
-}
-
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 8f0d06092f06..c3671b433dab 100644
--- a/writerperfect/source/writer/exp/xmltbli.hxx
+++ b/writerperfect/source/writer/exp/xmltbli.hxx
@@ -25,7 +25,6 @@ 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: