Kaydet (Commit) ba660eb8 authored tarafından Pierre-Eric Pelloux-Prayer's avatar Pierre-Eric Pelloux-Prayer Kaydeden (comit) Miklos Vajna

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
üst 23b67c53
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment