Kaydet (Commit) ed584a8b authored tarafından Mikhail Voitenko's avatar Mikhail Voitenko

#112923# let object work on unix

üst 2ea6cb57
......@@ -2,9 +2,9 @@
*
* $RCSfile: oleembobj.hxx,v $
*
* $Revision: 1.8 $
* $Revision: 1.9 $
*
* last change: $Author: mav $ $Date: 2003-12-09 15:09:30 $
* last change: $Author: mav $ $Date: 2003-12-15 15:37:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -205,6 +205,7 @@ public:
sal_Bool OnShowWindow_Impl( sal_Bool bShow );
void CreateOleComponent_Impl( OleComponent* pOleComponent = NULL );
void CreateOleComponentAndLoad_Impl( OleComponent* pOleComponent = NULL );
void SetObjectIsLink_Impl( sal_Bool bIsLink ) { m_bIsLink = bIsLink; }
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: olecomponent.cxx,v $
*
* $Revision: 1.15 $
* $Revision: 1.16 $
*
* last change: $Author: mav $ $Date: 2003-12-15 13:10:01 $
* last change: $Author: mav $ $Date: 2003-12-15 15:37:42 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -98,13 +98,15 @@ using namespace ::com::sun::star;
#define MAX_ENUM_ELE 20
#define FORMATS_NUM 3
const sal_Int32 n_ConstBufferSize = 32000;
sal_Bool ConvertBufferToFormat( void* pBuf,
sal_uInt32 nBufSize,
const ::rtl::OUString& aFormatShortName,
uno::Any& aResult );
void copyInputToOutput_Impl( const uno::Reference< io::XInputStream >& aIn,
const uno::Reference< io::XOutputStream >& aOut );
typedef ::std::vector< FORMATETC* > FormatEtcList;
FORMATETC pFormatTemplates[FORMATS_NUM] = {
......@@ -325,29 +327,6 @@ sal_Bool OleComponentNative_Impl::GraphicalFlavor( const datatransfer::DataFlavo
return sal_False;
}
//-----------------------------------------------
// TODO: probably later such a common function can be moved
// to a separate helper library.
void copyInputToOutput_Impl( const uno::Reference< io::XInputStream >& aIn,
const uno::Reference< io::XOutputStream >& aOut )
{
sal_Int32 nRead;
uno::Sequence < sal_Int8 > aSequence ( n_ConstBufferSize );
do
{
nRead = aIn->readBytes ( aSequence, n_ConstBufferSize );
if ( nRead < n_ConstBufferSize )
{
uno::Sequence < sal_Int8 > aTempBuf ( aSequence.getConstArray(), nRead );
aOut->writeBytes ( aTempBuf );
}
else
aOut->writeBytes ( aSequence );
}
while ( nRead == n_ConstBufferSize );
}
//-----------------------------------------------
sal_Bool KillFile( const ::rtl::OUString& aURL, const uno::Reference< lang::XMultiServiceFactory >& xFactory )
{
......@@ -579,6 +558,8 @@ FORMATETC* OleComponentNative_Impl::GetSupportedFormatForAspect( sal_uInt32 nReq
//----------------------------------------------
void OleComponent::Dispose()
{
CloseObject();
if ( m_pOleWrapClientSite )
{
m_pOleWrapClientSite->disconnectOleComponent();
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: oleembed.cxx,v $
*
* $Revision: 1.3 $
* $Revision: 1.4 $
*
* last change: $Author: mav $ $Date: 2003-12-12 12:50:52 $
* last change: $Author: mav $ $Date: 2003-12-15 15:37:42 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -147,25 +147,30 @@ void SAL_CALL OleEmbeddedObject::changeState( sal_Int32 nNewState )
if ( m_nObjectState == nNewState )
return;
if ( !m_pOleComponent )
throw uno::RuntimeException();
#ifdef WNT
// TODO: additional verbs can be a problem, since nobody knows how the object
// will behave after activation
if ( nNewState == embed::EmbedStates::EMBED_LOADED )
{
// This means just closing of the current object
SaveObject_Impl();
m_pOleComponent->CloseObject();
// If component can not be closed the object stays in loaded state
// and it holds reference to "incomplete" component
// If the object is switched to running state later
// the component will become "complete"
GetRidOfComponent( sal_False );
}
else
else if ( nNewState == embed::EmbedStates::EMBED_RUNNING || nNewState == embed::EmbedStates::EMBED_ACTIVE )
{
if ( m_nObjectState == embed::EmbedStates::EMBED_LOADED )
{
// if the target object is in loaded state and a different state is specified
// as a new one the object first must be switched to running state.
// the component can exist already in nonrunning state
// it can be created during loading to detect type of object
CreateOleComponentAndLoad_Impl( m_pOleComponent );
m_pOleComponent->RunObject();
m_nObjectState = embed::EmbedStates::EMBED_RUNNING;
if ( m_nObjectState == nNewState )
......@@ -185,9 +190,13 @@ void SAL_CALL OleEmbeddedObject::changeState( sal_Int32 nNewState )
}
else
{
OSL_ENSURE( sal_False, "Unreachable code executed!" );
throw embed::UnreachableStateException();
}
}
else
#endif
throw embed::UnreachableStateException();
}
//----------------------------------------------
......@@ -203,18 +212,22 @@ uno::Sequence< sal_Int32 > SAL_CALL OleEmbeddedObject::getReachableStates()
throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ),
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) );
if ( !m_pOleComponent )
throw uno::RuntimeException();
#ifdef WNT
if ( m_nObjectState == embed::EmbedStates::EMBED_LOADED )
{
// the list of supported verbs can be retrieved only when object is in running state
throw embed::NeedsRunningStateException(); // TODO:
}
if ( !m_pOleComponent )
throw uno::RuntimeException();
// the list of states can only be guessed based on standard verbs,
// since there is no way to detect what additional verbs do
return GetReachableStatesList_Impl( m_pOleComponent->GetVerbList() );
#else
return uno::Sequence< sal_Int32 >();
#endif
}
//----------------------------------------------
......@@ -250,19 +263,26 @@ void SAL_CALL OleEmbeddedObject::doVerb( sal_Int32 nVerbID )
throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ),
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) );
if ( !m_pOleComponent )
throw uno::RuntimeException();
#ifdef WNT
if ( m_nObjectState == embed::EmbedStates::EMBED_LOADED )
{
// if the target object is in loaded state
// it must be switched to running state to execute verb
// the component can exist already in noncomplete state
// it can be created during loading
CreateOleComponentAndLoad_Impl( m_pOleComponent );
m_pOleComponent->RunObject();
m_nObjectState = embed::EmbedStates::EMBED_RUNNING;
}
if ( !m_pOleComponent )
throw uno::RuntimeException();
m_pOleComponent->ExecuteVerb( nVerbID );
#else
throw embed::UnreachableStateException();
#endif
}
//----------------------------------------------
......@@ -277,14 +297,20 @@ uno::Sequence< embed::VerbDescr > SAL_CALL OleEmbeddedObject::getSupportedVerbs(
if ( m_nObjectState == -1 )
throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ),
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) );
#ifdef WNT
if ( m_nObjectState == embed::EmbedStates::EMBED_LOADED )
{
// the list of supported verbs can be retrieved only when object is in running state
throw embed::NeedsRunningStateException(); // TODO:
}
if ( !m_pOleComponent )
throw uno::RuntimeException();
return m_pOleComponent->GetVerbList();
#else
return uno::Sequence< embed::VerbDescr >();
#endif
}
//----------------------------------------------
......@@ -377,6 +403,14 @@ sal_Int64 SAL_CALL OleEmbeddedObject::getStatus( sal_Int64 nAspect )
throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object must be in running state!\n" ),
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) );
#ifdef WNT
if ( !m_pOleComponent )
throw uno::RuntimeException();
return m_pOleComponent->GetMiscStatus( nAspect );
#else
throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "Illegal call!\n" ),
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) );
#endif
}
......@@ -2,9 +2,9 @@
*
* $RCSfile: olemisc.cxx,v $
*
* $Revision: 1.9 $
* $Revision: 1.10 $
*
* last change: $Author: mav $ $Date: 2003-12-12 12:50:52 $
* last change: $Author: mav $ $Date: 2003-12-15 15:37:43 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -138,20 +138,30 @@ OleEmbeddedObject::~OleEmbeddedObject()
//------------------------------------------------------
void OleEmbeddedObject::GetRidOfComponent()
{
#ifdef WNT
if ( m_pOleComponent )
{
if ( m_nObjectState != embed::EmbedStates::EMBED_LOADED )
{
SaveObject_Impl();
m_pOleComponent->CloseObject();
}
m_pOleComponent->removeCloseListener( m_xClosePreventer );
m_pOleComponent->close( sal_True );
try
{
m_pOleComponent->close( sal_False );
}
catch( uno::Exception& )
{
// TODO: there should be a special listener to wait for component closing
// and to notify object, may be object itself can be such a listener
m_pOleComponent->addCloseListener( m_xClosePreventer );
throw;
}
m_pOleComponent->disconnectEmbeddedObject();
m_pOleComponent->release();
m_pOleComponent = NULL;
}
#endif
}
//------------------------------------------------------
......@@ -165,6 +175,8 @@ void OleEmbeddedObject::Dispose()
m_pInterfaceContainer = NULL;
}
m_bDisposed = true;
if ( m_pOleComponent )
GetRidOfComponent();
......@@ -183,8 +195,6 @@ void OleEmbeddedObject::Dispose()
}
m_xParentStorage = uno::Reference< embed::XStorage >();
m_bDisposed = true;
}
//------------------------------------------------------
......@@ -229,7 +239,7 @@ uno::Reference< util::XCloseable > SAL_CALL OleEmbeddedObject::getComponent()
if ( m_nObjectState == -1 || m_nObjectState == embed::EmbedStates::EMBED_LOADED )
{
// the object is still not loaded
// the object is still not running
throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object is not running!\n" ),
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) );
}
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: olevisual.cxx,v $
*
* $Revision: 1.1 $
* $Revision: 1.2 $
*
* last change: $Author: mav $ $Date: 2003-11-13 17:01:14 $
* last change: $Author: mav $ $Date: 2003-12-15 15:37:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -96,11 +96,15 @@ void SAL_CALL OleEmbeddedObject::setVisAreaSize( sal_Int64 nAspect, const awt::S
if ( m_nObjectState == -1 || m_nObjectState == embed::EmbedStates::EMBED_LOADED )
throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The own object has no model!\n" ),
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) );
#ifdef WNT
if ( !m_pOleComponent )
throw uno::RuntimeException();
m_pOleComponent->SetExtent( aSize, nAspect ); // will throw an exception in case of failure
#else
throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "Illegal call!\n" ),
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) );
#endif
}
awt::Size SAL_CALL OleEmbeddedObject::getVisAreaSize( sal_Int64 nAspect )
......@@ -116,11 +120,15 @@ awt::Size SAL_CALL OleEmbeddedObject::getVisAreaSize( sal_Int64 nAspect )
if ( m_nObjectState == -1 || m_nObjectState == embed::EmbedStates::EMBED_LOADED )
throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The own object has no model!\n" ),
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) );
#ifdef WNT
if ( !m_pOleComponent )
throw uno::RuntimeException();
return m_pOleComponent->GetExtent( nAspect ); // will throw an exception in case of failure
#else
throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "Illegal call!\n" ),
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) );
#endif
}
// Probably will be removed!!!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment