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 d9af7661abb3b6c85b39819f27bafa2125884e3e Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Dec 12 00:31:13 2018 +0300 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Thu Dec 13 10:58:47 2018 +0100 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> diff --git a/sw/CppunitTest_sw_ww8import.mk b/sw/CppunitTest_sw_ww8import.mk index 593886526cf9..1e733e1f2feb 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 907fe47ebcff..718c8948645d 100644 --- a/sw/qa/extras/ww8import/ww8import.cxx +++ b/sw/qa/extras/ww8import/ww8import.cxx @@ -13,6 +13,9 @@ #include <ndtxt.hxx> #include <viscrs.hxx> #include <wrtsh.hxx> +#include <editeng/boxitem.hxx> +#include <editeng/lrspitem.hxx> +#include <editeng/ulspitem.hxx> class Test : public SwModelTestBase { @@ -139,6 +142,46 @@ DECLARE_WW8IMPORT_TEST(testTdf112346, "tdf112346.doc") CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xDrawPage->getCount()); } +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 05bf0966dcac..8929ad71fae5 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -6340,12 +6340,8 @@ ErrCode WW8Reader::Read(SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, cons rBaseURL, bNew, 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 8a6bcee8c420..997da5f30f6b 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; // 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 d5d8813ce981..bf0a227dacee 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -2033,8 +2033,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)); @@ -2121,8 +2120,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