[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - 2 commits - sw/qa writerfilter/source
Michael Stahl
mstahl at redhat.com
Fri Jun 13 06:43:27 PDT 2014
sw/qa/extras/rtfimport/data/fdo76633.rtf | 32 +++++++++++++++++++
sw/qa/extras/rtfimport/rtfimport.cxx | 12 +++++++
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 41 ++++++++++++++++++-------
writerfilter/source/rtftok/rtfsdrimport.cxx | 11 ++++--
writerfilter/source/rtftok/rtfsdrimport.hxx | 5 ++-
5 files changed, 86 insertions(+), 15 deletions(-)
New commits:
commit 83de5fe9c3161b9bfe655306253fc760fc64e8f3
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Jun 13 14:47:05 2014 +0200
fdo#76633: writerfilter: RTF import: do not leak the XShape of image
RTFSdrImport::resolve() is called for \picprop and creates an XShape
that is stored in RTFSdrImport::m_xShape and also
DomainMapper_Impl::m_aPendingShapes;
later RTFDocumentImpl::resolvePict() completely ignores that XShape
and creates a new one, which is also inserted in the document;
the first XShape is effectively leaked.
Try to avoid that by re-using the exising m_xShape in resolvePict().
Not sure if there are any problems with doing this, it's all a bit
confusing.
Change-Id: I98456242acb0766f547eb8f7d877f51d53323f3a
(cherry picked from commit ba9b63d8101197d3fd8612193b1ca188271dfc1a)
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index e4254e7..8c8f038 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -578,14 +578,11 @@ DECLARE_RTFIMPORT_TEST(testFdo76633, "fdo76633.rtf")
// check that there is only a graphic object, not an additional rectangle
uno::Reference<lang::XServiceInfo> xShape(getShape(1), uno::UNO_QUERY);
CPPUNIT_ASSERT(xShape.is());
-#if 0
- // disabled - fails currently
CPPUNIT_ASSERT(xShape->supportsService("com.sun.star.text.TextGraphicObject"));
try {
uno::Reference<drawing::XShape> xShape2(getShape(2), uno::UNO_QUERY);
CPPUNIT_FAIL("exception expected");
} catch (lang::IndexOutOfBoundsException const&) { /* expected */ }
-#endif
}
DECLARE_RTFIMPORT_TEST(testFdo48033, "fdo48033.rtf")
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 16b09ea..aafc972 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -775,16 +775,29 @@ int RTFDocumentImpl::resolvePict(bool bInline)
// Wrap it in an XShape.
uno::Reference<drawing::XShape> xShape;
- if (m_xModelFactory.is())
- xShape.set(m_xModelFactory->createInstance("com.sun.star.drawing.GraphicObjectShape"), uno::UNO_QUERY);
- uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
- uno::Reference<drawing::XDrawPageSupplier> xDrawSupplier(m_xDstDoc, uno::UNO_QUERY);
- if (xDrawSupplier.is())
+ xShape = m_pSdrImport->getCurrentShape();//Mapper().PopPendingShape();
+ if (xShape.is())
{
- uno::Reference< drawing::XShapes > xShapes(xDrawSupplier->getDrawPage(), uno::UNO_QUERY);
- if (xShapes.is())
- xShapes->add(xShape);
+ uno::Reference<lang::XServiceInfo> xSI(xShape, uno::UNO_QUERY_THROW);
+ assert(xSI->supportsService("com.sun.star.drawing.GraphicObjectShape"));
}
+ else
+ {
+ if (m_xModelFactory.is())
+ xShape.set(m_xModelFactory->createInstance(
+ "com.sun.star.drawing.GraphicObjectShape"), uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPageSupplier> const xDrawSupplier(
+ m_xDstDoc, uno::UNO_QUERY);
+ if (xDrawSupplier.is())
+ {
+ uno::Reference<drawing::XShapes> xShapes(
+ xDrawSupplier->getDrawPage(), uno::UNO_QUERY);
+ if (xShapes.is())
+ xShapes->add(xShape);
+ }
+ }
+
+ uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
// check if the picture is in an OLE object and if the \objdata element is used
// (see RTF_OBJECT in RTFDocumentImpl::dispatchDestination)
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 5d0424a..a47731d 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -226,7 +226,10 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose,
uno::Reference<drawing::XShape> xShape;
uno::Reference<beans::XPropertySet> xPropertySet;
// Create this early, as custom shapes may have properties before the type arrives.
- createShape("com.sun.star.drawing.CustomShape", xShape, xPropertySet);
+ if (PICT == shapeOrPict)
+ createShape("com.sun.star.drawing.GraphicObjectShape", xShape, xPropertySet);
+ else
+ createShape("com.sun.star.drawing.CustomShape", xShape, xPropertySet);
uno::Any aAny;
beans::PropertyValue aPropertyValue;
awt::Rectangle aViewBox;
diff --git a/writerfilter/source/rtftok/rtfsdrimport.hxx b/writerfilter/source/rtftok/rtfsdrimport.hxx
index 770aff4..0b69589 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.hxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.hxx
@@ -43,6 +43,8 @@ public:
void pushParent(css::uno::Reference<css::drawing::XShapes> xParent);
/// Pop the current group shape from the parent stack.
void popParent();
+ css::uno::Reference<css::drawing::XShape> const& getCurrentShape()
+ { return m_xShape; }
private:
void createShape(const OUString& aService, css::uno::Reference<css::drawing::XShape>& xShape, css::uno::Reference<css::beans::XPropertySet>& xPropertySet);
void applyProperty(css::uno::Reference<css::drawing::XShape> xShape, const OUString& aKey, const OUString& aValue);
commit e2cf3ef783a824b0a5733040db91e6ca3eb247b2
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Jun 12 20:37:47 2014 +0200
fdo#76633: writerfilter RTF import: disappear the rectangle shapes on images
If the shape properties are inside \picprop destination, don't set
shapeType.
(regression from 9f1f7199736e2ae07b34849ba66f61a1ef5782e8)
Actually this does not fix the root cause, this is just a work-around,
the extra shape is still inserted but it's invisible now.
Change-Id: I6cf093de2a5657533f393863ed8010ae083bec16
(cherry picked from commit b7857e5cfe9d5d007785ae93e5505620fc8ed475)
diff --git a/sw/qa/extras/rtfimport/data/fdo76633.rtf b/sw/qa/extras/rtfimport/data/fdo76633.rtf
new file mode 100644
index 0000000..d339b12
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo76633.rtf
@@ -0,0 +1,32 @@
+{\rtf1\ansi
+{\*\generator LibreOfficeDev/4.4.0.0.alpha0$Linux_X86_64 LibreOffice_project/b534967caca6767cd2100da363b1da2433640ddd}
+{\*\shppict{\pict{\*\picprop{\sp{\sn wzDescription}{\sv }}{\sp{\sn wzName}{\sv }}}\picscalex100\picscaley100\piccropl0\piccropr0\piccropt0\piccropb0\picw64\pich60\picwgoal1280\pichgoal1200\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}}
+
+\par }
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 49e9687..e4254e7 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -573,6 +573,21 @@ DECLARE_RTFIMPORT_TEST(testFdo52066, "fdo52066.rtf")
CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(19)), xShape->getSize().Height);
}
+DECLARE_RTFIMPORT_TEST(testFdo76633, "fdo76633.rtf")
+{
+ // check that there is only a graphic object, not an additional rectangle
+ uno::Reference<lang::XServiceInfo> xShape(getShape(1), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xShape.is());
+#if 0
+ // disabled - fails currently
+ CPPUNIT_ASSERT(xShape->supportsService("com.sun.star.text.TextGraphicObject"));
+ try {
+ uno::Reference<drawing::XShape> xShape2(getShape(2), uno::UNO_QUERY);
+ CPPUNIT_FAIL("exception expected");
+ } catch (lang::IndexOutOfBoundsException const&) { /* expected */ }
+#endif
+}
+
DECLARE_RTFIMPORT_TEST(testFdo48033, "fdo48033.rtf")
{
/*
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index b83c74a..16b09ea 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1418,7 +1418,8 @@ void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer,
else if (boost::get<0>(aTuple) == BUFFER_PAR)
parBreak();
else if (boost::get<0>(aTuple) == BUFFER_STARTSHAPE)
- m_pSdrImport->resolve(boost::get<1>(aTuple)->getShape(), false);
+ m_pSdrImport->resolve(boost::get<1>(aTuple)->getShape(), false,
+ RTFSdrImport::SHAPE);
else if (boost::get<0>(aTuple) == BUFFER_ENDSHAPE)
m_pSdrImport->close();
else
@@ -1704,7 +1705,8 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
if (nKeyword == RTF_SHPTXT)
{
if (!m_aStates.top().pCurrentBuffer)
- m_pSdrImport->resolve(m_aStates.top().aShape, false);
+ m_pSdrImport->resolve(m_aStates.top().aShape, false,
+ RTFSdrImport::SHAPE);
else
{
RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aShape));
@@ -4843,7 +4845,11 @@ int RTFDocumentImpl::popState()
case DESTINATION_SHAPEINSTRUCTION:
// Don't trigger a shape import in case we're only leaving the \shpinst of the groupshape itself.
if (!m_bObject && !aState.bInListpicture && !aState.bHadShapeText && !(aState.bInShapeGroup && !aState.bInShape))
- m_pSdrImport->resolve(m_aStates.top().aShape, true);
+ {
+ m_pSdrImport->resolve(m_aStates.top().aShape, true,
+ (aState.nDestinationState == DESTINATION_SHAPEINSTRUCTION)
+ ? RTFSdrImport::SHAPE : RTFSdrImport::PICT);
+ }
else if (aState.bInShapeGroup && !aState.bInShape)
{
// End of a groupshape, as we're in shapegroup, but not in a real shape.
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 790fd60..5d0424a 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -215,7 +215,8 @@ void RTFSdrImport::applyProperty(uno::Reference<drawing::XShape> xShape, const O
}
}
-void RTFSdrImport::resolve(RTFShape& rShape, bool bClose)
+void RTFSdrImport::resolve(RTFShape& rShape, bool bClose,
+ ShapeOrPict const shapeOrPict)
{
int nType = -1;
bool bPib = false;
@@ -250,7 +251,8 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose)
sal_Int16 nRelativeHeightRelation = text::RelOrientation::PAGE_FRAME;
// The spec doesn't state what is the default for shapeType, Word seems to implement it as a rectangle.
- if (std::find_if(rShape.aProperties.begin(),
+ if (SHAPE == shapeOrPict &&
+ std::find_if(rShape.aProperties.begin(),
rShape.aProperties.end(),
boost::bind(&OUString::equals, boost::bind(&std::pair<OUString, OUString>::first, _1), OUString("shapeType")))
== rShape.aProperties.end())
diff --git a/writerfilter/source/rtftok/rtfsdrimport.hxx b/writerfilter/source/rtftok/rtfsdrimport.hxx
index 0d36c2b..770aff4 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.hxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.hxx
@@ -25,7 +25,8 @@ public:
RTFSdrImport(RTFDocumentImpl& rImport, css::uno::Reference<css::lang::XComponent> const& xDstDoc);
virtual ~RTFSdrImport();
- void resolve(RTFShape& rShape, bool bClose);
+ enum ShapeOrPict { SHAPE, PICT };
+ void resolve(RTFShape& rShape, bool bClose, ShapeOrPict shapeOrPict);
void close();
void append(const OUString& aKey, const OUString& aValue);
/// Append property on the current parent.
More information about the Libreoffice-commits
mailing list