20#include <com/sun/star/beans/PropertyValue.hpp>
25#include <osl/diagnose.h>
31using namespace css::uno;
33using css::container::NoSuchElementException;
34using css::container::XNameReplace;
35using css::lang::IllegalArgumentException;
36using css::beans::PropertyValue;
45constexpr OUStringLiteral
sNone =
u"None";
49void getAnyFromMacro(
Any& rAny,
const SvxMacro& rMacro)
51 bool bRetValueOK =
false;
60 Sequence<PropertyValue> aSequence(
75 Sequence<PropertyValue> aSequence(
87 OSL_FAIL(
"not implemented");
107 Sequence<PropertyValue> aSequence;
111 bool bTypeOK =
false;
117 for (
const PropertyValue& aValue : std::as_const(aSequence))
122 aValue.Value >>= sTmp;
128 else if (sTmp ==
"JavaScript")
138 else if (sTmp ==
sNone)
147 aValue.Value >>= sMacroVal;
151 aValue.Value >>= sLibVal;
153 else if (aValue.Name ==
sScript)
155 aValue.Value >>= sScriptVal;
163 throw IllegalArgumentException();
173 if (eType == STARBASIC)
176 SvxMacro aMacro(sMacroVal, sLibVal, eType);
179 else if (eType == EXTENDED_STYPE)
188 throw IllegalArgumentException();
196 mpSupportedMacroItems(pSupportedMacroItems),
199 assert(pSupportedMacroItems !=
nullptr &&
"Need a list of supported events!");
210 const OUString& rName,
211 const Any& rElement )
216 if (SvMacroItemId::NONE == nMacroID)
217 throw NoSuchElementException();
219 throw IllegalArgumentException();
222 Sequence<PropertyValue> aSequence;
223 rElement >>= aSequence;
227 getMacroFromAny(aMacro, rElement);
232 const OUString& rName )
237 if (SvMacroItemId::NONE == nMacroID)
238 throw NoSuchElementException();
244 getAnyFromMacro(aAny, aMacro);
252 auto aSequenceRange = asNonConstRange(aSequence);
262 const OUString& rName )
265 return (nMacroID != SvMacroItemId::NONE);
300 return SvMacroItemId::NONE;
342 rMacro = aEmptyMacro;
371 return "SvDetachedEventDescriptor";
381 throw IllegalArgumentException();
394 throw NoSuchElementException();
403 sal_Int16
nIndex = getIndex(nEvent);
405 throw IllegalArgumentException();
407 return (
nullptr != aMacros[
nIndex]) && aMacros[
nIndex]->HasMacro();
426 if (
nullptr != pMacro)
SvBaseEventDescriptor: Abstract class that implements the basics of an XNameReplace that is delivered...
virtual sal_Bool SAL_CALL hasElements() override
virtual css::uno::Type SAL_CALL getElementType() override
virtual ~SvBaseEventDescriptor() override
const SvEventDescription * mpSupportedMacroItems
last element is 0, 0
virtual sal_Bool SAL_CALL hasByName(const OUString &rName) override
SvMacroItemId mapNameToEventID(std::u16string_view rName) const
convert an API event name to the event ID as used by SvxMacroItem
virtual void SAL_CALL replaceByName(const OUString &rName, const css::uno::Any &rElement) override
calls replaceByName(const sal_uInt16, const SvxMacro&)
virtual css::uno::Any SAL_CALL getByName(const OUString &rName) override
calls getByName(sal_uInt16)
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
SvMacroItemId getMacroID(std::u16string_view rName) const
get the event ID for the name; return 0 if not supported
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
SvBaseEventDescriptor(const SvEventDescription *pSupportedMacroItems)
SvDetachedEventDescriptor:
virtual OUString SAL_CALL getImplementationName() override
must be implemented in subclass
virtual ~SvDetachedEventDescriptor() override
bool hasById(const SvMacroItemId nEvent) const
do we have an event? return true: we have a macro for the event return false: no macro; getByName() w...
SvDetachedEventDescriptor(const SvEventDescription *pSupportedMacroItems)
virtual void getByName(SvxMacro &rMacro, const SvMacroItemId nEvent) override
item ID of event
virtual void replaceByName(const SvMacroItemId nEvent, const SvxMacro &rMacro) override
event (will be copied)
std::vector< std::unique_ptr< SvxMacro > > aMacros
sal_Int16 getIndex(const SvMacroItemId nID) const
SvEventDescriptor(css::uno::XInterface &rParent, const SvEventDescription *pSupportedMacroItems)
virtual void setMacroItem(const SvxMacroItem &rItem)=0
Set the SvxMacroItem at the parent.
virtual const SvxMacroItem & getMacroItem()=0
Get the SvxMacroItem from the parent.
virtual sal_uInt16 getMacroItemWhich() const =0
Get the SvxMacroItem Which Id needed for the current application must be implemented by subclass.
virtual ~SvEventDescriptor() override
virtual void replaceByName(const SvMacroItemId nEvent, const SvxMacro &rMacro) override
event (will be copied)
virtual void getByName(SvxMacro &rMacros, const SvMacroItemId nEvent) override
item ID of event
SvMacroTableEventDescriptor(const SvEventDescription *pSupportedMacroItems)
virtual ~SvMacroTableEventDescriptor() override
void copyMacrosIntoTable(SvxMacroTableDtor &aFmt)
const SvxMacro & GetMacro(SvMacroItemId nEvent) const
bool HasMacro(SvMacroItemId nEvent) const
void SetMacroTable(const SvxMacroTableDtor &rTbl)
void SetMacro(SvMacroItemId nEvent, const SvxMacro &)
SvxMacro & Insert(SvMacroItemId nEvent, const SvxMacro &rMacro)
const SvxMacro * Get(SvMacroItemId nEvent) const
const OUString & GetMacName() const
ScriptType GetScriptType() const
const OUString & GetLibName() const
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
bool equalsAscii(std::u16string_view s1, std::string_view s2)
SvEventDescription: Description of a single event.
constexpr OUStringLiteral sScript
constexpr OUStringLiteral sLibrary
constexpr OUStringLiteral sAPI_ServiceName
constexpr OUStringLiteral sStarBasic
constexpr OUStringLiteral sMacroName
constexpr OUStringLiteral sNone
constexpr OUStringLiteral sEventType