Kaydet (Commit) 7780dbea authored tarafından npower Developer's avatar npower Developer

npower13_objectmodules: fold in review comment ( about making lcl_getObjectName…

npower13_objectmodules: fold in review comment ( about making lcl_getObjectName & lcl_getModuleType  'real' methods of a helper for basctl)
üst d17f9a78
......@@ -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(")");
......
......@@ -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 ) )
......
......@@ -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
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