[Libreoffice-commits] core.git: sw/CppunitTest_sw_ww8export.mk sw/qa
Justin Luth (via logerrit)
logerrit at kemper.freedesktop.org
Tue Sep 8 19:38:29 UTC 2020
sw/CppunitTest_sw_ww8export.mk | 1
sw/qa/extras/ww8export/ww8export.cxx | 138 +++++++++++++++++++++++++++++++++
sw/qa/extras/ww8import/ww8import.cxx | 144 +----------------------------------
3 files changed, 144 insertions(+), 139 deletions(-)
New commits:
commit a1ac10f3acc027fa325fb846f79db6af90dfc223
Author: Justin Luth <justin.luth at collabora.com>
AuthorDate: Sat Sep 5 12:41:51 2020 +0300
Commit: Justin Luth <justin_luth at sil.org>
CommitDate: Tue Sep 8 21:37:45 2020 +0200
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 at sil.org>
diff --git a/sw/CppunitTest_sw_ww8export.mk b/sw/CppunitTest_sw_ww8export.mk
index 0d79d53d9d57..beec46f3cc7f 100644
--- a/sw/CppunitTest_sw_ww8export.mk
+++ b/sw/CppunitTest_sw_ww8export.mk
@@ -21,6 +21,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_ww8export, \
comphelper \
cppu \
cppuhelper \
+ editeng \
emboleobj \
sal \
test \
diff --git a/sw/qa/extras/ww8import/data/tdf105570.doc b/sw/qa/extras/ww8export/data/tdf105570.doc
similarity index 100%
rename from sw/qa/extras/ww8import/data/tdf105570.doc
rename to sw/qa/extras/ww8export/data/tdf105570.doc
diff --git a/sw/qa/extras/ww8import/data/tdf106291.doc b/sw/qa/extras/ww8export/data/tdf106291.doc
similarity index 100%
rename from sw/qa/extras/ww8import/data/tdf106291.doc
rename to sw/qa/extras/ww8export/data/tdf106291.doc
diff --git a/sw/qa/extras/ww8import/data/tdf112346.doc b/sw/qa/extras/ww8export/data/tdf112346.doc
similarity index 100%
rename from sw/qa/extras/ww8import/data/tdf112346.doc
rename to sw/qa/extras/ww8export/data/tdf112346.doc
diff --git a/sw/qa/extras/ww8import/data/tdf112535.doc b/sw/qa/extras/ww8export/data/tdf112535.doc
similarity index 100%
rename from sw/qa/extras/ww8import/data/tdf112535.doc
rename to sw/qa/extras/ww8export/data/tdf112535.doc
diff --git a/sw/qa/extras/ww8import/data/tdf122425_2.doc b/sw/qa/extras/ww8export/data/tdf122425_2.doc
similarity index 100%
rename from sw/qa/extras/ww8import/data/tdf122425_2.doc
rename to sw/qa/extras/ww8export/data/tdf122425_2.doc
diff --git a/sw/qa/extras/ww8import/data/tdf128605.doc b/sw/qa/extras/ww8export/data/tdf128605.doc
similarity index 100%
rename from sw/qa/extras/ww8import/data/tdf128605.doc
rename to sw/qa/extras/ww8export/data/tdf128605.doc
diff --git a/sw/qa/extras/ww8import/data/tdf130262.doc b/sw/qa/extras/ww8export/data/tdf130262.doc
similarity index 100%
rename from sw/qa/extras/ww8import/data/tdf130262.doc
rename to sw/qa/extras/ww8export/data/tdf130262.doc
diff --git a/sw/qa/extras/ww8import/data/tdf79639.doc b/sw/qa/extras/ww8export/data/tdf79639.doc
similarity index 100%
rename from sw/qa/extras/ww8import/data/tdf79639.doc
rename to sw/qa/extras/ww8export/data/tdf79639.doc
diff --git a/sw/qa/extras/ww8import/data/transparent-text.doc b/sw/qa/extras/ww8export/data/transparent-text.doc
similarity index 100%
rename from sw/qa/extras/ww8import/data/transparent-text.doc
rename to 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"));
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index a703e08de6ae..9afe9cbb4cb4 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -23,12 +23,12 @@
#include <viscrs.hxx>
#include <wrtsh.hxx>
#include <ndgrf.hxx>
-#include <fmtsrnd.hxx>
-#include <frameformats.hxx>
#include <docsh.hxx>
#include <unotxdoc.hxx>
#include <IDocumentLayoutAccess.hxx>
+// tests should only be added to ww8IMPORT *if* they fail round-tripping in ww8EXPORT
+
class Test : public SwModelTestBase
{
public:
@@ -78,6 +78,7 @@ 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(testFloatingTableSectionColumns, "floating-table-section-columns.doc")
{
OUString tableWidth = parseDump("/root/page[1]/body/section/column[2]/body/txt/anchored/fly/tab/infos/bounds", "width");
@@ -93,98 +94,7 @@ DECLARE_WW8IMPORT_TEST(testTdf124601, "tdf124601.doc")
CPPUNIT_ASSERT(getProperty<bool>(getShapeByName("Grafik 19"), "IsFollowingTextFlow"));
}
-DECLARE_WW8IMPORT_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_WW8IMPORT_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_WW8IMPORT_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_WW8IMPORT_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_OOXMLIMPORT_TEST(testImageLazyRead, "image-lazy-read.doc")
+DECLARE_WW8IMPORT_TEST(testImageLazyRead, "image-lazy-read.doc")
{
auto xGraphic = getProperty<uno::Reference<graphic::XGraphic>>(getShape(1), "Graphic");
Graphic aGraphic(xGraphic);
@@ -192,7 +102,7 @@ DECLARE_OOXMLIMPORT_TEST(testImageLazyRead, "image-lazy-read.doc")
CPPUNIT_ASSERT(!aGraphic.isAvailable());
}
-DECLARE_OOXMLIMPORT_TEST(testImageLazyRead0size, "image-lazy-read-0size.doc")
+DECLARE_WW8IMPORT_TEST(testImageLazyRead0size, "image-lazy-read-0size.doc")
{
// Load a document with a single bitmap in it: it's declared as a WMF one, but actually a TGA
// bitmap.
@@ -231,12 +141,6 @@ DECLARE_WW8IMPORT_TEST(testTdf106799, "tdf106799.doc")
}
}
-DECLARE_WW8IMPORT_TEST(testTdf112346, "tdf112346.doc")
-{
- // This was 1, multi-page table was imported as a floating one.
- CPPUNIT_ASSERT_EQUAL(0, getShapes());
-}
-
DECLARE_WW8IMPORT_TEST(testTdf121734, "tdf121734.doc")
{
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
@@ -344,39 +248,6 @@ DECLARE_WW8IMPORT_TEST(testTdf122425_1, "tdf122425_1.doc")
}
}
-DECLARE_WW8IMPORT_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_WW8IMPORT_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_WW8IMPORT_TEST(testTdf110987, "tdf110987")
{
// The input document is an empty .doc, but without file name
@@ -388,11 +259,6 @@ DECLARE_WW8IMPORT_TEST(testTdf110987, "tdf110987")
CPPUNIT_ASSERT(sFilterName != "MS Word 97 Vorlage");
}
-DECLARE_WW8IMPORT_TEST(testTdf130262, "tdf130262.doc")
-{
- // We had an infinite layout loop
-}
-
// tests should only be added to ww8IMPORT *if* they fail round-tripping in ww8EXPORT
CPPUNIT_PLUGIN_IMPLEMENT();
More information about the Libreoffice-commits
mailing list