diff options
author | npower Developer <npower@openoffice.org> | 2010-04-19 11:02:13 +0100 |
---|---|---|
committer | npower Developer <npower@openoffice.org> | 2010-04-19 11:02:13 +0100 |
commit | 734f4532a5f48c78ef83c9b3a1e2cecef67871c5 (patch) | |
tree | 52fe962fdfa90756b2cc01039e4b2381fbef4255 /basctl/source | |
parent | 56a832522bd2b6ff81104dd92864d4ea4c0f8237 (diff) |
npower13_objectmodules: fold in review comment ( about making lcl_getObjectName & lcl_getModuleType 'real' methods of a helper for basctl)
Diffstat (limited to 'basctl/source')
-rw-r--r-- | basctl/source/basicide/bastype2.cxx | 31 | ||||
-rw-r--r-- | basctl/source/basicide/scriptdocument.cxx | 4 | ||||
-rw-r--r-- | basctl/source/inc/bastypes.hxx | 10 |
3 files changed, 38 insertions, 7 deletions
diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx index e9b0d4570..f112d5a06 100644 --- a/basctl/source/basicide/bastype2.cxx +++ b/basctl/source/basicide/bastype2.cxx @@ -55,13 +55,36 @@ #include <com/sun/star/script/XVBAModuleInfo.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/script/XVBAModuleInfo.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XNamed.hpp> using namespace ::com::sun::star::uno; using namespace ::com::sun::star; -void lcl_getObjectName( const uno::Reference< container::XNameContainer >& rLib, const String& rModName, String& rObjName ); +void ModuleInfoHelper::getObjectName( const uno::Reference< container::XNameContainer >& rLib, const String& rModName, String& rObjName ) +{ + try + { + uno::Reference< script::XVBAModuleInfo > xVBAModuleInfo( rLib, uno::UNO_QUERY ); + if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( rModName ) ) + { + script::ModuleInfo aModuleInfo = xVBAModuleInfo->getModuleInfo( rModName ); + uno::Any aObject( aModuleInfo.ModuleObject ); + uno::Reference< lang::XServiceInfo > xServiceInfo( aObject, uno::UNO_QUERY ); + if( xServiceInfo.is() && xServiceInfo->supportsService( rtl::OUString::createFromAscii( "ooo.vba.excel.Worksheet" ) ) ) + { + uno::Reference< container::XNamed > xNamed( aObject, uno::UNO_QUERY ); + if( xNamed.is() ) + rObjName = xNamed->getName(); + } + } + } + catch( uno::Exception& ) + { + } +} -sal_Int32 lcl_getModuleType( const uno::Reference< container::XNameContainer >& rLib, const String& rModName ) +sal_Int32 ModuleInfoHelper::getModuleType( const uno::Reference< container::XNameContainer >& rLib, const String& rModName ) { sal_Int32 nType = com::sun::star::script::ModuleType::NORMAL; uno::Reference< script::XVBAModuleInfo > xVBAModuleInfo( rLib, uno::UNO_QUERY ); @@ -446,7 +469,7 @@ void BasicTreeListBox::ImpCreateLibSubSubEntriesInVBAMode( SvLBoxEntry* pLibSubR { String aModName = pModNames[ i ]; BasicEntryType eType = OBJ_TYPE_UNKNOWN; - switch( lcl_getModuleType( xLib, aModName ) ) + switch( ModuleInfoHelper::getModuleType( xLib, aModName ) ) { case script::ModuleType::DOCUMENT: eType = OBJ_TYPE_DOCUMENT_OBJECTS; @@ -470,7 +493,7 @@ void BasicTreeListBox::ImpCreateLibSubSubEntriesInVBAMode( SvLBoxEntry* pLibSubR if( eType == OBJ_TYPE_DOCUMENT_OBJECTS ) { String sObjName; - lcl_getObjectName( xLib, aModName, sObjName ); + ModuleInfoHelper::getObjectName( xLib, aModName, sObjName ); if( sObjName.Len() ) { aEntryName.AppendAscii(" (").Append(sObjName).AppendAscii(")"); diff --git a/basctl/source/basicide/scriptdocument.cxx b/basctl/source/basicide/scriptdocument.cxx index 18119d43d..b85ac9216 100644 --- a/basctl/source/basicide/scriptdocument.cxx +++ b/basctl/source/basicide/scriptdocument.cxx @@ -691,7 +691,7 @@ namespace basctl } // insert element by new name in container - if ( _eType == E_SCRIPTS ) + else if ( _eType == E_SCRIPTS ) { Reference< XVBAModuleInfo > xVBAModuleInfo( xLib, UNO_QUERY ); if ( xVBAModuleInfo->hasModuleInfo( _rOldName ) ) @@ -765,7 +765,7 @@ namespace basctl Reference< XNameContainer > xLib( getOrCreateLibrary( E_SCRIPTS, _rLibName ), UNO_QUERY_THROW ); if ( !xLib->hasByName( _rModName ) ) return false; - xLib->replaceByName( _rModName, makeAny( _rModuleCode ) ); + xLib->replaceByName( _rModName, makeAny( _rModuleCode ) ); return true; } catch( const Exception& ) diff --git a/basctl/source/inc/bastypes.hxx b/basctl/source/inc/bastypes.hxx index 74d239f3c..034a46010 100644 --- a/basctl/source/inc/bastypes.hxx +++ b/basctl/source/inc/bastypes.hxx @@ -328,5 +328,13 @@ BOOL QueryDelModule( const String& rName, Window* pParent = 0 ); BOOL QueryDelLib( const String& rName, BOOL bRef = FALSE, Window* pParent = 0 ); BOOL QueryPassword( const ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer >& xLibContainer, const String& rLibName, String& rPassword, BOOL bRepeat = FALSE, BOOL bNewTitle = FALSE ); - +class ModuleInfoHelper +{ +ModuleInfoHelper(); +ModuleInfoHelper(const ModuleInfoHelper&); +ModuleInfoHelper& operator = (const ModuleInfoHelper&); +public: + static void getObjectName( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rLib, const String& rModName, String& rObjName ); + static sal_Int32 getModuleType( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rLib, const String& rModName ); +}; #endif // _BASTYPES_HXX |