sw/CppunitTest_sw_ww8import.mk | 1 sw/qa/extras/ww8import/data/tdf121734.doc |binary sw/qa/extras/ww8import/ww8import.cxx | 43 ++++++++++++++++++++++++++++++ sw/source/filter/ww8/ww8par.cxx | 4 -- sw/source/filter/ww8/ww8par4.cxx | 3 -- sw/source/filter/ww8/ww8par6.cxx | 6 +--- 6 files changed, 47 insertions(+), 10 deletions(-)
New commits: commit d03a76d0fa4c2fa5f9ecdf3ea36e257587f2c333 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Dec 12 00:31:13 2018 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Tue Jun 18 14:45:08 2019 +0200 tdf#121734: ww8 import: use direct formatting for floating object frames ... and don't modify standard frame styles to have no borders and padding. This makes "Frame", "OLE", and "Graphics" frame styles of imported DOC files to have usual settings (for "Frame", it's 1.5 mm padding and all borders set to 0.05 pt black line). All objects that need invisible frame will have them with all necessary settings set explicitly, which allows to copy and paste such frames to other documents without problems. This makes DOC import aligned with DOCX import in this regard. Change-Id: I6f05cf71e63ceccb8e0ddebe23ec41bf69af9b52 Reviewed-on: https://gerrit.libreoffice.org/64992 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/65012 Tested-by: Mike Kaganski <mike.kagan...@collabora.com> Reviewed-by: Andras Timar <andras.ti...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/74242 diff --git a/sw/CppunitTest_sw_ww8import.mk b/sw/CppunitTest_sw_ww8import.mk index 932878b0e557..31a7dcbe80ba 100644 --- a/sw/CppunitTest_sw_ww8import.mk +++ b/sw/CppunitTest_sw_ww8import.mk @@ -19,6 +19,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_ww8import, \ comphelper \ cppu \ cppuhelper \ + editeng \ sal \ test \ unotest \ diff --git a/sw/qa/extras/ww8import/data/tdf121734.doc b/sw/qa/extras/ww8import/data/tdf121734.doc new file mode 100644 index 000000000000..11a9bf503ca5 Binary files /dev/null and b/sw/qa/extras/ww8import/data/tdf121734.doc differ diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx index 5068f7bbf38c..e3763e60ba17 100644 --- a/sw/qa/extras/ww8import/ww8import.cxx +++ b/sw/qa/extras/ww8import/ww8import.cxx @@ -17,6 +17,9 @@ #include <ndgrf.hxx> #include <sfx2/docfile.hxx> #include <sfx2/docfilt.hxx> +#include <editeng/boxitem.hxx> +#include <editeng/lrspitem.hxx> +#include <editeng/ulspitem.hxx> class Test : public SwModelTestBase { @@ -264,6 +267,46 @@ DECLARE_WW8IMPORT_TEST(testTdf122425_2, "tdf122425_2.doc") } } +DECLARE_WW8IMPORT_TEST(testTdf121734, "tdf121734.doc") +{ + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + SwPosFlyFrames aPosFlyFrames = pDoc->GetAllFlyFormats(nullptr, false); + // There is only one fly frame in the document: the one with the imported floating table + CPPUNIT_ASSERT_EQUAL(size_t(1), 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)); + } + } +} + // tests should only be added to ww8IMPORT *if* they fail round-tripping in ww8EXPORT CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index bc5b7a864c98..612d0c200958 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -6333,12 +6333,8 @@ ErrCode WW8Reader::Read(SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, cons rBaseURL, bNew, m_bSkipImages, *rPaM.GetPoint())); if (bNew) { - // Remove Frame and offsets from Frame Template - Reader::ResetFrameFormats( rDoc ); - rPaM.GetBound().nContent.Assign(nullptr, 0); rPaM.GetBound(false).nContent.Assign(nullptr, 0); - } try { diff --git a/sw/source/filter/ww8/ww8par4.cxx b/sw/source/filter/ww8/ww8par4.cxx index 8749367ac965..5718d5ac45b4 100644 --- a/sw/source/filter/ww8/ww8par4.cxx +++ b/sw/source/filter/ww8/ww8par4.cxx @@ -263,8 +263,7 @@ SwFrameFormat* SwWW8ImplReader::ImportOle(const Graphic* pGrf, pFlySet = pTempSet.get(); // Remove distance/borders - if (!m_bNewDoc) - Reader::ResetFrameFormatAttrs( *pTempSet ); + Reader::ResetFrameFormatAttrs( *pTempSet ); SwFormatAnchor aAnchor( RndStdIds::FLY_AS_CHAR ); aAnchor.SetAnchor( m_pPaM->GetPoint() ); diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 7947f510c60d..80f81b4b70cf 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -2031,8 +2031,7 @@ WW8FlySet::WW8FlySet(SwWW8ImplReader& rReader, const WW8FlyPara* pFW, const WW8SwFlyPara* pFS, bool bGraf) : SfxItemSet(rReader.m_rDoc.GetAttrPool(),svl::Items<RES_FRMATR_BEGIN,RES_FRMATR_END-1>{}) { - if (!rReader.m_bNewDoc) - Reader::ResetFrameFormatAttrs(*this); // remove distance/border + Reader::ResetFrameFormatAttrs(*this); // remove distance/border // position Put(SvxFrameDirectionItem(SvxFrameDirection::Horizontal_LR_TB, RES_FRAMEDIR)); @@ -2119,8 +2118,7 @@ WW8FlySet::WW8FlySet( SwWW8ImplReader& rReader, const SwPaM* pPaM, void WW8FlySet::Init(const SwWW8ImplReader& rReader, const SwPaM* pPaM) { - if (!rReader.m_bNewDoc) - Reader::ResetFrameFormatAttrs(*this); // remove distance/borders + Reader::ResetFrameFormatAttrs(*this); // remove distance/borders Put(SvxLRSpaceItem(RES_LR_SPACE)); //inline writer ole2 objects start with 0.2cm l/r SwFormatAnchor aAnchor(RndStdIds::FLY_AS_CHAR); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits