diff options
author | Armin Weiss <aw@openoffice.org> | 2002-06-27 10:09:52 +0000 |
---|---|---|
committer | Armin Weiss <aw@openoffice.org> | 2002-06-27 10:09:52 +0000 |
commit | ec66979673b389990eb2ec4ef100c82b54d82b10 (patch) | |
tree | 101268c0b97212da65616b290b016da17245a013 /xmloff | |
parent | 46968079fa0f61334ffdfb08f98272a80fd0e7c9 (diff) |
#100592# added support for embedded OLE objects
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/draw/shapeexport2.cxx | 62 | ||||
-rw-r--r-- | xmloff/source/draw/ximpshap.cxx | 75 | ||||
-rw-r--r-- | xmloff/source/draw/ximpshap.hxx | 11 |
3 files changed, 124 insertions, 24 deletions
diff --git a/xmloff/source/draw/shapeexport2.cxx b/xmloff/source/draw/shapeexport2.cxx index 24e631df8b80..58de81416ee4 100644 --- a/xmloff/source/draw/shapeexport2.cxx +++ b/xmloff/source/draw/shapeexport2.cxx @@ -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 ); + } + } } } diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx index caeec253b61b..70620ab84595 100644 --- a/xmloff/source/draw/ximpshap.cxx +++ b/xmloff/source/draw/ximpshap.cxx @@ -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 ); diff --git a/xmloff/source/draw/ximpshap.hxx b/xmloff/source/draw/ximpshap.hxx index 8f8403166214..13302770205d 100644 --- a/xmloff/source/draw/ximpshap.hxx +++ b/xmloff/source/draw/ximpshap.hxx @@ -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 ); }; |