diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-05-10 13:52:51 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-05-12 09:54:23 +0200 |
commit | a651dbcfca9e198b5c2561076961504586bc6bea (patch) | |
tree | 812eee16af9bc3c4c75b8b45a4c126f99ad1bab3 /include/svx | |
parent | 9b5ce4023d35c4cc82f7b17e79b8fedbcb1367dd (diff) |
convert SdrLayerId to strong_int
Also
- rename SetOfByte to SdrLayerIDSet
- add asserts in SdrLayerAdmin::GetUniqueLayerID so that we don't
allocate overlapping SdrLayerID values
- add a new constant SDRLAYERPOS_NOTFOUND to be returned from
SdrLayerAdmin::GetLayerPos
Change-Id: I3bb3489f9338e3d02c4040bcbd811744699941c8
Reviewed-on: https://gerrit.libreoffice.org/37467
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/svx')
-rw-r--r-- | include/svx/sdr/contact/displayinfo.hxx | 6 | ||||
-rw-r--r-- | include/svx/sdr/contact/objectcontact.hxx | 2 | ||||
-rw-r--r-- | include/svx/sdr/contact/viewcontact.hxx | 2 | ||||
-rw-r--r-- | include/svx/sdr/contact/viewcontactofe3dscene.hxx | 4 | ||||
-rw-r--r-- | include/svx/sdr/contact/viewobjectcontactofsdrobj.hxx | 4 | ||||
-rw-r--r-- | include/svx/sdrhittesthelper.hxx | 6 | ||||
-rw-r--r-- | include/svx/sdrmasterpagedescriptor.hxx | 6 | ||||
-rw-r--r-- | include/svx/svdlayer.hxx | 8 | ||||
-rw-r--r-- | include/svx/svdmrkv.hxx | 6 | ||||
-rw-r--r-- | include/svx/svdobj.hxx | 8 | ||||
-rw-r--r-- | include/svx/svdpage.hxx | 8 | ||||
-rw-r--r-- | include/svx/svdpagv.hxx | 22 | ||||
-rw-r--r-- | include/svx/svdsob.hxx | 26 | ||||
-rw-r--r-- | include/svx/svdtypes.hxx | 11 | ||||
-rw-r--r-- | include/svx/svdundo.hxx | 4 | ||||
-rw-r--r-- | include/svx/svdviter.hxx | 2 |
16 files changed, 65 insertions, 60 deletions
diff --git a/include/svx/sdr/contact/displayinfo.hxx b/include/svx/sdr/contact/displayinfo.hxx index b4981808f023..486399ab16c4 100644 --- a/include/svx/sdr/contact/displayinfo.hxx +++ b/include/svx/sdr/contact/displayinfo.hxx @@ -32,7 +32,7 @@ namespace sdr class SVX_DLLPUBLIC DisplayInfo final { // The Layers which shall be processed (visible) - SetOfByte maProcessLayers; + SdrLayerIDSet maProcessLayers; // The redraw area, in logical coordinates of OutputDevice. If Region // is empty, everything needs to be redrawn @@ -74,8 +74,8 @@ namespace sdr ~DisplayInfo(); // access to ProcessLayers - void SetProcessLayers(const SetOfByte& rSet); - const SetOfByte& GetProcessLayers() const { return maProcessLayers; } + void SetProcessLayers(const SdrLayerIDSet& rSet); + const SdrLayerIDSet& GetProcessLayers() const { return maProcessLayers; } // access to RedrawArea void SetRedrawArea(const vcl::Region& rRegion); diff --git a/include/svx/sdr/contact/objectcontact.hxx b/include/svx/sdr/contact/objectcontact.hxx index a2429eca7af6..7185aa20132b 100644 --- a/include/svx/sdr/contact/objectcontact.hxx +++ b/include/svx/sdr/contact/objectcontact.hxx @@ -24,7 +24,7 @@ #include <svx/svxdllapi.h> #include <drawinglayer/geometry/viewinformation2d.hxx> -class SetOfByte; +class SdrLayerIDSet; namespace tools { class Rectangle; } class SdrPageView; class OutputDevice; diff --git a/include/svx/sdr/contact/viewcontact.hxx b/include/svx/sdr/contact/viewcontact.hxx index 20347120ed6c..0912d47dbf90 100644 --- a/include/svx/sdr/contact/viewcontact.hxx +++ b/include/svx/sdr/contact/viewcontact.hxx @@ -24,7 +24,7 @@ #include <svx/svxdllapi.h> #include <drawinglayer/primitive2d/baseprimitive2d.hxx> -class SetOfByte; +class SdrLayerIDSet; class SdrPage; class SdrObject; diff --git a/include/svx/sdr/contact/viewcontactofe3dscene.hxx b/include/svx/sdr/contact/viewcontactofe3dscene.hxx index a802db8384a5..5e0b8ec91d0d 100644 --- a/include/svx/sdr/contact/viewcontactofe3dscene.hxx +++ b/include/svx/sdr/contact/viewcontactofe3dscene.hxx @@ -65,8 +65,8 @@ public: const drawinglayer::attribute::SdrLightingAttribute& getSdrLightingAttribute() const; // scene primitive creators. If pLayerVisibility is given, a visibility test with the LayerID and the - // given SetOfByte is done. - drawinglayer::primitive2d::Primitive2DContainer createScenePrimitive2DSequence(const SetOfByte* pLayerVisibility) const; + // given SdrLayerIDSet is done. + drawinglayer::primitive2d::Primitive2DContainer createScenePrimitive2DSequence(const SdrLayerIDSet* pLayerVisibility) const; // helpers to get the sequence of all contained 3D primitives and its range, // regardless of layer or visibility constraints and using a neutral ViewInformation3D diff --git a/include/svx/sdr/contact/viewobjectcontactofsdrobj.hxx b/include/svx/sdr/contact/viewobjectcontactofsdrobj.hxx index 93332d41c917..cb7773c716f3 100644 --- a/include/svx/sdr/contact/viewobjectcontactofsdrobj.hxx +++ b/include/svx/sdr/contact/viewobjectcontactofsdrobj.hxx @@ -24,7 +24,7 @@ #include <boost/optional.hpp> class SdrObject; -class SetOfByte; +class SdrLayerIDSet; class OutputDevice; namespace sdr { namespace contact { @@ -37,7 +37,7 @@ class SVX_DLLPUBLIC ViewObjectContactOfSdrObj : public ViewObjectContact that have subparts which can be on different layers (that is, SdrObjGroup .-) */ - virtual bool isPrimitiveVisibleOnAnyLayer(const SetOfByte& aLayers) const; + virtual bool isPrimitiveVisibleOnAnyLayer(const SdrLayerIDSet& aLayers) const; protected: const SdrObject& getSdrObject() const; diff --git a/include/svx/sdrhittesthelper.hxx b/include/svx/sdrhittesthelper.hxx index 2943c42a22c9..b8da54c7d839 100644 --- a/include/svx/sdrhittesthelper.hxx +++ b/include/svx/sdrhittesthelper.hxx @@ -28,7 +28,7 @@ class SdrObject; class SdrPageView; -class SetOfByte; +class SdrLayerIDSet; class SdrObjList; namespace sdr { namespace contact { class ViewObjectContact; }} namespace basegfx { class B2DPoint; } @@ -41,7 +41,7 @@ SVX_DLLPUBLIC SdrObject* SdrObjectPrimitiveHit( const Point& rPnt, sal_uInt16 nTol, const SdrPageView& rSdrPageView, - const SetOfByte* pVisiLayer, + const SdrLayerIDSet* pVisiLayer, bool bTextOnly); SVX_DLLPUBLIC SdrObject* SdrObjListPrimitiveHit( @@ -49,7 +49,7 @@ SVX_DLLPUBLIC SdrObject* SdrObjListPrimitiveHit( const Point& rPnt, sal_uInt16 nTol, const SdrPageView& rSdrPageView, - const SetOfByte* pVisiLayer, + const SdrLayerIDSet* pVisiLayer, bool bTextOnly); diff --git a/include/svx/sdrmasterpagedescriptor.hxx b/include/svx/sdrmasterpagedescriptor.hxx index 39777f96456b..f719bca5322e 100644 --- a/include/svx/sdrmasterpagedescriptor.hxx +++ b/include/svx/sdrmasterpagedescriptor.hxx @@ -42,7 +42,7 @@ namespace sdr private: SdrPage& maOwnerPage; SdrPage& maUsedPage; - SetOfByte maVisibleLayers; + SdrLayerIDSet maVisibleLayers; // ViewContact part sdr::contact::ViewContact* mpViewContact; @@ -68,8 +68,8 @@ namespace sdr SdrPage& GetOwnerPage() const { return maOwnerPage; } // member access to VisibleLayers - const SetOfByte& GetVisibleLayers() const { return maVisibleLayers; } - void SetVisibleLayers(const SetOfByte& rNew); + const SdrLayerIDSet& GetVisibleLayers() const { return maVisibleLayers; } + void SetVisibleLayers(const SdrLayerIDSet& rNew); const SdrPageProperties* getCorrectSdrPageProperties() const; }; diff --git a/include/svx/svdlayer.hxx b/include/svx/svdlayer.hxx index 13354503a42c..1a60d8b24946 100644 --- a/include/svx/svdlayer.hxx +++ b/include/svx/svdlayer.hxx @@ -88,8 +88,10 @@ public: void SetStandardLayer(); }; -// When Changing the layer data you currently have to set the Modify flag manually #define SDRLAYER_MAXCOUNT 255 +#define SDRLAYERPOS_NOTFOUND 0xffff + +// When Changing the layer data you currently have to set the Modify flag manually class SVX_DLLPUBLIC SdrLayerAdmin { friend class SdrView; friend class SdrModel; @@ -145,8 +147,8 @@ public: SdrLayer* GetLayer(const OUString& rName); const SdrLayer* GetLayer(const OUString& rName) const; SdrLayerID GetLayerID(const OUString& rName) const; - SdrLayer* GetLayerPerID(sal_uInt16 nID) { return const_cast<SdrLayer*>(const_cast<const SdrLayerAdmin*>(this)->GetLayerPerID(nID)); } - const SdrLayer* GetLayerPerID(sal_uInt16 nID) const; + SdrLayer* GetLayerPerID(SdrLayerID nID) { return const_cast<SdrLayer*>(const_cast<const SdrLayerAdmin*>(this)->GetLayerPerID(nID)); } + const SdrLayer* GetLayerPerID(SdrLayerID nID) const; void SetControlLayerName(const OUString& rNewName); const OUString& GetControlLayerName() const { return maControlLayerName; } diff --git a/include/svx/svdmrkv.hxx b/include/svx/svdmrkv.hxx index d2142ded5040..2a049fc5288e 100644 --- a/include/svx/svdmrkv.hxx +++ b/include/svx/svdmrkv.hxx @@ -153,9 +153,9 @@ protected: void ForceRefToMarked(); void ForceUndirtyMrkPnt() const { if (mbMrkPntDirty) UndirtyMrkPnt(); } - virtual SdrObject* CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObject* pObj, SdrPageView* pPV, SdrSearchOptions nOptions, const SetOfByte* pMVisLay) const; - SdrObject* CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObjList* pOL, SdrPageView* pPV, SdrSearchOptions nOptions, const SetOfByte* pMVisLay, SdrObject*& rpRootObj) const; - SdrObject* CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObjList* pOL, SdrPageView* pPV, SdrSearchOptions nOptions, const SetOfByte* pMVisLay, SdrObject*& rpRootObj,const SdrMarkList * pMarkList) const; + virtual SdrObject* CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObject* pObj, SdrPageView* pPV, SdrSearchOptions nOptions, const SdrLayerIDSet* pMVisLay) const; + SdrObject* CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObjList* pOL, SdrPageView* pPV, SdrSearchOptions nOptions, const SdrLayerIDSet* pMVisLay, SdrObject*& rpRootObj) const; + SdrObject* CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObjList* pOL, SdrPageView* pPV, SdrSearchOptions nOptions, const SdrLayerIDSet* pMVisLay, SdrObject*& rpRootObj,const SdrMarkList * pMarkList) const; bool ImpIsFrameHandles() const; void ImpTakeDescriptionStr(sal_uInt16 nStrCacheID, OUString& rStr, ImpTakeDescriptionOptions nOpt=ImpTakeDescriptionOptions::NONE) const; diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index 9f8ef8f95422..8c1e4b59d278 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -69,7 +69,7 @@ class SdrObjUserDataList; class SdrObjPlusData; class SdrGluePoint; class SdrGluePointList; -class SetOfByte; +class SdrLayerIDSet; class OutputDevice; class Fraction; @@ -182,7 +182,7 @@ public: Point aPos; Point aDownPos; VclPtr<OutputDevice> pOut; - const SetOfByte* pVisiLayer; + const SdrLayerIDSet* pVisiLayer; const SdrPageView* pPageView; sal_uInt16 nTol; bool bDown; @@ -341,8 +341,8 @@ public: virtual SdrLayerID GetLayer() const; virtual void NbcSetLayer(SdrLayerID nLayer); virtual void SetLayer(SdrLayerID nLayer); - // renaming GetLayerSet -> getMergedHierarchyLayerSet to make clear what happens here. rSet needs to be empty. - void getMergedHierarchyLayerSet(SetOfByte& rSet) const; + // renaming GetSdrLayerIDSet -> getMergedHierarchySdrLayerIDSet to make clear what happens here. rSet needs to be empty. + void getMergedHierarchySdrLayerIDSet(SdrLayerIDSet& rSet) const; void SendUserCall(SdrUserCallType eUserCall, const tools::Rectangle& rBoundRect) const; diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx index 987acd87aa16..a348c2c75e1f 100644 --- a/include/svx/svdpage.hxx +++ b/include/svx/svdpage.hxx @@ -48,7 +48,7 @@ class SdrModel; class SfxItemPool; class SdrPageView; class SdrLayerAdmin; -class SetOfByte; +class SdrLayerIDSet; class Color; class SfxStyleSheet; class SvxUnoDrawPagesAccess; @@ -405,7 +405,7 @@ protected: // new MasterPageDescriptorVector sdr::MasterPageDescriptor* mpMasterPageDescriptor; - SetOfByte aPrefVisiLayers; + SdrLayerIDSet aPrefVisiLayers; sal_uInt16 nPageNum; bool mbMaster : 1; // flag if this is a MasterPage @@ -469,8 +469,8 @@ public: void TRG_SetMasterPage(SdrPage& rNew); void TRG_ClearMasterPage(); SdrPage& TRG_GetMasterPage() const; - const SetOfByte& TRG_GetMasterPageVisibleLayers() const; - void TRG_SetMasterPageVisibleLayers(const SetOfByte& rNew); + const SdrLayerIDSet& TRG_GetMasterPageVisibleLayers() const; + void TRG_SetMasterPageVisibleLayers(const SdrLayerIDSet& rNew); sdr::contact::ViewContact& TRG_GetMasterPageDescriptorViewContact() const; protected: diff --git a/include/svx/svdpagv.hxx b/include/svx/svdpagv.hxx index 44a0000beb86..b068ecea8875 100644 --- a/include/svx/svdpagv.hxx +++ b/include/svx/svdpagv.hxx @@ -69,9 +69,9 @@ private: bool mbHasMarked; bool mbVisible; - SetOfByte aLayerVisi; // Set of visible Layers - SetOfByte aLayerLock; // Set of non-editable Layers - SetOfByte aLayerPrn; // Set of printable Layers + SdrLayerIDSet aLayerVisi; // Set of visible Layers + SdrLayerIDSet aLayerLock; // Set of non-editable Layers + SdrLayerIDSet aLayerPrn; // Set of printable Layers SdrObjList* pAktList; // Current List, usually the Page SdrObject* pAktGroup; // Current Group; nullptr means none @@ -110,8 +110,8 @@ public: private: void ImpInvalidateHelpLineArea(sal_uInt16 nNum) const; - void SetLayer(const OUString& rName, SetOfByte& rBS, bool bJa); - bool IsLayer(const OUString& rName, const SetOfByte& rBS) const; + void SetLayer(const OUString& rName, SdrLayerIDSet& rBS, bool bJa); + bool IsLayer(const OUString& rName, const SdrLayerIDSet& rBS) const; /// Let's see if the current Group (pAktGroup) is still inserted void CheckAktGroup(); @@ -210,12 +210,12 @@ public: void LogicToPagePos(tools::Rectangle& rRect) const { rRect.Move(-aPgOrg.X(),-aPgOrg.Y()); } void PagePosToLogic(Point& rPnt) const { rPnt+=aPgOrg; } - void SetVisibleLayers(const SetOfByte& rSet) { aLayerVisi=rSet; } - const SetOfByte& GetVisibleLayers() const { return aLayerVisi; } - void SetPrintableLayers(const SetOfByte& rSet) { aLayerPrn=rSet; } - const SetOfByte& GetPrintableLayers() const { return aLayerPrn; } - void SetLockedLayers(const SetOfByte& rSet) { aLayerLock=rSet; } - const SetOfByte& GetLockedLayers() const { return aLayerLock; } + void SetVisibleLayers(const SdrLayerIDSet& rSet) { aLayerVisi=rSet; } + const SdrLayerIDSet& GetVisibleLayers() const { return aLayerVisi; } + void SetPrintableLayers(const SdrLayerIDSet& rSet) { aLayerPrn=rSet; } + const SdrLayerIDSet& GetPrintableLayers() const { return aLayerPrn; } + void SetLockedLayers(const SdrLayerIDSet& rSet) { aLayerLock=rSet; } + const SdrLayerIDSet& GetLockedLayers() const { return aLayerLock; } const SdrHelpLineList& GetHelpLines() const { return aHelpLines; } void SetHelpLines(const SdrHelpLineList& rHLL); diff --git a/include/svx/svdsob.hxx b/include/svx/svdsob.hxx index 510087c1914a..ac84a9bada1b 100644 --- a/include/svx/svdsob.hxx +++ b/include/svx/svdsob.hxx @@ -23,40 +23,40 @@ #include <com/sun/star/uno/Any.hxx> #include <svx/svxdllapi.h> +#include <svx/svdtypes.hxx> /* - Declaration of a static set type. The set can collect elements - from 0 to 255 and it takes always 32 Bytes. + Stores a bitfield of the layer values that have been set. */ -class SVX_DLLPUBLIC SetOfByte +class SVX_DLLPUBLIC SdrLayerIDSet { protected: sal_uInt8 aData[32]; public: - explicit SetOfByte(bool bInitVal = false) + explicit SdrLayerIDSet(bool bInitVal = false) { memset(aData, bInitVal ? 0xFF : 0x00, sizeof(aData)); } - bool operator!=(const SetOfByte& rCmpSet) const + bool operator!=(const SdrLayerIDSet& rCmpSet) const { return (memcmp(aData, rCmpSet.aData, sizeof(aData))!=0); } - void Set(sal_uInt8 a) + void Set(SdrLayerID a) { - aData[a/8] |= 1<<a%8; + aData[sal_uInt8(a)/8] |= 1 << (sal_uInt8(a) % 8); } - void Clear(sal_uInt8 a) + void Clear(SdrLayerID a) { - aData[a/8] &= ~(1<<a%8); + aData[sal_uInt8(a)/8] &= ~(1 << (sal_uInt8(a) % 8)); } - void Set(sal_uInt8 a, bool b) + void Set(SdrLayerID a, bool b) { if(b) Set(a); @@ -64,9 +64,9 @@ public: Clear(a); } - bool IsSet(sal_uInt8 a) const + bool IsSet(SdrLayerID a) const { - return (aData[a/8] & 1<<a%8) != 0; + return (aData[sal_uInt8(a)/8] & 1<<sal_uInt8(a)%8) != 0; } void SetAll() @@ -81,7 +81,7 @@ public: bool IsEmpty() const; - void operator&=(const SetOfByte& r2ndSet); + void operator&=(const SdrLayerIDSet& r2ndSet); // initialize this set with a uno sequence of sal_Int8 void PutValue(const css::uno::Any & rAny); diff --git a/include/svx/svdtypes.hxx b/include/svx/svdtypes.hxx index ec105228bee4..bf8e00005bb3 100644 --- a/include/svx/svdtypes.hxx +++ b/include/svx/svdtypes.hxx @@ -21,6 +21,7 @@ #define INCLUDED_SVX_SVDTYPES_HXX #include <sal/types.h> +#include <o3tl/strong_int.hxx> // commands for EndCreate() enum class SdrCreateCmd @@ -52,13 +53,15 @@ enum class SdrDragMode /* * Layer */ -// If there is no layer when it should be identified, then -// drLayerAdmin::GetLayerID(const String&) returns a value. -#define SDRLAYER_NOTFOUND 0xFF // 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 sal_uInt8 SdrLayerID; +struct SdrLayerIDTag {}; +typedef o3tl::strong_int<sal_uInt8,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); /* * Page + ObjList diff --git a/include/svx/svdundo.hxx b/include/svx/svdundo.hxx index 2653ba8569e8..3e434f8e64bd 100644 --- a/include/svx/svdundo.hxx +++ b/include/svx/svdundo.hxx @@ -678,7 +678,7 @@ class SdrUndoPageMasterPage : public SdrUndoPage { protected: bool mbOldHadMasterPage; - SetOfByte maOldSet; + SdrLayerIDSet maOldSet; sal_uInt16 maOldMasterPageNumber; protected: @@ -713,7 +713,7 @@ class SVX_DLLPUBLIC SdrUndoPageChangeMasterPage : public SdrUndoPageMasterPage { protected: bool mbNewHadMasterPage; - SetOfByte maNewSet; + SdrLayerIDSet maNewSet; sal_uInt16 maNewMasterPageNumber; public: diff --git a/include/svx/svdviter.hxx b/include/svx/svdviter.hxx index 7f903c440c73..76d0ca49662c 100644 --- a/include/svx/svdviter.hxx +++ b/include/svx/svdviter.hxx @@ -59,7 +59,7 @@ class SdrPageView; class SdrModel; class SdrPage; class SdrObject; -class SetOfByte; +class SdrLayerIDSet; class SVX_DLLPUBLIC SdrViewIter { |