diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2019-07-29 20:49:21 +0200 |
---|---|---|
committer | Xisco Faulí <xiscofauli@libreoffice.org> | 2019-08-02 16:41:41 +0200 |
commit | 4927f0c98c4231cb126e6d2e958971dcf5aa5268 (patch) | |
tree | 9d165fde74d630432efb7c6aa8f3b1977ec71ef0 /sw | |
parent | c542a385ce100f8f52a4aff6ab12312f9fbb674e (diff) |
tdf#112535 DOC import: fix handling the have contour but no polygon case
In case a graphic has contour enabled, but there is no wrap polygon,
that means auto-contour in Writer, and no contour in Word, so handle
this difference during DOC import.
Regarding the DOCX import -> DOC export -> DOC import scenario, this
fixes a regression from commit 628a0f313ed05db0149db680837c99267a77ea3c
(DOCX drawingML import: handle SurroundContour shape property,
2014-08-11), though the DOC import part was always broken, I think.
(cherry picked from commit 90928f23994d8fc1d9cc7edf95880782c8ca712a)
Change-Id: I6049fcf5df20736b702de901aef7068826d43f18
Reviewed-on: https://gerrit.libreoffice.org/76579
Tested-by: Jenkins
Reviewed-by: Xisco Faulí <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/CppunitTest_sw_ww8import.mk | 1 | ||||
-rw-r--r-- | sw/qa/extras/ww8import/data/tdf112535.doc | bin | 0 -> 19968 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8import/ww8import.cxx | 20 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8graf.cxx | 8 |
4 files changed, 29 insertions, 0 deletions
diff --git a/sw/CppunitTest_sw_ww8import.mk b/sw/CppunitTest_sw_ww8import.mk index 31a7dcbe80ba..01e0d6b95164 100644 --- a/sw/CppunitTest_sw_ww8import.mk +++ b/sw/CppunitTest_sw_ww8import.mk @@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_ww8import, \ unotest \ vcl \ sfx \ + svl \ sw \ utl \ )) diff --git a/sw/qa/extras/ww8import/data/tdf112535.doc b/sw/qa/extras/ww8import/data/tdf112535.doc Binary files differnew file mode 100644 index 000000000000..4eea19ecd54c --- /dev/null +++ b/sw/qa/extras/ww8import/data/tdf112535.doc diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx index 73495cea2754..bd29b496fea4 100644 --- a/sw/qa/extras/ww8import/ww8import.cxx +++ b/sw/qa/extras/ww8import/ww8import.cxx @@ -15,6 +15,7 @@ #include <viscrs.hxx> #include <wrtsh.hxx> #include <ndgrf.hxx> +#include <fmtsrnd.hxx> #include <editeng/boxitem.hxx> #include <editeng/lrspitem.hxx> #include <editeng/ulspitem.hxx> @@ -85,6 +86,25 @@ DECLARE_WW8IMPORT_TEST(testTdf107773, "tdf107773.doc") CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xDrawPage->getCount()); } +DECLARE_WW8IMPORT_TEST(testTdf112535, "tdf112535.doc") +{ + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + CPPUNIT_ASSERT(pDoc->GetSpzFrameFormats()); + + SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); + CPPUNIT_ASSERT(!rFormats.empty()); + + const SwFrameFormat* pFormat = rFormats[0]; + CPPUNIT_ASSERT(pFormat); + + // Without the accompanying fix in place, this test would have failed: auto-contour was enabled + // in Writer, but not in Word. + CPPUNIT_ASSERT(!pFormat->GetSurround().IsContour()); +} + DECLARE_WW8IMPORT_TEST(testTdf106291, "tdf106291.doc") { // Table cell was merged vertically instead of horizontally -> had incorrect dimensions diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index 3beb1e2f6181..58f72514f147 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -2087,6 +2087,14 @@ void SwWW8ImplReader::MapWrapIntoFlyFormat(SvxMSDffImportRec const * pRecord, pNd->SetContour(&aPoly); } } + else if (pFlyFormat->GetSurround().IsContour()) + { + // Contour is enabled, but no polygon is set: disable contour, because Word does not + // Writer-style auto-contour in that case. + SwFormatSurround aSurround(pFlyFormat->GetSurround()); + aSurround.SetContour(false); + pFlyFormat->SetFormatAttr(aSurround); + } } static sal_Int32 lcl_ConvertCrop(sal_uInt32 const nCrop, sal_Int32 const nSize) |