summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--basctl/source/basicide/bastype2.cxx31
-rw-r--r--basctl/source/basicide/scriptdocument.cxx4
-rw-r--r--basctl/source/inc/bastypes.hxx10
3 files changed, 38 insertions, 7 deletions
diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx
index 2360011399dd..0709fe38cbe2 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 6d175674a63d..a8c6d24a3ff5 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 c9981001e456..bc588fccaf14 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