LibreOffice Module extensions (master) 1
buttonnavigationhandler.cxx
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
21#include "formstrings.hxx"
22#include "formmetadata.hxx"
24
25#include <com/sun/star/form/inspection/FormComponentPropertyHandler.hpp>
26
27namespace pcr
28{
29
30
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::lang;
33 using namespace ::com::sun::star::beans;
34 using namespace ::com::sun::star::script;
35 using namespace ::com::sun::star::frame;
36 using namespace ::com::sun::star::inspection;
37
38 ButtonNavigationHandler::ButtonNavigationHandler( const Reference< XComponentContext >& _rxContext )
39 :PropertyHandlerComponent( _rxContext )
40 {
41
42 m_xSlaveHandler = css::form::inspection::FormComponentPropertyHandler::create( m_xContext );
43 }
44
45
47 {
48 }
49
50
52 {
53 return "com.sun.star.comp.extensions.ButtonNavigationHandler";
54 }
55
56
58 {
59 return { "com.sun.star.form.inspection.ButtonNavigationHandler" };
60 }
61
62
63 void SAL_CALL ButtonNavigationHandler::inspect( const Reference< XInterface >& _rxIntrospectee )
64 {
65 PropertyHandlerComponent::inspect( _rxIntrospectee );
66 m_xSlaveHandler->inspect( _rxIntrospectee );
67 }
68
69
70 PropertyState SAL_CALL ButtonNavigationHandler::getPropertyState( const OUString& _rPropertyName )
71 {
72 ::osl::MutexGuard aGuard( m_aMutex );
73 PropertyId nPropId( impl_getPropertyId_throwUnknownProperty( _rPropertyName ) );
74 PropertyState eState = PropertyState_DIRECT_VALUE;
75 switch ( nPropId )
76 {
78 {
80 eState = aHelper.getCurrentButtonTypeState();
81 }
82 break;
84 {
86 eState = aHelper.getCurrentTargetURLState();
87 }
88 break;
89
90 default:
91 OSL_FAIL( "ButtonNavigationHandler::getPropertyState: cannot handle this property!" );
92 break;
93 }
94
95 return eState;
96 }
97
98
99 Any SAL_CALL ButtonNavigationHandler::getPropertyValue( const OUString& _rPropertyName )
100 {
101 ::osl::MutexGuard aGuard( m_aMutex );
102 PropertyId nPropId( impl_getPropertyId_throwUnknownProperty( _rPropertyName ) );
103
104 Any aReturn;
105 switch ( nPropId )
106 {
108 {
110 aReturn = aHelper.getCurrentButtonType();
111 }
112 break;
113
115 {
117 aReturn = aHelper.getCurrentTargetURL();
118 }
119 break;
120
121 default:
122 OSL_FAIL( "ButtonNavigationHandler::getPropertyValue: cannot handle this property!" );
123 break;
124 }
125
126 return aReturn;
127 }
128
129
130 void SAL_CALL ButtonNavigationHandler::setPropertyValue( const OUString& _rPropertyName, const Any& _rValue )
131 {
132 ::osl::MutexGuard aGuard( m_aMutex );
133 PropertyId nPropId( impl_getPropertyId_throwUnknownProperty( _rPropertyName ) );
134 switch ( nPropId )
135 {
137 {
139 aHelper.setCurrentButtonType( _rValue );
140 }
141 break;
142
144 {
146 aHelper.setCurrentTargetURL( _rValue );
147 }
148 break;
149
150 default:
151 OSL_FAIL( "ButtonNavigationHandler::setPropertyValue: cannot handle this id!" );
152 }
153 }
154
155
156 bool ButtonNavigationHandler::isNavigationCapableButton( const Reference< XPropertySet >& _rxComponent )
157 {
158 Reference< XPropertySetInfo > xPSI;
159 if ( _rxComponent.is() )
160 xPSI = _rxComponent->getPropertySetInfo();
161
162 return xPSI.is()
163 && xPSI->hasPropertyByName( PROPERTY_TARGET_URL )
164 && xPSI->hasPropertyByName( PROPERTY_BUTTONTYPE );
165 }
166
167
169 {
170 std::vector< Property > aProperties;
171
173 {
176 }
177
178 if ( aProperties.empty() )
179 return Sequence< Property >();
181 }
182
183
184 Sequence< OUString > SAL_CALL ButtonNavigationHandler::getActuatingProperties( )
185 {
186 Sequence< OUString > aActuating{ PROPERTY_BUTTONTYPE, PROPERTY_TARGET_URL };
187 return aActuating;
188 }
189
190
191 InteractiveSelectionResult SAL_CALL ButtonNavigationHandler::onInteractivePropertySelection( const OUString& _rPropertyName, sal_Bool _bPrimary, Any& _rData, const Reference< XObjectInspectorUI >& _rxInspectorUI )
192 {
193 ::osl::MutexGuard aGuard( m_aMutex );
194 PropertyId nPropId( impl_getPropertyId_throwUnknownProperty( _rPropertyName ) );
195
196 InteractiveSelectionResult eReturn( InteractiveSelectionResult_Cancelled );
197
198 switch ( nPropId )
199 {
201 eReturn = m_xSlaveHandler->onInteractivePropertySelection( _rPropertyName, _bPrimary, _rData, _rxInspectorUI );
202 break;
203 default:
204 eReturn = PropertyHandlerComponent::onInteractivePropertySelection( _rPropertyName, _bPrimary, _rData, _rxInspectorUI );
205 break;
206 }
207
208 return eReturn;
209 }
210
211
212 void SAL_CALL ButtonNavigationHandler::actuatingPropertyChanged( const OUString& _rActuatingPropertyName, const Any& /*_rNewValue*/, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool /*_bFirstTimeInit*/ )
213 {
214 ::osl::MutexGuard aGuard( m_aMutex );
215 PropertyId nPropId( impl_getPropertyId_throwRuntime( _rActuatingPropertyName ) );
216 switch ( nPropId )
217 {
219 {
221 _rxInspectorUI->enablePropertyUI( PROPERTY_TARGET_URL, aHelper.currentButtonTypeIsOpenURL() );
222 }
223 break;
224
226 {
228 _rxInspectorUI->enablePropertyUI( PROPERTY_TARGET_FRAME, aHelper.hasNonEmptyCurrentTargetURL() );
229 }
230 break;
231
232 default:
233 OSL_FAIL( "ButtonNavigationHandler::actuatingPropertyChanged: cannot handle this id!" );
234 }
235 }
236
237
238 LineDescriptor SAL_CALL ButtonNavigationHandler::describePropertyLine( const OUString& _rPropertyName, const Reference< XPropertyControlFactory >& _rxControlFactory )
239 {
240 ::osl::MutexGuard aGuard( m_aMutex );
241 PropertyId nPropId( impl_getPropertyId_throwUnknownProperty( _rPropertyName ) );
242
243 LineDescriptor aReturn;
244
245 switch ( nPropId )
246 {
248 aReturn = m_xSlaveHandler->describePropertyLine( _rPropertyName, _rxControlFactory );
249 break;
250 default:
251 aReturn = PropertyHandlerComponent::describePropertyLine( _rPropertyName, _rxControlFactory );
252 break;
253 }
254
255 return aReturn;
256 }
257
258
259} // namespace pcr
260
261extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
263 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
264{
265 return cppu::acquire(new pcr::ButtonNavigationHandler(context));
266}
267
268/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PropertiesInfo aProperties
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * extensions_propctrlr_ButtonNavigationHandler_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
mutable::osl::Mutex m_aMutex
a property handler for any virtual string properties
static bool isNavigationCapableButton(const css::uno::Reference< css::beans::XPropertySet > &_rxComponent)
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &_rPropertyName) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
css::uno::Reference< css::inspection::XPropertyHandler > m_xSlaveHandler
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
virtual css::uno::Sequence< OUString > SAL_CALL getActuatingProperties() override
virtual css::uno::Sequence< css::beans::Property > doDescribeSupportedProperties() const override
virtual void SAL_CALL setPropertyValue(const OUString &_rPropertyName, const css::uno::Any &_rValue) override
virtual OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL inspect(const css::uno::Reference< css::uno::XInterface > &_rxIntrospectee) 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 css::inspection::LineDescriptor SAL_CALL describePropertyLine(const OUString &_rPropertyName, const css::uno::Reference< css::inspection::XPropertyControlFactory > &_rxControlFactory) override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &_rPropertyName) override
ButtonNavigationHandler(const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
PropertyHandler implementation which additionally supports XServiceInfo.
css::uno::Reference< css::uno::XComponentContext > m_xContext
the context in which the instance was created
void addStringPropertyDescription(std::vector< css::beans::Property > &_rProperties, const OUString &_rPropertyName) const
adds a description for the given string property to the given property vector Most probably to be cal...
virtual void SAL_CALL inspect(const css::uno::Reference< css::uno::XInterface > &_rxIntrospectee) override
PropertyId impl_getPropertyId_throwUnknownProperty(const OUString &_rPropertyName) const
retrieves the property id for a given property name
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
css::uno::Reference< css::beans::XPropertySet > m_xComponent
the component we're inspecting
PropertyId impl_getPropertyId_throwRuntime(const OUString &_rPropertyName) const
retrieves the property id for a given property name
void implAddPropertyDescription(std::vector< css::beans::Property > &_rProperties, const OUString &_rPropertyName, const css::uno::Type &_rType, sal_Int16 _nAttribs=0) const
adds a Property, given by name only, to a given vector of Properties
virtual css::inspection::LineDescriptor SAL_CALL describePropertyLine(const OUString &_rPropertyName, const css::uno::Reference< css::inspection::XPropertyControlFactory > &_rxControlFactory) override
Any aHelper
#define PROPERTY_ID_TARGET_URL
#define PROPERTY_ID_BUTTONTYPE
constexpr OUStringLiteral PROPERTY_TARGET_URL
Definition: formstrings.hxx:51
constexpr OUStringLiteral PROPERTY_TARGET_FRAME
Definition: formstrings.hxx:52
constexpr OUStringLiteral PROPERTY_BUTTONTYPE
Definition: formstrings.hxx:58
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
a property handler for any virtual string properties
Definition: browserline.cxx:39
sal_Int32 PropertyId
unsigned char sal_Bool