12a97ec55SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
32a97ec55SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
42a97ec55SAndrew Rist * or more contributor license agreements. See the NOTICE file
52a97ec55SAndrew Rist * distributed with this work for additional information
62a97ec55SAndrew Rist * regarding copyright ownership. The ASF licenses this file
72a97ec55SAndrew Rist * to you under the Apache License, Version 2.0 (the
82a97ec55SAndrew Rist * "License"); you may not use this file except in compliance
92a97ec55SAndrew Rist * with the License. You may obtain a copy of the License at
102a97ec55SAndrew Rist *
112a97ec55SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
122a97ec55SAndrew Rist *
132a97ec55SAndrew Rist * Unless required by applicable law or agreed to in writing,
142a97ec55SAndrew Rist * software distributed under the License is distributed on an
152a97ec55SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162a97ec55SAndrew Rist * KIND, either express or implied. See the License for the
172a97ec55SAndrew Rist * specific language governing permissions and limitations
182a97ec55SAndrew Rist * under the License.
192a97ec55SAndrew Rist *
202a97ec55SAndrew Rist *************************************************************/
212a97ec55SAndrew Rist
222a97ec55SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_extensions.hxx"
26cdf0e10cSrcweir #include "submissionhandler.hxx"
27cdf0e10cSrcweir #include "formmetadata.hxx"
28cdf0e10cSrcweir #include "formstrings.hxx"
29cdf0e10cSrcweir #include "handlerhelper.hxx"
30cdf0e10cSrcweir
31cdf0e10cSrcweir /** === begin UNO includes === **/
32cdf0e10cSrcweir #include <com/sun/star/form/FormButtonType.hpp>
33cdf0e10cSrcweir #include <com/sun/star/container/XNamed.hpp>
34cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp>
35cdf0e10cSrcweir #include <com/sun/star/form/submission/XSubmissionSupplier.hpp>
36cdf0e10cSrcweir #include <com/sun/star/inspection/XObjectInspectorUI.hpp>
37cdf0e10cSrcweir /** === end UNO includes === **/
38cdf0e10cSrcweir #include <tools/debug.hxx>
39cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
40cdf0e10cSrcweir
41cdf0e10cSrcweir //------------------------------------------------------------------------
createRegistryInfo_SubmissionPropertyHandler()42cdf0e10cSrcweir extern "C" void SAL_CALL createRegistryInfo_SubmissionPropertyHandler()
43cdf0e10cSrcweir {
44cdf0e10cSrcweir ::pcr::SubmissionPropertyHandler::registerImplementation();
45cdf0e10cSrcweir }
46cdf0e10cSrcweir
47cdf0e10cSrcweir //........................................................................
48cdf0e10cSrcweir namespace pcr
49cdf0e10cSrcweir {
50cdf0e10cSrcweir //........................................................................
51cdf0e10cSrcweir
52cdf0e10cSrcweir using namespace ::comphelper;
53cdf0e10cSrcweir using namespace ::com::sun::star;
54cdf0e10cSrcweir using namespace ::com::sun::star::uno;
55cdf0e10cSrcweir using namespace ::com::sun::star::lang;
56cdf0e10cSrcweir using namespace ::com::sun::star::beans;
57cdf0e10cSrcweir using namespace ::com::sun::star::script;
58cdf0e10cSrcweir using namespace ::com::sun::star::form;
59cdf0e10cSrcweir using namespace ::com::sun::star::xforms;
60cdf0e10cSrcweir using namespace ::com::sun::star::container;
61cdf0e10cSrcweir using namespace ::com::sun::star::inspection;
62cdf0e10cSrcweir
63cdf0e10cSrcweir //====================================================================
64cdf0e10cSrcweir //= SubmissionHelper
65cdf0e10cSrcweir //====================================================================
66cdf0e10cSrcweir //--------------------------------------------------------------------
SubmissionHelper(::osl::Mutex & _rMutex,const Reference<XPropertySet> & _rxIntrospectee,const Reference<frame::XModel> & _rxContextDocument)67cdf0e10cSrcweir SubmissionHelper::SubmissionHelper( ::osl::Mutex& _rMutex, const Reference< XPropertySet >& _rxIntrospectee, const Reference< frame::XModel >& _rxContextDocument )
68cdf0e10cSrcweir :EFormsHelper( _rMutex, _rxIntrospectee, _rxContextDocument )
69cdf0e10cSrcweir {
70cdf0e10cSrcweir OSL_ENSURE( canTriggerSubmissions( _rxIntrospectee, _rxContextDocument ),
71cdf0e10cSrcweir "SubmissionHelper::SubmissionHelper: you should not have instantiated me!" );
72cdf0e10cSrcweir }
73cdf0e10cSrcweir
74cdf0e10cSrcweir //--------------------------------------------------------------------
canTriggerSubmissions(const Reference<XPropertySet> & _rxControlModel,const Reference<frame::XModel> & _rxContextDocument)75cdf0e10cSrcweir bool SubmissionHelper::canTriggerSubmissions( const Reference< XPropertySet >& _rxControlModel,
76cdf0e10cSrcweir const Reference< frame::XModel >& _rxContextDocument ) SAL_THROW(())
77cdf0e10cSrcweir {
78cdf0e10cSrcweir if ( !EFormsHelper::isEForm( _rxContextDocument ) )
79cdf0e10cSrcweir return false;
80cdf0e10cSrcweir
81cdf0e10cSrcweir try
82cdf0e10cSrcweir {
83cdf0e10cSrcweir Reference< submission::XSubmissionSupplier > xSubmissionSupp( _rxControlModel, UNO_QUERY );
84cdf0e10cSrcweir if ( xSubmissionSupp.is() )
85cdf0e10cSrcweir return true;
86cdf0e10cSrcweir }
87cdf0e10cSrcweir catch( const Exception& )
88cdf0e10cSrcweir {
89cdf0e10cSrcweir OSL_ENSURE( sal_False, "SubmissionHelper::canTriggerSubmissions: caught an exception!" );
90cdf0e10cSrcweir }
91cdf0e10cSrcweir return false;
92cdf0e10cSrcweir }
93cdf0e10cSrcweir
94cdf0e10cSrcweir //====================================================================
95cdf0e10cSrcweir //= SubmissionPropertyHandler
96cdf0e10cSrcweir //====================================================================
DBG_NAME(SubmissionPropertyHandler)97cdf0e10cSrcweir DBG_NAME( SubmissionPropertyHandler )
98cdf0e10cSrcweir //--------------------------------------------------------------------
99cdf0e10cSrcweir SubmissionPropertyHandler::SubmissionPropertyHandler( const Reference< XComponentContext >& _rxContext )
100cdf0e10cSrcweir :EditPropertyHandler_Base( _rxContext )
101cdf0e10cSrcweir ,OPropertyChangeListener( m_aMutex )
102cdf0e10cSrcweir ,m_pPropChangeMultiplexer( NULL )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir DBG_CTOR( SubmissionPropertyHandler, NULL );
105cdf0e10cSrcweir }
106cdf0e10cSrcweir
107cdf0e10cSrcweir //--------------------------------------------------------------------
~SubmissionPropertyHandler()108cdf0e10cSrcweir SubmissionPropertyHandler::~SubmissionPropertyHandler( )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir disposeAdapter();
111cdf0e10cSrcweir DBG_DTOR( SubmissionPropertyHandler, NULL );
112cdf0e10cSrcweir }
113cdf0e10cSrcweir
114cdf0e10cSrcweir //--------------------------------------------------------------------
getImplementationName_static()115cdf0e10cSrcweir ::rtl::OUString SAL_CALL SubmissionPropertyHandler::getImplementationName_static( ) throw (RuntimeException)
116cdf0e10cSrcweir {
117cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.SubmissionPropertyHandler" ) );
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
120cdf0e10cSrcweir //--------------------------------------------------------------------
getSupportedServiceNames_static()121cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL SubmissionPropertyHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
122cdf0e10cSrcweir {
123cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupported( 1 );
124cdf0e10cSrcweir aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.SubmissionPropertyHandler" ) );
125cdf0e10cSrcweir return aSupported;
126cdf0e10cSrcweir }
127cdf0e10cSrcweir
128cdf0e10cSrcweir //--------------------------------------------------------------------
getPropertyValue(const::rtl::OUString & _rPropertyName)129cdf0e10cSrcweir Any SAL_CALL SubmissionPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
130cdf0e10cSrcweir {
131cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
132cdf0e10cSrcweir PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
133cdf0e10cSrcweir
134cdf0e10cSrcweir OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::getPropertyValue: inconsistency!" );
135cdf0e10cSrcweir // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
136cdf0e10cSrcweir
137cdf0e10cSrcweir Any aReturn;
138cdf0e10cSrcweir try
139cdf0e10cSrcweir {
140cdf0e10cSrcweir switch ( nPropId )
141cdf0e10cSrcweir {
142cdf0e10cSrcweir case PROPERTY_ID_SUBMISSION_ID:
143cdf0e10cSrcweir {
144cdf0e10cSrcweir Reference< submission::XSubmissionSupplier > xSubmissionSupp( m_xComponent, UNO_QUERY );
145cdf0e10cSrcweir OSL_ENSURE( xSubmissionSupp.is(), "SubmissionPropertyHandler::getPropertyValue: this should never happen ..." );
146cdf0e10cSrcweir // this handler is not intended for components which are no XSubmissionSupplier
147cdf0e10cSrcweir Reference< submission::XSubmission > xSubmission;
148cdf0e10cSrcweir if ( xSubmissionSupp.is() )
149cdf0e10cSrcweir xSubmission = xSubmissionSupp->getSubmission( );
150cdf0e10cSrcweir aReturn <<= xSubmission;
151cdf0e10cSrcweir }
152cdf0e10cSrcweir break;
153cdf0e10cSrcweir
154cdf0e10cSrcweir case PROPERTY_ID_XFORMS_BUTTONTYPE:
155cdf0e10cSrcweir {
156cdf0e10cSrcweir FormButtonType eType = FormButtonType_PUSH;
157cdf0e10cSrcweir OSL_VERIFY( m_xComponent->getPropertyValue( PROPERTY_BUTTONTYPE ) >>= eType );
158cdf0e10cSrcweir if ( ( eType != FormButtonType_PUSH ) && ( eType != FormButtonType_SUBMIT ) )
159cdf0e10cSrcweir eType = FormButtonType_PUSH;
160cdf0e10cSrcweir aReturn <<= eType;
161cdf0e10cSrcweir }
162cdf0e10cSrcweir break;
163cdf0e10cSrcweir
164cdf0e10cSrcweir default:
165cdf0e10cSrcweir DBG_ERROR( "SubmissionPropertyHandler::getPropertyValue: cannot handle this property!" );
166cdf0e10cSrcweir break;
167cdf0e10cSrcweir }
168cdf0e10cSrcweir }
169cdf0e10cSrcweir catch( const Exception& )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir OSL_ENSURE( sal_False, "SubmissionPropertyHandler::getPropertyValue: caught an exception!" );
172cdf0e10cSrcweir }
173cdf0e10cSrcweir
174cdf0e10cSrcweir return aReturn;
175cdf0e10cSrcweir }
176cdf0e10cSrcweir
177cdf0e10cSrcweir //--------------------------------------------------------------------
setPropertyValue(const::rtl::OUString & _rPropertyName,const Any & _rValue)178cdf0e10cSrcweir void SAL_CALL SubmissionPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
179cdf0e10cSrcweir {
180cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
181cdf0e10cSrcweir PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
182cdf0e10cSrcweir
183cdf0e10cSrcweir OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::setPropertyValue: inconsistency!" );
184cdf0e10cSrcweir // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
185cdf0e10cSrcweir
186cdf0e10cSrcweir try
187cdf0e10cSrcweir {
188cdf0e10cSrcweir switch ( nPropId )
189cdf0e10cSrcweir {
190cdf0e10cSrcweir case PROPERTY_ID_SUBMISSION_ID:
191cdf0e10cSrcweir {
192cdf0e10cSrcweir Reference< submission::XSubmission > xSubmission;
193cdf0e10cSrcweir OSL_VERIFY( _rValue >>= xSubmission );
194cdf0e10cSrcweir
195cdf0e10cSrcweir Reference< submission::XSubmissionSupplier > xSubmissionSupp( m_xComponent, UNO_QUERY );
196cdf0e10cSrcweir OSL_ENSURE( xSubmissionSupp.is(), "SubmissionPropertyHandler::setPropertyValue: this should never happen ..." );
197cdf0e10cSrcweir // this handler is not intended for components which are no XSubmissionSupplier
198cdf0e10cSrcweir if ( xSubmissionSupp.is() )
199cdf0e10cSrcweir {
200cdf0e10cSrcweir xSubmissionSupp->setSubmission( xSubmission );
201cdf0e10cSrcweir impl_setContextDocumentModified_nothrow();
202cdf0e10cSrcweir }
203cdf0e10cSrcweir }
204cdf0e10cSrcweir break;
205cdf0e10cSrcweir
206cdf0e10cSrcweir case PROPERTY_ID_XFORMS_BUTTONTYPE:
207cdf0e10cSrcweir m_xComponent->setPropertyValue( PROPERTY_BUTTONTYPE, _rValue );
208cdf0e10cSrcweir break;
209cdf0e10cSrcweir
210cdf0e10cSrcweir default:
211cdf0e10cSrcweir OSL_ENSURE( sal_False, "SubmissionPropertyHandler::setPropertyValue: cannot handle this id!" );
212cdf0e10cSrcweir }
213cdf0e10cSrcweir }
214cdf0e10cSrcweir catch( const Exception& )
215cdf0e10cSrcweir {
216cdf0e10cSrcweir OSL_ENSURE( sal_False, "SubmissionPropertyHandler::setPropertyValue: caught an exception!" );
217cdf0e10cSrcweir }
218cdf0e10cSrcweir }
219cdf0e10cSrcweir
220cdf0e10cSrcweir //--------------------------------------------------------------------
getActuatingProperties()221cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL SubmissionPropertyHandler::getActuatingProperties( ) throw (RuntimeException)
222cdf0e10cSrcweir {
223cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
224cdf0e10cSrcweir if ( !m_pHelper.get() )
225cdf0e10cSrcweir return Sequence< ::rtl::OUString >();
226cdf0e10cSrcweir
227cdf0e10cSrcweir Sequence< ::rtl::OUString > aReturn( 1 );
228cdf0e10cSrcweir aReturn[ 0 ] = PROPERTY_XFORMS_BUTTONTYPE;
229cdf0e10cSrcweir return aReturn;
230cdf0e10cSrcweir }
231cdf0e10cSrcweir
232cdf0e10cSrcweir //--------------------------------------------------------------------
getSupersededProperties()233cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL SubmissionPropertyHandler::getSupersededProperties( ) throw (RuntimeException)
234cdf0e10cSrcweir {
235cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
236cdf0e10cSrcweir if ( !m_pHelper.get() )
237cdf0e10cSrcweir return Sequence< ::rtl::OUString >();
238cdf0e10cSrcweir
239cdf0e10cSrcweir Sequence< ::rtl::OUString > aReturn( 3 );
240cdf0e10cSrcweir aReturn[ 0 ] = PROPERTY_TARGET_URL;
241cdf0e10cSrcweir aReturn[ 1 ] = PROPERTY_TARGET_FRAME;
242cdf0e10cSrcweir aReturn[ 2 ] = PROPERTY_BUTTONTYPE;
243cdf0e10cSrcweir return aReturn;
244cdf0e10cSrcweir }
245cdf0e10cSrcweir
246cdf0e10cSrcweir //--------------------------------------------------------------------
onNewComponent()247cdf0e10cSrcweir void SubmissionPropertyHandler::onNewComponent()
248cdf0e10cSrcweir {
249cdf0e10cSrcweir if ( m_pPropChangeMultiplexer )
250cdf0e10cSrcweir {
251cdf0e10cSrcweir m_pPropChangeMultiplexer->dispose();
252cdf0e10cSrcweir m_pPropChangeMultiplexer->release();
253cdf0e10cSrcweir m_pPropChangeMultiplexer = NULL;
254cdf0e10cSrcweir }
255cdf0e10cSrcweir
256cdf0e10cSrcweir EditPropertyHandler_Base::onNewComponent();
257cdf0e10cSrcweir
258cdf0e10cSrcweir Reference< frame::XModel > xDocument( impl_getContextDocument_nothrow() );
259cdf0e10cSrcweir DBG_ASSERT( xDocument.is(), "SubmissionPropertyHandler::onNewComponent: no document!" );
260cdf0e10cSrcweir
261*3d762826SHerbert Dürr m_pHelper.reset();
262cdf0e10cSrcweir
263cdf0e10cSrcweir if ( SubmissionHelper::canTriggerSubmissions( m_xComponent, xDocument ) )
264cdf0e10cSrcweir {
265cdf0e10cSrcweir m_pHelper.reset( new SubmissionHelper( m_aMutex, m_xComponent, xDocument ) );
266cdf0e10cSrcweir
267cdf0e10cSrcweir m_pPropChangeMultiplexer = new OPropertyChangeMultiplexer( this, m_xComponent );
268cdf0e10cSrcweir m_pPropChangeMultiplexer->acquire();
269cdf0e10cSrcweir m_pPropChangeMultiplexer->addProperty( PROPERTY_BUTTONTYPE );
270cdf0e10cSrcweir }
271cdf0e10cSrcweir }
272cdf0e10cSrcweir
273cdf0e10cSrcweir //--------------------------------------------------------------------
doDescribeSupportedProperties() const274cdf0e10cSrcweir Sequence< Property > SAL_CALL SubmissionPropertyHandler::doDescribeSupportedProperties() const
275cdf0e10cSrcweir {
276cdf0e10cSrcweir ::std::vector< Property > aProperties;
277cdf0e10cSrcweir if ( m_pHelper.get() )
278cdf0e10cSrcweir {
279cdf0e10cSrcweir implAddPropertyDescription( aProperties, PROPERTY_SUBMISSION_ID, ::getCppuType( static_cast< Reference< submission::XSubmission > * >( NULL ) ) );
280cdf0e10cSrcweir implAddPropertyDescription( aProperties, PROPERTY_XFORMS_BUTTONTYPE, ::getCppuType( static_cast< FormButtonType* >( NULL ) ) );
281cdf0e10cSrcweir }
282cdf0e10cSrcweir if ( aProperties.empty() )
283cdf0e10cSrcweir return Sequence< Property >();
284cdf0e10cSrcweir return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
285cdf0e10cSrcweir }
286cdf0e10cSrcweir
287cdf0e10cSrcweir //--------------------------------------------------------------------
describePropertyLine(const::rtl::OUString & _rPropertyName,const Reference<XPropertyControlFactory> & _rxControlFactory)288cdf0e10cSrcweir LineDescriptor SAL_CALL SubmissionPropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
289cdf0e10cSrcweir const Reference< XPropertyControlFactory >& _rxControlFactory )
290cdf0e10cSrcweir throw (UnknownPropertyException, NullPointerException, RuntimeException)
291cdf0e10cSrcweir {
292cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
293cdf0e10cSrcweir if ( !_rxControlFactory.is() )
294cdf0e10cSrcweir throw NullPointerException();
295cdf0e10cSrcweir if ( !m_pHelper.get() )
296cdf0e10cSrcweir RuntimeException();
297cdf0e10cSrcweir
298cdf0e10cSrcweir ::std::vector< ::rtl::OUString > aListEntries;
299cdf0e10cSrcweir PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
300cdf0e10cSrcweir switch ( nPropId )
301cdf0e10cSrcweir {
302cdf0e10cSrcweir case PROPERTY_ID_SUBMISSION_ID:
303cdf0e10cSrcweir const_cast< SubmissionHelper* >( m_pHelper.get() )->getAllElementUINames( EFormsHelper::Submission, aListEntries, false );
304cdf0e10cSrcweir break;
305cdf0e10cSrcweir
306cdf0e10cSrcweir case PROPERTY_ID_XFORMS_BUTTONTYPE:
307cdf0e10cSrcweir {
308cdf0e10cSrcweir // available options are nearly the same as for the "normal" button type, but only the
309cdf0e10cSrcweir // first two options
310cdf0e10cSrcweir aListEntries = m_pInfoService->getPropertyEnumRepresentations( PROPERTY_ID_BUTTONTYPE );
311cdf0e10cSrcweir aListEntries.resize( 2 );
312cdf0e10cSrcweir }
313cdf0e10cSrcweir break;
314cdf0e10cSrcweir
315cdf0e10cSrcweir default:
316cdf0e10cSrcweir OSL_ENSURE( sal_False, "SubmissionPropertyHandler::describePropertyLine: cannot handle this id!" );
317cdf0e10cSrcweir return LineDescriptor();
318cdf0e10cSrcweir }
319cdf0e10cSrcweir
320cdf0e10cSrcweir LineDescriptor aDescriptor;
321cdf0e10cSrcweir aDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory, aListEntries, sal_False, sal_True );
322cdf0e10cSrcweir aDescriptor.DisplayName = m_pInfoService->getPropertyTranslation( nPropId );
323cdf0e10cSrcweir aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "General" ) );
324cdf0e10cSrcweir aDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nPropId ) );
325cdf0e10cSrcweir return aDescriptor;
326cdf0e10cSrcweir }
327cdf0e10cSrcweir
328cdf0e10cSrcweir //--------------------------------------------------------------------
actuatingPropertyChanged(const::rtl::OUString & _rActuatingPropertyName,const Any & _rNewValue,const Any &,const Reference<XObjectInspectorUI> & _rxInspectorUI,sal_Bool)329cdf0e10cSrcweir void SAL_CALL SubmissionPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool ) throw (NullPointerException, RuntimeException)
330cdf0e10cSrcweir {
331cdf0e10cSrcweir if ( !_rxInspectorUI.is() )
332cdf0e10cSrcweir throw NullPointerException();
333cdf0e10cSrcweir
334cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
335cdf0e10cSrcweir PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
336cdf0e10cSrcweir OSL_PRECOND( m_pHelper.get(), "SubmissionPropertyHandler::actuatingPropertyChanged: inconsistentcy!" );
337cdf0e10cSrcweir // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
338cdf0e10cSrcweir
339cdf0e10cSrcweir switch ( nActuatingPropId )
340cdf0e10cSrcweir {
341cdf0e10cSrcweir case PROPERTY_ID_XFORMS_BUTTONTYPE:
342cdf0e10cSrcweir {
343cdf0e10cSrcweir FormButtonType eType = FormButtonType_PUSH;
344cdf0e10cSrcweir OSL_VERIFY( _rNewValue >>= eType );
345cdf0e10cSrcweir _rxInspectorUI->enablePropertyUI( PROPERTY_SUBMISSION_ID, eType == FormButtonType_SUBMIT );
346cdf0e10cSrcweir }
347cdf0e10cSrcweir break;
348cdf0e10cSrcweir
349cdf0e10cSrcweir default:
350cdf0e10cSrcweir OSL_ENSURE( sal_False, "SubmissionPropertyHandler::actuatingPropertyChanged: cannot handle this id!" );
351cdf0e10cSrcweir }
352cdf0e10cSrcweir }
353cdf0e10cSrcweir
354cdf0e10cSrcweir //--------------------------------------------------------------------
convertToPropertyValue(const::rtl::OUString & _rPropertyName,const Any & _rControlValue)355cdf0e10cSrcweir Any SAL_CALL SubmissionPropertyHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
356cdf0e10cSrcweir {
357cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
358cdf0e10cSrcweir Any aPropertyValue;
359cdf0e10cSrcweir
360cdf0e10cSrcweir OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::convertToPropertyValue: we have no SupportedProperties!" );
361cdf0e10cSrcweir if ( !m_pHelper.get() )
362cdf0e10cSrcweir return aPropertyValue;
363cdf0e10cSrcweir
364cdf0e10cSrcweir ::rtl::OUString sControlValue;
365cdf0e10cSrcweir OSL_VERIFY( _rControlValue >>= sControlValue );
366cdf0e10cSrcweir
367cdf0e10cSrcweir PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
368cdf0e10cSrcweir switch ( nPropId )
369cdf0e10cSrcweir {
370cdf0e10cSrcweir case PROPERTY_ID_SUBMISSION_ID:
371cdf0e10cSrcweir {
372cdf0e10cSrcweir Reference< XSubmission > xSubmission( m_pHelper->getModelElementFromUIName( EFormsHelper::Submission, sControlValue ), UNO_QUERY );
373cdf0e10cSrcweir aPropertyValue <<= xSubmission;
374cdf0e10cSrcweir }
375cdf0e10cSrcweir break;
376cdf0e10cSrcweir
377cdf0e10cSrcweir case PROPERTY_ID_XFORMS_BUTTONTYPE:
378cdf0e10cSrcweir {
379cdf0e10cSrcweir ::rtl::Reference< IPropertyEnumRepresentation > aEnumConversion(
380cdf0e10cSrcweir new DefaultEnumRepresentation( *m_pInfoService, ::getCppuType( static_cast< FormButtonType* >( NULL ) ), PROPERTY_ID_BUTTONTYPE ) );
381cdf0e10cSrcweir // TODO/UNOize: make aEnumConversion a member?
382cdf0e10cSrcweir aEnumConversion->getValueFromDescription( sControlValue, aPropertyValue );
383cdf0e10cSrcweir }
384cdf0e10cSrcweir break;
385cdf0e10cSrcweir
386cdf0e10cSrcweir default:
387cdf0e10cSrcweir OSL_ENSURE( sal_False, "SubmissionPropertyHandler::convertToPropertyValue: cannot handle this id!" );
388cdf0e10cSrcweir }
389cdf0e10cSrcweir
390cdf0e10cSrcweir return aPropertyValue;
391cdf0e10cSrcweir }
392cdf0e10cSrcweir
393cdf0e10cSrcweir //--------------------------------------------------------------------
convertToControlValue(const::rtl::OUString & _rPropertyName,const Any & _rPropertyValue,const Type & _rControlValueType)394cdf0e10cSrcweir Any SAL_CALL SubmissionPropertyHandler::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
395cdf0e10cSrcweir {
396cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
397cdf0e10cSrcweir Any aControlValue;
398cdf0e10cSrcweir
399cdf0e10cSrcweir OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::convertToControlValue: we have no SupportedProperties!" );
400cdf0e10cSrcweir if ( !m_pHelper.get() )
401cdf0e10cSrcweir return aControlValue;
402cdf0e10cSrcweir
403cdf0e10cSrcweir OSL_ENSURE( _rControlValueType.getTypeClass() == TypeClass_STRING,
404cdf0e10cSrcweir "SubmissionPropertyHandler::convertToControlValue: all our controls should use strings for value exchange!" );
405cdf0e10cSrcweir (void)_rControlValueType;
406cdf0e10cSrcweir
407cdf0e10cSrcweir PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
408cdf0e10cSrcweir switch ( nPropId )
409cdf0e10cSrcweir {
410cdf0e10cSrcweir case PROPERTY_ID_SUBMISSION_ID:
411cdf0e10cSrcweir {
412cdf0e10cSrcweir Reference< XPropertySet > xSubmission( _rPropertyValue, UNO_QUERY );
413cdf0e10cSrcweir if ( xSubmission.is() )
414cdf0e10cSrcweir aControlValue <<= m_pHelper->getModelElementUIName( EFormsHelper::Submission, xSubmission );
415cdf0e10cSrcweir }
416cdf0e10cSrcweir break;
417cdf0e10cSrcweir
418cdf0e10cSrcweir case PROPERTY_ID_XFORMS_BUTTONTYPE:
419cdf0e10cSrcweir {
420cdf0e10cSrcweir ::rtl::Reference< IPropertyEnumRepresentation > aEnumConversion(
421cdf0e10cSrcweir new DefaultEnumRepresentation( *m_pInfoService, _rPropertyValue.getValueType(), PROPERTY_ID_BUTTONTYPE ) );
422cdf0e10cSrcweir // TODO/UNOize: make aEnumConversion a member?
423cdf0e10cSrcweir aControlValue <<= aEnumConversion->getDescriptionForValue( _rPropertyValue );
424cdf0e10cSrcweir }
425cdf0e10cSrcweir break;
426cdf0e10cSrcweir
427cdf0e10cSrcweir default:
428cdf0e10cSrcweir OSL_ENSURE( sal_False, "SubmissionPropertyHandler::convertToControlValue: cannot handle this id!" );
429cdf0e10cSrcweir }
430cdf0e10cSrcweir
431cdf0e10cSrcweir return aControlValue;
432cdf0e10cSrcweir }
433cdf0e10cSrcweir
434cdf0e10cSrcweir //--------------------------------------------------------------------
_propertyChanged(const PropertyChangeEvent & _rEvent)435cdf0e10cSrcweir void SubmissionPropertyHandler::_propertyChanged( const PropertyChangeEvent& _rEvent ) throw(RuntimeException)
436cdf0e10cSrcweir {
437cdf0e10cSrcweir if ( _rEvent.PropertyName == PROPERTY_BUTTONTYPE )
438cdf0e10cSrcweir firePropertyChange( PROPERTY_XFORMS_BUTTONTYPE, PROPERTY_ID_XFORMS_BUTTONTYPE, _rEvent.OldValue, _rEvent.NewValue );
439cdf0e10cSrcweir }
440cdf0e10cSrcweir
441cdf0e10cSrcweir //........................................................................
442cdf0e10cSrcweir } // namespace pcr
443cdf0e10cSrcweir //........................................................................
444cdf0e10cSrcweir
445