summaryrefslogtreecommitdiff
path: root/writerperfect/qa
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/qa
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/qa')
-rw-r--r--writerperfect/qa/unit/EPUBExportTest.cxx27
-rw-r--r--writerperfect/qa/unit/data/writer/epubexport/table-cell-width.fodt45
2 files changed, 71 insertions, 1 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>