vcl/unx/generic/print/bitmap_gfx.cxx | 69 +++++++++++------------------------ 1 file changed, 23 insertions(+), 46 deletions(-)
New commits: commit f1d68d82ae5a2de18708bf71a93e4d4a42dfa45b Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu May 27 13:45:14 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri May 28 07:53:40 2021 +0200 no need to allocate these on the heap and remove ByteEncoder because loplugin:unreffun complains about ByteEncoder::EncodeByte Change-Id: Iebc531fb7748cb9c6a83a8b4a574167a5aac58b9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116257 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/vcl/unx/generic/print/bitmap_gfx.cxx b/vcl/unx/generic/print/bitmap_gfx.cxx index 830561b9677f..2d8649706060 100644 --- a/vcl/unx/generic/print/bitmap_gfx.cxx +++ b/vcl/unx/generic/print/bitmap_gfx.cxx @@ -38,31 +38,11 @@ PrinterBmp::~PrinterBmp() { } -/* virtual base class */ - -namespace { - -class ByteEncoder -{ -private: - -public: - - virtual void EncodeByte (sal_uInt8 nByte) = 0; - virtual ~ByteEncoder () = 0; -}; - -} - -ByteEncoder::~ByteEncoder() -{ -} - /* HexEncoder */ namespace { -class HexEncoder : public ByteEncoder +class HexEncoder { private: @@ -74,9 +54,9 @@ private: public: explicit HexEncoder (osl::File* pFile); - virtual ~HexEncoder () override; + ~HexEncoder (); void WriteAscii (sal_uInt8 nByte); - virtual void EncodeByte (sal_uInt8 nByte) override; + void EncodeByte (sal_uInt8 nByte); void FlushLine (); }; @@ -132,7 +112,7 @@ HexEncoder::FlushLine () namespace { -class Ascii85Encoder : public ByteEncoder +class Ascii85Encoder { private: @@ -152,8 +132,8 @@ private: public: explicit Ascii85Encoder (osl::File* pFile); - virtual ~Ascii85Encoder () override; - virtual void EncodeByte (sal_uInt8 nByte) override; + virtual ~Ascii85Encoder (); + virtual void EncodeByte (sal_uInt8 nByte); void WriteAscii (sal_uInt8 nByte); }; @@ -510,19 +490,17 @@ PrinterGfx::DrawPS1GrayImage (const PrinterBmp& rBitmap, const tools::Rectangle& WritePS (mpPageBody, pGrayImage.makeStringAndClear()); // image body - std::unique_ptr<HexEncoder> xEncoder(new HexEncoder (mpPageBody)); + HexEncoder aEncoder(mpPageBody); for (tools::Long nRow = rArea.Top(); nRow <= rArea.Bottom(); nRow++) { for (tools::Long nColumn = rArea.Left(); nColumn <= rArea.Right(); nColumn++) { unsigned char nByte = rBitmap.GetPixelGray (nRow, nColumn); - xEncoder->EncodeByte (nByte); + aEncoder.EncodeByte (nByte); } } - xEncoder.reset(); - WritePS (mpPageBody, "\n"); } @@ -587,16 +565,15 @@ PrinterGfx::writePS2Colorspace(const PrinterBmp& rBitmap, psp::ImageType nType) psp::appendStr ("\npsp_lzwstring\n", pImage); WritePS (mpPageBody, pImage.makeStringAndClear()); - std::unique_ptr<ByteEncoder> xEncoder(new LZWEncoder(mpPageBody)); + LZWEncoder aEncoder(mpPageBody); for (sal_uInt32 i = 0; i < nSize; i++) { PrinterColor aColor = rBitmap.GetPaletteColor(i); - xEncoder->EncodeByte (aColor.GetRed()); - xEncoder->EncodeByte (aColor.GetGreen()); - xEncoder->EncodeByte (aColor.GetBlue()); + aEncoder.EncodeByte (aColor.GetRed()); + aEncoder.EncodeByte (aColor.GetGreen()); + aEncoder.EncodeByte (aColor.GetBlue()); } - xEncoder.reset(); WritePS (mpPageBody, "pop ] setcolorspace\n"); } @@ -611,14 +588,14 @@ PrinterGfx::DrawPS2GrayImage (const PrinterBmp& rBitmap, const tools::Rectangle& writePS2Colorspace(rBitmap, psp::ImageType::GrayScaleImage); writePS2ImageHeader(rArea, psp::ImageType::GrayScaleImage); - std::unique_ptr<ByteEncoder> xEncoder(new LZWEncoder(mpPageBody)); + LZWEncoder aEncoder(mpPageBody); for (tools::Long nRow = rArea.Top(); nRow <= rArea.Bottom(); nRow++) { for (tools::Long nColumn = rArea.Left(); nColumn <= rArea.Right(); nColumn++) { unsigned char nByte = rBitmap.GetPixelGray (nRow, nColumn); - xEncoder->EncodeByte (nByte); + aEncoder.EncodeByte (nByte); } } } @@ -629,7 +606,7 @@ PrinterGfx::DrawPS2MonoImage (const PrinterBmp& rBitmap, const tools::Rectangle& writePS2Colorspace(rBitmap, psp::ImageType::MonochromeImage); writePS2ImageHeader(rArea, psp::ImageType::MonochromeImage); - std::unique_ptr<ByteEncoder> xEncoder(new LZWEncoder(mpPageBody)); + LZWEncoder aEncoder(mpPageBody); for (tools::Long nRow = rArea.Top(); nRow <= rArea.Bottom(); nRow++) { @@ -643,14 +620,14 @@ PrinterGfx::DrawPS2MonoImage (const PrinterBmp& rBitmap, const tools::Rectangle& if (++nBitPos == 8) { - xEncoder->EncodeByte (nByte); + aEncoder.EncodeByte (nByte); nBitPos = 0; nByte = 0; } } // keep the row byte aligned if (nBitPos != 0) - xEncoder->EncodeByte (nByte); + aEncoder.EncodeByte (nByte); } } @@ -660,14 +637,14 @@ PrinterGfx::DrawPS2PaletteImage (const PrinterBmp& rBitmap, const tools::Rectang writePS2Colorspace(rBitmap, psp::ImageType::PaletteImage); writePS2ImageHeader(rArea, psp::ImageType::PaletteImage); - std::unique_ptr<ByteEncoder> xEncoder(new LZWEncoder(mpPageBody)); + LZWEncoder aEncoder(mpPageBody); for (tools::Long nRow = rArea.Top(); nRow <= rArea.Bottom(); nRow++) { for (tools::Long nColumn = rArea.Left(); nColumn <= rArea.Right(); nColumn++) { unsigned char nByte = rBitmap.GetPixelIdx (nRow, nColumn); - xEncoder->EncodeByte (nByte); + aEncoder.EncodeByte (nByte); } } } @@ -678,16 +655,16 @@ PrinterGfx::DrawPS2TrueColorImage (const PrinterBmp& rBitmap, const tools::Recta writePS2Colorspace(rBitmap, psp::ImageType::TrueColorImage); writePS2ImageHeader(rArea, psp::ImageType::TrueColorImage); - std::unique_ptr<ByteEncoder> xEncoder(new LZWEncoder(mpPageBody)); + LZWEncoder aEncoder(mpPageBody); for (tools::Long nRow = rArea.Top(); nRow <= rArea.Bottom(); nRow++) { for (tools::Long nColumn = rArea.Left(); nColumn <= rArea.Right(); nColumn++) { PrinterColor aColor = rBitmap.GetPixelRGB (nRow, nColumn); - xEncoder->EncodeByte (aColor.GetRed()); - xEncoder->EncodeByte (aColor.GetGreen()); - xEncoder->EncodeByte (aColor.GetBlue()); + aEncoder.EncodeByte (aColor.GetRed()); + aEncoder.EncodeByte (aColor.GetGreen()); + aEncoder.EncodeByte (aColor.GetBlue()); } } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits