Kaydet (Commit) d2f6f863 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

loplugin:stringconstant

Change-Id: I08430479a2c8d1fd6e3fc357ba3069b3a7bb6ac8
üst eb760663
......@@ -150,19 +150,6 @@ protected:
/// get the event ID for the name; return 0 if not supported
sal_uInt16 getMacroID(const OUString& rName) const;
/// create PropertyValues and Any from macro
void getAnyFromMacro(
css::uno::Any& aAny, // Any to be filled by Macro values
const SvxMacro& rMacro);
/// create macro from PropertyValues (in an Any)
void getMacroFromAny(
SvxMacro& aMacro, // reference to be filled by Any
const css::uno::Any& rAny)
throw (
css::lang::IllegalArgumentException);
};
......
......@@ -45,138 +45,9 @@ static const char sJavaScript[] = "JavaScript";
static const char sScript[] = "Script";
static const char sNone[] = "None";
namespace {
SvBaseEventDescriptor::SvBaseEventDescriptor( const SvEventDescription* pSupportedMacroItems ) :
mpSupportedMacroItems(pSupportedMacroItems),
mnMacroItems(0)
{
assert(pSupportedMacroItems != nullptr && "Need a list of supported events!");
for( ; mpSupportedMacroItems[mnMacroItems].mnEvent != 0; mnMacroItems++) ;
}
SvBaseEventDescriptor::~SvBaseEventDescriptor()
{
}
void SvBaseEventDescriptor::replaceByName(
const OUString& rName,
const Any& rElement )
throw(
IllegalArgumentException,
NoSuchElementException,
WrappedTargetException,
RuntimeException, std::exception)
{
sal_uInt16 nMacroID = getMacroID(rName);
// error checking
if (0 == nMacroID)
throw NoSuchElementException();
if (rElement.getValueType() != getElementType())
throw IllegalArgumentException();
// get sequence
Sequence<PropertyValue> aSequence;
rElement >>= aSequence;
// perform replace (in subclass)
SvxMacro aMacro("","");
getMacroFromAny(aMacro, rElement);
replaceByName(nMacroID, aMacro);
}
Any SvBaseEventDescriptor::getByName(
const OUString& rName )
throw(
NoSuchElementException,
WrappedTargetException,
RuntimeException, std::exception)
{
sal_uInt16 nMacroID = getMacroID(rName);
// error checking
if (0 == nMacroID)
throw NoSuchElementException();
// perform get (in subclass)
Any aAny;
SvxMacro aMacro( "", "" );
getByName(aMacro, nMacroID);
getAnyFromMacro(aAny, aMacro);
return aAny;
}
Sequence<OUString> SvBaseEventDescriptor::getElementNames()
throw(RuntimeException, std::exception)
{
// create and fill sequence
Sequence<OUString> aSequence(mnMacroItems);
for( sal_Int16 i = 0; i < mnMacroItems; i++)
{
aSequence[i] = OUString::createFromAscii( mpSupportedMacroItems[i].mpEventName );
}
return aSequence;
}
sal_Bool SvBaseEventDescriptor::hasByName(
const OUString& rName )
throw(RuntimeException, std::exception)
{
sal_uInt16 nMacroID = getMacroID(rName);
return (nMacroID != 0);
}
Type SvBaseEventDescriptor::getElementType()
throw(RuntimeException, std::exception)
{
return cppu::UnoType<Sequence<PropertyValue>>::get();
}
sal_Bool SvBaseEventDescriptor::hasElements()
throw(RuntimeException, std::exception)
{
return mnMacroItems != 0;
}
sal_Bool SvBaseEventDescriptor::supportsService(const OUString& rServiceName)
throw(RuntimeException, std::exception)
{
return cppu::supportsService(this, rServiceName);
}
Sequence<OUString> SvBaseEventDescriptor::getSupportedServiceNames()
throw(RuntimeException, std::exception)
{
Sequence<OUString> aSequence { sAPI_ServiceName };
return aSequence;
}
sal_uInt16 SvBaseEventDescriptor::mapNameToEventID(const OUString& rName) const
{
// iterate over known event names
for(sal_Int16 i = 0; i < mnMacroItems; i++)
{
if( rName.equalsAscii(mpSupportedMacroItems[i].mpEventName))
{
return mpSupportedMacroItems[i].mnEvent;
}
}
// not found -> return zero
return 0;
}
sal_uInt16 SvBaseEventDescriptor::getMacroID(const OUString& rName) const
{
return mapNameToEventID(rName);
}
void SvBaseEventDescriptor::getAnyFromMacro(Any& rAny,
const SvxMacro& rMacro)
void getAnyFromMacro(Any& rAny, const SvxMacro& rMacro)
{
bool bRetValueOK = false; // do we have a ret value?
......@@ -266,8 +137,7 @@ void SvBaseEventDescriptor::getAnyFromMacro(Any& rAny,
}
}
void SvBaseEventDescriptor::getMacroFromAny(
void getMacroFromAny(
SvxMacro& rMacro,
const Any& rAny)
throw ( IllegalArgumentException )
......@@ -363,6 +233,136 @@ void SvBaseEventDescriptor::getMacroFromAny(
}
}
}
SvBaseEventDescriptor::SvBaseEventDescriptor( const SvEventDescription* pSupportedMacroItems ) :
mpSupportedMacroItems(pSupportedMacroItems),
mnMacroItems(0)
{
assert(pSupportedMacroItems != nullptr && "Need a list of supported events!");
for( ; mpSupportedMacroItems[mnMacroItems].mnEvent != 0; mnMacroItems++) ;
}
SvBaseEventDescriptor::~SvBaseEventDescriptor()
{
}
void SvBaseEventDescriptor::replaceByName(
const OUString& rName,
const Any& rElement )
throw(
IllegalArgumentException,
NoSuchElementException,
WrappedTargetException,
RuntimeException, std::exception)
{
sal_uInt16 nMacroID = getMacroID(rName);
// error checking
if (0 == nMacroID)
throw NoSuchElementException();
if (rElement.getValueType() != getElementType())
throw IllegalArgumentException();
// get sequence
Sequence<PropertyValue> aSequence;
rElement >>= aSequence;
// perform replace (in subclass)
SvxMacro aMacro("","");
getMacroFromAny(aMacro, rElement);
replaceByName(nMacroID, aMacro);
}
Any SvBaseEventDescriptor::getByName(
const OUString& rName )
throw(
NoSuchElementException,
WrappedTargetException,
RuntimeException, std::exception)
{
sal_uInt16 nMacroID = getMacroID(rName);
// error checking
if (0 == nMacroID)
throw NoSuchElementException();
// perform get (in subclass)
Any aAny;
SvxMacro aMacro( "", "" );
getByName(aMacro, nMacroID);
getAnyFromMacro(aAny, aMacro);
return aAny;
}
Sequence<OUString> SvBaseEventDescriptor::getElementNames()
throw(RuntimeException, std::exception)
{
// create and fill sequence
Sequence<OUString> aSequence(mnMacroItems);
for( sal_Int16 i = 0; i < mnMacroItems; i++)
{
aSequence[i] = OUString::createFromAscii( mpSupportedMacroItems[i].mpEventName );
}
return aSequence;
}
sal_Bool SvBaseEventDescriptor::hasByName(
const OUString& rName )
throw(RuntimeException, std::exception)
{
sal_uInt16 nMacroID = getMacroID(rName);
return (nMacroID != 0);
}
Type SvBaseEventDescriptor::getElementType()
throw(RuntimeException, std::exception)
{
return cppu::UnoType<Sequence<PropertyValue>>::get();
}
sal_Bool SvBaseEventDescriptor::hasElements()
throw(RuntimeException, std::exception)
{
return mnMacroItems != 0;
}
sal_Bool SvBaseEventDescriptor::supportsService(const OUString& rServiceName)
throw(RuntimeException, std::exception)
{
return cppu::supportsService(this, rServiceName);
}
Sequence<OUString> SvBaseEventDescriptor::getSupportedServiceNames()
throw(RuntimeException, std::exception)
{
Sequence<OUString> aSequence { sAPI_ServiceName };
return aSequence;
}
sal_uInt16 SvBaseEventDescriptor::mapNameToEventID(const OUString& rName) const
{
// iterate over known event names
for(sal_Int16 i = 0; i < mnMacroItems; i++)
{
if( rName.equalsAscii(mpSupportedMacroItems[i].mpEventName))
{
return mpSupportedMacroItems[i].mnEvent;
}
}
// not found -> return zero
return 0;
}
sal_uInt16 SvBaseEventDescriptor::getMacroID(const OUString& rName) const
{
return mapNameToEventID(rName);
}
SvEventDescriptor::SvEventDescriptor(
XInterface& rParent,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment