1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: buttonnavigationhandler.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_extensions.hxx"
33 #include "buttonnavigationhandler.hxx"
34 #include "formstrings.hxx"
35 #include "formmetadata.hxx"
36 #include "pushbuttonnavigation.hxx"
38 /** === begin UNO includes === **/
39 /** === end UNO includes === **/
40 #include <tools/debug.hxx>
42 //------------------------------------------------------------------------
43 extern "C" void SAL_CALL
createRegistryInfo_ButtonNavigationHandler()
45 ::pcr::ButtonNavigationHandler::registerImplementation();
48 //........................................................................
51 //........................................................................
53 using namespace ::com::sun::star::uno
;
54 using namespace ::com::sun::star::lang
;
55 using namespace ::com::sun::star::beans
;
56 using namespace ::com::sun::star::script
;
57 using namespace ::com::sun::star::frame
;
58 using namespace ::com::sun::star::inspection
;
60 //====================================================================
61 //= ButtonNavigationHandler
62 //====================================================================
63 DBG_NAME( ButtonNavigationHandler
)
64 //--------------------------------------------------------------------
65 ButtonNavigationHandler::ButtonNavigationHandler( const Reference
< XComponentContext
>& _rxContext
)
66 :ButtonNavigationHandler_Base( _rxContext
)
68 DBG_CTOR( ButtonNavigationHandler
, NULL
);
70 m_aContext
.createComponent(
71 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.FormComponentPropertyHandler" ) ),
73 if ( !m_xSlaveHandler
.is() )
74 throw RuntimeException();
77 //--------------------------------------------------------------------
78 ButtonNavigationHandler::~ButtonNavigationHandler( )
80 DBG_DTOR( ButtonNavigationHandler
, NULL
);
83 //--------------------------------------------------------------------
84 ::rtl::OUString SAL_CALL
ButtonNavigationHandler::getImplementationName_static( ) throw (RuntimeException
)
86 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.ButtonNavigationHandler" ) );
89 //--------------------------------------------------------------------
90 Sequence
< ::rtl::OUString
> SAL_CALL
ButtonNavigationHandler::getSupportedServiceNames_static( ) throw (RuntimeException
)
92 Sequence
< ::rtl::OUString
> aSupported( 1 );
93 aSupported
[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.ButtonNavigationHandler" ) );
97 //--------------------------------------------------------------------
98 void SAL_CALL
ButtonNavigationHandler::inspect( const Reference
< XInterface
>& _rxIntrospectee
) throw (RuntimeException
, NullPointerException
)
100 ButtonNavigationHandler_Base::inspect( _rxIntrospectee
);
101 m_xSlaveHandler
->inspect( _rxIntrospectee
);
104 //--------------------------------------------------------------------
105 PropertyState SAL_CALL
ButtonNavigationHandler::getPropertyState( const ::rtl::OUString
& _rPropertyName
) throw (UnknownPropertyException
, RuntimeException
)
107 ::osl::MutexGuard
aGuard( m_aMutex
);
108 PropertyId
nPropId( impl_getPropertyId_throw( _rPropertyName
) );
109 PropertyState eState
= PropertyState_DIRECT_VALUE
;
112 case PROPERTY_ID_BUTTONTYPE
:
114 PushButtonNavigation
aHelper( m_xComponent
);
115 eState
= aHelper
.getCurrentButtonTypeState();
118 case PROPERTY_ID_TARGET_URL
:
120 PushButtonNavigation
aHelper( m_xComponent
);
121 eState
= aHelper
.getCurrentTargetURLState();
126 DBG_ERROR( "ButtonNavigationHandler::getPropertyState: cannot handle this property!" );
133 //--------------------------------------------------------------------
134 Any SAL_CALL
ButtonNavigationHandler::getPropertyValue( const ::rtl::OUString
& _rPropertyName
) throw (UnknownPropertyException
, RuntimeException
)
136 ::osl::MutexGuard
aGuard( m_aMutex
);
137 PropertyId
nPropId( impl_getPropertyId_throw( _rPropertyName
) );
142 case PROPERTY_ID_BUTTONTYPE
:
144 PushButtonNavigation
aHelper( m_xComponent
);
145 aReturn
= aHelper
.getCurrentButtonType();
149 case PROPERTY_ID_TARGET_URL
:
151 PushButtonNavigation
aHelper( m_xComponent
);
152 aReturn
= aHelper
.getCurrentTargetURL();
157 DBG_ERROR( "ButtonNavigationHandler::getPropertyValue: cannot handle this property!" );
164 //--------------------------------------------------------------------
165 void SAL_CALL
ButtonNavigationHandler::setPropertyValue( const ::rtl::OUString
& _rPropertyName
, const Any
& _rValue
) throw (UnknownPropertyException
, RuntimeException
)
167 ::osl::MutexGuard
aGuard( m_aMutex
);
168 PropertyId
nPropId( impl_getPropertyId_throw( _rPropertyName
) );
171 case PROPERTY_ID_BUTTONTYPE
:
173 PushButtonNavigation
aHelper( m_xComponent
);
174 aHelper
.setCurrentButtonType( _rValue
);
178 case PROPERTY_ID_TARGET_URL
:
180 PushButtonNavigation
aHelper( m_xComponent
);
181 aHelper
.setCurrentTargetURL( _rValue
);
186 OSL_ENSURE( sal_False
, "ButtonNavigationHandler::setPropertyValue: cannot handle this id!" );
190 //--------------------------------------------------------------------
191 bool ButtonNavigationHandler::isNavigationCapableButton( const Reference
< XPropertySet
>& _rxComponent
)
193 Reference
< XPropertySetInfo
> xPSI
;
194 if ( _rxComponent
.is() )
195 xPSI
= _rxComponent
->getPropertySetInfo();
198 && xPSI
->hasPropertyByName( PROPERTY_TARGET_URL
)
199 && xPSI
->hasPropertyByName( PROPERTY_BUTTONTYPE
);
202 //--------------------------------------------------------------------
203 Sequence
< Property
> SAL_CALL
ButtonNavigationHandler::doDescribeSupportedProperties() const
205 ::std::vector
< Property
> aProperties
;
207 if ( isNavigationCapableButton( m_xComponent
) )
209 addStringPropertyDescription( aProperties
, PROPERTY_TARGET_URL
);
210 implAddPropertyDescription( aProperties
, PROPERTY_BUTTONTYPE
, ::getCppuType( static_cast< sal_Int32
* >( NULL
) ) );
213 if ( aProperties
.empty() )
214 return Sequence
< Property
>();
215 return Sequence
< Property
>( &(*aProperties
.begin()), aProperties
.size() );
218 //--------------------------------------------------------------------
219 Sequence
< ::rtl::OUString
> SAL_CALL
ButtonNavigationHandler::getActuatingProperties( ) throw (RuntimeException
)
221 Sequence
< ::rtl::OUString
> aActuating( 2 );
222 aActuating
[0] = PROPERTY_BUTTONTYPE
;
223 aActuating
[1] = PROPERTY_TARGET_URL
;
227 //--------------------------------------------------------------------
228 InteractiveSelectionResult SAL_CALL
ButtonNavigationHandler::onInteractivePropertySelection( const ::rtl::OUString
& _rPropertyName
, sal_Bool _bPrimary
, Any
& _rData
, const Reference
< XObjectInspectorUI
>& _rxInspectorUI
) throw (UnknownPropertyException
, NullPointerException
, RuntimeException
)
230 ::osl::MutexGuard
aGuard( m_aMutex
);
231 PropertyId
nPropId( impl_getPropertyId_throw( _rPropertyName
) );
233 InteractiveSelectionResult
eReturn( InteractiveSelectionResult_Cancelled
);
237 case PROPERTY_ID_TARGET_URL
:
238 eReturn
= m_xSlaveHandler
->onInteractivePropertySelection( _rPropertyName
, _bPrimary
, _rData
, _rxInspectorUI
);
241 eReturn
= ButtonNavigationHandler_Base::onInteractivePropertySelection( _rPropertyName
, _bPrimary
, _rData
, _rxInspectorUI
);
248 //--------------------------------------------------------------------
249 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
)
251 ::osl::MutexGuard
aGuard( m_aMutex
);
252 PropertyId
nPropId( impl_getPropertyId_throw( _rActuatingPropertyName
) );
255 case PROPERTY_ID_BUTTONTYPE
:
257 PushButtonNavigation
aHelper( m_xComponent
);
258 _rxInspectorUI
->enablePropertyUI( PROPERTY_TARGET_URL
, aHelper
.currentButtonTypeIsOpenURL() );
262 case PROPERTY_ID_TARGET_URL
:
264 PushButtonNavigation
aHelper( m_xComponent
);
265 _rxInspectorUI
->enablePropertyUI( PROPERTY_TARGET_FRAME
, aHelper
.hasNonEmptyCurrentTargetURL() );
270 OSL_ENSURE( sal_False
, "ButtonNavigationHandler::actuatingPropertyChanged: cannot handle this id!" );
274 //--------------------------------------------------------------------
275 LineDescriptor SAL_CALL
ButtonNavigationHandler::describePropertyLine( const ::rtl::OUString
& _rPropertyName
, const Reference
< XPropertyControlFactory
>& _rxControlFactory
) throw (UnknownPropertyException
, NullPointerException
, RuntimeException
)
277 ::osl::MutexGuard
aGuard( m_aMutex
);
278 PropertyId
nPropId( impl_getPropertyId_throw( _rPropertyName
) );
280 LineDescriptor aReturn
;
284 case PROPERTY_ID_TARGET_URL
:
285 aReturn
= m_xSlaveHandler
->describePropertyLine( _rPropertyName
, _rxControlFactory
);
288 aReturn
= ButtonNavigationHandler_Base::describePropertyLine( _rPropertyName
, _rxControlFactory
);
295 //........................................................................
297 //........................................................................