diff options
author | Justin Luth <justin.luth@collabora.com> | 2020-09-05 12:41:51 +0300 |
---|---|---|
committer | Justin Luth <justin_luth@sil.org> | 2020-09-08 21:37:45 +0200 |
commit | a1ac10f3acc027fa325fb846f79db6af90dfc223 (patch) | |
tree | 9eff180f605cb3b8b4c79c00446268492b9b255d /sw/qa/extras/ww8export | |
parent | d05c1459f5b8150654ca0b7098cc331ba6009e07 (diff) |
move round-tripables to ww8export #2
This is a followup to much earlier
commit a9afa89e953f0f32acf26b143717e7d067cbc75a
This serves two purposes. It helps to prevent regressions
and it allows focus on features that still don't export properly.
A few more DO export, but things like lazy-load are
just testing load-related things, so skipped a few
that didn't seem to have any value in being round-tripped.
Change-Id: I718e3c09074e7b52d8e83dc9a659f6439ce17d3c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102073
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'sw/qa/extras/ww8export')
-rw-r--r-- | sw/qa/extras/ww8export/data/tdf105570.doc | bin | 0 -> 29696 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/tdf106291.doc | bin | 0 -> 24064 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/tdf112346.doc | bin | 0 -> 27648 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/tdf112535.doc | bin | 0 -> 19968 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/tdf122425_2.doc | bin | 0 -> 41472 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/tdf128605.doc | bin | 0 -> 22016 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/tdf130262.doc | bin | 0 -> 36864 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/tdf79639.doc | bin | 0 -> 27648 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/data/transparent-text.doc | bin | 0 -> 33792 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/ww8export.cxx | 138 |
10 files changed, 138 insertions, 0 deletions
diff --git a/sw/qa/extras/ww8export/data/tdf105570.doc b/sw/qa/extras/ww8export/data/tdf105570.doc Binary files differnew file mode 100644 index 000000000000..1bace7709f6a --- /dev/null +++ b/sw/qa/extras/ww8export/data/tdf105570.doc diff --git a/sw/qa/extras/ww8export/data/tdf106291.doc b/sw/qa/extras/ww8export/data/tdf106291.doc Binary files differnew file mode 100644 index 000000000000..893004d46118 --- /dev/null +++ b/sw/qa/extras/ww8export/data/tdf106291.doc diff --git a/sw/qa/extras/ww8export/data/tdf112346.doc b/sw/qa/extras/ww8export/data/tdf112346.doc Binary files differnew file mode 100644 index 000000000000..af0cca219acf --- /dev/null +++ b/sw/qa/extras/ww8export/data/tdf112346.doc diff --git a/sw/qa/extras/ww8export/data/tdf112535.doc b/sw/qa/extras/ww8export/data/tdf112535.doc Binary files differnew file mode 100644 index 000000000000..4eea19ecd54c --- /dev/null +++ b/sw/qa/extras/ww8export/data/tdf112535.doc diff --git a/sw/qa/extras/ww8export/data/tdf122425_2.doc b/sw/qa/extras/ww8export/data/tdf122425_2.doc Binary files differnew file mode 100644 index 000000000000..8debcddc1690 --- /dev/null +++ b/sw/qa/extras/ww8export/data/tdf122425_2.doc diff --git a/sw/qa/extras/ww8export/data/tdf128605.doc b/sw/qa/extras/ww8export/data/tdf128605.doc Binary files differnew file mode 100644 index 000000000000..2bbfe6b73033 --- /dev/null +++ b/sw/qa/extras/ww8export/data/tdf128605.doc diff --git a/sw/qa/extras/ww8export/data/tdf130262.doc b/sw/qa/extras/ww8export/data/tdf130262.doc Binary files differnew file mode 100644 index 000000000000..fb60beacd79d --- /dev/null +++ b/sw/qa/extras/ww8export/data/tdf130262.doc diff --git a/sw/qa/extras/ww8export/data/tdf79639.doc b/sw/qa/extras/ww8export/data/tdf79639.doc Binary files differnew file mode 100644 index 000000000000..1a996b62b0dd --- /dev/null +++ b/sw/qa/extras/ww8export/data/tdf79639.doc diff --git a/sw/qa/extras/ww8export/data/transparent-text.doc b/sw/qa/extras/ww8export/data/transparent-text.doc Binary files differnew file mode 100644 index 000000000000..b458db29cc09 --- /dev/null +++ b/sw/qa/extras/ww8export/data/transparent-text.doc diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx index a8e774e4dfce..68c464bc8759 100644 --- a/sw/qa/extras/ww8export/ww8export.cxx +++ b/sw/qa/extras/ww8export/ww8export.cxx @@ -35,6 +35,7 @@ #include <com/sun/star/text/XPageCursor.hpp> #include <config_features.h> +#include <editeng/ulspitem.hxx> #include <sfx2/bindings.hxx> #include <sfx2/request.hxx> #include <comphelper/processfactory.hxx> @@ -45,6 +46,8 @@ #include <swmodule.hxx> #include <view.hxx> #include <wrtsh.hxx> +#include <fmtsrnd.hxx> +#include <frameformats.hxx> #include <grfatr.hxx> #include <pagedesc.hxx> #include <ndgrf.hxx> @@ -689,6 +692,141 @@ DECLARE_WW8EXPORT_TEST(testTdf102334, "tdf102334.doc") CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(getRun(getParagraph(7), 1), "CharHidden")); } +DECLARE_WW8EXPORT_TEST(testTdf128605, "tdf128605.doc") +{ + OUString aPara1PageStyleName = getProperty<OUString>(getParagraph(1), "PageStyleName"); + OUString aPara2PageStyleName = getProperty<OUString>(getParagraph(2), "PageStyleName"); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: Standard + // - Actual : Convert 1 + // i.e. the continuous section break resulted in an unwanted page break. + CPPUNIT_ASSERT_EQUAL(aPara1PageStyleName, aPara2PageStyleName); +} + +DECLARE_WW8EXPORT_TEST(testTdf112535, "tdf112535.doc") +{ + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + CPPUNIT_ASSERT(pDoc->GetSpzFrameFormats()); + + SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); + CPPUNIT_ASSERT(!rFormats.empty()); + + const SwFrameFormat* pFormat = rFormats[0]; + CPPUNIT_ASSERT(pFormat); + + // Without the accompanying fix in place, this test would have failed: auto-contour was enabled + // in Writer, but not in Word. + CPPUNIT_ASSERT(!pFormat->GetSurround().IsContour()); +} + +DECLARE_WW8EXPORT_TEST(testTdf106291, "tdf106291.doc") +{ + // Table cell was merged vertically instead of horizontally -> had incorrect dimensions + OUString cellWidth = parseDump("/root/page[1]/body/tab/row/cell[1]/infos/bounds", "width"); + OUString cellHeight = parseDump("/root/page[1]/body/tab/row/cell[1]/infos/bounds", "height"); + CPPUNIT_ASSERT_EQUAL(sal_Int32(8650), cellWidth.toInt32()); + CPPUNIT_ASSERT(cellHeight.toInt32() > 200); // height might depend on font size +} + +DECLARE_WW8EXPORT_TEST(testTransparentText, "transparent-text.doc") +{ + uno::Reference<text::XText> xHeaderText = getProperty<uno::Reference<text::XText>>( + getStyles("PageStyles")->getByName("Standard"), "HeaderText"); + uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(3, xHeaderText); + // Without the accompanying fix in place, this test would have failed: transparency was set to + // 100%, so the text was not readable. + sal_Int32 nExpected(COL_BLACK); + sal_Int32 nActual(getProperty<sal_Int16>(xParagraph, "CharTransparence")); + CPPUNIT_ASSERT_EQUAL(nExpected, nActual); +} + +DECLARE_WW8EXPORT_TEST( testTdf105570, "tdf105570.doc" ) +{ + /***** + * MS-DOC specification ( https://msdn.microsoft.com/en-us/library/cc313153 ) + * ch. 2.6.3, sprmTTableHeader: + * A Bool8 value that specifies that the current table row is a header row. + * If the value is 0x01 but sprmTTableHeader is not applied with a value of 0x01 + * for a previous row in the same table, then this property MUST be ignored. + * + * The document have three tables with three rows. + * Table 1 has { 1, 0, 0 } values of the "repeat as header row" property for each row + * Table 2 has { 1, 1, 0 } + * Table 3 has { 0, 1, 1 } + ****/ + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + SwShellCursor* pShellCursor = pWrtShell->getShellCursor( false ); + SwNodeIndex aIdx = pShellCursor->Start()->nNode; + + // Find first table + SwTableNode* pTableNd = aIdx.GetNode().FindTableNode(); + + CPPUNIT_ASSERT_EQUAL( sal_uInt16(1), pTableNd->GetTable().GetRowsToRepeat() ); + + // Go to next table + aIdx.Assign( *pTableNd->EndOfSectionNode(), 1 ); + while ( nullptr == (pTableNd = aIdx.GetNode().GetTableNode()) ) ++aIdx; + + CPPUNIT_ASSERT_EQUAL( sal_uInt16(2), pTableNd->GetTable().GetRowsToRepeat() ); + + // Go to next table + aIdx.Assign( *pTableNd->EndOfSectionNode(), 1 ); + while ( nullptr == (pTableNd = aIdx.GetNode().GetTableNode()) ) ++aIdx; + + // As first row hasn't sprmTTableHeader set, all following must be ignored, so no rows must be repeated + CPPUNIT_ASSERT_EQUAL( sal_uInt16(0), pTableNd->GetTable().GetRowsToRepeat() ); +} + +DECLARE_WW8EXPORT_TEST(testTdf112346, "tdf112346.doc") +{ + // This was 1, multi-page table was imported as a floating one. + CPPUNIT_ASSERT_EQUAL(0, getShapes()); +} + +DECLARE_WW8EXPORT_TEST(testTdf79639, "tdf79639.doc") +{ + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 0 + // as the floating table in the header wasn't converted to a TextFrame. + CPPUNIT_ASSERT_EQUAL(1, getShapes()); +} + +DECLARE_WW8EXPORT_TEST(testTdf122425_2, "tdf122425_2.doc") +{ + // This is for graphic objects in headers/footers + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + SwPosFlyFrames aPosFlyFrames = pDoc->GetAllFlyFormats(nullptr, false); + // There is one fly frame in the document: the text box + CPPUNIT_ASSERT_EQUAL(size_t(1), aPosFlyFrames.size()); + for (const auto& rPosFlyFrame : aPosFlyFrames) + { + const SwFrameFormat& rFormat = rPosFlyFrame->GetFormat(); + const SfxPoolItem* pItem = nullptr; + + // Check for correct explicitly-set values of UL spacings. Previously this was "DEFAULT", + // and resulted in inherited values (114 = 2 mm) used. + CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, rFormat.GetItemState(RES_UL_SPACE, false, &pItem)); + auto pUL = static_cast<const SvxULSpaceItem*>(pItem); + CPPUNIT_ASSERT(pUL); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), pUL->GetUpper()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), pUL->GetLower()); + } +} + +DECLARE_WW8EXPORT_TEST(testTdf130262, "tdf130262.doc") +{ + // We had an infinite layout loop +} + DECLARE_WW8EXPORT_TEST(testTdf38778, "tdf38778_properties_in_run_for_field.doc") { CPPUNIT_ASSERT_EQUAL(10.0f, getProperty<float>(getRun(getParagraph(1), 1), "CharHeight")); |