LibreOffice Module extensions (master) 1
eventhandler.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
20#pragma once
21
22#include "pcrcommon.hxx"
23
24#include <com/sun/star/script/ScriptEventDescriptor.hpp>
25#include <com/sun/star/lang/XServiceInfo.hpp>
26#include <com/sun/star/inspection/XPropertyHandler.hpp>
27#include <com/sun/star/beans/XPropertySet.hpp>
28#include <com/sun/star/frame/XFrame.hpp>
29#include <com/sun/star/uno/XComponentContext.hpp>
31#include <unotools/resmgr.hxx>
32
33#include <unordered_map>
34
35namespace pcr
36{
37
38
39 //= EventDescription
40
41 typedef sal_Int32 EventId;
43 {
44 public:
45 OUString sDisplayName;
48 OUString sHelpId;
51
53 :nId( 0 )
54 {
55 }
56
58 EventId _nId,
59 std::u16string_view listenerClassName,
60 std::u16string_view listenerMethodName,
61 TranslateId pDisplayNameResId,
62 OUString _sHelpId,
63 OString _sUniqueBrowseId );
64 };
65
66 typedef std::unordered_map< OUString, EventDescription > EventMap;
67
68
69 //= EventHandler
70
71 typedef ::cppu::WeakComponentImplHelper < css::inspection::XPropertyHandler
72 , css::lang::XServiceInfo
74 class EventHandler final : public EventHandler_Base
75 {
76 private:
77 mutable ::osl::Mutex m_aMutex;
78
80 css::uno::Reference< css::uno::XComponentContext > m_xContext;
82 css::uno::Reference< css::beans::XPropertySet > m_xComponent;
91 // TODO: move different handling into different derived classes?
94
95 public:
96 explicit EventHandler(
97 const css::uno::Reference< css::uno::XComponentContext >& _rxContext
98 );
99
100 virtual ~EventHandler() override;
101
102 private:
103 // XPropertyHandler overridables
104 virtual void SAL_CALL inspect( const css::uno::Reference< css::uno::XInterface >& _rxIntrospectee ) override;
105 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& _rPropertyName ) override;
106 virtual void SAL_CALL setPropertyValue( const OUString& _rPropertyName, const css::uno::Any& _rValue ) override;
107 virtual css::uno::Any SAL_CALL convertToPropertyValue( const OUString& _rPropertyName, const css::uno::Any& _rControlValue ) override;
108 virtual css::uno::Any SAL_CALL convertToControlValue( const OUString& _rPropertyName, const css::uno::Any& _rPropertyValue, const css::uno::Type& _rControlValueType ) override;
109 virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& _rPropertyName ) override;
110 virtual void SAL_CALL addPropertyChangeListener( const css::uno::Reference< css::beans::XPropertyChangeListener >& _rxListener ) override;
111 virtual void SAL_CALL removePropertyChangeListener( const css::uno::Reference< css::beans::XPropertyChangeListener >& _rxListener ) override;
112 virtual css::uno::Sequence< css::beans::Property > SAL_CALL getSupportedProperties() override;
113 virtual css::uno::Sequence< OUString > SAL_CALL getSupersededProperties( ) override;
114 virtual css::uno::Sequence< OUString > SAL_CALL getActuatingProperties( ) override;
115 virtual css::inspection::LineDescriptor SAL_CALL describePropertyLine( const OUString& _rPropertyName, const css::uno::Reference< css::inspection::XPropertyControlFactory >& _rxControlFactory ) override;
116 virtual sal_Bool SAL_CALL isComposable( const OUString& _rPropertyName ) override;
117 virtual css::inspection::InteractiveSelectionResult SAL_CALL onInteractivePropertySelection( const OUString& _rPropertyName, sal_Bool _bPrimary, css::uno::Any& _rData, const css::uno::Reference< css::inspection::XObjectInspectorUI >& _rxInspectorUI ) override;
118 virtual void SAL_CALL actuatingPropertyChanged( const OUString& _rActuatingPropertyName, const css::uno::Any& _rNewValue, const css::uno::Any& _rOldValue, const css::uno::Reference< css::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) override;
119 virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) override;
120
121 // XComponent
123 virtual void SAL_CALL disposing() override;
124
125 // XServiceInfo
126 virtual OUString SAL_CALL getImplementationName( ) override;
127 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
128 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
129
137 std::vector< css::script::ScriptEventDescriptor >& _out_rEvents
138 ) const;
139
147 std::vector< css::script::ScriptEventDescriptor >& _out_rEvents
148 ) const;
149
155 std::vector< css::script::ScriptEventDescriptor >& _out_rEvents
156 ) const
157 {
158 if ( m_bIsDialogElement )
160 else
162 }
163
169 std::vector< css::uno::Type >& _out_rTypes
170 ) const;
171
188 css::uno::Reference< css::uno::XInterface >
190
199 const EventDescription&
200 impl_getEventForName_throw( const OUString& _rPropertyName ) const;
201
205 sal_Int32 impl_getComponentIndexInParent_throw() const;
206
212 void impl_setFormComponentScriptEvent_nothrow( const css::script::ScriptEventDescriptor& _rScriptEvent );
213
219 void impl_setDialogElementScriptEvent_nothrow( const css::script::ScriptEventDescriptor& _rScriptEvent );
220
223 css::uno::Reference< css::frame::XFrame >
225
230 bool impl_filterMethod_nothrow( const EventDescription& _rEvent ) const;
231
232 EventHandler( const EventHandler& ) = delete;
234 };
235
236
237} // namespace pcr
238
239
240/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void impl_getFormComponentScriptEvents_nothrow(std::vector< css::script::ScriptEventDescriptor > &_out_rEvents) const
returns the script events associated with our introspectee
EventMap m_aEvents
cache of the events we found at our introspectee
virtual sal_Bool SAL_CALL isComposable(const OUString &_rPropertyName) override
bool m_bEventsMapInitialized
has m_aEvents been initialized?
bool m_bIsDialogElement
is our introspectee a dialog element?
EventHandler(const EventHandler &)=delete
virtual css::uno::Sequence< OUString > SAL_CALL getActuatingProperties() override
virtual OUString SAL_CALL getImplementationName() override
css::uno::Reference< css::uno::XInterface > impl_getSecondaryComponentForEventInspection_throw() const
returns a secondary component to be used for event inspection
void impl_getComponentScriptEvents_nothrow(std::vector< css::script::ScriptEventDescriptor > &_out_rEvents) const
returns the script events associated with our introspectee
virtual css::uno::Any SAL_CALL convertToControlValue(const OUString &_rPropertyName, const css::uno::Any &_rPropertyValue, const css::uno::Type &_rControlValueType) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupersededProperties() override
css::uno::Reference< css::beans::XPropertySet > m_xComponent
the properties of the object we're handling
void impl_getComponentListenerTypes_nothrow(std::vector< css::uno::Type > &_out_rTypes) const
returns the types of the listeners which can be registered at our introspectee
virtual void SAL_CALL removePropertyChangeListener(const css::uno::Reference< css::beans::XPropertyChangeListener > &_rxListener) override
EventHandler & operator=(const EventHandler &)=delete
css::uno::Reference< css::frame::XFrame > impl_getContextFrame_nothrow() const
returns the frame associated with our context document
virtual ~EventHandler() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
void impl_setFormComponentScriptEvent_nothrow(const css::script::ScriptEventDescriptor &_rScriptEvent)
sets a given script event as event handler at a form component
bool impl_filterMethod_nothrow(const EventDescription &_rEvent) const
approves or denies a certain method to be included in the UI
virtual sal_Bool SAL_CALL suspend(sal_Bool _bSuspend) override
const EventDescription & impl_getEventForName_throw(const OUString &_rPropertyName) const
returns the event description for the given (programmatic) property name
virtual void SAL_CALL setPropertyValue(const OUString &_rPropertyName, const css::uno::Any &_rValue) override
virtual void SAL_CALL actuatingPropertyChanged(const OUString &_rActuatingPropertyName, const css::uno::Any &_rNewValue, const css::uno::Any &_rOldValue, const css::uno::Reference< css::inspection::XObjectInspectorUI > &_rxInspectorUI, sal_Bool _bFirstTimeInit) override
virtual void SAL_CALL disposing() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Sequence< css::beans::Property > SAL_CALL getSupportedProperties() override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &_rPropertyName) override
virtual css::uno::Any SAL_CALL convertToPropertyValue(const OUString &_rPropertyName, const css::uno::Any &_rControlValue) override
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &_rPropertyName) override
PropertyChangeListeners m_aPropertyListeners
our XPropertyChangeListener(s)
virtual css::inspection::InteractiveSelectionResult SAL_CALL onInteractivePropertySelection(const OUString &_rPropertyName, sal_Bool _bPrimary, css::uno::Any &_rData, const css::uno::Reference< css::inspection::XObjectInspectorUI > &_rxInspectorUI) override
EventHandler(const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
css::uno::Reference< css::uno::XComponentContext > m_xContext
the context in which the instance was created
void impl_setDialogElementScriptEvent_nothrow(const css::script::ScriptEventDescriptor &_rScriptEvent)
sets a given script event as event handler at a dialog component
virtual void SAL_CALL inspect(const css::uno::Reference< css::uno::XInterface > &_rxIntrospectee) override
virtual void SAL_CALL addPropertyChangeListener(const css::uno::Reference< css::beans::XPropertyChangeListener > &_rxListener) override
virtual css::inspection::LineDescriptor SAL_CALL describePropertyLine(const OUString &_rPropertyName, const css::uno::Reference< css::inspection::XPropertyControlFactory > &_rxControlFactory) override
void impl_getDialogElementScriptEvents_nothrow(std::vector< css::script::ScriptEventDescriptor > &_out_rEvents) const
returns the script events associated with our introspectee
mutable::osl::Mutex m_aMutex
sal_Int32 impl_getComponentIndexInParent_throw() const
returns the index of our component within its parent, if this parent can be obtained (XChild::getPare...
sal_Int16 m_nGridColumnType
(FormComponent) type of the grid column being inspected, or -1 if we're not inspecting a grid column
a property handler for any virtual string properties
Definition: browserline.cxx:39
std::unordered_map< OUString, EventDescription > EventMap
sal_Int32 EventId
::cppu::WeakComponentImplHelper< css::inspection::XPropertyHandler, css::lang::XServiceInfo > EventHandler_Base
#define DECLARE_XCOMPONENT()
Definition: pcrcommon.hxx:100
unsigned char sal_Bool