[Libreoffice-commits] core.git: vcl/unx
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Jan 17 17:12:44 UTC 2019
vcl/unx/generic/print/bitmap_gfx.cxx | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
New commits:
commit 95612cc87827e797e0c44d9f11561603c8b11d50
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Thu Jan 17 15:51:54 2019 +0100
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu Jan 17 18:12:16 2019 +0100
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 at redhat.com>
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);
More information about the Libreoffice-commits
mailing list