[Libreoffice-commits] core.git: basctl/source filter/source include/filter include/svx reportdesign/inc reportdesign/source sc/inc sc/source sd/source svx/inc svx/source sw/inc sw/source

Noel Grandin noel.grandin at collabora.co.uk
Fri May 12 07:55:02 UTC 2017


 basctl/source/dlged/dlgedview.cxx                                  |    2 
 basctl/source/inc/dlgedview.hxx                                    |    2 
 filter/source/msfilter/escherex.cxx                                |    2 
 filter/source/msfilter/eschesdo.cxx                                |    4 
 include/filter/msfilter/escherex.hxx                               |    7 -
 include/svx/sdr/contact/displayinfo.hxx                            |    6 -
 include/svx/sdr/contact/objectcontact.hxx                          |    2 
 include/svx/sdr/contact/viewcontact.hxx                            |    2 
 include/svx/sdr/contact/viewcontactofe3dscene.hxx                  |    4 
 include/svx/sdr/contact/viewobjectcontactofsdrobj.hxx              |    4 
 include/svx/sdrhittesthelper.hxx                                   |    6 -
 include/svx/sdrmasterpagedescriptor.hxx                            |    6 -
 include/svx/svdlayer.hxx                                           |    8 -
 include/svx/svdmrkv.hxx                                            |    6 -
 include/svx/svdobj.hxx                                             |    8 -
 include/svx/svdpage.hxx                                            |    8 -
 include/svx/svdpagv.hxx                                            |   22 ++--
 include/svx/svdsob.hxx                                             |   26 ++--
 include/svx/svdtypes.hxx                                           |   11 +-
 include/svx/svdundo.hxx                                            |    4 
 include/svx/svdviter.hxx                                           |    2 
 reportdesign/inc/RptDef.hxx                                        |    6 -
 reportdesign/source/core/api/ReportDefinition.cxx                  |    6 -
 reportdesign/source/ui/inc/SectionView.hxx                         |    2 
 reportdesign/source/ui/report/ReportSection.cxx                    |    2 
 reportdesign/source/ui/report/SectionView.cxx                      |    9 -
 sc/inc/global.hxx                                                  |   14 +-
 sc/source/core/data/drwlayer.cxx                                   |   10 -
 sc/source/filter/xml/XMLTableShapeImportHelper.cxx                 |   10 -
 sc/source/filter/xml/XMLTableShapeImportHelper.hxx                 |    3 
 sc/source/filter/xml/xmlexprt.cxx                                  |    4 
 sc/source/ui/Accessibility/AccessibleDocument.cxx                  |   12 +-
 sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx       |   42 +++----
 sc/source/ui/drawfunc/drawsh2.cxx                                  |    2 
 sc/source/ui/inc/drawsh.hxx                                        |    3 
 sc/source/ui/inc/drawview.hxx                                      |    2 
 sc/source/ui/inc/gridwin.hxx                                       |    2 
 sc/source/ui/inc/output.hxx                                        |    8 -
 sc/source/ui/view/drawview.cxx                                     |    4 
 sc/source/ui/view/gridwin3.cxx                                     |    4 
 sc/source/ui/view/output3.cxx                                      |    4 
 sd/source/core/drawdoc2.cxx                                        |   12 +-
 sd/source/core/sdpage.cxx                                          |    8 -
 sd/source/filter/ppt/pptin.cxx                                     |    2 
 sd/source/ui/dlg/LayerTabBar.cxx                                   |   10 -
 sd/source/ui/func/fudraw.cxx                                       |    2 
 sd/source/ui/func/fuexpand.cxx                                     |    2 
 sd/source/ui/func/fusel.cxx                                        |    2 
 sd/source/ui/func/fusumry.cxx                                      |    2 
 sd/source/ui/inc/DrawViewShell.hxx                                 |    4 
 sd/source/ui/inc/FrameView.hxx                                     |   18 +--
 sd/source/ui/inc/OutlineView.hxx                                   |    4 
 sd/source/ui/inc/SlideSorterViewShell.hxx                          |    4 
 sd/source/ui/inc/View.hxx                                          |    6 -
 sd/source/ui/inc/ViewShell.hxx                                     |    4 
 sd/source/ui/sidebar/LayoutMenu.cxx                                |    6 -
 sd/source/ui/slidesorter/controller/SlsClipboard.cxx               |    6 -
 sd/source/ui/slidesorter/controller/SlsSlotManager.cxx             |    6 -
 sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx           |    6 -
 sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx            |    4 
 sd/source/ui/unoidl/unolayer.cxx                                   |    2 
 sd/source/ui/unoidl/unomodel.cxx                                   |   10 -
 sd/source/ui/unoidl/unopage.cxx                                    |    8 -
 sd/source/ui/view/DocumentRenderer.cxx                             |   28 ++---
 sd/source/ui/view/ViewShellImplementation.cxx                      |   12 +-
 sd/source/ui/view/drviews1.cxx                                     |   32 +++---
 sd/source/ui/view/drviews2.cxx                                     |    4 
 sd/source/ui/view/drviews7.cxx                                     |    6 -
 sd/source/ui/view/drviewsa.cxx                                     |    2 
 sd/source/ui/view/drviewsb.cxx                                     |    6 -
 sd/source/ui/view/frmview.cxx                                      |   18 +--
 sd/source/ui/view/outlview.cxx                                     |    4 
 sd/source/ui/view/sdview2.cxx                                      |    4 
 sd/source/ui/view/sdview3.cxx                                      |    8 -
 sd/source/ui/view/unmodpg.cxx                                      |   18 +--
 sd/source/ui/view/viewshe2.cxx                                     |    4 
 sd/source/ui/view/viewshe3.cxx                                     |    6 -
 svx/inc/sdr/contact/viewobjectcontactofgroup.hxx                   |    2 
 svx/inc/sxlayitm.hxx                                               |    4 
 svx/source/sdr/contact/displayinfo.cxx                             |    2 
 svx/source/sdr/contact/viewcontactofe3dscene.cxx                   |   10 -
 svx/source/sdr/contact/viewobjectcontactofe3dscene.cxx             |    2 
 svx/source/sdr/contact/viewobjectcontactofgroup.cxx                |    6 -
 svx/source/sdr/contact/viewobjectcontactofmasterpagedescriptor.cxx |    8 -
 svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx               |    2 
 svx/source/svdraw/sdrhittesthelper.cxx                             |    4 
 svx/source/svdraw/sdrmasterpagedescriptor.cxx                      |    2 
 svx/source/svdraw/sdrpagewindow.cxx                                |    4 
 svx/source/svdraw/svdattr.cxx                                      |    2 
 svx/source/svdraw/svdcrtv.cxx                                      |    4 
 svx/source/svdraw/svdedtv.cxx                                      |    7 -
 svx/source/svdraw/svdedtv1.cxx                                     |    3 
 svx/source/svdraw/svdetc.cxx                                       |    6 -
 svx/source/svdraw/svdlayer.cxx                                     |   53 ++++------
 svx/source/svdraw/svdmrkv.cxx                                      |    8 -
 svx/source/svdraw/svdobj.cxx                                       |    7 -
 svx/source/svdraw/svdoedge.cxx                                     |    2 
 svx/source/svdraw/svdogrp.cxx                                      |    2 
 svx/source/svdraw/svdpage.cxx                                      |    4 
 svx/source/svdraw/svdpagv.cxx                                      |    8 -
 svx/source/svdraw/svdviter.cxx                                     |    8 -
 svx/source/svdraw/svdxcgv.cxx                                      |    8 -
 svx/source/uitest/sdrobject.cxx                                    |    2 
 svx/source/unodraw/unoshape.cxx                                    |    6 -
 sw/inc/fesh.hxx                                                    |    2 
 sw/source/core/draw/dview.cxx                                      |    2 
 sw/source/core/frmedt/feshview.cxx                                 |   33 ++----
 sw/source/core/inc/UndoInsert.hxx                                  |    5 
 sw/source/core/inc/dview.hxx                                       |    2 
 sw/source/core/layout/fly.cxx                                      |    4 
 sw/source/core/text/txtfly.cxx                                     |    4 
 sw/source/core/undo/unins.cxx                                      |    2 
 sw/source/core/unocore/unodraw.cxx                                 |    6 +
 sw/source/filter/ww8/writerhelper.hxx                              |    3 
 sw/source/uibase/shells/drawsh.cxx                                 |    6 -
 sw/source/uibase/shells/drwbassh.cxx                               |    2 
 116 files changed, 409 insertions(+), 409 deletions(-)

New commits:
commit a651dbcfca9e198b5c2561076961504586bc6bea
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed May 10 13:52:51 2017 +0200

    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 at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/basctl/source/dlged/dlgedview.cxx b/basctl/source/dlged/dlgedview.cxx
index d05ceb1d9a70..afb76e242f71 100644
--- a/basctl/source/dlged/dlgedview.cxx
+++ b/basctl/source/dlged/dlgedview.cxx
@@ -168,7 +168,7 @@ SdrObject* impLocalHitCorrection(SdrObject* pRetval, const Point& rPnt, sal_uInt
     return pRetval;
 }
 
-SdrObject* DlgEdView::CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObject* pObj, SdrPageView* pPV, SdrSearchOptions nOptions, const SetOfByte* pMVisLay) const
+SdrObject* DlgEdView::CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObject* pObj, SdrPageView* pPV, SdrSearchOptions nOptions, const SdrLayerIDSet* pMVisLay) const
 {
     // call parent
     SdrObject* pRetval = SdrView::CheckSingleSdrObjectHit(rPnt, nTol, pObj, pPV, nOptions, pMVisLay);
diff --git a/basctl/source/inc/dlgedview.hxx b/basctl/source/inc/dlgedview.hxx
index a370d48e16b4..511abfc841e3 100644
--- a/basctl/source/inc/dlgedview.hxx
+++ b/basctl/source/inc/dlgedview.hxx
@@ -48,7 +48,7 @@ public:
 protected:
     /// override to handle HitTest for some objects specially
     using SdrView::CheckSingleSdrObjectHit;
-    virtual SdrObject* CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObject* pObj, SdrPageView* pPV, SdrSearchOptions nOptions, const SetOfByte* pMVisLay) const override;
+    virtual SdrObject* CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObject* pObj, SdrPageView* pPV, SdrSearchOptions nOptions, const SdrLayerIDSet* pMVisLay) const override;
 };
 
 } // namespace basctl
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index ee786573f1a0..cf83e13057d6 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -4934,7 +4934,7 @@ EscherEx::EscherEx(const std::shared_ptr<EscherExGlobal>& rxGlobal, SvStream* pO
     , mnCurrentDg(0)
     , mnCountOfs(0)
     , mnGroupLevel(0)
-    , mnHellLayerId(USHRT_MAX)
+    , mnHellLayerId(SDRLAYER_NOTFOUND)
     , mbEscherSpgr(false)
     , mbEscherDg(false)
     , mbOOXML(bOOXML)
diff --git a/filter/source/msfilter/eschesdo.cxx b/filter/source/msfilter/eschesdo.cxx
index ce1f7b792fce..a6dcda3a010c 100644
--- a/filter/source/msfilter/eschesdo.cxx
+++ b/filter/source/msfilter/eschesdo.cxx
@@ -645,9 +645,9 @@ sal_uInt32 ImplEESdrWriter::ImplWriteShape( ImplEESdrObject& rObj,
         }
         aPropOpt.CreateShadowProperties( rObj.mXPropSet );
 
-        if( USHRT_MAX != mpEscherEx->GetHellLayerId() &&
+        if( SDRLAYER_NOTFOUND != mpEscherEx->GetHellLayerId() &&
             rObj.ImplGetPropertyValue( OUString( "LayerID" ) ) &&
-            *o3tl::doAccess<sal_uInt16>(rObj.GetUsrAny()) == mpEscherEx->GetHellLayerId() )
+            *o3tl::doAccess<sal_uInt16>(rObj.GetUsrAny()) == sal_uInt8(mpEscherEx->GetHellLayerId()) )
         {
             aPropOpt.AddOpt( ESCHER_Prop_fPrint, 0x200020 );
         }
diff --git a/include/filter/msfilter/escherex.hxx b/include/filter/msfilter/escherex.hxx
index 9e46ca662927..4486ceb34e58 100644
--- a/include/filter/msfilter/escherex.hxx
+++ b/include/filter/msfilter/escherex.hxx
@@ -33,6 +33,7 @@
 #include <rtl/ustring.hxx>
 #include <sal/types.h>
 #include <svtools/grfmgr.hxx>
+#include <svx/svdtypes.hxx>
 #include <svx/msdffdef.hxx>
 #include <tools/color.hxx>
 #include <tools/gen.hxx>
@@ -1036,7 +1037,7 @@ class MSFILTER_DLLPUBLIC EscherEx : public EscherPersistTable
         sal_uInt32                  mnCountOfs;
 
         sal_uInt32                  mnGroupLevel;
-        sal_uInt16                  mnHellLayerId;
+        SdrLayerID                  mnHellLayerId;
 
         bool                        mbEscherSpgr;
         bool                        mbEscherDg;
@@ -1184,8 +1185,8 @@ public:
 
     static const SdrObject* GetSdrObject( const css::uno::Reference< css::drawing::XShape >& rXShape );
 
-    void SetHellLayerId( sal_uInt16 nId )       { mnHellLayerId = nId; }
-    sal_uInt16 GetHellLayerId() const           { return mnHellLayerId; }
+    void SetHellLayerId( SdrLayerID nId )       { mnHellLayerId = nId; }
+    SdrLayerID GetHellLayerId() const           { return mnHellLayerId; }
 
 private:
                         EscherEx( const EscherEx& ) = delete;
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
 {
diff --git a/reportdesign/inc/RptDef.hxx b/reportdesign/inc/RptDef.hxx
index 0007bedd9c1a..01cea68a878c 100644
--- a/reportdesign/inc/RptDef.hxx
+++ b/reportdesign/inc/RptDef.hxx
@@ -44,9 +44,9 @@ namespace com { namespace sun { namespace star {
 namespace rptui
 {
 // not all used at the moment
-#define RPT_LAYER_FRONT         0
-#define RPT_LAYER_BACK          1
-#define RPT_LAYER_HIDDEN        2
+constexpr SdrLayerID RPT_LAYER_FRONT  (0);
+constexpr SdrLayerID RPT_LAYER_BACK   (1);
+constexpr SdrLayerID RPT_LAYER_HIDDEN (2);
 
 
 
diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx
index 620951d2088e..9f853f677626 100644
--- a/reportdesign/source/core/api/ReportDefinition.cxx
+++ b/reportdesign/source/core/api/ReportDefinition.cxx
@@ -590,9 +590,9 @@ void OReportDefinition::init()
         m_pImpl->m_pReportModel->GetItemPool().FreezeIdRanges();
         m_pImpl->m_pReportModel->SetScaleUnit( MapUnit::Map100thMM );
         SdrLayerAdmin& rAdmin = m_pImpl->m_pReportModel->GetLayerAdmin();
-        rAdmin.NewStandardLayer(RPT_LAYER_FRONT);
-        rAdmin.NewLayer("back", RPT_LAYER_BACK);
-        rAdmin.NewLayer("HiddenLayer", RPT_LAYER_HIDDEN);
+        rAdmin.NewStandardLayer(sal_uInt8(RPT_LAYER_FRONT));
+        rAdmin.NewLayer("back", sal_uInt8(RPT_LAYER_BACK));
+        rAdmin.NewLayer("HiddenLayer", sal_uInt8(RPT_LAYER_HIDDEN));
 
         m_pImpl->m_pUndoManager = new ::dbaui::UndoManager( *this, m_aMutex );
         m_pImpl->m_pReportModel->SetSdrUndoManager( &m_pImpl->m_pUndoManager->GetSfxUndoManager() );
diff --git a/reportdesign/source/ui/inc/SectionView.hxx b/reportdesign/source/ui/inc/SectionView.hxx
index 1035a8a7ef5f..c5c48661c059 100644
--- a/reportdesign/source/ui/inc/SectionView.hxx
+++ b/reportdesign/source/ui/inc/SectionView.hxx
@@ -59,7 +59,7 @@ public:
 
     /* returns the common layer id of the marked objects, otherwise -1 will be returned.
     */
-    short GetLayerIdOfMarkedObjects() const;
+    SdrLayerID GetLayerIdOfMarkedObjects() const;
 
     // returns true if objects at Drag & Drop is resize not move
     bool IsDragResize() const;
diff --git a/reportdesign/source/ui/report/ReportSection.cxx b/reportdesign/source/ui/report/ReportSection.cxx
index 580c228ccb56..88171c364b60 100644
--- a/reportdesign/source/ui/report/ReportSection.cxx
+++ b/reportdesign/source/ui/report/ReportSection.cxx
@@ -163,7 +163,7 @@ void OReportSection::Paint( vcl::RenderContext& rRenderContext, const tools::Rec
         // do paint (unbuffered) and mark repaint end
         if(pPgView)
         {
-            pPgView->DrawLayer(0, &rRenderContext);
+            pPgView->DrawLayer(RPT_LAYER_FRONT, &rRenderContext);
             pPgView->GetView().EndDrawLayers(*pTargetPaintWindow, true);
         }
 
diff --git a/reportdesign/source/ui/report/SectionView.cxx b/reportdesign/source/ui/report/SectionView.cxx
index 1c5ba21f4865..d94fe0deb51d 100644
--- a/reportdesign/source/ui/report/SectionView.cxx
+++ b/reportdesign/source/ui/report/SectionView.cxx
@@ -229,23 +229,20 @@ bool OSectionView::IsDragResize() const
 }
 
 
-short OSectionView::GetLayerIdOfMarkedObjects() const
+SdrLayerID OSectionView::GetLayerIdOfMarkedObjects() const
 {
-    short nRet = SHRT_MAX;
+    SdrLayerID nRet = SDRLAYER_NOTFOUND;
     const SdrMarkList &rMrkList = GetMarkedObjectList();
     for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
     {
         const SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
-        if ( nRet == SHRT_MAX )
+        if ( nRet == SDRLAYER_NOTFOUND )
             nRet = pObj->GetLayer();
         else if ( nRet != pObj->GetLayer() )
         {
-            nRet = -1;
             break;
         }
     }
-    if ( nRet == SHRT_MAX )
-        nRet = -1;
     return nRet;
 }
 
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index 00f87cac0e35..1c67775099cb 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -22,6 +22,7 @@
 
 #include "address.hxx"
 #include <i18nlangtag/lang.h>
+#include <svx/svdtypes.hxx>
 #include <tools/stream.hxx>
 #include <com/sun/star/uno/Reference.hxx>
 #include "scdllapi.h"
@@ -204,12 +205,13 @@ namespace o3tl {
 
 #define EMPTY_OUSTRING ScGlobal::GetEmptyOUString()
 
-                                        //  layer id's for drawing
-#define SC_LAYER_FRONT      0
-#define SC_LAYER_BACK       1
-#define SC_LAYER_INTERN     2
-#define SC_LAYER_CONTROLS   3
-#define SC_LAYER_HIDDEN     4
+// Layer id's for drawing.
+// These are both id's and positions.
+constexpr SdrLayerID SC_LAYER_FRONT   (0);
+constexpr SdrLayerID SC_LAYER_BACK    (1);
+constexpr SdrLayerID SC_LAYER_INTERN  (2);
+constexpr SdrLayerID SC_LAYER_CONTROLS(3);
+constexpr SdrLayerID SC_LAYER_HIDDEN  (4);
 
 //  link tables
 enum class ScLinkMode {
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 2591334b6cfc..47d397c0d2b0 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -284,11 +284,11 @@ ScDrawLayer::ScDrawLayer( ScDocument* pDocument, const OUString& rName ) :
     rPool.FreezeIdRanges();                         // the pool is also used directly
 
     SdrLayerAdmin& rAdmin = GetLayerAdmin();
-    rAdmin.NewLayer("vorne",    SC_LAYER_FRONT);
-    rAdmin.NewLayer("hinten",   SC_LAYER_BACK);
-    rAdmin.NewLayer("intern",   SC_LAYER_INTERN);
-    rAdmin.NewLayer("Controls", SC_LAYER_CONTROLS);
-    rAdmin.NewLayer("hidden",   SC_LAYER_HIDDEN);
+    rAdmin.NewLayer("vorne",    sal_uInt8(SC_LAYER_FRONT));
+    rAdmin.NewLayer("hinten",   sal_uInt8(SC_LAYER_BACK));
+    rAdmin.NewLayer("intern",   sal_uInt8(SC_LAYER_INTERN));
+    rAdmin.NewLayer("Controls", sal_uInt8(SC_LAYER_CONTROLS));
+    rAdmin.NewLayer("hidden",   sal_uInt8(SC_LAYER_HIDDEN));
     // "Controls" is new - must also be created when loading
 
     // Set link for URL-Fields
diff --git a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
index 36922cd04326..ce39ad48f2a9 100644
--- a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
+++ b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
@@ -52,15 +52,15 @@ XMLTableShapeImportHelper::~XMLTableShapeImportHelper()
 {
 }
 
-void XMLTableShapeImportHelper::SetLayer(uno::Reference<drawing::XShape>& rShape, sal_Int16 nLayerID, const OUString& sType)
+void XMLTableShapeImportHelper::SetLayer(uno::Reference<drawing::XShape>& rShape, SdrLayerID nLayerID, const OUString& sType)
 {
     if ( sType == "com.sun.star.drawing.ControlShape" )
         nLayerID = SC_LAYER_CONTROLS;
-    if (nLayerID != -1)
+    if (nLayerID != SDRLAYER_NOTFOUND)
     {
         uno::Reference< beans::XPropertySet > xShapeProp( rShape, uno::UNO_QUERY );
         if( xShapeProp.is() )
-            xShapeProp->setPropertyValue( SC_LAYERID, uno::makeAny(nLayerID) );
+            xShapeProp->setPropertyValue( SC_LAYERID, uno::makeAny<sal_uInt16>(sal_uInt8(nLayerID)) );
     }
 }
 
@@ -97,7 +97,7 @@ void XMLTableShapeImportHelper::finishShape(
             sal_Int32 nEndY(-1);
             sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
             std::unique_ptr<OUString> xRangeList;
-            sal_Int16 nLayerID(-1);
+            SdrLayerID nLayerID = SDRLAYER_NOTFOUND;
             for( sal_Int16 i=0; i < nAttrCount; ++i )
             {
                 const OUString& rAttrName(xAttrList->getNameByIndex( i ));
@@ -215,7 +215,7 @@ void XMLTableShapeImportHelper::finishShape(
             }
         }
         sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
-        sal_Int16 nLayerID(-1);
+        SdrLayerID nLayerID = SDRLAYER_NOTFOUND;
         for( sal_Int16 i=0; i < nAttrCount; ++i )
         {
             const OUString& rAttrName(xAttrList->getNameByIndex( i ));
diff --git a/sc/source/filter/xml/XMLTableShapeImportHelper.hxx b/sc/source/filter/xml/XMLTableShapeImportHelper.hxx
index 397f07dcb4b9..b0312049ed07 100644
--- a/sc/source/filter/xml/XMLTableShapeImportHelper.hxx
+++ b/sc/source/filter/xml/XMLTableShapeImportHelper.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_SC_SOURCE_FILTER_XML_XMLTABLESHAPEIMPORTHELPER_HXX
 
 #include <xmloff/shapeimport.hxx>
+#include <svx/svdtypes.hxx>
 #include "address.hxx"
 
 class ScXMLImport;
@@ -37,7 +38,7 @@ public:
     explicit XMLTableShapeImportHelper( ScXMLImport& rImp );
     virtual ~XMLTableShapeImportHelper() override;
 
-    static void SetLayer(css::uno::Reference<css::drawing::XShape>& rShape, sal_Int16 nLayerID, const OUString& sType);
+    static void SetLayer(css::uno::Reference<css::drawing::XShape>& rShape, SdrLayerID nLayerID, const OUString& sType);
     virtual void finishShape(css::uno::Reference< css::drawing::XShape >& rShape,
             const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList,
             css::uno::Reference< css::drawing::XShapes >& rShapes) override;
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 625564e7d13a..f84eaea6488d 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -316,7 +316,7 @@ void ScXMLShapeExport::onExport( const uno::Reference < drawing::XShape >& xShap
     if( xShapeProp.is() )
     {
         sal_Int16 nLayerID = 0;
-        if( (xShapeProp->getPropertyValue( SC_LAYERID ) >>= nLayerID) && (nLayerID == SC_LAYER_BACK) )
+        if( (xShapeProp->getPropertyValue( SC_LAYERID ) >>= nLayerID) && (SdrLayerID(nLayerID) == SC_LAYER_BACK) )
             GetExport().AddAttribute(XML_NAMESPACE_TABLE, XML_TABLE_BACKGROUND, XML_TRUE);
     }
 }
@@ -529,7 +529,7 @@ void ScXMLExport::CollectSharedData(SCTAB& nTableCount, sal_Int32& nShapesCount)
             if (!bExtracted)
                 continue;
 
-            if ((nLayerID == SC_LAYER_INTERN) || (nLayerID == SC_LAYER_HIDDEN))
+            if ((SdrLayerID(nLayerID) == SC_LAYER_INTERN) || (SdrLayerID(nLayerID) == SC_LAYER_HIDDEN))
             {
                 CollectInternalShape(xShape);
                 continue;
diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx
index 791747d0eae5..2fbabe9efa36 100644
--- a/sc/source/ui/Accessibility/AccessibleDocument.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx
@@ -122,16 +122,16 @@ struct ScShapeDataLess
     {
         switch (rLayerID)
         {
-        case SC_LAYER_FRONT:
+        case sal_uInt8(SC_LAYER_FRONT):
             rLayerID = 1;
             break;
-        case SC_LAYER_BACK:
+        case sal_uInt8(SC_LAYER_BACK):
             rLayerID = 0;
             break;
-        case SC_LAYER_INTERN:
+        case sal_uInt8(SC_LAYER_INTERN):
             rLayerID = 2;
             break;
-        case SC_LAYER_CONTROLS:
+        case sal_uInt8(SC_LAYER_CONTROLS):
             rLayerID = 3;
             break;
         }
@@ -146,7 +146,7 @@ struct ScShapeDataLess
             sal_Int16 nLayerID = 0;
             if( (aPropAny >>= nLayerID) )
             {
-                if (nLayerID == SC_LAYER_BACK)
+                if (SdrLayerID(nLayerID) == SC_LAYER_BACK)
                     bResult = true;
             }
         }
@@ -1230,7 +1230,7 @@ void ScChildrenShapes::AddShape(const uno::Reference<drawing::XShape>& xShape, b
             sal_Int16 nLayerID = 0;
             if( aPropAny >>= nLayerID )
             {
-                if( (nLayerID == SC_LAYER_INTERN) || (nLayerID == SC_LAYER_HIDDEN) )
+                if( (SdrLayerID(nLayerID) == SC_LAYER_INTERN) || (SdrLayerID(nLayerID) == SC_LAYER_HIDDEN) )
                     pShape->bSelectable = false;
                 else
                     pShape->bSelectable = true;
diff --git a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
index ec81ed09dd42..21e84ddaaca7 100644
--- a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
@@ -1060,32 +1060,24 @@ void ScShapeChildren::FillShapes(const tools::Rectangle& aPixelPaintRect, const
                         ScShapeChild aShape;
                         aShape.mxShape = xShape;
                         aShape.mnRangeId = nRangeId;
-                        switch (pObj->GetLayer())
+                        if (pObj->GetLayer().anyOf(SC_LAYER_INTERN, SC_LAYER_FRONT))
                         {
-                            case SC_LAYER_INTERN:
-                            case SC_LAYER_FRONT:
-                            {
-                                maShapeRanges[nRangeId].maForeShapes.push_back(aShape);
-                                bForeAdded = true;
-                            }
-                            break;
-                            case SC_LAYER_BACK:
-                            {
-                                maShapeRanges[nRangeId].maBackShapes.push_back(aShape);
-                                bBackAdded = true;
-                            }
-                            break;
-                            case SC_LAYER_CONTROLS:
-                            {
-                                maShapeRanges[nRangeId].maControls.push_back(aShape);
-                                bControlAdded = true;
-                            }
-                            break;
-                            default:
-                            {
-                                OSL_FAIL("I don't know this layer.");
-                            }
-                            break;
+                            maShapeRanges[nRangeId].maForeShapes.push_back(aShape);
+                            bForeAdded = true;
+                        }
+                        else if (pObj->GetLayer() == SC_LAYER_BACK)
+                        {
+                            maShapeRanges[nRangeId].maBackShapes.push_back(aShape);
+                            bBackAdded = true;
+                        }
+                        else if (pObj->GetLayer() == SC_LAYER_CONTROLS)
+                        {
+                            maShapeRanges[nRangeId].maControls.push_back(aShape);
+                            bControlAdded = true;
+                        }
+                        else
+                        {
+                            OSL_FAIL("I don't know this layer.");
                         }
                     }
                 }
diff --git a/sc/source/ui/drawfunc/drawsh2.cxx b/sc/source/ui/drawfunc/drawsh2.cxx
index a92397a112f5..02215b8e1093 100644
--- a/sc/source/ui/drawfunc/drawsh2.cxx
+++ b/sc/source/ui/drawfunc/drawsh2.cxx
@@ -373,7 +373,7 @@ void ScDrawShell::GetAttrFuncState(SfxItemSet &rSet)
         rSet.DisableItem( SID_ATTRIBUTES_AREA );
 }
 
-bool ScDrawShell::AreAllObjectsOnLayer(sal_uInt16 nLayerNo,const SdrMarkList& rMark)
+bool ScDrawShell::AreAllObjectsOnLayer(SdrLayerID nLayerNo,const SdrMarkList& rMark)
 {
     bool bResult=true;
     const size_t nCount = rMark.GetMarkCount();
diff --git a/sc/source/ui/inc/drawsh.hxx b/sc/source/ui/inc/drawsh.hxx
index 0da1b1532f05..b1955160e734 100644
--- a/sc/source/ui/inc/drawsh.hxx
+++ b/sc/source/ui/inc/drawsh.hxx
@@ -24,6 +24,7 @@
 #include "shellids.hxx"
 #include <sfx2/module.hxx>
 #include <svx/svdmark.hxx>
+#include <svx/svdtypes.hxx>
 #include <tools/link.hxx>
 #include <rtl/ref.hxx>
 
@@ -84,7 +85,7 @@ public:
 
     ScDrawView* GetDrawView();
 
-    static bool AreAllObjectsOnLayer(sal_uInt16 nLayerNo,const SdrMarkList& rMark);
+    static bool AreAllObjectsOnLayer(SdrLayerID nLayerNo,const SdrMarkList& rMark);
 
     void GetDrawAttrStateForIFBX( SfxItemSet& rSet );
     ::rtl::OUString GetSidebarContextName();
diff --git a/sc/source/ui/inc/drawview.hxx b/sc/source/ui/inc/drawview.hxx
index f60d99d83e28..b747207d5e2b 100644
--- a/sc/source/ui/inc/drawview.hxx
+++ b/sc/source/ui/inc/drawview.hxx
@@ -84,7 +84,7 @@ public:
 
     void            MarkDropObj( SdrObject* pObj );
 
-    void            SetMarkedToLayer( sal_uInt8 nLayerNo );
+    void            SetMarkedToLayer( SdrLayerID nLayerNo );
 
     void            InvalidateAttribs();
     void            InvalidateDrawTextAttrs();
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 289640098e6b..ac90b1a14287 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -255,7 +255,7 @@ class ScGridWindow : public vcl::Window, public DropTargetHelper, public DragSou
     SdrObject*      GetEditObject();
     bool            IsMyModel(SdrEditView* pSdrView);
 
-    void            DrawRedraw( ScOutputData& rOutputData, sal_uLong nLayer );
+    void            DrawRedraw( ScOutputData& rOutputData, SdrLayerID nLayer );
     void            DrawSdrGrid( const tools::Rectangle& rDrawingRect, OutputDevice* pContentDev );
     void            DrawAfterScroll();
     tools::Rectangle       GetListValButtonRect( const ScAddress& rButtonPos );
diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx
index 26dad1add045..c5bc27d82e86 100644
--- a/sc/source/ui/inc/output.hxx
+++ b/sc/source/ui/inc/output.hxx
@@ -314,12 +314,12 @@ public:
     void    DrawClear();
 
     // #i72502# printer only command set
-    Point PrePrintDrawingLayer(long nLogStX, long nLogStY );
-    void PostPrintDrawingLayer(const Point& rMMOffset); // #i74768# need offset for FormLayer
-    void PrintDrawingLayer(const sal_uInt16 nLayer, const Point& rMMOffset);
+    Point   PrePrintDrawingLayer(long nLogStX, long nLogStY );
+    void    PostPrintDrawingLayer(const Point& rMMOffset); // #i74768# need offset for FormLayer
+    void    PrintDrawingLayer(SdrLayerID nLayer, const Point& rMMOffset);
 
     // only screen:
-    void    DrawSelectiveObjects(const sal_uInt16 nLayer);
+    void    DrawSelectiveObjects(SdrLayerID nLayer);
 
     bool    SetChangedClip();       // sal_False = not
     vcl::Region  GetChangedAreaRegion();
diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx
index 1758f7d8a062..e8b2e064bd85 100644
--- a/sc/source/ui/view/drawview.cxx
+++ b/sc/source/ui/view/drawview.cxx
@@ -209,7 +209,7 @@ void ScDrawView::InvalidateDrawTextAttrs()
     rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
 }
 
-void ScDrawView::SetMarkedToLayer( sal_uInt8 nLayerNo )
+void ScDrawView::SetMarkedToLayer( SdrLayerID nLayerNo )
 {
     if (AreObjectsMarked())
     {
@@ -224,7 +224,7 @@ void ScDrawView::SetMarkedToLayer( sal_uInt8 nLayerNo )
             SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj();
             if ( dynamic_cast<const SdrUnoObj*>( pObj) ==  nullptr && (pObj->GetLayer() != SC_LAYER_INTERN) )
             {
-                AddUndo( new SdrUndoObjectLayerChange( *pObj, pObj->GetLayer(), (SdrLayerID)nLayerNo) );
+                AddUndo( new SdrUndoObjectLayerChange( *pObj, pObj->GetLayer(), nLayerNo) );
                 pObj->SetLayer( nLayerNo );
             }
         }
diff --git a/sc/source/ui/view/gridwin3.cxx b/sc/source/ui/view/gridwin3.cxx
index cb15a6a40476..3383f18d0720 100644
--- a/sc/source/ui/view/gridwin3.cxx
+++ b/sc/source/ui/view/gridwin3.cxx
@@ -185,7 +185,7 @@ bool ScGridWindow::DrawKeyInput(const KeyEvent& rKEvt)
     return false;
 }
 
-void ScGridWindow::DrawRedraw( ScOutputData& rOutputData, sal_uLong nLayer )
+void ScGridWindow::DrawRedraw( ScOutputData& rOutputData, SdrLayerID nLayer )
 {
     const ScViewOptions& rOpts = pViewData->GetOptions();
 
@@ -206,7 +206,7 @@ void ScGridWindow::DrawRedraw( ScOutputData& rOutputData, sal_uLong nLayer )
             pDrView->setHideFormControl(!bDrawDraw);
         }
 
-        rOutputData.DrawSelectiveObjects((sal_uInt16)nLayer);
+        rOutputData.DrawSelectiveObjects(nLayer);
     }
 }
 
diff --git a/sc/source/ui/view/output3.cxx b/sc/source/ui/view/output3.cxx
index 55f2aad1fa5f..168879acaed5 100644
--- a/sc/source/ui/view/output3.cxx
+++ b/sc/source/ui/view/output3.cxx
@@ -131,7 +131,7 @@ void ScOutputData::PostPrintDrawingLayer(const Point& rMMOffset) // #i74768#
 }
 
 // #i72502#
-void ScOutputData::PrintDrawingLayer(const sal_uInt16 nLayer, const Point& rMMOffset)
+void ScOutputData::PrintDrawingLayer(SdrLayerID nLayer, const Point& rMMOffset)
 {
     bool bHideAllDrawingLayer(false);
 
@@ -166,7 +166,7 @@ void ScOutputData::PrintDrawingLayer(const sal_uInt16 nLayer, const Point& rMMOf
     }
 }
 
-void ScOutputData::DrawSelectiveObjects(const sal_uInt16 nLayer)
+void ScOutputData::DrawSelectiveObjects(SdrLayerID nLayer)
 {
     ScDrawLayer* pModel = mpDoc->GetDrawLayer();
     if (!pModel)
diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx
index 3431ba90b026..baa71139cce2 100644
--- a/sd/source/core/drawdoc2.cxx
+++ b/sd/source/core/drawdoc2.cxx
@@ -1346,9 +1346,9 @@ sal_uInt16 SdDrawDocument::DuplicatePage (sal_uInt16 nPageNum)
 
     // Get background flags
     SdrLayerAdmin& rLayerAdmin = GetLayerAdmin();
-    sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND));
-    sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
-    SetOfByte aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers();
+    SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND));
+    SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
+    SdrLayerIDSet aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers();
 
     return DuplicatePage (
         pActualPage, ePageKind,
@@ -1490,9 +1490,9 @@ void SdDrawDocument::SetupNewPage (
     if (pPreviousPage != nullptr)
     {
         SdrLayerAdmin& rLayerAdmin = GetLayerAdmin();
-        sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND));
-        sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
-        SetOfByte aVisibleLayers = pPreviousPage->TRG_GetMasterPageVisibleLayers();
+        SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND));
+        SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
+        SdrLayerIDSet aVisibleLayers = pPreviousPage->TRG_GetMasterPageVisibleLayers();
         aVisibleLayers.Set(aBckgrnd, bIsPageBack);
         aVisibleLayers.Set(aBckgrndObj, bIsPageObj);
         pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index d0220f6b631f..f334f155d2e3 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -1691,13 +1691,13 @@ void SdPage::NbcInsertObject(SdrObject* pObj, size_t nPos)
     SdrLayerID nId = pObj->GetLayer();
     if( mbMaster )
     {
-        if( nId == 0 )
-            pObj->NbcSetLayer( 2 );     // wrong layer. corrected to BackgroundObj layer
+        if( nId == SdrLayerID(0) )
+            pObj->NbcSetLayer( SdrLayerID(2) );     // wrong layer. corrected to BackgroundObj layer
     }
     else
     {
-        if( nId == 2 )
-            pObj->NbcSetLayer( 0 );     // wrong layer. corrected to layout layer
+        if( nId == SdrLayerID(2) )
+            pObj->NbcSetLayer( SdrLayerID(0) );     // wrong layer. corrected to layout layer
     }
 }
 
diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index 8af77d0965f8..0101a5243034 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -1519,7 +1519,7 @@ void ImplSdPPTImport::ImportPageEffect( SdPage* pPage, const bool bNewAnimations
             {
                 if(pPage->TRG_HasMasterPage())
                 {
-                    SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
+                    SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
                     aVisibleLayers.Set(mnBackgroundObjectsLayerID, false);
                     pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
                 }
diff --git a/sd/source/ui/dlg/LayerTabBar.cxx b/sd/source/ui/dlg/LayerTabBar.cxx
index 3d77b676884b..a62a59603403 100644
--- a/sd/source/ui/dlg/LayerTabBar.cxx
+++ b/sd/source/ui/dlg/LayerTabBar.cxx
@@ -128,9 +128,9 @@ sal_Int8 LayerTabBar::AcceptDrop( const AcceptDropEvent& rEvt )
 
     if( !pDrViewSh->GetDocSh()->IsReadOnly() )
     {
-        sal_uInt16          nPageId = SDRPAGE_NOTFOUND;
-        Point           aPos( PixelToLogic( rEvt.maPosPixel ) );
-        sal_uInt16 nLayerId = pDrViewSh->GetView()->GetDoc().GetLayerAdmin().GetLayerID(
+        sal_uInt16    nPageId = SDRPAGE_NOTFOUND;
+        Point         aPos( PixelToLogic( rEvt.maPosPixel ) );
+        SdrLayerID    nLayerId = pDrViewSh->GetView()->GetDoc().GetLayerAdmin().GetLayerID(
             GetPageText( GetPageId( aPos ) ) );
 
         nRet = pDrViewSh->AcceptDrop( rEvt, *this, nullptr, nPageId, nLayerId );
@@ -146,8 +146,8 @@ sal_Int8 LayerTabBar::AcceptDrop( const AcceptDropEvent& rEvt )
  */
 sal_Int8 LayerTabBar::ExecuteDrop( const ExecuteDropEvent& rEvt )
 {
-    sal_uInt16          nPageId = SDRPAGE_NOTFOUND;
-    sal_uInt16 nLayerId = pDrViewSh->GetView()->GetDoc().GetLayerAdmin().GetLayerID(
+    sal_uInt16      nPageId = SDRPAGE_NOTFOUND;
+    SdrLayerID      nLayerId = pDrViewSh->GetView()->GetDoc().GetLayerAdmin().GetLayerID(
         GetPageText( GetPageId( PixelToLogic( rEvt.maPosPixel ) ) ) );
     sal_Int8        nRet = pDrViewSh->ExecuteDrop( rEvt, *this, nullptr, nPageId, nLayerId );
 
diff --git a/sd/source/ui/func/fudraw.cxx b/sd/source/ui/func/fudraw.cxx
index 404b3be53d65..d82d59beca5f 100644
--- a/sd/source/ui/func/fudraw.cxx
+++ b/sd/source/ui/func/fudraw.cxx
@@ -603,7 +603,7 @@ bool FuDraw::SetPointer(SdrObject* pObj, const Point& rPos)
 
     if (bAnimationInfo || bImageMapInfo)
     {
-        const SetOfByte* pVisiLayer = &mpView->GetSdrPageView()->GetVisibleLayers();
+        const SdrLayerIDSet* pVisiLayer = &mpView->GetSdrPageView()->GetVisibleLayers();
         sal_uInt16 nHitLog(sal_uInt16 (mpWindow->PixelToLogic(Size(HITPIX,0)).Width()));
         long  n2HitLog(nHitLog * 2);
         Point aHitPosR(rPos);
diff --git a/sd/source/ui/func/fuexpand.cxx b/sd/source/ui/func/fuexpand.cxx
index f49a3885a844..c89b10289879 100644
--- a/sd/source/ui/func/fuexpand.cxx
+++ b/sd/source/ui/func/fuexpand.cxx
@@ -99,7 +99,7 @@ void FuExpandPage::DoExecute( SfxRequest& )
         pOutl->SetDefTab( mpDoc->GetDefaultTabulator() );
         pOutl->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(mpDoc->GetStyleSheetPool()));
 
-        SetOfByte aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers();
+        SdrLayerIDSet aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers();
         sal_uInt16 nActualPageNum = pActualPage->GetPageNum();
         SdPage* pActualNotesPage = static_cast<SdPage*>(mpDoc->GetPage(nActualPageNum + 1));
         SdrTextObj* pActualOutline = static_cast<SdrTextObj*>(pActualPage->GetPresObj(PRESOBJ_OUTLINE));
diff --git a/sd/source/ui/func/fusel.cxx b/sd/source/ui/func/fusel.cxx
index 846b2e208cc5..29e0e4490ce7 100644
--- a/sd/source/ui/func/fusel.cxx
+++ b/sd/source/ui/func/fusel.cxx
@@ -1202,7 +1202,7 @@ bool FuSelection::AnimateObj(SdrObject* pObj, const Point& rPos)
         bFilled = rFillStyle.GetValue() != drawing::FillStyle_NONE;
     }
 
-    const SetOfByte* pVisiLayer = &mpView->GetSdrPageView()->GetVisibleLayers();
+    const SdrLayerIDSet* pVisiLayer = &mpView->GetSdrPageView()->GetVisibleLayers();
     sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
     const long  n2HitLog = nHitLog * 2;
     Point aHitPosR(rPos);
diff --git a/sd/source/ui/func/fusumry.cxx b/sd/source/ui/func/fusumry.cxx
index e6a63b0f654e..e6377d7d1b1d 100644
--- a/sd/source/ui/func/fusumry.cxx
+++ b/sd/source/ui/func/fusumry.cxx
@@ -116,7 +116,7 @@ void FuSummaryPage::DoExecute( SfxRequest& )
                         bBegUndo = true;
                     }
 
-                    SetOfByte aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers();
+                    SdrLayerIDSet aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers();
 
                     // page with title & structuring!
                     pSummaryPage = mpDoc->AllocSdPage(false);
diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx
index d42b514753d3..3b5377deb9f4 100644
--- a/sd/source/ui/inc/DrawViewShell.hxx
+++ b/sd/source/ui/inc/DrawViewShell.hxx
@@ -283,9 +283,9 @@ public:
     bool            IsLayerModeActive() const { return mbIsLayerModeActive;}
 
     virtual sal_Int8    AcceptDrop( const AcceptDropEvent& rEvt, DropTargetHelper& rTargetHelper,
-                                    ::sd::Window* pTargetWindow, sal_uInt16 nPage, sal_uInt16 nLayer ) override;
+                                    ::sd::Window* pTargetWindow, sal_uInt16 nPage, SdrLayerID nLayer ) override;
     virtual sal_Int8    ExecuteDrop( const ExecuteDropEvent& rEvt, DropTargetHelper& rTargetHelper,
-                                    ::sd::Window* pTargetWindow, sal_uInt16 nPage, sal_uInt16 nLayer ) override;
+                                    ::sd::Window* pTargetWindow, sal_uInt16 nPage, SdrLayerID nLayer ) override;
 
     virtual void    WriteUserDataSequence ( css::uno::Sequence < css::beans::PropertyValue >&, bool bBrowse ) override;
     virtual void    ReadUserDataSequence ( const css::uno::Sequence < css::beans::PropertyValue >&, bool bBrowse ) override;
diff --git a/sd/source/ui/inc/FrameView.hxx b/sd/source/ui/inc/FrameView.hxx
index 4ae22cc04c2d..6186a363f146 100644
--- a/sd/source/ui/inc/FrameView.hxx
+++ b/sd/source/ui/inc/FrameView.hxx
@@ -55,17 +55,17 @@ public:
                              { maHandoutHelpLines = rHelpLines; }
     const SdrHelpLineList& GetHandoutHelpLines() { return maHandoutHelpLines; }
 
-    void SetVisibleLayers(const SetOfByte& rVisibleLayers)
+    void SetVisibleLayers(const SdrLayerIDSet& rVisibleLayers)
                          { maVisibleLayers = rVisibleLayers; }
-    const SetOfByte& GetVisibleLayers() { return maVisibleLayers; }
+    const SdrLayerIDSet& GetVisibleLayers() { return maVisibleLayers; }
 
-    void SetLockedLayers(const SetOfByte& rLockedLayers)
+    void SetLockedLayers(const SdrLayerIDSet& rLockedLayers)
                         { maLockedLayers = rLockedLayers; }
-    const SetOfByte& GetLockedLayers() { return maLockedLayers; }
+    const SdrLayerIDSet& GetLockedLayers() { return maLockedLayers; }
 
-    void SetPrintableLayers(const SetOfByte& rPrintableLayers)
+    void SetPrintableLayers(const SdrLayerIDSet& rPrintableLayers)
                          { maPrintableLayers = rPrintableLayers; }
-    const SetOfByte& GetPrintableLayers() { return maPrintableLayers; }
+    const SdrLayerIDSet& GetPrintableLayers() { return maPrintableLayers; }
 
     void SetRuler(const bool bRulerOn)
                  { mbRuler = bRulerOn; }
@@ -171,9 +171,9 @@ public:
 private:
     sal_uInt16          mnRefCount;
     bool                mbRuler;
-    SetOfByte           maVisibleLayers;
-    SetOfByte           maLockedLayers;
-    SetOfByte           maPrintableLayers;
+    SdrLayerIDSet           maVisibleLayers;
+    SdrLayerIDSet           maLockedLayers;
+    SdrLayerIDSet           maPrintableLayers;
     SdrHelpLineList     maStandardHelpLines;
     SdrHelpLineList     maNotesHelpLines;
     SdrHelpLineList     maHandoutHelpLines;
diff --git a/sd/source/ui/inc/OutlineView.hxx b/sd/source/ui/inc/OutlineView.hxx
index 27a17bb07a81..7bbd68a47510 100644
--- a/sd/source/ui/inc/OutlineView.hxx
+++ b/sd/source/ui/inc/OutlineView.hxx
@@ -128,12 +128,12 @@ public:
         DropTargetHelper& rTargetHelper,
         ::sd::Window* pTargetWindow,
         sal_uInt16 nPage,
-        sal_uInt16 nLayer) override;
+        SdrLayerID nLayer) override;
     virtual sal_Int8 ExecuteDrop (
         const ExecuteDropEvent& rEvt,
         ::sd::Window* pTargetWindow,
         sal_uInt16 nPage,
-        sal_uInt16 nLayer) override;
+        SdrLayerID nLayer) override;
 
     // Re-implement GetScriptType for this view to get correct results
     virtual SvtScriptType GetScriptType() const override;
diff --git a/sd/source/ui/inc/SlideSorterViewShell.hxx b/sd/source/ui/inc/SlideSorterViewShell.hxx
index c29b295bfb16..5f3e4c284756 100644
--- a/sd/source/ui/inc/SlideSorterViewShell.hxx
+++ b/sd/source/ui/inc/SlideSorterViewShell.hxx
@@ -140,13 +140,13 @@ public:
         DropTargetHelper& rTargetHelper,
         ::sd::Window* pTargetWindow,
         sal_uInt16 nPage,
-        sal_uInt16 nLayer ) override;
+        SdrLayerID nLayer ) override;
     virtual sal_Int8 ExecuteDrop (
         const ExecuteDropEvent& rEvt,
         DropTargetHelper& rTargetHelper,
         ::sd::Window* pTargetWindow,
         sal_uInt16 nPage,
-        sal_uInt16 nLayer) override;
+        SdrLayerID nLayer) override;
 
     typedef ::std::vector<SdPage*> PageSelection;
 
diff --git a/sd/source/ui/inc/View.hxx b/sd/source/ui/inc/View.hxx
index 58915b3e5149..d1fda4c1d417 100644
--- a/sd/source/ui/inc/View.hxx
+++ b/sd/source/ui/inc/View.hxx
@@ -102,12 +102,12 @@ public:
         DropTargetHelper& rTargetHelper,
         ::sd::Window* pTargetWindow,
         sal_uInt16 nPage,
-        sal_uInt16 nLayer);
+        SdrLayerID nLayer);
     virtual sal_Int8 ExecuteDrop (
         const ExecuteDropEvent& rEvt,
         ::sd::Window* pTargetWindow,
         sal_uInt16 nPage,
-        sal_uInt16 nLayer);
+        SdrLayerID nLayer);
 
     css::uno::Reference<css::datatransfer::XTransferable>
         CreateClipboardDataObject ();
@@ -135,7 +135,7 @@ public:
     bool                    InsertData( const TransferableDataHelper& rDataHelper,
                                         const Point& rPos, sal_Int8& rDnDAction, bool bDrag,
                                         SotClipboardFormatId nFormat = SotClipboardFormatId::NONE,
-                                        sal_uInt16 nPage = SDRPAGE_NOTFOUND, sal_uInt16 nLayer = SDRLAYER_NOTFOUND );
+                                        sal_uInt16 nPage = SDRPAGE_NOTFOUND, SdrLayerID nLayer = SDRLAYER_NOTFOUND );
     /** gets the metafile from the given transferable helper and insert it as a graphic shape.
         @param bOptimize if set to true, the metafile is analyzed and if only one bitmap action is
                          present, then is inserted as a single graphic.
diff --git a/sd/source/ui/inc/ViewShell.hxx b/sd/source/ui/inc/ViewShell.hxx
index 7fcc96cdff92..e736bb1982d9 100644
--- a/sd/source/ui/inc/ViewShell.hxx
+++ b/sd/source/ui/inc/ViewShell.hxx
@@ -273,9 +273,9 @@ public:
     void GetMenuState(SfxItemSet& rSet);
 
     virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt, DropTargetHelper& rTargetHelper,
-                                 ::sd::Window* pTargetWindow, sal_uInt16 nPage, sal_uInt16 nLayer );
+                                 ::sd::Window* pTargetWindow, sal_uInt16 nPage, SdrLayerID nLayer );
     virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt, DropTargetHelper& rTargetHelper,
-                                  ::sd::Window* pTargetWindow, sal_uInt16 nPage, sal_uInt16 nLayer );
+                                  ::sd::Window* pTargetWindow, sal_uInt16 nPage, SdrLayerID nLayer );
 
     virtual void WriteUserDataSequence ( css::uno::Sequence < css::beans::PropertyValue >&, bool bBrowse );
     virtual void ReadUserDataSequence ( const css::uno::Sequence < css::beans::PropertyValue >&, bool bBrowse );
diff --git a/sd/source/ui/sidebar/LayoutMenu.cxx b/sd/source/ui/sidebar/LayoutMenu.cxx
index 51ec16651ba1..93159a16beae 100644
--- a/sd/source/ui/sidebar/LayoutMenu.cxx
+++ b/sd/source/ui/sidebar/LayoutMenu.cxx
@@ -467,9 +467,9 @@ SfxRequest LayoutMenu::CreateRequest (
     do
     {
         SdrLayerAdmin& rLayerAdmin (mrBase.GetDocument()->GetLayerAdmin());
-        sal_uInt8 aBackground (rLayerAdmin.GetLayerID(
+        SdrLayerID aBackground (rLayerAdmin.GetLayerID(
             SD_RESSTR(STR_LAYER_BCKGRND)));
-        sal_uInt8 aBackgroundObject (rLayerAdmin.GetLayerID(
+        SdrLayerID aBackgroundObject (rLayerAdmin.GetLayerID(
             SD_RESSTR(STR_LAYER_BCKGRNDOBJ)));
         ViewShell* pViewShell = mrBase.GetMainViewShell().get();
         if (pViewShell == nullptr)
@@ -478,7 +478,7 @@ SfxRequest LayoutMenu::CreateRequest (
         if (pPage == nullptr)
             break;
 
-        SetOfByte aVisibleLayers (pPage->TRG_GetMasterPageVisibleLayers());
+        SdrLayerIDSet aVisibleLayers (pPage->TRG_GetMasterPageVisibleLayers());
 
         aRequest.AppendItem(
             SfxStringItem (ID_VAL_PAGENAME, OUString()));//pPage->GetName()));
diff --git a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
index d69a340e67d0..4f3d4d23e5c8 100644
--- a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
@@ -632,7 +632,7 @@ sal_Int8 Clipboard::AcceptDrop (
     DropTargetHelper& rTargetHelper,
     ::sd::Window* pTargetWindow,
     sal_uInt16 nPage,
-    sal_uInt16 nLayer)
+    SdrLayerID nLayer)
 {
     sal_Int8 nAction (DND_ACTION_NONE);
 
@@ -700,7 +700,7 @@ sal_Int8 Clipboard::ExecuteDrop (
     DropTargetHelper& rTargetHelper,
     ::sd::Window* pTargetWindow,
     sal_uInt16 nPage,
-    sal_uInt16 nLayer)
+    SdrLayerID nLayer)
 {
     sal_Int8 nResult = DND_ACTION_NONE;
     mxUndoContext.reset();
@@ -886,7 +886,7 @@ sal_Int8 Clipboard::ExecuteOrAcceptShapeDrop (
     DropTargetHelper& rTargetHelper,
     ::sd::Window* pTargetWindow,
     sal_uInt16 nPage,
-    sal_uInt16 nLayer)
+    SdrLayerID nLayer)
 {
     sal_Int8 nResult = 0;
 
diff --git a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx
index b4dfa803e5db..aef29161a600 100644
--- a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx
@@ -946,9 +946,9 @@ bool SlotManager::RenameSlideFromDrawViewShell( sal_uInt16 nPageId, const OUStri
             // Undo
             SdPage* pUndoPage = pPageToRename;
             SdrLayerAdmin &  rLayerAdmin = pDocument->GetLayerAdmin();
-            sal_uInt8 nBackground = rLayerAdmin.GetLayerID( SD_RESSTR( STR_LAYER_BCKGRND ) );
-            sal_uInt8 nBgObj = rLayerAdmin.GetLayerID( SD_RESSTR( STR_LAYER_BCKGRNDOBJ ) );
-            SetOfByte aVisibleLayers = pPageToRename->TRG_GetMasterPageVisibleLayers();
+            SdrLayerID nBackground = rLayerAdmin.GetLayerID( SD_RESSTR( STR_LAYER_BCKGRND ) );
+            SdrLayerID nBgObj = rLayerAdmin.GetLayerID( SD_RESSTR( STR_LAYER_BCKGRNDOBJ ) );
+            SdrLayerIDSet aVisibleLayers = pPageToRename->TRG_GetMasterPageVisibleLayers();
 
             // (#67720#)
             ModifyPageUndoAction* pAction = new ModifyPageUndoAction(
diff --git a/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx b/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx
index bc0ce0836174..03d981e3c957 100644
--- a/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx
+++ b/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx
@@ -92,14 +92,14 @@ public:
         DropTargetHelper& rTargetHelper,
         ::sd::Window* pTargetWindow,
         sal_uInt16 nPage,
-        sal_uInt16 nLayer );
+        SdrLayerID nLayer );
 
     sal_Int8 ExecuteDrop (
         const ExecuteDropEvent& rEvt,
         DropTargetHelper& rTargetHelper,
         ::sd::Window* pTargetWindow,
         sal_uInt16 nPage,
-        sal_uInt16 nLayer );
+        SdrLayerID nLayer );
 
     void Abort();
 
@@ -215,7 +215,7 @@ private:
         DropTargetHelper& rTargetHelper,
         ::sd::Window* pTargetWindow,
         sal_uInt16 nPage,
-        sal_uInt16 nLayer);
+        SdrLayerID nLayer);
 
     /** Return whether the insertion defined by the transferable is
         trivial, ie would not change either source nor target document.
diff --git a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx
index 1f015f1ae9bc..ef7d146c8d9d 100644
--- a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx
+++ b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx
@@ -643,7 +643,7 @@ sal_Int8 SlideSorterViewShell::AcceptDrop (
     DropTargetHelper& rTargetHelper,
     ::sd::Window* pTargetWindow,
     sal_uInt16 nPage,
-    sal_uInt16 nLayer)
+    SdrLayerID nLayer)
 {
     OSL_ASSERT(mpSlideSorter.get()!=nullptr);
     return mpSlideSorter->GetController().GetClipboard().AcceptDrop (
@@ -659,7 +659,7 @@ sal_Int8 SlideSorterViewShell::ExecuteDrop (
     DropTargetHelper& rTargetHelper,
     ::sd::Window* pTargetWindow,
     sal_uInt16 nPage,
-    sal_uInt16 nLayer)
+    SdrLayerID nLayer)
 {
     OSL_ASSERT(mpSlideSorter.get()!=nullptr);
     return mpSlideSorter->GetController().GetClipboard().ExecuteDrop (
diff --git a/sd/source/ui/unoidl/unolayer.cxx b/sd/source/ui/unoidl/unolayer.cxx
index 3ce581a80ef7..aa2d98380918 100644
--- a/sd/source/ui/unoidl/unolayer.cxx
+++ b/sd/source/ui/unoidl/unolayer.cxx
@@ -351,7 +351,7 @@ void SdLayer::set( LayerAttribute what, bool flag ) throw()
 
             if(pFrameView)
             {
-                SetOfByte aNewLayers;
+                SdrLayerIDSet aNewLayers;
                 switch(what)
                 {
                 case VISIBLE:   aNewLayers = pFrameView->GetVisibleLayers();
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index b86bb4f8b30e..b5c478e549f1 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -468,8 +468,8 @@ SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 nPage, bool bDuplicate )
 {
     sal_uInt16 nPageCount = mpDoc->GetSdPageCount( PageKind::Standard );
     SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
-    sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND));
-    sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
+    SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND));
+    SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
 
     SdPage* pStandardPage = nullptr;
 
@@ -486,7 +486,7 @@ SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 nPage, bool bDuplicate )
     {
         // here we determine the page after which we should insert
         SdPage* pPreviousStandardPage = mpDoc->GetSdPage( std::min( (sal_uInt16)(nPageCount - 1), nPage ), PageKind::Standard );
-        SetOfByte aVisibleLayers = pPreviousStandardPage->TRG_GetMasterPageVisibleLayers();
+        SdrLayerIDSet aVisibleLayers = pPreviousStandardPage->TRG_GetMasterPageVisibleLayers();
         bool bIsPageBack = aVisibleLayers.IsSet( aBckgrnd );
         bool bIsPageObj = aVisibleLayers.IsSet( aBckgrndObj );
 
@@ -1824,7 +1824,7 @@ bool ImplRenderPaintProc::IsVisible( const SdrObject* pObj ) const
     SdrLayerID nLayerId = pObj->GetLayer();
     if( pSdrPageView )
     {
-        const SdrLayer* pSdrLayer = rLayerAdmin.GetLayer( nLayerId );
+        const SdrLayer* pSdrLayer = rLayerAdmin.GetLayerPerID( nLayerId );
         if ( pSdrLayer )
         {
             OUString aLayerName = pSdrLayer->GetName();
@@ -1839,7 +1839,7 @@ bool ImplRenderPaintProc::IsPrintable( const SdrObject* pObj ) const
     SdrLayerID nLayerId = pObj->GetLayer();
     if( pSdrPageView )
     {
-        const SdrLayer* pSdrLayer = rLayerAdmin.GetLayer( nLayerId );
+        const SdrLayer* pSdrLayer = rLayerAdmin.GetLayerPerID( nLayerId );
         if ( pSdrLayer )
         {
             OUString aLayerName = pSdrLayer->GetName();
diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx
index d865abc448e4..72a4025470e7 100644
--- a/sd/source/ui/unoidl/unopage.cxx
+++ b/sd/source/ui/unoidl/unopage.cxx
@@ -792,7 +792,7 @@ void SAL_CALL SdGenericDrawPage::setPropertyValue( const OUString& aPropertyName
                 if( pDoc->GetMasterPageCount() )
                 {
                     SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
-                    SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
+                    SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
                     aVisibleLayers.Set(rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND)), bVisible);
                     pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
                 }
@@ -812,7 +812,7 @@ void SAL_CALL SdGenericDrawPage::setPropertyValue( const OUString& aPropertyName
                 if( pDoc->GetMasterPageCount() )
                 {
                     SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
-                    SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
+                    SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
                     aVisibleLayers.Set(rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ)), bVisible);
                     pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
                 }
@@ -1217,7 +1217,7 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName )
             if( pDoc->GetMasterPageCount() )
             {
                 SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
-                SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
+                SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
                 aAny <<= aVisibleLayers.IsSet(rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND)));
             }
             else
@@ -1236,7 +1236,7 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName )
             if( pDoc->GetMasterPageCount() )
             {
                 SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
-                SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
+                SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
                 aAny <<= aVisibleLayers.IsSet(rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ)));
             }
             else
diff --git a/sd/source/ui/view/DocumentRenderer.cxx b/sd/source/ui/view/DocumentRenderer.cxx
index f1c6d3186a0d..9d29bcac5c99 100644
--- a/sd/source/ui/view/DocumentRenderer.cxx
+++ b/sd/source/ui/view/DocumentRenderer.cxx
@@ -292,8 +292,8 @@ namespace {
         SdPage& rPage,
         View* pView,
         const bool bPrintMarkedOnly,
-        const SetOfByte& rVisibleLayers,
-        const SetOfByte& rPrintableLayers)
+        const SdrLayerIDSet& rVisibleLayers,
+        const SdrLayerIDSet& rPrintableLayers)
     {
         rPrintView.ShowSdrPage(&rPage);
 
@@ -698,8 +698,8 @@ namespace {
             ViewShell& rViewShell,
             View* pView,
             DrawView& rPrintView,
-            const SetOfByte& rVisibleLayers,
-            const SetOfByte& rPrintableLayers) const = 0;
+            const SdrLayerIDSet& rVisibleLayers,
+            const SdrLayerIDSet& rPrintableLayers) const = 0;
 
         DrawModeFlags GetDrawMode() const { return mnDrawMode; }
         Orientation GetOrientation() const { return meOrientation; }
@@ -744,8 +744,8 @@ namespace {
             ViewShell& rViewShell,
             View* pView,
             DrawView& rPrintView,
-            const SetOfByte& rVisibleLayers,
-            const SetOfByte& rPrintableLayers) const override
+            const SdrLayerIDSet& rVisibleLayers,
+            const SdrLayerIDSet& rPrintableLayers) const override
         {
             (void)rViewShell;
             SdPage* pPageToPrint = rDocument.GetSdPage(mnPageIndex, mePageKind);
@@ -795,8 +795,8 @@ namespace {
             ViewShell& rViewShell,
             View* pView,
             DrawView& rPrintView,
-            const SetOfByte& rVisibleLayers,
-            const SetOfByte& rPrintableLayers) const override
+            const SdrLayerIDSet& rVisibleLayers,
+            const SdrLayerIDSet& rPrintableLayers) const override
         {
             (void)rViewShell;
             SdPage* pPageToPrint = rDocument.GetSdPage(mnPageIndex, mePageKind);
@@ -878,8 +878,8 @@ namespace {
             ViewShell& rViewShell,
             View* pView,
             DrawView& rPrintView,
-            const SetOfByte& rVisibleLayers,
-            const SetOfByte& rPrintableLayers) const override
+            const SdrLayerIDSet& rVisibleLayers,
+            const SdrLayerIDSet& rPrintableLayers) const override
         {
             (void)rViewShell;
             MapMode aMap (maMap);
@@ -948,8 +948,8 @@ namespace {
             ViewShell& rViewShell,
             View* pView,
             DrawView& rPrintView,
-            const SetOfByte& rVisibleLayers,
-            const SetOfByte& rPrintableLayers) const override
+            const SdrLayerIDSet& rVisibleLayers,
+            const SdrLayerIDSet& rPrintableLayers) const override
         {
             SdPage& rHandoutPage (*rDocument.GetSdPage(0, PageKind::Handout));
 
@@ -1094,8 +1094,8 @@ namespace {
             ViewShell& rViewShell,
             View* pView,
             DrawView& rPrintView,
-            const SetOfByte& rVisibleLayers,
-            const SetOfByte& rPrintableLayers) const override
+            const SdrLayerIDSet& rVisibleLayers,
+            const SdrLayerIDSet& rPrintableLayers) const override
         {
             (void)rViewShell;
             (void)pView;
diff --git a/sd/source/ui/view/ViewShellImplementation.cxx b/sd/source/ui/view/ViewShellImplementation.cxx
index 581c182049e3..5a9fca237af6 100644
--- a/sd/source/ui/view/ViewShellImplementation.cxx
+++ b/sd/source/ui/view/ViewShellImplementation.cxx
@@ -93,7 +93,7 @@ void ViewShell::Implementation::ProcessModifyPageSlot (
 {
     SdDrawDocument* pDocument = mrViewShell.GetDoc();
     SdrLayerAdmin& rLayerAdmin = pDocument->GetLayerAdmin();
-    SetOfByte aVisibleLayers;
+    SdrLayerIDSet aVisibleLayers;
     bool bHandoutMode = false;
     SdPage* pHandoutMPage = nullptr;
     OUString aNewName;
@@ -198,8 +198,8 @@ void ViewShell::Implementation::ProcessModifyPageSlot (
 
                 pCurrentPage->SetAutoLayout(aNewAutoLayout, true);
 
-                sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND));
-                sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
+                SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND));
+                SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
                 aVisibleLayers.Set(aBckgrnd, bBVisible);
                 aVisibleLayers.Set(aBckgrndObj, bBObjsVisible);
                 pCurrentPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
@@ -259,10 +259,10 @@ void ViewShell::Implementation::AssignLayout ( SfxRequest& rRequest, PageKind eP
         // Transform the given request into the four argument form that is
         // understood by ProcessModifyPageSlot().
         SdrLayerAdmin& rLayerAdmin (mrViewShell.GetViewShellBase().GetDocument()->GetLayerAdmin());
-        sal_uInt8 aBackground (rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND)));
-        sal_uInt8 aBackgroundObject (rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ)));
+        SdrLayerID aBackground (rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND)));
+        SdrLayerID aBackgroundObject (rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ)));
 
-        SetOfByte aVisibleLayers;
+        SdrLayerIDSet aVisibleLayers;
 
         if( pPage->GetPageKind() == PageKind::Handout )
             aVisibleLayers.SetAll();
diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx
index 2ea8063470ab..5007bfff0f52 100644
--- a/sd/source/ui/view/drviews1.cxx
+++ b/sd/source/ui/view/drviews1.cxx
@@ -1140,7 +1140,7 @@ void DrawViewShell::ResetActualLayer()
         // this is needed when one layer is renamed to
         // restore current layer
         sal_uInt16 nOldLayerCnt = pLayerBar->GetPageCount();
-        sal_uInt16 nOldLayerId = pLayerBar->GetCurPageId();
+        sal_uInt16 nOldLayerPos = pLayerBar->GetCurPageId();
 
         /**
          * Update for LayerTab
@@ -1154,17 +1154,17 @@ void DrawViewShell::ResetActualLayer()
         OUString aLayoutLayer = SD_RESSTR(STR_LAYER_LAYOUT);
         OUString aControlsLayer = SD_RESSTR(STR_LAYER_CONTROLS);
         OUString aMeasureLinesLayer = SD_RESSTR(STR_LAYER_MEASURELINES);
-        sal_uInt16 nActiveLayer = SDRLAYER_NOTFOUND;
+        sal_uInt16 nActiveLayerPos = SDRLAYERPOS_NOTFOUND;
         SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
         sal_uInt16 nLayerCnt = rLayerAdmin.GetLayerCount();
 
-        for ( sal_uInt16 nLayer = 0; nLayer < nLayerCnt; nLayer++ )
+        for ( sal_uInt16 nLayerPos = 0; nLayerPos < nLayerCnt; nLayerPos++ )
         {
-            aName = rLayerAdmin.GetLayer(nLayer)->GetName();
+            aName = rLayerAdmin.GetLayer(nLayerPos)->GetName();
 
             if ( aName == aActiveLayer )
             {
-                nActiveLayer = nLayer;
+                nActiveLayerPos = nLayerPos;
             }
 
             if ( aName != aBackgroundLayer )
@@ -1176,7 +1176,7 @@ void DrawViewShell::ResetActualLayer()
                         aName != aControlsLayer &&
                         aName != aMeasureLinesLayer)
                     {
-                        pLayerBar->InsertPage(nLayer+1, aName);
+                        pLayerBar->InsertPage(nLayerPos+1, aName);
 
                         TabBarPageBits nBits = 0;
                         SdrPageView* pPV = mpDrawView->GetSdrPageView();
@@ -1187,7 +1187,7 @@ void DrawViewShell::ResetActualLayer()
                             nBits = TPB_SPECIAL;
                         }
 
-                        pLayerBar->SetPageBits(nLayer+1, nBits);
+                        pLayerBar->SetPageBits(nLayerPos+1, nBits);
                     }
                 }
                 else
@@ -1195,7 +1195,7 @@ void DrawViewShell::ResetActualLayer()
                     // don't show masterpage layer onto the page
                     if ( aName != aBackgroundObjLayer )
                     {
-                        pLayerBar->InsertPage(nLayer+1, aName);
+                        pLayerBar->InsertPage(nLayerPos+1, aName);
 
                         TabBarPageBits nBits = 0;
 
@@ -1205,27 +1205,27 @@ void DrawViewShell::ResetActualLayer()
                             nBits = TPB_SPECIAL;
                         }
 
-                        pLayerBar->SetPageBits(nLayer+1, nBits);
+                        pLayerBar->SetPageBits(nLayerPos+1, nBits);
                     }
                 }
             }
         }
 
-        if ( nActiveLayer == SDRLAYER_NOTFOUND )
+        if ( nActiveLayerPos == SDRLAYERPOS_NOTFOUND )
         {
             if( nOldLayerCnt == pLayerBar->GetPageCount() )
             {
-                nActiveLayer = nOldLayerId - 1;
+                nActiveLayerPos = nOldLayerPos - 1;
             }
             else
             {
-                nActiveLayer = ( meEditMode == EditMode::MasterPage ) ? 2 : 0;
+                nActiveLayerPos = ( meEditMode == EditMode::MasterPage ) ? 2 : 0;
             }
 
-            mpDrawView->SetActiveLayer( pLayerBar->GetPageText(nActiveLayer + 1) );
+            mpDrawView->SetActiveLayer( pLayerBar->GetPageText(nActiveLayerPos + 1) );
         }
 
-        pLayerBar->SetCurPageId(nActiveLayer + 1);
+        pLayerBar->SetCurPageId(nActiveLayerPos + 1);
         GetViewFrame()->GetBindings().Invalidate( SID_MODIFYLAYER );
         GetViewFrame()->GetBindings().Invalidate( SID_DELETE_LAYER );
     }
@@ -1240,7 +1240,7 @@ sal_Int8 DrawViewShell::AcceptDrop (
     DropTargetHelper& rTargetHelper,
     ::sd::Window* pTargetWindow,
     sal_uInt16 nPage,
-    sal_uInt16 nLayer )
+    SdrLayerID nLayer )
 {
     if( nPage != SDRPAGE_NOTFOUND )
         nPage = GetDoc()->GetSdPage( nPage, mePageKind )->GetPageNum();
@@ -1260,7 +1260,7 @@ sal_Int8 DrawViewShell::ExecuteDrop (
     DropTargetHelper& /*rTargetHelper*/,
     ::sd::Window* pTargetWindow,
     sal_uInt16 nPage,
-    sal_uInt16 nLayer)
+    SdrLayerID nLayer)
 {
     if( nPage != SDRPAGE_NOTFOUND )
         nPage = GetDoc()->GetSdPage( nPage, mePageKind )->GetPageNum();
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 3e1a597c4e7f..1ea7eae77139 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -2864,9 +2864,9 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
             if (pPage != nullptr
                 && GetDoc() != nullptr)
             {
-                SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
+                SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
                 SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
-                sal_uInt8 aLayerId;
+                SdrLayerID aLayerId;
                 if (nSId == SID_DISPLAY_MASTER_BACKGROUND)
                     aLayerId = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND));
                 else
diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx
index c71a0641b227..9e9c3bbee364 100644
--- a/sd/source/ui/view/drviews7.cxx
+++ b/sd/source/ui/view/drviews7.cxx
@@ -1520,10 +1520,10 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
         SdPage* pPage = GetActualPage();
         if (pPage != nullptr && GetDoc() != nullptr)
         {
-            SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
+            SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
             SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
-            sal_uInt8 aBackgroundId = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND));
-            sal_uInt8 aObjectId = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
+            SdrLayerID aBackgroundId = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND));
+            SdrLayerID aObjectId = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
             rSet.Put(SfxBoolItem(SID_DISPLAY_MASTER_BACKGROUND,
                     aVisibleLayers.IsSet(aBackgroundId)));
             rSet.Put(SfxBoolItem(SID_DISPLAY_MASTER_OBJECTS,
diff --git a/sd/source/ui/view/drviewsa.cxx b/sd/source/ui/view/drviewsa.cxx
index c623adcb6517..3a97a1b183ed 100644
--- a/sd/source/ui/view/drviewsa.cxx
+++ b/sd/source/ui/view/drviewsa.cxx
@@ -668,7 +668,7 @@ void DrawViewShell::GetStatusBarState(SfxItemSet& rSet)
         if (IsLayerModeActive())
         {
             SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
-            SdrLayerID nLayer = 0, nOldLayer = 0;
+            SdrLayerID nLayer(0), nOldLayer(0);
             SdrObject* pObj = nullptr;
             const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
             const size_t nMarkCount = rMarkList.GetMarkCount();
diff --git a/sd/source/ui/view/drviewsb.cxx b/sd/source/ui/view/drviewsb.cxx
index 8c6a43d8a8dc..a9a60fb35408 100644
--- a/sd/source/ui/view/drviewsb.cxx
+++ b/sd/source/ui/view/drviewsb.cxx
@@ -81,9 +81,9 @@ bool DrawViewShell::RenameSlide( sal_uInt16 nPageId, const OUString & rName  )
         // Undo
         SdPage* pUndoPage = pPageToRename;
         SdrLayerAdmin &  rLayerAdmin = GetDoc()->GetLayerAdmin();
-        sal_uInt8 nBackground = rLayerAdmin.GetLayerID( SD_RESSTR(STR_LAYER_BCKGRND) );
-        sal_uInt8 nBgObj = rLayerAdmin.GetLayerID( SD_RESSTR(STR_LAYER_BCKGRNDOBJ) );
-        SetOfByte aVisibleLayers = mpActualPage->TRG_GetMasterPageVisibleLayers();
+        SdrLayerID nBackground = rLayerAdmin.GetLayerID( SD_RESSTR(STR_LAYER_BCKGRND) );
+        SdrLayerID nBgObj = rLayerAdmin.GetLayerID( SD_RESSTR(STR_LAYER_BCKGRNDOBJ) );
+        SdrLayerIDSet aVisibleLayers = mpActualPage->TRG_GetMasterPageVisibleLayers();
 
         ::svl::IUndoManager* pManager = GetDoc()->GetDocSh()->GetUndoManager();
         ModifyPageUndoAction* pAction = new ModifyPageUndoAction(
diff --git a/sd/source/ui/view/frmview.cxx b/sd/source/ui/view/frmview.cxx
index e64042487324..7572c368074c 100644
--- a/sd/source/ui/view/frmview.cxx
+++ b/sd/source/ui/view/frmview.cxx
@@ -859,21 +859,21 @@ void FrameView::ReadUserDataSequence ( const css::uno::Sequence < css::beans::Pr
             }
             else if (!bImpress && pValue->Name == sUNO_View_VisibleLayers  )
             {
-                SetOfByte aSetOfBytes;
-                aSetOfBytes.PutValue( pValue->Value );
-                SetVisibleLayers( aSetOfBytes );
+                SdrLayerIDSet aSdrLayerIDSets;
+                aSdrLayerIDSets.PutValue( pValue->Value );
+                SetVisibleLayers( aSdrLayerIDSets );
             }
             else if (!bImpress && pValue->Name == sUNO_View_PrintableLayers )
             {
-                SetOfByte aSetOfBytes;
-                aSetOfBytes.PutValue( pValue->Value );
-                SetPrintableLayers( aSetOfBytes );
+                SdrLayerIDSet aSdrLayerIDSets;
+                aSdrLayerIDSets.PutValue( pValue->Value );
+                SetPrintableLayers( aSdrLayerIDSets );
             }
             else if (!bImpress && pValue->Name == sUNO_View_LockedLayers )
             {
-                SetOfByte aSetOfBytes;
-                aSetOfBytes.PutValue( pValue->Value );
-                SetLockedLayers( aSetOfBytes );
+                SdrLayerIDSet aSdrLayerIDSets;
+                aSdrLayerIDSets.PutValue( pValue->Value );
+                SetLockedLayers( aSdrLayerIDSets );
             }
         }
 
diff --git a/sd/source/ui/view/outlview.cxx b/sd/source/ui/view/outlview.cxx
index 3a859aa68662..2a4ce761c013 100644
--- a/sd/source/ui/view/outlview.cxx
+++ b/sd/source/ui/view/outlview.cxx
@@ -1361,12 +1361,12 @@ void OutlineView::ResetLinks() const
     mrOutliner.SetEndPasteOrDropHdl(Link<PasteOrDropInfos*,void>());
 }
 
-sal_Int8 OutlineView::AcceptDrop( const AcceptDropEvent&, DropTargetHelper&, ::sd::Window*, sal_uInt16, sal_uInt16)
+sal_Int8 OutlineView::AcceptDrop( const AcceptDropEvent&, DropTargetHelper&, ::sd::Window*, sal_uInt16, SdrLayerID)
 {
     return DND_ACTION_NONE;
 }
 
-sal_Int8 OutlineView::ExecuteDrop( const ExecuteDropEvent&, ::sd::Window*, sal_uInt16, sal_uInt16)
+sal_Int8 OutlineView::ExecuteDrop( const ExecuteDropEvent&, ::sd::Window*, sal_uInt16, SdrLayerID)
 {
     return DND_ACTION_NONE;
 }
diff --git a/sd/source/ui/view/sdview2.cxx b/sd/source/ui/view/sdview2.cxx
index 76af9466f9d4..41b935b4aa0d 100644
--- a/sd/source/ui/view/sdview2.cxx
+++ b/sd/source/ui/view/sdview2.cxx
@@ -438,7 +438,7 @@ void View::DragFinished( sal_Int8 nDropAction )
 }
 
 sal_Int8 View::AcceptDrop( const AcceptDropEvent& rEvt, DropTargetHelper& rTargetHelper,
-                             ::sd::Window*, sal_uInt16, sal_uInt16 nLayer )
+                             ::sd::Window*, sal_uInt16, SdrLayerID nLayer )
 {
     OUString        aLayerName = GetActiveLayer();
     SdrPageView*    pPV = GetSdrPageView();
@@ -615,7 +615,7 @@ sal_Int8 View::AcceptDrop( const AcceptDropEvent& rEvt, DropTargetHelper& rTarge
 }
 
 sal_Int8 View::ExecuteDrop( const ExecuteDropEvent& rEvt,
-                              ::sd::Window* pTargetWindow, sal_uInt16 nPage, sal_uInt16 nLayer )
+                              ::sd::Window* pTargetWindow, sal_uInt16 nPage, SdrLayerID nLayer )
 {
     SdrPageView*    pPV = GetSdrPageView();
     OUString        aActiveLayer = GetActiveLayer();
diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx
index 26deaffc2e23..d5129135d8ac 100644
--- a/sd/source/ui/view/sdview3.cxx
+++ b/sd/source/ui/view/sdview3.cxx
@@ -259,7 +259,7 @@ bool View::InsertMetaFile( TransferableDataHelper& rDataHelper, const Point& rPo
 
 bool View::InsertData( const TransferableDataHelper& rDataHelper,
                          const Point& rPos, sal_Int8& rDnDAction, bool bDrag,
-                         SotClipboardFormatId nFormat, sal_uInt16 nPage, sal_uInt16 nLayer )
+                         SotClipboardFormatId nFormat, sal_uInt16 nPage, SdrLayerID nLayer )
 {
     maDropPos = rPos;
     mnAction = rDnDAction;
@@ -411,11 +411,11 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
                                 if( IsUndoEnabled() )
                                 {
                                     BegUndo(SD_RESSTR(STR_MODIFYLAYER));
-                                    AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectLayerChange(*pO, pO->GetLayer(), (SdrLayerID)nLayer));
+                                    AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectLayerChange(*pO, pO->GetLayer(), nLayer));
                                     EndUndo();
                                 }
 
-                                pO->SetLayer( (SdrLayerID) nLayer );
+                                pO->SetLayer( nLayer );
                             }
                         }
 
@@ -1351,7 +1351,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
                 Point                   aHitPosL( rPos );
                 Point                   aHitPosT( rPos );
                 Point                   aHitPosB( rPos );
-                const SetOfByte*        pVisiLayer = &GetSdrPageView()->GetVisibleLayers();
+                const SdrLayerIDSet*        pVisiLayer = &GetSdrPageView()->GetVisibleLayers();
 
                 aHitPosR.X() += n2HitLog;
                 aHitPosL.X() -= n2HitLog;
diff --git a/sd/source/ui/view/unmodpg.cxx b/sd/source/ui/view/unmodpg.cxx
index 3716eb566b7a..b852eb58644c 100644
--- a/sd/source/ui/view/unmodpg.cxx
+++ b/sd/source/ui/view/unmodpg.cxx
@@ -58,9 +58,9 @@ ModifyPageUndoAction::ModifyPageUndoAction(
     {
         maOldName = mpPage->GetName();
         SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
-        sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND));
-        sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
-        SetOfByte aVisibleLayers = mpPage->TRG_GetMasterPageVisibleLayers();
+        SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND));
+        SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
+        SdrLayerIDSet aVisibleLayers = mpPage->TRG_GetMasterPageVisibleLayers();
 
         mbOldBckgrndVisible = aVisibleLayers.IsSet(aBckgrnd);
         mbOldBckgrndObjsVisible = aVisibleLayers.IsSet(aBckgrndObj);
@@ -104,9 +104,9 @@ void ModifyPageUndoAction::Undo()
         }
 
         SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
-        sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND));
-        sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
-        SetOfByte aVisibleLayers;
+        SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND));
+        SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
+        SdrLayerIDSet aVisibleLayers;
         aVisibleLayers.Set(aBckgrnd, mbOldBckgrndVisible);
         aVisibleLayers.Set(aBckgrndObj, mbOldBckgrndObjsVisible);
         mpPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
@@ -147,9 +147,9 @@ void ModifyPageUndoAction::Redo()
         }
 
         SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
-        sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND));
-        sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
-        SetOfByte aVisibleLayers;
+        SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND));
+        SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
+        SdrLayerIDSet aVisibleLayers;
         aVisibleLayers.Set(aBckgrnd, mbNewBckgrndVisible);
         aVisibleLayers.Set(aBckgrndObj, mbNewBckgrndObjsVisible);
         mpPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx
index 7d409d7021bf..4ed63c6f5387 100644
--- a/sd/source/ui/view/viewshe2.cxx
+++ b/sd/source/ui/view/viewshe2.cxx
@@ -944,7 +944,7 @@ sal_Int8 ViewShell::AcceptDrop (
     DropTargetHelper& rTargetHelper,
     ::sd::Window* pTargetWindow,
     sal_uInt16 nPage,
-    sal_uInt16 nLayer)
+    SdrLayerID nLayer)
 {
     ::sd::View* pView = GetView();
     return( pView ? pView->AcceptDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer ) : DND_ACTION_NONE );
@@ -955,7 +955,7 @@ sal_Int8 ViewShell::ExecuteDrop (
     DropTargetHelper& /*rTargetHelper*/,
     ::sd::Window* pTargetWindow,
     sal_uInt16 nPage,
-    sal_uInt16 nLayer)
+    SdrLayerID nLayer)
 {
     ::sd::View* pView = GetView();
     return pView ? pView->ExecuteDrop( rEvt, pTargetWindow, nPage, nLayer ) : DND_ACTION_NONE;
diff --git a/sd/source/ui/view/viewshe3.cxx b/sd/source/ui/view/viewshe3.cxx
index aa83468634c6..c24307a678de 100644
--- a/sd/source/ui/view/viewshe3.cxx
+++ b/sd/source/ui/view/viewshe3.cxx
@@ -202,9 +202,9 @@ SdPage* ViewShell::CreateOrDuplicatePage (
     sal_uInt16 nSId = rRequest.GetSlot();
     SdDrawDocument* pDocument = GetDoc();
     SdrLayerAdmin& rLayerAdmin = pDocument->GetLayerAdmin();
-    sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND));
-    sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
-    SetOfByte aVisibleLayers;
+    SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND));
+    SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
+    SdrLayerIDSet aVisibleLayers;
     // Determine the page from which to copy some values, such as layers,
     // size, master page, to the new page.  This is usually the given page.
     // When the given page is NULL then use the first page of the document.
