diff options
author | Oliver Bolte <obo@openoffice.org> | 2004-11-16 11:13:18 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2004-11-16 11:13:18 +0000 |
commit | 77308a1a9ca552d292f198a0a428430ad24dfe10 (patch) | |
tree | d238c2f4d3f6de04487b762b71ab12b864202876 /extensions | |
parent | b774e76353cc275c5e48d155ee199300fd3b18f9 (diff) |
INTEGRATION: CWS eforms2 (1.1.2); FILE ADDED
2004/08/04 13:45:58 fs 1.1.2.8: new logical name for a newly created binding / also allow de-selecting a binding-list-source
2004/08/04 13:00:11 fs 1.1.2.7: #i31958# use the XFormsUIHelper1 when generating UI names for submissions and bindings
2004/08/04 11:55:31 fs 1.1.2.6: #i31958# preliminary support for filling list and combo boxes from XML bindings
2004/07/22 10:37:30 fs 1.1.2.5: #i31762# pass the context document of the introspectee to some handlers
2004/07/22 09:04:46 fs 1.1.2.4: #i31762# split 'onBrowseButtonClicked' into 'requestUserInputOnButtonClick' and 'executeButtonClick', to allow composition of property handlers (request only once, but execute for every single handler in the composition)
2004/07/20 12:11:37 fs 1.1.2.3: in preparation of #i31762#: ensure that property handlers silently accept introspectees which they don't have properties for
2004/07/15 07:41:59 fs 1.1.2.2: #114856# cache supported properties
2004/07/12 14:25:14 fs 1.1.2.1: #114856# property handler for submission
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/source/propctrlr/submissionhandler.cxx | 436 |
1 files changed, 436 insertions, 0 deletions
diff --git a/extensions/source/propctrlr/submissionhandler.cxx b/extensions/source/propctrlr/submissionhandler.cxx new file mode 100644 index 000000000000..6c97ae6edf61 --- /dev/null +++ b/extensions/source/propctrlr/submissionhandler.cxx @@ -0,0 +1,436 @@ +/************************************************************************* + * + * $RCSfile: submissionhandler.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: obo $ $Date: 2004-11-16 12:13:18 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef EXTENSIONS_SOURCE_PROPCTRLR_SUBMISSIONHANDLER_HXX +#include "submissionhandler.hxx" +#endif +#ifndef _EXTENSIONS_PROPCTRLR_FORMMETADATA_HXX_ +#include "formmetadata.hxx" +#endif +#ifndef _EXTENSIONS_FORMSCTRLR_FORMSTRINGS_HXX_ +#include "formstrings.hxx" +#endif +#ifndef _EXTENSIONS_PROPCTRLR_LINEDESCRIPTOR_HXX_ +#include "linedescriptor.hxx" +#endif +#ifndef EXTENSIONS_SOURCE_PROPCTRLR_STRINGREPRESENTATION_HXX +#include "stringrepresentation.hxx" +#endif +#ifndef EXTENSIONS_SOURCE_PROPCTRLR_PROPBROWSERUI_HXX +#include "propbrowserui.hxx" +#endif + +/** === begin UNO includes === **/ +#ifndef _COM_SUN_STAR_FORM_FORMBUTTONTYPE_HPP_ +#include <com/sun/star/form/FormButtonType.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_ +#include <com/sun/star/container/XNamed.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_ +#include <com/sun/star/container/XIndexAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_SUBMISSION_XSUBMISSIONSUPPLIER_HPP_ +#include <com/sun/star/form/submission/XSubmissionSupplier.hpp> +#endif +/** === end UNO includes === **/ + +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif + +//........................................................................ +namespace pcr +{ +//........................................................................ + + using namespace ::comphelper; + using namespace ::com::sun::star; + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::beans; + using namespace ::com::sun::star::script; + using namespace ::com::sun::star::form; + using namespace ::com::sun::star::xforms; + using namespace ::com::sun::star::container; + + //==================================================================== + //= SubmissionHelper + //==================================================================== + //-------------------------------------------------------------------- + SubmissionHelper::SubmissionHelper( const Reference< XPropertySet >& _rxIntrospectee, const Reference< frame::XModel >& _rxContextDocument ) + :EFormsHelper( _rxIntrospectee, _rxContextDocument ) + { + OSL_ENSURE( canTriggerSubmissions( _rxIntrospectee, _rxContextDocument ), + "SubmissionHelper::SubmissionPropertyHandler: you should not have instantiated me!" ); + } + + //-------------------------------------------------------------------- + bool SubmissionHelper::canTriggerSubmissions( const Reference< XPropertySet >& _rxControlModel, + const Reference< frame::XModel >& _rxContextDocument ) SAL_THROW(()) + { + if ( !EFormsHelper::isEForm( _rxContextDocument ) ) + return false; + + try + { + Reference< submission::XSubmissionSupplier > xSubmissionSupp( _rxControlModel, UNO_QUERY ); + if ( xSubmissionSupp.is() ) + return true; + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "SubmissionHelper::canTriggerSubmissions: caught an exception!" ); + } + return false; + } + + //==================================================================== + //= SubmissionPropertyHandler + //==================================================================== + //-------------------------------------------------------------------- + SubmissionPropertyHandler::SubmissionPropertyHandler( const Reference< XPropertySet >& _rxIntrospectee, + const Reference< frame::XModel >& _rxContextDocument, const Reference< XTypeConverter >& _rxTypeConverter ) + :PropertyHandler ( _rxIntrospectee, _rxTypeConverter ) + ,OPropertyChangeListener( m_aMutex ) + { + if ( SubmissionHelper::canTriggerSubmissions( m_xIntrospectee, _rxContextDocument ) ) + { + m_pHelper.reset( new SubmissionHelper( m_xIntrospectee, _rxContextDocument ) ); + + OPropertyChangeMultiplexer* pMultiplexer = new OPropertyChangeMultiplexer( this, _rxIntrospectee ); + pMultiplexer->addProperty( PROPERTY_BUTTONTYPE ); + // this does not delete the object, since our base class holds it alive + } + } + + //-------------------------------------------------------------------- + SubmissionPropertyHandler::~SubmissionPropertyHandler( ) + { + disposeAdapter(); + } + + //-------------------------------------------------------------------- + Any SAL_CALL SubmissionPropertyHandler::getPropertyValue( PropertyId _nPropId, bool _bLazy ) const + { + Any aReturn; + + OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::getPropertyValue: we have no SupportedProperties!" ); + if ( !m_pHelper.get() ) + return aReturn; + + try + { + switch ( _nPropId ) + { + case PROPERTY_ID_SUBMISSION_ID: + { + Reference< submission::XSubmissionSupplier > xSubmissionSupp( m_xIntrospectee, UNO_QUERY ); + OSL_ENSURE( xSubmissionSupp.is(), "SubmissionPropertyHandler::getPropertyValue: this should never happen ..." ); + // this handler is not intended for components which are no XSubmissionSupplier + Reference< submission::XSubmission > xSubmission; + if ( xSubmissionSupp.is() ) + xSubmission = xSubmissionSupp->getSubmission( ); + aReturn <<= xSubmission; + } + break; + + case PROPERTY_ID_XFORMS_BUTTONTYPE: + { + FormButtonType eType = FormButtonType_PUSH; + OSL_VERIFY( m_xIntrospectee->getPropertyValue( PROPERTY_BUTTONTYPE ) >>= eType ); + if ( ( eType != FormButtonType_PUSH ) && ( eType != FormButtonType_SUBMIT ) ) + eType = FormButtonType_PUSH; + aReturn <<= eType; + } + break; + + default: + DBG_ERROR( "SubmissionPropertyHandler::getPropertyValue: cannot handle this property!" ); + } + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "SubmissionPropertyHandler::getPropertyValue: caught an exception!" ); + } + + return aReturn; + } + + //-------------------------------------------------------------------- + void SAL_CALL SubmissionPropertyHandler::setPropertyValue( PropertyId _nPropId, const Any& _rValue ) + { + OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::setPropertyValue: we have no SupportedProperties!" ); + if ( !m_pHelper.get() ) + return; + + try + { + switch ( _nPropId ) + { + case PROPERTY_ID_SUBMISSION_ID: + { + Reference< submission::XSubmission > xSubmission; + OSL_VERIFY( _rValue >>= xSubmission ); + + Reference< submission::XSubmissionSupplier > xSubmissionSupp( m_xIntrospectee, UNO_QUERY ); + OSL_ENSURE( xSubmissionSupp.is(), "SubmissionPropertyHandler::setPropertyValue: this should never happen ..." ); + // this handler is not intended for components which are no XSubmissionSupplier + if ( xSubmissionSupp.is() ) + xSubmissionSupp->setSubmission( xSubmission ); + } + break; + + case PROPERTY_ID_XFORMS_BUTTONTYPE: + m_xIntrospectee->setPropertyValue( PROPERTY_BUTTONTYPE, _rValue ); + break; + + default: + OSL_ENSURE( sal_False, "SubmissionPropertyHandler::setPropertyValue: cannot handle this id!" ); + } + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "SubmissionPropertyHandler::setPropertyValue: caught an exception!" ); + } + } + + //-------------------------------------------------------------------- + ::std::vector< ::rtl::OUString > SAL_CALL SubmissionPropertyHandler::getActuatingProperties( ) const + { + if ( !m_pHelper.get() ) + return ::std::vector< ::rtl::OUString >(); + + ::std::vector< ::rtl::OUString > aReturn( 1 ); + aReturn[ 0 ] = PROPERTY_XFORMS_BUTTONTYPE; + return aReturn; + } + + //-------------------------------------------------------------------- + ::std::vector< ::rtl::OUString > SAL_CALL SubmissionPropertyHandler::getSupersededProperties( ) const + { + if ( !m_pHelper.get() ) + return ::std::vector< ::rtl::OUString >(); + + ::std::vector< ::rtl::OUString > aReturn( 3 ); + aReturn[ 0 ] = PROPERTY_TARGET_URL; + aReturn[ 1 ] = PROPERTY_TARGET_FRAME; + aReturn[ 2 ] = PROPERTY_BUTTONTYPE; + return aReturn; + } + + //-------------------------------------------------------------------- + ::std::vector< Property > SAL_CALL SubmissionPropertyHandler::implDescribeSupportedProperties() const + { + ::std::vector< Property > aProperties; + if ( m_pHelper.get() ) + { + implAddPropertyDescription( aProperties, PROPERTY_SUBMISSION_ID, ::getCppuType( static_cast< Reference< submission::XSubmission > * >( NULL ) ) ); + implAddPropertyDescription( aProperties, PROPERTY_XFORMS_BUTTONTYPE, ::getCppuType( static_cast< FormButtonType* >( NULL ) ) ); + } + return aProperties; + } + + //-------------------------------------------------------------------- + bool SAL_CALL SubmissionPropertyHandler::supportsUIDescriptor( PropertyId _nPropId ) const + { + return true; + } + + //-------------------------------------------------------------------- + void SAL_CALL SubmissionPropertyHandler::describePropertyUI( PropertyId _nPropId, PropertyUIDescriptor& /* [out] */ _rDescriptor ) const + { + OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::describePropertyUI: we have no SupportedProperties!" ); + if ( !m_pHelper.get() ) + return; + + switch ( _nPropId ) + { + case PROPERTY_ID_SUBMISSION_ID: + _rDescriptor.eControlType = BCT_LISTBOX; + const_cast< SubmissionHelper* >( m_pHelper.get() )->getAllElementUINames( EFormsHelper::Submission, _rDescriptor.aListValues, false ); + break; + + case PROPERTY_ID_XFORMS_BUTTONTYPE: + { + _rDescriptor.eControlType = BCT_LISTBOX; + // available options are nearly the same as for the "normal" button type, but only the + // first two options + ::std::vector< String > aAllValues( m_pInfoService->getPropertyEnumRepresentations( PROPERTY_ID_BUTTONTYPE ) ); + _rDescriptor.aListValues.resize( 2 ); + _rDescriptor.aListValues[ 0 ] = aAllValues[ 0 ]; + _rDescriptor.aListValues[ 1 ] = aAllValues[ 1 ]; + } + break; + + default: + OSL_ENSURE( sal_False, "SubmissionPropertyHandler::describePropertyUI: cannot handle this id!" ); + } + } + + //-------------------------------------------------------------------- + void SAL_CALL SubmissionPropertyHandler::updateDependentProperties( PropertyId _nActuatingPropId, const Any& _rNewValue, const Any& _rOldValue, IPropertyBrowserUI* _pUpdater ) + { + OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::updateDependentProperties: we have no ActuatingProperties!" ); + if ( !m_pHelper.get() ) + return; + + switch ( _nActuatingPropId ) + { + case PROPERTY_ID_XFORMS_BUTTONTYPE: + { + FormButtonType eType = FormButtonType_PUSH; + OSL_VERIFY( _rNewValue >>= eType ); + _pUpdater->enablePropertyUI( PROPERTY_SUBMISSION_ID, eType == FormButtonType_SUBMIT ); + } + break; + + default: + OSL_ENSURE( sal_False, "SubmissionPropertyHandler::updateDependentProperties: cannot handle this id!" ); + } + } + + //-------------------------------------------------------------------- + void SAL_CALL SubmissionPropertyHandler::initializePropertyUI( PropertyId _nPropId, IPropertyBrowserUI* _pUpdater ) + { + OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::initializePropertyUI: we have no SupportedProperties!" ); + // nothing to do + } + + //-------------------------------------------------------------------- + Any SAL_CALL SubmissionPropertyHandler::getPropertyValueFromStringRep( PropertyId _nPropId, const ::rtl::OUString& _rStringRep ) const + { + Any aReturn; + + OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::getPropertyValueFromStringRep: we have no SupportedProperties!" ); + if ( !m_pHelper.get() ) + return aReturn; + + switch ( _nPropId ) + { + case PROPERTY_ID_SUBMISSION_ID: + { + Reference< XSubmission > xSubmission( m_pHelper->getModelElementFromUIName( EFormsHelper::Submission, _rStringRep ), UNO_QUERY ); + aReturn <<= xSubmission; + } + break; + + case PROPERTY_ID_XFORMS_BUTTONTYPE: + { + StringRepresentation aConversionHelper( m_xTypeConverter ); + aReturn = aConversionHelper.getPropertyValueFromStringRep( _rStringRep, ::getCppuType( static_cast< FormButtonType* >( NULL ) ), PROPERTY_ID_BUTTONTYPE, m_pInfoService.get() ); + } + break; + + default: + OSL_ENSURE( sal_False, "SubmissionPropertyHandler::getPropertyValueFromStringRep: cannot handle this id!" ); + } + + return aReturn; + } + + //-------------------------------------------------------------------- + ::rtl::OUString SAL_CALL SubmissionPropertyHandler::getStringRepFromPropertyValue( PropertyId _nPropId, const Any& _rValue ) const + { + ::rtl::OUString sReturn; + + OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::getStringRepFromPropertyValue: we have no SupportedProperties!" ); + if ( !m_pHelper.get() ) + return sReturn; + + switch ( _nPropId ) + { + case PROPERTY_ID_SUBMISSION_ID: + { + Reference< XPropertySet > xSubmission( _rValue, UNO_QUERY ); + if ( xSubmission.is() ) + sReturn = m_pHelper->getModelElementUIName( EFormsHelper::Submission, xSubmission ); + } + break; + + case PROPERTY_ID_XFORMS_BUTTONTYPE: + { + StringRepresentation aConversionHelper( m_xTypeConverter ); + sReturn = aConversionHelper.getStringRepFromPropertyValue( _rValue, PROPERTY_ID_BUTTONTYPE, m_pInfoService.get() ); + } + break; + + default: + OSL_ENSURE( sal_False, "SubmissionPropertyHandler::getStringRepFromPropertyValue: cannot handle this id!" ); + } + + return sReturn; + } + + //-------------------------------------------------------------------- + void SubmissionPropertyHandler::_propertyChanged( const PropertyChangeEvent& _rEvent ) throw(RuntimeException) + { + if ( _rEvent.PropertyName == PROPERTY_BUTTONTYPE ) + firePropertyChange( PROPERTY_XFORMS_BUTTONTYPE, PROPERTY_ID_XFORMS_BUTTONTYPE, _rEvent.OldValue, _rEvent.NewValue ); + } + +//........................................................................ +} // namespace pcr +//........................................................................ + |