[Libreoffice-commits] core.git: 3 commits - sw/qa sw/source writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Aug 12 07:55:12 PDT 2014
sw/qa/extras/ooxmlexport/data/picture-wrap-polygon.docx |binary
sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx | 12 ++++++
sw/source/filter/ww8/docxsdrexport.cxx | 29 +++++++++++++++
sw/source/filter/ww8/writerhelper.cxx | 30 ++++++++++++++++
sw/source/filter/ww8/writerhelper.hxx | 3 +
sw/source/filter/ww8/wrtw8esh.cxx | 27 --------------
writerfilter/source/ooxml/model.xml | 1
7 files changed, 75 insertions(+), 27 deletions(-)
New commits:
commit b818256d1c0f467d1064a0ebc1b17d079e74f38a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Aug 12 16:48:27 2014 +0200
DOCX export: handle wrap polygon around pictures
Change-Id: I83d9d42cd48ba4dcd86c6506c7dbd6493bb4d204
diff --git a/sw/qa/extras/ooxmlexport/data/picture-wrap-polygon.docx b/sw/qa/extras/ooxmlexport/data/picture-wrap-polygon.docx
new file mode 100644
index 0000000..f858a05
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/picture-wrap-polygon.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
index fc4c1c2..7dfa7ad 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 7265745..2c1f7bc 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)
{
commit 959a843f48be63071c64ba9e20c9389ebc390e81
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Aug 12 11:40:13 2014 +0200
DOC export: factor out wrap polygon handling to to sw::util
So that it'll be possible to reuse it in the DOCX exporter.
Change-Id: Ib7371c92c4fd93d7c6f3271ca81311bac8f1a1a7
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx
index 015b076..85891c3 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -660,6 +660,36 @@ namespace sw
}
}
+ Polygon CorrectWordWrapPolygonForExport(const PolyPolygon& rPolyPoly, const SwNoTxtNode* pNd)
+ {
+ Polygon aPoly(PolygonFromPolyPolygon(rPolyPoly));
+ const Size &rOrigSize = pNd->GetGraphic().GetPrefSize();
+ Fraction aMapPolyX(ww::nWrap100Percent, rOrigSize.Width());
+ Fraction aMapPolyY(ww::nWrap100Percent, rOrigSize.Height());
+ aPoly.Scale(aMapPolyX, aMapPolyY);
+
+ /*
+ a) stretch right bound by 15twips
+ b) shrink bottom bound to where it would have been in word
+ c) Move it to the left by 15twips
+
+ See the import for details
+ */
+ const Size &rSize = pNd->GetTwipSize();
+ Fraction aMoveHack(ww::nWrap100Percent, rSize.Width());
+ aMoveHack *= Fraction(15, 1);
+ long nMove(aMoveHack);
+
+ Fraction aHackX(ww::nWrap100Percent + nMove,
+ ww::nWrap100Percent);
+ Fraction aHackY(ww::nWrap100Percent - nMove,
+ ww::nWrap100Percent);
+ aPoly.Scale(aHackX, aHackY);
+
+ aPoly.Move(-nMove, 0);
+ return aPoly;
+ }
+
Size GetSwappedInSize(const SwNoTxtNode& rNd)
{
Size aGrTwipSz(rNd.GetTwipSize());
diff --git a/sw/source/filter/ww8/writerhelper.hxx b/sw/source/filter/ww8/writerhelper.hxx
index 8a99413..5928499 100644
--- a/sw/source/filter/ww8/writerhelper.hxx
+++ b/sw/source/filter/ww8/writerhelper.hxx
@@ -741,6 +741,9 @@ namespace sw
*/
Polygon PolygonFromPolyPolygon(const PolyPolygon &rPolyPoly);
+ /// Undo all scaling / move tricks of the wrap polygon done during import.
+ Polygon CorrectWordWrapPolygonForExport(const PolyPolygon& rPolyPoly, const SwNoTxtNode* pNd);
+
/** Make setting a drawing object's layer in a Writer document easy
Word has the simple concept of a drawing object either in the
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index 0808b15..18f0591 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -2106,32 +2106,7 @@ sal_Int32 SwEscherEx::WriteFlyFrameAttr(const SwFrmFmt& rFmt, MSO_SPT eShapeType
const PolyPolygon *pPolyPoly = pNd->HasContour();
if (pPolyPoly && pPolyPoly->Count())
{
- Polygon aPoly(PolygonFromPolyPolygon(*pPolyPoly));
- const Size &rOrigSize = pNd->GetGraphic().GetPrefSize();
- Fraction aMapPolyX(ww::nWrap100Percent, rOrigSize.Width());
- Fraction aMapPolyY(ww::nWrap100Percent, rOrigSize.Height());
- aPoly.Scale(aMapPolyX, aMapPolyY);
-
- /*
- a) stretch right bound by 15twips
- b) shrink bottom bound to where it would have been in word
- c) Move it to the left by 15twips
-
- See the import for details
- */
- const Size &rSize = pNd->GetTwipSize();
- Fraction aMoveHack(ww::nWrap100Percent, rSize.Width());
- aMoveHack *= Fraction(15, 1);
- long nMove(aMoveHack);
-
- Fraction aHackX(ww::nWrap100Percent + nMove,
- ww::nWrap100Percent);
- Fraction aHackY(ww::nWrap100Percent - nMove,
- ww::nWrap100Percent);
- aPoly.Scale(aHackX, aHackY);
-
- aPoly.Move(-nMove, 0);
-
+ Polygon aPoly = CorrectWordWrapPolygonForExport(*pPolyPoly, pNd);
SvMemoryStream aPolyDump;
aPolyDump.SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
commit bea342be301063d761f95177d8b65c88a52d1a1e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Aug 12 09:26:04 2014 +0200
Remove unused default element
Change-Id: I703f54ef8640f9be70f16441c330e53fce3f7489
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index f2b8aeb..4763305 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -18228,7 +18228,6 @@
<resource name="ST_Merge" resource="List">
<value tokenid="ooxml:Value_ST_Merge_continue">continue</value>
<value tokenid="ooxml:Value_ST_Merge_restart">restart</value>
- <default tokenid="ooxml:Value_ST_Merge_continue"/>
</resource>
<resource name="CT_VMerge" resource="Value">
<attribute name="val" tokenid="ooxml:CT_VMerge_val" action="setValue"/>
More information about the Libreoffice-commits
mailing list