22#include <com/sun/star/beans/PropertyValue.hpp>
25#include <osl/diagnose.h>
32 using ::com::sun::star::uno::Any;
33 using ::com::sun::star::beans::PropertyValue;
34 using ::com::sun::star::container::NoSuchElementException;
35 using ::com::sun::star::lang::IllegalArgumentException;
36 using ::com::sun::star::uno::Sequence;
37 using ::com::sun::star::uno::Type;
42 struct DocumentEventData
48 const DocumentEventData* lcl_getDocumentEventData()
50 static const DocumentEventData s_aData[] = {
52 {
"OnLoadFinished",
true },
56 {
"OnSaveAsDone",
false },
57 {
"OnSaveAsFailed",
false },
59 {
"OnSaveDone",
false },
60 {
"OnSaveFailed",
false },
62 {
"OnSaveToDone",
false },
63 {
"OnSaveToFailed",
false },
64 {
"OnPrepareUnload",
true },
67 {
"OnUnfocus",
false },
68 {
"OnModifyChanged",
false },
69 {
"OnViewCreated",
false },
70 {
"OnPrepareViewClosing",
true },
71 {
"OnViewClosed",
false },
72 {
"OnTitleChanged",
false },
73 {
"OnSubComponentOpened",
false },
74 {
"OnSubComponentClosed",
false },
83 :
mrParent(_rParent), mrMutex(_rMutex), mrEventsData(_rEventsData)
85 const DocumentEventData* pEventData = lcl_getDocumentEventData();
86 while ( pEventData->pAsciiEventName )
88 OUString sEventName = OUString::createFromAscii( pEventData->pAsciiEventName );
89 DocumentEventsData::const_iterator existingPos =
mrEventsData.find( sEventName );
91 mrEventsData[ sEventName ] = Sequence< PropertyValue >();
112 const DocumentEventData* pEventData = lcl_getDocumentEventData();
113 while ( pEventData->pAsciiEventName )
116 return pEventData->bNeedsSyncNotify;
126 ::osl::MutexGuard aGuard(
mrMutex );
130 throw NoSuchElementException(
Name, *
this );
132 Sequence< PropertyValue > aEventDescriptor;
133 if ( Element.hasValue() && !( Element >>= aEventDescriptor ) )
134 throw IllegalArgumentException( Element.getValueTypeName(), *
this, 2 );
139 if ( aCheck.
has(
"EventType" ) )
142 OSL_ENSURE( !
sEventType.isEmpty(),
"DocumentEvents::replaceByName: doing a reset via an empty EventType is weird!" );
144 aEventDescriptor.realloc( 0 );
146 if ( aCheck.
has(
"Script" ) )
149 OSL_ENSURE( !
sScript.isEmpty(),
"DocumentEvents::replaceByName: doing a reset via an empty Script is weird!" );
151 aEventDescriptor.realloc( 0 );
154 elementPos->second = aEventDescriptor;
159 ::osl::MutexGuard aGuard(
mrMutex );
163 throw NoSuchElementException(
Name, *
this );
166 const Sequence< PropertyValue >& rEventDesc( elementPos->second );
167 if ( rEventDesc.hasElements() )
168 aReturn <<= rEventDesc;
174 ::osl::MutexGuard aGuard(
mrMutex );
181 ::osl::MutexGuard aGuard(
mrMutex );
188 return ::cppu::UnoType< Sequence< PropertyValue > >::get();
193 ::osl::MutexGuard aGuard(
mrMutex );
BaseContainerNodeSharedPtr & mrParent
bool has(const OUString &_rValueName) const
VALUE_TYPE getOrDefault(const OUString &_rValueName, const VALUE_TYPE &_rDefault) const
virtual void SAL_CALL acquire() SAL_NOEXCEPT SAL_OVERRIDE
virtual void SAL_CALL release() SAL_NOEXCEPT SAL_OVERRIDE
static bool needsSynchronousNotification(std::u16string_view _rEventName)
virtual sal_Bool SAL_CALL hasElements() override
virtual void SAL_CALL acquire() noexcept override
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
virtual void SAL_CALL release() noexcept override
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
DocumentEventsData & mrEventsData
::cppu::OWeakObject & mrParent
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
virtual ~DocumentEvents() override
virtual css::uno::Type SAL_CALL getElementType() override
virtual void SAL_CALL replaceByName(const OUString &aName, const css::uno::Any &aElement) override
DocumentEvents(::cppu::OWeakObject &_rParent, ::osl::Mutex &_rMutex, DocumentEventsData &_rEventsData)
const char * pAsciiEventName
css::uno::Sequence< typename M::key_type > mapKeysToSequence(M const &map)
std::map< OUString, css::uno::Sequence< css::beans::PropertyValue > > DocumentEventsData
bool equalsAscii(std::u16string_view s1, std::string_view s2)
constexpr OUStringLiteral sScript
constexpr OUStringLiteral sEventType