diff options
-rw-r--r-- | idl/source/objects/object.cxx | 2 | ||||
-rw-r--r-- | idl/source/objects/slot.cxx | 2 | ||||
-rw-r--r-- | idl/source/prj/database.cxx | 7 | ||||
-rw-r--r-- | include/sfx2/groupid.hxx | 56 | ||||
-rw-r--r-- | include/sfx2/msg.hxx | 7 | ||||
-rw-r--r-- | include/sfx2/msgpool.hxx | 3 | ||||
-rw-r--r-- | include/sfx2/sfx.hrc | 3 | ||||
-rw-r--r-- | include/sfx2/sfxbasecontroller.hxx | 3 | ||||
-rw-r--r-- | sd/source/ui/dlg/PaneShells.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/control/msgpool.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/control/shell.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/view/sfxbasecontroller.cxx | 10 | ||||
-rw-r--r-- | svx/source/toolbars/extrusionbar.cxx | 2 | ||||
-rw-r--r-- | svx/source/toolbars/fontworkbar.cxx | 2 |
14 files changed, 85 insertions, 20 deletions
diff --git a/idl/source/objects/object.cxx b/idl/source/objects/object.cxx index 931ad3a1aacf..33a5fd75b6f6 100644 --- a/idl/source/objects/object.cxx +++ b/idl/source/objects/object.cxx @@ -327,7 +327,7 @@ void SvMetaClass::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ) // at least one dummy WriteTab( rOutStm, 1 ); rOutStm.WriteCharPtr( "SFX_SLOT_ARG(" ).WriteOString( GetName() ) - .WriteCharPtr( ", 0, 0, " ) + .WriteCharPtr( ", 0, SfxGroupId(0), " ) .WriteCharPtr( "SFX_STUB_PTR_EXEC_NONE," ) .WriteCharPtr( "SFX_STUB_PTR_STATE_NONE," ) .WriteCharPtr( "SfxSlotMode::NONE, SfxVoidItem, 0, 0, \"\", SfxSlotMode::NONE )" ) << endl; diff --git a/idl/source/objects/slot.cxx b/idl/source/objects/slot.cxx index b14b0ec1b031..dec49c26bd8a 100644 --- a/idl/source/objects/slot.cxx +++ b/idl/source/objects/slot.cxx @@ -434,7 +434,7 @@ void SvMetaSlot::WriteSlot( const OString& rShellName, sal_uInt16 nCount, if( !GetGroupId().isEmpty() ) rOutStm.WriteOString( GetGroupId() ); else - rOutStm.WriteChar( '0' ); + rOutStm.WriteCharPtr( "SfxGroupId(0)" ); rOutStm.WriteChar( ',' ) << endl; WriteTab( rOutStm, 4 ); diff --git a/idl/source/prj/database.cxx b/idl/source/prj/database.cxx index 377f507fe57d..3395183cf574 100644 --- a/idl/source/prj/database.cxx +++ b/idl/source/prj/database.cxx @@ -229,7 +229,12 @@ bool SvIdlDataBase::ReadIdFile( const OString& rOFileName ) } } OString aName(aNameBuf.makeStringAndClear()); - if (!ReadIdFile(aName)) + if (aName == "sfx2/groupid.hxx") + { + // contains C++ code which we cannot parse + // we special-case this by defining a macro internally in .... + } + else if (!ReadIdFile(aName)) { throw SvParseException("cannot read file: " + aName, rTok); } 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 diff --git a/sd/source/ui/dlg/PaneShells.cxx b/sd/source/ui/dlg/PaneShells.cxx index ac6a514602fa..6b3635e023b7 100644 --- a/sd/source/ui/dlg/PaneShells.cxx +++ b/sd/source/ui/dlg/PaneShells.cxx @@ -33,7 +33,7 @@ namespace sd { static SfxSlot aLeftImpressPaneShellSlots_Impl[] = { - { 0, 0, SfxSlotMode::NONE, 0, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0, SfxDisableFlags::NONE, nullptr } + { 0, SfxGroupId(0), SfxSlotMode::NONE, 0, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0, SfxDisableFlags::NONE, nullptr } }; SFX_IMPL_INTERFACE(LeftImpressPaneShell, SfxShell) @@ -58,7 +58,7 @@ LeftImpressPaneShell::~LeftImpressPaneShell() static SfxSlot aLeftDrawPaneShellSlots_Impl[] = { - { 0, 0, SfxSlotMode::NONE, 0, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0, SfxDisableFlags::NONE, nullptr } + { 0, SfxGroupId(0), SfxSlotMode::NONE, 0, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0, SfxDisableFlags::NONE, nullptr } }; SFX_IMPL_INTERFACE(LeftDrawPaneShell, SfxShell) diff --git a/sfx2/source/control/msgpool.cxx b/sfx2/source/control/msgpool.cxx index ed74d2020c3b..e0de09b8d548 100644 --- a/sfx2/source/control/msgpool.cxx +++ b/sfx2/source/control/msgpool.cxx @@ -143,7 +143,7 @@ OUString SfxSlotPool::SeekGroup( sal_uInt16 nNo ) } } - SfxResId aResId( _vGroups[_nCurGroup] ); + SfxResId aResId( (sal_uInt16)_vGroups[_nCurGroup] ); aResId.SetRT(RSC_STRING); if ( !SfxResId::GetResMgr()->IsAvailable(aResId) ) { diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx index 13b3be168c07..4fa297d02010 100644 --- a/sfx2/source/control/shell.cxx +++ b/sfx2/source/control/shell.cxx @@ -537,7 +537,7 @@ void SfxShell::SetVerbs(const css::uno::Sequence < css::embed::VerbDescriptor >& SfxSlot *pNewSlot = new SfxSlot; pNewSlot->nSlotId = nSlotId; - pNewSlot->nGroupId = 0; + pNewSlot->nGroupId = SfxGroupId(0); // Verb slots must be executed asynchronously, so that they can be // destroyed while executing. diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx index bb03b8ddf036..b7947d3dc648 100644 --- a/sfx2/source/view/sfxbasecontroller.cxx +++ b/sfx2/source/view/sfxbasecontroller.cxx @@ -108,7 +108,7 @@ using ::com::sun::star::ui::XSidebarProvider; struct GroupIDToCommandGroup { - sal_Int16 nGroupID; + SfxGroupId nGroupID; sal_Int16 nCommandGroup; }; @@ -141,19 +141,19 @@ static const GroupIDToCommandGroup GroupIDCommandGroupMap[] = { GID_MODIFY , frame::CommandGroup::MODIFY }, { GID_DRAWING , frame::CommandGroup::DRAWING }, { GID_CONTROLS , frame::CommandGroup::CONTROLS }, - { 0 , 0 } + { SfxGroupId(0) , 0 } }; -typedef std::unordered_map< sal_Int16, sal_Int16 > GroupHashMap; +typedef std::unordered_map< SfxGroupId, sal_Int16 > GroupHashMap; -sal_Int16 MapGroupIDToCommandGroup( sal_Int16 nGroupID ) +sal_Int16 MapGroupIDToCommandGroup( SfxGroupId nGroupID ) { static GroupHashMap s_aHashMap; if ( !bGroupIDMapInitialized ) { sal_Int32 i = 0; - while ( GroupIDCommandGroupMap[i].nGroupID != 0 ) + while ( GroupIDCommandGroupMap[i].nGroupID != SfxGroupId(0) ) { s_aHashMap.insert( GroupHashMap::value_type( GroupIDCommandGroupMap[i].nGroupID, diff --git a/svx/source/toolbars/extrusionbar.cxx b/svx/source/toolbars/extrusionbar.cxx index 90f395e4da7e..5dea6c528bd6 100644 --- a/svx/source/toolbars/extrusionbar.cxx +++ b/svx/source/toolbars/extrusionbar.cxx @@ -51,7 +51,7 @@ using namespace ::com::sun::star::uno; // we enter something which never occurs here (hopefully).) static SfxSlot aExtrusionBarSlots_Impl[] = { - { 0, 0, SfxSlotMode::NONE, 0, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0, SfxDisableFlags::NONE, nullptr } + { 0, SfxGroupId(0), SfxSlotMode::NONE, 0, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0, SfxDisableFlags::NONE, nullptr } }; SFX_IMPL_INTERFACE(ExtrusionBar, SfxShell) diff --git a/svx/source/toolbars/fontworkbar.cxx b/svx/source/toolbars/fontworkbar.cxx index 59ed7287adbf..fbcd1003de73 100644 --- a/svx/source/toolbars/fontworkbar.cxx +++ b/svx/source/toolbars/fontworkbar.cxx @@ -172,7 +172,7 @@ void SetFontWorkShapeTypeState( SdrView* pSdrView, SfxItemSet& rSet ) // we enter something which never occurs here (hopefully).) static SfxSlot aFontworkBarSlots_Impl[] = { - { 0, 0, SfxSlotMode::NONE, 0, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0, SfxDisableFlags::NONE, nullptr } + { 0, SfxGroupId(0), SfxSlotMode::NONE, 0, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0, SfxDisableFlags::NONE, nullptr } }; SFX_IMPL_INTERFACE(FontworkBar, SfxShell) |