diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-08-12 16:48:27 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-08-12 16:54:35 +0200 |
commit | b818256d1c0f467d1064a0ebc1b17d079e74f38a (patch) | |
tree | fe0bd0b6d4027ec496850641c0f78a5dbd402010 /sw | |
parent | 959a843f48be63071c64ba9e20c9389ebc390e81 (diff) |
DOCX export: handle wrap polygon around pictures
Change-Id: I83d9d42cd48ba4dcd86c6506c7dbd6493bb4d204
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/picture-wrap-polygon.docx | bin | 0 -> 15997 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx | 12 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxsdrexport.cxx | 29 |
3 files changed, 41 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/picture-wrap-polygon.docx b/sw/qa/extras/ooxmlexport/data/picture-wrap-polygon.docx Binary files differnew file mode 100644 index 000000000000..f858a05ad8cd --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/picture-wrap-polygon.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx index fc4c1c27fce7..7dfa7adc5191 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx @@ -18,6 +18,7 @@ #include <com/sun/star/drawing/Hatch.hpp> #include <com/sun/star/drawing/LineJoint.hpp> #include <com/sun/star/drawing/LineStyle.hpp> +#include <com/sun/star/drawing/PointSequenceSequence.hpp> #include <com/sun/star/drawing/TextVerticalAdjust.hpp> #include <com/sun/star/style/LineSpacing.hpp> #include <com/sun/star/style/LineSpacingMode.hpp> @@ -1792,6 +1793,17 @@ DECLARE_OOXMLEXPORT_TEST(testWrapTightThrough, "wrap-tight-through.docx") } } +DECLARE_OOXMLEXPORT_TEST(testPictureWrapPolygon, "picture-wrap-polygon.docx") +{ + // The problem was that the wrap polygon was ignored during export. + drawing::PointSequenceSequence aSeqSeq = getProperty<drawing::PointSequenceSequence>(getShape(1), "ContourPolyPolygon"); + // This was 0: the polygon list was empty. + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aSeqSeq.getLength()); + + drawing::PointSequence aSeq = aSeqSeq[0]; + CPPUNIT_ASSERT_EQUAL(sal_Int32(11), aSeq.getLength()); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index 72657451fe29..2c1f7bcbf28d 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -51,6 +51,7 @@ #include <IDocumentDrawModelAccess.hxx> +#include <writerhelper.hxx> using namespace com::sun::star; using namespace oox; @@ -682,6 +683,34 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrmFmt* pFrmFmt, const Size& rS } } + // Or if we have a contour. + if (!nWrapToken && pFrmFmt->GetSurround().IsContour()) + { + if (const SwNoTxtNode* pNd = sw::util::GetNoTxtNodeFromSwFrmFmt(*pFrmFmt)) + { + const PolyPolygon* pPolyPoly = pNd->HasContour(); + if (pPolyPoly && pPolyPoly->Count()) + { + nWrapToken = XML_wrapTight; + m_pImpl->m_pSerializer->startElementNS(XML_wp, nWrapToken, + XML_wrapText, "bothSides", FSEND); + + m_pImpl->m_pSerializer->startElementNS(XML_wp, XML_wrapPolygon, + XML_edited, "0", + FSEND); + Polygon aPoly = sw::util::CorrectWordWrapPolygonForExport(*pPolyPoly, pNd); + for (sal_uInt16 i = 0; i < aPoly.GetSize(); ++i) + m_pImpl->m_pSerializer->singleElementNS(XML_wp, (i == 0 ? XML_start : XML_lineTo), + XML_x, OString::number(aPoly[i].X()), + XML_y, OString::number(aPoly[i].Y()), + FSEND); + m_pImpl->m_pSerializer->endElementNS(XML_wp, XML_wrapPolygon); + + m_pImpl->m_pSerializer->endElementNS(XML_wp, nWrapToken); + } + } + } + // No? Then just approximate based on what we have. if (isAnchor && !nWrapToken) { |