summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-02-20 21:18:04 +0000
committerMichael Stahl <Michael.Stahl@cib.de>2019-08-27 14:12:24 +0200
commitaa79414d7106bf5198ab47274ba2e0dae870e0aa (patch)
treefb29f1f452904eff05d37de66353157c2ca9efad
parent27f29dd3622f5d4be4f2a95add651fb9f3098176 (diff)
forcepoint #4
Thanks to Antti Levomäki and Christian Jalio from Forcepoint. Change-Id: I569ca80267ad9b5a21da0029ba903d2a4c45a035 Reviewed-on: https://gerrit.libreoffice.org/50086 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--vcl/source/gdi/pdfwriter_impl2.cxx27
1 files changed, 21 insertions, 6 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx
index 9f6274660c45..8cf9746e4dee 100644
--- a/vcl/source/gdi/pdfwriter_impl2.cxx
+++ b/vcl/source/gdi/pdfwriter_impl2.cxx
@@ -1625,11 +1625,8 @@ inline bool isSet( const Scanline i_pLine, long i_nIndex )
return (i_pLine[ i_nIndex/8 ] & (0x80 >> (i_nIndex&7))) != 0;
}
-long findBitRun( const Scanline i_pLine, long i_nStartIndex, long i_nW, bool i_bSet )
+long findBitRunImpl( const Scanline i_pLine, long i_nStartIndex, long i_nW, bool i_bSet )
{
- if( i_nStartIndex < 0 )
- return i_nW;
-
long nIndex = i_nStartIndex;
if( nIndex < i_nW )
{
@@ -1691,6 +1688,24 @@ long findBitRun( const Scanline i_pLine, long i_nStartIndex, long i_nW, bool i_b
return nIndex < i_nW ? nIndex : i_nW;
}
+long findBitRun(const Scanline i_pLine, long i_nStartIndex, long i_nW, bool i_bSet)
+{
+ if (i_nStartIndex < 0)
+ return i_nW;
+
+ return findBitRunImpl(i_pLine, i_nStartIndex, i_nW, i_bSet);
+}
+
+long findBitRun(const Scanline i_pLine, long i_nStartIndex, long i_nW)
+{
+ if (i_nStartIndex < 0)
+ return i_nW;
+
+ const bool bSet = i_nStartIndex < i_nW && isSet(i_pLine, i_nStartIndex);
+
+ return findBitRunImpl(i_pLine, i_nStartIndex, i_nW, bSet);
+}
+
struct BitStreamState
{
sal_uInt8 mnBuffer;
@@ -1994,7 +2009,7 @@ void PDFWriterImpl::writeG4Stream( BitmapReadAccess* i_pBitmap )
long nRefIndex1 = bRefSet ? 0 : findBitRun( pRefLine, 0, nW, bRefSet );
for( ; nLineIndex < nW; )
{
- long nRefIndex2 = findBitRun( pRefLine, nRefIndex1, nW, isSet( pRefLine, nRefIndex1 ) );
+ long nRefIndex2 = findBitRun( pRefLine, nRefIndex1, nW );
if( nRefIndex2 >= nRunIndex1 )
{
long nDiff = nRefIndex1 - nRunIndex1;
@@ -2024,7 +2039,7 @@ void PDFWriterImpl::writeG4Stream( BitmapReadAccess* i_pBitmap )
{ // difference too large, horizontal coding
// emit horz code 001
putG4Bits( 3, 0x1, aBitState );
- long nRunIndex2 = findBitRun( pCurLine, nRunIndex1, nW, isSet( pCurLine, nRunIndex1 ) );
+ long nRunIndex2 = findBitRun( pCurLine, nRunIndex1, nW );
bool bWhiteFirst = ( nLineIndex + nRunIndex1 == 0 || ! isSet( pCurLine, nLineIndex ) );
putG4Span( nRunIndex1 - nLineIndex, bWhiteFirst, aBitState );
putG4Span( nRunIndex2 - nRunIndex1, ! bWhiteFirst, aBitState );