diff options
author | Maxime de Roucy <mderoucy@linagora.com> | 2013-02-20 14:27:47 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-02-25 09:43:32 +0000 |
commit | 0c9afe307eae8310de04de458c13b5c14a4e17da (patch) | |
tree | 55f474efa830a362658542868592ef622ddeedbb /writerfilter | |
parent | Last use of obsolete gb_*_add_api is long gone (diff) | |
download | core-0c9afe307eae8310de04de458c13b5c14a4e17da.tar.gz core-0c9afe307eae8310de04de458c13b5c14a4e17da.zip |
RTF IMPORT : considere OLE objects as pictures
resolve fdo#53594 : Import RTF file but ole are not well positioned in
table/cells
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>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 41 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.hxx | 4 |
2 files changed, 41 insertions, 4 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 9d5de81a8404..14c74869e78a 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -716,6 +716,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 @@ -736,6 +739,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)); @@ -1446,11 +1450,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; @@ -3861,6 +3888,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; |