summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-08-16 18:00:21 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-08-16 18:26:00 +0200
commit63fa1a7bc8a99800f490fb4dcd968eeb5710a631 (patch)
treee708c104769a72eb20e98e9de6195df1048de03e
parentdc0149869bc0cc09e92816ae6f34831bf5353e3b (diff)
RTF import: handle pWrapPolygonVertices shape property
Change-Id: I512713e9b9aa1ceb3d98af7a1a6abd144e370689
-rw-r--r--sw/qa/extras/rtfimport/data/picture-wrap-polygon.rtf47
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx16
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx5
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx2
-rw-r--r--writerfilter/source/rtftok/rtfsdrimport.cxx38
5 files changed, 108 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfimport/data/picture-wrap-polygon.rtf b/sw/qa/extras/rtfimport/data/picture-wrap-polygon.rtf
new file mode 100644
index 000000000000..4fec72f206ea
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/picture-wrap-polygon.rtf
@@ -0,0 +1,47 @@
+{\rtf1\pard\plain
+{\shp
+{\*\shpinst\shpleft-1177\shptop-67\shpright1613\shpbottom2723\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr4\shpwrk0\shpfblwtxt1\shpz0\shplid1026
+{\sp{\sn shapeType}{\sv 75}}
+{\sp
+{\sn pib}
+{\sv
+{\pict\picscalex218\picscaley218\piccropl0\piccropr0\piccropt0\piccropb0
+\picw2258\pich2258\picwgoal1280\pichgoal1280\pngblip\bliptag1974568719
+89504e470d0a1a0a0000000d4948445200000040000000400806000000aa6971de0000000473424954080808087c086488000000097048597300000b1200000b
+1201d2dd7efc0000001874455874536f6674776172650041646f62652046697265776f726b734fb31f4e0000059049444154789ced9bdd8bd45518c73fcff9bd
+ccecbc38abbbea14b551a94890a4d04579515646d44d4160443782418410485df50f14417411dde47528845117929ba85d488808dbcb85a5bdd9a6bbae2f3bed
+b8cefce6f73b4f1733b3ad26eeac737676dcf10be7665ece79ce73bee77b9ee739bf9fa82a4dbcfe4da918faec0a3dd966842161694001ab9c8912dd1bc57cf8
+e9d6c258f33b693ae0cd43a56db994ec2ea44d2e1b0a812798c5b2d8312c504b942b9152aad872b9aa3b3e79aab0171a0ed879b8b46d2063f60c663d72a1107a
+82b75466df4062214a9472a45cb8927071dabef2f196c25e79e3e0647155ce9c2ae6bd5c3e6596dcc4af476261aa6a199b4acae7cb76ad9f4bc9ae155993cba5
+0463149dbb8fdb1ac6402e25acb026375dd39dfeb2b4bc940d0423a04b7df60d18816c202c4bc94b7e5f60867c4fb08b6d5587e179423a9435beef118a61c953
+ff7a18038127a12f8dc3bed71c0020023eda3b7bff7f50f02df4dcfe6fc202bea2688f5240517ca537f73fd4e77d670bdc1141dc3240808dcb03d6e43d065286
+52a4fc5a8e397eb1d6754cab8ba04306580b2fde9be29eac37f359211436ad0818ca78ecfbab4adc4574d3ff18d0be5156e1e14270cde46763306dd8b4dce3e8
+855ad7649c1630cd53a0dd564b944756f8371df0a1fe80285127e3b96abe6a7df5da4535864278f3a5cdf8825a71329e0bccda02ed23d67a9a39172c8aa53baa
+8d4e45b0d5556d32ae1b5cd060803a6140abb5a4e678dde0008bbad38056fb7877437ede7d8f5db57c3f5963e4720d71e839a71ab090414eb1cf50ec4b715fc6
+63df6805e3e81875aa019d886fd6177cd6977c4e4ec54e98a00aa6c980765ba74eb647070222ab4e6c9ea907b8d180ceb8a03f3444b13a892615bd3d3460362e
+572d89bab3d95d32d4a13d7062a2561fce916edd560c385d8a393c1e91ed73cc804ec601b782f169cbd1b18803a315b219831137f984d348b0d5947afba149aa
+f3b05e043c03e940c8648430001537779816c5b78e18d06a17858c901899d7396e1a4ef03d0171c736abd4abc29dd4003f1082e0d67201d715ec997a40272341
+e37005dbc5a29c02abd31e7f4789d3a4e6566101dfaa9b485055998e958c7ff3993d3618b06734ee8abaa055add7045de502172a73f3e0f155211bfb8399686e
+319b530d00f86d2a612877e3aaf06c6c7f20c3ba8988e3976b8c4e27448b542a77aa011818b954e3c9bbc2967ebe7965c8e695adfd76ac623971a9c6f07885a4
+1d1baf435d0370a4ca22fc3819538a9442e856e18a69c30b77a7589ff7f8e8f4348923c634ee05b451a76baf214a622c5ffe79d5897137c283799fa7570624ea
+c66645314d0d68b741fdc1a3e17355fe987249d46bb1b13f2449dcd8ecb422640131600278ff87294ad1c2e4878550a839ac0899662ee0a229751694acf2de48
+99a99a7b751f9fb658ebce66677783cd26068250f8bd92f0f6b17f182dbbdd0e87ce55415cde0d3a4a8767433c0852301925bc756c92678a695e5b97211fb477
+3a1c395be5c844953025b8b8d1d6e6c5c842c421c640180ac6c0c1f35586cf56d8b03c64f3ea90fb9779e403433133773c1c5b383919b3ff4c85ef2e45f4a5eb
+a974d795c46e08035e20a43c4812f8e94a8d915f6a58aba86d28f11c5dd40b22f5143a95168c0f2a6ed262b745d19bc0183046f03c080250ad2f61abc38ad4ff
+3bf354ab237b179e01d7c330eb5a6bfe7ad0142e57b080dfecb857d1d802bde982ce6f812e43c744b05ba1ca9d67857d8548a1b5cac4128342e45be58c55d62c
+b6318b01abfc6cacd52f9a995c2f35ab60ad7e25cf0e4f14c33e39653c726efc7a7bc02694ab5775ad39b075702c8ed9d14b2cb00a71cc8ee1ad8363332f4f3f
+ffedc5573d9fdd22f4397171974295ab49cc8efd4f0c7c06b3de1e0778eef0c5a2e7f38e185e166168d1ac5c00a872462d9f27311f7cbd6560e6f5f97f01f618b11f3ea233690000000049454e44ae426082}
+}
+}
+{\sp
+{\sn pWrapPolygonVertices}
+{\sv 8;11;(7781,4181);(5923,4994);(5458,14284);(7200,16839);(15445,16490);(15678,13355);(15910,11497);(16026,7432);(12078,6271);(10219,5110);(7781,4181)}
+}
+{\sp
+{\sn fBehindDocument}
+{\sv 1}
+}
+}
+}
+Suddenly next to him, with a barely noticeable squeak, a door swung quietly to and fro in the night's breeze. Could this be the haven he'd prayed for? Slowly he slid toward the door, pressing himself more and more into the wall, into the dark, away from his enemy. Would this door save his hide?\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 36b29c7c41e5..ba3b581c1d8f 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -15,6 +15,7 @@
#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
+#include <com/sun/star/drawing/PointSequenceSequence.hpp>
#include <com/sun/star/graphic/GraphicType.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/style/BreakType.hpp>
@@ -1902,6 +1903,21 @@ 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"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 92caf868d2eb..7098f04c551c 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -900,6 +900,11 @@ int RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XSh
if (i->first == NS_ooxml::LN_EG_WrapType_wrapNone || i->first == NS_ooxml::LN_EG_WrapType_wrapTight)
{
nWrap = i->first;
+
+ // If there is a wrap polygon prepared by RTFSdrImport, pick it up here.
+ if (i->first == NS_ooxml::LN_EG_WrapType_wrapTight && !m_aStates.top().aShape.aWrapPolygonSprms.empty())
+ i->second->getSprms().set(NS_ooxml::LN_CT_WrapTight_wrapPolygon, RTFValue::Pointer_t(new RTFValue(RTFSprms(), m_aStates.top().aShape.aWrapPolygonSprms)));
+
aAnchorSprms.set(i->first, i->second);
}
}
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index d6bdf9486071..7a720f5b1814 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -139,6 +139,8 @@ public:
int nWrap;
/// If shape is below text (true) or text is below shape (false).
bool bInBackground;
+ /// Wrap polygon, written by RTFSdrImport::resolve(), read by RTFDocumentImpl::resolvePict().
+ RTFSprms aWrapPolygonSprms;
};
/// Stores the properties of a drawing object.
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index ee3f0c33d124..3b530bfb2564 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -712,6 +712,44 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
xPropertySet->setPropertyValue("HoriOrient", uno::makeAny(nHoriOrient));
}
}
+ else if (i->first == "pWrapPolygonVertices")
+ {
+ RTFSprms aPolygonSprms;
+ sal_Int32 nSize = 0; // Size of a token
+ sal_Int32 nCount = 0; // Number of tokens
+ sal_Int32 nCharIndex = 0; // Character index
+ do
+ {
+ OUString aToken = i->second.getToken(0, ';', nCharIndex);
+ if (!nSize)
+ nSize = aToken.toInt32();
+ else if (!nCount)
+ nCount = aToken.toInt32();
+ else if (aToken.getLength())
+ {
+ // The coordinates are in an (x,y) form.
+ aToken = aToken.copy(1, aToken.getLength() - 2);
+ sal_Int32 nI = 0;
+ boost::optional<sal_Int32> oX;
+ boost::optional<sal_Int32> oY;
+ do
+ {
+ OUString aPoint = aToken.getToken(0, ',', nI);
+ if (!oX)
+ oX.reset(aPoint.toInt32());
+ else
+ oY.reset(aPoint.toInt32());
+ }
+ while (nI >= 0);
+ RTFSprms aPathAttributes;
+ aPathAttributes.set(NS_ooxml::LN_CT_Point2D_x, RTFValue::Pointer_t(new RTFValue(*oX)));
+ aPathAttributes.set(NS_ooxml::LN_CT_Point2D_y, RTFValue::Pointer_t(new RTFValue(*oY)));
+ aPolygonSprms.set(NS_ooxml::LN_CT_WrapPath_lineTo, RTFValue::Pointer_t(new RTFValue(aPathAttributes)), OVERWRITE_NO_APPEND);
+ }
+ }
+ while (nCharIndex >= 0);
+ rShape.aWrapPolygonSprms = aPolygonSprms;
+ }
else
SAL_INFO("writerfilter", "TODO handle shape property '" << i->first << "':'" << i->second << "'");
}