summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2017-04-30 19:50:49 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-05-02 08:18:14 +0200
commita12dfa353122d1865b7c20513865a4632a621a38 (patch)
treed37bb405e7f7783050a26b8fd98b39746cb3e278 /include
parent5eaad8eb1d46b6f85605c5ac210e8b1397b18b22 (diff)
create SfxGroupId based on o3tl::strong_int
Change-Id: Iaccf16f29b6f4b1a2c712d1e5e2bd0fa4fdb5e71 Reviewed-on: https://gerrit.libreoffice.org/37108 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include')
-rw-r--r--include/sfx2/groupid.hxx56
-rw-r--r--include/sfx2/msg.hxx7
-rw-r--r--include/sfx2/msgpool.hxx3
-rw-r--r--include/sfx2/sfx.hrc3
-rw-r--r--include/sfx2/sfxbasecontroller.hxx3
5 files changed, 66 insertions, 6 deletions
diff --git a/include/sfx2/groupid.hxx b/include/sfx2/groupid.hxx
new file mode 100644
index 000000000000..072ac723319b
--- /dev/null
+++ b/include/sfx2/groupid.hxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SFX2_GROUPID_HXX
+#define INCLUDED_SFX2_GROUPID_HXX
+
+#ifdef __RSC
+#define SfxGroupId(x) (x)
+#else
+
+#include <o3tl/strong_int.hxx>
+#include <sal/types.h>
+#include <functional>
+
+struct SfxGroupIdTag {};
+typedef o3tl::strong_int<sal_uInt16, SfxGroupIdTag> SfxGroupId;
+
+// make it hashable for storing in maps
+namespace std {
+
+ template <>
+ struct hash<SfxGroupId>
+ {
+ std::size_t operator()(const SfxGroupId& k) const
+ {
+ return std::hash<sal_uInt16>()((sal_uInt16)k);
+ }
+ };
+
+}
+
+// Make it easier to declare the constants in the .hrc files.
+// This way, we only have to mark the START constant as being SfxGroupId.
+inline SfxGroupId operator+(SfxGroupId lhs, sal_uInt16 rhs)
+{
+ return SfxGroupId((sal_uInt16)lhs + rhs);
+}
+#endif
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sfx2/msg.hxx b/include/sfx2/msg.hxx
index 5d864ade4694..f3c60afb52b0 100644
--- a/include/sfx2/msg.hxx
+++ b/include/sfx2/msg.hxx
@@ -24,6 +24,7 @@
#include <rtl/ustring.hxx>
#include <sfx2/dllapi.h>
#include <o3tl/typed_flags_set.hxx>
+#include <sfx2/groupid.hxx>
#include <functional>
class SfxItemPool;
@@ -183,7 +184,7 @@ class SfxSlot
{
public:
sal_uInt16 nSlotId; // Unique slot-ID in Shell
- sal_uInt16 nGroupId; // for configuration region
+ SfxGroupId nGroupId; // for configuration region
SfxSlotMode nFlags; // arithmetic ordered Flags
sal_uInt16 nMasterSlotId; // Enum-Slot for example Which-Id
@@ -209,7 +210,7 @@ public:
sal_uInt16 GetSlotId() const;
SfxSlotMode GetMode() const;
bool IsMode( SfxSlotMode nMode ) const;
- sal_uInt16 GetGroupId() const;
+ SfxGroupId GetGroupId() const;
sal_uInt16 GetWhich( const SfxItemPool &rPool ) const;
const SfxType* GetType() const { return pType; }
const char* GetUnoName() const { return pUnoName; }
@@ -252,7 +253,7 @@ inline bool SfxSlot::IsMode( SfxSlotMode nMode ) const
// returns the id of the associated group
-inline sal_uInt16 SfxSlot::GetGroupId() const
+inline SfxGroupId SfxSlot::GetGroupId() const
{
return nGroupId;
diff --git a/include/sfx2/msgpool.hxx b/include/sfx2/msgpool.hxx
index 4d57ba74d46a..fffdf415d5e9 100644
--- a/include/sfx2/msgpool.hxx
+++ b/include/sfx2/msgpool.hxx
@@ -24,6 +24,7 @@
#include <sal/types.h>
#include <sfx2/dllapi.h>
#include <sfx2/msg.hxx>
+#include <sfx2/groupid.hxx>
#include <memory>
#include <vector>
@@ -32,7 +33,7 @@ class SfxSlot;
class SFX2_DLLPUBLIC SfxSlotPool
{
- std::vector<sal_uInt16> _vGroups;
+ std::vector<SfxGroupId> _vGroups;
SfxSlotPool* _pParentPool;
std::vector<SfxInterface*> _vInterfaces;
sal_uInt16 _nCurGroup;
diff --git a/include/sfx2/sfx.hrc b/include/sfx2/sfx.hrc
index 3653eca24339..0cab808bd06e 100644
--- a/include/sfx2/sfx.hrc
+++ b/include/sfx2/sfx.hrc
@@ -22,8 +22,9 @@
#include <svl/solar.hrc>
#include <svl/memberid.hrc>
+#include <sfx2/groupid.hxx>
-#define RID_GROUPS_SFXOFFSET 32700
+#define RID_GROUPS_SFXOFFSET SfxGroupId(32700)
#define EVENT_SFX_START 5000
// EVENT_SFX_END 9999
diff --git a/include/sfx2/sfxbasecontroller.hxx b/include/sfx2/sfxbasecontroller.hxx
index 44de7a736692..524e6ad4122d 100644
--- a/include/sfx2/sfxbasecontroller.hxx
+++ b/include/sfx2/sfxbasecontroller.hxx
@@ -53,12 +53,13 @@
#include <sfx2/viewsh.hxx>
#include <sfx2/sfxuno.hxx>
+#include <sfx2/groupid.hxx>
struct IMPL_SfxBaseController_DataContainer ; // impl. struct to hold member of class SfxBaseController
class SfxViewFrame;
-sal_Int16 MapGroupIDToCommandGroup( sal_Int16 nGroupID );
+sal_Int16 MapGroupIDToCommandGroup( SfxGroupId nGroupID );
// class declarations