summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Deller <luke@deller.id.au>2014-03-26 21:58:19 +1100
committerMichael Stahl <mstahl@redhat.com>2014-03-27 16:57:59 +0000
commit92ad689bcb3ad16bd35302e6ff4ee45b872c05a0 (patch)
treea01bf2ff47dce29c555fe069e5de76f4ecb6d4b9
parente0791969c8913f7719f59cf57983f5388a311cc6 (diff)
Unit test for .doc import of full colour borders
This test exercises the import component of commit ad51d4952dc30e0d1cdcc6037556cd7c66a61542 which adds support for full colour borders in .doc import/export. Also this test showed that page border import was not actually covered by ad51d4952dc30e0d1cdcc6037556cd7c66a61542, so that omission is fixed here. Change-Id: I6272e9b22415b5af012145e99360c5765d5aec60 Reviewed-on: https://gerrit.libreoffice.org/8759 Tested-by: Michael Stahl <mstahl@redhat.com> Reviewed-by: Michael Stahl <mstahl@redhat.com>
-rwxr-xr-xsw/qa/extras/ww8import/data/bordercolours.docbin0 -> 29696 bytes
-rw-r--r--sw/qa/extras/ww8import/ww8import.cxx116
-rw-r--r--sw/source/filter/ww8/ww8par6.cxx22
3 files changed, 132 insertions, 6 deletions
diff --git a/sw/qa/extras/ww8import/data/bordercolours.doc b/sw/qa/extras/ww8import/data/bordercolours.doc
new file mode 100755
index 000000000000..c442223ead3b
--- /dev/null
+++ b/sw/qa/extras/ww8import/data/bordercolours.doc
Binary files differ
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index 17296e4ca5ec..861a960ee78f 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -12,6 +12,7 @@
#include <com/sun/star/table/BorderLine2.hpp>
#include <com/sun/star/table/TableBorder.hpp>
+#include <com/sun/star/table/TableBorder2.hpp>
#include <com/sun/star/text/XDependentTextField.hpp>
#include <com/sun/star/text/XTextFramesSupplier.hpp>
#include <com/sun/star/text/XTextTablesSupplier.hpp>
@@ -256,6 +257,121 @@ DECLARE_WW8IMPORT_TEST(testCp1000039, "cp1000039.doc")
CPPUNIT_ASSERT_EQUAL(sal_Int16(RTL_TEXTENCODING_DONTKNOW), getProperty<sal_Int16>(getRun(getParagraph(1), 1), "CharFontCharSet"));
}
+DECLARE_WW8IMPORT_TEST(testBorderColours, "bordercolours.doc")
+{
+ // 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);
+ CPPUNIT_ASSERT_EQUAL(expectedBottom.Color, tableBorder.BottomLine.Color);
+
+ // 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");
+ CPPUNIT_ASSERT_BORDER_EQUAL(expectedBottom, border);
+
+ 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 imported 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
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 4923053da591..a9f95705289c 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -1223,15 +1223,25 @@ static sal_uInt8 lcl_ReadBorders(bool bVer67, WW8_BRCVer9* brc, WW8PLCFx_Cp_FKP*
{
if( !bVer67 )
{
- sal_uInt8* pSprm[4];
+ sal_uInt8* pSprm[4];
- // sprmSBrcTop, sprmSBrcLeft, sprmSBrcBottom, sprmSBrcRight
- if( pSep->Find4Sprms( 0x702B, 0x702C, 0x702D, 0x702E,
- pSprm[0], pSprm[1], pSprm[2], pSprm[3] ) )
- {
+ if( pSep->Find4Sprms(
+ NS_sprm::LN_SBrcTop, NS_sprm::LN_SBrcLeft,
+ NS_sprm::LN_SBrcBottom, NS_sprm::LN_SBrcRight,
+ pSprm[0], pSprm[1], pSprm[2], pSprm[3] ) )
+ {
for( int i = 0; i < 4; ++i )
nBorder |= int(_SetWW8_BRC( 8, brc[ i ], pSprm[ i ] ))<<i;
- }
+ }
+ // Version 9 BRCs if present will override version 8
+ if( pSep->Find4Sprms(
+ NS_sprm::LN_SBorderTop, NS_sprm::LN_SBorderLeft,
+ NS_sprm::LN_SBorderBottom, NS_sprm::LN_SBorderRight,
+ pSprm[0], pSprm[1], pSprm[2], pSprm[3] ) )
+ {
+ for( int i = 0; i < 4; ++i )
+ nBorder |= int(_SetWW8_BRC( 9, brc[ i ], pSprm[ i ] ))<<i;
+ }
}
}
else