summaryrefslogtreecommitdiff
path: root/sfx2/source/doc/objxtor.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sfx2/source/doc/objxtor.cxx')
-rw-r--r--sfx2/source/doc/objxtor.cxx50
1 files changed, 44 insertions, 6 deletions
diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx
index 017b5873e5..d850fc03c7 100644
--- a/sfx2/source/doc/objxtor.cxx
+++ b/sfx2/source/doc/objxtor.cxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -124,6 +124,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 )
+ {
+ }
+ }
+ }
+}
+
//=========================================================================
@@ -158,6 +192,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 >() );
}
@@ -910,7 +945,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";
@@ -1100,7 +1138,7 @@ bool SfxObjectShell::IsChangeRecording() const
return false;
}
-
+
bool SfxObjectShell::HasChangeRecordProtection() const
{
// currently this function needs to be overwritten by Writer and Calc only
@@ -1108,20 +1146,20 @@ bool SfxObjectShell::HasChangeRecordProtection() const
return false;
}
-
+
void SfxObjectShell::SetChangeRecording( bool /*bActivate*/ )
{
// currently this function needs to be overwritten by Writer and Calc only
DBG_ASSERT( 0, "function not implemented" );
}
-
+
bool SfxObjectShell::SetProtectionPassword( const String & /*rPassword*/ )
{
// currently this function needs to be overwritten by Writer and Calc only
DBG_ASSERT( 0, "function not implemented" );
return false;
-}
+}
bool SfxObjectShell::GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > & /*rPasswordHash*/ )
@@ -1129,5 +1167,5 @@ bool SfxObjectShell::GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence<
// currently this function needs to be overwritten by Writer and Calc only
DBG_ASSERT( 0, "function not implemented" );
return false;
-}
+}