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 @@ ...@@ -55,13 +55,36 @@
#include <com/sun/star/script/XVBAModuleInfo.hpp> #include <com/sun/star/script/XVBAModuleInfo.hpp>
#include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/script/XVBAModuleInfo.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::uno;
using namespace ::com::sun::star; 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; sal_Int32 nType = com::sun::star::script::ModuleType::NORMAL;
uno::Reference< script::XVBAModuleInfo > xVBAModuleInfo( rLib, uno::UNO_QUERY ); uno::Reference< script::XVBAModuleInfo > xVBAModuleInfo( rLib, uno::UNO_QUERY );
...@@ -446,7 +469,7 @@ void BasicTreeListBox::ImpCreateLibSubSubEntriesInVBAMode( SvLBoxEntry* pLibSubR ...@@ -446,7 +469,7 @@ void BasicTreeListBox::ImpCreateLibSubSubEntriesInVBAMode( SvLBoxEntry* pLibSubR
{ {
String aModName = pModNames[ i ]; String aModName = pModNames[ i ];
BasicEntryType eType = OBJ_TYPE_UNKNOWN; BasicEntryType eType = OBJ_TYPE_UNKNOWN;
switch( lcl_getModuleType( xLib, aModName ) ) switch( ModuleInfoHelper::getModuleType( xLib, aModName ) )
{ {
case script::ModuleType::DOCUMENT: case script::ModuleType::DOCUMENT:
eType = OBJ_TYPE_DOCUMENT_OBJECTS; eType = OBJ_TYPE_DOCUMENT_OBJECTS;
...@@ -470,7 +493,7 @@ void BasicTreeListBox::ImpCreateLibSubSubEntriesInVBAMode( SvLBoxEntry* pLibSubR ...@@ -470,7 +493,7 @@ void BasicTreeListBox::ImpCreateLibSubSubEntriesInVBAMode( SvLBoxEntry* pLibSubR
if( eType == OBJ_TYPE_DOCUMENT_OBJECTS ) if( eType == OBJ_TYPE_DOCUMENT_OBJECTS )
{ {
String sObjName; String sObjName;
lcl_getObjectName( xLib, aModName, sObjName ); ModuleInfoHelper::getObjectName( xLib, aModName, sObjName );
if( sObjName.Len() ) if( sObjName.Len() )
{ {
aEntryName.AppendAscii(" (").Append(sObjName).AppendAscii(")"); aEntryName.AppendAscii(" (").Append(sObjName).AppendAscii(")");
......
...@@ -691,7 +691,7 @@ namespace basctl ...@@ -691,7 +691,7 @@ namespace basctl
} }
// insert element by new name in container // insert element by new name in container
if ( _eType == E_SCRIPTS ) else if ( _eType == E_SCRIPTS )
{ {
Reference< XVBAModuleInfo > xVBAModuleInfo( xLib, UNO_QUERY ); Reference< XVBAModuleInfo > xVBAModuleInfo( xLib, UNO_QUERY );
if ( xVBAModuleInfo->hasModuleInfo( _rOldName ) ) if ( xVBAModuleInfo->hasModuleInfo( _rOldName ) )
...@@ -765,7 +765,7 @@ namespace basctl ...@@ -765,7 +765,7 @@ namespace basctl
Reference< XNameContainer > xLib( getOrCreateLibrary( E_SCRIPTS, _rLibName ), UNO_QUERY_THROW ); Reference< XNameContainer > xLib( getOrCreateLibrary( E_SCRIPTS, _rLibName ), UNO_QUERY_THROW );
if ( !xLib->hasByName( _rModName ) ) if ( !xLib->hasByName( _rModName ) )
return false; return false;
xLib->replaceByName( _rModName, makeAny( _rModuleCode ) ); xLib->replaceByName( _rModName, makeAny( _rModuleCode ) );
return true; return true;
} }
catch( const Exception& ) catch( const Exception& )
......
...@@ -328,5 +328,13 @@ BOOL QueryDelModule( const String& rName, Window* pParent = 0 ); ...@@ -328,5 +328,13 @@ BOOL QueryDelModule( const String& rName, Window* pParent = 0 );
BOOL QueryDelLib( const String& rName, BOOL bRef = FALSE, 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 ); 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 #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