summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2017-11-24 19:55:24 +0100
committerJulien Nabet <serval2412@yahoo.fr>2017-11-25 09:19:15 +0100
commitb50b099d5a23a0306723c02b30bec056e59702c6 (patch)
treeb6425e26f3c956092330d1bae74de52608b0a091 /vcl
parent60fc08111d6453ca79603b4c5c85be05e45c35e7 (diff)
Modernize pdfwriter_impl, part 2 (vcl)
by using for range loops + find_if instead of loops Change-Id: Ide439a683e6b3c406811fe135a7651e26395cf1e Reviewed-on: https://gerrit.libreoffice.org/45257 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx38
1 files changed, 13 insertions, 25 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index e6ad03b44940..34161b7ca35a 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -9786,9 +9786,8 @@ void PDFWriterImpl::drawJPGBitmap( SvStream& rDCTData, bool bIsTrueColor, const
if( ! rMask.IsEmpty() )
aID.m_nMaskChecksum = rMask.GetChecksum();
- std::vector< JPGEmit >::const_iterator it;
- for( it = m_aJPGs.begin(); it != m_aJPGs.end() && ! (aID == it->m_aID); ++it )
- ;
+ std::vector< JPGEmit >::const_iterator it = std::find_if(m_aJPGs.begin(), m_aJPGs.end(),
+ [&](const JPGEmit& arg) { return aID == arg.m_aID; });
if( it == m_aJPGs.end() )
{
m_aJPGs.emplace( m_aJPGs.begin() );
@@ -9894,12 +9893,8 @@ const PDFWriterImpl::BitmapEmit& PDFWriterImpl::createBitmapEmit( const BitmapEx
if( ! aMask.IsEmpty() )
aID.m_nMaskChecksum = aMask.GetChecksum();
}
- std::list< BitmapEmit >::const_iterator it;
- for( it = m_aBitmaps.begin(); it != m_aBitmaps.end(); ++it )
- {
- if( aID == it->m_aID )
- break;
- }
+ std::list< BitmapEmit >::const_iterator it = std::find_if(m_aBitmaps.begin(), m_aBitmaps.end(),
+ [&](const BitmapEmit& arg) { return aID == arg.m_aID; });
if( it == m_aBitmaps.end() )
{
m_aBitmaps.push_front( BitmapEmit() );
@@ -9951,19 +9946,13 @@ sal_Int32 PDFWriterImpl::createGradient( const Gradient& rGradient, const Size&
getReferenceDevice(),
rSize ) );
// check if we already have this gradient
- std::list<GradientEmit>::iterator it;
// rounding to point will generally lose some pixels
// round up to point boundary
aPtSize.Width()++;
aPtSize.Height()++;
- for( it = m_aGradients.begin(); it != m_aGradients.end(); ++it )
- {
- if( it->m_aGradient == rGradient )
- {
- if( it->m_aSize == aPtSize )
- break;
- }
- }
+ std::list< GradientEmit >::const_iterator it = std::find_if(m_aGradients.begin(), m_aGradients.end(),
+ [&](const GradientEmit& arg) { return ((rGradient == arg.m_aGradient) && (aPtSize == arg.m_aSize) ); });
+
if( it == m_aGradients.end() )
{
m_aGradients.push_front( GradientEmit() );
@@ -11438,11 +11427,9 @@ void PDFWriterImpl::ensureUniqueRadioOnValues()
PDFWidget& rGroupWidget = m_aWidgets[ group.second ];
// check whether all kids have a unique OnValue
std::unordered_map< OUString, sal_Int32 > aOnValues;
- int nChildren = rGroupWidget.m_aKidsIndex.size();
bool bIsUnique = true;
- for( int nKid = 0; nKid < nChildren && bIsUnique; nKid++ )
+ for (auto const& nKidIndex : rGroupWidget.m_aKidsIndex)
{
- int nKidIndex = rGroupWidget.m_aKidsIndex[nKid];
const OUString& rVal = m_aWidgets[nKidIndex].m_aOnValue;
SAL_INFO("vcl.pdfwriter", "OnValue: " << rVal);
if( aOnValues.find( rVal ) == aOnValues.end() )
@@ -11452,25 +11439,26 @@ void PDFWriterImpl::ensureUniqueRadioOnValues()
else
{
bIsUnique = false;
+ break;
}
}
if( ! bIsUnique )
{
SAL_INFO("vcl.pdfwriter", "enforcing unique OnValues" );
// make unique by using ascending OnValues
- for( int nKid = 0; nKid < nChildren; nKid++ )
+ int nKid = 0;
+ for (auto const& nKidIndex : rGroupWidget.m_aKidsIndex)
{
- int nKidIndex = rGroupWidget.m_aKidsIndex[nKid];
PDFWidget& rKid = m_aWidgets[nKidIndex];
rKid.m_aOnValue = OUString::number( nKid+1 );
if( rKid.m_aValue != "Off" )
rKid.m_aValue = rKid.m_aOnValue;
+ ++nKid;
}
}
// finally move the "Yes" appearance to the OnValue appearance
- for( int nKid = 0; nKid < nChildren; nKid++ )
+ for (auto const& nKidIndex : rGroupWidget.m_aKidsIndex)
{
- int nKidIndex = rGroupWidget.m_aKidsIndex[nKid];
PDFWidget& rKid = m_aWidgets[nKidIndex];
PDFAppearanceMap::iterator app_it = rKid.m_aAppearances.find( "N" );
if( app_it != rKid.m_aAppearances.end() )