summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-05-10 13:52:51 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-05-12 09:54:23 +0200
commita651dbcfca9e198b5c2561076961504586bc6bea (patch)
tree812eee16af9bc3c4c75b8b45a4c126f99ad1bab3 /sc
parent9b5ce4023d35c4cc82f7b17e79b8fedbcb1367dd (diff)
convert SdrLayerId to strong_int
Also - rename SetOfByte to SdrLayerIDSet - add asserts in SdrLayerAdmin::GetUniqueLayerID so that we don't allocate overlapping SdrLayerID values - add a new constant SDRLAYERPOS_NOTFOUND to be returned from SdrLayerAdmin::GetLayerPos Change-Id: I3bb3489f9338e3d02c4040bcbd811744699941c8 Reviewed-on: https://gerrit.libreoffice.org/37467 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/global.hxx14
-rw-r--r--sc/source/core/data/drwlayer.cxx10
-rw-r--r--sc/source/filter/xml/XMLTableShapeImportHelper.cxx10
-rw-r--r--sc/source/filter/xml/XMLTableShapeImportHelper.hxx3
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx4
-rw-r--r--sc/source/ui/Accessibility/AccessibleDocument.cxx12
-rw-r--r--sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx42
-rw-r--r--sc/source/ui/drawfunc/drawsh2.cxx2
-rw-r--r--sc/source/ui/inc/drawsh.hxx3
-rw-r--r--sc/source/ui/inc/drawview.hxx2
-rw-r--r--sc/source/ui/inc/gridwin.hxx2
-rw-r--r--sc/source/ui/inc/output.hxx8
-rw-r--r--sc/source/ui/view/drawview.cxx4
-rw-r--r--sc/source/ui/view/gridwin3.cxx4
-rw-r--r--sc/source/ui/view/output3.cxx4
15 files changed, 60 insertions, 64 deletions
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)