summaryrefslogtreecommitdiff
path: root/sc/source/ui/vba
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2016-11-01 13:18:59 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2016-11-01 12:34:51 +0000
commit39414827352e58e8be76abaa9a5a1ac9518d927f (patch)
tree7b856026bae224c678cab020ce00f97574d2bbba /sc/source/ui/vba
parentd5c4823555e6f5c4e3bd9258c819bb2a763227c4 (diff)
loplugin:oncevar in sal..scripting
Change-Id: Id9ab12f3a61eb83a2288b2fd4d99ab77f5833e1b Reviewed-on: https://gerrit.libreoffice.org/30461 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/ui/vba')
-rw-r--r--sc/source/ui/vba/vbaformatconditions.cxx16
-rw-r--r--sc/source/ui/vba/vbarange.cxx20
-rw-r--r--sc/source/ui/vba/vbawindow.cxx3
-rw-r--r--sc/source/ui/vba/vbaworkbooks.cxx3
4 files changed, 14 insertions, 28 deletions
diff --git a/sc/source/ui/vba/vbaformatconditions.cxx b/sc/source/ui/vba/vbaformatconditions.cxx
index c01b1863b426..6cfebf709b2b 100644
--- a/sc/source/ui/vba/vbaformatconditions.cxx
+++ b/sc/source/ui/vba/vbaformatconditions.cxx
@@ -34,12 +34,6 @@
using namespace ::ooo::vba;
using namespace ::com::sun::star;
-static const char OPERATOR[] = "Operator";
-static const char FORMULA1[] = "Formula1";
-static const char FORMULA2[] = "Formula2";
-static const char STYLENAME[] = "StyleName";
-static const char sStyleNamePrefix[] = "Excel_CondFormat";
-
void SAL_CALL
ScVbaFormatConditions::Delete( ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
{
@@ -176,20 +170,20 @@ ScVbaFormatConditions::Add( ::sal_Int32 _nType, const uno::Any& _aOperator, cons
else
aValue = uno::makeAny( ScVbaFormatCondition::retrieveAPIOperator(_aOperator) );
- beans::PropertyValue aProperty( OPERATOR, 0, aValue, beans::PropertyState_DIRECT_VALUE );
+ beans::PropertyValue aProperty( "Operator", 0, aValue, beans::PropertyState_DIRECT_VALUE );
aPropertyValueVector.push_back( aProperty );
if ( _aFormula1.hasValue() )
{
- beans::PropertyValue aProp( FORMULA1, 0, uno::makeAny( getA1Formula( _aFormula1 ) ), beans::PropertyState_DIRECT_VALUE );
+ beans::PropertyValue aProp( "Formula1", 0, uno::makeAny( getA1Formula( _aFormula1 ) ), beans::PropertyState_DIRECT_VALUE );
aPropertyValueVector.push_back( aProp );
}
if ( _aFormula2.hasValue() )
{
- beans::PropertyValue aProp( FORMULA2, 0, uno::makeAny( getA1Formula( _aFormula2 ) ), beans::PropertyState_DIRECT_VALUE );
+ beans::PropertyValue aProp( "Formula2", 0, uno::makeAny( getA1Formula( _aFormula2 ) ), beans::PropertyState_DIRECT_VALUE );
aPropertyValueVector.push_back( aProp );
}
- aProperty.Name = STYLENAME;
+ aProperty.Name = "StyleName";
aProperty.Value = uno::makeAny( sStyleName );
mxSheetConditionalEntries->addNew(comphelper::containerToSequence(aPropertyValueVector));
@@ -247,7 +241,7 @@ ScVbaFormatConditions::getStyleName()
if ( !pStyles )
DebugHelper::basicexception(ERRCODE_BASIC_METHOD_FAILED, OUString() );
uno::Sequence< OUString > sCellStyleNames = pStyles->getStyleNames();
- return ContainerUtilities::getUniqueName(sCellStyleNames, sStyleNamePrefix, "_");
+ return ContainerUtilities::getUniqueName(sCellStyleNames, "Excel_CondFormat", "_");
}
void
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 60f48d1d5685..f68d5495a9d8 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -686,17 +686,13 @@ public:
};
static const char ISVISIBLE[] = "IsVisible";
-static const char POSITION[] = "Position";
static const char EQUALS[] = "=";
static const char NOTEQUALS[] = "<>";
static const char GREATERTHAN[] = ">";
static const char GREATERTHANEQUALS[] = ">=";
static const char LESSTHAN[] = "<";
static const char LESSTHANEQUALS[] = "<=";
-static const char CONTS_HEADER[] = "ContainsHeader";
-static const char INSERTPAGEBREAKS[] = "InsertPageBreaks";
static const char STR_ERRORMESSAGE_APPLIESTOSINGLERANGEONLY[] = "The command you chose cannot be performed with multiple selections.\nSelect a single range and click the command again";
-static const char STR_ERRORMESSAGE_NOCELLSWEREFOUND[] = "No cells were found";
static const char CELLSTYLE[] = "CellStyle";
class CellValueSetter : public ValueSetter
@@ -3517,7 +3513,7 @@ ScVbaRange::Sort( const uno::Any& Key1, const uno::Any& Order1, const uno::Any&
sal_Int32 nIndex = findSortPropertyIndex( sortDescriptor, "IsSortColumns" );
sortDescriptor[ nIndex ].Value <<= bIsSortColumns;
- nIndex = findSortPropertyIndex( sortDescriptor, CONTS_HEADER );
+ nIndex = findSortPropertyIndex( sortDescriptor, "ContainsHeader" );
sortDescriptor[ nIndex ].Value <<= bContainsHeader;
rDoc.SetSortParam( aSortParam, nTab );
@@ -4070,13 +4066,13 @@ ScVbaRange::getHeight() throw (uno::RuntimeException, std::exception)
awt::Point
ScVbaRange::getPosition() throw ( uno::RuntimeException )
{
- awt::Point aPoint;
+ awt::Point aPoint;
uno::Reference< beans::XPropertySet > xProps;
if ( mxRange.is() )
xProps.set( mxRange, uno::UNO_QUERY_THROW );
else
xProps.set( mxRanges, uno::UNO_QUERY_THROW );
- xProps->getPropertyValue( POSITION ) >>= aPoint;
+ xProps->getPropertyValue( "Position" ) >>= aPoint;
return aPoint;
}
uno::Any SAL_CALL
@@ -4196,10 +4192,9 @@ ScVbaRange::ApplicationRange( const uno::Reference< uno::XComponentContext >& xC
Cell1 >>= sRangeName;
if ( Cell1.hasValue() && !Cell2.hasValue() && !sRangeName.isEmpty() )
{
- static const char sNamedRanges[] = "NamedRanges";
uno::Reference< beans::XPropertySet > xPropSet( getCurrentExcelDoc(xContext), uno::UNO_QUERY_THROW );
- uno::Reference< container::XNameAccess > xNamed( xPropSet->getPropertyValue( sNamedRanges ), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNameAccess > xNamed( xPropSet->getPropertyValue( "NamedRanges" ), uno::UNO_QUERY_THROW );
uno::Reference< sheet::XCellRangeReferrer > xReferrer;
try
{
@@ -5478,7 +5473,7 @@ ScVbaRange::SpecialCellsImpl( sal_Int32 nType, const uno::Any& _oValue) throw (
}
catch (uno::Exception& )
{
- DebugHelper::basicexception(ERRCODE_BASIC_METHOD_FAILED, STR_ERRORMESSAGE_NOCELLSWEREFOUND);
+ DebugHelper::basicexception(ERRCODE_BASIC_METHOD_FAILED, "No cells were found");
}
return xRange;
}
@@ -5503,7 +5498,7 @@ ScVbaRange::Subtotal( ::sal_Int32 _nGroupBy, ::sal_Int32 _nFunction, const uno::
uno::Reference< sheet::XSubTotalCalculatable> xSub(mxRange, uno::UNO_QUERY_THROW );
uno::Reference< sheet::XSubTotalDescriptor > xSubDesc = xSub->createSubTotalDescriptor(true);
uno::Reference< beans::XPropertySet > xSubDescPropertySet( xSubDesc, uno::UNO_QUERY_THROW );
- xSubDescPropertySet->setPropertyValue(INSERTPAGEBREAKS, uno::makeAny( bAddPageBreaks));
+ xSubDescPropertySet->setPropertyValue("InsertPageBreaks", uno::makeAny( bAddPageBreaks));
sal_Int32 nLen = _nTotalList.getLength();
uno::Sequence< sheet::SubTotalColumn > aColumns( nLen );
for (int i = 0; i < nLen; i++)
@@ -5586,13 +5581,12 @@ ScVbaRange::hasError() throw (uno::RuntimeException, std::exception)
uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
uno::Reference< script::XInvocation > xInvoc( xApplication->WorksheetFunction(), uno::UNO_QUERY_THROW );
- static const char FunctionName[] = "IsError";
uno::Sequence< uno::Any > Params(1);
uno::Reference< excel::XRange > aRange( this );
Params[0] = uno::makeAny( aRange );
uno::Sequence< sal_Int16 > OutParamIndex;
uno::Sequence< uno::Any > OutParam;
- xInvoc->invoke( FunctionName, Params, OutParamIndex, OutParam ) >>= dResult;
+ xInvoc->invoke( "IsError", Params, OutParamIndex, OutParam ) >>= dResult;
return dResult > 0.0;
}
diff --git a/sc/source/ui/vba/vbawindow.cxx b/sc/source/ui/vba/vbawindow.cxx
index 29f9206ac586..de36e6daff9e 100644
--- a/sc/source/ui/vba/vbawindow.cxx
+++ b/sc/source/ui/vba/vbawindow.cxx
@@ -319,11 +319,10 @@ ScVbaWindow::getCaption() throw (uno::RuntimeException, std::exception)
if ( !sTitle.equals( sName ) )
{
- static const char sDot[] = ".";
// starts with title
if ( sName.startsWith( sTitle ) )
// extension starts immediately after
- if ( sName.match( sDot, sTitle.getLength() ) )
+ if ( sName.match( ".", sTitle.getLength() ) )
sTitle = sName;
}
}
diff --git a/sc/source/ui/vba/vbaworkbooks.cxx b/sc/source/ui/vba/vbaworkbooks.cxx
index 57215fd78bbd..535e554636b3 100644
--- a/sc/source/ui/vba/vbaworkbooks.cxx
+++ b/sc/source/ui/vba/vbaworkbooks.cxx
@@ -230,7 +230,6 @@ ScVbaWorkbooks::Open( const OUString& rFileName, const uno::Any& /*UpdateLinks*/
sProps.realloc( 3 );
sProps[ nIndex ].Name = "FilterOptions";
sal_Int16 delims[] = { 0 /*default not used*/, 9/*tab*/, 44/*comma*/, 32/*space*/, 59/*semicolon*/ };
- static const char sRestOfFormat[] = ",34,0,1";
OUString sFormat;
sal_Int16 nFormat = 0; // default indicator
@@ -264,7 +263,7 @@ ScVbaWorkbooks::Open( const OUString& rFileName, const uno::Any& /*UpdateLinks*/
getCurrentDelim() = nDelim; //set new current
- sFormat = OUString::number( nDelim ) + sRestOfFormat;
+ sFormat = OUString::number( nDelim ) + ",34,0,1";
sProps[ nIndex++ ].Value <<= sFormat;
sProps[ nIndex ].Name = "FilterName";
sProps[ nIndex++ ].Value <<= OUString( "Text - txt - csv (StarCalc)" );