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.

Change-Id: I6049fcf5df20736b702de901aef7068826d43f18
(cherry picked from commit 5b7b269c5e32abf4fbb6a664453e422e3667f4a3)
Reviewed-on: https://gerrit.libreoffice.org/76566
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
diff --git a/sw/CppunitTest_sw_ww8import.mk b/sw/CppunitTest_sw_ww8import.mk
index 31a7dcb..01e0d6b 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
new file mode 100644
index 0000000..4eea19e
--- /dev/null
+++ b/sw/qa/extras/ww8import/data/tdf112535.doc
Binary files differ
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index 73495cea..bd29b49 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 c9ec0f4..50672e7 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -2089,6 +2089,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)