tdf#119030: Disable entries if open file read-only is unchecked
[LibreOffice.git] / vcl / inc / salbmp.hxx
blob7a89e82e057fd0a15307c8d251f50e448aaa299a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_INC_SALBMP_HXX
21 #define INCLUDED_VCL_INC_SALBMP_HXX
23 #include <tools/gen.hxx>
24 #include <vcl/checksum.hxx>
25 #include <vcl/salbtype.hxx>
27 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
29 struct BitmapBuffer;
30 class Color;
31 class SalGraphics;
32 class BitmapPalette;
33 struct BitmapSystemData;
34 enum class BmpScaleFlag;
36 extern const sal_uLong nVCLRLut[ 6 ];
37 extern const sal_uLong nVCLGLut[ 6 ];
38 extern const sal_uLong nVCLBLut[ 6 ];
39 extern const sal_uLong nVCLDitherLut[ 256 ];
40 extern const sal_uLong nVCLLut[ 256 ];
42 class VCL_PLUGIN_PUBLIC SalBitmap
44 public:
46 SalBitmap()
47 : mnChecksum(0)
48 , mbChecksumValid(false)
52 virtual ~SalBitmap();
54 virtual bool Create( const Size& rSize,
55 sal_uInt16 nBitCount,
56 const BitmapPalette& rPal ) = 0;
57 virtual bool Create( const SalBitmap& rSalBmp ) = 0;
58 virtual bool Create( const SalBitmap& rSalBmp,
59 SalGraphics* pGraphics ) = 0;
60 virtual bool Create( const SalBitmap& rSalBmp,
61 sal_uInt16 nNewBitCount ) = 0;
62 virtual bool Create( const css::uno::Reference< css::rendering::XBitmapCanvas >& rBitmapCanvas,
63 Size& rSize,
64 bool bMask = false ) = 0;
65 virtual void Destroy() = 0;
66 virtual Size GetSize() const = 0;
67 virtual sal_uInt16 GetBitCount() const = 0;
69 virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) = 0;
70 virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) = 0;
71 virtual bool GetSystemData( BitmapSystemData& rData ) = 0;
73 virtual bool ScalingSupported() const = 0;
74 virtual bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) = 0;
75 virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) = 0;
77 virtual bool ConvertToGreyscale()
79 return false;
82 void GetChecksum(BitmapChecksum& rChecksum) const
84 updateChecksum();
85 if (!mbChecksumValid)
86 rChecksum = 0; // back-compat
87 else
88 rChecksum = mnChecksum;
91 void InvalidateChecksum()
93 mbChecksumValid = false;
96 protected:
97 BitmapChecksum mnChecksum;
98 bool mbChecksumValid;
100 protected:
101 virtual void updateChecksum() const
103 if (mbChecksumValid)
104 return;
106 BitmapChecksum nCrc = 0;
107 SalBitmap* pThis = const_cast<SalBitmap*>(this);
108 BitmapBuffer* pBuf = pThis->AcquireBuffer(BitmapAccessMode::Read);
109 if (pBuf)
111 nCrc = pBuf->maPalette.GetChecksum();
112 nCrc = vcl_get_checksum(nCrc, pBuf->mpBits, pBuf->mnScanlineSize * pBuf->mnHeight);
113 pThis->ReleaseBuffer(pBuf, BitmapAccessMode::Read);
114 pThis->mnChecksum = nCrc;
115 pThis->mbChecksumValid = true;
117 else
119 pThis->mbChecksumValid = false;
126 #endif
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */