#100592# added support for embedded OLE objects
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: shapeexport2.cxx,v $
|
||||
*
|
||||
* $Revision: 1.29 $
|
||||
* $Revision: 1.30 $
|
||||
*
|
||||
* last change: $Author: cl $ $Date: 2002-01-18 16:36:12 $
|
||||
* last change: $Author: aw $ $Date: 2002-06-27 11:07:20 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -1386,41 +1386,47 @@ void XMLShapeExport::ImpExportOLE2Shape(
|
||||
bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, GetXMLToken(XML_PRESENTATION_TABLE) );
|
||||
|
||||
OUString sClassId;
|
||||
sal_Bool bInternal;
|
||||
xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsInternal"))) >>= bInternal;
|
||||
|
||||
sal_Bool bExportEmbedded(0 != (rExport.getExportFlags() & EXPORT_EMBEDDED));
|
||||
|
||||
OUString sURL;
|
||||
OUString sPersistName;
|
||||
|
||||
if( !bIsEmptyPresObj )
|
||||
{
|
||||
// xlink:href
|
||||
OUString sURL;
|
||||
OUString sPersistName;
|
||||
|
||||
xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM( "PersistName" ) ) ) >>= sPersistName;
|
||||
|
||||
if( sPersistName.getLength() )
|
||||
{
|
||||
sURL = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.EmbeddedObject:" ) );
|
||||
sURL += sPersistName;
|
||||
}
|
||||
|
||||
sal_Bool bInternal;
|
||||
xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsInternal"))) >>= bInternal;
|
||||
|
||||
if( !bInternal )
|
||||
xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CLSID"))) >>= sClassId;
|
||||
|
||||
if( sClassId.getLength() )
|
||||
rExport.AddAttribute(XML_NAMESPACE_DRAW, XML_CLASS_ID, sClassId );
|
||||
}
|
||||
|
||||
if( sURL.getLength() )
|
||||
if( !bIsEmptyPresObj )
|
||||
{
|
||||
if(!bExportEmbedded)
|
||||
{
|
||||
// #96717# in theorie, if we don't have a url we shouldn't even
|
||||
// export this ole shape. But practical its to risky right now
|
||||
// to change this so we better dispose this on load
|
||||
sURL = rExport.AddEmbeddedObject( sURL );
|
||||
// xlink:href
|
||||
if( sURL.getLength() )
|
||||
{
|
||||
// #96717# in theorie, if we don't have a url we shouldn't even
|
||||
// export this ole shape. But practical its to risky right now
|
||||
// to change this so we better dispose this on load
|
||||
sURL = rExport.AddEmbeddedObject( sURL );
|
||||
|
||||
rExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sURL );
|
||||
rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
|
||||
rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
|
||||
rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
|
||||
rExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sURL );
|
||||
rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
|
||||
rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
|
||||
rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1430,6 +1436,24 @@ void XMLShapeExport::ImpExportOLE2Shape(
|
||||
|
||||
ImpExportEvents( xShape );
|
||||
ImpExportGluePoints( xShape );
|
||||
|
||||
if(bExportEmbedded && !bIsEmptyPresObj)
|
||||
{
|
||||
// #100592#
|
||||
if(bInternal)
|
||||
{
|
||||
// embedded XML
|
||||
uno::Reference< lang::XComponent > xComp;
|
||||
xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) ) >>= xComp;
|
||||
DBG_ASSERT( xComp.is(), "no xModel for own OLE format" );
|
||||
rExport.ExportEmbeddedOwnObject( xComp );
|
||||
}
|
||||
else
|
||||
{
|
||||
// embed as Base64
|
||||
rExport.AddEmbeddedObjectAsBase64( sURL );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: ximpshap.cxx,v $
|
||||
*
|
||||
* $Revision: 1.74 $
|
||||
* $Revision: 1.75 $
|
||||
*
|
||||
* last change: $Author: cl $ $Date: 2002-02-05 11:09:23 $
|
||||
* last change: $Author: aw $ $Date: 2002-06-27 11:09:08 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -187,6 +187,10 @@
|
||||
#include "eventimp.hxx"
|
||||
#endif
|
||||
|
||||
#ifndef _XMLOFF_XMLEMBEDDEDOBJECTIMPORTCONTEXT_HXX
|
||||
#include "XMLEmbeddedObjectImportContext.hxx"
|
||||
#endif
|
||||
|
||||
using namespace ::rtl;
|
||||
using namespace ::com::sun::star;
|
||||
using namespace ::xmloff::token;
|
||||
@@ -2344,7 +2348,12 @@ void SdXMLObjectShapeContext::StartElement( const ::com::sun::star::uno::Referen
|
||||
// #96717# in theorie, if we don't have a url we shouldn't even
|
||||
// export this ole shape. But practical its to risky right now
|
||||
// to change this so we better dispose this on load
|
||||
if( !mbIsPlaceholder && (maHref.getLength() == 0) )
|
||||
//if( !mbIsPlaceholder && (maHref.getLength() == 0) )
|
||||
// return;
|
||||
|
||||
// #100592# this BugFix prevents that a shape is created. CL
|
||||
// is thinking about an alternative.
|
||||
if( !(GetImport().getImportFlags() & IMPORT_EMBEDDED) && !mbIsPlaceholder && (maHref.getLength() == 0) )
|
||||
return;
|
||||
|
||||
char* pService = "com.sun.star.drawing.OLE2Shape";
|
||||
@@ -2417,6 +2426,18 @@ void SdXMLObjectShapeContext::StartElement( const ::com::sun::star::uno::Referen
|
||||
|
||||
void SdXMLObjectShapeContext::EndElement()
|
||||
{
|
||||
// #100592#
|
||||
if( mxBase64Stream.is() )
|
||||
{
|
||||
OUString aPersistName( GetImport().ResolveEmbeddedObjectURL( maHref, OUString() ) );
|
||||
const OUString sURL(RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.EmbeddedObject:" ));
|
||||
|
||||
aPersistName = aPersistName.copy( sURL.getLength() );
|
||||
|
||||
uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
|
||||
if( xProps.is() )
|
||||
xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PersistName" ) ), uno::makeAny( aPersistName ) );
|
||||
}
|
||||
}
|
||||
|
||||
// this is called from the parent group for each unparsed attribute in the attribute list
|
||||
@@ -2443,6 +2464,54 @@ void SdXMLObjectShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl:
|
||||
SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
|
||||
}
|
||||
|
||||
SvXMLImportContext* SdXMLObjectShapeContext::CreateChildContext(
|
||||
USHORT nPrefix, const ::rtl::OUString& rLocalName,
|
||||
const uno::Reference<xml::sax::XAttributeList>& xAttrList )
|
||||
{
|
||||
// #100592#
|
||||
SvXMLImportContext* pContext = NULL;
|
||||
|
||||
if(XML_NAMESPACE_OFFICE == nPrefix)
|
||||
{
|
||||
if(IsXMLToken(rLocalName, XML_BINARY_DATA))
|
||||
{
|
||||
maHref = OUString( RTL_CONSTASCII_USTRINGPARAM( "#Obj12345678" ) );
|
||||
mxBase64Stream = GetImport().ResolveEmbeddedObjectURLFromBase64( maHref );
|
||||
if( mxBase64Stream.is() )
|
||||
pContext = new XMLBase64ImportContext( GetImport(), nPrefix,
|
||||
rLocalName, xAttrList,
|
||||
mxBase64Stream );
|
||||
}
|
||||
else if(IsXMLToken(rLocalName, XML_DOCUMENT))
|
||||
{
|
||||
XMLEmbeddedObjectImportContext *pEContext =
|
||||
new XMLEmbeddedObjectImportContext( GetImport(), nPrefix,
|
||||
rLocalName, xAttrList );
|
||||
maCLSID = pEContext->GetFilterCLSID();
|
||||
if( maCLSID.getLength() != 0 )
|
||||
{
|
||||
uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
|
||||
if( xPropSet.is() )
|
||||
{
|
||||
xPropSet->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CLSID") ), uno::makeAny( maCLSID ) );
|
||||
|
||||
uno::Reference< lang::XComponent > xComp;
|
||||
xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) ) >>= xComp;
|
||||
DBG_ASSERT( xComp.is(), "no xModel for own OLE format" );
|
||||
pEContext->SetComponent( xComp );
|
||||
}
|
||||
}
|
||||
pContext = pEContext;
|
||||
}
|
||||
}
|
||||
|
||||
// delegate to parent class if no context could be created
|
||||
if(!pContext)
|
||||
pContext = SdXMLShapeContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
|
||||
|
||||
return pContext;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TYPEINIT1( SdXMLAppletShapeContext, SdXMLShapeContext );
|
||||
|
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: ximpshap.hxx,v $
|
||||
*
|
||||
* $Revision: 1.32 $
|
||||
* $Revision: 1.33 $
|
||||
*
|
||||
* last change: $Author: cl $ $Date: 2001-12-14 14:06:48 $
|
||||
* last change: $Author: aw $ $Date: 2002-06-27 11:09:52 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -498,6 +498,9 @@ private:
|
||||
rtl::OUString maCLSID;
|
||||
rtl::OUString maHref;
|
||||
|
||||
// #100592#
|
||||
::com::sun::star::uno::Reference < ::com::sun::star::io::XOutputStream > mxBase64Stream;
|
||||
|
||||
public:
|
||||
TYPEINFO();
|
||||
|
||||
@@ -510,6 +513,10 @@ public:
|
||||
virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
|
||||
virtual void EndElement();
|
||||
|
||||
// #100592#
|
||||
virtual SvXMLImportContext * CreateChildContext( USHORT nPrefix, const ::rtl::OUString& rLocalName,
|
||||
const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList );
|
||||
|
||||
// this is called from the parent group for each unparsed attribute in the attribute list
|
||||
virtual void processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue );
|
||||
};
|
||||
|
Reference in New Issue
Block a user