summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-08-11 16:19:23 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-08-11 17:16:17 +0200
commit47e1ba312b8d87dfb019104429416edaac139786 (patch)
treedd3086b7940ff44e2e6672416c2fab4a320544a0 /sw
parente24f8bb11ac1894556ddefb2dd8854939c4190eb (diff)
DOCX drawingML export: handle ContourPolyPolygon for drawinglayer shapes
Change-Id: I04438e4c32d001b989d3d3b8aec882ec57dc28b9
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/wrap-tight-through.docxbin0 -> 18524 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx12
-rw-r--r--sw/source/filter/ww8/docxsdrexport.cxx49
3 files changed, 60 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/wrap-tight-through.docx b/sw/qa/extras/ooxmlexport/data/wrap-tight-through.docx
new file mode 100644
index 000000000000..1ea9e14788e0
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/wrap-tight-through.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
index a6b73427b1e1..fc4c1c27fce7 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
@@ -1780,6 +1780,18 @@ DECLARE_OOXMLEXPORT_TEST(testfdo80895, "fdo80895.docx")
assertXPath(pXmlDoc, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:rect/v:fill", "type", "solid");
}
+DECLARE_OOXMLEXPORT_TEST(testWrapTightThrough, "wrap-tight-through.docx")
+{
+ // These were wrapSquare without a wrap polygon before.
+ if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
+ {
+ // The first shape should be wrapThrough with a wrap polygon (was wrapSquare).
+ assertXPath(pXmlDoc, "//w:drawing/wp:anchor[1]/wp:wrapThrough/wp:wrapPolygon/wp:start", "x", "-1104");
+ // The second shape should be wrapTight with a wrap polygon (was wrapSquare).
+ assertXPath(pXmlDoc, "//w:drawing/wp:anchor[1]/wp:wrapTight/wp:wrapPolygon/wp:start", "y", "792");
+ }
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index 181c12b49b71..72657451fe29 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -8,6 +8,7 @@
*/
#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/drawing/PointSequenceSequence.hpp>
#include <com/sun/star/xml/dom/XDocument.hpp>
#include <com/sun/star/xml/sax/XSAXSerializable.hpp>
#include <com/sun/star/xml/sax/Writer.hpp>
@@ -46,6 +47,7 @@
#include <docxexportfilter.hxx>
#include <writerhelper.hxx>
#include <comphelper/seqstream.hxx>
+#include <comphelper/sequenceasvector.hxx>
#include <IDocumentDrawModelAccess.hxx>
@@ -636,7 +638,52 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrmFmt* pFrmFmt, const Size& rS
XML_b, aBottomExt,
FSEND);
- if (isAnchor)
+ // See if we know the exact wrap type from grab-bag.
+ sal_Int32 nWrapToken = 0;
+ if (const SdrObject* pObject = pFrmFmt->FindRealSdrObject())
+ {
+ uno::Any aAny;
+ pObject->GetGrabBagItem(aAny);
+ comphelper::SequenceAsHashMap aGrabBag(aAny);
+ comphelper::SequenceAsHashMap::iterator it = aGrabBag.find("EG_WrapType");
+ if (it != aGrabBag.end())
+ {
+ OUString sType = it->second.get<OUString>();
+ if (sType == "wrapTight")
+ nWrapToken = XML_wrapTight;
+ else if (sType == "wrapThrough")
+ nWrapToken = XML_wrapThrough;
+ else
+ SAL_WARN("sw.ww8", "DocxSdrExport::startDMLAnchorInline: unexpected EG_WrapType value");
+
+ m_pImpl->m_pSerializer->startElementNS(XML_wp, nWrapToken,
+ XML_wrapText, "bothSides", FSEND);
+
+ it = aGrabBag.find("CT_WrapPath");
+ if (it != aGrabBag.end())
+ {
+ m_pImpl->m_pSerializer->startElementNS(XML_wp, XML_wrapPolygon,
+ XML_edited, "0",
+ FSEND);
+ drawing::PointSequenceSequence aSeqSeq = it->second.get< drawing::PointSequenceSequence >();
+ comphelper::SequenceAsVector<awt::Point> aPoints(aSeqSeq[0]);
+ for (comphelper::SequenceAsVector<awt::Point>::iterator i = aPoints.begin(); i != aPoints.end(); ++i)
+ {
+ awt::Point& rPoint = *i;
+ m_pImpl->m_pSerializer->singleElementNS(XML_wp, (i == aPoints.begin() ? XML_start : XML_lineTo),
+ XML_x, OString::number(rPoint.X),
+ XML_y, OString::number(rPoint.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)
{
switch (pFrmFmt->GetSurround().GetValue())
{