From 127f70d66ac32b7a4ec818adaf1bdccb71865ee5 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 21 Jul 2016 14:23:23 +0200 Subject: new loplugin to check for static OUStrings that are better declared as OUStringLiteral Change-Id: Ifb5d9a12bb31a68641940bec16971a8181a46567 Reviewed-on: https://gerrit.libreoffice.org/27377 Reviewed-by: Noel Grandin Tested-by: Noel Grandin --- svx/source/fmcomp/fmgridif.cxx | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'svx/source/fmcomp/fmgridif.cxx') diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx index fbb6d18f221e..6f40844c9088 100644 --- a/svx/source/fmcomp/fmgridif.cxx +++ b/svx/source/fmcomp/fmgridif.cxx @@ -1594,24 +1594,22 @@ Reference< XIndexContainer > FmXGridPeer::getColumns() throw( RuntimeException, void FmXGridPeer::addColumnListeners(const Reference< XPropertySet >& xCol) { - static const OUString aPropsListenedTo[] = + static const OUStringLiteral aPropsListenedTo[] = { - OUString(FM_PROP_LABEL), OUString(FM_PROP_WIDTH), OUString(FM_PROP_HIDDEN), OUString(FM_PROP_ALIGN), OUString(FM_PROP_FORMATKEY) + OUStringLiteral(FM_PROP_LABEL), OUStringLiteral(FM_PROP_WIDTH), OUStringLiteral(FM_PROP_HIDDEN), + OUStringLiteral(FM_PROP_ALIGN), OUStringLiteral(FM_PROP_FORMATKEY) }; // as not all properties have to be supported by all columns we have to check this // before adding a listener Reference< XPropertySetInfo > xInfo = xCol->getPropertySetInfo(); - Property aPropDesc; - const OUString* pProps = aPropsListenedTo; - const OUString* pPropsEnd = pProps + SAL_N_ELEMENTS( aPropsListenedTo ); - for (; pProps != pPropsEnd; ++pProps) + for (unsigned i=0; ihasPropertyByName( *pProps ) ) + if ( xInfo->hasPropertyByName( aPropsListenedTo[i] ) ) { - aPropDesc = xInfo->getPropertyByName( *pProps ); + Property aPropDesc = xInfo->getPropertyByName( aPropsListenedTo[i] ); if ( 0 != ( aPropDesc.Attributes & PropertyAttribute::BOUND ) ) - xCol->addPropertyChangeListener( *pProps, this ); + xCol->addPropertyChangeListener( aPropsListenedTo[i], this ); } } } @@ -1621,9 +1619,10 @@ void FmXGridPeer::removeColumnListeners(const Reference< XPropertySet >& xCol) { // the same props as in addColumnListeners ... linux has problems with global static UStrings, so // we have to do it this way .... - static const OUString aPropsListenedTo[] = + static const OUStringLiteral aPropsListenedTo[] = { - OUString(FM_PROP_LABEL), OUString(FM_PROP_WIDTH), OUString(FM_PROP_HIDDEN), OUString(FM_PROP_ALIGN), OUString(FM_PROP_FORMATKEY) + OUStringLiteral(FM_PROP_LABEL), OUStringLiteral(FM_PROP_WIDTH), OUStringLiteral(FM_PROP_HIDDEN), + OUStringLiteral(FM_PROP_ALIGN), OUStringLiteral(FM_PROP_FORMATKEY) }; Reference< XPropertySetInfo > xInfo = xCol->getPropertySetInfo(); -- cgit