Kaydet (Commit) 56d97cdd authored tarafından Arkadiy Illarionov's avatar Arkadiy Illarionov Kaydeden (comit) Noel Grandin

Simplify containers iterations in sfx2, shell

Use range-based loop or replace with STL functions

Change-Id: I42361d6a73d201db8eb6dca09d79768e2d62051d
Reviewed-on: https://gerrit.libreoffice.org/64389
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst fff501a3
......@@ -92,10 +92,9 @@ void LinkManager::InsertCachedComp(const Reference<XComponent>& xComp)
void LinkManager::CloseCachedComps()
{
CompVector::iterator itr = maCachedComps.begin(), itrEnd = maCachedComps.end();
for (; itr != itrEnd; ++itr)
for (const auto& rxCachedComp : maCachedComps)
{
Reference<XCloseable> xCloseable(*itr, UNO_QUERY);
Reference<XCloseable> xCloseable(rxCachedComp, UNO_QUERY);
if (!xCloseable.is())
continue;
......
......@@ -99,12 +99,10 @@ public:
void DeleteAndDestroy(SvLinkSource_Entry_Impl const * p)
{
for (auto it = mvData.begin(); it != mvData.end(); ++it)
if (it->get() == p)
{
mvData.erase(it);
break;
}
auto it = std::find_if(mvData.begin(), mvData.end(),
[&p](const std::unique_ptr<SvLinkSource_Entry_Impl>& rxData) { return rxData.get() == p; });
if (it != mvData.end())
mvData.erase(it);
}
};
......
......@@ -88,20 +88,15 @@ void SAL_CALL PreventDuplicateInteraction::handle(const css::uno::Reference< css
// SAFE ->
::osl::ResettableMutexGuard aLock(m_aLock);
InteractionList::iterator pIt;
for ( pIt = m_lInteractionRules.begin();
pIt != m_lInteractionRules.end();
++pIt )
auto pIt = std::find_if(m_lInteractionRules.begin(), m_lInteractionRules.end(),
[&aRequest](const InteractionInfo& rInfo) { return aRequest.isExtractableTo(rInfo.m_aInteraction); });
if (pIt != m_lInteractionRules.end())
{
InteractionInfo& rInfo = *pIt;
if (aRequest.isExtractableTo(rInfo.m_aInteraction))
{
++rInfo.m_nCallCount;
rInfo.m_xRequest = xRequest;
bHandleIt = (rInfo.m_nCallCount <= rInfo.m_nMaxCount);
break;
}
++rInfo.m_nCallCount;
rInfo.m_xRequest = xRequest;
bHandleIt = (rInfo.m_nCallCount <= rInfo.m_nMaxCount);
}
css::uno::Reference< css::task::XInteractionHandler > xHandler = m_xHandler;
......@@ -138,20 +133,15 @@ sal_Bool SAL_CALL PreventDuplicateInteraction::handleInteractionRequest( const c
// SAFE ->
::osl::ResettableMutexGuard aLock(m_aLock);
InteractionList::iterator pIt;
for ( pIt = m_lInteractionRules.begin();
pIt != m_lInteractionRules.end();
++pIt )
auto pIt = std::find_if(m_lInteractionRules.begin(), m_lInteractionRules.end(),
[&aRequest](const InteractionInfo& rInfo) { return aRequest.isExtractableTo(rInfo.m_aInteraction); });
if (pIt != m_lInteractionRules.end())
{
InteractionInfo& rInfo = *pIt;
if (aRequest.isExtractableTo(rInfo.m_aInteraction))
{
++rInfo.m_nCallCount;
rInfo.m_xRequest = xRequest;
bHandleIt = (rInfo.m_nCallCount <= rInfo.m_nMaxCount);
break;
}
++rInfo.m_nCallCount;
rInfo.m_xRequest = xRequest;
bHandleIt = (rInfo.m_nCallCount <= rInfo.m_nMaxCount);
}
css::uno::Reference< css::task::XInteractionHandler2 > xHandler( m_xHandler, css::uno::UNO_QUERY );
......@@ -188,18 +178,14 @@ void PreventDuplicateInteraction::addInteractionRule(const PreventDuplicateInter
// SAFE ->
::osl::ResettableMutexGuard aLock(m_aLock);
InteractionList::iterator pIt;
for ( pIt = m_lInteractionRules.begin();
pIt != m_lInteractionRules.end();
++pIt )
auto pIt = std::find_if(m_lInteractionRules.begin(), m_lInteractionRules.end(),
[&aInteractionInfo](const InteractionInfo& rInfo) { return rInfo.m_aInteraction == aInteractionInfo.m_aInteraction; });
if (pIt != m_lInteractionRules.end())
{
InteractionInfo& rInfo = *pIt;
if (rInfo.m_aInteraction == aInteractionInfo.m_aInteraction)
{
rInfo.m_nMaxCount = aInteractionInfo.m_nMaxCount;
rInfo.m_nCallCount = aInteractionInfo.m_nCallCount;
return;
}
rInfo.m_nMaxCount = aInteractionInfo.m_nMaxCount;
rInfo.m_nCallCount = aInteractionInfo.m_nCallCount;
return;
}
m_lInteractionRules.push_back(aInteractionInfo);
......@@ -214,17 +200,12 @@ bool PreventDuplicateInteraction::getInteractionInfo(const css::uno::Type&
// SAFE ->
::osl::ResettableMutexGuard aLock(m_aLock);
PreventDuplicateInteraction::InteractionList::const_iterator pIt;
for ( pIt = m_lInteractionRules.begin();
pIt != m_lInteractionRules.end();
++pIt )
auto pIt = std::find_if(m_lInteractionRules.begin(), m_lInteractionRules.end(),
[&aInteraction](const InteractionInfo& rInfo) { return rInfo.m_aInteraction == aInteraction; });
if (pIt != m_lInteractionRules.end())
{
const PreventDuplicateInteraction::InteractionInfo& rInfo = *pIt;
if (rInfo.m_aInteraction == aInteraction)
{
*pReturn = rInfo;
return true;
}
*pReturn = *pIt;
return true;
}
aLock.clear();
......
......@@ -444,28 +444,24 @@ bool TemplateLocalView::removeTemplate (const sal_uInt16 nItemId, const sal_uInt
if (pRegion->mnId == nSrcItemId)
{
TemplateContainerItem *pItem = pRegion.get();
std::vector<TemplateItemProperties>::iterator pIter;
for (pIter = pItem->maTemplates.begin(); pIter != pItem->maTemplates.end(); ++pIter)
auto pIter = std::find_if(pItem->maTemplates.begin(), pItem->maTemplates.end(),
[nItemId](const TemplateItemProperties& rTemplate) { return rTemplate.nId == nItemId; });
if (pIter != pItem->maTemplates.end())
{
if (pIter->nId == nItemId)
{
if (!mpDocTemplates->Delete(pItem->mnRegionId,pIter->nDocId))
return false;
pIter = pItem->maTemplates.erase(pIter);
if (pRegion->mnRegionId == mnCurRegionId-1)
{
RemoveItem(nItemId);
Invalidate();
}
if (!mpDocTemplates->Delete(pItem->mnRegionId,pIter->nDocId))
return false;
// Update Doc Idx for all templates that follow
for (; pIter != pItem->maTemplates.end(); ++pIter)
pIter->nDocId = pIter->nDocId - 1;
pIter = pItem->maTemplates.erase(pIter);
break;
if (pRegion->mnRegionId == mnCurRegionId-1)
{
RemoveItem(nItemId);
Invalidate();
}
// Update Doc Idx for all templates that follow
for (; pIter != pItem->maTemplates.end(); ++pIter)
pIter->nDocId = pIter->nDocId - 1;
}
CalculateItemPositions();
......
......@@ -38,6 +38,7 @@
#include <memory>
#include <comphelper/sequence.hxx>
#include <comphelper/string.hxx>
#include <com/sun/star/security/DocumentSignatureInformation.hpp>
#include <com/sun/star/security/DocumentDigitalSignatures.hpp>
......@@ -2353,10 +2354,9 @@ Sequence< document::CmisProperty > CmisPropertiesWindow::GetCmisProperties() con
{
Sequence< document::CmisProperty > aPropertiesSeq( m_aCmisPropertiesLines.size() );
sal_Int32 i = 0;
for ( auto pIter = m_aCmisPropertiesLines.begin();
pIter != m_aCmisPropertiesLines.end(); ++pIter, ++i )
for ( auto& rxLine : m_aCmisPropertiesLines )
{
CmisPropertyLine* pLine = pIter->get();
CmisPropertyLine* pLine = rxLine.get();
aPropertiesSeq[i].Id = pLine->m_sId;
aPropertiesSeq[i].Type = pLine->m_sType;
......@@ -2376,15 +2376,15 @@ Sequence< document::CmisProperty > CmisPropertiesWindow::GetCmisProperties() con
m_aNumberFormatter ).GetFormatIndex( NF_NUMBER_SYSTEM );
Sequence< double > seqValue( pLine->m_aValues.size( ) );
sal_Int32 k = 0;
for ( auto it = pLine->m_aValues.begin();
it != pLine->m_aValues.end(); ++it, ++k)
for ( auto& rxValue : pLine->m_aValues )
{
double dValue = 0.0;
OUString sValue( (*it)->m_aValueEdit->GetText() );
OUString sValue( rxValue->m_aValueEdit->GetText() );
bool bIsNum = const_cast< SvNumberFormatter& >( m_aNumberFormatter ).
IsNumberFormat( sValue, nIndex, dValue );
if ( bIsNum )
seqValue[k] = dValue;
++k;
}
aPropertiesSeq[i].Value <<= seqValue;
}
......@@ -2394,15 +2394,15 @@ Sequence< document::CmisProperty > CmisPropertiesWindow::GetCmisProperties() con
m_aNumberFormatter ).GetFormatIndex( NF_NUMBER_SYSTEM );
Sequence< sal_Int64 > seqValue( pLine->m_aValues.size( ) );
sal_Int32 k = 0;
for ( auto it = pLine->m_aValues.begin();
it != pLine->m_aValues.end(); ++it, ++k)
for ( auto& rxValue : pLine->m_aValues )
{
double dValue = 0;
OUString sValue( (*it)->m_aValueEdit->GetText() );
OUString sValue( rxValue->m_aValueEdit->GetText() );
bool bIsNum = const_cast< SvNumberFormatter& >( m_aNumberFormatter ).
IsNumberFormat( sValue, nIndex, dValue );
if ( bIsNum )
seqValue[k] = static_cast<sal_Int64>(dValue);
++k;
}
aPropertiesSeq[i].Value <<= seqValue;
}
......@@ -2410,11 +2410,11 @@ Sequence< document::CmisProperty > CmisPropertiesWindow::GetCmisProperties() con
{
Sequence<sal_Bool> seqValue( pLine->m_aYesNos.size( ) );
sal_Int32 k = 0;
for ( auto it = pLine->m_aYesNos.begin();
it != pLine->m_aYesNos.end(); ++it, ++k)
for ( auto& rxYesNo : pLine->m_aYesNos )
{
bool bValue = (*it)->m_aYesButton->IsChecked();
bool bValue = rxYesNo->m_aYesButton->IsChecked();
seqValue[k] = bValue;
++k;
}
aPropertiesSeq[i].Value <<= seqValue;
......@@ -2423,16 +2423,16 @@ Sequence< document::CmisProperty > CmisPropertiesWindow::GetCmisProperties() con
{
Sequence< util::DateTime > seqValue( pLine->m_aDateTimes.size( ) );
sal_Int32 k = 0;
for ( auto it = pLine->m_aDateTimes.begin();
it != pLine->m_aDateTimes.end(); ++it, ++k)
for ( auto& rxDateTime : pLine->m_aDateTimes )
{
Date aTmpDate = (*it)->m_aDateField->GetDate();
tools::Time aTmpTime = (*it)->m_aTimeField->GetTime();
Date aTmpDate = rxDateTime->m_aDateField->GetDate();
tools::Time aTmpTime = rxDateTime->m_aTimeField->GetTime();
util::DateTime aDateTime( aTmpTime.GetNanoSec(), aTmpTime.GetSec(),
aTmpTime.GetMin(), aTmpTime.GetHour(),
aTmpDate.GetDay(), aTmpDate.GetMonth(),
aTmpDate.GetYear(), true );
seqValue[k] = aDateTime;
++k;
}
aPropertiesSeq[i].Value <<= seqValue;
}
......@@ -2440,15 +2440,16 @@ Sequence< document::CmisProperty > CmisPropertiesWindow::GetCmisProperties() con
{
Sequence< OUString > seqValue( pLine->m_aValues.size( ) );
sal_Int32 k = 0;
for ( auto it = pLine->m_aValues.begin();
it != pLine->m_aValues.end(); ++it, ++k)
for ( auto& rxValue : pLine->m_aValues )
{
OUString sValue( (*it)->m_aValueEdit->GetText() );
OUString sValue( rxValue->m_aValueEdit->GetText() );
seqValue[k] = sValue;
++k;
}
aPropertiesSeq[i].Value <<= seqValue;
}
}
++i;
}
return aPropertiesSeq;
......@@ -2592,11 +2593,7 @@ bool SfxCmisPropertiesPage::FillItemSet( SfxItemSet* rSet )
}
}
}
Sequence< document::CmisProperty> aModifiedProps( modifiedNum );
sal_Int32 nCount = 0;
for( std::vector< document::CmisProperty>::const_iterator pIter = changedProps.begin();
pIter != changedProps.end( ); ++pIter )
aModifiedProps[ nCount++ ] = *pIter;
Sequence< document::CmisProperty> aModifiedProps( comphelper::containerToSequence(changedProps) );
pInfo->SetCmisProperties( aModifiedProps );
rSet->Put( *pInfo );
if ( bMustDelete )
......
......@@ -623,15 +623,11 @@ namespace sfx2
"sfx2::lcl_GroupAndClassify: invalid all-filters array here!" );
// the loop below will work on invalid objects else ...
++aGroupPos;
auto aGlobalIter = aGlobalClassNames.begin();
while ( ( aGroupPos != _rAllFilters.end() )
&& ( aGlobalIter != aGlobalClassNames.end() )
&& ( *aGlobalIter != aServiceName )
)
{
++aGlobalIter;
++aGroupPos;
}
auto aGlobalIter = std::find(aGlobalClassNames.begin(), aGlobalClassNames.end(), aServiceName);
auto nGroupPosShift = std::min(
std::distance(aGlobalClassNames.begin(), aGlobalIter),
std::distance(aGroupPos, _rAllFilters.end()));
std::advance(aGroupPos, nGroupPosShift);
if ( aGroupPos != _rAllFilters.end() )
// we found a global class name which matches the doc service name -> fill the filters of this
// group in the respective prepared group
......
......@@ -222,8 +222,8 @@ void SfxInfoBarWindow::SetForeAndBackgroundColors(InfoBarType eType)
void SfxInfoBarWindow::dispose()
{
for ( auto it = m_aActionBtns.begin( ); it != m_aActionBtns.end( ); ++it )
it->disposeAndClear();
for ( auto& rxBtn : m_aActionBtns )
rxBtn.disposeAndClear();
m_pImage.disposeAndClear();
m_pMessage.disposeAndClear();
......@@ -382,14 +382,11 @@ bool SfxInfoBarContainerWindow::hasInfoBarWithID( const OUString &sId )
void SfxInfoBarContainerWindow::removeInfoBar(VclPtr<SfxInfoBarWindow> const & pInfoBar)
{
// Remove
for (auto it = m_pInfoBars.begin(); it != m_pInfoBars.end(); ++it)
auto it = std::find(m_pInfoBars.begin(), m_pInfoBars.end(), pInfoBar);
if (it != m_pInfoBars.end())
{
if (pInfoBar == *it)
{
it->disposeAndClear();
m_pInfoBars.erase(it);
break;
}
it->disposeAndClear();
m_pInfoBars.erase(it);
}
// Resize
......@@ -412,12 +409,12 @@ void SfxInfoBarContainerWindow::Resize()
// Only need to change the width of the infobars
long nWidth = GetSizePixel().getWidth();
for (auto it = m_pInfoBars.begin(); it != m_pInfoBars.end(); ++it)
for (auto& rxInfoBar : m_pInfoBars)
{
Size aSize = (*it)->GetSizePixel();
Size aSize = rxInfoBar->GetSizePixel();
aSize.setWidth(nWidth);
(*it)->SetSizePixel(aSize);
(*it)->Resize();
rxInfoBar->SetSizePixel(aSize);
rxInfoBar->Resize();
}
}
......
......@@ -1079,10 +1079,8 @@ void SAL_CALL DocumentMetadataAccess::loadMetadataFromStorage(
const uno::Reference<rdf::XURI>& xMetadataFile(
getURI<rdf::URIs::PKG_METADATAFILE>(m_pImpl->m_xContext));
const sal_Int32 len( baseURI.getLength() );
for (::std::vector< uno::Reference< rdf::XURI > >::const_iterator it
= parts.begin();
it != parts.end(); ++it) {
const OUString name((*it)->getStringValue());
for (const auto& rxPart : parts) {
const OUString name(rxPart->getStringValue());
if (!name.match(baseURI)) {
SAL_WARN("sfx", "loadMetadataFromStorage: graph not in document: " << name);
continue;
......@@ -1095,7 +1093,7 @@ void SAL_CALL DocumentMetadataAccess::loadMetadataFromStorage(
// remove found items from StgFiles
StgFiles.erase(relName);
if (isContentFile(relName)) {
if (!isPartOfType(*m_pImpl, *it, xContentFile)) {
if (!isPartOfType(*m_pImpl, rxPart, xContentFile)) {
const uno::Reference <rdf::XURI> xName(
getURIForStream(*m_pImpl, relName) );
// add missing type statement
......@@ -1104,7 +1102,7 @@ void SAL_CALL DocumentMetadataAccess::loadMetadataFromStorage(
xContentFile.get());
}
} else if (isStylesFile(relName)) {
if (!isPartOfType(*m_pImpl, *it, xStylesFile)) {
if (!isPartOfType(*m_pImpl, rxPart, xStylesFile)) {
const uno::Reference <rdf::XURI> xName(
getURIForStream(*m_pImpl, relName) );
// add missing type statement
......@@ -1115,7 +1113,7 @@ void SAL_CALL DocumentMetadataAccess::loadMetadataFromStorage(
} else if (isReservedFile(relName)) {
SAL_WARN("sfx", "loadMetadataFromStorage: reserved file name in manifest");
} else {
if (isPartOfType(*m_pImpl, *it, xMetadataFile)) {
if (isPartOfType(*m_pImpl, rxPart, xMetadataFile)) {
MfstMetadataFiles.push_back(relName);
}
// do not add statement for MetadataFile; it could be
......
......@@ -110,11 +110,8 @@ void SfxObjectFactory::RegisterViewFactory
}
}
#endif
SfxViewFactoryArr_Impl::iterator it = pImpl->aViewFactoryArr.begin();
for ( ; it != pImpl->aViewFactoryArr.end() &&
(*it)->GetOrdinal() <= rFactory.GetOrdinal();
++it )
/* empty loop */;
auto it = std::find_if(pImpl->aViewFactoryArr.begin(), pImpl->aViewFactoryArr.end(),
[&rFactory](SfxViewFactory* pFactory) { return pFactory->GetOrdinal() > rFactory.GetOrdinal(); });
pImpl->aViewFactoryArr.insert(it, &rFactory);
}
......
......@@ -149,11 +149,10 @@ ErrCode LoadOlePropertySet(
i_xDocProps->getUserDefinedProperties(), uno::UNO_QUERY_THROW);
::std::vector< sal_Int32 > aPropIds;
xCustomSect->GetPropertyIds( aPropIds );
for( ::std::vector< sal_Int32 >::const_iterator aIt = aPropIds.begin(),
aEnd = aPropIds.end(); aIt != aEnd; ++aIt )
for( const auto& rPropId : aPropIds )
{
const OUString aPropName = xCustomSect->GetPropertyName( *aIt );
uno::Any aPropValue = xCustomSect->GetAnyValue( *aIt );
const OUString aPropName = xCustomSect->GetPropertyName( rPropId );
uno::Any aPropValue = xCustomSect->GetAnyValue( rPropId );
if( !aPropName.isEmpty() && aPropValue.hasValue() )
{
try
......
......@@ -124,27 +124,20 @@ void PriorityHBox::Resize()
long nCurrentWidth = VclHBox::calculateRequisition().getWidth();
// Hide lower priority controls
auto pChild = m_aSortedChildren.begin();
while (nCurrentWidth > nWidth && pChild != m_aSortedChildren.end())
for (vcl::IPrioritable* pPrioritable : m_aSortedChildren)
{
vcl::Window* pWindow = dynamic_cast<vcl::Window*>(*pChild);
vcl::IPrioritable* pPrioritable = *pChild;
if (nCurrentWidth <= nWidth)
break;
if(pWindow->GetParent() != this)
{
pChild++;
continue;
}
vcl::Window* pWindow = dynamic_cast<vcl::Window*>(pPrioritable);
if (pWindow)
if (pWindow && pWindow->GetParent() == this)
{
nCurrentWidth -= pWindow->GetOutputWidthPixel() + get_spacing();
pWindow->Show();
pPrioritable->HideContent();
nCurrentWidth += pWindow->GetOutputWidthPixel() + get_spacing();
}
pChild++;
}
auto pChildR = m_aSortedChildren.rbegin();
......
......@@ -399,17 +399,11 @@ TModelList::iterator SfxGlobalEvents_Impl::impl_searchDoc(const uno::Reference<
if (!xModel.is())
return m_lModels.end();
TModelList::iterator pIt;
for ( pIt = m_lModels.begin();
pIt != m_lModels.end() ;
++pIt )
{
uno::Reference< frame::XModel > xContainerDoc(*pIt, uno::UNO_QUERY);
if (xContainerDoc == xModel)
break;
}
return pIt;
return std::find_if(m_lModels.begin(), m_lModels.end(),
[&xModel](const TModelList::value_type& rxModel) {
uno::Reference< frame::XModel > xContainerDoc(rxModel, uno::UNO_QUERY);
return xContainerDoc == xModel;
});
}
struct Instance {
......
......@@ -155,13 +155,10 @@ tools::Rectangle LayoutPanels (
sal_Int32 nTotalPreferredHeight (0);
sal_Int32 nTotalMinimumHeight (0);
for(::std::vector<LayoutItem>::const_iterator iItem(rLayoutItems.begin()),
iEnd(rLayoutItems.end());
iItem!=iEnd;
++iItem)
for (const auto& rItem : rLayoutItems)
{
nTotalMinimumHeight += iItem->maLayoutSize.Minimum;
nTotalPreferredHeight += iItem->maLayoutSize.Preferred;
nTotalMinimumHeight += rItem.maLayoutSize.Minimum;
nTotalPreferredHeight += rItem.maLayoutSize.Preferred;
}
if (nTotalMinimumHeight > nAvailableHeight
......@@ -343,36 +340,32 @@ void GetRequestedSizes (
const sal_Int32 nDeckSeparatorHeight (Theme::GetInteger(Theme::Int_DeckSeparatorHeight));
::std::vector<LayoutItem>::const_iterator iEnd(rLayoutItems.end());
for(::std::vector<LayoutItem>::iterator iItem(rLayoutItems.begin());
iItem!=iEnd;
++iItem)
for (auto& rItem : rLayoutItems)
{
ui::LayoutSize aLayoutSize (ui::LayoutSize(0,0,0));
if (iItem->mpPanel != nullptr)
if (rItem.mpPanel != nullptr)
{
if (rLayoutItems.size() == 1
&& iItem->mpPanel->IsTitleBarOptional())
&& rItem.mpPanel->IsTitleBarOptional())
{
// There is only one panel and its title bar is
// optional => hide it.
rAvailableHeight -= nDeckSeparatorHeight;
iItem->mbShowTitleBar = false;
rItem.mbShowTitleBar = false;
}
else
{
// Show the title bar and a separator above and below
// the title bar.
const sal_Int32 nPanelTitleBarHeight (Theme::GetInteger(Theme::Int_PanelTitleBarHeight) * iItem->mpPanel->GetDPIScaleFactor());
const sal_Int32 nPanelTitleBarHeight (Theme::GetInteger(Theme::Int_PanelTitleBarHeight) * rItem.mpPanel->GetDPIScaleFactor());
rAvailableHeight -= nPanelTitleBarHeight;
rAvailableHeight -= nDeckSeparatorHeight;
}
if (iItem->mpPanel->IsExpanded())
if (rItem.mpPanel->IsExpanded())
{
Reference<ui::XSidebarPanel> xPanel (iItem->mpPanel->GetPanelComponent());
Reference<ui::XSidebarPanel> xPanel (rItem.mpPanel->GetPanelComponent());
if (xPanel.is())
{
aLayoutSize = xPanel->getHeightForWidth(rContentBox.GetWidth());
......@@ -385,7 +378,7 @@ void GetRequestedSizes (
aLayoutSize = ui::LayoutSize(MinimalPanelHeight, -1, 0);
}
}
iItem->maLayoutSize = aLayoutSize;
rItem.maLayoutSize = aLayoutSize;
}
}
......@@ -405,25 +398,21 @@ void DistributeHeights (
sal_Int32 nTotalWeight (0);
sal_Int32 nNoMaximumCount (0);
::std::vector<LayoutItem>::const_iterator iEnd(rLayoutItems.end());
for(::std::vector<LayoutItem>::iterator iItem(rLayoutItems.begin());
iItem!=iEnd;
++iItem)
for (auto& rItem : rLayoutItems)
{
if (iItem->maLayoutSize.Maximum == 0)
if (rItem.maLayoutSize.Maximum == 0)
continue;
if (iItem->maLayoutSize.Maximum < 0)
if (rItem.maLayoutSize.Maximum < 0)
++nNoMaximumCount;
const sal_Int32 nBaseHeight (
bMinimumHeightIsBase
? iItem->maLayoutSize.Minimum
: iItem->maLayoutSize.Preferred);
? rItem.maLayoutSize.Minimum
: rItem.maLayoutSize.Preferred);
if (nBaseHeight < nContainerHeight)
{
iItem->mnWeight = nContainerHeight - nBaseHeight;
nTotalWeight += iItem->mnWeight;
rItem.mnWeight = nContainerHeight - nBaseHeight;
nTotalWeight += rItem.mnWeight;
}
}
......@@ -431,21 +420,19 @@ void DistributeHeights (
return;
// First pass of height distribution.
for(::std::vector<LayoutItem>::iterator iItem(rLayoutItems.begin());
iItem!=iEnd;
++iItem)
for (auto& rItem : rLayoutItems)
{
const sal_Int32 nBaseHeight (
bMinimumHeightIsBase
? iItem->maLayoutSize.Minimum
: iItem->maLayoutSize.Preferred);
sal_Int32 nDistributedHeight (iItem->mnWeight * nHeightToDistribute / nTotalWeight);
if (nBaseHeight+nDistributedHeight > iItem->maLayoutSize.Maximum
&& iItem->maLayoutSize.Maximum >= 0)
? rItem.maLayoutSize.Minimum
: rItem.maLayoutSize.Preferred);
sal_Int32 nDistributedHeight (rItem.mnWeight * nHeightToDistribute / nTotalWeight);
if (nBaseHeight+nDistributedHeight > rItem.maLayoutSize.Maximum
&& rItem.maLayoutSize.Maximum >= 0)
{
nDistributedHeight = ::std::max<sal_Int32>(0,iItem->maLayoutSize.Maximum - nBaseHeight);
nDistributedHeight = ::std::max<sal_Int32>(0, rItem.maLayoutSize.Maximum - nBaseHeight);
}
iItem->mnDistributedHeight = nDistributedHeight;
rItem.mnDistributedHeight = nDistributedHeight;
nRemainingHeightToDistribute -= nDistributedHeight;
}
......@@ -467,13 +454,11 @@ void DistributeHeights (
sal_Int32 nAdditionalHeightForFirstPanel (nRemainingHeightToDistribute
- nNoMaximumCount*nAdditionalHeightPerPanel);
for(::std::vector<LayoutItem>::iterator iItem(rLayoutItems.begin());
iItem!=iEnd;
++iItem)
for (auto& rItem : rLayoutItems)
{
if (iItem->maLayoutSize.Maximum < 0)
if (rItem.maLayoutSize.Maximum < 0)
{
iItem->mnDistributedHeight += nAdditionalHeightPerPanel + nAdditionalHeightForFirstPanel;
rItem.mnDistributedHeight += nAdditionalHeightPerPanel + nAdditionalHeightForFirstPanel;
nRemainingHeightToDistribute -= nAdditionalHeightPerPanel + nAdditionalHeightForFirstPanel;
}
}
......
......@@ -229,11 +229,9 @@ void SAL_CALL SidebarController::disposing()
IsDocumentReadOnly(),
mxFrame->getController());
for (ResourceManager::DeckContextDescriptorContainer::const_iterator
iDeck(aDecks.begin()), iEnd(aDecks.end());
iDeck!=iEnd; ++iDeck)
for (const auto& rDeck : aDecks)
{
std::shared_ptr<DeckDescriptor> deckDesc = mpResourceManager->GetDeckDescriptor(iDeck->msId);
std::shared_ptr<DeckDescriptor> deckDesc = mpResourceManager->GetDeckDescriptor(rDeck.msId);
VclPtr<Deck> aDeck = deckDesc->mpDeck;
if (aDeck)
......@@ -480,21 +478,17 @@ void SidebarController::UpdateConfigurations()
// one. If that is not set or not enabled, then choose the
// first enabled deck (which is PropertyDeck).
OUString sNewDeckId;
for (ResourceManager::DeckContextDescriptorContainer::const_iterator
iDeck(aDecks.begin()),
iEnd(aDecks.end());
iDeck!=iEnd;
++iDeck)
for (const auto& rDeck : aDecks)
{
if (iDeck->mbIsEnabled)
if (rDeck.mbIsEnabled)
{
if (iDeck->msId == msCurrentDeckId)
if (rDeck.msId == msCurrentDeckId)
{
sNewDeckId = msCurrentDeckId;
break;
}
else if (sNewDeckId.getLength() == 0)
sNewDeckId = iDeck->msId;
sNewDeckId = rDeck.msId;
}
}
......@@ -996,29 +990,26 @@ VclPtr<PopupMenu> SidebarController::CreatePopupMenu (
// Add one entry for every tool panel element to individually make
// them visible or hide them.
sal_Int32 nIndex (0);
for(::std::vector<TabBar::DeckMenuData>::const_iterator
iItem(rMenuData.begin()),
iEnd(rMenuData.end());
iItem!=iEnd;
++iItem,++nIndex)
for (const auto& rItem : rMenuData)
{
const sal_Int32 nMenuIndex (nIndex+MID_FIRST_PANEL);
pMenu->InsertItem(nMenuIndex, iItem->msDisplayName, MenuItemBits::RADIOCHECK);
pMenu->CheckItem(nMenuIndex, iItem->mbIsCurrentDeck);
pMenu->EnableItem(nMenuIndex, iItem->mbIsEnabled&&iItem->mbIsActive);
pMenu->InsertItem(nMenuIndex, rItem.msDisplayName, MenuItemBits::RADIOCHECK);
pMenu->CheckItem(nMenuIndex, rItem.mbIsCurrentDeck);
pMenu->EnableItem(nMenuIndex, rItem.mbIsEnabled && rItem.mbIsActive);
const sal_Int32 nSubMenuIndex (nIndex+MID_FIRST_HIDE);
if (iItem->mbIsCurrentDeck)
if (rItem.mbIsCurrentDeck)
{
// Don't allow the currently visible deck to be disabled.
pCustomizationMenu->InsertItem(nSubMenuIndex, iItem->msDisplayName, MenuItemBits::RADIOCHECK);
pCustomizationMenu->InsertItem(nSubMenuIndex, rItem.msDisplayName, MenuItemBits::RADIOCHECK);
pCustomizationMenu->CheckItem(nSubMenuIndex);
}
else
{
pCustomizationMenu->InsertItem(nSubMenuIndex, iItem->msDisplayName, MenuItemBits::CHECKABLE);
pCustomizationMenu->CheckItem(nSubMenuIndex, iItem->mbIsEnabled && iItem->mbIsActive);
pCustomizationMenu->InsertItem(nSubMenuIndex, rItem.msDisplayName, MenuItemBits::CHECKABLE);
pCustomizationMenu->CheckItem(nSubMenuIndex, rItem.mbIsEnabled && rItem.mbIsActive);
}
++nIndex;
}
pMenu->InsertSeparator();
......@@ -1311,23 +1302,20 @@ void SidebarController::UpdateTitleBarIcons()
// Update the panel icons.
const SharedPanelContainer& rPanels (mpCurrentDeck->GetPanels());
for (SharedPanelContainer::const_iterator
iPanel(rPanels.begin()), iEnd(rPanels.end());
iPanel!=iEnd;
++iPanel)
for (const auto& rxPanel : rPanels)
{
if ( ! *iPanel)
if ( ! rxPanel)
continue;
if (!(*iPanel)->GetTitleBar())
if (!rxPanel->GetTitleBar())
continue;
std::shared_ptr<PanelDescriptor> xPanelDescriptor = rResourceManager.GetPanelDescriptor((*iPanel)->GetId());
std::shared_ptr<PanelDescriptor> xPanelDescriptor = rResourceManager.GetPanelDescriptor(rxPanel->GetId());
if (!xPanelDescriptor)
continue;
const OUString sIconURL (
bIsHighContrastModeActive
? xPanelDescriptor->msHighContrastTitleBarIconURL
: xPanelDescriptor->msTitleBarIconURL);
(*iPanel)->GetTitleBar()->SetIcon(Tools::GetImage(sIconURL, mxFrame));
rxPanel->GetTitleBar()->SetIcon(Tools::GetImage(sIconURL, mxFrame));
}
}
......
......@@ -350,21 +350,13 @@ void SAL_CALL Theme::disposing()
const lang::EventObject aEvent (static_cast<XWeak*>(this));
for (ChangeListeners::const_iterator
iContainer(aListeners.begin()),
iContainerEnd(aListeners.end());
iContainer != iContainerEnd;
++iContainer)
for (const auto& rContainer : aListeners)
{
for (ChangeListenerContainer::const_iterator
iListener(iContainer->second.begin()),
iEnd(iContainer->second.end());
iListener!=iEnd;
++iListener)
for (const auto& rxListener : rContainer.second)
{
try
{
(*iListener)->disposing(aEvent);
rxListener->disposing(aEvent);
}
catch(const Exception&)
{
......@@ -934,13 +926,9 @@ bool Theme::DoVetoableListenersVeto (
VetoableListenerContainer aListeners (*pListeners);
try
{
for (VetoableListenerContainer::const_iterator
iListener(aListeners.begin()),
iEnd(aListeners.end());
iListener!=iEnd;
++iListener)
for (const auto& rxListener : aListeners)
{
(*iListener)->vetoableChange(rEvent);
rxListener->vetoableChange(rEvent);
}
}
catch(const beans::PropertyVetoException&)
......@@ -964,13 +952,9 @@ void Theme::BroadcastPropertyChange (
const ChangeListenerContainer aListeners (*pListeners);
try
{
for (ChangeListenerContainer::const_iterator
iListener(aListeners.begin()),
iEnd(aListeners.end());
iListener!=iEnd;
++iListener)
for (const auto& rxListener : aListeners)
{
(*iListener)->propertyChange(rEvent);
rxListener->propertyChange(rEvent);
}
}
catch(const Exception&)
......
......@@ -67,13 +67,11 @@ uno::Sequence< OUString > SAL_CALL SfxUnoDecks::getElementNames()
long n = 0;
for (ResourceManager::DeckContextDescriptorContainer::const_iterator
iDeck(aDecks.begin()), iEnd(aDecks.end());
iDeck!=iEnd; ++iDeck)
{
deckList[n] = iDeck->msId;
n++;
}
for (const auto& rDeck : aDecks)
{
deckList[n] = rDeck.msId;
n++;
}
}
return deckList;
......@@ -98,13 +96,8 @@ sal_Bool SAL_CALL SfxUnoDecks::hasByName( const OUString& aName )
pSidebarController->IsDocumentReadOnly(),
xFrame->getController());
for (ResourceManager::DeckContextDescriptorContainer::const_iterator
iDeck(aDecks.begin()), iEnd(aDecks.end());
iDeck!=iEnd && !bFound; ++iDeck)
{
if (iDeck->msId == aName)
bFound = true;
}
bFound = std::any_of(aDecks.begin(), aDecks.end(),
[&aName](const ResourceManager::DeckContextDescriptor& rDeck) { return rDeck.msId == aName; });
}
return bFound;
......
......@@ -76,13 +76,11 @@ uno::Sequence< OUString > SAL_CALL SfxUnoPanels::getElementNames()
long n = 0;
for (ResourceManager::PanelContextDescriptorContainer::const_iterator
iPanel(aPanels.begin()), iEnd(aPanels.end());
iPanel!=iEnd; ++iPanel)
{
panelList[n] = iPanel->msId;
n++;
}
for (const auto& rPanel : aPanels)
{
panelList[n] = rPanel.msId;
n++;
}
}
return panelList;
......@@ -104,16 +102,13 @@ sal_Bool SAL_CALL SfxUnoPanels::hasByName( const OUString& aName )
mDeckId,
xFrame->getController());
for (ResourceManager::PanelContextDescriptorContainer::const_iterator
iPanel(aPanels.begin()), iEnd(aPanels.end());
iPanel!=iEnd; ++iPanel)
{
// Determine if the panel can be displayed.
if(pSidebarController->IsDocumentReadOnly() && !iPanel->mbShowForReadOnlyDocuments)
continue;
if (iPanel->msId == aName)
return true;
}
bool bIsDocumentReadOnly = pSidebarController->IsDocumentReadOnly();
return std::any_of(aPanels.begin(), aPanels.end(),
[&bIsDocumentReadOnly, &aName](const ResourceManager::PanelContextDescriptor& rPanel) {
return (!bIsDocumentReadOnly || rPanel.mbShowForReadOnlyDocuments) // Determine if the panel can be displayed.
&& (rPanel.msId == aName);
});
}
// nothing found
......
......@@ -360,14 +360,9 @@ void SfxViewShell::IPClientGone_Impl( SfxInPlaceClient const *pIPClient )
{
std::vector< SfxInPlaceClient* > *pClients = pImpl->GetIPClients_Impl();
for(std::vector< SfxInPlaceClient* >::iterator it = pClients->begin(); it != pClients->end(); ++it)
{
if ( *it == pIPClient )
{
pClients->erase( it );
break;
}
}
auto it = std::find(pClients->begin(), pClients->end(), pIPClient);
if (it != pClients->end())
pClients->erase( it );
}
......
......@@ -73,19 +73,13 @@ void list_view_builder::build(statistic_group_list_t& gl)
{
setup_list_view();
statistic_group_list_t::iterator group_iter = gl.begin();
statistic_group_list_t::iterator group_iter_end = gl.end();
for (/**/; group_iter != group_iter_end; ++group_iter)
for (const auto& group : gl)
{
statistic_item_list_t::iterator item_iter = group_iter->second.begin();
statistic_item_list_t::iterator item_iter_end = group_iter->second.end();
if (item_iter != item_iter_end)
insert_group(group_iter->first);
if (!group.second.empty())
insert_group(group.first);
for (/**/; item_iter != item_iter_end; ++item_iter)
insert_item(item_iter->title_, item_iter->value_, item_iter->editable_);
for (const auto& item : group.second)
insert_item(item.title_, item.value_, item.editable_);
}
}
......
......@@ -114,26 +114,23 @@ std::wstring iso8601_duration_to_local_duration(const std::wstring& iso8601durat
std::wstring minutes;
std::wstring seconds;
std::wstring::const_iterator iter = iso8601duration.begin();
std::wstring::const_iterator iter_end = iso8601duration.end();
std::wstring num;
for (/**/; iter != iter_end; ++iter)
for (const auto& w_ch : iso8601duration)
{
if (rtl::isAsciiDigit(*iter)) // wchar_t is unsigned under MSVC
if (rtl::isAsciiDigit(w_ch)) // wchar_t is unsigned under MSVC
{
num += *iter;
num += w_ch;
}
else
{
if (*iter == L'D' || *iter == L'd')
if (w_ch == L'D' || w_ch == L'd')
days = num;
else if (*iter == L'H' || *iter == L'h')
else if (w_ch == L'H' || w_ch == L'h')
hours = num;
else if (*iter == L'M' || *iter == L'm')
else if (w_ch == L'M' || w_ch == L'm')
minutes = num;
else if (*iter == L'S' || *iter == L's')
else if (w_ch == L'S' || w_ch == L's')
seconds = num;
num.clear();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment