LibreOffice Module svtools (master) 1
unoevent.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#pragma once
20
21#include <svtools/svtdllapi.h>
22#include <com/sun/star/container/XNameReplace.hpp>
23#include <com/sun/star/lang/XServiceInfo.hpp>
25#include <vector>
26#include <memory>
27
28namespace com :: sun :: star :: uno { class XInterface; }
29
31class SvxMacroItem;
32class SvxMacro;
33enum class SvMacroItemId : sal_uInt16;
34
42{
44 const char* mpEventName;
45};
46
60class SVT_DLLPUBLIC SvBaseEventDescriptor : public cppu::WeakImplHelper
61<
62 css::container::XNameReplace,
63 css::lang::XServiceInfo
64>
65{
66protected:
69 sal_Int16 mnMacroItems;
70
71public:
72
73 SvBaseEventDescriptor(const SvEventDescription* pSupportedMacroItems);
74
75 virtual ~SvBaseEventDescriptor() override;
76
77
78 // XNameReplace
80 virtual void SAL_CALL replaceByName(
81 const OUString& rName,
82 const css::uno::Any& rElement )
83 override;
84
85 // XNameAccess (via XNameReplace)
87 virtual css::uno::Any SAL_CALL getByName(
88 const OUString& rName )
89 override;
90
91 // XNameAxcess (via XNameReplace)
92 virtual css::uno::Sequence< OUString > SAL_CALL
93 getElementNames() override;
94
95 // XNameAccess (via XNameReplace)
96 virtual sal_Bool SAL_CALL hasByName(
97 const OUString& rName ) override;
98
99 // XElementAccess (via XNameReplace)
100 virtual css::uno::Type SAL_CALL getElementType() override;
101
102 // XElementAccess (via XNameReplace)
103 virtual sal_Bool SAL_CALL hasElements() override;
104
105 // XServiceInfo
107 virtual OUString SAL_CALL getImplementationName() override = 0;
108
109 // XServiceInfo
110 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
111
112 // XServiceInfo
113 virtual css::uno::Sequence< OUString > SAL_CALL
114 getSupportedServiceNames() override;
115
116protected:
117
124 virtual void replaceByName(
125 const SvMacroItemId nEvent,
126 const SvxMacro& rMacro)
127 = 0;
128
134 virtual void getByName(
135 SvxMacro& rMacro,
136 const SvMacroItemId nEvent ) = 0;
137
139 SvMacroItemId mapNameToEventID(std::u16string_view rName) const;
140
142 SvMacroItemId getMacroID(std::u16string_view rName) const;
143};
144
145
160{
162 css::uno::Reference< css::uno::XInterface > xParentRef;
163
164public:
165
166 SvEventDescriptor(css::uno::XInterface& rParent,
167 const SvEventDescription* pSupportedMacroItems);
168
169 virtual ~SvEventDescriptor() override;
170
171
172protected:
173
174
176 virtual void replaceByName(
177 const SvMacroItemId nEvent,
178 const SvxMacro& rMacro)
179 override;
180
182 virtual void getByName(
183 SvxMacro& rMacros,
184 const SvMacroItemId nEvent )
185 override;
186
187
190 virtual const SvxMacroItem& getMacroItem() = 0;
191
194 virtual void setMacroItem(const SvxMacroItem& rItem) = 0;
195
198 virtual sal_uInt16 getMacroItemWhich() const = 0;
199};
200
201
206{
207 // the macros; aMacros[i] is the value for aSupportedMacroItemIDs[i]
208 std::vector<std::unique_ptr<SvxMacro>> aMacros;
209
210public:
211
212 SvDetachedEventDescriptor(const SvEventDescription* pSupportedMacroItems);
213 SvDetachedEventDescriptor& operator=( SvDetachedEventDescriptor const & ) = delete; // MSVC2015 workaround
214 SvDetachedEventDescriptor( SvDetachedEventDescriptor const & ) = delete; // MSVC2015 workaround
215
216 virtual ~SvDetachedEventDescriptor() override;
217
218 //XServiceInfo
219 virtual OUString SAL_CALL getImplementationName() override;
220
221protected:
222
223 sal_Int16 getIndex(const SvMacroItemId nID) const;
224
226 virtual void replaceByName(
227 const SvMacroItemId nEvent,
228 const SvxMacro& rMacro)
229 override;
230
232 virtual void getByName(
233 SvxMacro& rMacro,
234 const SvMacroItemId nEvent )
235 override;
236
241 bool hasById(
242 const SvMacroItemId nEvent ) const;
243
244};
245
247{
248public:
249
250 SvMacroTableEventDescriptor(const SvEventDescription* pSupportedMacroItems);
252 const SvEventDescription* pSupportedMacroItems);
253
254 virtual ~SvMacroTableEventDescriptor() override;
255
256 void copyMacrosIntoTable(SvxMacroTableDtor& aFmt);
257};
258
259/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvBaseEventDescriptor: Abstract class that implements the basics of an XNameReplace that is delivered...
Definition: unoevent.hxx:65
const SvEventDescription * mpSupportedMacroItems
last element is 0, 0
Definition: unoevent.hxx:68
virtual void replaceByName(const SvMacroItemId nEvent, const SvxMacro &rMacro)=0
Must be implemented in subclass.
virtual OUString SAL_CALL getImplementationName() override=0
must be implemented in subclass
virtual void SAL_CALL replaceByName(const OUString &rName, const css::uno::Any &rElement) override
calls replaceByName(const sal_uInt16, const SvxMacro&)
virtual void getByName(SvxMacro &rMacro, const SvMacroItemId nEvent)=0
Must be implemented in subclass.
virtual css::uno::Any SAL_CALL getByName(const OUString &rName) override
calls getByName(sal_uInt16)
Definition: unoevent.cxx:231
sal_Int16 mnMacroItems
Definition: unoevent.hxx:69
SvDetachedEventDescriptor:
Definition: unoevent.hxx:206
SvDetachedEventDescriptor(SvDetachedEventDescriptor const &)=delete
std::vector< std::unique_ptr< SvxMacro > > aMacros
Definition: unoevent.hxx:208
SvDetachedEventDescriptor & operator=(SvDetachedEventDescriptor const &)=delete
SvEventDescriptor: Implement the XNameReplace that is delivered by the XEventsSupplier::getEvents() m...
Definition: unoevent.hxx:160
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.
css::uno::Reference< css::uno::XInterface > xParentRef
keep reference to parent to prevent it from being destroyed
Definition: unoevent.hxx:162
SvMacroItemId
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
SvEventDescription: Description of a single event.
Definition: unoevent.hxx:42
const char * mpEventName
Definition: unoevent.hxx:44
SvMacroItemId mnEvent
Definition: unoevent.hxx:43
#define SVT_DLLPUBLIC
Definition: svtdllapi.h:27
unsigned char sal_Bool