[Libreoffice-commits] core.git: sc/qa sc/source
Justin Luth
justin_luth at sil.org
Fri Nov 17 18:52:06 UTC 2017
sc/qa/extras/testdocuments/vba_findFunction.xls |binary
sc/source/ui/vba/vbarange.cxx | 17 +++++++----------
2 files changed, 7 insertions(+), 10 deletions(-)
New commits:
commit ac116d190da9e59b6a8cc541bba652183fccc5b3
Author: Justin Luth <justin_luth at sil.org>
Date: Sat Nov 11 07:54:01 2017 +0300
ScVbaRange::Find - allow empty string as What to search for
Excel's find macro is able to search for an empty string
and find an empty cell, without giving a script error.
LibreOffice was raising a "missing params" error if it was passed
an empty string to search for, causing execution failure,
a misleading error code, and failing to find an empty cell.
Also fixed the other copy/paste error codes to indicate
that this is the find function, not the replace function.
Also added a sanity control line to the VBA test. First select
cell A1 - instead of assuming that no one has touched the
file.
Change-Id: Iabbac7333c37886a667ab5670af819b1cd53c086
Reviewed-on: https://gerrit.libreoffice.org/44618
Reviewed-by: Justin Luth <justin_luth at sil.org>
Tested-by: Justin Luth <justin_luth at sil.org>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/sc/qa/extras/testdocuments/vba_findFunction.xls b/sc/qa/extras/testdocuments/vba_findFunction.xls
index 2ea964ee290f..bb0f450b1ac8 100644
Binary files a/sc/qa/extras/testdocuments/vba_findFunction.xls and b/sc/qa/extras/testdocuments/vba_findFunction.xls differ
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 1f078b5408af..c8bc5ac351a8 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -3127,10 +3127,7 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L
// string.
if( What >>= sWhat )
- {
- if( sWhat.isEmpty() )
- throw uno::RuntimeException("Range::Find, missing params" );
- }
+ {}
else if( What >>= nWhat )
{
sWhat = OUString::number( nWhat );
@@ -3140,7 +3137,7 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L
sWhat = OUString::number( fWhat );
}
else
- throw uno::RuntimeException("Range::Find, missing params" );
+ throw uno::RuntimeException("Range::Find, missing search-for-what param" );
OUString sSearch = VBAToRegexp( sWhat );
@@ -3184,7 +3181,7 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L
nSearchType = SvxSearchCellType::VALUE;
break;
default:
- throw uno::RuntimeException("Range::Replace, illegal value for LookIn." );
+ throw uno::RuntimeException("Range::Find, illegal value for LookIn." );
}
newOptions.SetCellType( nSearchType );
xDescriptor->setPropertyValue( "SearchType", uno::makeAny( static_cast<sal_uInt16>(nSearchType) ) );
@@ -3201,7 +3198,7 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L
else if ( nLookAt == excel::XlLookAt::xlWhole )
bSearchWords = true;
else
- throw uno::RuntimeException("Range::Replace, illegal value for LookAt" );
+ throw uno::RuntimeException("Range::Find, illegal value for LookAt" );
newOptions.SetWordOnly( bSearchWords );
xDescriptor->setPropertyValue( SC_UNO_SRCHWORDS, uno::makeAny( bSearchWords ) );
}
@@ -3216,7 +3213,7 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L
else if ( nSearchOrder == excel::XlSearchOrder::xlByRows )
bSearchByRow = true;
else
- throw uno::RuntimeException("Range::Replace, illegal value for SearchOrder" );
+ throw uno::RuntimeException("Range::Find, illegal value for SearchOrder" );
newOptions.SetRowDirection( bSearchByRow );
xDescriptor->setPropertyValue( SC_UNO_SRCHBYROW, uno::makeAny( bSearchByRow ) );
@@ -3234,7 +3231,7 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L
else if( nSearchDirection == excel::XlSearchDirection::xlPrevious )
bSearchBackwards = true;
else
- throw uno::RuntimeException("Range::Replace, illegal value for SearchDirection" );
+ throw uno::RuntimeException("Range::Find, illegal value for SearchDirection" );
newOptions.SetBackward( bSearchBackwards );
xDescriptor->setPropertyValue( "SearchBackwards", uno::makeAny( bSearchBackwards ) );
}
@@ -3246,7 +3243,7 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L
{
// SearchCaseSensitive
if( !( MatchCase >>= bMatchCase ) )
- throw uno::RuntimeException("Range::Replace, illegal value for MatchCase" );
+ throw uno::RuntimeException("Range::Find illegal value for MatchCase" );
}
xDescriptor->setPropertyValue( SC_UNO_SRCHCASE, uno::makeAny( bMatchCase ) );
More information about the Libreoffice-commits
mailing list