#112923# breaking of ole link and assertion fixes
This commit is contained in:
@@ -2,9 +2,9 @@
|
|||||||
*
|
*
|
||||||
* $RCSfile: persistence.cxx,v $
|
* $RCSfile: persistence.cxx,v $
|
||||||
*
|
*
|
||||||
* $Revision: 1.4 $
|
* $Revision: 1.5 $
|
||||||
*
|
*
|
||||||
* last change: $Author: mav $ $Date: 2003-11-25 13:21:47 $
|
* last change: $Author: mav $ $Date: 2003-11-26 16:44:03 $
|
||||||
*
|
*
|
||||||
* The Contents of this file are made available subject to the terms of
|
* The Contents of this file are made available subject to the terms of
|
||||||
* either of the following licenses
|
* either of the following licenses
|
||||||
@@ -220,7 +220,7 @@ void OCommonEmbeddedObject::SwitchOwnPersistence( const uno::Reference< embed::X
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
uno::Reference< lang::XComponent > xComponent( m_xObjectStorage, uno::UNO_QUERY );
|
uno::Reference< lang::XComponent > xComponent( m_xObjectStorage, uno::UNO_QUERY );
|
||||||
OSL_ENSURE( xComponent.is(), "Wrong storage implementation!" );
|
OSL_ENSURE( !m_xObjectStorage.is() || xComponent.is(), "Wrong storage implementation!" );
|
||||||
if ( xComponent.is() )
|
if ( xComponent.is() )
|
||||||
xComponent->dispose();
|
xComponent->dispose();
|
||||||
}
|
}
|
||||||
|
@@ -2,9 +2,9 @@
|
|||||||
*
|
*
|
||||||
* $RCSfile: olecomponent.cxx,v $
|
* $RCSfile: olecomponent.cxx,v $
|
||||||
*
|
*
|
||||||
* $Revision: 1.6 $
|
* $Revision: 1.7 $
|
||||||
*
|
*
|
||||||
* last change: $Author: mav $ $Date: 2003-11-26 10:27:47 $
|
* last change: $Author: mav $ $Date: 2003-11-26 16:44:04 $
|
||||||
*
|
*
|
||||||
* The Contents of this file are made available subject to the terms of
|
* The Contents of this file are made available subject to the terms of
|
||||||
* either of the following licenses
|
* either of the following licenses
|
||||||
@@ -727,22 +727,83 @@ void OleComponent::InitEmbeddedCopyOfLink( OleComponent* pOleLinkComponent )
|
|||||||
|
|
||||||
CComPtr< IDataObject > pDataObject;
|
CComPtr< IDataObject > pDataObject;
|
||||||
HRESULT hr = pOleLinkComponent->m_pObj->QueryInterface( IID_IDataObject, (void**)&pDataObject );
|
HRESULT hr = pOleLinkComponent->m_pObj->QueryInterface( IID_IDataObject, (void**)&pDataObject );
|
||||||
if ( FAILED( hr ) || !pDataObject || OleQueryCreateFromData( pDataObject ) )
|
if ( SUCCEEDED( hr ) && pDataObject && SUCCEEDED( OleQueryCreateFromData( pDataObject ) ) )
|
||||||
throw io::IOException(); // TODO: the object doesn't allow initialization based on data
|
{
|
||||||
|
m_pIStorage = CreateNewIStorage_Impl();
|
||||||
|
if ( !m_pIStorage )
|
||||||
|
throw uno::RuntimeException(); // TODO:
|
||||||
|
|
||||||
m_pIStorage = CreateNewIStorage_Impl();
|
|
||||||
if ( !m_pIStorage )
|
|
||||||
throw uno::RuntimeException(); // TODO:
|
|
||||||
|
|
||||||
hr = OleCreateFromData( pDataObject,
|
hr = OleCreateFromData( pDataObject,
|
||||||
IID_IUnknown,
|
IID_IUnknown,
|
||||||
OLERENDER_DRAW,
|
OLERENDER_DRAW,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
m_pIStorage,
|
m_pIStorage,
|
||||||
(void**)&m_pObj );
|
(void**)&m_pObj );
|
||||||
|
}
|
||||||
|
|
||||||
if ( FAILED( hr ) || !m_pObj)
|
if ( !m_pObj )
|
||||||
|
{
|
||||||
|
CComPtr< IOleLink > pOleLink;
|
||||||
|
hr = pOleLinkComponent->m_pObj->QueryInterface( IID_IOleLink, (void**)&pOleLink );
|
||||||
|
if ( FAILED( hr ) || !pOleLink )
|
||||||
|
throw io::IOException(); // TODO: the object doesn't support IOleLink
|
||||||
|
|
||||||
|
CComPtr< IMoniker > pMoniker;
|
||||||
|
hr = pOleLink->GetSourceMoniker( &pMoniker );
|
||||||
|
if ( FAILED( hr ) || !pMoniker )
|
||||||
|
throw io::IOException(); // TODO: can not retrieve moniker
|
||||||
|
|
||||||
|
// In case of file moniker life is easy :)
|
||||||
|
DWORD aMonType = 0;
|
||||||
|
hr = pMoniker->IsSystemMoniker( &aMonType );
|
||||||
|
if ( SUCCEEDED( hr ) && aMonType == MKSYS_FILEMONIKER )
|
||||||
|
{
|
||||||
|
CComPtr< IMalloc > pMalloc;
|
||||||
|
CoGetMalloc( 1, &pMalloc ); // if fails there will be a memory leak
|
||||||
|
OSL_ENSURE( pMalloc, "CoGetMalloc() failed!" );
|
||||||
|
|
||||||
|
LPOLESTR pOleStr = NULL;
|
||||||
|
hr = pOleLink->GetSourceDisplayName( &pOleStr );
|
||||||
|
if ( SUCCEEDED( hr ) && pOleStr )
|
||||||
|
{
|
||||||
|
::rtl::OUString aFilePath( (sal_Unicode*)pOleStr );
|
||||||
|
if ( pMalloc )
|
||||||
|
pMalloc->Free( (void*)pOleStr );
|
||||||
|
|
||||||
|
hr = OleCreateFromFile( CLSID_NULL,
|
||||||
|
aFilePath.getStr(),
|
||||||
|
IID_IUnknown,
|
||||||
|
OLERENDER_DRAW, // OLERENDER_FORMAT
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
m_pIStorage,
|
||||||
|
(void**)&m_pObj );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// in case of other moniker types the only way is to get storage
|
||||||
|
if ( !m_pObj )
|
||||||
|
{
|
||||||
|
CComPtr< IBindCtx > pBindCtx;
|
||||||
|
hr = CreateBindCtx( 0, (LPBC FAR*)&pBindCtx );
|
||||||
|
if ( SUCCEEDED( hr ) && pBindCtx )
|
||||||
|
{
|
||||||
|
CComPtr< IStorage > pObjectStorage;
|
||||||
|
hr = pMoniker->BindToStorage( pBindCtx, NULL, IID_IStorage, (void**)&pObjectStorage );
|
||||||
|
if ( SUCCEEDED( hr ) && pObjectStorage )
|
||||||
|
{
|
||||||
|
hr = pObjectStorage->CopyTo( 0, NULL, NULL, m_pIStorage );
|
||||||
|
if ( SUCCEEDED( hr ) )
|
||||||
|
hr = OleLoad( m_pIStorage, IID_IUnknown, NULL, (void**)&m_pObj );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If object could not be created the only way is to use graphical representation
|
||||||
|
if ( FAILED( hr ) || !m_pObj )
|
||||||
throw uno::RuntimeException(); // TODO
|
throw uno::RuntimeException(); // TODO
|
||||||
|
|
||||||
// TODO: May be the Icon should be also copied?
|
// TODO: May be the Icon should be also copied?
|
||||||
|
@@ -2,9 +2,9 @@
|
|||||||
*
|
*
|
||||||
* $RCSfile: olepersist.cxx,v $
|
* $RCSfile: olepersist.cxx,v $
|
||||||
*
|
*
|
||||||
* $Revision: 1.7 $
|
* $Revision: 1.8 $
|
||||||
*
|
*
|
||||||
* last change: $Author: mav $ $Date: 2003-11-26 10:27:48 $
|
* last change: $Author: mav $ $Date: 2003-11-26 16:44:04 $
|
||||||
*
|
*
|
||||||
* The Contents of this file are made available subject to the terms of
|
* The Contents of this file are made available subject to the terms of
|
||||||
* either of the following licenses
|
* either of the following licenses
|
||||||
@@ -111,7 +111,7 @@ void OleEmbeddedObject::SwitchOwnPersistence( const uno::Reference< embed::XStor
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
uno::Reference< lang::XComponent > xComponent( m_xObjectStream, uno::UNO_QUERY );
|
uno::Reference< lang::XComponent > xComponent( m_xObjectStream, uno::UNO_QUERY );
|
||||||
OSL_ENSURE( xComponent.is(), "Wrong stream implementation!" );
|
OSL_ENSURE( !m_xObjectStream.is() || xComponent.is(), "Wrong stream implementation!" );
|
||||||
if ( xComponent.is() )
|
if ( xComponent.is() )
|
||||||
xComponent->dispose();
|
xComponent->dispose();
|
||||||
}
|
}
|
||||||
@@ -766,7 +766,7 @@ void SAL_CALL OleEmbeddedObject::breakLink( const uno::Reference< embed::XStorag
|
|||||||
GetRidOfComponent();
|
GetRidOfComponent();
|
||||||
CreateOleComponent_Impl( pNewOleComponent );
|
CreateOleComponent_Impl( pNewOleComponent );
|
||||||
|
|
||||||
if ( m_xParentStorage != xStorage || !m_aNewEntryName.equals( sEntName ) )
|
if ( m_xParentStorage != xStorage || !m_aEntryName.equals( sEntName ) )
|
||||||
SwitchOwnPersistence( xStorage, sEntName );
|
SwitchOwnPersistence( xStorage, sEntName );
|
||||||
|
|
||||||
if ( m_nObjectState != embed::EmbedStates::EMBED_LOADED )
|
if ( m_nObjectState != embed::EmbedStates::EMBED_LOADED )
|
||||||
|
Reference in New Issue
Block a user