summaryrefslogtreecommitdiff
path: root/include/sfx2
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2017-03-23 20:14:15 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-03-27 09:43:58 +0000
commitd615af618cc6a7152c76a49b3cd09db38eaa9e07 (patch)
treebc0d69070444dc687708de9a4a146c5c2d3b6852 /include/sfx2
parent6f968f00b1534406a2943be374fab924c3396482 (diff)
create SfxInterfaceId o3tl::strong_int
Change-Id: Ie52f63382a9fb36f9a472801be012b140bfb51f6 Reviewed-on: https://gerrit.libreoffice.org/35722 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/sfx2')
-rw-r--r--include/sfx2/docfac.hxx2
-rw-r--r--include/sfx2/frame.hxx3
-rw-r--r--include/sfx2/shell.hxx59
-rw-r--r--include/sfx2/viewfac.hxx9
-rw-r--r--include/sfx2/viewfrm.hxx16
-rw-r--r--include/sfx2/viewsh.hxx4
6 files changed, 41 insertions, 52 deletions
diff --git a/include/sfx2/docfac.hxx b/include/sfx2/docfac.hxx
index 6cd70b86f586..c9fc6c880805 100644
--- a/include/sfx2/docfac.hxx
+++ b/include/sfx2/docfac.hxx
@@ -78,7 +78,7 @@ public:
SfxModule* GetModule() const;
SAL_DLLPRIVATE void SetModule_Impl( SfxModule* );
- SAL_DLLPRIVATE sal_uInt16 GetViewNo_Impl( const sal_uInt16 i_nViewId, const sal_uInt16 i_nFallback ) const;
+ SAL_DLLPRIVATE sal_uInt16 GetViewNo_Impl( const SfxInterfaceId i_nViewId, const sal_uInt16 i_nFallback ) const;
private:
SfxObjectFactory(const SfxObjectFactory&) = delete;
diff --git a/include/sfx2/frame.hxx b/include/sfx2/frame.hxx
index a46fd2616cec..b8afc7f9b26d 100644
--- a/include/sfx2/frame.hxx
+++ b/include/sfx2/frame.hxx
@@ -21,6 +21,7 @@
#include <sal/config.h>
#include <sfx2/dllapi.h>
+#include <sfx2/shell.hxx>
#include <sal/types.h>
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/uno/Any.hxx>
@@ -109,7 +110,7 @@ public:
static SfxFrame* Create( const css::uno::Reference< css::frame::XFrame >& xFrame );
static css::uno::Reference< css::frame::XFrame >
CreateBlankFrame();
- static SfxFrame* Create( SfxObjectShell& rDoc, vcl::Window& rWindow, sal_uInt16 nViewId, bool bHidden );
+ static SfxFrame* Create( SfxObjectShell& rDoc, vcl::Window& rWindow, SfxInterfaceId nViewId, bool bHidden );
vcl::Window& GetWindow() const { return *pWindow;}
void CancelTransfers();
diff --git a/include/sfx2/shell.hxx b/include/sfx2/shell.hxx
index d3368ff1dea8..2e1106591115 100644
--- a/include/sfx2/shell.hxx
+++ b/include/sfx2/shell.hxx
@@ -27,6 +27,7 @@
#include <sfx2/sfxuno.hxx>
#include <svl/SfxBroadcaster.hxx>
#include <o3tl/typed_flags_set.hxx>
+#include <o3tl/strong_int.hxx>
class ResMgr;
namespace vcl { class Window; }
@@ -64,35 +65,21 @@ namespace svl
Id for <SfxInterface>s, gives a quasi-static access to the interface
through an array to <SfxApplication>.
*/
-enum SfxInterfaceId
-{
- SFX_INTERFACE_NONE,
- SFX_INTERFACE_SFXAPP,
- SFX_INTERFACE_SFXDOCSH,
- SFX_INTERFACE_SFXVIEWSH,
- SFX_INTERFACE_SFXVIEWFRM,
- SFX_INTERFACE_SFXMODULE,
- SFX_INTERFACE_OFA_START = 100,
- SFX_INTERFACE_OFA_END = 100,
- SFX_INTERFACE_SC_START = 150,
- SFX_INTERFACE_SC_END = 199,
- SFX_INTERFACE_SD_START = 200,
- SFX_INTERFACE_SD_END = 249,
- SFX_INTERFACE_SW_START = 250,
- SFX_INTERFACE_SW_END = 299,
- SFX_INTERFACE_SIM_START = 300,
- SFX_INTERFACE_SIM_END = 319,
- SFX_INTERFACE_SCH_START = 320,
- SFX_INTERFACE_SCH_END = 339,
- SFX_INTERFACE_SMA_START = 340,
- SFX_INTERFACE_SMA_END = 359,
- SFX_INTERFACE_SBA_START = 360,
- SFX_INTERFACE_SBA_END = 399,
- SFX_INTERFACE_IDE_START = 400,
- SFX_INTERFACE_IDE_END = 409,
- //-if one is still needed
- SFX_INTERFACE_APP = SFX_INTERFACE_SW_START,
-};
+struct SfxInterfaceIdTag {};
+typedef o3tl::strong_int<sal_uInt16, SfxInterfaceIdTag> SfxInterfaceId;
+
+constexpr auto SFX_INTERFACE_NONE = SfxInterfaceId(0);
+constexpr auto SFX_INTERFACE_SFXAPP = SfxInterfaceId(1);
+constexpr auto SFX_INTERFACE_SFXDOCSH = SfxInterfaceId(2);
+constexpr auto SFX_INTERFACE_SFXVIEWSH = SfxInterfaceId(3);
+constexpr auto SFX_INTERFACE_SFXVIEWFRM = SfxInterfaceId(4);
+constexpr auto SFX_INTERFACE_SFXMODULE = SfxInterfaceId(5);
+constexpr auto SFX_INTERFACE_SC_START = SfxInterfaceId(150);
+constexpr auto SFX_INTERFACE_SD_START = SfxInterfaceId(200);
+constexpr auto SFX_INTERFACE_SW_START = SfxInterfaceId(250);
+constexpr auto SFX_INTERFACE_SMA_START = SfxInterfaceId(340);
+constexpr auto SFX_INTERFACE_IDE_START = SfxInterfaceId(400);
+constexpr auto SFX_INTERFACE_IDE_END = SfxInterfaceId(409);
enum class SfxShellFeature
{
@@ -547,16 +534,16 @@ inline void SfxShell::SetPool
pPool = pNewPool;
}
-#define SFX_DECL_INTERFACE(nId) \
- static SfxInterface* pInterface; \
- static SfxInterface* GetStaticInterface(); \
- static SfxInterfaceId GetInterfaceId() {return SfxInterfaceId(nId);} \
- static void RegisterInterface(SfxModule* pMod=nullptr); \
- virtual SfxInterface* GetInterface() const override;
+#define SFX_DECL_INTERFACE(nId) \
+ static SfxInterface* pInterface; \
+ static SfxInterface* GetStaticInterface(); \
+ static SfxInterfaceId GetInterfaceId() {return nId;} \
+ static void RegisterInterface(SfxModule* pMod=nullptr); \
+ virtual SfxInterface* GetInterface() const override;
#define SFX_TMPL_INTERFACE(Class,SuperClass,Abstract) \
\
- SfxInterface* Class::pInterface = nullptr; \
+ SfxInterface* Class::pInterface = nullptr; \
SfxInterface* Class::GetStaticInterface() \
{ \
if ( !pInterface ) \
diff --git a/include/sfx2/viewfac.hxx b/include/sfx2/viewfac.hxx
index 2bff0da82258..e9bef0f6cc76 100644
--- a/include/sfx2/viewfac.hxx
+++ b/include/sfx2/viewfac.hxx
@@ -22,6 +22,7 @@
#include <rtl/ustring.hxx>
#include <sal/config.h>
#include <sfx2/dllapi.h>
+#include <sfx2/shell.hxx>
class SfxViewFrame;
class SfxViewShell;
@@ -34,10 +35,10 @@ class SFX2_DLLPUBLIC SfxViewFactory
{
public:
SfxViewFactory( SfxViewCtor fnC,
- sal_uInt16 nOrdinal, const sal_Char* asciiViewName );
+ SfxInterfaceId nOrdinal, const sal_Char* asciiViewName );
- SfxViewShell *CreateInstance(SfxViewFrame *pViewFrame, SfxViewShell *pOldSh);
- sal_uInt16 GetOrdinal() const { return nOrd; }
+ SfxViewShell* CreateInstance(SfxViewFrame *pViewFrame, SfxViewShell *pOldSh);
+ SfxInterfaceId GetOrdinal() const { return nOrd; }
/// returns a legacy view name. This is "view" with an appended ordinal/ID.
OUString GetLegacyViewName() const;
@@ -51,7 +52,7 @@ public:
private:
SfxViewCtor fnCreate;
- sal_uInt16 nOrd;
+ SfxInterfaceId nOrd;
const OUString m_sViewName;
};
diff --git a/include/sfx2/viewfrm.hxx b/include/sfx2/viewfrm.hxx
index 2b6093ef3679..83928d364170 100644
--- a/include/sfx2/viewfrm.hxx
+++ b/include/sfx2/viewfrm.hxx
@@ -97,9 +97,9 @@ public:
static void SetViewFrame( SfxViewFrame* );
- static SfxViewFrame* LoadHiddenDocument( SfxObjectShell& i_rDoc, const sal_uInt16 i_nViewId );
- static SfxViewFrame* LoadDocument( SfxObjectShell& i_rDoc, const sal_uInt16 i_nViewId );
- static SfxViewFrame* LoadDocumentIntoFrame( SfxObjectShell& i_rDoc, const SfxFrameItem* i_pFrameItem, const sal_uInt16 i_nViewId );
+ static SfxViewFrame* LoadHiddenDocument( SfxObjectShell& i_rDoc, SfxInterfaceId i_nViewId );
+ static SfxViewFrame* LoadDocument( SfxObjectShell& i_rDoc, SfxInterfaceId i_nViewId );
+ static SfxViewFrame* LoadDocumentIntoFrame( SfxObjectShell& i_rDoc, const SfxFrameItem* i_pFrameItem, SfxInterfaceId i_nViewId );
static SfxViewFrame* LoadDocumentIntoFrame( SfxObjectShell& i_rDoc, const css::uno::Reference< css::frame::XFrame >& i_rFrameItem );
static SfxViewFrame* DisplayNewDocument( SfxObjectShell& i_rDoc, const SfxRequest& i_rCreateDocRequest );
@@ -143,7 +143,7 @@ public:
SAL_DLLPRIVATE void InvalidateBorderImpl( const SfxViewShell *pSh );
virtual SfxObjectShell* GetObjectShell() override;
- sal_uInt16 GetCurViewId() const;
+ SfxInterfaceId GetCurViewId() const;
SfxFrame& GetFrame() const;
SfxViewFrame* GetTopViewFrame() const;
@@ -206,12 +206,12 @@ public:
SAL_DLLPRIVATE void INetExecute_Impl(SfxRequest &);
SAL_DLLPRIVATE void INetState_Impl(SfxItemSet &);
- SAL_DLLPRIVATE void SetCurViewId_Impl( const sal_uInt16 i_nID );
+ SAL_DLLPRIVATE void SetCurViewId_Impl( const SfxInterfaceId i_nID );
private:
SAL_DLLPRIVATE bool SwitchToViewShell_Impl( sal_uInt16 nNo, bool bIsIndex = false );
SAL_DLLPRIVATE void PopShellAndSubShells_Impl( SfxViewShell& i_rViewShell );
- SAL_DLLPRIVATE void SaveCurrentViewData_Impl( const sal_uInt16 i_nNewViewId );
+ SAL_DLLPRIVATE void SaveCurrentViewData_Impl( const SfxInterfaceId i_nNewViewId );
/** loads the given existing document into the given frame
@@ -234,7 +234,7 @@ private:
const SfxObjectShell& i_rDoc,
const css::uno::Reference< css::frame::XFrame >& i_rFrame,
const css::uno::Sequence< css::beans::PropertyValue >& i_rLoadArgs,
- const sal_uInt16 i_nViewId,
+ const SfxInterfaceId i_nViewId,
const bool i_bHidden
);
@@ -256,7 +256,7 @@ private:
SAL_DLLPRIVATE static SfxViewFrame* LoadViewIntoFrame_Impl_NoThrow(
const SfxObjectShell& i_rDoc,
const css::uno::Reference< css::frame::XFrame >& i_rFrame,
- const sal_uInt16 i_nViewId,
+ const SfxInterfaceId i_nViewId,
const bool i_bHidden
);
};
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index e8aef57c7c50..52792c3d2f7b 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -118,7 +118,7 @@ private: \
static SfxViewFactory *pFactory; \
public: \
static SfxViewShell *CreateInstance(SfxViewFrame *pFrame, SfxViewShell *pOldView); \
- static void RegisterFactory( sal_uInt16 nPrio = USHRT_MAX ); \
+ static void RegisterFactory( SfxInterfaceId nPrio ); \
static SfxViewFactory*Factory() { return pFactory; } \
static void InitFactory()
@@ -126,7 +126,7 @@ public: \
SfxViewFactory* Class::pFactory; \
SfxViewShell* Class::CreateInstance(SfxViewFrame *pFrame, SfxViewShell *pOldView) \
{ return new Class(pFrame, pOldView); } \
- void Class::RegisterFactory( sal_uInt16 nPrio ) \
+ void Class::RegisterFactory( SfxInterfaceId nPrio ) \
{ \
pFactory = new SfxViewFactory(&CreateInstance,nPrio,AsciiViewName);\
InitFactory(); \