summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorPierre-Eric Pelloux-Prayer <pierre-eric@lanedo.com>2012-12-20 17:09:24 +0100
committerMiklos Vajna <vmiklos@suse.cz>2013-03-04 13:18:53 +0100
commitba660eb85665b1893c86217daf1dad78d68ba192 (patch)
tree2e5a3a8289cbea0d816c220d3a660480160eca86 /sw
parent23b67c536537c91020cf5a45ab5cb36d7316ed89 (diff)
docx import: table styles and rPr/pPr tags unit test
When importing table style from docx, ignore sz tag when not inside a tblStylePr element. I did not find any reason for this in WordProcessingML documentation, but Office seems to be doing so. This change includes the unit test. Change-Id: I2a6c27e458e02eb6cd39defe65a415792adc6393
Diffstat (limited to 'sw')
-rwxr-xr-xsw/qa/extras/ooxmlexport/data/table-style-rPr-sz.docxbin0 -> 10771 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx24
2 files changed, 24 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/table-style-rPr-sz.docx b/sw/qa/extras/ooxmlexport/data/table-style-rPr-sz.docx
new file mode 100755
index 000000000000..6b6f69424726
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/table-style-rPr-sz.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 433160fd4a07..c95a99ff5ff3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -39,6 +39,9 @@
#include <com/sun/star/table/BorderLine2.hpp>
#include <com/sun/star/table/ShadowFormat.hpp>
#include <com/sun/star/text/XPageCursor.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
#include <unotools/tempfile.hxx>
#include <unotools/ucbstreamhelper.hxx>
@@ -80,6 +83,7 @@ public:
void testTextFrameBorders();
void testTextframeGradient();
void testCellBtlr();
+ void testTableStylerPrSz();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -123,6 +127,7 @@ void Test::run()
{"textframe-borders.docx", &Test::testTextFrameBorders},
{"textframe-gradient.docx", &Test::testTextframeGradient},
{"cell-btlr.docx", &Test::testCellBtlr},
+ {"table-style-rPr-sz.docx", &Test::testTableStylerPrSz},
};
// Don't test the first import of these, for some reason those tests fail
const char* aBlacklist[] = {
@@ -626,6 +631,25 @@ void Test::testCellBtlr()
CPPUNIT_ASSERT_EQUAL(OUString("btLr"), aValue);
}
+void Test::testTableStylerPrSz()
+{
+ // Verify that font size inside the table is 20pt, despite the sz attribute in the table size.
+ // Also check that other rPr attribute are used: italic, bold, underline
+ // Office has the same behavior
+ uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
+ uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
+ uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
+
+ CPPUNIT_ASSERT_EQUAL(20.f, getProperty<float>(getRun(xPara, 1), "CharHeight"));
+ CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::SINGLE, getProperty<short>(getRun(xPara, 1), "CharUnderline"));
+ CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(getRun(xPara, 1), "CharWeight"));
+ CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, getProperty<awt::FontSlant>(getRun(xPara, 1), "CharPosture"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();