rtl::OUString cleanup in basctl

Change-Id: If57c184b355224f31fdf7872ab1f52c034e5c7f0
Reviewed-on: https://gerrit.libreoffice.org/872
Reviewed-by: Olivier Hallot <olivier.hallot@alta.org.br>
Tested-by: Olivier Hallot <olivier.hallot@alta.org.br>
This commit is contained in:
Ricardo Montania
2012-10-14 18:31:59 -03:00
committed by Olivier Hallot
parent ae92b2730c
commit 20e7a9bda9
3 changed files with 41 additions and 42 deletions

View File

@@ -70,7 +70,7 @@ sal_Bool ExtTreeListBox::EditingEntry( SvLBoxEntry* pEntry, Selection& )
{ {
EntryDescriptor aDesc = GetEntryDescriptor(pEntry); EntryDescriptor aDesc = GetEntryDescriptor(pEntry);
ScriptDocument aDocument( aDesc.GetDocument() ); ScriptDocument aDocument( aDesc.GetDocument() );
::rtl::OUString aLibName( aDesc.GetLibName() ); OUString aLibName( aDesc.GetLibName() );
Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY ); Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY ); Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) || if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) ||
@@ -85,7 +85,7 @@ sal_Bool ExtTreeListBox::EditingEntry( SvLBoxEntry* pEntry, Selection& )
return bRet; return bRet;
} }
sal_Bool ExtTreeListBox::EditedEntry( SvLBoxEntry* pEntry, const rtl::OUString& rNewText ) sal_Bool ExtTreeListBox::EditedEntry( SvLBoxEntry* pEntry, const OUString& rNewText )
{ {
if ( !IsValidSbxName(rNewText) ) if ( !IsValidSbxName(rNewText) )
{ {
@@ -93,7 +93,7 @@ sal_Bool ExtTreeListBox::EditedEntry( SvLBoxEntry* pEntry, const rtl::OUString&
return false; return false;
} }
rtl::OUString aCurText( GetEntryText( pEntry ) ); OUString aCurText( GetEntryText( pEntry ) );
if ( aCurText == rNewText ) if ( aCurText == rNewText )
// nothing to do // nothing to do
return true; return true;
@@ -103,7 +103,7 @@ sal_Bool ExtTreeListBox::EditedEntry( SvLBoxEntry* pEntry, const rtl::OUString&
DBG_ASSERT( aDocument.isValid(), "ExtTreeListBox::EditedEntry: no document!" ); DBG_ASSERT( aDocument.isValid(), "ExtTreeListBox::EditedEntry: no document!" );
if ( !aDocument.isValid() ) if ( !aDocument.isValid() )
return false; return false;
::rtl::OUString aLibName( aDesc.GetLibName() ); OUString aLibName( aDesc.GetLibName() );
EntryType eType = aDesc.GetType(); EntryType eType = aDesc.GetType();
bool bSuccess = eType == OBJ_TYPE_MODULE ? bool bSuccess = eType == OBJ_TYPE_MODULE ?
@@ -145,7 +145,7 @@ DragDropMode ExtTreeListBox::NotifyStartDrag( TransferDataContainer&, SvLBoxEntr
nMode_ = SV_DRAGDROP_CTRL_COPY; nMode_ = SV_DRAGDROP_CTRL_COPY;
EntryDescriptor aDesc = GetEntryDescriptor(pEntry); EntryDescriptor aDesc = GetEntryDescriptor(pEntry);
ScriptDocument aDocument( aDesc.GetDocument() ); ScriptDocument aDocument( aDesc.GetDocument() );
::rtl::OUString aLibName( aDesc.GetLibName() ); OUString aLibName( aDesc.GetLibName() );
// allow MOVE mode only for libraries, which are not readonly // allow MOVE mode only for libraries, which are not readonly
Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY ); Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY ); Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
@@ -192,13 +192,13 @@ sal_Bool ExtTreeListBox::NotifyAcceptDrop( SvLBoxEntry* pEntry )
{ {
// get source module/dialog name // get source module/dialog name
EntryDescriptor aSourceDesc = GetEntryDescriptor(pSelected); EntryDescriptor aSourceDesc = GetEntryDescriptor(pSelected);
rtl::OUString aSourceName = aSourceDesc.GetName(); OUString aSourceName = aSourceDesc.GetName();
EntryType eSourceType = aSourceDesc.GetType(); EntryType eSourceType = aSourceDesc.GetType();
// get target shell and target library name // get target shell and target library name
EntryDescriptor aDestDesc = GetEntryDescriptor(pEntry); EntryDescriptor aDestDesc = GetEntryDescriptor(pEntry);
ScriptDocument const& rDestDoc = aDestDesc.GetDocument(); ScriptDocument const& rDestDoc = aDestDesc.GetDocument();
rtl::OUString aDestLibName = aDestDesc.GetLibName(); OUString aDestLibName = aDestDesc.GetLibName();
// check if module library is not loaded, readonly or password protected // check if module library is not loaded, readonly or password protected
Reference< script::XLibraryContainer2 > xModLibContainer( rDestDoc.getLibraryContainer( E_SCRIPTS ), UNO_QUERY ); Reference< script::XLibraryContainer2 > xModLibContainer( rDestDoc.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
@@ -255,10 +255,10 @@ sal_Bool ExtTreeListBox::NotifyCopying( SvLBoxEntry* pTarget, SvLBoxEntry* pEntr
void Shell::CopyDialogResources( void Shell::CopyDialogResources(
Reference< io::XInputStreamProvider >& io_xISP, Reference< io::XInputStreamProvider >& io_xISP,
ScriptDocument const& rSourceDoc, ScriptDocument const& rSourceDoc,
rtl::OUString const& rSourceLibName, OUString const& rSourceLibName,
ScriptDocument const& rDestDoc, ScriptDocument const& rDestDoc,
rtl::OUString const& rDestLibName, OUString const& rDestLibName,
rtl::OUString const& rDlgName OUString const& rDlgName
) )
{ {
if ( !io_xISP.is() ) if ( !io_xISP.is() )
@@ -285,7 +285,7 @@ void Shell::CopyDialogResources(
// create dialog model // create dialog model
Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
Reference< container::XNameContainer > xDialogModel = Reference< container::XNameContainer >( xMSF->createInstance Reference< container::XNameContainer > xDialogModel = Reference< container::XNameContainer >( xMSF->createInstance
( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), UNO_QUERY ); ( "com.sun.star.awt.UnoControlDialogModel" ), UNO_QUERY );
Reference< io::XInputStream > xInput( io_xISP->createInputStream() ); Reference< io::XInputStream > xInput( io_xISP->createInputStream() );
Reference< XComponentContext > xContext( Reference< XComponentContext > xContext(
comphelper::getComponentContext( xMSF ) ); comphelper::getComponentContext( xMSF ) );
@@ -335,13 +335,13 @@ sal_Bool ExtTreeListBox::NotifyCopyingMoving( SvLBoxEntry* pTarget, SvLBoxEntry*
// get target shell and target library name // get target shell and target library name
EntryDescriptor aDestDesc = GetEntryDescriptor(rpNewParent); EntryDescriptor aDestDesc = GetEntryDescriptor(rpNewParent);
const ScriptDocument& rDestDoc( aDestDesc.GetDocument() ); const ScriptDocument& rDestDoc( aDestDesc.GetDocument() );
::rtl::OUString aDestLibName( aDestDesc.GetLibName() ); OUString aDestLibName( aDestDesc.GetLibName() );
// get source shell, library name and module/dialog name // get source shell, library name and module/dialog name
EntryDescriptor aSourceDesc = GetEntryDescriptor(FirstSelected()); EntryDescriptor aSourceDesc = GetEntryDescriptor(FirstSelected());
const ScriptDocument rSourceDoc( aSourceDesc.GetDocument() ); const ScriptDocument rSourceDoc( aSourceDesc.GetDocument() );
::rtl::OUString aSourceLibName( aSourceDesc.GetLibName() ); OUString aSourceLibName( aSourceDesc.GetLibName() );
::rtl::OUString aSourceName( aSourceDesc.GetName() ); OUString aSourceName( aSourceDesc.GetName() );
EntryType eType = aSourceDesc.GetType(); EntryType eType = aSourceDesc.GetType();
// get dispatcher // get dispatcher
@@ -365,7 +365,7 @@ sal_Bool ExtTreeListBox::NotifyCopyingMoving( SvLBoxEntry* pTarget, SvLBoxEntry*
if ( eType == OBJ_TYPE_MODULE ) // module if ( eType == OBJ_TYPE_MODULE ) // module
{ {
// get module // get module
::rtl::OUString aModule; OUString aModule;
if ( rSourceDoc.getModule( aSourceLibName, aSourceName, aModule ) ) if ( rSourceDoc.getModule( aSourceLibName, aSourceName, aModule ) )
{ {
// remove module from source library // remove module from source library
@@ -412,7 +412,7 @@ sal_Bool ExtTreeListBox::NotifyCopyingMoving( SvLBoxEntry* pTarget, SvLBoxEntry*
if ( eType == OBJ_TYPE_MODULE ) // module if ( eType == OBJ_TYPE_MODULE ) // module
{ {
// get module // get module
::rtl::OUString aModule; OUString aModule;
if ( rSourceDoc.getModule( aSourceLibName, aSourceName, aModule ) ) if ( rSourceDoc.getModule( aSourceLibName, aSourceName, aModule ) )
{ {
// insert module into target library // insert module into target library
@@ -609,8 +609,8 @@ void ObjectPage::CheckButtons()
SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry(); SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry();
EntryDescriptor aDesc = aBasicBox.GetEntryDescriptor(pCurEntry); EntryDescriptor aDesc = aBasicBox.GetEntryDescriptor(pCurEntry);
ScriptDocument aDocument( aDesc.GetDocument() ); ScriptDocument aDocument( aDesc.GetDocument() );
::rtl::OUString aLibName( aDesc.GetLibName() ); OUString aLibName( aDesc.GetLibName() );
::rtl::OUString aLibSubName( aDesc.GetLibSubName() ); OUString aLibSubName( aDesc.GetLibSubName() );
bool bVBAEnabled = aDocument.isInVBAMode(); bool bVBAEnabled = aDocument.isInVBAMode();
sal_uInt16 nMode = aBasicBox.GetMode(); sal_uInt16 nMode = aBasicBox.GetMode();
@@ -686,7 +686,7 @@ IMPL_LINK( ObjectPage, ButtonHdl, Button *, pButton )
EntryDescriptor aDesc = aBasicBox.GetEntryDescriptor(pCurEntry); EntryDescriptor aDesc = aBasicBox.GetEntryDescriptor(pCurEntry);
if ( pDispatcher ) if ( pDispatcher )
{ {
::rtl::OUString aModName( aDesc.GetName() ); OUString aModName( aDesc.GetName() );
// extract the module name from the string like "Sheet1 (Example1)" // extract the module name from the string like "Sheet1 (Example1)"
if( aDesc.GetLibSubName() == IDE_RESSTR(RID_STR_DOCUMENT_OBJECTS) ) if( aDesc.GetLibSubName() == IDE_RESSTR(RID_STR_DOCUMENT_OBJECTS) )
{ {
@@ -710,7 +710,7 @@ IMPL_LINK( ObjectPage, ButtonHdl, Button *, pButton )
aDocument = pDocumentEntry->GetDocument(); aDocument = pDocumentEntry->GetDocument();
} }
SfxUsrAnyItem aDocItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, makeAny( aDocument.getDocumentOrNull() ) ); SfxUsrAnyItem aDocItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, makeAny( aDocument.getDocumentOrNull() ) );
::rtl::OUString aLibName( aBasicBox.GetEntryText( pCurEntry ) ); OUString aLibName( aBasicBox.GetEntryText( pCurEntry ) );
SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName ); SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
if ( pDispatcher ) if ( pDispatcher )
{ {
@@ -731,7 +731,7 @@ IMPL_LINK( ObjectPage, ButtonHdl, Button *, pButton )
return 0; return 0;
} }
bool ObjectPage::GetSelection( ScriptDocument& rDocument, ::rtl::OUString& rLibName ) bool ObjectPage::GetSelection( ScriptDocument& rDocument, OUString& rLibName )
{ {
bool bRet = false; bool bRet = false;
@@ -740,7 +740,7 @@ bool ObjectPage::GetSelection( ScriptDocument& rDocument, ::rtl::OUString& rLibN
rDocument = aDesc.GetDocument(); rDocument = aDesc.GetDocument();
rLibName = aDesc.GetLibName(); rLibName = aDesc.GetLibName();
if ( rLibName.isEmpty() ) if ( rLibName.isEmpty() )
rLibName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Standard")); rLibName = "Standard" ;
DBG_ASSERT( rDocument.isAlive(), "ObjectPage::GetSelection: no or dead ScriptDocument in the selection!" ); DBG_ASSERT( rDocument.isAlive(), "ObjectPage::GetSelection: no or dead ScriptDocument in the selection!" );
if ( !rDocument.isAlive() ) if ( !rDocument.isAlive() )
@@ -748,7 +748,7 @@ bool ObjectPage::GetSelection( ScriptDocument& rDocument, ::rtl::OUString& rLibN
// check if the module library is loaded // check if the module library is loaded
bool bOK = true; bool bOK = true;
::rtl::OUString aLibName( rLibName ); OUString aLibName( rLibName );
Reference< script::XLibraryContainer > xModLibContainer( rDocument.getLibraryContainer( E_SCRIPTS ) ); Reference< script::XLibraryContainer > xModLibContainer( rDocument.getLibraryContainer( E_SCRIPTS ) );
if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && !xModLibContainer->isLibraryLoaded( aLibName ) ) if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && !xModLibContainer->isLibraryLoaded( aLibName ) )
{ {
@@ -756,7 +756,7 @@ bool ObjectPage::GetSelection( ScriptDocument& rDocument, ::rtl::OUString& rLibN
Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY ); Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) && !xPasswd->isLibraryPasswordVerified( aLibName ) ) if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) && !xPasswd->isLibraryPasswordVerified( aLibName ) )
{ {
::rtl::OUString aPassword; OUString aPassword;
bOK = QueryPassword( xModLibContainer, rLibName, aPassword ); bOK = QueryPassword( xModLibContainer, rLibName, aPassword );
} }
@@ -783,11 +783,11 @@ bool ObjectPage::GetSelection( ScriptDocument& rDocument, ::rtl::OUString& rLibN
void ObjectPage::NewModule() void ObjectPage::NewModule()
{ {
ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() ); ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() );
::rtl::OUString aLibName; OUString aLibName;
if ( GetSelection( aDocument, aLibName ) ) if ( GetSelection( aDocument, aLibName ) )
{ {
::rtl::OUString aModName; OUString aModName;
createModImpl( static_cast<Window*>( this ), aDocument, createModImpl( static_cast<Window*>( this ), aDocument,
aBasicBox, aLibName, aModName, true ); aBasicBox, aLibName, aModName, true );
} }
@@ -796,7 +796,7 @@ void ObjectPage::NewModule()
void ObjectPage::NewDialog() void ObjectPage::NewDialog()
{ {
ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() ); ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() );
::rtl::OUString aLibName; OUString aLibName;
if ( GetSelection( aDocument, aLibName ) ) if ( GetSelection( aDocument, aLibName ) )
{ {
@@ -807,7 +807,7 @@ void ObjectPage::NewDialog()
if (aNewDlg.Execute() != 0) if (aNewDlg.Execute() != 0)
{ {
rtl::OUString aDlgName = aNewDlg.GetObjectName(); OUString aDlgName = aNewDlg.GetObjectName();
if (aDlgName.isEmpty()) if (aDlgName.isEmpty())
aDlgName = aDocument.createObjectName( E_DIALOGS, aLibName); aDlgName = aDocument.createObjectName( E_DIALOGS, aLibName);
@@ -869,8 +869,8 @@ void ObjectPage::DeleteCurrent()
DBG_ASSERT( aDocument.isAlive(), "ObjectPage::DeleteCurrent: no document!" ); DBG_ASSERT( aDocument.isAlive(), "ObjectPage::DeleteCurrent: no document!" );
if ( !aDocument.isAlive() ) if ( !aDocument.isAlive() )
return; return;
::rtl::OUString aLibName( aDesc.GetLibName() ); OUString aLibName( aDesc.GetLibName() );
::rtl::OUString aName( aDesc.GetName() ); OUString aName( aDesc.GetName() );
EntryType eType = aDesc.GetType(); EntryType eType = aDesc.GetType();
if ( ( eType == OBJ_TYPE_MODULE && QueryDelModule( aName, this ) ) || if ( ( eType == OBJ_TYPE_MODULE && QueryDelModule( aName, this ) ) ||
@@ -933,16 +933,16 @@ LibDialog::~LibDialog()
{ {
} }
void LibDialog::SetStorageName( const ::rtl::OUString& rName ) void LibDialog::SetStorageName( const OUString& rName )
{ {
::rtl::OUString aName( IDE_RESSTR(RID_STR_FILENAME) ); OUString aName( IDE_RESSTR(RID_STR_FILENAME) );
aName += rName; aName += rName;
aStorageName.SetText( aName ); aStorageName.SetText( aName );
} }
// Helper function // Helper function
SbModule* createModImpl( Window* pWin, const ScriptDocument& rDocument, SbModule* createModImpl( Window* pWin, const ScriptDocument& rDocument,
TreeListBox& rBasicBox, const ::rtl::OUString& rLibName, ::rtl::OUString aModName, bool bMain ) TreeListBox& rBasicBox, const OUString& rLibName, OUString aModName, bool bMain )
{ {
OSL_ENSURE( rDocument.isAlive(), "createModImpl: invalid document!" ); OSL_ENSURE( rDocument.isAlive(), "createModImpl: invalid document!" );
if ( !rDocument.isAlive() ) if ( !rDocument.isAlive() )
@@ -950,9 +950,9 @@ SbModule* createModImpl( Window* pWin, const ScriptDocument& rDocument,
SbModule* pModule = NULL; SbModule* pModule = NULL;
::rtl::OUString aLibName( rLibName ); OUString aLibName( rLibName );
if ( aLibName.isEmpty() ) if ( aLibName.isEmpty() )
aLibName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Standard")); aLibName = "Standard" ;
rDocument.getOrCreateLibrary( E_SCRIPTS, aLibName ); rDocument.getOrCreateLibrary( E_SCRIPTS, aLibName );
if ( aModName.isEmpty() ) if ( aModName.isEmpty() )
aModName = rDocument.createObjectName( E_SCRIPTS, aLibName ); aModName = rDocument.createObjectName( E_SCRIPTS, aLibName );
@@ -967,7 +967,7 @@ SbModule* createModImpl( Window* pWin, const ScriptDocument& rDocument,
try try
{ {
::rtl::OUString sModuleCode; OUString sModuleCode;
// the module has existed // the module has existed
if( rDocument.hasModule( aLibName, aModName ) ) if( rDocument.hasModule( aLibName, aModName ) )
return NULL; return NULL;

View File

@@ -29,7 +29,6 @@
namespace basctl namespace basctl
{ {
using ::rtl::OUString;
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang; using namespace ::com::sun::star::lang;

View File

@@ -25,8 +25,8 @@ namespace basctl
SbxItem::SbxItem ( SbxItem::SbxItem (
sal_uInt16 nWhichItem, sal_uInt16 nWhichItem,
ScriptDocument const& rDocument, ScriptDocument const& rDocument,
rtl::OUString const& aLibName, OUString const& aLibName,
rtl::OUString const& aName, OUString const& aName,
ItemType eType ItemType eType
) : ) :
SfxPoolItem(nWhichItem), SfxPoolItem(nWhichItem),
@@ -39,9 +39,9 @@ SbxItem::SbxItem (
SbxItem::SbxItem ( SbxItem::SbxItem (
sal_uInt16 nWhichItem, sal_uInt16 nWhichItem,
ScriptDocument const& rDocument, ScriptDocument const& rDocument,
rtl::OUString const& aLibName, OUString const& aLibName,
rtl::OUString const& aName, OUString const& aName,
rtl::OUString const& aMethodName, OUString const& aMethodName,
ItemType eType ItemType eType
) : ) :
SfxPoolItem(nWhichItem), SfxPoolItem(nWhichItem),