Kaydet (Commit) 0c9afe30 authored tarafından Maxime de Roucy's avatar Maxime de Roucy Kaydeden (comit) Miklos Vajna

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/2243Reviewed-by: 's avatarMiklos Vajna <vmiklos@suse.cz>
Tested-by: 's avatarMiklos Vajna <vmiklos@suse.cz>
üst 54a8acb3
...@@ -716,6 +716,9 @@ int RTFDocumentImpl::resolvePict(bool bInline) ...@@ -716,6 +716,9 @@ int RTFDocumentImpl::resolvePict(bool bInline)
if ( xShapes.is() ) if ( xShapes.is() )
xShapes->add( xShape ); 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) if (m_bObject)
{ {
// Set bitmap // Set bitmap
...@@ -736,6 +739,7 @@ int RTFDocumentImpl::resolvePict(bool bInline) ...@@ -736,6 +739,7 @@ int RTFDocumentImpl::resolvePict(bool bInline)
m_aObjectAttributes.set(NS_ooxml::LN_shape, pShapeValue); m_aObjectAttributes.set(NS_ooxml::LN_shape, pShapeValue);
return 0; return 0;
} }
if (xPropertySet.is()) if (xPropertySet.is())
xPropertySet->setPropertyValue("GraphicURL", uno::Any(aGraphicUrl)); xPropertySet->setPropertyValue("GraphicURL", uno::Any(aGraphicUrl));
...@@ -1446,11 +1450,34 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) ...@@ -1446,11 +1450,34 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
m_aStates.top().nDestinationState = DESTINATION_COMMENT; m_aStates.top().nDestinationState = DESTINATION_COMMENT;
break; break;
case RTF_OBJECT: 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; break;
case RTF_OBJDATA: 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; break;
case RTF_RESULT: case RTF_RESULT:
m_aStates.top().nDestinationState = DESTINATION_RESULT; m_aStates.top().nDestinationState = DESTINATION_RESULT;
...@@ -3861,6 +3888,14 @@ int RTFDocumentImpl::popState() ...@@ -3861,6 +3888,14 @@ int RTFDocumentImpl::popState()
break; break;
case DESTINATION_OBJECT: 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 aObjAttributes;
RTFSprms aObjSprms; RTFSprms aObjSprms;
RTFValue::Pointer_t pValue(new RTFValue(m_aObjectAttributes, m_aObjectSprms)); RTFValue::Pointer_t pValue(new RTFValue(m_aObjectAttributes, m_aObjectSprms));
......
...@@ -561,7 +561,9 @@ namespace writerfilter { ...@@ -561,7 +561,9 @@ namespace writerfilter {
RTFSprms m_aObjectSprms; RTFSprms m_aObjectSprms;
RTFSprms m_aObjectAttributes; 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; bool m_bObject;
/// Contents of the objdata group. /// Contents of the objdata group.
boost::shared_ptr<SvStream> m_pObjectData; boost::shared_ptr<SvStream> m_pObjectData;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment