summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-07-15 23:36:51 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-07-16 20:48:37 +0000
commit88cf46be3d1ad709cf822e209d0911d6a71f3222 (patch)
treecd0bcf79183b35789276d4c44bd8422bbb71afe6
parentb2e0120140db580b30ae78914b5f5d80ca9b1f6c (diff)
fdo#80924: writerfilter: RTF import: fix shapeType PictureFrame import
For shapeType PictureFrame, a default CustomShape was created and then RTFDocumentImpl::resolvePict() crashes because it actually operates on a previous shape, because in this special case RTFSdrImport::m_xShape is never actually set to the new shape, so contains the previous one. Also the new shape needs to be added to the draw-page, at least otherwise the assertion of the supported service fails because some SvxShape::mpObj weak-reference is dead? This essentially reverts commit 3cab1adf19d553663685e8198f0ec3f258a37c36 (except for the added testcase, which was slightly different because it did not have a "pib" property). (regression from ba9b63d8101197d3fd8612193b1ca188271dfc1a) (cherry picked from commit 083b2b1471fff9e75f4b27a8769f95b8a0ebf5a1) Conflicts: writerfilter/source/rtftok/rtfdocumentimpl.cxx Change-Id: I6539c4286850dff2d8564006487cc765f1d117be Reviewed-on: https://gerrit.libreoffice.org/10351 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/qa/core/data/rtf/pass/fdo80924.rtf43
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx14
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx3
-rw-r--r--writerfilter/source/rtftok/rtfsdrimport.cxx17
4 files changed, 65 insertions, 12 deletions
diff --git a/sw/qa/core/data/rtf/pass/fdo80924.rtf b/sw/qa/core/data/rtf/pass/fdo80924.rtf
new file mode 100644
index 000000000000..cbaeb442cee4
--- /dev/null
+++ b/sw/qa/core/data/rtf/pass/fdo80924.rtf
@@ -0,0 +1,43 @@
+{\rtf1\ansi\ansicpg1252\uc1
+{\*\generator Microsoft Word 11.0.5604;}
+{\info{\author Crystal Reports}{\doccomm Powered By Crystal}}
+\pard\plain {
+\lang1024\langfe1024\noproof\insrsid10428813
+{\shp{\*\shpinst\shpleft306\shptop16065\shpright11251\shpbottom16065\shpfhdr0\shpbxpage\shpbxignore\shpbypage\shpbyignore\shpwr3\shpwrk0\shpfblwtxt1\shpz1\shplid1026
+{\sp{\sn shapeType}{\sv 20}}{\sp{\sn fFlipH}{\sv 0}}{\sp{\sn fFlipV}{\sv 0}}{\sp{\sn lineWidth}{\sv 12700}}{\sp{\sn fLine}{\sv 1}}{\sp{\sn posrelh}{\sv 1}}{\sp{\sn posrelv}{\sv 1}}{\sp{\sn fLayoutInCell}{\sv 0}}{\sp{\sn fBehindDocument}{\sv 1}}
+{\sp{\sn fLayoutInCell}{\sv 0}}}}
+}
+\pard
+{\shp{\*\shpinst\shpleft4920\shptop850\shpright6264\shpbottom1858\shpfhdr0\shpbxpage\shpbxignore\shpbypage\shpbyignore\shpwr3\shpwrk0\shpfblwtxt1\shpz2\shplid1027{\sp{\sn shapeType}{\sv 75}}{\sp{\sn fFlipH}{\sv 0}}{\sp{\sn fFlipV}{\sv 0}}
+{\sp{\sn pib}{\sv {\pict\picscalex30\picscaley30\piccropl0\piccropr0\piccropt0\piccropb0\picw7939\pich5953\picwgoal4501\pichgoal3375
+\jpegblip
+ffd8ffe000104a46494600010101004800480000ffe101604578696600004d4d002a000000080009010e00020000000100000000010f0002000000060000007a
+011000020000001500000080011200030000000100010000011a00050000000100000096011b0005000000010000009e01280003000000010002000001310002
+0000000c000000a68769000400000001000000b20000000043616e6f6e0043616e6f6e20506f77657253686f7420413531300000000000480000000100000048
+0000000147494d5020322e362e3131000009829a00050000000100000124829d0005000000010000012c88270003000000010000000090000007000000043032
+3130900300020000001400000134920a00050000000100000148928600070000000800000150a00000070000000430313030a001000300000001ffff00000000
+00000051eb85ffffffff0000000400000001323031313a30363a31322031393a32363a3436000000001000000001554e49434f444500ffdb0043000806060706
+05080707070909080a0c140d0c0b0b0c1912130f141d1a1f1e1d1a1c1c20242e2720222c231c1c2837292c30313434341f27393d38323c2e333432ffdb004301
+0909090c0b0c180d0d1832211c213232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232
+ffc0001108003c004003012200021101031101ffc4001a000002030101000000000000000000000004050203060100ffc4003210000201030302050302050500
+000000000102030004110512213151132241617106143242911523a1c1e17281b1d1f0ffc400190101010101010100000000000000000000010200030405ffc4
+001d110002020203010000000000000000000000010211213103225141ffda000c03010002110311003f007e1df6912a2c9e8372f27fdc509731bc571f731065
+8b1b668f180bcf0c3e3d7da99c6ca3cf24783ed5cbd1b6d8c91287232319ea3b7c57cc3d82cbdd5adecf62c9b9e50be6551d3e6975d7d49163f976ec47405985
+461fa6defa797c49e73264332a614007b64e71e993da8a6fa26d9b02459ca8f533e7fe055df1ad93d9e81edbea8831992270c060ed20d7351d76316ea6c9f6cb
+2379ba7007b50b7bf467dabaf812c881f254b9ca8f63eb54e816da6dd4d2e9978a535589cf926fc5d7b2907b7355d2ad076d0136b5746e15da77dcbd8fbf6ada
+0769144858052a0e3b8a51aae876a34b98ac31c4f1a92194739a274f995b4cb7594296f0c0233d7ff62a66d35686298dadc1958a89627e7aa9dbd7d0a9fed5c9
+199565555c323608cf0738ff001553b9824dc5778f6f37a54cb89e4dfbcf9941f4c71dea1942c86ff1acc9340764817c2970bc9c72323f7a7aba84aea4e0678e
+0f18acb5bec3acdeba070e1b1c0e09029c2baf86482aa71fa813fd3d6a65156298d3ee5a67db22a6d230ca4fe5599fa8fe985bb432443c2b98fcd6f32b727d42
+934c22994b30cb021b9214f1c7bfad1e2fa27b6922b91cc433b80f6c8c0ef5a2dc5e0cf3b10e8badaeb7612595f0116ab0a14911b8f1401f97cf7ab6cadd52d8
+44e780be50f80323af3e99a5b7f6f8d5edb53b3c7de6e2bb0ae04a30723fd445398d0f86889e424701b079aa963408b2662a049092c18ed200cd4236731c4f9c
+7246339aba1b83185049f7e7d4f7cd0f730cd736720b6f0dd8e498d9f6ab8edd29fa0cc83eb725bdd4a2d88f348497c641f807a579b59bb698399873fa71c0cf
+b502da16b0d3304b275009e0b00073e849a99d175a4600d8bf27960ca40f9e6bbd44e76c3df57ba38669cee1ea3028cd2f5dbcbabb4b090f8aae0e18e015e339
+f7ff00349a6d1355455678939e021917767f7a23e9bb37fe2c65b872823181b39e4fa1ed44a31a14dd9a2d4d360b62ea1b1386ebedd28a376890659d843fa8c9
+d71ff79a13584630c1b18bb8940c28f53d28a8bc4306638f3819219871f39e95c19d11631324061207dc6762b95cec61dc0f71fd69969f0d9ff0f8e2ba01655d
+d9c291ce4f208e71cd7a3b48597c464cbb1de5ba1cf1daaefb189433465e321b8d871d41a993148b25d26d76f98b0e47490f3f3533a4da642a028e0648ce78a5
+1717973671954999f613867e49c9c609edc554faadda40ec24e9818f91454bd3606efa05a4cd993c49075db9c0c8f8aea68f681b7a0973c91e62c47ef40a5ecc
+d023b90c73b79cf4aaef6e678d86d95c33851bb3c8cf6f4a5a97a6c1ed6ece3b7804b02ac9b86c1c12d93c8c01d7a1a147871a239dc84f250b647b64d4e79a53
+0c71072a646c175fc8704e476e959db6bdb892cd54c9b40214ed00646ec7f7aa8a6d03747fffd9
+}}}{\sp{\sn posrelh}{\sv 1}}{\sp{\sn posrelv}{\sv 1}}{\sp{\sn fLayoutInCell}{\sv 0}}
+{\sp{\sn fBehindDocument}{\sv 1}}{\sp{\sn fLayoutInCell}{\sv 0}}}}
+\par }
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index befbb4204a89..c53174e2487e 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -705,7 +705,8 @@ void RTFDocumentImpl::resolve(Stream& rMapper)
}
}
-int RTFDocumentImpl::resolvePict(bool bInline)
+int RTFDocumentImpl::resolvePict(bool const bInline,
+ uno::Reference<drawing::XShape> const& i_xShape)
{
SvMemoryStream aStream;
SvStream* pStream = 0;
@@ -778,16 +779,13 @@ int RTFDocumentImpl::resolvePict(bool bInline)
}
// Wrap it in an XShape.
- uno::Reference<drawing::XShape> xShape;
- xShape = m_pSdrImport->getCurrentShape();
+ uno::Reference<drawing::XShape> xShape(i_xShape);
if (xShape.is())
{
uno::Reference<lang::XServiceInfo> xSI(xShape, uno::UNO_QUERY_THROW);
- if(!xSI->supportsService("com.sun.star.drawing.GraphicObjectShape"))
- xShape.clear();
+ assert(xSI->supportsService("com.sun.star.drawing.GraphicObjectShape"));
}
-
- if (!xShape.is())
+ else
{
if (m_xModelFactory.is())
xShape.set(m_xModelFactory->createInstance(
@@ -4944,7 +4942,7 @@ int RTFDocumentImpl::popState()
Mapper().props(lcl_getBookmarkProperties(m_aBookmarks[m_aStates.top().aDestinationText.makeStringAndClear()]));
break;
case DESTINATION_PICT:
- resolvePict(true);
+ resolvePict(true, m_pSdrImport->getCurrentShape());
break;
case DESTINATION_FORMFIELDNAME:
{
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index b86c54f950ae..1e8a46e34bab 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -356,7 +356,8 @@ public:
bool isInBackground();
void setDestinationText(OUString& rString);
/// Resolve a picture: If not inline, then anchored.
- int resolvePict(bool bInline);
+ int resolvePict(bool bInline,
+ css::uno::Reference<css::drawing::XShape> const& xShape);
/// If this is the first run of the document, starts the initial paragraph.
void checkFirstRun();
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index a47731d9c7a0..5edf4254c5d7 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -269,6 +269,9 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose,
nType = i->second.toInt32();
switch (nType)
{
+ case ESCHER_ShpInst_PictureFrame:
+ createShape("com.sun.star.drawing.GraphicObjectShape", xShape, xPropertySet);
+ break;
case ESCHER_ShpInst_Line:
createShape("com.sun.star.drawing.LineShape", xShape, xPropertySet);
break;
@@ -653,15 +656,23 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose,
xPropertySet->setPropertyValue("TextWritingMode", uno::makeAny(eWritingMode));
}
+ if (m_aParents.size() && m_aParents.top().is() && !m_bTextFrame)
+ m_aParents.top()->add(xShape);
+
if (nType == ESCHER_ShpInst_PictureFrame) // picture frame
{
+ assert(!m_bTextFrame);
if (bPib)
- m_rImport.resolvePict(false);
+ {
+ m_rImport.resolvePict(false, xShape);
+ }
+ else // ??? not sure if the early return should be removed on else?
+ {
+ m_xShape = xShape; // store it for later resolvePict call
+ }
return;
}
- if (m_aParents.size() && m_aParents.top().is() && !m_bTextFrame)
- m_aParents.top()->add(xShape);
if (bCustom && xShape.is())
{
uno::Reference<drawing::XEnhancedCustomShapeDefaulter> xDefaulter(xShape, uno::UNO_QUERY);