diff options
author | Justin Luth <justin_luth@sil.org> | 2016-10-11 16:19:28 +0300 |
---|---|---|
committer | Justin Luth <justin_luth@sil.org> | 2016-10-13 05:10:43 +0000 |
commit | a9afa89e953f0f32acf26b143717e7d067cbc75a (patch) | |
tree | 9bb4aaea34da4e53524448a1c7324eb77a364884 /sw/qa/extras | |
parent | 66b67f40a7785f08ae214e62b669e001148b474c (diff) |
move round-tripables to ww8export
This serves two purposes. It helps to prevent regressions
and it allows focus on features that still don't export properly.
Change-Id: I63ed43bccb2279f889474611ce436e85374e6bc5
Reviewed-on: https://gerrit.libreoffice.org/29704
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'sw/qa/extras')
-rw-r--r-- | sw/qa/extras/ww8export/data/all_gaps_word.doc (renamed from sw/qa/extras/ww8import/data/all_gaps_word.doc) | bin | 32256 -> 32256 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/bnc787942.doc (renamed from sw/qa/extras/ww8import/data/bnc787942.doc) | bin | 24064 -> 24064 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/bnc821208.doc (renamed from sw/qa/extras/ww8import/data/bnc821208.doc) | bin | 30208 -> 30208 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/bordercolours.doc (renamed from sw/qa/extras/ww8import/data/bordercolours.doc) | bin | 29696 -> 29696 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/cp1000039.doc (renamed from sw/qa/extras/ww8import/data/cp1000039.doc) | bin | 22016 -> 22016 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/cp1000044.doc (renamed from sw/qa/extras/ww8import/data/cp1000044.doc) | bin | 26112 -> 26112 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/fdo36868.doc (renamed from sw/qa/extras/ww8import/data/fdo36868.doc) | bin | 23552 -> 23552 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/fdo68963.doc (renamed from sw/qa/extras/ww8import/data/fdo68963.doc) | bin | 22528 -> 22528 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/fdo68967.doc (renamed from sw/qa/extras/ww8import/data/fdo68967.doc) | bin | 99328 -> 99328 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/fdo77844.doc (renamed from sw/qa/extras/ww8import/data/fdo77844.doc) | bin | 28672 -> 28672 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/fdo80333.doc (renamed from sw/qa/extras/ww8import/data/fdo80333.doc) | bin | 24064 -> 24064 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/fdo81102.doc (renamed from sw/qa/extras/ww8import/data/fdo81102.doc) | bin | 22528 -> 22528 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/i120158.doc (renamed from sw/qa/extras/ww8import/data/i120158.doc) | bin | 23040 -> 23040 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/list-nolevel.doc (renamed from sw/qa/extras/ww8import/data/list-nolevel.doc) | bin | 23040 -> 23040 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/msobrightnesscontrast.doc (renamed from sw/qa/extras/ww8import/data/msobrightnesscontrast.doc) | bin | 27648 -> 27648 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/n652364.doc (renamed from sw/qa/extras/ww8import/data/n652364.doc) | bin | 22016 -> 22016 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/n750255.doc (renamed from sw/qa/extras/ww8import/data/n750255.doc) | bin | 22016 -> 22016 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/n757118.doc (renamed from sw/qa/extras/ww8import/data/n757118.doc) | bin | 35840 -> 35840 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/n757905.doc (renamed from sw/qa/extras/ww8import/data/n757905.doc) | bin | 28160 -> 28160 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/n757910.doc (renamed from sw/qa/extras/ww8import/data/n757910.doc) | bin | 22528 -> 22528 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/n760294.doc (renamed from sw/qa/extras/ww8import/data/n760294.doc) | bin | 26112 -> 26112 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/n816603.doc (renamed from sw/qa/extras/ww8import/data/n816603.doc) | bin | 67072 -> 67072 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/n823651.doc (renamed from sw/qa/extras/ww8import/data/n823651.doc) | bin | 30720 -> 30720 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/page-border.doc (renamed from sw/qa/extras/ww8import/data/page-border.doc) | bin | 22016 -> 22016 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/tdf102334.doc (renamed from sw/qa/extras/ww8import/data/tdf102334.doc) | bin | 28672 -> 28672 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/tdf59896.doc (renamed from sw/qa/extras/ww8import/data/tdf59896.doc) | bin | 12288 -> 12288 bytes | |||
-rwxr-xr-x | sw/qa/extras/ww8export/data/tdf74328.doc (renamed from sw/qa/extras/ww8import/data/tdf74328.doc) | bin | 44032 -> 44032 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/tdf95321.doc (renamed from sw/qa/extras/ww8import/data/tdf95321.doc) | bin | 27648 -> 27648 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/tdf95576.doc (renamed from sw/qa/extras/ww8import/data/tdf95576.doc) | bin | 23040 -> 23040 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/tdf99100.doc (renamed from sw/qa/extras/ww8import/data/tdf99100.doc) | bin | 22528 -> 22528 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/ww8export.cxx | 543 | ||||
-rw-r--r-- | sw/qa/extras/ww8import/ww8import.cxx | 546 |
32 files changed, 544 insertions, 545 deletions
diff --git a/sw/qa/extras/ww8import/data/all_gaps_word.doc b/sw/qa/extras/ww8export/data/all_gaps_word.doc Binary files differindex d5c61a6c44d3..d5c61a6c44d3 100644 --- a/sw/qa/extras/ww8import/data/all_gaps_word.doc +++ b/sw/qa/extras/ww8export/data/all_gaps_word.doc diff --git a/sw/qa/extras/ww8import/data/bnc787942.doc b/sw/qa/extras/ww8export/data/bnc787942.doc Binary files differindex 06b2c39f2f84..06b2c39f2f84 100644 --- a/sw/qa/extras/ww8import/data/bnc787942.doc +++ b/sw/qa/extras/ww8export/data/bnc787942.doc diff --git a/sw/qa/extras/ww8import/data/bnc821208.doc b/sw/qa/extras/ww8export/data/bnc821208.doc Binary files differindex cfe76806ef80..cfe76806ef80 100644 --- a/sw/qa/extras/ww8import/data/bnc821208.doc +++ b/sw/qa/extras/ww8export/data/bnc821208.doc diff --git a/sw/qa/extras/ww8import/data/bordercolours.doc b/sw/qa/extras/ww8export/data/bordercolours.doc Binary files differindex c442223ead3b..c442223ead3b 100644 --- a/sw/qa/extras/ww8import/data/bordercolours.doc +++ b/sw/qa/extras/ww8export/data/bordercolours.doc diff --git a/sw/qa/extras/ww8import/data/cp1000039.doc b/sw/qa/extras/ww8export/data/cp1000039.doc Binary files differindex 70cad3c244b9..70cad3c244b9 100644 --- a/sw/qa/extras/ww8import/data/cp1000039.doc +++ b/sw/qa/extras/ww8export/data/cp1000039.doc diff --git a/sw/qa/extras/ww8import/data/cp1000044.doc b/sw/qa/extras/ww8export/data/cp1000044.doc Binary files differindex ea30cc0024ce..ea30cc0024ce 100644 --- a/sw/qa/extras/ww8import/data/cp1000044.doc +++ b/sw/qa/extras/ww8export/data/cp1000044.doc diff --git a/sw/qa/extras/ww8import/data/fdo36868.doc b/sw/qa/extras/ww8export/data/fdo36868.doc Binary files differindex 382c6b267d4c..382c6b267d4c 100644 --- a/sw/qa/extras/ww8import/data/fdo36868.doc +++ b/sw/qa/extras/ww8export/data/fdo36868.doc diff --git a/sw/qa/extras/ww8import/data/fdo68963.doc b/sw/qa/extras/ww8export/data/fdo68963.doc Binary files differindex b31741f7c545..b31741f7c545 100644 --- a/sw/qa/extras/ww8import/data/fdo68963.doc +++ b/sw/qa/extras/ww8export/data/fdo68963.doc diff --git a/sw/qa/extras/ww8import/data/fdo68967.doc b/sw/qa/extras/ww8export/data/fdo68967.doc Binary files differindex 05271c3d868a..05271c3d868a 100644 --- a/sw/qa/extras/ww8import/data/fdo68967.doc +++ b/sw/qa/extras/ww8export/data/fdo68967.doc diff --git a/sw/qa/extras/ww8import/data/fdo77844.doc b/sw/qa/extras/ww8export/data/fdo77844.doc Binary files differindex cd7368d5d654..cd7368d5d654 100644 --- a/sw/qa/extras/ww8import/data/fdo77844.doc +++ b/sw/qa/extras/ww8export/data/fdo77844.doc diff --git a/sw/qa/extras/ww8import/data/fdo80333.doc b/sw/qa/extras/ww8export/data/fdo80333.doc Binary files differindex 773a922bad08..773a922bad08 100644 --- a/sw/qa/extras/ww8import/data/fdo80333.doc +++ b/sw/qa/extras/ww8export/data/fdo80333.doc diff --git a/sw/qa/extras/ww8import/data/fdo81102.doc b/sw/qa/extras/ww8export/data/fdo81102.doc Binary files differindex e8a550768f01..e8a550768f01 100644 --- a/sw/qa/extras/ww8import/data/fdo81102.doc +++ b/sw/qa/extras/ww8export/data/fdo81102.doc diff --git a/sw/qa/extras/ww8import/data/i120158.doc b/sw/qa/extras/ww8export/data/i120158.doc Binary files differindex 6adf3ec13d52..6adf3ec13d52 100644 --- a/sw/qa/extras/ww8import/data/i120158.doc +++ b/sw/qa/extras/ww8export/data/i120158.doc diff --git a/sw/qa/extras/ww8import/data/list-nolevel.doc b/sw/qa/extras/ww8export/data/list-nolevel.doc Binary files differindex 04e34996fe39..04e34996fe39 100644 --- a/sw/qa/extras/ww8import/data/list-nolevel.doc +++ b/sw/qa/extras/ww8export/data/list-nolevel.doc diff --git a/sw/qa/extras/ww8import/data/msobrightnesscontrast.doc b/sw/qa/extras/ww8export/data/msobrightnesscontrast.doc Binary files differindex 675d6d3702e4..675d6d3702e4 100644 --- a/sw/qa/extras/ww8import/data/msobrightnesscontrast.doc +++ b/sw/qa/extras/ww8export/data/msobrightnesscontrast.doc diff --git a/sw/qa/extras/ww8import/data/n652364.doc b/sw/qa/extras/ww8export/data/n652364.doc Binary files differindex f7a0fe0d57d7..f7a0fe0d57d7 100644 --- a/sw/qa/extras/ww8import/data/n652364.doc +++ b/sw/qa/extras/ww8export/data/n652364.doc diff --git a/sw/qa/extras/ww8import/data/n750255.doc b/sw/qa/extras/ww8export/data/n750255.doc Binary files differindex c0475c4ede26..c0475c4ede26 100644 --- a/sw/qa/extras/ww8import/data/n750255.doc +++ b/sw/qa/extras/ww8export/data/n750255.doc diff --git a/sw/qa/extras/ww8import/data/n757118.doc b/sw/qa/extras/ww8export/data/n757118.doc Binary files differindex 2c69485212a1..2c69485212a1 100644 --- a/sw/qa/extras/ww8import/data/n757118.doc +++ b/sw/qa/extras/ww8export/data/n757118.doc diff --git a/sw/qa/extras/ww8import/data/n757905.doc b/sw/qa/extras/ww8export/data/n757905.doc Binary files differindex 0fb7b097cd00..0fb7b097cd00 100644 --- a/sw/qa/extras/ww8import/data/n757905.doc +++ b/sw/qa/extras/ww8export/data/n757905.doc diff --git a/sw/qa/extras/ww8import/data/n757910.doc b/sw/qa/extras/ww8export/data/n757910.doc Binary files differindex 49a0e59f8440..49a0e59f8440 100644 --- a/sw/qa/extras/ww8import/data/n757910.doc +++ b/sw/qa/extras/ww8export/data/n757910.doc diff --git a/sw/qa/extras/ww8import/data/n760294.doc b/sw/qa/extras/ww8export/data/n760294.doc Binary files differindex 04960d060b15..04960d060b15 100644 --- a/sw/qa/extras/ww8import/data/n760294.doc +++ b/sw/qa/extras/ww8export/data/n760294.doc diff --git a/sw/qa/extras/ww8import/data/n816603.doc b/sw/qa/extras/ww8export/data/n816603.doc Binary files differindex 9186f628ff06..9186f628ff06 100644 --- a/sw/qa/extras/ww8import/data/n816603.doc +++ b/sw/qa/extras/ww8export/data/n816603.doc diff --git a/sw/qa/extras/ww8import/data/n823651.doc b/sw/qa/extras/ww8export/data/n823651.doc Binary files differindex 51b383c42d5d..51b383c42d5d 100644 --- a/sw/qa/extras/ww8import/data/n823651.doc +++ b/sw/qa/extras/ww8export/data/n823651.doc diff --git a/sw/qa/extras/ww8import/data/page-border.doc b/sw/qa/extras/ww8export/data/page-border.doc Binary files differindex c2dec4fede22..c2dec4fede22 100644 --- a/sw/qa/extras/ww8import/data/page-border.doc +++ b/sw/qa/extras/ww8export/data/page-border.doc diff --git a/sw/qa/extras/ww8import/data/tdf102334.doc b/sw/qa/extras/ww8export/data/tdf102334.doc Binary files differindex d007257cfb79..d007257cfb79 100644 --- a/sw/qa/extras/ww8import/data/tdf102334.doc +++ b/sw/qa/extras/ww8export/data/tdf102334.doc diff --git a/sw/qa/extras/ww8import/data/tdf59896.doc b/sw/qa/extras/ww8export/data/tdf59896.doc Binary files differindex a3c7242992f0..a3c7242992f0 100644 --- a/sw/qa/extras/ww8import/data/tdf59896.doc +++ b/sw/qa/extras/ww8export/data/tdf59896.doc diff --git a/sw/qa/extras/ww8import/data/tdf74328.doc b/sw/qa/extras/ww8export/data/tdf74328.doc Binary files differindex a82978547b5d..a82978547b5d 100755 --- a/sw/qa/extras/ww8import/data/tdf74328.doc +++ b/sw/qa/extras/ww8export/data/tdf74328.doc diff --git a/sw/qa/extras/ww8import/data/tdf95321.doc b/sw/qa/extras/ww8export/data/tdf95321.doc Binary files differindex 8b85472b5660..8b85472b5660 100644 --- a/sw/qa/extras/ww8import/data/tdf95321.doc +++ b/sw/qa/extras/ww8export/data/tdf95321.doc diff --git a/sw/qa/extras/ww8import/data/tdf95576.doc b/sw/qa/extras/ww8export/data/tdf95576.doc Binary files differindex a8a601885f33..a8a601885f33 100644 --- a/sw/qa/extras/ww8import/data/tdf95576.doc +++ b/sw/qa/extras/ww8export/data/tdf95576.doc diff --git a/sw/qa/extras/ww8import/data/tdf99100.doc b/sw/qa/extras/ww8export/data/tdf99100.doc Binary files differindex 6352ae3559a3..6352ae3559a3 100644 --- a/sw/qa/extras/ww8import/data/tdf99100.doc +++ b/sw/qa/extras/ww8export/data/tdf99100.doc diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx index 7d3cf22131ec..88a703d99782 100644 --- a/sw/qa/extras/ww8export/ww8export.cxx +++ b/sw/qa/extras/ww8export/ww8export.cxx @@ -9,20 +9,30 @@ #include <swmodeltestbase.hxx> +//#include <com/sun/star/text/XDependentTextField.hpp> + +#include <com/sun/star/awt/FontWeight.hpp> #include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/awt/XBitmap.hpp> #include <com/sun/star/form/validation/XValidatableFormComponent.hpp> #include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/drawing/TextVerticalAdjust.hpp> #include <com/sun/star/drawing/XControlShape.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/view/XViewSettingsSupplier.hpp> +#include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/table/ShadowFormat.hpp> +#include <com/sun/star/table/TableBorder.hpp> #include <com/sun/star/table/TableBorder2.hpp> #include <com/sun/star/text/GraphicCrop.hpp> #include <com/sun/star/text/XFormField.hpp> +#include <com/sun/star/text/XTextFramesSupplier.hpp> +#include <com/sun/star/text/XTextTablesSupplier.hpp> #include <com/sun/star/view/DocumentZoomType.hpp> #include <com/sun/star/rdf/URI.hpp> #include <com/sun/star/rdf/Statement.hpp> +//#include <vcl/svapp.hxx> #include <grfatr.hxx> #include <pagedesc.hxx> #include <ndgrf.hxx> @@ -36,6 +46,10 @@ #include <view.hxx> #include <wrtsh.hxx> +#include <bordertest.hxx> + +#define convertTwipToMm100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L)) + class Test : public SwModelTestBase { public: @@ -121,6 +135,535 @@ protected: } }; +DECLARE_WW8EXPORT_TEST(testN757910, "n757910.doc") +{ + // The internal margin was larger than 0.28cm + uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropertySet(xIndexAccess->getByIndex(0), uno::UNO_QUERY); + sal_Int32 nValue = 0; + xPropertySet->getPropertyValue("LeftBorderDistance") >>= nValue; + CPPUNIT_ASSERT_EQUAL(sal_Int32(280), nValue); + + // The border width was zero + table::BorderLine2 aBorder; + xPropertySet->getPropertyValue("LeftBorder") >>= aBorder; + CPPUNIT_ASSERT(aBorder.LineWidth > 0); +} + +DECLARE_WW8EXPORT_TEST(testN760294, "n760294.doc") +{ + uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xTable(xIndexAccess->getByIndex(0), uno::UNO_QUERY); + table::TableBorder aTableBorder; + xTable->getPropertyValue("TableBorder") >>= aTableBorder; + CPPUNIT_ASSERT_EQUAL(aTableBorder.TopLine.InnerLineWidth, aTableBorder.TopLine.OuterLineWidth); + CPPUNIT_ASSERT_EQUAL(aTableBorder.TopLine.InnerLineWidth, aTableBorder.TopLine.LineDistance); +} + +DECLARE_WW8EXPORT_TEST(testN750255, "n750255.doc") +{ +/* +Column break without columns on the page is a page break, so check those paragraphs +are on page 2 (page style 'Convert 1') and page 3 (page style 'Convert 2') +enum = ThisComponent.Text.createEnumeration +enum.nextElement +para1 = enum.nextElement +xray para1.String +xray para1.PageStyleName +para2 = enum.nextElement +xray para2.String +xray para2.PageStyleName +*/ + uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY); + // list of paragraphs + uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration(); + // go to 1st paragraph + (void) paraEnum->nextElement(); + // get the 2nd and 3rd paragraph + uno::Reference<uno::XInterface> paragraph1(paraEnum->nextElement(), uno::UNO_QUERY); + uno::Reference<uno::XInterface> paragraph2(paraEnum->nextElement(), uno::UNO_QUERY); + uno::Reference<text::XTextRange> text1(paragraph1, uno::UNO_QUERY); + uno::Reference<text::XTextRange> text2(paragraph2, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL( OUString( "one" ), text1->getString()); + CPPUNIT_ASSERT_EQUAL( OUString( "two" ), text2->getString()); + uno::Reference<beans::XPropertySet> paragraphProperties1(paragraph1, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> paragraphProperties2(paragraph2, uno::UNO_QUERY); + OUString pageStyle1, pageStyle2; + paragraphProperties1->getPropertyValue( "PageStyleName" ) >>= pageStyle1; + paragraphProperties2->getPropertyValue( "PageStyleName" ) >>= pageStyle2; + CPPUNIT_ASSERT_EQUAL( OUString( "Convert 1" ), pageStyle1 ); + CPPUNIT_ASSERT_EQUAL( OUString( "Convert 2" ), pageStyle2 ); + +} + +DECLARE_WW8EXPORT_TEST(testN652364, "n652364.doc") +{ +/* +Related to 750255 above, column break with columns on the page however should be a column break. +enum = ThisComponent.Text.createEnumeration +enum.nextElement +para1 = enum.nextElement +xray para1.String +xray para1.PageStyleName +enum.nextElement +para2 = enum.nextElement +xray para2.String +xray para2.PageStyleName +*/ + uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY); + // list of paragraphs + uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration(); + // get the 2nd and 4th paragraph + (void) paraEnum->nextElement(); + uno::Reference<uno::XInterface> paragraph1(paraEnum->nextElement(), uno::UNO_QUERY); + (void) paraEnum->nextElement(); + uno::Reference<uno::XInterface> paragraph2(paraEnum->nextElement(), uno::UNO_QUERY); + uno::Reference<text::XTextRange> text1(paragraph1, uno::UNO_QUERY); + uno::Reference<text::XTextRange> text2(paragraph2, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL( OUString( "text1" ), text1->getString()); + CPPUNIT_ASSERT_EQUAL( OUString( "text2" ), text2->getString()); + uno::Reference<beans::XPropertySet> paragraphProperties1(paragraph1, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> paragraphProperties2(paragraph2, uno::UNO_QUERY); + OUString pageStyle1, pageStyle2; + paragraphProperties1->getPropertyValue( "PageStyleName" ) >>= pageStyle1; + paragraphProperties2->getPropertyValue( "PageStyleName" ) >>= pageStyle2; + // "Standard" is the style for the first page (2nd is "Convert 1"). + CPPUNIT_ASSERT_EQUAL( OUString( "Standard" ), pageStyle1 ); + CPPUNIT_ASSERT_EQUAL( OUString( "Standard" ), pageStyle2 ); +} + +DECLARE_WW8EXPORT_TEST(testN757118, "n757118.doc") +{ +/* +Two pairs of horizontal rules (one absolute width, one relative width) +have the same width (full page width, half page width). +xray ThisComponent.DrawPage.getByIndex(0).BoundRect +*/ + uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XShape> rule1 = getShape(1), rule2 = getShape(2), rule3 = getShape(3), rule4 = getShape(4); + uno::Reference<beans::XPropertySet> ruleProperties1(rule1, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> ruleProperties2(rule2, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> ruleProperties3(rule3, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> ruleProperties4(rule4, uno::UNO_QUERY); + awt::Rectangle boundRect1, boundRect2, boundRect3, boundRect4; + ruleProperties1->getPropertyValue( "BoundRect" ) >>= boundRect1; + ruleProperties2->getPropertyValue( "BoundRect" ) >>= boundRect2; + ruleProperties3->getPropertyValue( "BoundRect" ) >>= boundRect3; + ruleProperties4->getPropertyValue( "BoundRect" ) >>= boundRect4; + // compare, allow for < 5 differences because of rounding errors + CPPUNIT_ASSERT( abs( boundRect1.Width - boundRect3.Width ) < 5 ); + CPPUNIT_ASSERT( abs( boundRect2.Width - boundRect4.Width ) < 5 ); +} + +DECLARE_WW8EXPORT_TEST(testN757905, "n757905.doc") +{ + // The problem was that the paragraph had only a single fly + // (as-character-anchored), and the height of that was smaller than the + // paragraph height. When in Word-compat mode, we should take the max of + // the two, not just the height of the fly. + + OUString aHeight = parseDump("/root/page/body/txt/infos/bounds", "height"); + CPPUNIT_ASSERT(sal_Int32(31) < aHeight.toInt32()); +} + +DECLARE_WW8EXPORT_TEST(testAllGapsWord, "all_gaps_word.doc") +{ + BorderTest borderTest; + BorderTest::testTheBorders(mxComponent, true); +} + +DECLARE_WW8EXPORT_TEST(testI120158, "i120158.doc") +{ + // See https://bz.apache.org/ooo/show_bug.cgi?id=120158 + uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY); + // list of paragraphs + uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration(); + // get contents of 1st paragraph as text + uno::Reference<uno::XInterface> paragraph0(paraEnum->nextElement(), uno::UNO_QUERY); + uno::Reference<text::XTextRange> text0(paragraph0, uno::UNO_QUERY); + OUString sFieldResult = text0->getString(); + CPPUNIT_ASSERT(sFieldResult.endsWith("AM") || sFieldResult.endsWith("PM")); +} + +DECLARE_WW8EXPORT_TEST(testN816603, "n816603.doc") +{ + // Bugdoc was 5 pages in Word, 1 in Writer due to pointlessly wrapping the + // table in a frame. Exact layout may depend on fonts available, etc. -- + // but at least make sure that our table spans over multiple pages now. + CPPUNIT_ASSERT(getPages() > 1); +} + +DECLARE_WW8EXPORT_TEST(testPageBorder, "page-border.doc") +{ + // Page border was missing (LineWidth was 0), due to wrong interpretation of pgbApplyTo. + table::BorderLine2 aBorder = getProperty<table::BorderLine2>(getStyles("PageStyles")->getByName("Standard"), "TopBorder"); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(convertTwipToMm100(6 * 20)), aBorder.LineWidth); +} + +DECLARE_WW8EXPORT_TEST(testN823651, "n823651.doc") +{ + // Character height was 10pt instead of 7.5pt in the header. + uno::Reference<beans::XPropertySet> xStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); + uno::Reference<text::XText> xText = getProperty< uno::Reference<text::XTextRange> >(xStyle, "HeaderTextFirst")->getText(); + CPPUNIT_ASSERT_EQUAL(7.5f, getProperty<float>(getParagraphOfText(1, xText), "CharHeight")); +} + +DECLARE_WW8EXPORT_TEST(testFdo36868, "fdo36868.doc") +{ + OUString aText = parseDump("/root/page/body/txt[3]/Special[@nType='POR_NUMBER']", "rText"); + // This was 1.1. + CPPUNIT_ASSERT_EQUAL(OUString("2.1"), aText); +} + +DECLARE_WW8EXPORT_TEST(testListNolevel, "list-nolevel.doc") +{ + // Similar to fdo#36868, numbering portions had wrong values. + OUString aText = parseDump("/root/page/body/txt[1]/Special[@nType='POR_NUMBER']", "rText"); + // POR_NUMBER was completely missing. + CPPUNIT_ASSERT_EQUAL(OUString("1."), aText); +} + +DECLARE_WW8EXPORT_TEST(testBnc821208, "bnc821208.doc") +{ + // WW8Num1z0 earned a Symbol font, turning numbers into rectangles. + uno::Reference<beans::XPropertyState> xPropertyState(getStyles("CharacterStyles")->getByName("WW8Num1z0"), uno::UNO_QUERY); + beans::PropertyState ePropertyState = xPropertyState->getPropertyState("CharFontName"); + // This was beans::PropertyState_DIRECT_VALUE. + CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DEFAULT_VALUE, ePropertyState); + + // Background of the numbering itself should have been the default, was yellow (0xffff00). + CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(xPropertyState, "CharBackColor")); +} + +DECLARE_WW8EXPORT_TEST(testCp1000044, "cp1000044.doc") +{ + uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); + // It wasn't possible to fill out this form. + CPPUNIT_ASSERT_EQUAL(false, bool(xStorable->isReadonly())); +} + +DECLARE_WW8EXPORT_TEST(testCp1000039, "cp1000039.doc") +{ + // This was RTL_TEXTENCODING_SYMBOL, causing "1" rendered as a placeholder rectangle. + CPPUNIT_ASSERT_EQUAL(sal_Int16(RTL_TEXTENCODING_DONTKNOW), getProperty<sal_Int16>(getRun(getParagraph(1), 1), "CharFontCharSet")); +} + +DECLARE_WW8EXPORT_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 +} + +DECLARE_WW8EXPORT_TEST(testMsoBrightnessContrast, "msobrightnesscontrast.doc") +{ + uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XShape> image(getShape(1), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> imageProperties(image, uno::UNO_QUERY); + uno::Reference<graphic::XGraphic> graphic; + imageProperties->getPropertyValue( "Graphic" ) >>= graphic; + uno::Reference<awt::XBitmap> bitmap(graphic, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL( sal_Int32(58), bitmap->getSize().Width ); + CPPUNIT_ASSERT_EQUAL( sal_Int32(320), bitmap->getSize().Height ); + const uno::Sequence< sal_Int8 > data = bitmap->getDIB(); // as .bmp data + CPPUNIT_ASSERT_EQUAL( sal_Int32(20278), data.getLength()); + CPPUNIT_ASSERT_EQUAL( -50, int(data[0x6b0])); // -50 = 206 pixel value + CPPUNIT_ASSERT_EQUAL( -50, int(data[0x6b1])); + CPPUNIT_ASSERT_EQUAL( -50, int(data[0x6b2])); + CPPUNIT_ASSERT_EQUAL( -50, int(data[0x6b3])); + CPPUNIT_ASSERT_EQUAL( -50, int(data[0x6b4])); +} + +DECLARE_WW8EXPORT_TEST(testTdf95321, "tdf95321.doc") +{ + // The problem was that there should be content in the second cell + // but there wasn't. + uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); + uno::Reference<text::XTextTable> xTable(xIndexAccess->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Second Column"), uno::Reference<text::XTextRange>(xTable->getCellByName("B1"), uno::UNO_QUERY)->getString()); +} + +DECLARE_WW8EXPORT_TEST(testFdo77844, "fdo77844.doc") +{ + uno::Reference<container::XNameAccess> pageStyles = getStyles("PageStyles"); + + // get a page cursor + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier( + xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference<text::XPageCursor> xCursor( + xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); + + // check that the first page has no header + xCursor->jumpToFirstPage(); + OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + uno::Reference<style::XStyle> pageStyle( + pageStyles->getByName(pageStyleName), uno::UNO_QUERY); + bool headerIsOn = getProperty<bool>(pageStyle, "HeaderIsOn"); + CPPUNIT_ASSERT(!headerIsOn); + + // check that the second page has a header + xCursor->jumpToPage(2); + pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + pageStyle.set( + pageStyles->getByName(pageStyleName), uno::UNO_QUERY); + headerIsOn = getProperty<bool>(pageStyle, "HeaderIsOn"); + CPPUNIT_ASSERT(headerIsOn); + + // check that the third page has a header + xCursor->jumpToPage(3); + pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + pageStyle.set( + pageStyles->getByName(pageStyleName), uno::UNO_QUERY); + headerIsOn = getProperty<bool>(pageStyle, "HeaderIsOn"); + CPPUNIT_ASSERT(headerIsOn); + + // check that the fourth page has no header + // (#if'd out as this is not yet imported correctly) +#if 0 + xCursor->jumpToPage(4); + pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + pageStyle.set( + pageStyles->getByName(pageStyleName), uno::UNO_QUERY); + headerIsOn = getProperty<bool>(pageStyle, "HeaderIsOn"); + CPPUNIT_ASSERT(!headerIsOn); +#endif +} + +DECLARE_WW8EXPORT_TEST(testFdp80333, "fdo80333.doc") +{ + // Despite there is no character border, border shadow was imported + uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY); + const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xRun, "CharShadowFormat"); + CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location); +} + +DECLARE_WW8EXPORT_TEST(testFdo81102, "fdo81102.doc") +{ + // get page style at beginning of document + uno::Reference<text::XTextDocument> textDocument( + mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextRange> start( + textDocument->getText()->getStart(), uno::UNO_QUERY); + OUString pageStyleName = getProperty<OUString>(start, "PageStyleName"); + uno::Reference<style::XStyle> pageStyle( + getStyles("PageStyles")->getByName(pageStyleName), uno::UNO_QUERY); + + // check that left and right pages do not share the same header + bool headerIsShared = getProperty<bool>(pageStyle, "HeaderIsShared"); + CPPUNIT_ASSERT(!headerIsShared); +} + +DECLARE_WW8EXPORT_TEST(testBnc787942, "bnc787942.doc") +{ + // The frame ended up on the second page instead of first. + parseDump("/root/page[1]/body/txt[4]/anchored"); +} + +DECLARE_WW8EXPORT_TEST(testLayoutHanging, "fdo68967.doc") +{ + // This must not hang in layout +} + +DECLARE_WW8EXPORT_TEST(testfdo68963, "fdo68963.doc") +{ + // The problem was that the text was not displayed. + CPPUNIT_ASSERT ( !parseDump("/root/page/body/tab/row[2]/cell[1]/txt/Special", "rText").isEmpty() ); + CPPUNIT_ASSERT_EQUAL( OUString("Topic 1"), parseDump("/root/page/body/tab/row[2]/cell[1]/txt/Special", "rText") ); + // all crossreference bookmarks should have a target. Shouldn't be any "Reference source not found" in the xml + CPPUNIT_ASSERT ( -1 == parseDump("/root/page/body/txt[24]/Special[2]","rText").indexOf("Reference source not found")); +} + +DECLARE_WW8EXPORT_TEST(testTdf99100, "tdf99100.doc") +{ + uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName("Standard"), "HeaderText"); + auto xField = getProperty< uno::Reference<lang::XServiceInfo> >(getRun(getParagraphOfText(1, xHeaderText), 2), "TextField"); + // This failed: the second text portion wasn't a field. + CPPUNIT_ASSERT(xField.is()); + CPPUNIT_ASSERT(xField->supportsService("com.sun.star.text.textfield.Chapter")); +} + +DECLARE_WW8EXPORT_TEST(testTdf74328, "tdf74328.doc") +{ +/* +reading page numbers at sections > 255, in this case 256 +*/ + uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextCursor> xTextCursor(textDocument->getText()->createTextCursor( ), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xProps(xTextCursor, uno::UNO_QUERY); + uno::Any aOffset = xProps->getPropertyValue("PageNumberOffset"); + sal_Int16 nOffset = 0; + aOffset >>= nOffset; + CPPUNIT_ASSERT_EQUAL(sal_Int16(256), nOffset); +} + +DECLARE_WW8EXPORT_TEST(testTdf95576, "tdf95576.doc") +{ + // The first three paragraphs in this document (which are headings) + // should have zero indent and first line indent + for (int nPara = 1; nPara <= 3; ++nPara) { + std::cout << "nPara = " << nPara << "\n"; + auto xPara = getParagraph(nPara); + + // get the numbering rules effective at this paragraph + uno::Reference<container::XIndexReplace> xNumRules( + getProperty< uno::Reference<container::XIndexReplace> >( + xPara, "NumberingRules"), + uno::UNO_QUERY); + + // get the numbering level of this paragraph, and the properties + // associated with that numbering level + int numLevel = getProperty<sal_Int32>(xPara, "NumberingLevel"); + uno::Sequence< beans::PropertyValue > aPropertyValues; + xNumRules->getByIndex(numLevel) >>= aPropertyValues; + + // Now look through these properties for the indent and + // first line indent settings + sal_Int32 nIndentAt = -1; + sal_Int32 nFirstLineIndent = -1; + for(int j = 0 ; j< aPropertyValues.getLength() ; ++j) + { + auto aProp = aPropertyValues[j]; + std::cout << "Prop.Name: " << aProp.Name << "\n"; + if (aProp.Name == "FirstLineIndent") { + nFirstLineIndent = aProp.Value.get<sal_Int32>(); + } else if (aProp.Name == "IndentAt") { + nIndentAt = aProp.Value.get<sal_Int32>(); + } + } + + // The indent and first line indent should be zero + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nIndentAt); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nFirstLineIndent); + } +} + +DECLARE_WW8EXPORT_TEST(testTdf59896, "tdf59896.doc") +{ + // This was awt::FontWeight::NORMAL, i.e. the first run wasn't bold, when it should be bold + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(getRun(getParagraph(1), 1), "CharWeight")); +} + +DECLARE_WW8EXPORT_TEST(testTdf102334, "tdf102334.doc") +{ + // This was false, i.e. the first run wasn't hidden, when it should have been + CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(getRun(getParagraph(7), 1), "CharHidden")); +} + DECLARE_WW8EXPORT_TEST(testN325936, "n325936.doc") { /* diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx index de3817afa4fb..85f4ca311e9c 100644 --- a/sw/qa/extras/ww8import/ww8import.cxx +++ b/sw/qa/extras/ww8import/ww8import.cxx @@ -9,22 +9,7 @@ #include <swmodeltestbase.hxx> -#include <com/sun/star/awt/FontWeight.hpp> -#include <com/sun/star/awt/XBitmap.hpp> -#include <com/sun/star/graphic/XGraphic.hpp> -#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> -#include <com/sun/star/table/ShadowFormat.hpp> - -#include <vcl/svapp.hxx> - -#include <bordertest.hxx> - -#define convertTwipToMm100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L)) class Test : public SwModelTestBase { @@ -48,169 +33,6 @@ DECLARE_WW8IMPORT_TEST(testFloatingTableSectionMargins, "floating-table-section- CPPUNIT_ASSERT( abs(( pageLeft + pageWidth / 2 ) - ( tableLeft + tableWidth / 2 )) < 20 ); } -DECLARE_WW8IMPORT_TEST(testN757910, "n757910.doc") -{ - // The internal margin was larger than 0.28cm - uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xPropertySet(xIndexAccess->getByIndex(0), uno::UNO_QUERY); - sal_Int32 nValue = 0; - xPropertySet->getPropertyValue("LeftBorderDistance") >>= nValue; - CPPUNIT_ASSERT_EQUAL(sal_Int32(280), nValue); - - // The border width was zero - table::BorderLine2 aBorder; - xPropertySet->getPropertyValue("LeftBorder") >>= aBorder; - CPPUNIT_ASSERT(aBorder.LineWidth > 0); -} - -DECLARE_WW8IMPORT_TEST(testN760294, "n760294.doc") -{ - uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xTable(xIndexAccess->getByIndex(0), uno::UNO_QUERY); - table::TableBorder aTableBorder; - xTable->getPropertyValue("TableBorder") >>= aTableBorder; - CPPUNIT_ASSERT_EQUAL(aTableBorder.TopLine.InnerLineWidth, aTableBorder.TopLine.OuterLineWidth); - CPPUNIT_ASSERT_EQUAL(aTableBorder.TopLine.InnerLineWidth, aTableBorder.TopLine.LineDistance); -} - -DECLARE_WW8IMPORT_TEST(testN750255, "n750255.doc") -{ -/* -Column break without columns on the page is a page break, so check those paragraphs -are on page 2 (page style 'Convert 1') and page 3 (page style 'Convert 2') -enum = ThisComponent.Text.createEnumeration -enum.nextElement -para1 = enum.nextElement -xray para1.String -xray para1.PageStyleName -para2 = enum.nextElement -xray para2.String -xray para2.PageStyleName -*/ - uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY); - // list of paragraphs - uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration(); - // go to 1st paragraph - (void) paraEnum->nextElement(); - // get the 2nd and 3rd paragraph - uno::Reference<uno::XInterface> paragraph1(paraEnum->nextElement(), uno::UNO_QUERY); - uno::Reference<uno::XInterface> paragraph2(paraEnum->nextElement(), uno::UNO_QUERY); - uno::Reference<text::XTextRange> text1(paragraph1, uno::UNO_QUERY); - uno::Reference<text::XTextRange> text2(paragraph2, uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL( OUString( "one" ), text1->getString()); - CPPUNIT_ASSERT_EQUAL( OUString( "two" ), text2->getString()); - uno::Reference<beans::XPropertySet> paragraphProperties1(paragraph1, uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> paragraphProperties2(paragraph2, uno::UNO_QUERY); - OUString pageStyle1, pageStyle2; - paragraphProperties1->getPropertyValue( "PageStyleName" ) >>= pageStyle1; - paragraphProperties2->getPropertyValue( "PageStyleName" ) >>= pageStyle2; - CPPUNIT_ASSERT_EQUAL( OUString( "Convert 1" ), pageStyle1 ); - CPPUNIT_ASSERT_EQUAL( OUString( "Convert 2" ), pageStyle2 ); - -} - -DECLARE_WW8IMPORT_TEST(testN652364, "n652364.doc") -{ -/* -Related to 750255 above, column break with columns on the page however should be a column break. -enum = ThisComponent.Text.createEnumeration -enum.nextElement -para1 = enum.nextElement -xray para1.String -xray para1.PageStyleName -enum.nextElement -para2 = enum.nextElement -xray para2.String -xray para2.PageStyleName -*/ - uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY); - // list of paragraphs - uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration(); - // get the 2nd and 4th paragraph - (void) paraEnum->nextElement(); - uno::Reference<uno::XInterface> paragraph1(paraEnum->nextElement(), uno::UNO_QUERY); - (void) paraEnum->nextElement(); - uno::Reference<uno::XInterface> paragraph2(paraEnum->nextElement(), uno::UNO_QUERY); - uno::Reference<text::XTextRange> text1(paragraph1, uno::UNO_QUERY); - uno::Reference<text::XTextRange> text2(paragraph2, uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL( OUString( "text1" ), text1->getString()); - CPPUNIT_ASSERT_EQUAL( OUString( "text2" ), text2->getString()); - uno::Reference<beans::XPropertySet> paragraphProperties1(paragraph1, uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> paragraphProperties2(paragraph2, uno::UNO_QUERY); - OUString pageStyle1, pageStyle2; - paragraphProperties1->getPropertyValue( "PageStyleName" ) >>= pageStyle1; - paragraphProperties2->getPropertyValue( "PageStyleName" ) >>= pageStyle2; - // "Standard" is the style for the first page (2nd is "Convert 1"). - CPPUNIT_ASSERT_EQUAL( OUString( "Standard" ), pageStyle1 ); - CPPUNIT_ASSERT_EQUAL( OUString( "Standard" ), pageStyle2 ); -} - -DECLARE_WW8IMPORT_TEST(testN757118, "n757118.doc") -{ -/* -Two pairs of horizontal rules (one absolute width, one relative width) -have the same width (full page width, half page width). -xray ThisComponent.DrawPage.getByIndex(0).BoundRect -*/ - uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); - uno::Reference<drawing::XShape> rule1 = getShape(1), rule2 = getShape(2), rule3 = getShape(3), rule4 = getShape(4); - uno::Reference<beans::XPropertySet> ruleProperties1(rule1, uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> ruleProperties2(rule2, uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> ruleProperties3(rule3, uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> ruleProperties4(rule4, uno::UNO_QUERY); - awt::Rectangle boundRect1, boundRect2, boundRect3, boundRect4; - ruleProperties1->getPropertyValue( "BoundRect" ) >>= boundRect1; - ruleProperties2->getPropertyValue( "BoundRect" ) >>= boundRect2; - ruleProperties3->getPropertyValue( "BoundRect" ) >>= boundRect3; - ruleProperties4->getPropertyValue( "BoundRect" ) >>= boundRect4; - // compare, allow for < 5 differences because of rounding errors - CPPUNIT_ASSERT( abs( boundRect1.Width - boundRect3.Width ) < 5 ); - CPPUNIT_ASSERT( abs( boundRect2.Width - boundRect4.Width ) < 5 ); -} - -DECLARE_WW8IMPORT_TEST(testN757905, "n757905.doc") -{ - // The problem was that the paragraph had only a single fly - // (as-character-anchored), and the height of that was smaller than the - // paragraph height. When in Word-compat mode, we should take the max of - // the two, not just the height of the fly. - - OUString aHeight = parseDump("/root/page/body/txt/infos/bounds", "height"); - CPPUNIT_ASSERT(sal_Int32(31) < aHeight.toInt32()); -} - -DECLARE_WW8IMPORT_TEST(testAllGapsWord, "all_gaps_word.doc") -{ - BorderTest borderTest; - BorderTest::testTheBorders(mxComponent, true); -} - -DECLARE_WW8IMPORT_TEST(testI120158, "i120158.doc") -{ - // See https://bz.apache.org/ooo/show_bug.cgi?id=120158 - uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY); - // list of paragraphs - uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration(); - // get contents of 1st paragraph as text - uno::Reference<uno::XInterface> paragraph0(paraEnum->nextElement(), uno::UNO_QUERY); - uno::Reference<text::XTextRange> text0(paragraph0, uno::UNO_QUERY); - OUString sFieldResult = text0->getString(); - CPPUNIT_ASSERT(sFieldResult.endsWith("AM") || sFieldResult.endsWith("PM")); -} - -DECLARE_WW8IMPORT_TEST(testN816603, "n816603.doc") -{ - // Bugdoc was 5 pages in Word, 1 in Writer due to pointlessly wrapping the - // table in a frame. Exact layout may depend on fonts available, etc. -- - // but at least make sure that our table spans over multiple pages now. - CPPUNIT_ASSERT(getPages() > 1); -} - DECLARE_WW8IMPORT_TEST(testN816593, "n816593.doc") { uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); @@ -220,195 +42,6 @@ DECLARE_WW8IMPORT_TEST(testN816593, "n816593.doc") CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); } -DECLARE_WW8IMPORT_TEST(testPageBorder, "page-border.doc") -{ - // Page border was missing (LineWidth was 0), due to wrong interpretation of pgbApplyTo. - table::BorderLine2 aBorder = getProperty<table::BorderLine2>(getStyles("PageStyles")->getByName("Standard"), "TopBorder"); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(convertTwipToMm100(6 * 20)), aBorder.LineWidth); -} - -DECLARE_WW8IMPORT_TEST(testN823651, "n823651.doc") -{ - // Character height was 10pt instead of 7.5pt in the header. - uno::Reference<beans::XPropertySet> xStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); - uno::Reference<text::XText> xText = getProperty< uno::Reference<text::XTextRange> >(xStyle, "HeaderTextFirst")->getText(); - CPPUNIT_ASSERT_EQUAL(7.5f, getProperty<float>(getParagraphOfText(1, xText), "CharHeight")); -} - -DECLARE_WW8IMPORT_TEST(testFdo36868, "fdo36868.doc") -{ - OUString aText = parseDump("/root/page/body/txt[3]/Special[@nType='POR_NUMBER']", "rText"); - // This was 1.1. - CPPUNIT_ASSERT_EQUAL(OUString("2.1"), aText); -} - -DECLARE_WW8IMPORT_TEST(testListNolevel, "list-nolevel.doc") -{ - // Similar to fdo#36868, numbering portions had wrong values. - OUString aText = parseDump("/root/page/body/txt[1]/Special[@nType='POR_NUMBER']", "rText"); - // POR_NUMBER was completely missing. - CPPUNIT_ASSERT_EQUAL(OUString("1."), aText); -} - -DECLARE_WW8IMPORT_TEST(testBnc821208, "bnc821208.doc") -{ - // WW8Num1z0 earned a Symbol font, turning numbers into rectangles. - uno::Reference<beans::XPropertyState> xPropertyState(getStyles("CharacterStyles")->getByName("WW8Num1z0"), uno::UNO_QUERY); - beans::PropertyState ePropertyState = xPropertyState->getPropertyState("CharFontName"); - // This was beans::PropertyState_DIRECT_VALUE. - CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DEFAULT_VALUE, ePropertyState); - - // Background of the numbering itself should have been the default, was yellow (0xffff00). - CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(xPropertyState, "CharBackColor")); -} - -DECLARE_WW8IMPORT_TEST(testCp1000044, "cp1000044.doc") -{ - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); - // It wasn't possible to fill out this form. - CPPUNIT_ASSERT_EQUAL(false, bool(xStorable->isReadonly())); -} - -DECLARE_WW8IMPORT_TEST(testCp1000039, "cp1000039.doc") -{ - // This was RTL_TEXTENCODING_SYMBOL, causing "1" rendered as a placeholder rectangle. - 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 -} - -DECLARE_WW8IMPORT_TEST(testMsoBrightnessContrast, "msobrightnesscontrast.doc") -{ - uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); - uno::Reference<drawing::XShape> image(getShape(1), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> imageProperties(image, uno::UNO_QUERY); - uno::Reference<graphic::XGraphic> graphic; - imageProperties->getPropertyValue( "Graphic" ) >>= graphic; - uno::Reference<awt::XBitmap> bitmap(graphic, uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL( sal_Int32(58), bitmap->getSize().Width ); - CPPUNIT_ASSERT_EQUAL( sal_Int32(320), bitmap->getSize().Height ); - const uno::Sequence< sal_Int8 > data = bitmap->getDIB(); // as .bmp data - CPPUNIT_ASSERT_EQUAL( sal_Int32(20278), data.getLength()); - CPPUNIT_ASSERT_EQUAL( -50, int(data[0x6b0])); // -50 = 206 pixel value - CPPUNIT_ASSERT_EQUAL( -50, int(data[0x6b1])); - CPPUNIT_ASSERT_EQUAL( -50, int(data[0x6b2])); - CPPUNIT_ASSERT_EQUAL( -50, int(data[0x6b3])); - CPPUNIT_ASSERT_EQUAL( -50, int(data[0x6b4])); -} - DECLARE_WW8IMPORT_TEST(testBnc863018, "bnc863018.doc") { // The problem was that there should be some whitespace above the table, @@ -419,17 +52,6 @@ DECLARE_WW8IMPORT_TEST(testBnc863018, "bnc863018.doc") // This was 0. CPPUNIT_ASSERT_EQUAL(sal_Int32(5002), getProperty<sal_Int32>(xTable, "TopMargin")); } - -DECLARE_WW8IMPORT_TEST(testTdf95321, "tdf95321.doc") -{ - // The problem was that there should be content in the second cell - // but there wasn't. - uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); - uno::Reference<text::XTextTable> xTable(xIndexAccess->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Second Column"), uno::Reference<text::XTextRange>(xTable->getCellByName("B1"), uno::UNO_QUERY)->getString()); -} - DECLARE_WW8IMPORT_TEST(testBnc875715, "bnc875715.doc") { uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY); @@ -437,78 +59,6 @@ DECLARE_WW8IMPORT_TEST(testBnc875715, "bnc875715.doc") // Was incorrectly set as -1270. CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xSections->getByIndex(0), "SectionLeftMargin")); } - -DECLARE_WW8IMPORT_TEST(testFdo77844, "fdo77844.doc") -{ - uno::Reference<container::XNameAccess> pageStyles = getStyles("PageStyles"); - - // get a page cursor - uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); - uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier( - xModel->getCurrentController(), uno::UNO_QUERY); - uno::Reference<text::XPageCursor> xCursor( - xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); - - // check that the first page has no header - xCursor->jumpToFirstPage(); - OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); - uno::Reference<style::XStyle> pageStyle( - pageStyles->getByName(pageStyleName), uno::UNO_QUERY); - bool headerIsOn = getProperty<bool>(pageStyle, "HeaderIsOn"); - CPPUNIT_ASSERT(!headerIsOn); - - // check that the second page has a header - xCursor->jumpToPage(2); - pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); - pageStyle.set( - pageStyles->getByName(pageStyleName), uno::UNO_QUERY); - headerIsOn = getProperty<bool>(pageStyle, "HeaderIsOn"); - CPPUNIT_ASSERT(headerIsOn); - - // check that the third page has a header - xCursor->jumpToPage(3); - pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); - pageStyle.set( - pageStyles->getByName(pageStyleName), uno::UNO_QUERY); - headerIsOn = getProperty<bool>(pageStyle, "HeaderIsOn"); - CPPUNIT_ASSERT(headerIsOn); - - // check that the fourth page has no header - // (#if'd out as this is not yet imported correctly) -#if 0 - xCursor->jumpToPage(4); - pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); - pageStyle.set( - pageStyles->getByName(pageStyleName), uno::UNO_QUERY); - headerIsOn = getProperty<bool>(pageStyle, "HeaderIsOn"); - CPPUNIT_ASSERT(!headerIsOn); -#endif -} - -DECLARE_WW8IMPORT_TEST(testFdp80333, "fdo80333.doc") -{ - // Despite there is no character border, border shadow was imported - uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY); - const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xRun, "CharShadowFormat"); - CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location); -} - -DECLARE_WW8IMPORT_TEST(testFdo81102, "fdo81102.doc") -{ - // get page style at beginning of document - uno::Reference<text::XTextDocument> textDocument( - mxComponent, uno::UNO_QUERY); - uno::Reference<text::XTextRange> start( - textDocument->getText()->getStart(), uno::UNO_QUERY); - OUString pageStyleName = getProperty<OUString>(start, "PageStyleName"); - uno::Reference<style::XStyle> pageStyle( - getStyles("PageStyles")->getByName(pageStyleName), uno::UNO_QUERY); - - // check that left and right pages do not share the same header - bool headerIsShared = getProperty<bool>(pageStyle, "HeaderIsShared"); - CPPUNIT_ASSERT(!headerIsShared); -} - DECLARE_WW8IMPORT_TEST(testFloatingTableSectionColumns, "floating-table-section-columns.doc") { OUString tableWidth = parseDump("/root/page[1]/body/section/column[2]/body/txt/anchored/fly/tab/infos/bounds", "width"); @@ -516,35 +66,6 @@ DECLARE_WW8IMPORT_TEST(testFloatingTableSectionColumns, "floating-table-section- CPPUNIT_ASSERT( tableWidth.toInt32() > 10000 ); } -DECLARE_WW8IMPORT_TEST(testBnc787942, "bnc787942.doc") -{ - // The frame ended up on the second page instead of first. - parseDump("/root/page[1]/body/txt[4]/anchored"); -} - -DECLARE_WW8IMPORT_TEST(testLayoutHanging, "fdo68967.doc") -{ - // This must not hang in layout -} - -DECLARE_WW8IMPORT_TEST(testfdo68963, "fdo68963.doc") -{ - // The problem was that the text was not displayed. - CPPUNIT_ASSERT ( !parseDump("/root/page/body/tab/row[2]/cell[1]/txt/Special", "rText").isEmpty() ); - CPPUNIT_ASSERT_EQUAL( OUString("Topic 1"), parseDump("/root/page/body/tab/row[2]/cell[1]/txt/Special", "rText") ); - // all crossreference bookmarks should have a target. Shouldn't be any "Reference source not found" in the xml - CPPUNIT_ASSERT ( -1 == parseDump("/root/page/body/txt[24]/Special[2]","rText").indexOf("Reference source not found")); -} - -DECLARE_WW8IMPORT_TEST(testTdf99100, "tdf99100.doc") -{ - uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName("Standard"), "HeaderText"); - auto xField = getProperty< uno::Reference<lang::XServiceInfo> >(getRun(getParagraphOfText(1, xHeaderText), 2), "TextField"); - // This failed: the second text portion wasn't a field. - CPPUNIT_ASSERT(xField.is()); - CPPUNIT_ASSERT(xField->supportsService("com.sun.star.text.textfield.Chapter")); -} - DECLARE_WW8IMPORT_TEST(testTdf99120, "tdf99120.doc") { CPPUNIT_ASSERT_EQUAL(OUString("Section 1, odd."), parseDump("/root/page[1]/header/txt/text()")); @@ -554,72 +75,7 @@ DECLARE_WW8IMPORT_TEST(testTdf99120, "tdf99120.doc") CPPUNIT_ASSERT_EQUAL(OUString("Section 2, even."), parseDump("/root/page[4]/header/txt/text()")); } -DECLARE_WW8IMPORT_TEST(testTdf74328, "tdf74328.doc") -{ -/* -reading page numbers at sections > 255, in this case 256 -*/ - uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); - uno::Reference<text::XTextCursor> xTextCursor(textDocument->getText()->createTextCursor( ), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xProps(xTextCursor, uno::UNO_QUERY); - uno::Any aOffset = xProps->getPropertyValue("PageNumberOffset"); - sal_Int16 nOffset = 0; - aOffset >>= nOffset; - CPPUNIT_ASSERT_EQUAL(sal_Int16(256), nOffset); -} - -DECLARE_WW8IMPORT_TEST(testTdf95576, "tdf95576.doc") -{ - // The first three paragraphs in this document (which are headings) - // should have zero indent and first line indent - for (int nPara = 1; nPara <= 3; ++nPara) { - std::cout << "nPara = " << nPara << "\n"; - auto xPara = getParagraph(nPara); - - // get the numbering rules effective at this paragraph - uno::Reference<container::XIndexReplace> xNumRules( - getProperty< uno::Reference<container::XIndexReplace> >( - xPara, "NumberingRules"), - uno::UNO_QUERY); - - // get the numbering level of this paragraph, and the properties - // associated with that numbering level - int numLevel = getProperty<sal_Int32>(xPara, "NumberingLevel"); - uno::Sequence< beans::PropertyValue > aPropertyValues; - xNumRules->getByIndex(numLevel) >>= aPropertyValues; - - // Now look through these properties for the indent and - // first line indent settings - sal_Int32 nIndentAt = -1; - sal_Int32 nFirstLineIndent = -1; - for(int j = 0 ; j< aPropertyValues.getLength() ; ++j) - { - auto aProp = aPropertyValues[j]; - std::cout << "Prop.Name: " << aProp.Name << "\n"; - if (aProp.Name == "FirstLineIndent") { - nFirstLineIndent = aProp.Value.get<sal_Int32>(); - } else if (aProp.Name == "IndentAt") { - nIndentAt = aProp.Value.get<sal_Int32>(); - } - } - - // The indent and first line indent should be zero - CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nIndentAt); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nFirstLineIndent); - } -} - -DECLARE_WW8IMPORT_TEST(testTdf59896, "tdf59896.doc") -{ - // This was awt::FontWeight::NORMAL, i.e. the first run wasn't bold, when it should be bold - CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(getRun(getParagraph(1), 1), "CharWeight")); -} - -DECLARE_WW8IMPORT_TEST(testTdf102334, "tdf102334.doc") -{ - // This was false, i.e. the first run wasn't hidden, when it should have been - CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(getRun(getParagraph(7), 1), "CharHidden")); -} +// tests should only be added to ww8IMPORT *if* they fail round-tripping in ww8EXPORT CPPUNIT_PLUGIN_IMPLEMENT(); |