diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2019-07-20 20:03:15 +0300 |
---|---|---|
committer | Arkadiy Illarionov <qarkai@gmail.com> | 2019-07-22 18:42:35 +0200 |
commit | 6ffdc88e79904882e319bdd0b901e7491abae0b3 (patch) | |
tree | 5cb0257a03987f962668655af536a05ad72f8882 /starmath/source | |
parent | 803a6ccb774ff6dc67ca697459d6679e4bc9604f (diff) |
Simplify Sequence iterations in shell..svgio
Use range-based loops, STL and comphelper functions
Change-Id: I612d36abcc09a91c60f7212de6747a1a1bdcfc69
Reviewed-on: https://gerrit.libreoffice.org/76056
Tested-by: Jenkins
Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'starmath/source')
-rw-r--r-- | starmath/source/cfgitem.cxx | 38 | ||||
-rw-r--r-- | starmath/source/mathmlimport.cxx | 39 | ||||
-rw-r--r-- | starmath/source/unomodel.cxx | 28 |
3 files changed, 38 insertions, 67 deletions
diff --git a/starmath/source/cfgitem.cxx b/starmath/source/cfgitem.cxx index fb43b5ce5bee..5b6b900e051c 100644 --- a/starmath/source/cfgitem.cxx +++ b/starmath/source/cfgitem.cxx @@ -373,17 +373,9 @@ void SmMathConfig::ReadSymbol( SmSym &rSymbol, sal_Int32 nProps = aNames.getLength(); OUString aDelim( "/" ); - OUString *pName = aNames.getArray(); - for (sal_Int32 i = 0; i < nProps; ++i) - { - OUString &rName = pName[i]; - OUString aTmp( rName ); - rName = rBaseNode; - rName += aDelim; - rName += rSymbolName; - rName += aDelim; - rName += aTmp; - } + std::transform(aNames.begin(), aNames.end(), aNames.begin(), + [&rBaseNode, &rSymbolName, &aDelim](const OUString& rName) -> OUString { + return rBaseNode + aDelim + rSymbolName + aDelim + rName; }); const Sequence< Any > aValues = const_cast<SmMathConfig*>(this)->GetProperties(aNames); @@ -569,15 +561,13 @@ void SmMathConfig::LoadFontFormatList() pFontFormatList->Clear(); Sequence< OUString > aNodes( GetNodeNames( FONT_FORMAT_LIST ) ); - const OUString *pNode = aNodes.getConstArray(); - sal_Int32 nNodes = aNodes.getLength(); - for (sal_Int32 i = 0; i < nNodes; ++i) + for (const OUString& rNode : aNodes) { SmFontFormat aFntFmt; - ReadFontFormat( aFntFmt, pNode[i], FONT_FORMAT_LIST ); - if (!pFontFormatList->GetFontFormat( pNode[i] )) - pFontFormatList->AddFontFormat( pNode[i], aFntFmt ); + ReadFontFormat( aFntFmt, rNode, FONT_FORMAT_LIST ); + if (!pFontFormatList->GetFontFormat( rNode )) + pFontFormatList->AddFontFormat( rNode, aFntFmt ); } pFontFormatList->SetModified( false ); } @@ -590,17 +580,9 @@ void SmMathConfig::ReadFontFormat( SmFontFormat &rFontFormat, sal_Int32 nProps = aNames.getLength(); OUString aDelim( "/" ); - OUString *pName = aNames.getArray(); - for (sal_Int32 i = 0; i < nProps; ++i) - { - OUString &rName = pName[i]; - OUString aTmp( rName ); - rName = rBaseNode; - rName += aDelim; - rName += rSymbolName; - rName += aDelim; - rName += aTmp; - } + std::transform(aNames.begin(), aNames.end(), aNames.begin(), + [&rBaseNode, &rSymbolName, &aDelim](const OUString& rName) -> OUString { + return rBaseNode + aDelim + rSymbolName + aDelim + rName; }); const Sequence< Any > aValues = const_cast<SmMathConfig*>(this)->GetProperties(aNames); diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx index fcc4a6c45bd4..a0d7afd51267 100644 --- a/starmath/source/mathmlimport.cxx +++ b/starmath/source/mathmlimport.cxx @@ -3079,38 +3079,34 @@ void SmXMLImport::SetViewSettings(const Sequence<PropertyValue>& aViewProps) tools::Rectangle aRect( pDocShell->GetVisArea() ); - sal_Int32 nCount = aViewProps.getLength(); - const PropertyValue *pValue = aViewProps.getConstArray(); - long nTmp = 0; - for (sal_Int32 i = 0; i < nCount ; i++) + for (const PropertyValue& rValue : aViewProps) { - if (pValue->Name == "ViewAreaTop" ) + if (rValue.Name == "ViewAreaTop" ) { - pValue->Value >>= nTmp; + rValue.Value >>= nTmp; aRect.SaturatingSetY(nTmp); } - else if (pValue->Name == "ViewAreaLeft" ) + else if (rValue.Name == "ViewAreaLeft" ) { - pValue->Value >>= nTmp; + rValue.Value >>= nTmp; aRect.SaturatingSetX(nTmp); } - else if (pValue->Name == "ViewAreaWidth" ) + else if (rValue.Name == "ViewAreaWidth" ) { - pValue->Value >>= nTmp; + rValue.Value >>= nTmp; Size aSize( aRect.GetSize() ); aSize.setWidth( nTmp ); aRect.SaturatingSetSize(aSize); } - else if (pValue->Name == "ViewAreaHeight" ) + else if (rValue.Name == "ViewAreaHeight" ) { - pValue->Value >>= nTmp; + rValue.Value >>= nTmp; Size aSize( aRect.GetSize() ); aSize.setHeight( nTmp ); aRect.SaturatingSetSize(aSize); } - pValue++; } pDocShell->SetVisArea ( aRect ); @@ -3126,22 +3122,19 @@ void SmXMLImport::SetConfigurationSettings(const Sequence<PropertyValue>& aConfP if (!xInfo.is() ) return; - sal_Int32 nCount = aConfProps.getLength(); - const PropertyValue* pValues = aConfProps.getConstArray(); - const OUString sFormula ( "Formula" ); const OUString sBasicLibraries ( "BasicLibraries" ); const OUString sDialogLibraries ( "DialogLibraries" ); - while ( nCount-- ) + for ( const PropertyValue& rValue : aConfProps ) { - if (pValues->Name != sFormula && - pValues->Name != sBasicLibraries && - pValues->Name != sDialogLibraries) + if (rValue.Name != sFormula && + rValue.Name != sBasicLibraries && + rValue.Name != sDialogLibraries) { try { - if ( xInfo->hasPropertyByName( pValues->Name ) ) - xProps->setPropertyValue( pValues->Name, pValues->Value ); + if ( xInfo->hasPropertyByName( rValue.Name ) ) + xProps->setPropertyValue( rValue.Name, rValue.Value ); } catch (const beans::PropertyVetoException &) { @@ -3152,8 +3145,6 @@ void SmXMLImport::SetConfigurationSettings(const Sequence<PropertyValue>& aConfP DBG_UNHANDLED_EXCEPTION("starmath"); } } - - pValues++; } } diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx index 8042f0e099d7..ce6e1d0c4f68 100644 --- a/starmath/source/unomodel.cxx +++ b/starmath/source/unomodel.cxx @@ -636,22 +636,20 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any* if ( !(*pValues >>= aSequence) ) throw IllegalArgumentException(); - sal_uInt32 nSize = aSequence.getLength(); SmModule *pp = SM_MOD(); SmSymbolManager &rManager = pp->GetSymbolManager(); - SymbolDescriptor *pDescriptor = aSequence.getArray(); - for (sal_uInt32 i = 0; i < nSize ; i++, pDescriptor++) + for (const SymbolDescriptor& rDescriptor : aSequence) { vcl::Font aFont; - aFont.SetFamilyName ( pDescriptor->sFontName ); - aFont.SetCharSet ( static_cast < rtl_TextEncoding > (pDescriptor->nCharSet) ); - aFont.SetFamily ( static_cast < FontFamily > (pDescriptor->nFamily ) ); - aFont.SetPitch ( static_cast < FontPitch > (pDescriptor->nPitch ) ); - aFont.SetWeight ( static_cast < FontWeight > (pDescriptor->nWeight ) ); - aFont.SetItalic ( static_cast < FontItalic > (pDescriptor->nItalic ) ); - SmSym aSymbol ( pDescriptor->sName, aFont, static_cast < sal_Unicode > (pDescriptor->nCharacter), - pDescriptor->sSymbolSet ); - aSymbol.SetExportName ( pDescriptor->sExportName ); + aFont.SetFamilyName ( rDescriptor.sFontName ); + aFont.SetCharSet ( static_cast < rtl_TextEncoding > (rDescriptor.nCharSet) ); + aFont.SetFamily ( static_cast < FontFamily > (rDescriptor.nFamily ) ); + aFont.SetPitch ( static_cast < FontPitch > (rDescriptor.nPitch ) ); + aFont.SetWeight ( static_cast < FontWeight > (rDescriptor.nWeight ) ); + aFont.SetItalic ( static_cast < FontItalic > (rDescriptor.nItalic ) ); + SmSym aSymbol ( rDescriptor.sName, aFont, static_cast < sal_Unicode > (rDescriptor.nCharacter), + rDescriptor.sSymbolSet ); + aSymbol.SetExportName ( rDescriptor.sExportName ); rManager.AddOrReplaceSymbol ( aSymbol ); } } @@ -982,10 +980,10 @@ void SAL_CALL SmModel::render( // get device to be rendered in uno::Reference< awt::XDevice > xRenderDevice; - for (sal_Int32 i = 0, nCount = rxOptions.getLength(); i < nCount; ++i) + for (const auto& rxOption : rxOptions) { - if( rxOptions[i].Name == "RenderDevice" ) - rxOptions[i].Value >>= xRenderDevice; + if( rxOption.Name == "RenderDevice" ) + rxOption.Value >>= xRenderDevice; } if (!xRenderDevice.is()) |