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

Simplify containers iterations in oox, opencl, package

Use range-based loop or replace with STL functions

Change-Id: I91405920d91383bc6cf13b9497d262b1f6f0a84d
Reviewed-on: https://gerrit.libreoffice.org/67848
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 177747c4
......@@ -66,10 +66,10 @@ sal_Int32 ContextHandler2Helper::getCurrentElementWithMce() const
sal_Int32 ContextHandler2Helper::getCurrentElement() const
{
for ( ContextStack::reverse_iterator It = mxContextStack->rbegin();
It != mxContextStack->rend(); ++It )
if( getNamespace( It->mnElement ) != NMSP_mce )
return It->mnElement;
auto It = std::find_if(mxContextStack->rbegin(), mxContextStack->rend(),
[](const ElementInfo& rItem) { return getNamespace(rItem.mnElement) != NMSP_mce; });
if (It != mxContextStack->rend())
return It->mnElement;
return XML_ROOT_CONTEXT;
}
......
......@@ -782,30 +782,31 @@ writeCustomProperties( XmlFilterBase& rSelf, const Reference< XDocumentPropertie
FSNS( XML_xmlns, XML_vt ), OUStringToOString(rSelf.getNamespaceURL(OOX_NS(officeDocPropsVT)), RTL_TEXTENCODING_UTF8).getStr(),
FSEND );
for (auto aIt = aprop.begin(); aIt != aprop.end(); ++aIt)
size_t nIndex = 0;
for (const auto& rProp : aprop)
{
if ( !aIt->Name.isEmpty() )
if ( !rProp.Name.isEmpty() )
{
OString aName = OUStringToOString( aIt->Name, RTL_TEXTENCODING_ASCII_US );
OString aName = OUStringToOString( rProp.Name, RTL_TEXTENCODING_ASCII_US );
// pid starts from 2 not from 1 as MS supports pid from 2
pAppProps->startElement( XML_property ,
XML_fmtid, "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
XML_pid, OString::number((aIt - aprop.begin()) + 2),
XML_pid, OString::number(nIndex + 2),
XML_name, aName,
FSEND);
switch ( aIt->Value.getValueTypeClass() )
switch ( rProp.Value.getValueTypeClass() )
{
case TypeClass_STRING:
{
OUString aValue;
aIt->Value >>= aValue;
rProp.Value >>= aValue;
writeElement( pAppProps, FSNS( XML_vt, XML_lpwstr ), aValue );
}
break;
case TypeClass_BOOLEAN:
{
bool val = *o3tl::forceAccess<bool>(aIt->Value);
bool val = *o3tl::forceAccess<bool>(rProp.Value);
writeElement( pAppProps, FSNS( XML_vt, XML_bool ), val ? 1 : 0);
}
break;
......@@ -815,23 +816,23 @@ writeCustomProperties( XmlFilterBase& rSelf, const Reference< XDocumentPropertie
util::Date aDate;
util::Duration aDuration;
util::DateTime aDateTime;
if ( ( aIt->Value ) >>= num )
if ( rProp.Value >>= num )
{
writeElement( pAppProps, FSNS( XML_vt, XML_i4 ), num );
}
else if ( ( aIt->Value ) >>= aDate )
else if ( rProp.Value >>= aDate )
{
aDateTime = util::DateTime( 0, 0 , 0, 0, aDate.Year, aDate.Month, aDate.Day, true );
writeElement( pAppProps, FSNS( XML_vt, XML_filetime ), aDateTime);
}
else if ( ( aIt->Value ) >>= aDuration )
else if ( rProp.Value >>= aDuration )
{
OUStringBuffer buf;
::sax::Converter::convertDuration( buf, aDuration );
OUString aDurationStr = buf.makeStringAndClear();
writeElement( pAppProps, FSNS( XML_vt, XML_lpwstr ), aDurationStr );
}
else if ( ( aIt->Value ) >>= aDateTime )
else if ( rProp.Value >>= aDateTime )
writeElement( pAppProps, FSNS( XML_vt, XML_filetime ), aDateTime );
else
//no other options
......@@ -841,6 +842,7 @@ writeCustomProperties( XmlFilterBase& rSelf, const Reference< XDocumentPropertie
}
pAppProps->endElement( XML_property );
}
++nIndex;
}
pAppProps->endElement( XML_Properties );
}
......
......@@ -371,7 +371,7 @@ void TypeGroupConverter::convertFromModel( const Reference< XDiagram >& rxDiagra
::std::vector< Reference< XLabeledDataSequence > > aLabeledSeqVec;
OSL_ENSURE( aSeries.size() >= 3, "TypeGroupConverter::convertFromModel - too few stock chart series" );
int nRoleIdx = (aSeries.size() == 3) ? 1 : 0;
for( SeriesConvVector::iterator aIt = aSeries.begin(), aEnd = aSeries.end(); (nRoleIdx < 4) && (aIt != aEnd); ++nRoleIdx, ++aIt )
for( auto& rxSeriesConv : aSeries )
{
// create a data sequence with a specific role
OUString aRole;
......@@ -382,9 +382,13 @@ void TypeGroupConverter::convertFromModel( const Reference< XDiagram >& rxDiagra
case 2: aRole = "values-min"; break;
case 3: aRole = "values-last"; break;
}
Reference< XLabeledDataSequence > xDataSeq = (*aIt)->createValueSequence( aRole );
Reference< XLabeledDataSequence > xDataSeq = rxSeriesConv->createValueSequence( aRole );
if( xDataSeq.is() )
aLabeledSeqVec.push_back( xDataSeq );
++nRoleIdx;
if (nRoleIdx >= 4)
break;
}
// attach labeled data sequences to series and insert series into chart type
......
......@@ -150,10 +150,8 @@ void calculateHierChildOffsetScale(const oox::drawingml::ShapePtr& pShape,
{
const oox::drawingml::ShapePtr& pParentShape = rParents[nParent];
const std::vector<oox::drawingml::ShapePtr>& rChildren = pParentShape->getChildren();
auto it = std::find_if(
rChildren.begin(), rChildren.end(),
[pShape](const oox::drawingml::ShapePtr& pChild) { return pChild == pShape; });
if (it == rChildren.end())
if (std::none_of(rChildren.begin(), rChildren.end(),
[pShape](const oox::drawingml::ShapePtr& pChild) { return pChild == pShape; }))
// This is not our parent.
continue;
......@@ -1152,23 +1150,20 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, const dgm::Point* pPresNode
pPresNode->msModelId);
if( aNodeName != mrDgm.getData()->getPresOfNameMap().end() )
{
DiagramData::StringMap::value_type::second_type::const_iterator aVecIter=aNodeName->second.begin();
const DiagramData::StringMap::value_type::second_type::const_iterator aVecEnd=aNodeName->second.end();
while( aVecIter != aVecEnd )
for( const auto& rItem : aNodeName->second )
{
DiagramData::PointNameMap& rMap = mrDgm.getData()->getPointNameMap();
// pPresNode is the presentation node of the aDataNode2 data node.
DiagramData::PointNameMap::const_iterator aDataNode2 = rMap.find(aVecIter->first);
DiagramData::PointNameMap::const_iterator aDataNode2 = rMap.find(rItem.first);
if (aDataNode2 == rMap.end())
{
//busted, skip it
++aVecIter;
continue;
}
rShape->setDataNodeType(aDataNode2->second->mnType);
if( aVecIter->second == 0 )
if( rItem.second == 0 )
{
// grab shape attr from topmost element(s)
rShape->getShapeProperties() = aDataNode2->second->mpShape->getShapeProperties();
......@@ -1210,8 +1205,8 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, const dgm::Point* pPresNode
for (const auto& pSourceParagraph : rSourceParagraphs)
{
TextParagraph& rPara = pTextBody->addParagraph();
if (aVecIter->second != -1)
rPara.getProperties().setLevel(aVecIter->second);
if (rItem.second != -1)
rPara.getProperties().setLevel(rItem.second);
for (const auto& pRun : pSourceParagraph->getRuns())
rPara.addRun(pRun);
......@@ -1219,8 +1214,6 @@ bool LayoutNode::setupShape( const ShapePtr& rShape, const dgm::Point* pPresNode
rPara.getProperties().apply(rBody->getParagraphs().front()->getProperties());
}
}
++aVecIter;
}
}
else
......
......@@ -1190,35 +1190,35 @@ Reference< XShape > const & Shape::createAndInsert(
if( aShapeProps.hasProperty( PROP_FillGradient ) )
{
std::vector<beans::PropertyValue> aGradientStops;
auto aIt = aFillProperties.maGradientProps.maGradientStops.begin();
for( size_t i = 0; i < aFillProperties.maGradientProps.maGradientStops.size(); ++i )
size_t i = 0;
for( const auto& [rPos, rColor] : aFillProperties.maGradientProps.maGradientStops )
{ // for each stop in the gradient definition:
// save position
std::vector<beans::PropertyValue> aGradientStop;
aGradientStop.push_back(comphelper::makePropertyValue("Pos", aIt->first));
aGradientStop.push_back(comphelper::makePropertyValue("Pos", rPos));
OUString sStopColorScheme = aIt->second.getSchemeName();
OUString sStopColorScheme = rColor.getSchemeName();
if( sStopColorScheme.isEmpty() )
{
// save RGB color
aGradientStop.push_back(comphelper::makePropertyValue("RgbClr", aIt->second.getColor(rGraphicHelper, nFillPhClr)));
aGradientStop.push_back(comphelper::makePropertyValue("RgbClr", rColor.getColor(rGraphicHelper, nFillPhClr)));
// in the case of a RGB color, transformations are already applied to
// the color with the exception of alpha transformations. We only need
// to keep the transparency value to calculate the alpha value later.
if( aIt->second.hasTransparency() )
aGradientStop.push_back(comphelper::makePropertyValue("Transparency", aIt->second.getTransparency()));
if( rColor.hasTransparency() )
aGradientStop.push_back(comphelper::makePropertyValue("Transparency", rColor.getTransparency()));
}
else
{
// save color with scheme name
aGradientStop.push_back(comphelper::makePropertyValue("SchemeClr", sStopColorScheme));
// save all color transformations
aGradientStop.push_back(comphelper::makePropertyValue("Transformations", aIt->second.getTransformations()));
aGradientStop.push_back(comphelper::makePropertyValue("Transformations", rColor.getTransformations()));
}
aGradientStops.push_back(comphelper::makePropertyValue(OUString::number(i), comphelper::containerToSequence(aGradientStop)));
++aIt;
++i;
}
// If getFillProperties.moFillType is unused that means gradient is defined by a theme
// which is already saved into StyleFillRef property, so no need to save the explicit values too
......
......@@ -450,21 +450,23 @@ void VbaFormControl::importStorage( StorageBase& rStrg, const AxClassTable& rCla
}
}
// apply caption/titles to pages
auto itCtrlId = pMultiPage->mnIDs.begin();
auto itCtrlId_end = pMultiPage->mnIDs.end();
AxArrayString::iterator itCaption = sCaptions.begin();
maControls.clear();
// need to sort the controls according to the order of the ids
for ( sal_Int32 index = 1 ; ( sCaptions.size() == idToPage.size() ) && itCtrlId != itCtrlId_end; ++itCtrlId, ++itCaption, ++index )
if ( sCaptions.size() == idToPage.size() )
{
IdToPageMap::iterator iter = idToPage.find( *itCtrlId );
if ( iter != idToPage.end() )
AxArrayString::iterator itCaption = sCaptions.begin();
for ( const auto& rCtrlId : pMultiPage->mnIDs )
{
AxPageModel* pPage = static_cast<AxPageModel*> ( iter->second->mxCtrlModel.get() );
pPage->importProperty( XML_Caption, *itCaption );
maControls.push_back( iter->second );
IdToPageMap::iterator iter = idToPage.find( rCtrlId );
if ( iter != idToPage.end() )
{
AxPageModel* pPage = static_cast<AxPageModel*> ( iter->second->mxCtrlModel.get() );
pPage->importProperty( XML_Caption, *itCaption );
maControls.push_back( iter->second );
}
++itCaption;
}
}
}
......
......@@ -58,14 +58,14 @@ css::uno::Sequence<OUString> SetOfImplMatcherToStringSequence(const OpenCLConfig
css::uno::Sequence<OUString> result(rSet.size());
size_t n(0);
for (auto i = rSet.cbegin(); i != rSet.cend(); ++i)
for (const auto& rItem : rSet)
{
result[n++] =
(*i).maOS.replaceAll("%", "%25").replaceAll("/", "%2F").replaceAll(";", "%3B") + "/" +
(*i).maOSVersion.replaceAll("%", "%25").replaceAll("/", "%2F").replaceAll(";", "%3B") + "/" +
(*i).maPlatformVendor.replaceAll("%", "%25").replaceAll("/", "%2F").replaceAll(";", "%3B") + "/" +
(*i).maDevice.replaceAll("%", "%25").replaceAll("/", "%2F").replaceAll(";", "%3B") + "/" +
(*i).maDriverVersion.replaceAll("%", "%25").replaceAll("/", "%2F").replaceAll(";", "%3B");
rItem.maOS.replaceAll("%", "%25").replaceAll("/", "%2F").replaceAll(";", "%3B") + "/" +
rItem.maOSVersion.replaceAll("%", "%25").replaceAll("/", "%2F").replaceAll(";", "%3B") + "/" +
rItem.maPlatformVendor.replaceAll("%", "%25").replaceAll("/", "%2F").replaceAll(";", "%3B") + "/" +
rItem.maDevice.replaceAll("%", "%25").replaceAll("/", "%2F").replaceAll(";", "%3B") + "/" +
rItem.maDriverVersion.replaceAll("%", "%25").replaceAll("/", "%2F").replaceAll(";", "%3B");
}
return result;
......@@ -100,15 +100,15 @@ OpenCLConfig::ImplMatcherSet StringSequenceToSetOfImplMatcher(const css::uno::Se
{
OpenCLConfig::ImplMatcherSet result;
for (auto i = rSequence.begin(); i != rSequence.end(); ++i)
for (const auto& rItem : rSequence)
{
OpenCLConfig::ImplMatcher m;
sal_Int32 index(0);
m.maOS = getToken(*i, index);
m.maOSVersion = getToken(*i, index);
m.maPlatformVendor = getToken(*i, index);
m.maDevice = getToken(*i, index);
m.maDriverVersion = getToken(*i, index);
m.maOS = getToken(rItem, index);
m.maOSVersion = getToken(rItem, index);
m.maPlatformVendor = getToken(rItem, index);
m.maDevice = getToken(rItem, index);
m.maDriverVersion = getToken(rItem, index);
result.insert(m);
}
......@@ -158,12 +158,12 @@ bool match(const OpenCLConfig::ImplMatcher& rListEntry, const OpenCLPlatformInfo
bool match(const OpenCLConfig::ImplMatcherSet& rList, const OpenCLPlatformInfo& rPlatform, const OpenCLDeviceInfo& rDevice, const char* sKindOfList)
{
for (auto i = rList.cbegin(); i != rList.end(); ++i)
for (const auto& rListEntry : rList)
{
SAL_INFO("opencl", "Looking for match for platform=" << rPlatform << ", device=" << rDevice <<
" in " << sKindOfList << " entry=" << *i);
" in " << sKindOfList << " entry=" << rListEntry);
if (match(*i, rPlatform, rDevice))
if (match(rListEntry, rPlatform, rDevice))
{
SAL_INFO("opencl", "Match!");
return true;
......
......@@ -264,18 +264,10 @@ void SAL_CALL OHierarchyElement_Impl::disposing( const lang::EventObject& Source
::osl::ClearableMutexGuard aGuard( m_aMutex );
uno::Reference< embed::XExtendedStorageStream > xStream( Source.Source, uno::UNO_QUERY );
for ( OWeakStorRefList_Impl::iterator pStorageIter = m_aOpenStreams.begin();
pStorageIter != m_aOpenStreams.end(); )
{
if ( !pStorageIter->get().is() || pStorageIter->get() == xStream )
{
pStorageIter = m_aOpenStreams.erase(pStorageIter);
}
else
{
++pStorageIter;
}
}
m_aOpenStreams.erase(std::remove_if(m_aOpenStreams.begin(), m_aOpenStreams.end(),
[&xStream](const OWeakStorRefList_Impl::value_type& rxStorage) {
return !rxStorage.get().is() || rxStorage.get() == xStream; }),
m_aOpenStreams.end());
aGuard.clear();
......
......@@ -481,13 +481,12 @@ void OWriteStream_Impl::DisposeWrappers()
if ( !m_aInputStreamsVector.empty() )
{
for ( InputStreamsVector_Impl::iterator pStreamIter = m_aInputStreamsVector.begin();
pStreamIter != m_aInputStreamsVector.end(); ++pStreamIter )
for ( auto& pStream : m_aInputStreamsVector )
{
if ( *pStreamIter )
if ( pStream )
{
(*pStreamIter)->InternalDispose();
(*pStreamIter) = nullptr;
pStream->InternalDispose();
pStream = nullptr;
}
}
......
......@@ -1086,18 +1086,18 @@ void ZipFile::recover()
nCompressedSize = nCompressedSize32;
nSize = nSize32;
for( EntryHash::iterator aIter = aEntries.begin(); aIter != aEntries.end(); ++aIter )
for( auto& rEntry : aEntries )
{
ZipEntry aTmp = (*aIter).second;
ZipEntry aTmp = rEntry.second;
// this is a broken package, accept this block not only for DEFLATED streams
if( (*aIter).second.nFlag & 8 )
if( rEntry.second.nFlag & 8 )
{
sal_Int64 nStreamOffset = nGenPos + nPos - nCompressedSize;
if ( nStreamOffset == (*aIter).second.nOffset && nCompressedSize > (*aIter).second.nCompressedSize )
if ( nStreamOffset == rEntry.second.nOffset && nCompressedSize > rEntry.second.nCompressedSize )
{
// only DEFLATED blocks need to be checked
bool bAcceptBlock = ( (*aIter).second.nMethod == STORED && nCompressedSize == nSize );
bool bAcceptBlock = ( rEntry.second.nMethod == STORED && nCompressedSize == nSize );
if ( !bAcceptBlock )
{
......@@ -1109,19 +1109,19 @@ void ZipFile::recover()
if ( bAcceptBlock )
{
(*aIter).second.nCrc = nCRC32;
(*aIter).second.nCompressedSize = nCompressedSize;
(*aIter).second.nSize = nSize;
rEntry.second.nCrc = nCRC32;
rEntry.second.nCompressedSize = nCompressedSize;
rEntry.second.nSize = nSize;
}
}
#if 0
// for now ignore clearly broken streams
else if( !(*aIter).second.nCompressedSize )
else if( !rEntry.second.nCompressedSize )
{
(*aIter).second.nCrc = nCRC32;
sal_Int32 nRealStreamSize = nGenPos + nPos - (*aIter).second.nOffset;
(*aIter).second.nCompressedSize = nGenPos + nPos - (*aIter).second.nOffset;
(*aIter).second.nSize = nSize;
rEntry.second.nCrc = nCRC32;
sal_Int32 nRealStreamSize = nGenPos + nPos - rEntry.second.nOffset;
rEntry.second.nCompressedSize = nRealStreamSize;
rEntry.second.nSize = nSize;
}
#endif
}
......
......@@ -1103,20 +1103,17 @@ void ZipPackage::WriteContentTypes( ZipOutputStream& aZipOut, const vector< uno:
uno::Sequence< beans::StringPair > aOverridesSequence(aManList.size());
sal_Int32 nOverSeqLength = 0;
for ( vector< uno::Sequence< beans::PropertyValue > >::const_iterator aIter = aManList.begin(),
aEnd = aManList.end();
aIter != aEnd;
++aIter)
for (const auto& rMan : aManList)
{
OUString aPath;
OUString aType;
OSL_ENSURE( ( *aIter )[PKG_MNFST_MEDIATYPE].Name == "MediaType" && ( *aIter )[PKG_MNFST_FULLPATH].Name == "FullPath",
OSL_ENSURE( rMan[PKG_MNFST_MEDIATYPE].Name == "MediaType" && rMan[PKG_MNFST_FULLPATH].Name == "FullPath",
"The mediatype sequence format is wrong!" );
( *aIter )[PKG_MNFST_MEDIATYPE].Value >>= aType;
rMan[PKG_MNFST_MEDIATYPE].Value >>= aType;
if ( !aType.isEmpty() )
{
// only nonempty type makes sense here
( *aIter )[PKG_MNFST_FULLPATH].Value >>= aPath;
rMan[PKG_MNFST_FULLPATH].Value >>= aPath;
//FIXME: For now we have no way of differentiating defaults from others.
aOverridesSequence[nOverSeqLength].First = "/" + aPath;
aOverridesSequence[nOverSeqLength].Second = aType;
......
......@@ -27,6 +27,7 @@
#include "ZipPackageFolderEnumeration.hxx"
#include <com/sun/star/packages/zip/ZipConstants.hpp>
#include <com/sun/star/embed/StorageFormats.hpp>
#include <comphelper/sequence.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/typeprovider.hxx>
#include <osl/diagnose.h>
......@@ -81,12 +82,9 @@ bool ZipPackageFolder::LookForUnexpectedODF12Streams( const OUString& aPath )
{
bool bHasUnexpected = false;
for ( ContentHash::const_iterator aCI = maContents.begin(), aEnd = maContents.end();
!bHasUnexpected && aCI != aEnd;
++aCI)
for (const auto& [rShortName, rxInfo] : maContents)
{
const OUString &rShortName = (*aCI).first;
const ZipContentInfo &rInfo = *(*aCI).second;
const ZipContentInfo &rInfo = *rxInfo;
if ( rInfo.bFolder )
{
......@@ -125,6 +123,9 @@ bool ZipPackageFolder::LookForUnexpectedODF12Streams( const OUString& aPath )
}
}
}
if (bHasUnexpected)
break;
}
return bHasUnexpected;
......@@ -138,12 +139,9 @@ void ZipPackageFolder::setChildStreamsTypeByExtension( const beans::StringPair&
else
aExt = "." + aPair.First;
for ( ContentHash::const_iterator aCI = maContents.begin(), aEnd = maContents.end();
aCI != aEnd;
++aCI)
for (const auto& [rShortName, rxInfo] : maContents)
{
const OUString &rShortName = (*aCI).first;
const ZipContentInfo &rInfo = *(*aCI).second;
const ZipContentInfo &rInfo = *rxInfo;
if ( rInfo.bFolder )
rInfo.pFolder->setChildStreamsTypeByExtension( aPair );
......@@ -229,13 +227,7 @@ uno::Any SAL_CALL ZipPackageFolder::getByName( const OUString& aName )
}
uno::Sequence< OUString > SAL_CALL ZipPackageFolder::getElementNames( )
{
sal_uInt32 i=0, nSize = maContents.size();
uno::Sequence < OUString > aSequence ( nSize );
for ( ContentHash::const_iterator aIterator = maContents.begin(), aEnd = maContents.end();
aIterator != aEnd;
++i, ++aIterator)
aSequence[i] = (*aIterator).first;
return aSequence;
return comphelper::mapKeysToSequence(maContents);
}
sal_Bool SAL_CALL ZipPackageFolder::hasByName( const OUString& aName )
{
......@@ -335,12 +327,9 @@ void ZipPackageFolder::saveContents(
}
}
for ( ContentHash::const_iterator aCI = maContents.begin(), aEnd = maContents.end();
aCI != aEnd;
++aCI)
for (const auto& [rShortName, rxInfo] : maContents)
{
const OUString &rShortName = (*aCI).first;
const ZipContentInfo &rInfo = *(*aCI).second;
const ZipContentInfo &rInfo = *rxInfo;
if ( !bMimeTypeStreamStored || rShortName != aMimeTypeStreamName )
{
......
......@@ -309,7 +309,7 @@ uno::Sequence< OUString > SAL_CALL OZipFileAccess::getElementNames()
uno::Sequence< OUString > aNames( m_pZipFile->GetEntryHash().size() );
sal_Int32 nLen = 0;
for ( EntryHash::iterator aIter = m_pZipFile->GetEntryHash().begin(); aIter != m_pZipFile->GetEntryHash().end(); ++aIter )
for ( const auto& rEntry : m_pZipFile->GetEntryHash() )
{
if ( aNames.getLength() < ++nLen )
{
......@@ -317,7 +317,7 @@ uno::Sequence< OUString > SAL_CALL OZipFileAccess::getElementNames()
aNames.realloc( nLen );
}
aNames[nLen-1] = (*aIter).second.sPath;
aNames[nLen-1] = rEntry.second.sPath;
}
if ( aNames.getLength() != nLen )
......@@ -384,19 +384,18 @@ uno::Reference< io::XInputStream > SAL_CALL OZipFileAccess::getStreamByPattern(
// Code to compare strings by patterns
uno::Sequence< OUString > aPattern = GetPatternsFromString_Impl( aPatternString );
for ( EntryHash::iterator aIter = m_pZipFile->GetEntryHash().begin(); aIter != m_pZipFile->GetEntryHash().end(); ++aIter )
auto aIter = std::find_if(m_pZipFile->GetEntryHash().begin(), m_pZipFile->GetEntryHash().end(),
[&aPattern](const EntryHash::value_type& rEntry) { return StringGoodForPattern_Impl(rEntry.second.sPath, aPattern); });
if (aIter != m_pZipFile->GetEntryHash().end())
{
if ( StringGoodForPattern_Impl( (*aIter).second.sPath, aPattern ) )
{
uno::Reference< io::XInputStream > xEntryStream( m_pZipFile->getDataStream( (*aIter).second,
::rtl::Reference< EncryptionData >(),
false,
m_aMutexHolder ) );
if ( !xEntryStream.is() )
throw uno::RuntimeException(THROW_WHERE );
return xEntryStream;
}
uno::Reference< io::XInputStream > xEntryStream( m_pZipFile->getDataStream( (*aIter).second,
::rtl::Reference< EncryptionData >(),
false,
m_aMutexHolder ) );
if ( !xEntryStream.is() )
throw uno::RuntimeException(THROW_WHERE );
return xEntryStream;
}
throw container::NoSuchElementException(THROW_WHERE );
......
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