summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-12-12 00:31:13 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2018-12-12 05:51:53 +0100
commitd398e9248c183cf988b6d985b342b0cbff93ea02 (patch)
tree6750cb396ae1baabf22184ee26ddd58c888a29ff /sw
parent3c964980da07892a02d5ac721d80558c459532d0 (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>
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 1ccc1a3f20aa..bb73e4230da0 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 de16cfe253e6..cd07887669bd 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
{
@@ -147,6 +150,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 b1174771c554..16c7850adce7 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -6319,12 +6319,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 822597dd246f..2bcc42f4987a 100644
--- a/sw/source/filter/ww8/ww8par4.cxx
+++ b/sw/source/filter/ww8/ww8par4.cxx
@@ -264,8 +264,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 c16fdc6f7953..32b822aee523 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -2056,8 +2056,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));
@@ -2144,8 +2143,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);