summaryrefslogtreecommitdiff
path: root/sw/qa/extras/ww8import
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2019-01-06 19:35:41 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2019-01-06 18:49:52 +0100
commit2e189c2464de007b3d59ba37d4f3f1cfbe5b480c (patch)
treea040afd4a9bfd23bb8befeb2ab1b62f8eb58d9fc /sw/qa/extras/ww8import
parentdd2de0c07f8ed5ebe11412902c011519b5c50be7 (diff)
tdf#122425: explicitly remove borders for newly created flys
After commit d398e9248c183cf988b6d985b342b0cbff93ea02, it's necessary to make sure that each created floating object has proper default border and spacing values (empty and 0), to not inherit frame style's non-0 values unintentionally. This fixes two places for objects in headers/footers. Change-Id: I2632bcd4066609c97aa15e39d69e9089ac691ff2 Reviewed-on: https://gerrit.libreoffice.org/65906 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw/qa/extras/ww8import')
-rw-r--r--sw/qa/extras/ww8import/data/tdf122425_1.docbin0 -> 32256 bytes
-rw-r--r--sw/qa/extras/ww8import/data/tdf122425_2.docbin0 -> 41472 bytes
-rw-r--r--sw/qa/extras/ww8import/ww8import.cxx66
3 files changed, 66 insertions, 0 deletions
diff --git a/sw/qa/extras/ww8import/data/tdf122425_1.doc b/sw/qa/extras/ww8import/data/tdf122425_1.doc
new file mode 100644
index 000000000000..f0e5b148d347
--- /dev/null
+++ b/sw/qa/extras/ww8import/data/tdf122425_1.doc
Binary files differ
diff --git a/sw/qa/extras/ww8import/data/tdf122425_2.doc b/sw/qa/extras/ww8import/data/tdf122425_2.doc
new file mode 100644
index 000000000000..8debcddc1690
--- /dev/null
+++ b/sw/qa/extras/ww8import/data/tdf122425_2.doc
Binary files differ
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index cd07887669bd..83395192985f 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -190,6 +190,72 @@ DECLARE_WW8IMPORT_TEST(testTdf121734, "tdf121734.doc")
}
}
+DECLARE_WW8IMPORT_TEST(testTdf122425_1, "tdf122425_1.doc")
+{
+ // This is for header text in case we use a hack for fixed-height headers
+ // (see SwWW8ImplReader::Read_HdFtTextAsHackedFrame)
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+ SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+ SwPosFlyFrames aPosFlyFrames = pDoc->GetAllFlyFormats(nullptr, false);
+ // There are two fly frames in the document: for first page's header, and for other pages'
+ CPPUNIT_ASSERT_EQUAL(size_t(2), aPosFlyFrames.size());
+ for (const auto& rPosFlyFrame : aPosFlyFrames)
+ {
+ const SwFrameFormat& rFormat = rPosFlyFrame->GetFormat();
+ const SfxPoolItem* pItem = nullptr;
+
+ // The LR and UL spacings and borders must all be set explicitly;
+ // spacings and border distances must be 0; borders must be absent
+
+ CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, rFormat.GetItemState(RES_LR_SPACE, false, &pItem));
+ auto pLR = static_cast<const SvxLRSpaceItem*>(pItem);
+ CPPUNIT_ASSERT(pLR);
+ CPPUNIT_ASSERT_EQUAL(long(0), pLR->GetLeft());
+ CPPUNIT_ASSERT_EQUAL(long(0), pLR->GetRight());
+
+ 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());
+
+ CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, rFormat.GetItemState(RES_BOX, false, &pItem));
+ auto pBox = static_cast<const SvxBoxItem*>(pItem);
+ CPPUNIT_ASSERT(pBox);
+ for (auto eLine : { SvxBoxItemLine::TOP, SvxBoxItemLine::BOTTOM,
+ SvxBoxItemLine::LEFT, SvxBoxItemLine::RIGHT })
+ {
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), pBox->GetDistance(eLine));
+ CPPUNIT_ASSERT(!pBox->GetLine(eLine));
+ }
+ }
+}
+
+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());
+ }
+}
+
// tests should only be added to ww8IMPORT *if* they fail round-tripping in ww8EXPORT
CPPUNIT_PLUGIN_IMPLEMENT();