summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-12-12 00:31:13 +0300
committerAndras Timar <andras.timar@collabora.com>2018-12-13 10:58:47 +0100
commitd9af7661abb3b6c85b39819f27bafa2125884e3e (patch)
treec6c284d9d82322c02eaaf6f3d0887c3f1d3d1c3b /sw
parent647a5a3761ad81bc544fa3709a6055c59aa661e9 (diff)
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.kaganski@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/65012 Tested-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/CppunitTest_sw_ww8import.mk1
-rw-r--r--sw/qa/extras/ww8import/data/tdf121734.docbin0 -> 26624 bytes
-rw-r--r--sw/qa/extras/ww8import/ww8import.cxx43
-rw-r--r--sw/source/filter/ww8/ww8par.cxx4
-rw-r--r--sw/source/filter/ww8/ww8par4.cxx3
-rw-r--r--sw/source/filter/ww8/ww8par6.cxx6
6 files changed, 47 insertions, 10 deletions
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
--- /dev/null
+++ b/sw/qa/extras/ww8import/data/tdf121734.doc
Binary files 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);