Kaydet (Commit) 7f585002 authored tarafından Olivier Hallot's avatar Olivier Hallot

Fix for fdo43460 Part LVI getLength() to isEmpty()

Part LVI
Modules
vbahelper
üst 7c4807bf
...@@ -62,7 +62,7 @@ ScVbaComboBox::ScVbaComboBox( const uno::Reference< XHelperInterface >& xParent, ...@@ -62,7 +62,7 @@ ScVbaComboBox::ScVbaComboBox( const uno::Reference< XHelperInterface >& xParent,
catch( uno::Exception& ) catch( uno::Exception& )
{ {
} }
if( sSourceName.getLength() == 0 ) if( sSourceName.isEmpty() )
sSourceName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) ); sSourceName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) );
} }
...@@ -110,7 +110,7 @@ ScVbaComboBox::getListIndex() throw (uno::RuntimeException) ...@@ -110,7 +110,7 @@ ScVbaComboBox::getListIndex() throw (uno::RuntimeException)
{ {
rtl::OUString sText = getText(); rtl::OUString sText = getText();
sal_Int32 nLen = sItems.getLength(); sal_Int32 nLen = sItems.getLength();
for ( sal_Int32 index = 0; sText.getLength() && index < nLen; ++index ) for ( sal_Int32 index = 0; !sText.isEmpty() && index < nLen; ++index )
{ {
if ( sItems[ index ].equals( sText ) ) if ( sItems[ index ].equals( sText ) )
{ {
......
...@@ -288,10 +288,10 @@ uno::Any SAL_CALL ScVbaControls::Add( const uno::Any& Object, const uno::Any& St ...@@ -288,10 +288,10 @@ uno::Any SAL_CALL ScVbaControls::Add( const uno::Any& Object, const uno::Any& St
// TODO: Support Before and After? // TODO: Support Before and After?
::rtl::OUString aNewName; ::rtl::OUString aNewName;
StringKey >>= aNewName; StringKey >>= aNewName;
if ( !aNewName.getLength() ) if ( aNewName.isEmpty() )
{ {
aNewName = aComServiceName; aNewName = aComServiceName;
if ( !aNewName.getLength() ) if ( aNewName.isEmpty() )
aNewName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Control" ) ); aNewName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Control" ) );
sal_Int32 nInd = 0; sal_Int32 nInd = 0;
...@@ -303,7 +303,7 @@ uno::Any SAL_CALL ScVbaControls::Add( const uno::Any& Object, const uno::Any& St ...@@ -303,7 +303,7 @@ uno::Any SAL_CALL ScVbaControls::Add( const uno::Any& Object, const uno::Any& St
} }
double fDefWidth = 72.0, fDefHeight = 18.0; double fDefWidth = 72.0, fDefHeight = 18.0;
if ( aComServiceName.getLength() ) if ( !aComServiceName.isEmpty() )
{ {
// create a UNO control model based on the passed control type // create a UNO control model based on the passed control type
uno::Reference< awt::XControlModel > xNewModel; uno::Reference< awt::XControlModel > xNewModel;
...@@ -464,12 +464,12 @@ void SAL_CALL ScVbaControls::Remove( const uno::Any& StringKeyOrIndex ) ...@@ -464,12 +464,12 @@ void SAL_CALL ScVbaControls::Remove( const uno::Any& StringKeyOrIndex )
uno::Reference< lang::XMultiServiceFactory > xModelFactory( mxDialog->getModel(), uno::UNO_QUERY_THROW ); uno::Reference< lang::XMultiServiceFactory > xModelFactory( mxDialog->getModel(), uno::UNO_QUERY_THROW );
uno::Reference< container::XNameContainer > xDialogContainer( xModelFactory, uno::UNO_QUERY_THROW ); uno::Reference< container::XNameContainer > xDialogContainer( xModelFactory, uno::UNO_QUERY_THROW );
if ( !( ( StringKeyOrIndex >>= aControlName ) && aControlName.getLength() ) if ( !( ( StringKeyOrIndex >>= aControlName ) && !aControlName.isEmpty() )
&& !( ( StringKeyOrIndex >>= nIndex ) && nIndex >= 0 && nIndex < m_xIndexAccess->getCount() ) ) && !( ( StringKeyOrIndex >>= nIndex ) && nIndex >= 0 && nIndex < m_xIndexAccess->getCount() ) )
throw uno::RuntimeException(); throw uno::RuntimeException();
uno::Reference< awt::XControl > xControl; uno::Reference< awt::XControl > xControl;
if ( aControlName.getLength() ) if ( !aControlName.isEmpty() )
{ {
uno::Reference< awt::XControlContainer > xControlContainer( mxDialog, uno::UNO_QUERY_THROW ); uno::Reference< awt::XControlContainer > xControlContainer( mxDialog, uno::UNO_QUERY_THROW );
xControl = xControlContainer->getControl( aControlName ); xControl = xControlContainer->getControl( aControlName );
...@@ -482,7 +482,7 @@ void SAL_CALL ScVbaControls::Remove( const uno::Any& StringKeyOrIndex ) ...@@ -482,7 +482,7 @@ void SAL_CALL ScVbaControls::Remove( const uno::Any& StringKeyOrIndex )
if ( !xControl.is() ) if ( !xControl.is() )
throw uno::RuntimeException(); throw uno::RuntimeException();
if ( !aControlName.getLength() ) if ( aControlName.isEmpty() )
aControlName = ControlArrayWrapper::getControlName( xControl ); aControlName = ControlArrayWrapper::getControlName( xControl );
xDialogContainer->removeByName( aControlName ); xDialogContainer->removeByName( aControlName );
......
...@@ -161,7 +161,7 @@ ListControlHelper::Clear( ) throw (uno::RuntimeException) ...@@ -161,7 +161,7 @@ ListControlHelper::Clear( ) throw (uno::RuntimeException)
void SAL_CALL void SAL_CALL
ListControlHelper::setRowSource( const rtl::OUString& _rowsource ) throw (uno::RuntimeException) ListControlHelper::setRowSource( const rtl::OUString& _rowsource ) throw (uno::RuntimeException)
{ {
if ( _rowsource.getLength() == 0 ) if ( _rowsource.isEmpty() )
Clear(); Clear();
} }
......
...@@ -273,7 +273,7 @@ ScVbaUserForm::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::Un ...@@ -273,7 +273,7 @@ ScVbaUserForm::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::Un
{ {
uno::Reference< msforms::XControl > xVBAControl = ScVbaControlFactory::createUserformControl( mxContext, xControl, xDialogControl, m_xModel, mpGeometryHelper->getOffsetX(), mpGeometryHelper->getOffsetY() ); uno::Reference< msforms::XControl > xVBAControl = ScVbaControlFactory::createUserformControl( mxContext, xControl, xDialogControl, m_xModel, mpGeometryHelper->getOffsetX(), mpGeometryHelper->getOffsetY() );
ScVbaControl* pControl = dynamic_cast< ScVbaControl* >( xVBAControl.get() ); ScVbaControl* pControl = dynamic_cast< ScVbaControl* >( xVBAControl.get() );
if ( m_sLibName.getLength() ) if ( !m_sLibName.isEmpty() )
pControl->setLibraryAndCodeName( m_sLibName.concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "." ) ) ).concat( getName() ) ); pControl->setLibraryAndCodeName( m_sLibName.concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "." ) ) ).concat( getName() ) );
aResult = uno::makeAny( xVBAControl ); aResult = uno::makeAny( xVBAControl );
} }
......
...@@ -109,7 +109,7 @@ public: ...@@ -109,7 +109,7 @@ public:
void Start( const ::rtl::Reference< VbaApplicationBase > xBase, const ::rtl::OUString& aFunction, double nFrom, double nTo ) void Start( const ::rtl::Reference< VbaApplicationBase > xBase, const ::rtl::OUString& aFunction, double nFrom, double nTo )
{ {
if ( !xBase.is() || !aFunction.getLength() ) if ( !xBase.is() || aFunction.isEmpty() )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unexpected arguments!" ) ), uno::Reference< uno::XInterface >() ); throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unexpected arguments!" ) ), uno::Reference< uno::XInterface >() );
m_xBase = xBase; m_xBase = xBase;
...@@ -347,7 +347,7 @@ uno::Any SAL_CALL VbaApplicationBase::Run( const ::rtl::OUString& MacroName, con ...@@ -347,7 +347,7 @@ uno::Any SAL_CALL VbaApplicationBase::Run( const ::rtl::OUString& MacroName, con
void SAL_CALL VbaApplicationBase::OnTime( const uno::Any& aEarliestTime, const ::rtl::OUString& aFunction, const uno::Any& aLatestTime, const uno::Any& aSchedule ) void SAL_CALL VbaApplicationBase::OnTime( const uno::Any& aEarliestTime, const ::rtl::OUString& aFunction, const uno::Any& aLatestTime, const uno::Any& aSchedule )
throw ( uno::RuntimeException ) throw ( uno::RuntimeException )
{ {
if ( !aFunction.getLength() ) if ( aFunction.isEmpty() )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unexpected function name!" ) ), uno::Reference< uno::XInterface >() ); throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unexpected function name!" ) ), uno::Reference< uno::XInterface >() );
double nEarliestTime = 0; double nEarliestTime = 0;
......
...@@ -50,7 +50,7 @@ ScVbaCommandBar::getName() throw ( uno::RuntimeException ) ...@@ -50,7 +50,7 @@ ScVbaCommandBar::getName() throw ( uno::RuntimeException )
uno::Any aName = xPropertySet->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UIName")) ); uno::Any aName = xPropertySet->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UIName")) );
rtl::OUString sName; rtl::OUString sName;
aName >>= sName; aName >>= sName;
if( sName.getLength() < 1 ) if( sName.isEmpty() )
{ {
if( m_bIsMenu ) if( m_bIsMenu )
{ {
......
...@@ -114,7 +114,7 @@ void VbaCommandBarHelper::Init( ) throw (css::uno::RuntimeException) ...@@ -114,7 +114,7 @@ void VbaCommandBarHelper::Init( ) throw (css::uno::RuntimeException)
maModuleId = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument") ); maModuleId = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument") );
} }
if( maModuleId.getLength() == 0 ) if( maModuleId.isEmpty() )
{ {
throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
} }
...@@ -209,7 +209,7 @@ rtl::OUString VbaCommandBarHelper::findToolbarByName( const css::uno::Reference< ...@@ -209,7 +209,7 @@ rtl::OUString VbaCommandBarHelper::findToolbarByName( const css::uno::Reference<
// check if it is an buildin toolbar // check if it is an buildin toolbar
sResourceUrl = MSO2OOCommandbarHelper::getMSO2OOCommandbarHelper()->findBuildinToolbar( sName ); sResourceUrl = MSO2OOCommandbarHelper::getMSO2OOCommandbarHelper()->findBuildinToolbar( sName );
if( sResourceUrl.getLength() > 0 ) if( !sResourceUrl.isEmpty() )
return sResourceUrl; return sResourceUrl;
uno::Sequence< ::rtl::OUString > allNames = xNameAccess->getElementNames(); uno::Sequence< ::rtl::OUString > allNames = xNameAccess->getElementNames();
......
...@@ -143,14 +143,14 @@ ScVbaCommandBars::createCollectionObject( const uno::Any& aSource ) ...@@ -143,14 +143,14 @@ ScVbaCommandBars::createCollectionObject( const uno::Any& aSource )
} }
// nothing found - try to resolve from name // nothing found - try to resolve from name
if( !aRet.hasValue() && (sResourceUrl.getLength() == 0) ) if( !aRet.hasValue() && sResourceUrl.isEmpty() )
{ {
sResourceUrl = m_pCBarHelper->findToolbarByName( m_xNameAccess, sBarName ); sResourceUrl = m_pCBarHelper->findToolbarByName( m_xNameAccess, sBarName );
bMenu = sal_False; bMenu = sal_False;
} }
} }
if( sResourceUrl.getLength() ) if( !sResourceUrl.isEmpty() )
{ {
xBarSettings = m_pCBarHelper->getSettings( sResourceUrl ); xBarSettings = m_pCBarHelper->getSettings( sResourceUrl );
aRet <<= uno::Reference< XCommandBar >( new ScVbaCommandBar( this, mxContext, m_pCBarHelper, xBarSettings, sResourceUrl, bMenu, sal_False ) ); aRet <<= uno::Reference< XCommandBar >( new ScVbaCommandBar( this, mxContext, m_pCBarHelper, xBarSettings, sResourceUrl, bMenu, sal_False ) );
...@@ -174,10 +174,10 @@ ScVbaCommandBars::Add( const css::uno::Any& Name, const css::uno::Any& /*Positio ...@@ -174,10 +174,10 @@ ScVbaCommandBars::Add( const css::uno::Any& Name, const css::uno::Any& /*Positio
Name >>= sName; Name >>= sName;
rtl::OUString sResourceUrl; rtl::OUString sResourceUrl;
if( sName.getLength() ) if( !sName.isEmpty() )
{ {
sResourceUrl = m_pCBarHelper->findToolbarByName( m_xNameAccess, sName ); sResourceUrl = m_pCBarHelper->findToolbarByName( m_xNameAccess, sName );
if( sResourceUrl.getLength() ) if( !sResourceUrl.isEmpty() )
throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Toolbar exists") ), uno::Reference< uno::XInterface >() ); throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Toolbar exists") ), uno::Reference< uno::XInterface >() );
} }
else else
......
...@@ -38,7 +38,7 @@ sal_Bool SAL_CALL VbaDialogBase::Show() throw ( uno::RuntimeException ) ...@@ -38,7 +38,7 @@ sal_Bool SAL_CALL VbaDialogBase::Show() throw ( uno::RuntimeException )
if ( m_xModel.is() ) if ( m_xModel.is() )
{ {
aURL = mapIndexToName( mnIndex ); aURL = mapIndexToName( mnIndex );
if( aURL.getLength() == 0 ) if( aURL.isEmpty() )
throw uno::RuntimeException( throw uno::RuntimeException(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " Unable to open the specified dialog " ) ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " Unable to open the specified dialog " ) ),
uno::Reference< XInterface > () ); uno::Reference< XInterface > () );
......
...@@ -67,7 +67,7 @@ VbaDocumentBase::VbaDocumentBase( uno::Sequence< uno::Any> const & args, ...@@ -67,7 +67,7 @@ VbaDocumentBase::VbaDocumentBase( uno::Sequence< uno::Any> const & args,
VbaDocumentBase::getName() throw (uno::RuntimeException) VbaDocumentBase::getName() throw (uno::RuntimeException)
{ {
rtl::OUString sName = getModel()->getURL(); rtl::OUString sName = getModel()->getURL();
if ( sName.getLength() ) if ( !sName.isEmpty() )
{ {
INetURLObject aURL( getModel()->getURL() ); INetURLObject aURL( getModel()->getURL() );
...@@ -87,7 +87,7 @@ VbaDocumentBase::getPath() throw (uno::RuntimeException) ...@@ -87,7 +87,7 @@ VbaDocumentBase::getPath() throw (uno::RuntimeException)
INetURLObject aURL( getModel()->getURL() ); INetURLObject aURL( getModel()->getURL() );
rtl::OUString sURL = aURL.GetMainURL( INetURLObject::DECODE_TO_IURI ); rtl::OUString sURL = aURL.GetMainURL( INetURLObject::DECODE_TO_IURI );
rtl::OUString sPath; rtl::OUString sPath;
if( sURL.getLength() > 0 ) if( !sURL.isEmpty() )
{ {
sURL = sURL.copy( 0, sURL.getLength() - aURL.GetLastName().getLength() - 1 ); sURL = sURL.copy( 0, sURL.getLength() - aURL.GetLastName().getLength() - 1 );
::osl::File::getSystemPathFromFileURL( sURL, sPath ); ::osl::File::getSystemPathFromFileURL( sURL, sPath );
......
...@@ -69,7 +69,7 @@ sal_Bool SAL_CALL VbaEventsHelperBase::hasVbaEventHandler( sal_Int32 nEventId, c ...@@ -69,7 +69,7 @@ sal_Bool SAL_CALL VbaEventsHelperBase::hasVbaEventHandler( sal_Int32 nEventId, c
// getEventHandlerInfo() throws, if unknown event dentifier has been passed // getEventHandlerInfo() throws, if unknown event dentifier has been passed
const EventHandlerInfo& rInfo = getEventHandlerInfo( nEventId ); const EventHandlerInfo& rInfo = getEventHandlerInfo( nEventId );
// getEventHandlerPath() searches for the macro in the document // getEventHandlerPath() searches for the macro in the document
return getEventHandlerPath( rInfo, rArgs ).getLength() > 0; return !getEventHandlerPath( rInfo, rArgs ).isEmpty();
} }
sal_Bool SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs ) sal_Bool SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs )
...@@ -114,7 +114,7 @@ sal_Bool SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, cons ...@@ -114,7 +114,7 @@ sal_Bool SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, cons
{ {
// search the event handler macro in the document // search the event handler macro in the document
OUString aMacroPath = getEventHandlerPath( rInfo, aEventArgs ); OUString aMacroPath = getEventHandlerPath( rInfo, aEventArgs );
if( aMacroPath.getLength() > 0 ) if( !aMacroPath.isEmpty() )
{ {
// build the argument list // build the argument list
uno::Sequence< uno::Any > aVbaArgs = implBuildArgumentList( rInfo, aEventArgs ); uno::Sequence< uno::Any > aVbaArgs = implBuildArgumentList( rInfo, aEventArgs );
...@@ -179,7 +179,7 @@ void SAL_CALL VbaEventsHelperBase::changesOccurred( const util::ChangesEvent& rE ...@@ -179,7 +179,7 @@ void SAL_CALL VbaEventsHelperBase::changesOccurred( const util::ChangesEvent& rE
{ {
const util::ElementChange& rChange = rEvent.Changes[ nIndex ]; const util::ElementChange& rChange = rEvent.Changes[ nIndex ];
OUString aModuleName; OUString aModuleName;
if( (rChange.Accessor >>= aModuleName) && (aModuleName.getLength() > 0) ) try if( (rChange.Accessor >>= aModuleName) && !aModuleName.isEmpty() ) try
{ {
// invalidate event handler path map depending on module type // invalidate event handler path map depending on module type
if( getModuleType( aModuleName ) == script::ModuleType::NORMAL ) if( getModuleType( aModuleName ) == script::ModuleType::NORMAL )
...@@ -275,7 +275,7 @@ OUString VbaEventsHelperBase::getEventHandlerPath( const EventHandlerInfo& rInfo ...@@ -275,7 +275,7 @@ OUString VbaEventsHelperBase::getEventHandlerPath( const EventHandlerInfo& rInfo
// document event: get name of the code module associated to the event sender // document event: get name of the code module associated to the event sender
case script::ModuleType::DOCUMENT: case script::ModuleType::DOCUMENT:
aModuleName = implGetDocumentModuleName( rInfo, rArgs ); aModuleName = implGetDocumentModuleName( rInfo, rArgs );
if( aModuleName.getLength() == 0 ) if( aModuleName.isEmpty() )
throw lang::IllegalArgumentException(); throw lang::IllegalArgumentException();
break; break;
...@@ -295,7 +295,7 @@ void VbaEventsHelperBase::ensureVBALibrary() throw (uno::RuntimeException) ...@@ -295,7 +295,7 @@ void VbaEventsHelperBase::ensureVBALibrary() throw (uno::RuntimeException)
if( !mxModuleInfos.is() ) try if( !mxModuleInfos.is() ) try
{ {
maLibraryName = getDefaultProjectName( mpShell ); maLibraryName = getDefaultProjectName( mpShell );
if( maLibraryName.getLength() == 0 ) if( maLibraryName.isEmpty() )
throw uno::RuntimeException(); throw uno::RuntimeException();
uno::Reference< beans::XPropertySet > xModelProps( mxModel, uno::UNO_QUERY_THROW ); uno::Reference< beans::XPropertySet > xModelProps( mxModel, uno::UNO_QUERY_THROW );
uno::Reference< container::XNameAccess > xBasicLibs( xModelProps->getPropertyValue( uno::Reference< container::XNameAccess > xBasicLibs( xModelProps->getPropertyValue(
...@@ -319,7 +319,7 @@ sal_Int32 VbaEventsHelperBase::getModuleType( const OUString& rModuleName ) thro ...@@ -319,7 +319,7 @@ sal_Int32 VbaEventsHelperBase::getModuleType( const OUString& rModuleName ) thro
ensureVBALibrary(); ensureVBALibrary();
// no module specified: global event handler in standard code modules // no module specified: global event handler in standard code modules
if( rModuleName.getLength() == 0 ) if( rModuleName.isEmpty() )
return script::ModuleType::NORMAL; return script::ModuleType::NORMAL;
// get module type from module info // get module type from module info
......
...@@ -432,13 +432,13 @@ void PrintOutHelper( SfxViewShell* pViewShell, const uno::Any& From, const uno:: ...@@ -432,13 +432,13 @@ void PrintOutHelper( SfxViewShell* pViewShell, const uno::Any& From, const uno::
aArgs.Put( sfxCollate, sfxCollate.Which() ); aArgs.Put( sfxCollate, sfxCollate.Which() );
SfxInt16Item sfxCopies( SID_PRINT_COPIES, nCopies ); SfxInt16Item sfxCopies( SID_PRINT_COPIES, nCopies );
aArgs.Put( sfxCopies, sfxCopies.Which() ); aArgs.Put( sfxCopies, sfxCopies.Which() );
if ( sFileName.getLength() ) if ( !sFileName.isEmpty() )
{ {
SfxStringItem sfxFileName( SID_FILE_NAME, sFileName); SfxStringItem sfxFileName( SID_FILE_NAME, sFileName);
aArgs.Put( sfxFileName, sfxFileName.Which() ); aArgs.Put( sfxFileName, sfxFileName.Which() );
} }
if ( sRange.getLength() ) if ( !sRange.isEmpty() )
{ {
SfxStringItem sfxRange( SID_PRINT_PAGES, sRange ); SfxStringItem sfxRange( SID_PRINT_PAGES, sRange );
aArgs.Put( sfxRange, sfxRange.Which() ); aArgs.Put( sfxRange, sfxRange.Which() );
......
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