Kaydet (Commit) f332db68 authored tarafından Miklos Vajna's avatar Miklos Vajna

RTF export: handle wrap polygon of Writer pictures

Change-Id: I712d8f73466c662659a7b76ff363a44a71bba324
üst 34580851
......@@ -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();
......
......@@ -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);
......
......@@ -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 "{");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment