summaryrefslogtreecommitdiff
path: root/sfx2/source/doc/objxtor.cxx
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2010-10-06 10:16:27 +0100
committerNoel Power <noel.power@novell.com>2010-10-06 10:16:27 +0100
commit0b21b8b146fc4b982c7c9bbb866b9ff18a29332a (patch)
tree9b36a1dee6f92703604bcc86564568eefe711c22 /sfx2/source/doc/objxtor.cxx
parent8d4d17664c9c6207fa35458075559d1fbfbfa2a5 (diff)
initial commit for vba blob ( not including container_control stuff )
Diffstat (limited to 'sfx2/source/doc/objxtor.cxx')
-rw-r--r--sfx2/source/doc/objxtor.cxx38
1 files changed, 38 insertions, 0 deletions
diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx
index b7567b89f02f..dc8be0c0e764 100644
--- a/sfx2/source/doc/objxtor.cxx
+++ b/sfx2/source/doc/objxtor.cxx
@@ -134,6 +134,40 @@ DBG_NAME(SfxObjectShell)
static WeakReference< XInterface > s_xCurrentComponent;
+void lcl_UpdateAppBasicDocVars( const Reference< XInterface >& _rxComponent, bool bClear = false )
+{
+ BasicManager* pAppMgr = SFX_APP()->GetBasicManager();
+ if ( pAppMgr )
+ {
+ uno::Reference< beans::XPropertySet > xProps( _rxComponent, uno::UNO_QUERY );
+ if ( xProps.is() )
+ {
+ try
+ {
+ // ThisVBADocObj contains a PropertyValue
+ // Name is ( the name of the VBA global to insert )
+ // Value is the Object to insert.
+ // ( note: at the moment the Value is actually the model so
+ // it strictly is not necessary, however we do intend to store
+ // not the model in basic but a custom object, so we keep this
+ // level of indirection for future proofing )
+ beans::PropertyValue aProp;
+ xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ThisVBADocObj") ) ) >>= aProp;
+ rtl::OString sTmp( rtl::OUStringToOString( aProp.Name, RTL_TEXTENCODING_UTF8 ) );
+ const char* pAscii = sTmp.getStr();
+ if ( bClear )
+ pAppMgr->SetGlobalUNOConstant( pAscii, uno::makeAny( uno::Reference< uno::XInterface >() ) );
+ else
+ pAppMgr->SetGlobalUNOConstant( pAscii, aProp.Value );
+
+ }
+ catch( uno::Exception& e )
+ {
+ }
+ }
+ }
+}
+
//=========================================================================
@@ -168,6 +202,7 @@ void SAL_CALL SfxModelListener_Impl::disposing( const com::sun::star::lang::Even
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
if ( SfxObjectShell::GetCurrentComponent() == _rEvent.Source )
{
+ lcl_UpdateAppBasicDocVars( SfxObjectShell::GetCurrentComponent(), true );
// remove ThisComponent reference from AppBasic
SfxObjectShell::SetCurrentComponent( Reference< XInterface >() );
}
@@ -919,7 +954,10 @@ void SfxObjectShell::SetCurrentComponent( const Reference< XInterface >& _rxComp
BasicManager* pAppMgr = SFX_APP()->GetBasicManager();
s_xCurrentComponent = _rxComponent;
if ( pAppMgr )
+ {
+ lcl_UpdateAppBasicDocVars( _rxComponent );
pAppMgr->SetGlobalUNOConstant( "ThisComponent", makeAny( _rxComponent ) );
+ }
#if OSL_DEBUG_LEVEL > 0
const char* pComponentImplName = _rxComponent.get() ? typeid( *_rxComponent.get() ).name() : "void";