1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
30 #include "buttonnavigationhandler.hxx"
31 #include "formstrings.hxx"
32 #include "formmetadata.hxx"
33 #include "pushbuttonnavigation.hxx"
35 /** === begin UNO includes === **/
36 /** === end UNO includes === **/
37 #include <tools/debug.hxx>
39 //------------------------------------------------------------------------
40 extern "C" void SAL_CALL
createRegistryInfo_ButtonNavigationHandler()
42 ::pcr::ButtonNavigationHandler::registerImplementation();
45 //........................................................................
48 //........................................................................
50 using namespace ::com::sun::star::uno
;
51 using namespace ::com::sun::star::lang
;
52 using namespace ::com::sun::star::beans
;
53 using namespace ::com::sun::star::script
;
54 using namespace ::com::sun::star::frame
;
55 using namespace ::com::sun::star::inspection
;
57 //====================================================================
58 //= ButtonNavigationHandler
59 //====================================================================
60 DBG_NAME( ButtonNavigationHandler
)
61 //--------------------------------------------------------------------
62 ButtonNavigationHandler::ButtonNavigationHandler( const Reference
< XComponentContext
>& _rxContext
)
63 :ButtonNavigationHandler_Base( _rxContext
)
65 DBG_CTOR( ButtonNavigationHandler
, NULL
);
67 m_aContext
.createComponent(
68 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.FormComponentPropertyHandler" ) ),
70 if ( !m_xSlaveHandler
.is() )
71 throw RuntimeException();
74 //--------------------------------------------------------------------
75 ButtonNavigationHandler::~ButtonNavigationHandler( )
77 DBG_DTOR( ButtonNavigationHandler
, NULL
);
80 //--------------------------------------------------------------------
81 ::rtl::OUString SAL_CALL
ButtonNavigationHandler::getImplementationName_static( ) throw (RuntimeException
)
83 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.ButtonNavigationHandler" ) );
86 //--------------------------------------------------------------------
87 Sequence
< ::rtl::OUString
> SAL_CALL
ButtonNavigationHandler::getSupportedServiceNames_static( ) throw (RuntimeException
)
89 Sequence
< ::rtl::OUString
> aSupported( 1 );
90 aSupported
[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.ButtonNavigationHandler" ) );
94 //--------------------------------------------------------------------
95 void SAL_CALL
ButtonNavigationHandler::inspect( const Reference
< XInterface
>& _rxIntrospectee
) throw (RuntimeException
, NullPointerException
)
97 ButtonNavigationHandler_Base::inspect( _rxIntrospectee
);
98 m_xSlaveHandler
->inspect( _rxIntrospectee
);
101 //--------------------------------------------------------------------
102 PropertyState SAL_CALL
ButtonNavigationHandler::getPropertyState( const ::rtl::OUString
& _rPropertyName
) throw (UnknownPropertyException
, RuntimeException
)
104 ::osl::MutexGuard
aGuard( m_aMutex
);
105 PropertyId
nPropId( impl_getPropertyId_throw( _rPropertyName
) );
106 PropertyState eState
= PropertyState_DIRECT_VALUE
;
109 case PROPERTY_ID_BUTTONTYPE
:
111 PushButtonNavigation
aHelper( m_xComponent
);
112 eState
= aHelper
.getCurrentButtonTypeState();
115 case PROPERTY_ID_TARGET_URL
:
117 PushButtonNavigation
aHelper( m_xComponent
);
118 eState
= aHelper
.getCurrentTargetURLState();
123 DBG_ERROR( "ButtonNavigationHandler::getPropertyState: cannot handle this property!" );
130 //--------------------------------------------------------------------
131 Any SAL_CALL
ButtonNavigationHandler::getPropertyValue( const ::rtl::OUString
& _rPropertyName
) throw (UnknownPropertyException
, RuntimeException
)
133 ::osl::MutexGuard
aGuard( m_aMutex
);
134 PropertyId
nPropId( impl_getPropertyId_throw( _rPropertyName
) );
139 case PROPERTY_ID_BUTTONTYPE
:
141 PushButtonNavigation
aHelper( m_xComponent
);
142 aReturn
= aHelper
.getCurrentButtonType();
146 case PROPERTY_ID_TARGET_URL
:
148 PushButtonNavigation
aHelper( m_xComponent
);
149 aReturn
= aHelper
.getCurrentTargetURL();
154 DBG_ERROR( "ButtonNavigationHandler::getPropertyValue: cannot handle this property!" );
161 //--------------------------------------------------------------------
162 void SAL_CALL
ButtonNavigationHandler::setPropertyValue( const ::rtl::OUString
& _rPropertyName
, const Any
& _rValue
) throw (UnknownPropertyException
, RuntimeException
)
164 ::osl::MutexGuard
aGuard( m_aMutex
);
165 PropertyId
nPropId( impl_getPropertyId_throw( _rPropertyName
) );
168 case PROPERTY_ID_BUTTONTYPE
:
170 PushButtonNavigation
aHelper( m_xComponent
);
171 aHelper
.setCurrentButtonType( _rValue
);
175 case PROPERTY_ID_TARGET_URL
:
177 PushButtonNavigation
aHelper( m_xComponent
);
178 aHelper
.setCurrentTargetURL( _rValue
);
183 OSL_ENSURE( sal_False
, "ButtonNavigationHandler::setPropertyValue: cannot handle this id!" );
187 //--------------------------------------------------------------------
188 bool ButtonNavigationHandler::isNavigationCapableButton( const Reference
< XPropertySet
>& _rxComponent
)
190 Reference
< XPropertySetInfo
> xPSI
;
191 if ( _rxComponent
.is() )
192 xPSI
= _rxComponent
->getPropertySetInfo();
195 && xPSI
->hasPropertyByName( PROPERTY_TARGET_URL
)
196 && xPSI
->hasPropertyByName( PROPERTY_BUTTONTYPE
);
199 //--------------------------------------------------------------------
200 Sequence
< Property
> SAL_CALL
ButtonNavigationHandler::doDescribeSupportedProperties() const
202 ::std::vector
< Property
> aProperties
;
204 if ( isNavigationCapableButton( m_xComponent
) )
206 addStringPropertyDescription( aProperties
, PROPERTY_TARGET_URL
);
207 implAddPropertyDescription( aProperties
, PROPERTY_BUTTONTYPE
, ::getCppuType( static_cast< sal_Int32
* >( NULL
) ) );
210 if ( aProperties
.empty() )
211 return Sequence
< Property
>();
212 return Sequence
< Property
>( &(*aProperties
.begin()), aProperties
.size() );
215 //--------------------------------------------------------------------
216 Sequence
< ::rtl::OUString
> SAL_CALL
ButtonNavigationHandler::getActuatingProperties( ) throw (RuntimeException
)
218 Sequence
< ::rtl::OUString
> aActuating( 2 );
219 aActuating
[0] = PROPERTY_BUTTONTYPE
;
220 aActuating
[1] = PROPERTY_TARGET_URL
;
224 //--------------------------------------------------------------------
225 InteractiveSelectionResult SAL_CALL
ButtonNavigationHandler::onInteractivePropertySelection( const ::rtl::OUString
& _rPropertyName
, sal_Bool _bPrimary
, Any
& _rData
, const Reference
< XObjectInspectorUI
>& _rxInspectorUI
) throw (UnknownPropertyException
, NullPointerException
, RuntimeException
)
227 ::osl::MutexGuard
aGuard( m_aMutex
);
228 PropertyId
nPropId( impl_getPropertyId_throw( _rPropertyName
) );
230 InteractiveSelectionResult
eReturn( InteractiveSelectionResult_Cancelled
);
234 case PROPERTY_ID_TARGET_URL
:
235 eReturn
= m_xSlaveHandler
->onInteractivePropertySelection( _rPropertyName
, _bPrimary
, _rData
, _rxInspectorUI
);
238 eReturn
= ButtonNavigationHandler_Base::onInteractivePropertySelection( _rPropertyName
, _bPrimary
, _rData
, _rxInspectorUI
);
245 //--------------------------------------------------------------------
246 void SAL_CALL
ButtonNavigationHandler::actuatingPropertyChanged( const ::rtl::OUString
& _rActuatingPropertyName
, const Any
& /*_rNewValue*/, const Any
& /*_rOldValue*/, const Reference
< XObjectInspectorUI
>& _rxInspectorUI
, sal_Bool
/*_bFirstTimeInit*/ ) throw (NullPointerException
, RuntimeException
)
248 ::osl::MutexGuard
aGuard( m_aMutex
);
249 PropertyId
nPropId( impl_getPropertyId_throw( _rActuatingPropertyName
) );
252 case PROPERTY_ID_BUTTONTYPE
:
254 PushButtonNavigation
aHelper( m_xComponent
);
255 _rxInspectorUI
->enablePropertyUI( PROPERTY_TARGET_URL
, aHelper
.currentButtonTypeIsOpenURL() );
259 case PROPERTY_ID_TARGET_URL
:
261 PushButtonNavigation
aHelper( m_xComponent
);
262 _rxInspectorUI
->enablePropertyUI( PROPERTY_TARGET_FRAME
, aHelper
.hasNonEmptyCurrentTargetURL() );
267 OSL_ENSURE( sal_False
, "ButtonNavigationHandler::actuatingPropertyChanged: cannot handle this id!" );
271 //--------------------------------------------------------------------
272 LineDescriptor SAL_CALL
ButtonNavigationHandler::describePropertyLine( const ::rtl::OUString
& _rPropertyName
, const Reference
< XPropertyControlFactory
>& _rxControlFactory
) throw (UnknownPropertyException
, NullPointerException
, RuntimeException
)
274 ::osl::MutexGuard
aGuard( m_aMutex
);
275 PropertyId
nPropId( impl_getPropertyId_throw( _rPropertyName
) );
277 LineDescriptor aReturn
;
281 case PROPERTY_ID_TARGET_URL
:
282 aReturn
= m_xSlaveHandler
->describePropertyLine( _rPropertyName
, _rxControlFactory
);
285 aReturn
= ButtonNavigationHandler_Base::describePropertyLine( _rPropertyName
, _rxControlFactory
);
292 //........................................................................
294 //........................................................................