From ec8c747b457c2b1161b875474d2ba4e15819a3c7 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 16 Aug 2014 17:53:34 +0200 Subject: fdo#82067 RTF import: handle negative SHPLEFT / SHPTOP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit dc0149869bc0cc09e92816ae6f34831bf5353e3b) Change-Id: Id82d6d54b160b5b78a53c526e6ccab0514c21312 Reviewed-on: https://gerrit.libreoffice.org/11283 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- .../extras/rtfimport/data/picture-wrap-polygon.rtf | 47 ++++++++++++++++++++++ sw/qa/extras/rtfimport/rtfimport.cxx | 8 ++++ writerfilter/source/rtftok/rtfdocumentimpl.cxx | 4 +- 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 sw/qa/extras/rtfimport/data/picture-wrap-polygon.rtf 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 ad42e6c94754..12c6b521ff05 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -1879,6 +1880,13 @@ DECLARE_RTFIMPORT_TEST(testFdo82106, "fdo82106.rtf") getParagraph(2, "before\tafter"); } +DECLARE_RTFIMPORT_TEST(testPictureWrapPolygon, "picture-wrap-polygon.rtf") +{ + // The shape also didn't have negative top / left coordinates. + CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-1177)), getProperty(getShape(1), "HoriOrientPosition")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-67)), getProperty(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 94e518a4a721..62a779486d0b 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -925,14 +925,14 @@ int RTFDocumentImpl::resolvePict(bool const bInline, RTFSprms aPoshSprms; if (m_aStates.top().aShape.nHoriOrientRelationToken > 0) aPoshSprms.set(NS_ooxml::LN_CT_PosH_relativeFrom, RTFValue::Pointer_t(new RTFValue(m_aStates.top().aShape.nHoriOrientRelationToken))); - if (m_aStates.top().aShape.nLeft > 0) + if (m_aStates.top().aShape.nLeft != 0) writerfilter::dmapper::PositionHandler::setPositionOffset(OUString::number(MM100_TO_EMU(m_aStates.top().aShape.nLeft)), false); aAnchorSprms.set(NS_ooxml::LN_CT_Anchor_positionH, RTFValue::Pointer_t(new RTFValue(aPoshSprms))); RTFSprms aPosvSprms; if (m_aStates.top().aShape.nVertOrientRelationToken > 0) aPosvSprms.set(NS_ooxml::LN_CT_PosV_relativeFrom, RTFValue::Pointer_t(new RTFValue(m_aStates.top().aShape.nVertOrientRelationToken))); - if (m_aStates.top().aShape.nTop > 0) + if (m_aStates.top().aShape.nTop != 0) writerfilter::dmapper::PositionHandler::setPositionOffset(OUString::number(MM100_TO_EMU(m_aStates.top().aShape.nTop)), true); aAnchorSprms.set(NS_ooxml::LN_CT_Anchor_positionV, RTFValue::Pointer_t(new RTFValue(aPosvSprms))); -- cgit v1.2.3