[Libreoffice-commits] core.git: basic/source include/basic sfx2/source
Noel Grandin
noel at peralex.com
Mon Apr 11 06:20:36 UTC 2016
basic/source/basmgr/basmgr.cxx | 12 +++++-------
basic/source/classes/sb.cxx | 5 ++---
include/basic/basmgr.hxx | 4 ++--
include/basic/sbstar.hxx | 2 +-
sfx2/source/doc/objxtor.cxx | 18 +++++++++---------
5 files changed, 19 insertions(+), 22 deletions(-)
New commits:
commit f3dabe7507b578484805255eae31d8a1358e605c
Author: Noel Grandin <noel at peralex.com>
Date: Fri Apr 8 15:41:15 2016 +0200
make GetGlobalUNOConstant and GetUNOConstant take an OUString
and eliminate converting backwards and forwards between
sal_Char*/OString/OUString
Change-Id: Iaf52ce93f0e732ab338f75d21b95ab4b020a4d6f
Reviewed-on: https://gerrit.libreoffice.org/23919
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx
index 533fb0c..4ac8556 100644
--- a/basic/source/basmgr/basmgr.cxx
+++ b/basic/source/basmgr/basmgr.cxx
@@ -1458,17 +1458,17 @@ bool BasicManager::IsBasicModified() const
}
-bool BasicManager::GetGlobalUNOConstant( const sal_Char* _pAsciiName, uno::Any& aOut )
+bool BasicManager::GetGlobalUNOConstant( const OUString& rName, uno::Any& aOut )
{
bool bRes = false;
StarBASIC* pStandardLib = GetStdLib();
OSL_PRECOND( pStandardLib, "BasicManager::GetGlobalUNOConstant: no lib to read from!" );
if ( pStandardLib )
- bRes = pStandardLib->GetUNOConstant( _pAsciiName, aOut );
+ bRes = pStandardLib->GetUNOConstant( rName, aOut );
return bRes;
}
-uno::Any BasicManager::SetGlobalUNOConstant( const sal_Char* _pAsciiName, const uno::Any& _rValue )
+uno::Any BasicManager::SetGlobalUNOConstant( const OUString& rName, const uno::Any& _rValue )
{
uno::Any aOldValue;
@@ -1477,14 +1477,12 @@ uno::Any BasicManager::SetGlobalUNOConstant( const sal_Char* _pAsciiName, const
if ( !pStandardLib )
return aOldValue;
- OUString sVarName( OUString::createFromAscii( _pAsciiName ) );
-
// obtain the old value
- SbxVariable* pVariable = pStandardLib->Find( sVarName, SbxCLASS_OBJECT );
+ SbxVariable* pVariable = pStandardLib->Find( rName, SbxCLASS_OBJECT );
if ( pVariable )
aOldValue = sbxToUnoValue( pVariable );
- SbxObjectRef xUnoObj = GetSbUnoObject( sVarName, _rValue );
+ SbxObjectRef xUnoObj = GetSbUnoObject( rName, _rValue );
xUnoObj->SetFlag( SbxFlagBits::DontStore );
pStandardLib->Insert( xUnoObj );
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index 7e4323a..a470547 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -1921,11 +1921,10 @@ bool StarBASIC::StoreData( SvStream& r ) const
return true;
}
-bool StarBASIC::GetUNOConstant( const sal_Char* _pAsciiName, css::uno::Any& aOut )
+bool StarBASIC::GetUNOConstant( const OUString& rName, css::uno::Any& aOut )
{
bool bRes = false;
- OUString sVarName( OUString::createFromAscii( _pAsciiName ) );
- SbUnoObject* pGlobs = dynamic_cast<SbUnoObject*>( Find( sVarName, SbxCLASS_DONTCARE ) );
+ SbUnoObject* pGlobs = dynamic_cast<SbUnoObject*>( Find( rName, SbxCLASS_DONTCARE ) );
if ( pGlobs )
{
aOut = pGlobs->getUnoAny();
diff --git a/include/basic/basmgr.hxx b/include/basic/basmgr.hxx
index 7277585..8b65bef 100644
--- a/include/basic/basmgr.hxx
+++ b/include/basic/basmgr.hxx
@@ -185,10 +185,10 @@ public:
returned. If it does not yet exist, it is newly created, and inserted into the basic library.
*/
css::uno::Any
- SetGlobalUNOConstant( const sal_Char* _pAsciiName, const css::uno::Any& _rValue );
+ SetGlobalUNOConstant( const OUString& rName, const css::uno::Any& _rValue );
/** retrieves a global constant in the basic library, referring to some UNO object, returns true if a value is found ( value is in aOut ) false otherwise. */
- bool GetGlobalUNOConstant( const sal_Char* _pAsciiName, css::uno::Any& aOut );
+ bool GetGlobalUNOConstant( const OUString& rName, css::uno::Any& aOut );
/** determines whether there are password-protected modules whose size exceedes the
legacy module size
@param _out_rModuleNames
diff --git a/include/basic/sbstar.hxx b/include/basic/sbstar.hxx
index 670e597..a0e2345 100644
--- a/include/basic/sbstar.hxx
+++ b/include/basic/sbstar.hxx
@@ -155,7 +155,7 @@ public:
SbxObjectRef getRTL() { return pRtl; }
bool IsDocBasic() { return bDocBasic; }
SbxVariable* VBAFind( const OUString& rName, SbxClassType t );
- bool GetUNOConstant( const sal_Char* _pAsciiName, css::uno::Any& aOut );
+ bool GetUNOConstant( const OUString& rName, css::uno::Any& aOut );
void QuitAndExitApplication();
bool IsQuitApplication() { return bQuit; };
diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx
index 6f69630..5f2ff89 100644
--- a/sfx2/source/doc/objxtor.cxx
+++ b/sfx2/source/doc/objxtor.cxx
@@ -118,10 +118,10 @@ class theCurrentComponent : public rtl::Static< WeakReference< XInterface >, the
#if HAVE_FEATURE_SCRIPTING
// remember all registered components for VBA compatibility, to be able to remove them on disposing the model
-typedef ::std::map< XInterface*, OString > VBAConstantNameMap;
+typedef ::std::map< XInterface*, OUString > VBAConstantNameMap;
static VBAConstantNameMap s_aRegisteredVBAConstants;
-OString lclGetVBAGlobalConstName( const Reference< XInterface >& rxComponent )
+OUString lclGetVBAGlobalConstName( const Reference< XInterface >& rxComponent )
{
OSL_ENSURE( rxComponent.is(), "lclGetVBAGlobalConstName - missing component" );
@@ -134,12 +134,12 @@ OString lclGetVBAGlobalConstName( const Reference< XInterface >& rxComponent )
{
OUString aConstName;
xProps->getPropertyValue("VBAGlobalConstantName") >>= aConstName;
- return OUStringToOString( aConstName, RTL_TEXTENCODING_ASCII_US );
+ return aConstName;
}
catch (const uno::Exception&) // not supported
{
}
- return OString();
+ return OUString();
}
#endif
@@ -190,7 +190,7 @@ void SAL_CALL SfxModelListener_Impl::disposing( const css::lang::EventObject& _r
if ( aIt != s_aRegisteredVBAConstants.end() )
{
if ( BasicManager* pAppMgr = SfxApplication::GetBasicManager() )
- pAppMgr->SetGlobalUNOConstant( aIt->second.getStr(), Any( Reference< XInterface >() ) );
+ pAppMgr->SetGlobalUNOConstant( aIt->second, Any( Reference< XInterface >() ) );
s_aRegisteredVBAConstants.erase( aIt );
}
}
@@ -933,20 +933,20 @@ void SfxObjectShell::SetCurrentComponent( const Reference< XInterface >& _rxComp
// set new current component for VBA compatibility
if ( _rxComponent.is() )
{
- OString aVBAConstName = lclGetVBAGlobalConstName( _rxComponent );
+ OUString aVBAConstName = lclGetVBAGlobalConstName( _rxComponent );
if ( !aVBAConstName.isEmpty() )
{
- pAppMgr->SetGlobalUNOConstant( aVBAConstName.getStr(), Any( _rxComponent ) );
+ pAppMgr->SetGlobalUNOConstant( aVBAConstName, Any( _rxComponent ) );
s_aRegisteredVBAConstants[ _rxComponent.get() ] = aVBAConstName;
}
}
// no new component passed -> remove last registered VBA component
else if ( xOldCurrentComp.is() )
{
- OString aVBAConstName = lclGetVBAGlobalConstName( xOldCurrentComp );
+ OUString aVBAConstName = lclGetVBAGlobalConstName( xOldCurrentComp );
if ( !aVBAConstName.isEmpty() )
{
- pAppMgr->SetGlobalUNOConstant( aVBAConstName.getStr(), Any( Reference< XInterface >() ) );
+ pAppMgr->SetGlobalUNOConstant( aVBAConstName, Any( Reference< XInterface >() ) );
s_aRegisteredVBAConstants.erase( xOldCurrentComp.get() );
}
}
More information about the Libreoffice-commits
mailing list