From 206946515f4139eedcb3139dacb08664b2c3853a Mon Sep 17 00:00:00 2001 From: Michael Brauer Date: Fri, 26 Jan 2001 10:22:48 +0000 Subject: ole objects continued --- sw/source/filter/xml/swxml.cxx | 22 ++++++++++++++--- sw/source/filter/xml/wrtxml.cxx | 34 ++++++++++++++++++++------ sw/source/filter/xml/xmltexte.cxx | 12 ++++++---- sw/source/filter/xml/xmltexte.hxx | 5 ++-- sw/source/filter/xml/xmltexti.cxx | 50 +++++++-------------------------------- 5 files changed, 64 insertions(+), 59 deletions(-) (limited to 'sw') diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx index 887756f45b89..7e328247279f 100644 --- a/sw/source/filter/xml/swxml.cxx +++ b/sw/source/filter/xml/swxml.cxx @@ -2,9 +2,9 @@ * * $RCSfile: swxml.cxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: mib $ $Date: 2001-01-22 13:47:37 $ + * last change: $Author: mib $ $Date: 2001-01-26 11:22:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -114,6 +114,9 @@ #ifndef _XMLGRHLP_HXX #include #endif +#ifndef _XMLEOHLP_HXX +#include +#endif #ifndef _XMLIMP_HXX #include "xmlimp.hxx" @@ -150,6 +153,8 @@ sal_uInt32 XMLReader::Read( SwDoc &rDoc, SwPaM &rPaM, const String & rName ) Reference< XInterface > xPipe; Reference< document::XGraphicObjectResolver > xGraphicResolver; SvXMLGraphicHelper *pGraphicHelper = 0; + Reference< document::XEmbeddedObjectResolver > xObjectResolver; + SvXMLEmbeddedObjectHelper *pObjectHelper = 0; SvStorageStreamRef xDocStream; xml::sax::InputSource aParserInput; @@ -167,6 +172,16 @@ sal_uInt32 XMLReader::Read( SwDoc &rDoc, SwPaM &rPaM, const String & rName ) sal_False ); xGraphicResolver = pGraphicHelper; + SvPersist *pPersist = rDoc.GetPersist(); + if( pPersist ) + { + pObjectHelper = SvXMLEmbeddedObjectHelper::Create( + *pStorage, *pPersist, + EMBEDDEDOBJECTHELPER_MODE_READ, + sal_False ); + xObjectResolver = pObjectHelper; + } + OUString sDocName( RTL_CONSTASCII_USTRINGPARAM( "Content.xml" ) ); xDocStream = pStorage->OpenStream( sDocName, STREAM_READ | STREAM_NOCREATE ); @@ -215,9 +230,10 @@ sal_uInt32 XMLReader::Read( SwDoc &rDoc, SwPaM &rPaM, const String & rName ) return ERR_SWG_READ_ERROR; // get filter - Sequence < Any > aArgs( 1 ); + Sequence < Any > aArgs( 2 ); Any *pArgs = aArgs.getArray(); *pArgs++ <<= xGraphicResolver; + *pArgs++ <<= xObjectResolver; Reference< xml::sax::XDocumentHandler > xFilter( xServiceFactory->createInstanceWithArguments( OUString::createFromAscii("com.sun.star.office.sax.importer.Writer"), diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx index 61172fc49dd6..3c449d4b564f 100644 --- a/sw/source/filter/xml/wrtxml.cxx +++ b/sw/source/filter/xml/wrtxml.cxx @@ -2,9 +2,9 @@ * * $RCSfile: wrtxml.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: mib $ $Date: 2001-01-22 12:31:45 $ + * last change: $Author: mib $ $Date: 2001-01-26 11:22:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -80,6 +80,9 @@ #ifndef _XMLGRHLP_HXX #include #endif +#ifndef _XMLEOHLP_HXX +#include +#endif #ifndef _SFXDOCFILE_HXX //autogen wg. SfxMedium #include @@ -140,6 +143,8 @@ sal_uInt32 SwXMLWriter::_Write() SvStorageStreamRef xDocStream; Reference< document::XGraphicObjectResolver > xGraphicResolver; SvXMLGraphicHelper *pGraphicHelper = 0; + Reference< document::XEmbeddedObjectResolver > xObjectResolver; + SvXMLEmbeddedObjectHelper *pObjectHelper = 0; if( pStg ) { @@ -148,6 +153,16 @@ sal_uInt32 SwXMLWriter::_Write() sal_False ); xGraphicResolver = pGraphicHelper; + SvPersist *pPersist = pDoc->GetPersist(); + if( pPersist ) + { + pObjectHelper = SvXMLEmbeddedObjectHelper::Create( + *pStg, *pPersist, + EMBEDDEDOBJECTHELPER_MODE_WRITE, + sal_False ); + xObjectResolver = pObjectHelper; + } + OUString sDocName( RTL_CONSTASCII_USTRINGPARAM( "Content.xml" ) ); xDocStream = pStg->OpenStream( sDocName, STREAM_WRITE | STREAM_SHARE_DENYWRITE ); @@ -174,10 +189,11 @@ sal_uInt32 SwXMLWriter::_Write() // get filter Reference< xml::sax::XDocumentHandler > xHandler( xWriter, UNO_QUERY ); - Sequence < Any > aArgs( 2 ); + Sequence < Any > aArgs( 3 ); Any *pArgs = aArgs.getArray(); *pArgs++ <<= xHandler; *pArgs++ <<= xGraphicResolver; + *pArgs++ <<= xObjectResolver; Reference< document::XExporter > xExporter( xServiceFactory->createInstanceWithArguments( OUString::createFromAscii("com.sun.star.office.sax.exporter.Writer"), @@ -223,13 +239,14 @@ sal_uInt32 SwXMLWriter::_Write() if( xDocStream.Is() ) xDocStream->Commit(); - if( pStg ) - pDoc->GetDocShell()->SaveAsChilds( pStg ); - if( pGraphicHelper ) SvXMLGraphicHelper::Destroy( pGraphicHelper ); xGraphicResolver = 0; + if( pObjectHelper ) + SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper ); + xObjectResolver = 0; + return 0; } sal_uInt32 SwXMLWriter::WriteStream() @@ -268,11 +285,14 @@ void GetXMLWriter( const String& rName, WriterRef& xRet ) Source Code Control System - Header - $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/wrtxml.cxx,v 1.13 2001-01-22 12:31:45 mib Exp $ + $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/wrtxml.cxx,v 1.14 2001-01-26 11:22:48 mib Exp $ Source Code Control System - Update $Log: not supported by cvs2svn $ + Revision 1.13 2001/01/22 12:31:45 mib + block mode + Revision 1.12 2001/01/17 10:55:18 mib XML filter now is a component diff --git a/sw/source/filter/xml/xmltexte.cxx b/sw/source/filter/xml/xmltexte.cxx index 87b1e8074b06..d5130a86ad4d 100644 --- a/sw/source/filter/xml/xmltexte.cxx +++ b/sw/source/filter/xml/xmltexte.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmltexte.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: mib $ $Date: 2001-01-08 09:44:55 $ + * last change: $Author: mib $ $Date: 2001-01-26 11:22:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -228,7 +228,8 @@ SwXMLTextParagraphExport::SwXMLTextParagraphExport( SwXMLExport& rExp, SvXMLAutoStylePoolP& rAutoStylePool ) : XMLTextParagraphExport( rExp, rAutoStylePool ), - sTextTable( RTL_CONSTASCII_USTRINGPARAM( "TextTable" ) ) + sTextTable( RTL_CONSTASCII_USTRINGPARAM( "TextTable" ) ), + sEmbeddedObjectProtocol( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.EmbeddedObject:" ) ) { } @@ -238,13 +239,14 @@ SwXMLTextParagraphExport::~SwXMLTextParagraphExport() void SwXMLTextParagraphExport::getTextEmbeddedObjectProperties( const Reference < XPropertySet >& rPropSet, - OUString& rStreamName, + OUString& rURL, OUString& rClassId ) const { SwOLENode *pOLENd = GetNoTxtNode( rPropSet )->GetOLENode(); SwOLEObj& rOLEObj = pOLENd->GetOLEObj(); - rStreamName = rOLEObj.GetName(); + rURL = sEmbeddedObjectProtocol; + rURL += rOLEObj.GetName(); const SvInPlaceObjectRef& rOLERef = rOLEObj.GetOleRef(); rClassId = rOLERef->GetClassName().GetHexName(); } diff --git a/sw/source/filter/xml/xmltexte.hxx b/sw/source/filter/xml/xmltexte.hxx index c602d7d8766f..ba1f96b42b19 100644 --- a/sw/source/filter/xml/xmltexte.hxx +++ b/sw/source/filter/xml/xmltexte.hxx @@ -2,9 +2,9 @@ * * $RCSfile: xmltexte.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: mib $ $Date: 2001-01-03 11:40:56 $ + * last change: $Author: mib $ $Date: 2001-01-26 11:22:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -76,6 +76,7 @@ namespace com { namespace sun { namespace star { namespace style { class SwXMLTextParagraphExport : public XMLTextParagraphExport { const ::rtl::OUString sTextTable; + const ::rtl::OUString sEmbeddedObjectProtocol; SwNoTxtNode *GetNoTxtNode( const ::com::sun::star::uno::Reference < diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx index 18f4e32ab86f..43c20f8d4cbe 100644 --- a/sw/source/filter/xml/xmltexti.cxx +++ b/sw/source/filter/xml/xmltexti.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmltexti.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: dvo $ $Date: 2001-01-25 11:36:37 $ + * last change: $Author: mib $ $Date: 2001-01-26 11:22:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -161,17 +161,13 @@ Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOLEObject( { Reference < XPropertySet > xPropSet; - String aObjName; - if( 0 == rHRef.compareToAscii( "#./", 3 ) ) - aObjName = rHRef.copy( 3 ); - else if( rHRef.getLength() && '#' == rHRef[0] ) - aObjName = rHRef.copy( 1 ); - - if( !aObjName.Len() ) + sal_Int32 nPos = rHRef.indexOf( ':' ); + if( -1 == nPos ) return xPropSet; - SvGlobalName aClassId; - if( !rClassId.getLength() || !aClassId.MakeId( rClassId ) ) + String aObjName( rHRef.copy( nPos+1) ); + + if( !aObjName.Len() ) return xPropSet; Reference xCrsrTunnel( GetCursor(), UNO_QUERY ); @@ -182,37 +178,7 @@ Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOLEObject( ASSERT( pTxtCrsr, "SwXTextCursor missing" ); SwDoc *pDoc = pTxtCrsr->GetDoc(); - SvStorage *pPackage = ((SwXMLImport&)rImport).GetPackage(); - if( !pPackage || !pDoc->GetPersist() ) - return xPropSet; - - String aSrcObjName( aObjName ); - SvPersistRef xDstDoc( pDoc->GetPersist() ); - SvStorageRef xDst( pDoc->GetPersist()->GetStorage() ); - - // Sind Objektname und Storagename eindeutig? - if( xDstDoc->GetObjectList() ) - { - for( ULONG i = 0; i < xDstDoc->GetObjectList()->Count(); i++ ) - { - SvInfoObject* pTst = xDstDoc->GetObjectList()->GetObject(i); - // TODO: unicode: is this correct? - if( aObjName.EqualsIgnoreCaseAscii( pTst->GetObjName() ) || - aObjName.EqualsIgnoreCaseAscii( pTst->GetStorageName() ) ) - { - aObjName = Sw3Io::UniqueName( xDst, "Obj" ); - break; - } - } - } - - if( !pPackage->CopyTo( aSrcObjName, xDst, aObjName ) ) - return xPropSet; - - SvInfoObjectRef xInfo = new SvEmbeddedInfoObject( aObjName, aClassId ); - pDoc->GetPersist()->Insert( xInfo ); - - SwFrmFmt *pFrmFmt = pTxtCrsr->GetDoc()->InsertOLE( *pTxtCrsr->GetPaM(), + SwFrmFmt *pFrmFmt = pDoc->InsertOLE( *pTxtCrsr->GetPaM(), aObjName ); xPropSet = SwXFrames::GetObject( *pFrmFmt, FLYCNTTYPE_OLE ); return xPropSet; -- cgit v1.2.3