diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-09-03 21:09:37 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-09-03 21:25:00 +0200 |
commit | f332db6864c1c0f28feb64a7f79b9b4ef3c76b58 (patch) | |
tree | 4279d476de7a35dbb19a3722f7f8ac58a26845de /sw | |
parent | 34580851065fc04af25e9c83a1106d1478f159e0 (diff) |
RTF export: handle wrap polygon of Writer pictures
Change-Id: I712d8f73466c662659a7b76ff363a44a71bba324
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/rtfexport/data/picture-wrap-polygon.rtf (renamed from sw/qa/extras/rtfimport/data/picture-wrap-polygon.rtf) | 0 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport.cxx | 16 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/rtfimport.cxx | 15 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.cxx | 27 |
4 files changed, 43 insertions, 15 deletions
diff --git a/sw/qa/extras/rtfimport/data/picture-wrap-polygon.rtf b/sw/qa/extras/rtfexport/data/picture-wrap-polygon.rtf index 4fec72f206ea..4fec72f206ea 100644 --- a/sw/qa/extras/rtfimport/data/picture-wrap-polygon.rtf +++ b/sw/qa/extras/rtfexport/data/picture-wrap-polygon.rtf diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index 644abaae7a08..63df38948632 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -14,6 +14,7 @@ #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp> #include <com/sun/star/drawing/FillStyle.hpp> +#include <com/sun/star/drawing/PointSequenceSequence.hpp> #include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/table/ShadowFormat.hpp> @@ -664,6 +665,21 @@ DECLARE_RTFEXPORT_TEST(testFdo32613, "fdo32613.odt") CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType")); } +DECLARE_RTFEXPORT_TEST(testPictureWrapPolygon, "picture-wrap-polygon.rtf") +{ + // The problem was that the wrap polygon was ignored during import. + 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()); + + // The shape also didn't have negative top / left coordinates. + CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-1177)), getProperty<sal_Int32>(getShape(1), "HoriOrientPosition")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-67)), getProperty<sal_Int32>(getShape(1), "VertOrientPosition")); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 64e2b046ac44..b2ed3d98e845 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -1903,21 +1903,6 @@ DECLARE_RTFIMPORT_TEST(testBehindDoc, "behind-doc.rtf") CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xShape, "Opaque")); } -DECLARE_RTFIMPORT_TEST(testPictureWrapPolygon, "picture-wrap-polygon.rtf") -{ - // The problem was that the wrap polygon was ignored during import. - 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()); - - // The shape also didn't have negative top / left coordinates. - CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-1177)), getProperty<sal_Int32>(getShape(1), "HoriOrientPosition")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-67)), getProperty<sal_Int32>(getShape(1), "VertOrientPosition")); -} - DECLARE_RTFIMPORT_TEST(testFdo74229, "fdo74229.rtf") { uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 7bd31cb537e2..308e1f2f462d 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -65,6 +65,7 @@ #include <editeng/blinkitem.hxx> #include <editeng/charhiddenitem.hxx> #include <editeng/shaditem.hxx> +#include <editeng/opaqitem.hxx> #include <svx/svdmodel.hxx> #include <svx/fmglob.hxx> #include <svx/svdouno.hxx> @@ -2866,6 +2867,10 @@ void RtfAttributeOutput::FormatSurround(const SwFmtSurround& rSurround) oWrk = 3; // largest break; } + + if (rSurround.IsContour()) + nWr = 4; // tight + m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPWR); m_rExport.OutLong(nWr); if (oWrk) @@ -3721,6 +3726,28 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw aFlyProperties.push_back(std::make_pair<OString, OString>("shapeType", OString::number(ESCHER_ShpInst_PictureFrame))); aFlyProperties.push_back(std::make_pair<OString, OString>("wzDescription", msfilter::rtfutil::OutString(pFlyFrmFmt->GetObjDescription(), m_rExport.eCurrentEncoding))); aFlyProperties.push_back(std::make_pair<OString, OString>("wzName", msfilter::rtfutil::OutString(pFlyFrmFmt->GetObjTitle(), m_rExport.eCurrentEncoding))); + + // If we have a wrap polygon, then handle that here. + if (pFlyFrmFmt->GetSurround().IsContour()) + { + if (const SwNoTxtNode* pNd = sw::util::GetNoTxtNodeFromSwFrmFmt(*pFlyFrmFmt)) + { + const PolyPolygon* pPolyPoly = pNd->HasContour(); + if (pPolyPoly && pPolyPoly->Count()) + { + Polygon aPoly = sw::util::CorrectWordWrapPolygonForExport(*pPolyPoly, pNd); + OStringBuffer aVerticies; + for (sal_uInt16 i = 0; i < aPoly.GetSize(); ++i) + aVerticies.append(";(").append(aPoly[i].X()).append(",").append(aPoly[i].Y()).append(")"); + aFlyProperties.push_back(std::make_pair<OString, OString>("pWrapPolygonVertices", "8;" + OString::number(aPoly.GetSize()) + aVerticies.makeStringAndClear())); + } + } + } + + // Below text, behind document, opaque: they all refer to the same thing. + if (!pFlyFrmFmt->GetOpaque().GetValue()) + aFlyProperties.push_back(std::make_pair<OString, OString>("fBehindDocument", "1")); + for (size_t i = 0; i < aFlyProperties.size(); ++i) { m_rExport.Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_SP "{"); |