diff options
author | Noel Grandin <noel@peralex.com> | 2016-05-20 14:37:46 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-05-22 17:51:21 +0000 |
commit | 835de2917eb2941150edc38285e41488380323e0 (patch) | |
tree | b4b4d924297ea3d34c90aadf319b3aa3e5c139e9 | |
parent | eaba47bce44a373116b0583dc293c8c3238b7bea (diff) |
Convert HYPERDLG_EVENT to scoped enum
Change-Id: I8a0248bb91ee67596aa44d11ca862d2e127a65ad
Reviewed-on: https://gerrit.libreoffice.org/25197
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
-rw-r--r-- | cui/source/dialogs/hltpbase.cxx | 16 | ||||
-rw-r--r-- | cui/source/inc/hltpbase.hxx | 2 | ||||
-rw-r--r-- | include/svx/hlnkitem.hxx | 25 | ||||
-rw-r--r-- | svx/source/items/hlnkitem.cxx | 41 | ||||
-rw-r--r-- | sw/source/uibase/shells/textsh.cxx | 10 |
5 files changed, 51 insertions, 43 deletions
diff --git a/cui/source/dialogs/hltpbase.cxx b/cui/source/dialogs/hltpbase.cxx index 07cbd4cd3870..cef6aecf9f58 100644 --- a/cui/source/dialogs/hltpbase.cxx +++ b/cui/source/dialogs/hltpbase.cxx @@ -295,7 +295,7 @@ void SvxHyperlinkTabPageBase::FillStandardDlgFields ( const SvxHyperlinkItem* pH mpEdText->SetText ( pHyperlinkItem->GetIntName() ); // Script-button - if ( !pHyperlinkItem->GetMacroEvents() ) + if ( pHyperlinkItem->GetMacroEvents() == HyperDialogEvent::NONE ) mpBtScript->Disable(); else mpBtScript->Enable(); @@ -344,7 +344,7 @@ IMPL_LINK_NOARG_TYPED(SvxHyperlinkTabPageBase, ClickScriptHdl_Impl, Button*, voi SvxHyperlinkItem *pHyperlinkItem = const_cast<SvxHyperlinkItem*>(static_cast<const SvxHyperlinkItem *>( GetItemSet().GetItem (SID_HYPERLINK_GETLINK))); - if ( pHyperlinkItem->GetMacroEvents() ) + if ( pHyperlinkItem->GetMacroEvents() != HyperDialogEvent::NONE ) { // get macros from itemset const SvxMacroTableDtor* pMacroTbl = pHyperlinkItem->GetMacroTable(); @@ -370,13 +370,13 @@ IMPL_LINK_NOARG_TYPED(SvxHyperlinkTabPageBase, ClickScriptHdl_Impl, Button*, voi // add events SfxMacroTabPage *pMacroPage = static_cast<SfxMacroTabPage*>( aDlg->GetTabPage() ); - if ( pHyperlinkItem->GetMacroEvents() & HYPERDLG_EVENT_MOUSEOVER_OBJECT ) + if ( pHyperlinkItem->GetMacroEvents() & HyperDialogEvent::MouseOverObject ) pMacroPage->AddEvent( OUString( CUI_RESSTR(RID_SVXSTR_HYPDLG_MACROACT1) ), SFX_EVENT_MOUSEOVER_OBJECT ); - if ( pHyperlinkItem->GetMacroEvents() & HYPERDLG_EVENT_MOUSECLICK_OBJECT ) + if ( pHyperlinkItem->GetMacroEvents() & HyperDialogEvent::MouseClickObject ) pMacroPage->AddEvent( OUString( CUI_RESSTR(RID_SVXSTR_HYPDLG_MACROACT2) ), SFX_EVENT_MOUSECLICK_OBJECT); - if ( pHyperlinkItem->GetMacroEvents() & HYPERDLG_EVENT_MOUSEOUT_OBJECT ) + if ( pHyperlinkItem->GetMacroEvents() & HyperDialogEvent::MouseOutObject ) pMacroPage->AddEvent( OUString( CUI_RESSTR(RID_SVXSTR_HYPDLG_MACROACT3) ), SFX_EVENT_MOUSEOUT_OBJECT); @@ -400,7 +400,7 @@ IMPL_LINK_NOARG_TYPED(SvxHyperlinkTabPageBase, ClickScriptHdl_Impl, Button*, voi } // Get Macro-Infos -sal_uInt16 SvxHyperlinkTabPageBase::GetMacroEvents() +HyperDialogEvent SvxHyperlinkTabPageBase::GetMacroEvents() { const SvxHyperlinkItem *pHyperlinkItem = static_cast<const SvxHyperlinkItem *>( GetItemSet().GetItem (SID_HYPERLINK_GETLINK)); @@ -496,7 +496,7 @@ bool SvxHyperlinkTabPageBase::FillItemSet( SfxItemSet* rOut) if ( aStrName.isEmpty() ) //automatically create a visible name if the link is created without name aStrName = CreateUiNameFromURL(aStrURL); - sal_uInt16 nEvents = GetMacroEvents(); + HyperDialogEvent nEvents = GetMacroEvents(); SvxMacroTableDtor* pTable = GetMacroTable(); SvxHyperlinkItem aItem( SID_HYPERLINK_SETLINK, aStrName, aStrURL, aStrFrame, @@ -537,7 +537,7 @@ int SvxHyperlinkTabPageBase::DeactivatePage( SfxItemSet* _pSet) GetCurentItemData ( aStrURL, aStrName, aStrIntName, aStrFrame, eMode); - sal_uInt16 nEvents = GetMacroEvents(); + HyperDialogEvent nEvents = GetMacroEvents(); SvxMacroTableDtor* pTable = GetMacroTable(); if( _pSet ) diff --git a/cui/source/inc/hltpbase.hxx b/cui/source/inc/hltpbase.hxx index 043ab0130bda..b3cc61b147f9 100644 --- a/cui/source/inc/hltpbase.hxx +++ b/cui/source/inc/hltpbase.hxx @@ -149,7 +149,7 @@ protected: SfxDispatcher* GetDispatcher() const; - sal_uInt16 GetMacroEvents(); + HyperDialogEvent GetMacroEvents(); SvxMacroTableDtor* GetMacroTable(); bool IsHTMLDoc() const; diff --git a/include/svx/hlnkitem.hxx b/include/svx/hlnkitem.hxx index 24d79c9df7eb..8f73036dbfd9 100644 --- a/include/svx/hlnkitem.hxx +++ b/include/svx/hlnkitem.hxx @@ -24,10 +24,17 @@ #include <sfx2/sfxsids.hrc> #include <svl/macitem.hxx> #include <svx/svxdllapi.h> +#include <o3tl/typed_flags_set.hxx> -#define HYPERDLG_EVENT_MOUSEOVER_OBJECT 0x0001 -#define HYPERDLG_EVENT_MOUSECLICK_OBJECT 0x0002 -#define HYPERDLG_EVENT_MOUSEOUT_OBJECT 0x0004 +enum class HyperDialogEvent { + NONE = 0x0000, + MouseOverObject = 0x0001, + MouseClickObject = 0x0002, + MouseOutObject = 0x0004, +}; +namespace o3tl { + template<> struct typed_flags<HyperDialogEvent> : is_typed_flags<HyperDialogEvent, 0x07> {}; +} enum SvxLinkInsertMode { @@ -47,18 +54,18 @@ class SVX_DLLPUBLIC SvxHyperlinkItem : public SfxPoolItem OUString sIntName; SvxMacroTableDtor* pMacroTable; - sal_uInt16 nMacroEvents; + HyperDialogEvent nMacroEvents; public: static SfxPoolItem* CreateDefault(); SvxHyperlinkItem( sal_uInt16 _nWhich = SID_HYPERLINK_GETLINK ): - SfxPoolItem(_nWhich), pMacroTable(nullptr) { eType = HLINK_DEFAULT; nMacroEvents=0; }; + SfxPoolItem(_nWhich), pMacroTable(nullptr) { eType = HLINK_DEFAULT; nMacroEvents=HyperDialogEvent::NONE; }; SvxHyperlinkItem( const SvxHyperlinkItem& rHyperlinkItem ); SvxHyperlinkItem( sal_uInt16 nWhich, const OUString& rName, const OUString& rURL, const OUString& rTarget, const OUString& rIntName, SvxLinkInsertMode eTyp = HLINK_FIELD, - sal_uInt16 nEvents = 0, + HyperDialogEvent nEvents = HyperDialogEvent::NONE, SvxMacroTableDtor *pMacroTbl =nullptr ); virtual ~SvxHyperlinkItem () { delete pMacroTable; } @@ -84,13 +91,13 @@ public: SvxLinkInsertMode GetInsertMode() const { return eType; } void SetInsertMode( SvxLinkInsertMode eNew ) { eType = eNew; } - void SetMacro( sal_uInt16 nEvent, const SvxMacro& rMacro ); + void SetMacro( HyperDialogEvent nEvent, const SvxMacro& rMacro ); void SetMacroTable( const SvxMacroTableDtor& rTbl ); const SvxMacroTableDtor* GetMacroTable() const { return pMacroTable; } - void SetMacroEvents (const sal_uInt16 nEvents) { nMacroEvents = nEvents; } - sal_uInt16 GetMacroEvents() const { return nMacroEvents; } + void SetMacroEvents (const HyperDialogEvent nEvents) { nMacroEvents = nEvents; } + HyperDialogEvent GetMacroEvents() const { return nMacroEvents; } virtual SvStream& Store( SvStream &, sal_uInt16 nItemVersion ) const override; virtual SfxPoolItem* Create( SvStream &, sal_uInt16 nVer ) const override; diff --git a/svx/source/items/hlnkitem.cxx b/svx/source/items/hlnkitem.cxx index 5ff6e27ca847..f9165f6cdbb0 100644 --- a/svx/source/items/hlnkitem.cxx +++ b/svx/source/items/hlnkitem.cxx @@ -51,7 +51,7 @@ SvStream& SvxHyperlinkItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ rStrm.WriteUniOrByteString(sIntName, rStrm.GetStreamCharSet()); // macro-events - rStrm.WriteUInt16( nMacroEvents ); + rStrm.WriteUInt16( (sal_uInt16)nMacroEvents ); // store macros sal_uInt16 nCnt = pMacroTable ? (sal_uInt16)pMacroTable->size() : 0; @@ -141,7 +141,9 @@ SfxPoolItem* SvxHyperlinkItem::Create( SvStream &rStrm, sal_uInt16 /*nItemVer pNew->sIntName = rStrm.ReadUniOrByteString(rStrm.GetStreamCharSet()); // macro-events - rStrm.ReadUInt16( pNew->nMacroEvents ); + sal_uInt16 nTmp; + rStrm.ReadUInt16(nTmp); + pNew->nMacroEvents = (HyperDialogEvent)nTmp; // macros sal_uInt16 nCnt; @@ -158,7 +160,7 @@ SfxPoolItem* SvxHyperlinkItem::Create( SvStream &rStrm, sal_uInt16 /*nItemVer // UNICODE: rStrm >> aMacName; aMacName = rStrm.ReadUniOrByteString(rStrm.GetStreamCharSet()); - pNew->SetMacro( nCurKey, SvxMacro( aMacName, aLibName, STARBASIC ) ); + pNew->SetMacro( (HyperDialogEvent)nCurKey, SvxMacro( aMacName, aLibName, STARBASIC ) ); } rStrm.ReadUInt16( nCnt ); @@ -177,7 +179,7 @@ SfxPoolItem* SvxHyperlinkItem::Create( SvStream &rStrm, sal_uInt16 /*nItemVer rStrm.ReadUInt16( nScriptType ); - pNew->SetMacro( nCurKey, SvxMacro( aMacName, aLibName, + pNew->SetMacro( (HyperDialogEvent)nCurKey, SvxMacro( aMacName, aLibName, (ScriptType)nScriptType ) ); } } @@ -206,7 +208,7 @@ SvxHyperlinkItem::SvxHyperlinkItem( const SvxHyperlinkItem& rHyperlinkItem ): SvxHyperlinkItem::SvxHyperlinkItem( sal_uInt16 _nWhich, const OUString& rName, const OUString& rURL, const OUString& rTarget, const OUString& rIntName, SvxLinkInsertMode eTyp, - sal_uInt16 nEvents, SvxMacroTableDtor *pMacroTbl ): + HyperDialogEvent nEvents, SvxMacroTableDtor *pMacroTbl ): SfxPoolItem (_nWhich), sName (rName), sURL (rURL), @@ -253,28 +255,27 @@ bool SvxHyperlinkItem::operator==( const SfxPoolItem& rAttr ) const return rOwn == rOther; } -void SvxHyperlinkItem::SetMacro( sal_uInt16 nEvent, const SvxMacro& rMacro ) +void SvxHyperlinkItem::SetMacro( HyperDialogEvent nEvent, const SvxMacro& rMacro ) { - if( nEvent < EVENT_SFX_START ) + sal_uInt16 nSfxEvent = 0; + switch( nEvent ) { - switch( nEvent ) - { - case HYPERDLG_EVENT_MOUSEOVER_OBJECT: - nEvent = SFX_EVENT_MOUSEOVER_OBJECT; - break; - case HYPERDLG_EVENT_MOUSECLICK_OBJECT: - nEvent = SFX_EVENT_MOUSECLICK_OBJECT; - break; - case HYPERDLG_EVENT_MOUSEOUT_OBJECT: - nEvent = SFX_EVENT_MOUSEOUT_OBJECT; - break; - } + case HyperDialogEvent::MouseOverObject: + nSfxEvent = SFX_EVENT_MOUSEOVER_OBJECT; + break; + case HyperDialogEvent::MouseClickObject: + nSfxEvent = SFX_EVENT_MOUSECLICK_OBJECT; + break; + case HyperDialogEvent::MouseOutObject: + nSfxEvent = SFX_EVENT_MOUSEOUT_OBJECT; + break; + default: break; } if( !pMacroTable ) pMacroTable = new SvxMacroTableDtor; - pMacroTable->Insert( nEvent, rMacro); + pMacroTable->Insert( nSfxEvent, rMacro); } void SvxHyperlinkItem::SetMacroTable( const SvxMacroTableDtor& rTbl ) diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx index cf44195e9f12..fe8b8277bfa5 100644 --- a/sw/source/uibase/shells/textsh.cxx +++ b/sw/source/uibase/shells/textsh.cxx @@ -652,15 +652,15 @@ void SwTextShell::StateInsert( SfxItemSet &rSet ) aHLinkItem.SetIntName(pINetFormat->GetName()); const SvxMacro *pMacro = pINetFormat->GetMacro( SFX_EVENT_MOUSEOVER_OBJECT ); if( pMacro ) - aHLinkItem.SetMacro(HYPERDLG_EVENT_MOUSEOVER_OBJECT, *pMacro); + aHLinkItem.SetMacro(HyperDialogEvent::MouseOverObject, *pMacro); pMacro = pINetFormat->GetMacro( SFX_EVENT_MOUSECLICK_OBJECT ); if( pMacro ) - aHLinkItem.SetMacro(HYPERDLG_EVENT_MOUSECLICK_OBJECT, *pMacro); + aHLinkItem.SetMacro(HyperDialogEvent::MouseClickObject, *pMacro); pMacro = pINetFormat->GetMacro( SFX_EVENT_MOUSEOUT_OBJECT ); if( pMacro ) - aHLinkItem.SetMacro(HYPERDLG_EVENT_MOUSEOUT_OBJECT, *pMacro); + aHLinkItem.SetMacro(HyperDialogEvent::MouseOutObject, *pMacro); // Get the text of the Link. rSh.StartAction(); @@ -681,8 +681,8 @@ void SwTextShell::StateInsert( SfxItemSet &rSet ) aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() | (bHtmlModeOn ? HLINK_HTMLMODE : 0))); - aHLinkItem.SetMacroEvents ( HYPERDLG_EVENT_MOUSEOVER_OBJECT| - HYPERDLG_EVENT_MOUSECLICK_OBJECT | HYPERDLG_EVENT_MOUSEOUT_OBJECT ); + aHLinkItem.SetMacroEvents ( HyperDialogEvent::MouseOverObject| + HyperDialogEvent::MouseClickObject | HyperDialogEvent::MouseOutObject ); rSet.Put(aHLinkItem); } |