diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-09-07 12:16:24 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2022-02-23 16:00:28 +0100 |
commit | f4a62e5479b47d90d6de518f38a97ac0b5322c54 (patch) | |
tree | ff1a90880f5ed9de959a66b447b0b182c32fea94 /include/svx | |
parent | 4751853b19dabfb57963c58183b0c3557328b3b8 (diff) |
SdrLayerID must be based on sal_Int16
... which is the type corresponding to the related published property
"LayerID" of com.sun.star.drawing.Shape service.
Without this, the code asserts on values passed to the published API
from external sources to be in the 8-bit limits, which is incorrect.
Change-Id: I0449a7dd313f7e6c4adbc1c1f7b8c50b6a51434e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121760
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'include/svx')
-rw-r--r-- | include/svx/svdsob.hxx | 12 | ||||
-rw-r--r-- | include/svx/svdtypes.hxx | 4 |
2 files changed, 11 insertions, 5 deletions
diff --git a/include/svx/svdsob.hxx b/include/svx/svdsob.hxx index 2d17ab05640a..7e2b8578e01d 100644 --- a/include/svx/svdsob.hxx +++ b/include/svx/svdsob.hxx @@ -30,6 +30,7 @@ class SVXCORE_DLLPUBLIC SdrLayerIDSet final { + // For now, have up to 256 layers sal_uInt8 aData[32]; public: @@ -45,12 +46,16 @@ public: void Set(SdrLayerID a) { - aData[sal_uInt8(a)/8] |= 1 << (sal_uInt8(a) % 8); + const sal_Int16 nId = a.get(); + if (nId >= 0 && nId < 256) + aData[nId / 8] |= 1 << (nId % 8); } void Clear(SdrLayerID a) { - aData[sal_uInt8(a)/8] &= ~(1 << (sal_uInt8(a) % 8)); + const sal_Int16 nId = a.get(); + if (nId >= 0 && nId < 256) + aData[nId / 8] &= ~(1 << (nId % 8)); } void Set(SdrLayerID a, bool b) @@ -63,7 +68,8 @@ public: bool IsSet(SdrLayerID a) const { - return (aData[sal_uInt8(a)/8] & 1<<sal_uInt8(a)%8) != 0; + const sal_Int16 nId = a.get(); + return nId >= 0 && nId < 256 && (aData[nId / 8] & 1 << nId % 8) != 0; } void SetAll() diff --git a/include/svx/svdtypes.hxx b/include/svx/svdtypes.hxx index 5b73552a5719..1009b0314923 100644 --- a/include/svx/svdtypes.hxx +++ b/include/svx/svdtypes.hxx @@ -53,11 +53,11 @@ enum class SdrDragMode // You can use this value in the methods of SdrLayerSet, but false is returned // every time or the method does nothing. // type declaration for Layer-IDs -typedef o3tl::strong_int<sal_uInt8, struct SdrLayerIDTag> SdrLayerID; +typedef o3tl::strong_int<sal_Int16, struct SdrLayerIDTag> SdrLayerID; // If there is no layer when it should be identified, then // SdrLayerAdmin::GetLayerID(const String&) returns a value. -constexpr SdrLayerID SDRLAYER_NOTFOUND(0xff); +constexpr SdrLayerID SDRLAYER_NOTFOUND(-1); /* * Repeat |