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