summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2017-12-17 23:00:24 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-12-18 07:36:32 +0100
commit4e144751f12a06e358e4f7efa7c8f13954e6cfd7 (patch)
treec6df66d58d02ecaf5caa437a944665fe83959402 /editeng
parent39c618caf5aa19da95285bec6cab7108bee3984c (diff)
loplugin:unusedindex
Change-Id: I256a807dd2a4c81126b5a76f3d472e31b8224146 Reviewed-on: https://gerrit.libreoffice.org/46652 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/accessibility/AccessibleEditableTextPara.cxx121
-rw-r--r--editeng/source/misc/acorrcfg.cxx3
-rw-r--r--editeng/source/uno/unotext.cxx68
3 files changed, 74 insertions, 118 deletions
diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
index 2348709303b1..d985d6648cea 100644
--- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx
+++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
@@ -1218,12 +1218,9 @@ namespace accessibility
::comphelper::SequenceAsHashMap aPropHashMap( getDefaultAttributes( aPropertyNames ) );
// ... and override them with the direct attributes from the specific position
- uno::Sequence< beans::PropertyValue > aRunAttribs( getRunAttributes( nIndex, aPropertyNames ) );
- sal_Int32 nRunAttribs = aRunAttribs.getLength();
- const beans::PropertyValue *pRunAttrib = aRunAttribs.getConstArray();
- for (sal_Int32 k = 0; k < nRunAttribs; ++k)
+ const uno::Sequence< beans::PropertyValue > aRunAttribs( getRunAttributes( nIndex, aPropertyNames ) );
+ for (auto const& rRunAttrib : aRunAttribs)
{
- const beans::PropertyValue &rRunAttrib = pRunAttrib[k];
aPropHashMap[ rRunAttrib.Name ] = rRunAttrib.Value; //!! should not only be the value !!
}
@@ -1234,16 +1231,13 @@ namespace accessibility
// since SequenceAsHashMap ignores property handles and property state
// we have to restore the property state here (property handles are
// of no use to the accessibility API).
- sal_Int32 nRes = aRes.getLength();
- beans::PropertyValue *pRes = aRes.getArray();
- for (sal_Int32 i = 0; i < nRes; ++i)
+ for (beans::PropertyValue & rRes : aRes)
{
- beans::PropertyValue &rRes = pRes[i];
bool bIsDirectVal = false;
- for (sal_Int32 k = 0; k < nRunAttribs && !bIsDirectVal; ++k)
+ for (auto const& rRunAttrib : aRunAttribs)
{
- if (rRes.Name == pRunAttrib[k].Name)
- bIsDirectVal = true;
+ if ((bIsDirectVal = rRes.Name == rRunAttrib.Name))
+ break;
}
rRes.Handle = -1;
rRes.State = bIsDirectVal ? PropertyState_DIRECT_VALUE : PropertyState_DEFAULT_VALUE;
@@ -1252,10 +1246,9 @@ namespace accessibility
{
_correctValues( aRes );
// NumberingPrefix
- nRes = aRes.getLength();
+ sal_Int32 nRes = aRes.getLength();
aRes.realloc( nRes + 1 );
- pRes = aRes.getArray();
- beans::PropertyValue &rRes = pRes[nRes];
+ beans::PropertyValue &rRes = aRes[nRes];
rRes.Name = "NumberingPrefix";
OUString numStr;
if (aBulletInfo.nType != SVX_NUM_CHAR_SPECIAL && aBulletInfo.nType != SVX_NUM_BITMAP)
@@ -1269,32 +1262,30 @@ namespace accessibility
{
nRes = aRes.getLength();
aRes.realloc( nRes + 1 );
- pRes = aRes.getArray();
- beans::PropertyValue &rResField = pRes[nRes];
- beans::PropertyValue aFieldType;
+ beans::PropertyValue &rResField = aRes[nRes];
rResField.Name = "FieldType";
rResField.Value <<= strFieldType.toAsciiLowerCase();
rResField.Handle = -1;
rResField.State = PropertyState_DIRECT_VALUE;
- }
- //sort property values
- // build sorted index array
- sal_Int32 nLength = aRes.getLength();
- const beans::PropertyValue* pPairs = aRes.getConstArray();
- std::unique_ptr<sal_Int32[]> pIndices(new sal_Int32[nLength]);
- sal_Int32 i = 0;
- for( i = 0; i < nLength; i++ )
- pIndices[i] = i;
- sort( &pIndices[0], &pIndices[nLength], IndexCompare(pPairs) );
- // create sorted sequences according to index array
- uno::Sequence<beans::PropertyValue> aNewValues( nLength );
- beans::PropertyValue* pNewValues = aNewValues.getArray();
- for( i = 0; i < nLength; i++ )
- {
- pNewValues[i] = pPairs[pIndices[i]];
- }
+ }
+ //sort property values
+ // build sorted index array
+ sal_Int32 nLength = aRes.getLength();
+ const beans::PropertyValue* pPairs = aRes.getConstArray();
+ std::unique_ptr<sal_Int32[]> pIndices(new sal_Int32[nLength]);
+ sal_Int32 i = 0;
+ for( i = 0; i < nLength; i++ )
+ pIndices[i] = i;
+ sort( &pIndices[0], &pIndices[nLength], IndexCompare(pPairs) );
+ // create sorted sequences according to index array
+ uno::Sequence<beans::PropertyValue> aNewValues( nLength );
+ beans::PropertyValue* pNewValues = aNewValues.getArray();
+ for( i = 0; i < nLength; i++ )
+ {
+ pNewValues[i] = pPairs[pIndices[i]];
+ }
- return aNewValues;
+ return aNewValues;
}
return aRes;
}
@@ -2352,20 +2343,16 @@ namespace accessibility
xPropSet->SetSelection( MakeSelection(nStartIndex, nEndIndex) );
// convert from PropertyValue to Any
- sal_Int32 i, nLength( aAttributeSet.getLength() );
- const beans::PropertyValue* pPropArray = aAttributeSet.getConstArray();
- for(i=0; i<nLength; ++i)
+ for(const beans::PropertyValue& rProp : aAttributeSet)
{
try
{
- xPropSet->setPropertyValue(pPropArray->Name, pPropArray->Value);
+ xPropSet->setPropertyValue(rProp.Name, rProp.Value);
}
catch (const uno::Exception&)
{
OSL_FAIL("AccessibleEditableTextPara::setAttributes exception in setPropertyValue");
}
-
- ++pPropArray;
}
rCacheTF.QuickFormatDoc();
@@ -2410,21 +2397,18 @@ namespace accessibility
( static_cast< XAccessible* > (this) ) ); // disambiguate hierarchy
// build sequence of available properties to check
- sal_Int32 nLenReqAttr = rRequestedAttributes.getLength();
uno::Sequence< beans::Property > aProperties;
- if (nLenReqAttr)
+ if (const sal_Int32 nLenReqAttr = rRequestedAttributes.getLength())
{
- const OUString *pRequestedAttributes = rRequestedAttributes.getConstArray();
-
aProperties.realloc( nLenReqAttr );
beans::Property *pProperties = aProperties.getArray();
sal_Int32 nCurLen = 0;
- for (sal_Int32 i = 0; i < nLenReqAttr; ++i)
+ for (const OUString& rRequestedAttribute : rRequestedAttributes)
{
beans::Property aProp;
try
{
- aProp = xPropSetInfo->getPropertyByName( pRequestedAttributes[i] );
+ aProp = xPropSetInfo->getPropertyByName( rRequestedAttribute );
}
catch (const beans::UnknownPropertyException&)
{
@@ -2437,19 +2421,16 @@ namespace accessibility
else
aProperties = xPropSetInfo->getProperties();
- sal_Int32 nLength = aProperties.getLength();
- const beans::Property *pProperties = aProperties.getConstArray();
-
// build resulting sequence
- uno::Sequence< beans::PropertyValue > aOutSequence( nLength );
+ uno::Sequence< beans::PropertyValue > aOutSequence( aProperties.getLength() );
beans::PropertyValue* pOutSequence = aOutSequence.getArray();
sal_Int32 nOutLen = 0;
- for (sal_Int32 i = 0; i < nLength; ++i)
+ for (const beans::Property& rProperty : aProperties)
{
// calling implementation functions:
// _getPropertyState and _getPropertyValue (see below) to provide
// the proper paragraph number when retrieving paragraph attributes
- PropertyState eState = xPropSet->_getPropertyState( pProperties->Name, mnParagraphIndex );
+ PropertyState eState = xPropSet->_getPropertyState( rProperty.Name, mnParagraphIndex );
if ( eState == PropertyState_AMBIGUOUS_VALUE )
{
OSL_FAIL( "ambiguous property value encountered" );
@@ -2460,15 +2441,14 @@ namespace accessibility
// properties spanning the whole paragraph should be returned
// and declared as default value
{
- pOutSequence->Name = pProperties->Name;
- pOutSequence->Handle = pProperties->Handle;
- pOutSequence->Value = xPropSet->_getPropertyValue( pProperties->Name, mnParagraphIndex );
+ pOutSequence->Name = rProperty.Name;
+ pOutSequence->Handle = rProperty.Handle;
+ pOutSequence->Value = xPropSet->_getPropertyValue( rProperty.Name, mnParagraphIndex );
pOutSequence->State = PropertyState_DEFAULT_VALUE;
++pOutSequence;
++nOutLen;
}
- ++pProperties;
}
aOutSequence.realloc( nOutLen );
@@ -2503,21 +2483,18 @@ namespace accessibility
( static_cast< XAccessible* > (this) ) ); // disambiguate hierarchy
// build sequence of available properties to check
- sal_Int32 nLenReqAttr = rRequestedAttributes.getLength();
uno::Sequence< beans::Property > aProperties;
- if (nLenReqAttr)
+ if (const sal_Int32 nLenReqAttr = rRequestedAttributes.getLength())
{
- const OUString *pRequestedAttributes = rRequestedAttributes.getConstArray();
-
aProperties.realloc( nLenReqAttr );
beans::Property *pProperties = aProperties.getArray();
sal_Int32 nCurLen = 0;
- for (sal_Int32 i = 0; i < nLenReqAttr; ++i)
+ for (const OUString& rRequestedAttribute : rRequestedAttributes)
{
beans::Property aProp;
try
{
- aProp = xPropSetInfo->getPropertyByName( pRequestedAttributes[i] );
+ aProp = xPropSetInfo->getPropertyByName( rRequestedAttribute );
}
catch (const beans::UnknownPropertyException&)
{
@@ -2530,28 +2507,24 @@ namespace accessibility
else
aProperties = xPropSetInfo->getProperties();
- sal_Int32 nLength = aProperties.getLength();
- const beans::Property *pProperties = aProperties.getConstArray();
-
// build resulting sequence
- uno::Sequence< beans::PropertyValue > aOutSequence( nLength );
+ uno::Sequence< beans::PropertyValue > aOutSequence( aProperties.getLength() );
beans::PropertyValue* pOutSequence = aOutSequence.getArray();
sal_Int32 nOutLen = 0;
- for (sal_Int32 i = 0; i < nLength; ++i)
+ for (const beans::Property& rProperty : aProperties)
{
// calling 'regular' functions that will operate on the selection
- PropertyState eState = xPropSet->getPropertyState( pProperties->Name );
+ PropertyState eState = xPropSet->getPropertyState( rProperty.Name );
if (eState == PropertyState_DIRECT_VALUE)
{
- pOutSequence->Name = pProperties->Name;
- pOutSequence->Handle = pProperties->Handle;
- pOutSequence->Value = xPropSet->getPropertyValue( pProperties->Name );
+ pOutSequence->Name = rProperty.Name;
+ pOutSequence->Handle = rProperty.Handle;
+ pOutSequence->Value = xPropSet->getPropertyValue( rProperty.Name );
pOutSequence->State = eState;
++pOutSequence;
++nOutLen;
}
- ++pProperties;
}
aOutSequence.realloc( nOutLen );
diff --git a/editeng/source/misc/acorrcfg.cxx b/editeng/source/misc/acorrcfg.cxx
index 3f8df4907ed5..5bd97c67a197 100644
--- a/editeng/source/misc/acorrcfg.cxx
+++ b/editeng/source/misc/acorrcfg.cxx
@@ -59,8 +59,7 @@ SvxAutoCorrCfg::SvxAutoCorrCfg() :
Reference < ucb::XCommandEnvironment > xEnv;
::utl::UCBContentHelper::ensureFolder(comphelper::getProcessComponentContext(), xEnv, sUserPath, aContent);
- OUString* pS = &sSharePath;
- for( sal_uInt16 n = 0; n < 2; ++n, pS = &sUserPath )
+ for( OUString* pS : { &sSharePath, &sUserPath } )
{
INetURLObject aPath( *pS );
aPath.insertName("acor");
diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx
index 82a90486bc65..aced15ee0f53 100644
--- a/editeng/source/uno/unotext.cxx
+++ b/editeng/source/uno/unotext.cxx
@@ -1042,43 +1042,32 @@ uno::Sequence< beans::PropertyState > SAL_CALL SvxUnoTextRangeBase::getPropertyS
uno::Sequence< beans::PropertyState > SvxUnoTextRangeBase::_getPropertyStates(const uno::Sequence< OUString >& PropertyName, sal_Int32 nPara /* = -1 */)
{
- const sal_Int32 nCount = PropertyName.getLength();
- const OUString* pNames = PropertyName.getConstArray();
-
- uno::Sequence< beans::PropertyState > aRet( nCount );
- beans::PropertyState* pState = aRet.getArray();
+ uno::Sequence< beans::PropertyState > aRet( PropertyName.getLength() );
SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
if( pForwarder )
{
- SfxItemSet* pSet = nullptr;
+ std::unique_ptr<SfxItemSet> pSet;
if( nPara != -1 )
{
- pSet = new SfxItemSet( pForwarder->GetParaAttribs( nPara ) );
+ pSet.reset(new SfxItemSet( pForwarder->GetParaAttribs( nPara ) ));
}
else
{
ESelection aSel( GetSelection() );
CheckSelection( aSel, pForwarder );
- pSet = new SfxItemSet( pForwarder->GetAttribs( aSel, EditEngineAttribs::OnlyHard ) );
+ pSet.reset(new SfxItemSet( pForwarder->GetAttribs( aSel, EditEngineAttribs::OnlyHard ) ));
}
- bool bUnknownPropertyFound = false;
- for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++ )
+ beans::PropertyState* pState = aRet.getArray();
+ for( const OUString& rName : PropertyName )
{
- const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry( *pNames++ );
- if( nullptr == pMap )
+ const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry( rName );
+ if( !_getOnePropertyStates(pSet.get(), pMap, *pState++) )
{
- bUnknownPropertyFound = true;
- break;
+ throw beans::UnknownPropertyException();
}
- bUnknownPropertyFound = !_getOnePropertyStates(pSet, pMap, *pState++);
}
-
- delete pSet;
-
- if( bUnknownPropertyFound )
- throw beans::UnknownPropertyException();
}
return aRet;
@@ -1302,22 +1291,20 @@ void SAL_CALL SvxUnoTextRangeBase::setAllPropertiesToDefault()
void SAL_CALL SvxUnoTextRangeBase::setPropertiesToDefault( const uno::Sequence< OUString >& aPropertyNames )
{
- sal_Int32 nCount = aPropertyNames.getLength();
- for( const OUString* pName = aPropertyNames.getConstArray(); nCount; pName++, nCount-- )
+ for( const OUString& rName : aPropertyNames )
{
- setPropertyToDefault( *pName );
+ setPropertyToDefault( rName );
}
}
uno::Sequence< uno::Any > SAL_CALL SvxUnoTextRangeBase::getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames )
{
- sal_Int32 nCount = aPropertyNames.getLength();
- uno::Sequence< uno::Any > ret( nCount );
+ uno::Sequence< uno::Any > ret( aPropertyNames.getLength() );
uno::Any* pDefaults = ret.getArray();
- for( const OUString* pName = aPropertyNames.getConstArray(); nCount; pName++, nCount--, pDefaults++ )
+ for( const OUString& rName : aPropertyNames )
{
- *pDefaults = getPropertyDefault( *pName );
+ *pDefaults++ = getPropertyDefault( rName );
}
return ret;
@@ -2004,13 +1991,11 @@ void SvxPropertyValuesToItemSet(
SvxTextForwarder *pForwarder /*needed for WID_NUMLEVEL*/,
sal_Int32 nPara /*needed for WID_NUMLEVEL*/)
{
- sal_Int32 nProps = rPropertyVaules.getLength();
- const beans::PropertyValue *pProps = rPropertyVaules.getConstArray();
- for (sal_Int32 i = 0; i < nProps; ++i)
+ for (const beans::PropertyValue& rProp : rPropertyVaules)
{
- const SfxItemPropertySimpleEntry *pEntry = pPropSet->getPropertyMap().getByName( pProps[i].Name );
+ const SfxItemPropertySimpleEntry *pEntry = pPropSet->getPropertyMap().getByName( rProp.Name );
if (!pEntry)
- throw beans::UnknownPropertyException( "Unknown property: " + pProps[i].Name, static_cast < cppu::OWeakObject * > ( nullptr ) );
+ throw beans::UnknownPropertyException( "Unknown property: " + rProp.Name, static_cast < cppu::OWeakObject * > ( nullptr ) );
// Note: there is no need to take special care of the properties
// TextField (EE_FEATURE_FIELD) and
// TextPortionType (WID_PORTIONTYPE)
@@ -2018,13 +2003,13 @@ void SvxPropertyValuesToItemSet(
if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
// should be PropertyVetoException which is not yet defined for the new import API's functions
- throw uno::RuntimeException("Property is read-only: " + pProps[i].Name, static_cast < cppu::OWeakObject * > ( nullptr ) );
- //throw PropertyVetoException ("Property is read-only: " + pProps[i].Name, static_cast < cppu::OWeakObject * > ( 0 ) );
+ throw uno::RuntimeException("Property is read-only: " + rProp.Name, static_cast < cppu::OWeakObject * > ( nullptr ) );
+ //throw PropertyVetoException ("Property is read-only: " + rProp.Name, static_cast < cppu::OWeakObject * > ( 0 ) );
if (pEntry->nWID == WID_FONTDESC)
{
awt::FontDescriptor aDesc;
- if (pProps[i].Value >>= aDesc)
+ if (rProp.Value >>= aDesc)
SvxUnoFontDescriptor::FillItemSet( aDesc, rItemSet );
}
else if (pEntry->nWID == WID_NUMLEVEL)
@@ -2032,7 +2017,7 @@ void SvxPropertyValuesToItemSet(
if (pForwarder)
{
sal_Int16 nLevel = -1;
- pProps[i].Value >>= nLevel;
+ rProp.Value >>= nLevel;
// #101004# Call interface method instead of unsafe cast
if (!pForwarder->SetDepth( nPara, nLevel ))
@@ -2044,7 +2029,7 @@ void SvxPropertyValuesToItemSet(
if( pForwarder )
{
sal_Int16 nStartValue = -1;
- if( !(pProps[i].Value >>= nStartValue) )
+ if( !(rProp.Value >>= nStartValue) )
throw lang::IllegalArgumentException();
pForwarder->SetNumberingStartValue( nPara, nStartValue );
@@ -2055,14 +2040,14 @@ void SvxPropertyValuesToItemSet(
if( pForwarder )
{
bool bParaIsNumberingRestart = false;
- if( !(pProps[i].Value >>= bParaIsNumberingRestart) )
+ if( !(rProp.Value >>= bParaIsNumberingRestart) )
throw lang::IllegalArgumentException();
pForwarder->SetParaIsNumberingRestart( nPara, bParaIsNumberingRestart );
}
}
else
- pPropSet->setPropertyValue( pProps[i].Name, pProps[i].Value, rItemSet );
+ pPropSet->setPropertyValue( rProp.Name, rProp.Value, rItemSet );
}
}
@@ -2144,9 +2129,8 @@ uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::appendTextPortion(
SvxUnoTextRange* pRange = new SvxUnoTextRange( *this );
xRet = pRange;
pRange->SetSelection( aSel );
- const beans::PropertyValue* pProps = rCharAndParaProps.getConstArray();
- for( sal_Int32 nProp = 0; nProp < rCharAndParaProps.getLength(); ++nProp )
- pRange->setPropertyValue( pProps[nProp].Name, pProps[nProp].Value );
+ for( const beans::PropertyValue& rProp : rCharAndParaProps )
+ pRange->setPropertyValue( rProp.Name, rProp.Value );
}
return xRet;
}