summaryrefslogtreecommitdiff
path: root/svtools/source/uno/unoevent.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-07-25 10:03:44 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-07-25 12:21:22 +0200
commit31a85a9a13595a9aeae1932ee08c9b09ead384cd (patch)
treed3cf4136e21a3acee1ddbf77aca62f3d73c3ed55 /svtools/source/uno/unoevent.cxx
parent2fffaf6f05d829e345ad8b391646a6e8df9a9a26 (diff)
convert UNO event ids to scoped enum
I'm fairly sure there are more simplifications that could be make here. It seems like we have both an ID and a string name for all of these events, and we could probably get by with just one of those, or alternately, centralise the name<->id mapping somewhere Change-Id: I978073822ddbebce94ac5b560fea675bea905a35 Reviewed-on: https://gerrit.libreoffice.org/40392 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools/source/uno/unoevent.cxx')
-rw-r--r--svtools/source/uno/unoevent.cxx43
1 files changed, 22 insertions, 21 deletions
diff --git a/svtools/source/uno/unoevent.cxx b/svtools/source/uno/unoevent.cxx
index 04e335a146a1..351f6a76b999 100644
--- a/svtools/source/uno/unoevent.cxx
+++ b/svtools/source/uno/unoevent.cxx
@@ -21,6 +21,7 @@
#include <cppuhelper/supportsservice.hxx>
#include <osl/diagnose.h>
#include <rtl/ustrbuf.hxx>
+#include <sfx2/event.hxx>
#include <svtools/unoevent.hxx>
#include <svl/macitem.hxx>
@@ -238,7 +239,7 @@ SvBaseEventDescriptor::SvBaseEventDescriptor( const SvEventDescription* pSupport
{
assert(pSupportedMacroItems != nullptr && "Need a list of supported events!");
- for( ; mpSupportedMacroItems[mnMacroItems].mnEvent != 0; mnMacroItems++) ;
+ for( ; mpSupportedMacroItems[mnMacroItems].mnEvent != SvMacroItemId::NONE; mnMacroItems++) ;
}
@@ -250,10 +251,10 @@ void SvBaseEventDescriptor::replaceByName(
const OUString& rName,
const Any& rElement )
{
- sal_uInt16 nMacroID = getMacroID(rName);
+ SvMacroItemId nMacroID = getMacroID(rName);
// error checking
- if (0 == nMacroID)
+ if (SvMacroItemId::NONE == nMacroID)
throw NoSuchElementException();
if (rElement.getValueType() != getElementType())
throw IllegalArgumentException();
@@ -271,10 +272,10 @@ void SvBaseEventDescriptor::replaceByName(
Any SvBaseEventDescriptor::getByName(
const OUString& rName )
{
- sal_uInt16 nMacroID = getMacroID(rName);
+ SvMacroItemId nMacroID = getMacroID(rName);
// error checking
- if (0 == nMacroID)
+ if (SvMacroItemId::NONE == nMacroID)
throw NoSuchElementException();
// perform get (in subclass)
@@ -300,8 +301,8 @@ Sequence<OUString> SvBaseEventDescriptor::getElementNames()
sal_Bool SvBaseEventDescriptor::hasByName(
const OUString& rName )
{
- sal_uInt16 nMacroID = getMacroID(rName);
- return (nMacroID != 0);
+ SvMacroItemId nMacroID = getMacroID(rName);
+ return (nMacroID != SvMacroItemId::NONE);
}
Type SvBaseEventDescriptor::getElementType()
@@ -326,7 +327,7 @@ Sequence<OUString> SvBaseEventDescriptor::getSupportedServiceNames()
return aSequence;
}
-sal_uInt16 SvBaseEventDescriptor::mapNameToEventID(const OUString& rName) const
+SvMacroItemId SvBaseEventDescriptor::mapNameToEventID(const OUString& rName) const
{
// iterate over known event names
for(sal_Int16 i = 0; i < mnMacroItems; i++)
@@ -338,10 +339,10 @@ sal_uInt16 SvBaseEventDescriptor::mapNameToEventID(const OUString& rName) const
}
// not found -> return zero
- return 0;
+ return SvMacroItemId::NONE;
}
-sal_uInt16 SvBaseEventDescriptor::getMacroID(const OUString& rName) const
+SvMacroItemId SvBaseEventDescriptor::getMacroID(const OUString& rName) const
{
return mapNameToEventID(rName);
}
@@ -361,7 +362,7 @@ SvEventDescriptor::~SvEventDescriptor()
}
void SvEventDescriptor::replaceByName(
- const sal_uInt16 nEvent,
+ const SvMacroItemId nEvent,
const SvxMacro& rMacro)
{
SvxMacroItem aItem(getMacroItemWhich());
@@ -372,7 +373,7 @@ void SvEventDescriptor::replaceByName(
void SvEventDescriptor::getByName(
SvxMacro& rMacro,
- const sal_uInt16 nEvent )
+ const SvMacroItemId nEvent )
{
const SvxMacroItem& rItem = getMacroItem();
if( rItem.HasMacro( nEvent ) )
@@ -397,12 +398,12 @@ SvDetachedEventDescriptor::~SvDetachedEventDescriptor()
{
}
-sal_Int16 SvDetachedEventDescriptor::getIndex(const sal_uInt16 nID) const
+sal_Int16 SvDetachedEventDescriptor::getIndex(const SvMacroItemId nID) const
{
// iterate over supported events
sal_Int16 nIndex = 0;
while ( (mpSupportedMacroItems[nIndex].mnEvent != nID) &&
- (mpSupportedMacroItems[nIndex].mnEvent != 0) )
+ (mpSupportedMacroItems[nIndex].mnEvent != SvMacroItemId::NONE) )
{
nIndex++;
}
@@ -416,7 +417,7 @@ OUString SvDetachedEventDescriptor::getImplementationName()
void SvDetachedEventDescriptor::replaceByName(
- const sal_uInt16 nEvent,
+ const SvMacroItemId nEvent,
const SvxMacro& rMacro)
{
sal_Int16 nIndex = getIndex(nEvent);
@@ -430,7 +431,7 @@ void SvDetachedEventDescriptor::replaceByName(
void SvDetachedEventDescriptor::getByName(
SvxMacro& rMacro,
- const sal_uInt16 nEvent )
+ const SvMacroItemId nEvent )
{
sal_Int16 nIndex = getIndex(nEvent);
if (-1 == nIndex )
@@ -441,7 +442,7 @@ void SvDetachedEventDescriptor::getByName(
}
bool SvDetachedEventDescriptor::hasById(
- const sal_uInt16 nEvent ) const /// item ID of event
+ const SvMacroItemId nEvent ) const /// item ID of event
{
sal_Int16 nIndex = getIndex(nEvent);
if (-1 == nIndex)
@@ -461,9 +462,9 @@ SvMacroTableEventDescriptor::SvMacroTableEventDescriptor(
const SvEventDescription* pSupportedMacroItems) :
SvDetachedEventDescriptor(pSupportedMacroItems)
{
- for(sal_Int16 i = 0; mpSupportedMacroItems[i].mnEvent != 0; i++)
+ for(sal_Int16 i = 0; mpSupportedMacroItems[i].mnEvent != SvMacroItemId::NONE; i++)
{
- const sal_uInt16 nEvent = mpSupportedMacroItems[i].mnEvent;
+ const SvMacroItemId nEvent = mpSupportedMacroItems[i].mnEvent;
const SvxMacro* pMacro = rMacroTable.Get(nEvent);
if (nullptr != pMacro)
replaceByName(nEvent, *pMacro);
@@ -477,9 +478,9 @@ SvMacroTableEventDescriptor::~SvMacroTableEventDescriptor()
void SvMacroTableEventDescriptor::copyMacrosIntoTable(
SvxMacroTableDtor& rMacroTable)
{
- for(sal_Int16 i = 0; mpSupportedMacroItems[i].mnEvent != 0; i++)
+ for(sal_Int16 i = 0; mpSupportedMacroItems[i].mnEvent != SvMacroItemId::NONE; i++)
{
- const sal_uInt16 nEvent = mpSupportedMacroItems[i].mnEvent;
+ const SvMacroItemId nEvent = mpSupportedMacroItems[i].mnEvent;
if (hasById(nEvent))
{
SvxMacro& rMacro = rMacroTable.Insert(nEvent, SvxMacro("", ""));