diff options
-rw-r--r-- | sw/qa/extras/ww8import/data/tdf122425_1.doc | bin | 0 -> 32256 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8import/data/tdf122425_2.doc | bin | 0 -> 41472 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8import/ww8import.cxx | 66 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8graf.cxx | 1 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 7 |
5 files changed, 73 insertions, 1 deletions
diff --git a/sw/qa/extras/ww8import/data/tdf122425_1.doc b/sw/qa/extras/ww8import/data/tdf122425_1.doc Binary files differnew file mode 100644 index 000000000000..f0e5b148d347 --- /dev/null +++ b/sw/qa/extras/ww8import/data/tdf122425_1.doc diff --git a/sw/qa/extras/ww8import/data/tdf122425_2.doc b/sw/qa/extras/ww8import/data/tdf122425_2.doc Binary files differnew file mode 100644 index 000000000000..8debcddc1690 --- /dev/null +++ b/sw/qa/extras/ww8import/data/tdf122425_2.doc diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx index 0b68d83eb753..5068f7bbf38c 100644 --- a/sw/qa/extras/ww8import/ww8import.cxx +++ b/sw/qa/extras/ww8import/ww8import.cxx @@ -198,6 +198,72 @@ DECLARE_WW8IMPORT_TEST(testTdf110987, "tdf110987") CPPUNIT_ASSERT(sFilterName != "MS Word 97 Vorlage"); } +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(); diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index ec4425b1da8c..866937a17c8f 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -2553,6 +2553,7 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( long nGrafAnchorCp ) // determine wrapping mode SfxItemSet aFlySet(m_rDoc.GetAttrPool(), svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END-1>{}); + Reader::ResetFrameFormatAttrs(aFlySet); // tdf#122425: Explicitly remove borders and spacing css::text::WrapTextMode eSurround = css::text::WrapTextMode_PARALLEL; bool bContour = false; switch (pF->nwr) diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 00c57b690977..bc5b7a864c98 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -2180,7 +2180,12 @@ void SwWW8ImplReader::Read_HdFtTextAsHackedFrame(WW8_CP nStart, WW8_CP nLen, m_pPaM->GetPoint()->nNode = pSttIdx->GetIndex() + 1; m_pPaM->GetPoint()->nContent.Assign(m_pPaM->GetContentNode(), 0); - SwFlyFrameFormat *pFrame = m_rDoc.MakeFlySection(RndStdIds::FLY_AT_PARA, m_pPaM->GetPoint()); + // tdf#122425: Explicitly remove borders and spacing + SfxItemSet aFlySet(m_rDoc.GetAttrPool(), svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END - 1>{}); + Reader::ResetFrameFormatAttrs(aFlySet); + + SwFlyFrameFormat* pFrame + = m_rDoc.MakeFlySection(RndStdIds::FLY_AT_PARA, m_pPaM->GetPoint(), &aFlySet); SwFormatAnchor aAnch( pFrame->GetAnchor() ); aAnch.SetType( RndStdIds::FLY_AT_PARA ); |