diff options
author | Mikhail Voitenko <mav@openoffice.org> | 2003-11-24 15:12:44 +0000 |
---|---|---|
committer | Mikhail Voitenko <mav@openoffice.org> | 2003-11-24 15:12:44 +0000 |
commit | 637f866df0deb3e1a861cf23a0d67be481d4096d (patch) | |
tree | 0ce4a736b1221c3b12e08133e2495faae74a4a0f /embeddedobj/source | |
parent | b48620947caf316db386694cedafd1cb3a199fe3 (diff) |
#112923# creation of OLE objects or links base on fileURL
Diffstat (limited to 'embeddedobj/source')
-rw-r--r-- | embeddedobj/source/inc/oleembobj.hxx | 7 | ||||
-rw-r--r-- | embeddedobj/source/msole/olecomponent.cxx | 89 | ||||
-rw-r--r-- | embeddedobj/source/msole/olecomponent.hxx | 6 | ||||
-rw-r--r-- | embeddedobj/source/msole/olemisc.cxx | 8 | ||||
-rw-r--r-- | embeddedobj/source/msole/olepersist.cxx | 8 |
5 files changed, 100 insertions, 18 deletions
diff --git a/embeddedobj/source/inc/oleembobj.hxx b/embeddedobj/source/inc/oleembobj.hxx index c38e7fbc7d78..10f4c9819ba9 100644 --- a/embeddedobj/source/inc/oleembobj.hxx +++ b/embeddedobj/source/inc/oleembobj.hxx @@ -2,9 +2,9 @@ * * $RCSfile: oleembobj.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: mav $ $Date: 2003-11-20 17:02:21 $ + * last change: $Author: mav $ $Date: 2003-11-24 16:12:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -184,7 +184,8 @@ public: // in case object will be loaded from a persistent entry or from a file the class ID will be detected on loading // factory can do it for OOo objects, but for OLE objects OS dependent code is required - OleEmbeddedObject( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory ); + OleEmbeddedObject( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory, + sal_Bool bLink ); virtual ~OleEmbeddedObject(); diff --git a/embeddedobj/source/msole/olecomponent.cxx b/embeddedobj/source/msole/olecomponent.cxx index 2680c3603655..a9dff7705c24 100644 --- a/embeddedobj/source/msole/olecomponent.cxx +++ b/embeddedobj/source/msole/olecomponent.cxx @@ -2,9 +2,9 @@ * * $RCSfile: olecomponent.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: mav $ $Date: 2003-11-24 09:42:58 $ + * last change: $Author: mav $ $Date: 2003-11-24 16:12:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -103,6 +103,12 @@ using namespace ::com::sun::star; #define MAX_ENUM_ELE 20 const sal_Int32 n_ConstBufferSize = 32000; + +uno::Sequence< sal_Int8 > GetSequenceClassID( sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3, + sal_uInt8 b8, sal_uInt8 b9, sal_uInt8 b10, sal_uInt8 b11, + sal_uInt8 b12, sal_uInt8 b13, sal_uInt8 b14, sal_uInt8 b15 ); + +//---------------------------------------------- STDAPI StarObject_SwitchDisplayAspect(IUnknown *pObj, LPDWORD pdwCurAspect , DWORD dwNewAspect, HGLOBAL hMetaPict, BOOL fDeleteOld , BOOL fViewAdvise, IAdviseSink *pSink, BOOL *pfMustUpdate) @@ -111,7 +117,7 @@ STDAPI StarObject_SwitchDisplayAspect(IUnknown *pObj, LPDWORD pdwCurAspect return S_OK; } - +//---------------------------------------------- sal_Bool ConvertDataForFlavor( const STGMEDIUM& aMedium, const datatransfer::DataFlavor& aFlavor, uno::Any& aResult ) { // TODO: try to convert data from Medium format to specified Flavor format @@ -650,15 +656,66 @@ void OleComponent::CreateObjectFromData( const uno::Reference< datatransfer::XTr } //---------------------------------------------- -void OleComponent::CreateObjectFromFile( const ::rtl::OUString& aFileName, sal_Int64 nAspect, sal_uInt32 nIconHandle ) +void OleComponent::CreateObjectFromFile( const ::rtl::OUString& aFileURL, sal_Int64 nAspect, sal_uInt32 nIconHandle ) { - // TODO: + if ( m_pIStorage || m_aTempURL.getLength() ) + throw frame::DoubleInitializationException(); // the object is already initialized + + m_nMSAspect = (DWORD)nAspect; // first 32 bits are for MS aspects + + m_pIStorage = CreateNewIStorage_Impl(); + if ( !m_pIStorage ) + throw uno::RuntimeException(); // TODO: + + ::rtl::OUString aFilePath; + if ( ::osl::FileBase::getSystemPathFromFileURL( aFileURL, aFilePath ) != ::osl::FileBase::E_None ) + throw uno::RuntimeException(); // TODO: something dangerous happend + + HRESULT hr = OleCreateFromFile( CLSID_NULL, + aFilePath.getStr(), + IID_IUnknown, + OLERENDER_DRAW, // OLERENDER_FORMAT + NULL, + NULL, + m_pIStorage, + (void**)&m_pObj ); + + if ( FAILED( hr ) || !m_pObj) + throw uno::RuntimeException(); // TODO + + if ( !InitializeObject_Impl( nIconHandle ) ) + throw uno::RuntimeException(); // TODO } //---------------------------------------------- -void OleComponent::CreateLinkFromFile( const ::rtl::OUString& aFileName, sal_Int64 nAspect, sal_uInt32 nIconHandle ) +void OleComponent::CreateLinkFromFile( const ::rtl::OUString& aFileURL, sal_Int64 nAspect, sal_uInt32 nIconHandle ) { - // TODO: + if ( m_pIStorage || m_aTempURL.getLength() ) + throw frame::DoubleInitializationException(); // the object is already initialized + + m_nMSAspect = (DWORD)nAspect; // first 32 bits are for MS aspects + + m_pIStorage = CreateNewIStorage_Impl(); + if ( !m_pIStorage ) + throw uno::RuntimeException(); // TODO: + + ::rtl::OUString aFilePath; + if ( ::osl::FileBase::getSystemPathFromFileURL( aFileURL, aFilePath ) != ::osl::FileBase::E_None ) + throw uno::RuntimeException(); // TODO: something dangerous happend + + HRESULT hr = OleCreateLinkToFile( aFilePath.getStr(), + IID_IUnknown, + OLERENDER_DRAW, // OLERENDER_FORMAT + NULL, + NULL, + m_pIStorage, + (void**)&m_pObj ); + + if ( FAILED( hr ) || !m_pObj) + throw uno::RuntimeException(); // TODO + + if ( !InitializeObject_Impl( nIconHandle ) ) + throw uno::RuntimeException(); // TODO } //---------------------------------------------- @@ -793,6 +850,24 @@ sal_Int64 OleComponent::GetMiscStatus() } //---------------------------------------------- +uno::Sequence< sal_Int8 > OleComponent::GetCLSID() +{ + if ( !m_pOleObject ) + throw embed::WrongStateException(); // TODO: the object is in wrong state + + GUID aCLSID; + HRESULT hr = m_pOleObject->GetUserClassID( &aCLSID ); + if ( FAILED( hr ) ) + throw io::IOException(); // TODO: + + return GetSequenceClassID( aCLSID.Data1, aCLSID.Data2, aCLSID.Data3, + aCLSID.Data4[0], aCLSID.Data4[1], + aCLSID.Data4[2], aCLSID.Data4[3], + aCLSID.Data4[4], aCLSID.Data4[5], + aCLSID.Data4[6], aCLSID.Data4[7] ); +} + +//---------------------------------------------- sal_Int64 OleComponent::GetViewAspect() { if ( !m_pOleObject ) diff --git a/embeddedobj/source/msole/olecomponent.hxx b/embeddedobj/source/msole/olecomponent.hxx index af17009295e2..a9acc7625254 100644 --- a/embeddedobj/source/msole/olecomponent.hxx +++ b/embeddedobj/source/msole/olecomponent.hxx @@ -2,9 +2,9 @@ * * $RCSfile: olecomponent.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: mav $ $Date: 2003-11-17 16:19:24 $ + * last change: $Author: mav $ $Date: 2003-11-24 16:12:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -201,6 +201,8 @@ public: sal_Int64 GetMiscStatus(); + ::com::sun::star::uno::Sequence< sal_Int8 > GetCLSID(); + void StoreObjectToStream( ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > xOutStream, sal_Bool bStoreVisReplace ); diff --git a/embeddedobj/source/msole/olemisc.cxx b/embeddedobj/source/msole/olemisc.cxx index 3cf36d8b5b72..f901c0870160 100644 --- a/embeddedobj/source/msole/olemisc.cxx +++ b/embeddedobj/source/msole/olemisc.cxx @@ -2,9 +2,9 @@ * * $RCSfile: olemisc.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: mav $ $Date: 2003-11-20 17:02:23 $ + * last change: $Author: mav $ $Date: 2003-11-24 16:12:40 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -102,7 +102,7 @@ OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< lang::XMultiServiceF //------------------------------------------------------ // In case of loading from persistent entry the classID of the object // will be retrieved from the entry, during construction it is unknown -OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< lang::XMultiServiceFactory >& xFactory ) +OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< lang::XMultiServiceFactory >& xFactory, sal_Bool bLink ) : m_pOleComponent( NULL ) , m_pInterfaceContainer( NULL ) , m_bReadOnly( sal_False ) @@ -112,7 +112,7 @@ OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< lang::XMultiServiceF , m_bStoreVisRepl( sal_True ) , m_xFactory( xFactory ) , m_bWaitSaveCompleted( sal_False ) -, m_bIsLink( sal_False ) +, m_bIsLink( bLink ) { } diff --git a/embeddedobj/source/msole/olepersist.cxx b/embeddedobj/source/msole/olepersist.cxx index ce43cd5200e1..27aed1ebc25f 100644 --- a/embeddedobj/source/msole/olepersist.cxx +++ b/embeddedobj/source/msole/olepersist.cxx @@ -2,9 +2,9 @@ * * $RCSfile: olepersist.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: mav $ $Date: 2003-11-24 09:42:10 $ + * last change: $Author: mav $ $Date: 2003-11-24 16:12:41 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -273,6 +273,8 @@ void SAL_CALL OleEmbeddedObject::setPersistentEntry( // after the loading the object can appear as a link // will be detected later by olecomponent m_pOleComponent->LoadEmbeddedObject( xInStream, embed::Aspects::MSASPECT_CONTENT ); + m_aClassID = m_pOleComponent->GetCLSID(); // was not set during consruction + m_nObjectState = embed::EmbedStates::EMBED_LOADED; } else @@ -326,6 +328,8 @@ void SAL_CALL OleEmbeddedObject::setPersistentEntry( m_pOleComponent->CreateLinkFromFile( aURL, embed::Aspects::MSASPECT_CONTENT, NULL ); m_pOleComponent->RunObject(); + m_aClassID = m_pOleComponent->GetCLSID(); // was not set during consruction + m_nObjectState = embed::EmbedStates::EMBED_RUNNING; } //else if ( nEntryConnectionMode == embed::EntryInitModes::ENTRY_TRANSFERABLE_INIT ) |