Unit test for .doc export of full colour borders
This test exercises the *export* component of recent work to add support for full colour borders in .doc import/export. Change-Id: I2da0b8b488e399d0cd4791678fac6e1c85921c2c Reviewed-on: https://gerrit.libreoffice.org/8887 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
committed by
Caolán McNamara
parent
d8802562be
commit
19644e657d
BIN
sw/qa/extras/ww8export/data/bordercolours.odt
Normal file
BIN
sw/qa/extras/ww8export/data/bordercolours.odt
Normal file
Binary file not shown.
@@ -16,6 +16,7 @@
|
|||||||
#include <com/sun/star/beans/XPropertySet.hpp>
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
||||||
#include <com/sun/star/view/XViewSettingsSupplier.hpp>
|
#include <com/sun/star/view/XViewSettingsSupplier.hpp>
|
||||||
#include <com/sun/star/table/ShadowFormat.hpp>
|
#include <com/sun/star/table/ShadowFormat.hpp>
|
||||||
|
#include <com/sun/star/table/TableBorder2.hpp>
|
||||||
|
|
||||||
class Test : public SwModelTestBase
|
class Test : public SwModelTestBase
|
||||||
{
|
{
|
||||||
@@ -196,6 +197,130 @@ DECLARE_WW8EXPORT_TEST(testCommentsNested, "comments-nested.doc")
|
|||||||
CPPUNIT_ASSERT_EQUAL(OUString("Inner"), getProperty<OUString>(xInner, "Content"));
|
CPPUNIT_ASSERT_EQUAL(OUString("Inner"), getProperty<OUString>(xInner, "Content"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DECLARE_WW8EXPORT_TEST(testBorderColoursExport, "bordercolours.odt")
|
||||||
|
{
|
||||||
|
// This is very close to testBorderColours in ww8import.cxx, but for export
|
||||||
|
|
||||||
|
// The following 6 colours can only be represented with WW9 (Word 2000)
|
||||||
|
// BRC (BoRder Control) structures. We can tell that they have been
|
||||||
|
// exported/imported using a WW8 (Word '97) BRC if they instead come
|
||||||
|
// through as one of the 16 colours listed at this link:
|
||||||
|
// http://msdn.microsoft.com/en-us/library/dd773060.aspx
|
||||||
|
table::BorderLine2 expectedTop(0xFA670C, 0, 53, 0, 1, 53);
|
||||||
|
table::BorderLine2 expectedLeft(0xD99594, 0, 79, 0, 0, 79);
|
||||||
|
table::BorderLine2 expectedRight(0xB2A1C7, 53, 53, 53, 3, 159);
|
||||||
|
table::BorderLine2 expectedBottom(0xB6DDE8, 0, 106, 0, 14, 106);
|
||||||
|
table::BorderLine2 expectedDashedRed(0xFA670C, 0, 53, 0, 2, 53);
|
||||||
|
table::BorderLine2 expectedDoubleGreen(0xC2D69B, 26, 106, 26, 4, 159);
|
||||||
|
|
||||||
|
// Paragraph border
|
||||||
|
uno::Reference<text::XBookmarksSupplier> bookmarksSupplier(mxComponent,
|
||||||
|
uno::UNO_QUERY);
|
||||||
|
uno::Reference<container::XNameAccess> bookmarks(
|
||||||
|
bookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
|
||||||
|
uno::Reference<text::XTextContent> bookmark(
|
||||||
|
bookmarks->getByName("ParagraphBorder"), uno::UNO_QUERY);
|
||||||
|
uno::Reference<text::XTextRange> anchor(bookmark->getAnchor());
|
||||||
|
table::BorderLine2 border;
|
||||||
|
border = getProperty<table::BorderLine2>(anchor, "TopBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
|
||||||
|
border = getProperty<table::BorderLine2>(anchor, "LeftBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedLeft, border);
|
||||||
|
border = getProperty<table::BorderLine2>(anchor, "RightBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedRight, border);
|
||||||
|
border = getProperty<table::BorderLine2>(anchor, "BottomBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedBottom, border);
|
||||||
|
|
||||||
|
// Page border
|
||||||
|
OUString pageStyleName = getProperty<OUString>(anchor, "PageStyleName");
|
||||||
|
uno::Reference<style::XStyle> pageStyle(
|
||||||
|
getStyles("PageStyles")->getByName(pageStyleName), uno::UNO_QUERY);
|
||||||
|
border = getProperty<table::BorderLine2>(pageStyle, "TopBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
|
||||||
|
border = getProperty<table::BorderLine2>(pageStyle, "LeftBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedLeft, border);
|
||||||
|
border = getProperty<table::BorderLine2>(pageStyle, "RightBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedRight, border);
|
||||||
|
border = getProperty<table::BorderLine2>(pageStyle, "BottomBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedBottom, border);
|
||||||
|
|
||||||
|
// Character border
|
||||||
|
bookmark.set(bookmarks->getByName("CharBorder"), uno::UNO_QUERY);
|
||||||
|
anchor = bookmark->getAnchor();
|
||||||
|
border = getProperty<table::BorderLine2>(anchor, "CharTopBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
|
||||||
|
border = getProperty<table::BorderLine2>(anchor, "CharLeftBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
|
||||||
|
border = getProperty<table::BorderLine2>(anchor, "CharRightBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
|
||||||
|
border = getProperty<table::BorderLine2>(anchor, "CharBottomBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
|
||||||
|
|
||||||
|
// Table border
|
||||||
|
uno::Reference<text::XTextTablesSupplier> tablesSupplier(mxComponent,
|
||||||
|
uno::UNO_QUERY);
|
||||||
|
uno::Reference<container::XNameAccess> tables(
|
||||||
|
tablesSupplier->getTextTables(), uno::UNO_QUERY);
|
||||||
|
uno::Reference<text::XTextTable> table(
|
||||||
|
tables->getByName("Table1"), uno::UNO_QUERY);
|
||||||
|
table::TableBorder2 tableBorder = getProperty<table::TableBorder2>(
|
||||||
|
table, "TableBorder2");
|
||||||
|
CPPUNIT_ASSERT_EQUAL(expectedTop.Color, tableBorder.TopLine.Color);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(expectedLeft.Color, tableBorder.LeftLine.Color);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(expectedRight.Color, tableBorder.RightLine.Color);
|
||||||
|
#if 0
|
||||||
|
// #if'd out because the "fine dashed" border line style for table borders
|
||||||
|
// does not seem to save or load correctly in odt format at present
|
||||||
|
CPPUNIT_ASSERT_EQUAL(expectedBottom.Color, tableBorder.BottomLine.Color);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Table cells
|
||||||
|
uno::Reference<table::XCell> cell(
|
||||||
|
table->getCellByName("A2"), uno::UNO_QUERY);
|
||||||
|
border = getProperty<table::BorderLine2>(cell, "TopBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
|
||||||
|
border = getProperty<table::BorderLine2>(cell, "LeftBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedLeft, border);
|
||||||
|
border = getProperty<table::BorderLine2>(cell, "BottomBorder");
|
||||||
|
#if 0
|
||||||
|
// #if'd out because the "fine dashed" border line style for table borders
|
||||||
|
// does not seem to save or load correctly in odt format at present
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedBottom, border);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cell.set(table->getCellByName("B2"), uno::UNO_QUERY);
|
||||||
|
border = getProperty<table::BorderLine2>(cell, "TopBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedDoubleGreen, border);
|
||||||
|
border = getProperty<table::BorderLine2>(cell, "LeftBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedRight, border);
|
||||||
|
border = getProperty<table::BorderLine2>(cell, "BottomBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedDoubleGreen, border);
|
||||||
|
|
||||||
|
cell.set(table->getCellByName("C2"), uno::UNO_QUERY);
|
||||||
|
border = getProperty<table::BorderLine2>(cell, "TopBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedDoubleGreen, border);
|
||||||
|
border = getProperty<table::BorderLine2>(cell, "LeftBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedDashedRed, border);
|
||||||
|
border = getProperty<table::BorderLine2>(cell, "RightBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedRight, border);
|
||||||
|
border = getProperty<table::BorderLine2>(cell, "BottomBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedDoubleGreen, border);
|
||||||
|
|
||||||
|
// Picture border
|
||||||
|
// (#if'd out as they are not yet exported with correct colours)
|
||||||
|
#if 0
|
||||||
|
bookmark.set(bookmarks->getByName("PictureBorder"),uno::UNO_QUERY);
|
||||||
|
anchor = bookmark->getAnchor();
|
||||||
|
border = getProperty<table::BorderLine2>(anchor, "TopBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
|
||||||
|
border = getProperty<table::BorderLine2>(anchor, "LeftBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedLeft, border);
|
||||||
|
border = getProperty<table::BorderLine2>(anchor, "RightBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedRight, border);
|
||||||
|
border = getProperty<table::BorderLine2>(anchor, "BottomBorder");
|
||||||
|
CPPUNIT_ASSERT_BORDER_EQUAL(expectedBottom, border);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
Reference in New Issue
Block a user