diff --git a/svx/inc/sdr/contact/viewobjectcontactofgroup.hxx b/svx/inc/sdr/contact/viewobjectcontactofgroup.hxx
index 416ca0fb633b..af2dd6644998 100644
--- a/svx/inc/sdr/contact/viewobjectcontactofgroup.hxx
+++ b/svx/inc/sdr/contact/viewobjectcontactofgroup.hxx
@@ -37,7 +37,7 @@ namespace sdr
             virtual drawinglayer::primitive2d::Primitive2DContainer getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo) const override;
 
         private:
-            virtual bool isPrimitiveVisibleOnAnyLayer(const SetOfByte& aLayers) const override;
+            virtual bool isPrimitiveVisibleOnAnyLayer(const SdrLayerIDSet& aLayers) const override;
         };
     } // end of namespace contact
 } // end of namespace sdr
diff --git a/svx/inc/sxlayitm.hxx b/svx/inc/sxlayitm.hxx
index 47fba3a9b616..9516f4efb9de 100644
--- a/svx/inc/sxlayitm.hxx
+++ b/svx/inc/sxlayitm.hxx
@@ -26,8 +26,8 @@
 
 class SdrLayerIdItem: public SfxUInt16Item {
 public:
-    SdrLayerIdItem(sal_uInt16 nId=0): SfxUInt16Item(SDRATTR_LAYERID,nId)  {}
-    SdrLayerID GetValue() const { return (SdrLayerID)SfxUInt16Item::GetValue(); }
+    SdrLayerIdItem(SdrLayerID nId): SfxUInt16Item(SDRATTR_LAYERID,sal_uInt8(nId))  {}
+    SdrLayerID GetValue() const { return SdrLayerID(SfxUInt16Item::GetValue()); }
     virtual SfxPoolItem* Clone(SfxItemPool* pPool=nullptr) const override;
 };
 
diff --git a/svx/source/sdr/contact/displayinfo.cxx b/svx/source/sdr/contact/displayinfo.cxx
index c3a219724d24..6a70a879fb88 100644
--- a/svx/source/sdr/contact/displayinfo.cxx
+++ b/svx/source/sdr/contact/displayinfo.cxx
@@ -39,7 +39,7 @@ namespace sdr
         }
 
         // Access to LayerInfos (which layers to process)
-        void DisplayInfo::SetProcessLayers(const SetOfByte& rSet)
+        void DisplayInfo::SetProcessLayers(const SdrLayerIDSet& rSet)
         {
             maProcessLayers = rSet;
         }
diff --git a/svx/source/sdr/contact/viewcontactofe3dscene.cxx b/svx/source/sdr/contact/viewcontactofe3dscene.cxx
index 75292d9b860f..f3e2a366a0f2 100644
--- a/svx/source/sdr/contact/viewcontactofe3dscene.cxx
+++ b/svx/source/sdr/contact/viewcontactofe3dscene.cxx
@@ -42,7 +42,7 @@ void createSubPrimitive3DVector(
     const sdr::contact::ViewContact& rCandidate,
     drawinglayer::primitive3d::Primitive3DContainer& o_rAllTarget,
     drawinglayer::primitive3d::Primitive3DContainer* o_pVisibleTarget,
-    const SetOfByte* pVisibleLayerSet,
+    const SdrLayerIDSet* pVisibleSdrLayerIDSet,
     const bool bTestSelectedVisibility)
 {
     const sdr::contact::ViewContactOfE3dScene* pViewContactOfE3dScene = dynamic_cast< const sdr::contact::ViewContactOfE3dScene* >(&rCandidate);
@@ -64,7 +64,7 @@ void createSubPrimitive3DVector(
                     rCandidate.GetViewContact(a),
                     aNewAllTarget,
                     o_pVisibleTarget ? &aNewVisibleTarget : nullptr,
-                    pVisibleLayerSet,
+                    pVisibleSdrLayerIDSet,
                     bTestSelectedVisibility);
             }
 
@@ -102,13 +102,13 @@ void createSubPrimitive3DVector(
                     // test visibility. Primitive is visible when both tests are true (AND)
                     bool bVisible(true);
 
-                    if(pVisibleLayerSet)
+                    if(pVisibleSdrLayerIDSet)
                     {
                         // test layer visibility
                         const E3dObject& rE3dObject = pViewContactOfE3d->GetE3dObject();
                         const SdrLayerID aLayerID(rE3dObject.GetLayer());
 
-                        bVisible = pVisibleLayerSet->IsSet(aLayerID);
+                        bVisible = pVisibleSdrLayerIDSet->IsSet(aLayerID);
                     }
 
                     if(bVisible && bTestSelectedVisibility)
@@ -268,7 +268,7 @@ void ViewContactOfE3dScene::createSdrLightingAttribute()
 }
 
 drawinglayer::primitive2d::Primitive2DContainer ViewContactOfE3dScene::createScenePrimitive2DSequence(
-    const SetOfByte* pLayerVisibility) const
+    const SdrLayerIDSet* pLayerVisibility) const
 {
     drawinglayer::primitive2d::Primitive2DContainer xRetval;
     const sal_uInt32 nChildrenCount(GetObjectCount());
diff --git a/svx/source/sdr/contact/viewobjectcontactofe3dscene.cxx b/svx/source/sdr/contact/viewobjectcontactofe3dscene.cxx
index 4a4a9e9e7d00..2cd53ba26509 100644
--- a/svx/source/sdr/contact/viewobjectcontactofe3dscene.cxx
+++ b/svx/source/sdr/contact/viewobjectcontactofe3dscene.cxx
@@ -82,7 +82,7 @@ namespace sdr
             // support ghosted for now. This is no problem currently but would need to be
             // added when sub-groups in 3d will be added one day.
             const ViewContactOfE3dScene& rViewContact = dynamic_cast< ViewContactOfE3dScene& >(GetViewContact());
-            const SetOfByte& rVisibleLayers = rDisplayInfo.GetProcessLayers();
+            const SdrLayerIDSet& rVisibleLayers = rDisplayInfo.GetProcessLayers();
             drawinglayer::primitive2d::Primitive2DContainer xRetval(rViewContact.createScenePrimitive2DSequence(&rVisibleLayers));
 
             if(!xRetval.empty())
diff --git a/svx/source/sdr/contact/viewobjectcontactofgroup.cxx b/svx/source/sdr/contact/viewobjectcontactofgroup.cxx
index d67210f3b6e2..cb676b712f7f 100644
--- a/svx/source/sdr/contact/viewobjectcontactofgroup.cxx
+++ b/svx/source/sdr/contact/viewobjectcontactofgroup.cxx
@@ -99,10 +99,10 @@ namespace sdr
             return xRetval;
         }
 
-        bool ViewObjectContactOfGroup::isPrimitiveVisibleOnAnyLayer(const SetOfByte& aLayers) const
+        bool ViewObjectContactOfGroup::isPrimitiveVisibleOnAnyLayer(const SdrLayerIDSet& aLayers) const
         {
-            SetOfByte aObjectLayers;
-            getSdrObject().getMergedHierarchyLayerSet(aObjectLayers);
+            SdrLayerIDSet aObjectLayers;
+            getSdrObject().getMergedHierarchySdrLayerIDSet(aObjectLayers);
             aObjectLayers &= aLayers;
             return !aObjectLayers.IsEmpty();
         }
diff --git a/svx/source/sdr/contact/viewobjectcontactofmasterpagedescriptor.cxx b/svx/source/sdr/contact/viewobjectcontactofmasterpagedescriptor.cxx
index cadd37c6b466..3c9aca92946b 100644
--- a/svx/source/sdr/contact/viewobjectcontactofmasterpagedescriptor.cxx
+++ b/svx/source/sdr/contact/viewobjectcontactofmasterpagedescriptor.cxx
@@ -72,15 +72,15 @@ namespace sdr
                 rOwnerPage.GetWdt() - rOwnerPage.GetRgtBorder(), rOwnerPage.GetHgt() - rOwnerPage.GetLwrBorder());
 
             // Modify DisplayInfo for MasterPageContent collection; remember original layers and
-            // set combined LayerSet; set MasterPagePaint flag

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list