diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2019-06-15 17:13:48 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-06-18 09:43:08 +0200 |
commit | 452a8e4abe0c416d664078baddff67c1561025ec (patch) | |
tree | 037f973aebd5e740d97525ff7aa852515762ae0b /vcl/qa/cppunit | |
parent | e1eb7cb04a4c30cec238ab0f54d41a6cdc3299c1 (diff) |
Simplify Sequence iterations in vcl
Use range-based loops or replace with comphelper or STL functions
Change-Id: If046738084c2d13cc1eaea6a03aaf60b63f62767
Reviewed-on: https://gerrit.libreoffice.org/74104
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/qa/cppunit')
-rw-r--r-- | vcl/qa/cppunit/canvasbitmaptest.cxx | 46 |
1 files changed, 19 insertions, 27 deletions
diff --git a/vcl/qa/cppunit/canvasbitmaptest.cxx b/vcl/qa/cppunit/canvasbitmaptest.cxx index 070b8b6217a4..cf7a82c653ad 100644 --- a/vcl/qa/cppunit/canvasbitmaptest.cxx +++ b/vcl/qa/cppunit/canvasbitmaptest.cxx @@ -482,15 +482,13 @@ private: virtual uno::Sequence< rendering::RGBColor > SAL_CALL convertIntegerToRGB( const uno::Sequence< ::sal_Int8 >& deviceColor ) override { const uno::Sequence< rendering::ARGBColor > aTemp( convertIntegerToARGB(deviceColor) ); - const std::size_t nLen(aTemp.getLength()); - uno::Sequence< rendering::RGBColor > aRes( nLen ); - rendering::RGBColor* pOut = aRes.getArray(); - for( std::size_t i=0; i<nLen; ++i ) - { - *pOut++ = rendering::RGBColor(aTemp[i].Red, - aTemp[i].Green, - aTemp[i].Blue); - } + uno::Sequence< rendering::RGBColor > aRes( aTemp.getLength() ); + std::transform(aTemp.begin(), aTemp.end(), aRes.begin(), + [](const rendering::ARGBColor& rColor) { + return rendering::RGBColor(rColor.Red, + rColor.Green, + rColor.Blue); + }); return aRes; } @@ -503,21 +501,18 @@ private: 0, static_cast<int>(nLen%nBytesPerPixel)); uno::Sequence< rendering::ARGBColor > aRes( nLen / nBytesPerPixel ); - rendering::ARGBColor* pOut( aRes.getArray() ); if( getPalette().is() ) { - for( std::size_t i=0; i<nLen; ++i ) - { - *pOut++ = rendering::ARGBColor( - 1.0, - vcl::unotools::toDoubleColor(deviceColor[i]), - vcl::unotools::toDoubleColor(deviceColor[i]), - vcl::unotools::toDoubleColor(deviceColor[i])); - } + std::transform(deviceColor.begin(), deviceColor.end(), aRes.begin(), + [](sal_Int8 nIn) { + auto fColor = vcl::unotools::toDoubleColor(nIn); + return rendering::ARGBColor(1.0, fColor, fColor, fColor); + }); } else { + rendering::ARGBColor* pOut( aRes.getArray() ); for( std::size_t i=0; i<nLen; i+=4 ) { *pOut++ = rendering::ARGBColor( @@ -540,21 +535,18 @@ private: 0, static_cast<int>(nLen%nBytesPerPixel)); uno::Sequence< rendering::ARGBColor > aRes( nLen / nBytesPerPixel ); - rendering::ARGBColor* pOut( aRes.getArray() ); if( getPalette().is() ) { - for( std::size_t i=0; i<nLen; ++i ) - { - *pOut++ = rendering::ARGBColor( - 1.0, - vcl::unotools::toDoubleColor(deviceColor[i]), - vcl::unotools::toDoubleColor(deviceColor[i]), - vcl::unotools::toDoubleColor(deviceColor[i])); - } + std::transform(deviceColor.begin(), deviceColor.end(), aRes.begin(), + [](sal_Int8 nIn) { + auto fColor = vcl::unotools::toDoubleColor(nIn); + return rendering::ARGBColor(1.0, fColor, fColor, fColor); + }); } else { + rendering::ARGBColor* pOut( aRes.getArray() ); for( std::size_t i=0; i<nLen; i+=4 ) { const double fAlpha=vcl::unotools::toDoubleColor(deviceColor[i+3]); |