1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "buttonnavigationhandler.hxx"
21 #include "formstrings.hxx"
22 #include "formmetadata.hxx"
23 #include "pcrservices.hxx"
24 #include "pushbuttonnavigation.hxx"
26 #include <com/sun/star/form/inspection/FormComponentPropertyHandler.hpp>
28 extern "C" void SAL_CALL
createRegistryInfo_ButtonNavigationHandler()
30 ::pcr::ButtonNavigationHandler::registerImplementation();
38 using namespace ::com::sun::star::uno
;
39 using namespace ::com::sun::star::lang
;
40 using namespace ::com::sun::star::beans
;
41 using namespace ::com::sun::star::script
;
42 using namespace ::com::sun::star::frame
;
43 using namespace ::com::sun::star::inspection
;
45 ButtonNavigationHandler::ButtonNavigationHandler( const Reference
< XComponentContext
>& _rxContext
)
46 :ButtonNavigationHandler_Base( _rxContext
)
49 m_xSlaveHandler
= css::form::inspection::FormComponentPropertyHandler::create( m_xContext
);
53 ButtonNavigationHandler::~ButtonNavigationHandler( )
58 OUString SAL_CALL
ButtonNavigationHandler::getImplementationName_static( ) throw (RuntimeException
)
60 return OUString( "com.sun.star.comp.extensions.ButtonNavigationHandler" );
64 Sequence
< OUString
> SAL_CALL
ButtonNavigationHandler::getSupportedServiceNames_static( ) throw (RuntimeException
)
66 Sequence
< OUString
> aSupported( 1 );
67 aSupported
[0] = "com.sun.star.form.inspection.ButtonNavigationHandler";
72 void SAL_CALL
ButtonNavigationHandler::inspect( const Reference
< XInterface
>& _rxIntrospectee
) throw (RuntimeException
, NullPointerException
, std::exception
)
74 ButtonNavigationHandler_Base::inspect( _rxIntrospectee
);
75 m_xSlaveHandler
->inspect( _rxIntrospectee
);
79 PropertyState SAL_CALL
ButtonNavigationHandler::getPropertyState( const OUString
& _rPropertyName
) throw (UnknownPropertyException
, RuntimeException
, std::exception
)
81 ::osl::MutexGuard
aGuard( m_aMutex
);
82 PropertyId
nPropId( impl_getPropertyId_throwUnknownProperty( _rPropertyName
) );
83 PropertyState eState
= PropertyState_DIRECT_VALUE
;
86 case PROPERTY_ID_BUTTONTYPE
:
88 PushButtonNavigation
aHelper( m_xComponent
);
89 eState
= aHelper
.getCurrentButtonTypeState();
92 case PROPERTY_ID_TARGET_URL
:
94 PushButtonNavigation
aHelper( m_xComponent
);
95 eState
= aHelper
.getCurrentTargetURLState();
100 OSL_FAIL( "ButtonNavigationHandler::getPropertyState: cannot handle this property!" );
108 Any SAL_CALL
ButtonNavigationHandler::getPropertyValue( const OUString
& _rPropertyName
) throw (UnknownPropertyException
, RuntimeException
, std::exception
)
110 ::osl::MutexGuard
aGuard( m_aMutex
);
111 PropertyId
nPropId( impl_getPropertyId_throwUnknownProperty( _rPropertyName
) );
116 case PROPERTY_ID_BUTTONTYPE
:
118 PushButtonNavigation
aHelper( m_xComponent
);
119 aReturn
= aHelper
.getCurrentButtonType();
123 case PROPERTY_ID_TARGET_URL
:
125 PushButtonNavigation
aHelper( m_xComponent
);
126 aReturn
= aHelper
.getCurrentTargetURL();
131 OSL_FAIL( "ButtonNavigationHandler::getPropertyValue: cannot handle this property!" );
139 void SAL_CALL
ButtonNavigationHandler::setPropertyValue( const OUString
& _rPropertyName
, const Any
& _rValue
) throw (UnknownPropertyException
, RuntimeException
, std::exception
)
141 ::osl::MutexGuard
aGuard( m_aMutex
);
142 PropertyId
nPropId( impl_getPropertyId_throwUnknownProperty( _rPropertyName
) );
145 case PROPERTY_ID_BUTTONTYPE
:
147 PushButtonNavigation
aHelper( m_xComponent
);
148 aHelper
.setCurrentButtonType( _rValue
);
152 case PROPERTY_ID_TARGET_URL
:
154 PushButtonNavigation
aHelper( m_xComponent
);
155 aHelper
.setCurrentTargetURL( _rValue
);
160 OSL_FAIL( "ButtonNavigationHandler::setPropertyValue: cannot handle this id!" );
165 bool ButtonNavigationHandler::isNavigationCapableButton( const Reference
< XPropertySet
>& _rxComponent
)
167 Reference
< XPropertySetInfo
> xPSI
;
168 if ( _rxComponent
.is() )
169 xPSI
= _rxComponent
->getPropertySetInfo();
172 && xPSI
->hasPropertyByName( PROPERTY_TARGET_URL
)
173 && xPSI
->hasPropertyByName( PROPERTY_BUTTONTYPE
);
177 Sequence
< Property
> SAL_CALL
ButtonNavigationHandler::doDescribeSupportedProperties() const
179 ::std::vector
< Property
> aProperties
;
181 if ( isNavigationCapableButton( m_xComponent
) )
183 addStringPropertyDescription( aProperties
, PROPERTY_TARGET_URL
);
184 implAddPropertyDescription( aProperties
, PROPERTY_BUTTONTYPE
, ::cppu::UnoType
<sal_Int32
>::get() );
187 if ( aProperties
.empty() )
188 return Sequence
< Property
>();
189 return Sequence
< Property
>( &(*aProperties
.begin()), aProperties
.size() );
193 Sequence
< OUString
> SAL_CALL
ButtonNavigationHandler::getActuatingProperties( ) throw (RuntimeException
, std::exception
)
195 Sequence
< OUString
> aActuating( 2 );
196 aActuating
[0] = PROPERTY_BUTTONTYPE
;
197 aActuating
[1] = PROPERTY_TARGET_URL
;
202 InteractiveSelectionResult SAL_CALL
ButtonNavigationHandler::onInteractivePropertySelection( const OUString
& _rPropertyName
, sal_Bool _bPrimary
, Any
& _rData
, const Reference
< XObjectInspectorUI
>& _rxInspectorUI
) throw (UnknownPropertyException
, NullPointerException
, RuntimeException
, std::exception
)
204 ::osl::MutexGuard
aGuard( m_aMutex
);
205 PropertyId
nPropId( impl_getPropertyId_throwUnknownProperty( _rPropertyName
) );
207 InteractiveSelectionResult
eReturn( InteractiveSelectionResult_Cancelled
);
211 case PROPERTY_ID_TARGET_URL
:
212 eReturn
= m_xSlaveHandler
->onInteractivePropertySelection( _rPropertyName
, _bPrimary
, _rData
, _rxInspectorUI
);
215 eReturn
= ButtonNavigationHandler_Base::onInteractivePropertySelection( _rPropertyName
, _bPrimary
, _rData
, _rxInspectorUI
);
223 void SAL_CALL
ButtonNavigationHandler::actuatingPropertyChanged( const OUString
& _rActuatingPropertyName
, const Any
& /*_rNewValue*/, const Any
& /*_rOldValue*/, const Reference
< XObjectInspectorUI
>& _rxInspectorUI
, sal_Bool
/*_bFirstTimeInit*/ ) throw (NullPointerException
, RuntimeException
, std::exception
)
225 ::osl::MutexGuard
aGuard( m_aMutex
);
226 PropertyId
nPropId( impl_getPropertyId_throwRuntime( _rActuatingPropertyName
) );
229 case PROPERTY_ID_BUTTONTYPE
:
231 PushButtonNavigation
aHelper( m_xComponent
);
232 _rxInspectorUI
->enablePropertyUI( PROPERTY_TARGET_URL
, aHelper
.currentButtonTypeIsOpenURL() );
236 case PROPERTY_ID_TARGET_URL
:
238 PushButtonNavigation
aHelper( m_xComponent
);
239 _rxInspectorUI
->enablePropertyUI( PROPERTY_TARGET_FRAME
, aHelper
.hasNonEmptyCurrentTargetURL() );
244 OSL_FAIL( "ButtonNavigationHandler::actuatingPropertyChanged: cannot handle this id!" );
249 LineDescriptor SAL_CALL
ButtonNavigationHandler::describePropertyLine( const OUString
& _rPropertyName
, const Reference
< XPropertyControlFactory
>& _rxControlFactory
) throw (UnknownPropertyException
, NullPointerException
, RuntimeException
, std::exception
)
251 ::osl::MutexGuard
aGuard( m_aMutex
);
252 PropertyId
nPropId( impl_getPropertyId_throwUnknownProperty( _rPropertyName
) );
254 LineDescriptor aReturn
;
258 case PROPERTY_ID_TARGET_URL
:
259 aReturn
= m_xSlaveHandler
->describePropertyLine( _rPropertyName
, _rxControlFactory
);
262 aReturn
= ButtonNavigationHandler_Base::describePropertyLine( _rPropertyName
, _rxControlFactory
);
273 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */