summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime de Roucy <mderoucy@linagora.com>2013-02-20 14:27:47 +0100
committerMiklos Vajna <vmiklos@suse.cz>2013-02-25 11:09:00 +0100
commit04a761f330b6ff17a125cc5522e71aae86a862f9 (patch)
tree3ce746ebb209e25332df1456f1b8fa90c28f7aa3
parent67b069cf42b990f47af0a2de4f9cb0bc5e44eeab (diff)
fdo#53594 RTF IMPORT : considere OLE objects as pictures
If the OLE object is in a container, don't try to import it as OLE object (use the \objdata element) but use the \result element which is the appareance of the object (it's a picture). Change-Id: Id97b36ce89beae02885cf82383321c14b58f2ea5 Reviewed-on: https://gerrit.libreoffice.org/2243 Reviewed-by: Miklos Vajna <vmiklos@suse.cz> Tested-by: Miklos Vajna <vmiklos@suse.cz> Signed-off-by: Miklos Vajna <vmiklos@suse.cz>
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx41
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx4
2 files changed, 41 insertions, 4 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 366959e04a59..cf1a1aa8eb49 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -715,6 +715,9 @@ int RTFDocumentImpl::resolvePict(bool bInline)
if ( xShapes.is() )
xShapes->add( xShape );
}
+
+ // check if the picture is in an OLE object and if the \objdata element is used
+ // (see RTF_OBJECT in RTFDocumentImpl::dispatchDestination)
if (m_bObject)
{
// Set bitmap
@@ -735,6 +738,7 @@ int RTFDocumentImpl::resolvePict(bool bInline)
m_aObjectAttributes.set(NS_ooxml::LN_shape, pShapeValue);
return 0;
}
+
if (xPropertySet.is())
xPropertySet->setPropertyValue("GraphicURL", uno::Any(aGraphicUrl));
@@ -1445,11 +1449,34 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
m_aStates.top().nDestinationState = DESTINATION_COMMENT;
break;
case RTF_OBJECT:
- m_aStates.top().nDestinationState = DESTINATION_OBJECT;
- m_bObject = true;
+ {
+ // begining of an OLE Object
+ m_aStates.top().nDestinationState = DESTINATION_OBJECT;
+
+ // check if the object is in a special container (e.g. a table)
+ if (!m_pCurrentBuffer)
+ {
+ // the object is in a table or another container.
+ // Don't try to treate it as an OLE object (fdo#53594).
+ // Use the \result (RTF_RESULT) element of the object instead,
+ // the result element contain picture representing the OLE Object.
+ m_bObject = true;
+ }
+ }
break;
case RTF_OBJDATA:
- m_aStates.top().nDestinationState = DESTINATION_OBJDATA;
+ // check if the object is in a special container (e.g. a table)
+ if (m_pCurrentBuffer)
+ {
+ // the object is in a table or another container.
+ // Use the \result (RTF_RESULT) element of the object instead,
+ // of the \objdata.
+ m_aStates.top().nDestinationState = DESTINATION_SKIP;
+ }
+ else
+ {
+ m_aStates.top().nDestinationState = DESTINATION_OBJDATA;
+ }
break;
case RTF_RESULT:
m_aStates.top().nDestinationState = DESTINATION_RESULT;
@@ -3860,6 +3887,14 @@ int RTFDocumentImpl::popState()
break;
case DESTINATION_OBJECT:
{
+ if (!m_bObject)
+ {
+ // if the object is in a special container we will use the \result
+ // element instead of the \objdata
+ // (see RTF_OBJECT in RTFDocumentImpl::dispatchDestination)
+ break;
+ }
+
RTFSprms aObjAttributes;
RTFSprms aObjSprms;
RTFValue::Pointer_t pValue(new RTFValue(m_aObjectAttributes, m_aObjectSprms));
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index d61efef493b7..82490eba072f 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -561,7 +561,9 @@ namespace writerfilter {
RTFSprms m_aObjectSprms;
RTFSprms m_aObjectAttributes;
- /// If we are in an object group.
+ /** If we are in an object group and if the we use its
+ * \objdata element.
+ * (if we don't use the \objdata we use the \result element)*/
bool m_bObject;
/// Contents of the objdata group.
boost::shared_ptr<SvStream> m_pObjectData;