diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-01-17 15:51:54 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-01-17 18:12:16 +0100 |
commit | 95612cc87827e797e0c44d9f11561603c8b11d50 (patch) | |
tree | 7b8577fdaec25e0825484bf382591638f044b761 /vcl | |
parent | 5de78478ce98ae484040b79de7df6c091873481b (diff) |
Rework Ascii85Encoder::ConvertToAscii85 code somewhat
...making sure not to generate characters into the output that are ultimately
discarded again. In preparation of eventually changing the output from a char
array to something more flexible like OStringBuffer.
Change-Id: I2fde3d02752d4e81ee1ee34188266e72d1d8b01d
Reviewed-on: https://gerrit.libreoffice.org/66528
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/unx/generic/print/bitmap_gfx.cxx | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/vcl/unx/generic/print/bitmap_gfx.cxx b/vcl/unx/generic/print/bitmap_gfx.cxx index fffe137f7981..eca8cbb90921 100644 --- a/vcl/unx/generic/print/bitmap_gfx.cxx +++ b/vcl/unx/generic/print/bitmap_gfx.cxx @@ -190,18 +190,26 @@ Ascii85Encoder::ConvertToAscii85 () else { /* real ascii85 encoding */ - mpFileBuffer [mnOffset + 4] = (nByteValue % 85) + 33; + + // Of the up to 5 characters to be generated, do not generate the last (4 - mnByte) ones + // that correspond to the (4 - mnByte) zero padding bytes added to the input: + + if (mnByte == 4) { + mpFileBuffer [mnOffset + 4] = (nByteValue % 85) + 33; + } nByteValue /= 85; - mpFileBuffer [mnOffset + 3] = (nByteValue % 85) + 33; + if (mnByte >= 3) { + mpFileBuffer [mnOffset + 3] = (nByteValue % 85) + 33; + } nByteValue /= 85; - mpFileBuffer [mnOffset + 2] = (nByteValue % 85) + 33; + if (mnByte >= 2) { + mpFileBuffer [mnOffset + 2] = (nByteValue % 85) + 33; + } nByteValue /= 85; mpFileBuffer [mnOffset + 1] = (nByteValue % 85) + 33; nByteValue /= 85; mpFileBuffer [mnOffset + 0] = (nByteValue % 85) + 33; - // Ignore the last (4 - mnByte) generated characters that correspond to the (4 - mnByte) - // zero padding bytes: mnColumn += (mnByte + 1); mnOffset += (mnByte + 1); |