From f332db6864c1c0f28feb64a7f79b9b4ef3c76b58 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 3 Sep 2014 21:09:37 +0200 Subject: RTF export: handle wrap polygon of Writer pictures Change-Id: I712d8f73466c662659a7b76ff363a44a71bba324 --- .../extras/rtfexport/data/picture-wrap-polygon.rtf | 47 ++++++++++++++++++++++ sw/qa/extras/rtfexport/rtfexport.cxx | 16 ++++++++ .../extras/rtfimport/data/picture-wrap-polygon.rtf | 47 ---------------------- sw/qa/extras/rtfimport/rtfimport.cxx | 15 ------- sw/source/filter/ww8/rtfattributeoutput.cxx | 27 +++++++++++++ 5 files changed, 90 insertions(+), 62 deletions(-) create mode 100644 sw/qa/extras/rtfexport/data/picture-wrap-polygon.rtf delete mode 100644 sw/qa/extras/rtfimport/data/picture-wrap-polygon.rtf (limited to 'sw') diff --git a/sw/qa/extras/rtfexport/data/picture-wrap-polygon.rtf b/sw/qa/extras/rtfexport/data/picture-wrap-polygon.rtf new file mode 100644 index 000000000000..4fec72f206ea --- /dev/null +++ b/sw/qa/extras/rtfexport/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/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 #include #include +#include #include #include #include @@ -664,6 +665,21 @@ DECLARE_RTFEXPORT_TEST(testFdo32613, "fdo32613.odt") CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty(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(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(getShape(1), "HoriOrientPosition")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-67)), getProperty(getShape(1), "VertOrientPosition")); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/rtfimport/data/picture-wrap-polygon.rtf b/sw/qa/extras/rtfimport/data/picture-wrap-polygon.rtf deleted file mode 100644 index 4fec72f206ea..000000000000 --- a/sw/qa/extras/rtfimport/data/picture-wrap-polygon.rtf +++ /dev/null @@ -1,47 +0,0 @@ -{\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 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(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(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(getShape(1), "HoriOrientPosition")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-67)), getProperty(getShape(1), "VertOrientPosition")); -} - DECLARE_RTFIMPORT_TEST(testFdo74229, "fdo74229.rtf") { uno::Reference 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 #include #include +#include #include #include #include @@ -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("shapeType", OString::number(ESCHER_ShpInst_PictureFrame))); aFlyProperties.push_back(std::make_pair("wzDescription", msfilter::rtfutil::OutString(pFlyFrmFmt->GetObjDescription(), m_rExport.eCurrentEncoding))); aFlyProperties.push_back(std::make_pair("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("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("fBehindDocument", "1")); + for (size_t i = 0; i < aFlyProperties.size(); ++i) { m_rExport.Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_SP "{"); -- cgit