diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2006-03-14 10:35:13 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2006-03-14 10:35:13 +0000 |
commit | 8b285f5c28a81507e6e6f04b0bac21c732c0749f (patch) | |
tree | 44f4c98e8ce2abeb6781a05d0af18f51f73c8121 /extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx | |
parent | 70dc2ea58beca9ba12ea390547410c31559e9870 (diff) |
INTEGRATION: CWS pbrwuno (1.3.88); FILE MERGED
2006/03/13 07:35:15 fs 1.3.88.21: more help ids
2006/03/09 14:16:41 fs 1.3.88.20: Has*Button must be set, too, not only the images
2006/02/15 07:25:56 fs 1.3.88.19: don't access &(*foo.begin()) of empty STL containers
2005/11/02 12:17:22 fs 1.3.88.18: #i10000# exception specifications
2005/11/02 11:43:48 fs 1.3.88.17: #i10000# exception specifications
2005/10/25 07:13:16 fs 1.3.88.16: #i53095# knitting lose ends (amongst others, make the handlers available as service)
2005/10/24 08:42:10 fs 1.3.88.15: start making the handlers full-fledged components, with using a new infrastructure replacing extensions/source/inc/componentmodule.*
2005/10/17 14:09:40 fs 1.3.88.14: #i53095# some cleanup of remaining TODOs
2005/10/17 13:19:06 fs 1.3.88.13: #i53095# proper listener administration: allow multiple listeners per handler
2005/10/17 09:48:45 fs 1.3.88.12: #i53095# make DateFields and TimeFields exchange their values as css.util.Date/Time
2005/10/17 08:58:21 fs 1.3.88.11: some mutex locking
2005/10/14 12:43:50 fs 1.3.88.10: #i53095# properly care for MAYBEVOID properties and AMBIGUOUS property values
2005/10/13 13:01:12 fs 1.3.88.9: #i53095# introduce an XObjectInspector/Model
2005/10/11 13:29:58 fs 1.3.88.8: #i53095# phase 3:
introduced XPropertyHandler and XObjectInspectorUI
same open issues as in previous phase
(plus probably some more, since not everything is tested, yet :-\)
2005/10/05 07:16:07 fs 1.3.88.7: RESYNC: (1.3-1.4); FILE MERGED
2005/09/05 07:41:56 fs 1.3.88.6: #i53095# phase 3, part 1: introduced XPropertyControl and relatives,
describing one control in the ObjectInspector, responsible for one
property
known issues:
- rebuildPropertyUI can cause problems now: If the user clicks into
the control for property A, which causes property B to be committed,
which causes the UI for property A to be rebuilt, then this will
crash currently. Reason: rebuildPropertyUI now synchronously replaces
the VCL-Window of the rebuilt control, which is exactly the one
which is still in some MouseButtonDown-handler.
possible solutions:
- see if rebuiltPropertyUI can be obsoleted - handlers should be able
to just obtain the XPropertyControl from the PropertyUI, and
re-initialize the control. Shouldn't they?`
- make one of the steps in the chain (mouse-click, handler-call,
rebuildPropertyUI-callback) asynchronous.
2005/08/18 12:44:36 fs 1.3.88.5: #i53095#, phase 2
moved (nearly) all property handling to dedicated handlers, the controller is
now simply managing a set of handlers
open issues for making the property browser completely generic:
- target page for a property - at the moment, the pbrw uses form-specific
knowledge
- relative position of properties. Again, the pbrw uses the OPropertyInfoService
which is not generic
- isComposeable for a given property. Also OPropertyInfoService-dependent ATM
- help ids of pages and the pbrw as a whole. They're hard-coded at the moment
other open issues:
everything in the code which is tagged with TOD/UNOize. Those are items which
do not immediately hinder phase 3 (real UNOization, i.e. definition of new
UNO interfaces for the handlers, the controller, and so on), but need to be
addressed in phase 4 (knit lose ends)
2005/08/16 05:39:08 fs 1.3.88.4: #i53095# completely moved the handling of actuating properties into dedicated handlers
2005/08/12 16:30:16 fs 1.3.88.3: - more fine-grained control in the IPropertyBrowserUI which elements
to enable or disable
- moved designing the SQL command into a dedicated handler
- some more reactions on actuating properties move to dedicated handlers
- *nearly* completed implementation of the "composed browser UI", which
collects and combines UI change requests (IPropertyBrowserUI)
(still missing: proper auto-firing)
2005/08/10 15:41:48 fs 1.3.88.2: #i53095#
get rid of nearly all [1] the implementations in OPropertyBrowserController::Clicked,
and move them to a FormComponentHandler
[1] still to migrate:
- browsing for events (needs a dedicated event property handler)
- handling for clicking the button of the Command property - this
is kind of asynchronous, and IPropertyHandler is not yet prepared for this
2005/08/09 14:00:09 fs 1.3.88.1: #i53095# phase 1:
- don't use strings to transver values between controls and introspectee, but Anys
- first version of a dedicated property handler for form-component-related properties
(not yet completed)
known regressions over previous phase:
- handlers for events not yet implemented, thus some assertions
- click handlers for form-component-related properties do not yet work,
thus the browse buttons mostly do not work
Diffstat (limited to 'extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx')
-rw-r--r-- | extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx | 433 |
1 files changed, 233 insertions, 200 deletions
diff --git a/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx b/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx index 1054da698722..45aab83bee44 100644 --- a/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx +++ b/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx @@ -4,9 +4,9 @@ * * $RCSfile: xsdvalidationpropertyhandler.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: rt $ $Date: 2005-09-08 20:33:37 $ + * last change: $Author: vg $ $Date: 2006-03-14 11:35:13 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -42,9 +42,6 @@ #ifndef _EXTENSIONS_PROPCTRLR_FORMMETADATA_HXX_ #include "formmetadata.hxx" #endif -#ifndef _EXTENSIONS_PROPCTRLR_LINEDESCRIPTOR_HXX_ -#include "linedescriptor.hxx" -#endif #ifndef EXTENSIONS_SOURCE_PROPCTRLR_XSDDATATYPES_HXX #include "xsddatatypes.hxx" #endif @@ -60,18 +57,18 @@ #ifndef EXTENSIONS_INC_EXTENSIO_HRC #include "extensio.hrc" #endif -#ifndef EXTENSIONS_SOURCE_PROPCTRLR_STRINGREPRESENTATION_HXX -#include "stringrepresentation.hxx" -#endif #ifndef EXTENSIONS_SOURCE_PROPCTRLR_NEWDATATYPE_HXX #include "newdatatype.hxx" #endif -#ifndef EXTENSIONS_SOURCE_PROPCTRLR_PROPBROWSERUI_HXX -#include "propbrowserui.hxx" -#endif #ifndef EXTENSIONS_SOURCE_PROPCTRLR_XSDVALIDATIONHELPER_HXX #include "xsdvalidationhelper.hxx" #endif +#ifndef _EXTENSIONS_PROPCTRLR_PCRCOMMON_HXX_ +#include "pcrcommon.hxx" +#endif +#ifndef EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX +#include "handlerhelper.hxx" +#endif /** === begin UNO includes === **/ #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ @@ -83,6 +80,18 @@ #ifndef _COM_SUN_STAR_XSD_DATATYPECLASS_HPP_ #include <com/sun/star/xsd/DataTypeClass.hpp> #endif +#ifndef _COM_SUN_STAR_INSPECTION_PROPERTYCONTROLTYPE_HPP_ +#include <com/sun/star/inspection/PropertyControlType.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_OPTIONAL_HPP_ +#include <com/sun/star/beans/Optional.hpp> +#endif +#ifndef _COM_SUN_STAR_INSPECTION_XOBJECTINSPECTORUI_HPP_ +#include <com/sun/star/inspection/XObjectInspectorUI.hpp> +#endif +#ifndef _COM_SUN_STAR_INSPECTION_PROPERTYLINEELEMENT_HPP_ +#include <com/sun/star/inspection/PropertyLineElement.hpp> +#endif /** === end UNO includes === **/ #ifndef _SV_MSGBOX_HXX @@ -99,6 +108,12 @@ #include <functional> #include <limits> +//------------------------------------------------------------------------ +extern "C" void SAL_CALL createRegistryInfo_XSDValidationPropertyHandler() +{ + ::pcr::XSDValidationPropertyHandler::registerImplementation(); +} + //........................................................................ namespace pcr { @@ -111,44 +126,53 @@ namespace pcr using namespace ::com::sun::star::xforms; using namespace ::com::sun::star::xsd; using namespace ::com::sun::star::script; + using namespace ::com::sun::star::inspection; using ::com::sun::star::beans::PropertyAttribute::MAYBEVOID; //==================================================================== //= XSDValidationPropertyHandler //==================================================================== + DBG_NAME( XSDValidationPropertyHandler ) //-------------------------------------------------------------------- - XSDValidationPropertyHandler::XSDValidationPropertyHandler( const Reference< XPropertySet >& _rxIntrospectee, - const Reference< frame::XModel >& _rxContextDocument, const Reference< XTypeConverter >& _rxTypeConverter ) - :PropertyHandler( _rxIntrospectee, _rxTypeConverter ) + XSDValidationPropertyHandler::XSDValidationPropertyHandler( const Reference< XComponentContext >& _rxContext ) + :XSDValidationPropertyHandler_Base( _rxContext ) { - if ( EFormsHelper::isEForm( _rxContextDocument ) ) - m_pHelper.reset( new XSDValidationHelper( m_xIntrospectee, _rxContextDocument ) ); + DBG_CTOR( XSDValidationPropertyHandler, NULL ); } //-------------------------------------------------------------------- XSDValidationPropertyHandler::~XSDValidationPropertyHandler() { + DBG_DTOR( XSDValidationPropertyHandler, NULL ); } //-------------------------------------------------------------------- - bool SAL_CALL XSDValidationPropertyHandler::supportsUIDescriptor( PropertyId _nPropId ) const + ::rtl::OUString SAL_CALL XSDValidationPropertyHandler::getImplementationName_static( ) throw (RuntimeException) { - return true; + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.XSDValidationPropertyHandler" ) ); } //-------------------------------------------------------------------- - Any SAL_CALL XSDValidationPropertyHandler::getPropertyValue( PropertyId _nPropId, bool _bLazy ) const + Sequence< ::rtl::OUString > SAL_CALL XSDValidationPropertyHandler::getSupportedServiceNames_static( ) throw (RuntimeException) { - Any aReturn; + Sequence< ::rtl::OUString > aSupported( 1 ); + aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.XSDValidationPropertyHandler" ) ); + return aSupported; + } - OSL_ENSURE( m_pHelper.get(), "XSDValidationPropertyHandler::getPropertyValue: we don't have any SupportedProperties!" ); - if ( !m_pHelper.get() ) - return aReturn; + //-------------------------------------------------------------------- + Any SAL_CALL XSDValidationPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException) + { + ::osl::MutexGuard aGuard( m_aMutex ); + PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) ); - ::rtl::Reference< XSDDataType > pType = m_pHelper->getValidatingDataType(); + OSL_ENSURE( m_pHelper.get(), "XSDValidationPropertyHandler::getPropertyValue: inconsistency!" ); + // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties - switch ( _nPropId ) + Any aReturn; + ::rtl::Reference< XSDDataType > pType = m_pHelper->getValidatingDataType(); + switch ( nPropId ) { // common facets case PROPERTY_ID_XSD_DATA_TYPE: aReturn = pType.is() ? pType->getFacet( PROPERTY_NAME ) : makeAny( ::rtl::OUString() ); break; @@ -158,9 +182,8 @@ namespace pcr // all other properties are simply forwarded, if they exist at the given type default: { - ::rtl::OUString sFacetName = getPropertyNameFromId( _nPropId ); - if ( pType.is() && pType->hasFacet( sFacetName ) ) - aReturn = pType->getFacet( sFacetName ); + if ( pType.is() && pType->hasFacet( _rPropertyName ) ) + aReturn = pType->getFacet( _rPropertyName ); } break; } @@ -169,17 +192,20 @@ namespace pcr } //-------------------------------------------------------------------- - void SAL_CALL XSDValidationPropertyHandler::setPropertyValue( PropertyId _nPropId, const Any& _rValue ) + void SAL_CALL XSDValidationPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException) { - OSL_ENSURE( m_pHelper.get(), "XSDValidationPropertyHandler::setPropertyValue: we don't have any SupportedProperties!" ); - if ( !m_pHelper.get() ) - return; + ::osl::MutexGuard aGuard( m_aMutex ); + PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) ); + + OSL_ENSURE( m_pHelper.get(), "XSDValidationPropertyHandler::getPropertyValue: inconsistency!" ); + // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties - if ( PROPERTY_ID_XSD_DATA_TYPE == _nPropId ) + if ( PROPERTY_ID_XSD_DATA_TYPE == nPropId ) { ::rtl::OUString sTypeName; OSL_VERIFY( _rValue >>= sTypeName ); m_pHelper->setValidatingDataTypeByName( sTypeName ); + impl_setContextDocumentModified_nothrow(); return; } @@ -190,11 +216,25 @@ namespace pcr return; } - pType->setFacet( getPropertyNameFromId( _nPropId ), _rValue ); + pType->setFacet( _rPropertyName, _rValue ); + impl_setContextDocumentModified_nothrow(); + } + + //-------------------------------------------------------------------- + void XSDValidationPropertyHandler::onNewComponent() + { + XSDValidationPropertyHandler_Base::onNewComponent(); + + Reference< frame::XModel > xDocument( impl_getContextDocument_nothrow() ); + DBG_ASSERT( xDocument.is(), "XSDValidationPropertyHandler::onNewComponent: no document!" ); + if ( EFormsHelper::isEForm( xDocument ) ) + m_pHelper.reset( new XSDValidationHelper( m_aMutex, m_xComponent, xDocument ) ); + else + m_pHelper.reset( NULL ); } //-------------------------------------------------------------------- - ::std::vector< Property > XSDValidationPropertyHandler::implDescribeSupportedProperties() const + Sequence< Property > XSDValidationPropertyHandler::doDescribeSupportedProperties() const { ::std::vector< Property > aProperties; @@ -243,14 +283,17 @@ namespace pcr } } - return aProperties; + if ( aProperties.empty() ) + return Sequence< Property >(); + return Sequence< Property >( &(*aProperties.begin()), aProperties.size() ); } //-------------------------------------------------------------------- - ::std::vector< ::rtl::OUString > XSDValidationPropertyHandler::getSupersededProperties( ) const + Sequence< ::rtl::OUString > SAL_CALL XSDValidationPropertyHandler::getSupersededProperties( ) throw (RuntimeException) { - ::std::vector< ::rtl::OUString > aSuperfluous; + ::osl::MutexGuard aGuard( m_aMutex ); + ::std::vector< ::rtl::OUString > aSuperfluous; if ( m_pHelper.get() ) { aSuperfluous.push_back( PROPERTY_CONTROLSOURCE ); @@ -277,144 +320,98 @@ namespace pcr } } - return aSuperfluous; + if ( aSuperfluous.empty() ) + return Sequence< ::rtl::OUString >(); + return Sequence< ::rtl::OUString >( &(*aSuperfluous.begin()), aSuperfluous.size() ); } //-------------------------------------------------------------------- - ::std::vector< ::rtl::OUString > SAL_CALL XSDValidationPropertyHandler::getActuatingProperties( ) const + Sequence< ::rtl::OUString > SAL_CALL XSDValidationPropertyHandler::getActuatingProperties( ) throw (RuntimeException) { + ::osl::MutexGuard aGuard( m_aMutex ); ::std::vector< ::rtl::OUString > aInterestedInActuations( 2 ); if ( m_pHelper.get() ) { aInterestedInActuations.push_back( PROPERTY_XSD_DATA_TYPE ); aInterestedInActuations.push_back( PROPERTY_XML_DATA_MODEL ); } - return aInterestedInActuations; + if ( aInterestedInActuations.empty() ) + return Sequence< ::rtl::OUString >(); + return Sequence< ::rtl::OUString >( &(*aInterestedInActuations.begin()), aInterestedInActuations.size() ); } //-------------------------------------------------------------------- namespace { - void showPropertyUI( IPropertyBrowserUI* _pUpdater, const ::rtl::OUString& _rPropertyName, bool _bShow ) + void showPropertyUI( const Reference< XObjectInspectorUI >& _rxInspectorUI, const ::rtl::OUString& _rPropertyName, bool _bShow ) { if ( _bShow ) - _pUpdater->showPropertyUI( _rPropertyName, true ); + _rxInspectorUI->showPropertyUI( _rPropertyName ); else - _pUpdater->hidePropertyUI( _rPropertyName ); + _rxInspectorUI->hidePropertyUI( _rPropertyName ); } } //-------------------------------------------------------------------- - void SAL_CALL XSDValidationPropertyHandler::initializePropertyUI( PropertyId _nPropId, IPropertyBrowserUI* _pUpdater ) + void SAL_CALL XSDValidationPropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName, + LineDescriptor& /* [out] */ _rDescriptor, const Reference< XPropertyControlFactory >& _rxControlFactory ) + throw (UnknownPropertyException, NullPointerException, RuntimeException) { - OSL_ENSURE( m_pHelper.get(), "XSDValidationPropertyHandler::initializePropertyUI: we don't have any SupportedProperties!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + if ( !_rxControlFactory.is() ) + throw NullPointerException(); if ( !m_pHelper.get() ) - return; - - switch ( _nPropId ) - { - case PROPERTY_ID_XSD_DATA_TYPE: - { - ::rtl::Reference< XSDDataType > xDataType( m_pHelper->getValidatingDataType() ); - sal_Int16 nTypeClass = xDataType.is() ? xDataType->classify() : DataTypeClass::STRING; - - // is removal of this type possible? - bool bIsBasicType = xDataType.is() && xDataType->isBasicType(); - _pUpdater->enablePropertyButtons( PROPERTY_XSD_DATA_TYPE, xDataType.is(), xDataType.is() && !bIsBasicType ); - - //------------------------------------------------------------ - // show the facets which are available at the data type - ::rtl::OUString aFacets[] = { - PROPERTY_XSD_WHITESPACES, PROPERTY_XSD_PATTERN, - PROPERTY_XSD_LENGTH, PROPERTY_XSD_MIN_LENGTH, PROPERTY_XSD_MAX_LENGTH, PROPERTY_XSD_TOTAL_DIGITS, - PROPERTY_XSD_FRACTION_DIGITS, - PROPERTY_XSD_MAX_INCLUSIVE_INT, - PROPERTY_XSD_MAX_EXCLUSIVE_INT, - PROPERTY_XSD_MIN_INCLUSIVE_INT, - PROPERTY_XSD_MIN_EXCLUSIVE_INT, - PROPERTY_XSD_MAX_INCLUSIVE_DOUBLE, - PROPERTY_XSD_MAX_EXCLUSIVE_DOUBLE, - PROPERTY_XSD_MIN_INCLUSIVE_DOUBLE, - PROPERTY_XSD_MIN_EXCLUSIVE_DOUBLE, - PROPERTY_XSD_MAX_INCLUSIVE_DATE, - PROPERTY_XSD_MAX_EXCLUSIVE_DATE, - PROPERTY_XSD_MIN_INCLUSIVE_DATE, - PROPERTY_XSD_MIN_EXCLUSIVE_DATE, - PROPERTY_XSD_MAX_INCLUSIVE_TIME, - PROPERTY_XSD_MAX_EXCLUSIVE_TIME, - PROPERTY_XSD_MIN_INCLUSIVE_TIME, - PROPERTY_XSD_MIN_EXCLUSIVE_TIME, - PROPERTY_XSD_MAX_INCLUSIVE_DATE_TIME, - PROPERTY_XSD_MAX_EXCLUSIVE_DATE_TIME, - PROPERTY_XSD_MIN_INCLUSIVE_DATE_TIME, - PROPERTY_XSD_MIN_EXCLUSIVE_DATE_TIME - }; + throw RuntimeException(); - sal_Int32 i=0; - const ::rtl::OUString* pLoop = NULL; - for ( i = 0, pLoop = aFacets; - i < sizeof( aFacets ) / sizeof( aFacets[0] ); - ++i, ++pLoop - ) - { - showPropertyUI( _pUpdater, *pLoop, xDataType.is() && xDataType->hasFacet( *pLoop ) ); - _pUpdater->enablePropertyUI( *pLoop, !bIsBasicType ); - } - } - break; - } - } + PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) ); - //-------------------------------------------------------------------- - void SAL_CALL XSDValidationPropertyHandler::describePropertyUI( PropertyId _nPropId, PropertyUIDescriptor& /* [out] */ _rDescriptor ) const - { - OSL_ENSURE( m_pHelper.get(), "XSDValidationPropertyHandler::describePropertyUI: we don't have any SupportedProperties!" ); - if ( !m_pHelper.get() ) - return; + if ( nPropId != PROPERTY_ID_XSD_DATA_TYPE ) + _rDescriptor.IndentLevel = 1; - if ( _nPropId != PROPERTY_ID_XSD_DATA_TYPE ) - _rDescriptor.bIndent = sal_True; + // collect some information about the to-be-created control + sal_Int16 nControlType = PropertyControlType::TextField; + ::std::vector< ::rtl::OUString > aListEntries; + Optional< double > aMinValue( sal_False, 0 ); + Optional< double > aMaxValue( sal_False, 0 ); - switch ( _nPropId ) + switch ( nPropId ) { case PROPERTY_ID_XSD_DATA_TYPE: - _rDescriptor.eControlType = BCT_LISTBOX; + nControlType = PropertyControlType::ListBox; - implGetAvailableDataTypeNames( _rDescriptor.aListValues ); + implGetAvailableDataTypeNames( aListEntries ); - _rDescriptor.nButtonHelpId = UID_PROP_ADD_DATA_TYPE; - _rDescriptor.nAdditionalButtonHelpId = UID_PROP_REMOVE_DATA_TYPE; + _rDescriptor.PrimaryButtonId = UID_PROP_ADD_DATA_TYPE; + _rDescriptor.SecondaryButtonId = UID_PROP_REMOVE_DATA_TYPE; { - ModuleRes aResId( RID_RSC_BUTTON_IMAGES ); + PcrRes aResId( RID_RSC_BUTTON_IMAGES ); ::svt::OLocalResourceAccess aEnumStrings( aResId, RSC_RESOURCE ); - _rDescriptor.aButtonImage = Image( ResId( IMG_PLUS ) ); - _rDescriptor.aAdditionalButtonImage = Image( ResId( IMG_MINUS ) ); + _rDescriptor.HasPrimaryButton = _rDescriptor.HasSecondaryButton = sal_True; + _rDescriptor.PrimaryButtonImage = Image( ResId( IMG_PLUS ) ).GetXGraphic(); + _rDescriptor.SecondaryButtonImage = Image( ResId( IMG_MINUS ) ).GetXGraphic(); } break; case PROPERTY_ID_XSD_WHITESPACES: { - _rDescriptor.eControlType = BCT_LISTBOX; - ::std::vector< String > aListValues = m_pInfoService->getPropertyEnumRepresentations( PROPERTY_ID_XSD_WHITESPACES ); - _rDescriptor.aListValues.resize( aListValues.size() ); - ::std::copy( aListValues.begin(), aListValues.end(), _rDescriptor.aListValues.begin() ); + nControlType = PropertyControlType::ListBox; + aListEntries = m_pInfoService->getPropertyEnumRepresentations( PROPERTY_ID_XSD_WHITESPACES ); } break; case PROPERTY_ID_XSD_PATTERN: - _rDescriptor.eControlType = BCT_EDIT; + nControlType = PropertyControlType::TextField; break; case PROPERTY_ID_XSD_LENGTH: case PROPERTY_ID_XSD_MIN_LENGTH: case PROPERTY_ID_XSD_MAX_LENGTH: - _rDescriptor.eControlType = BCT_NUMFIELD; + nControlType = PropertyControlType::NumericField; break; case PROPERTY_ID_XSD_TOTAL_DIGITS: case PROPERTY_ID_XSD_FRACTION_DIGITS: - _rDescriptor.eControlType = BCT_NUMFIELD; - _rDescriptor.nDigits = 0; + nControlType = PropertyControlType::NumericField; break; case PROPERTY_ID_XSD_MAX_INCLUSIVE_INT: @@ -422,8 +419,7 @@ namespace pcr case PROPERTY_ID_XSD_MIN_INCLUSIVE_INT: case PROPERTY_ID_XSD_MIN_EXCLUSIVE_INT: { - _rDescriptor.eControlType = BCT_NUMFIELD; - _rDescriptor.nDigits = 0; + nControlType = PropertyControlType::NumericField; // handle limits for various 'INT' types according to // their actual semantics (year, month, day) @@ -431,13 +427,13 @@ namespace pcr ::rtl::Reference< XSDDataType > xDataType( m_pHelper->getValidatingDataType() ); sal_Int16 nTypeClass = xDataType.is() ? xDataType->classify() : DataTypeClass::STRING; - _rDescriptor.bHaveMinMax = sal_True; - _rDescriptor.nMinValue = DataTypeClass::gYear == nTypeClass ? 0 : 1; - _rDescriptor.nMaxValue = ::std::numeric_limits< sal_Int32 >::max(); + aMinValue.IsPresent = aMaxValue.IsPresent = sal_True; + aMinValue.Value = DataTypeClass::gYear == nTypeClass ? 0 : 1; + aMaxValue.Value = ::std::numeric_limits< sal_Int32 >::max(); if ( DataTypeClass::gMonth == nTypeClass ) - _rDescriptor.nMaxValue = 12; + aMaxValue.Value = 12; else if ( DataTypeClass::gDay == nTypeClass ) - _rDescriptor.nMaxValue = 31; + aMaxValue.Value = 31; } break; @@ -445,7 +441,7 @@ namespace pcr case PROPERTY_ID_XSD_MAX_EXCLUSIVE_DOUBLE: case PROPERTY_ID_XSD_MIN_INCLUSIVE_DOUBLE: case PROPERTY_ID_XSD_MIN_EXCLUSIVE_DOUBLE: - _rDescriptor.eControlType = BCT_NUMFIELD; + nControlType = PropertyControlType::NumericField; // TODO/eForms: do we have "auto-digits"? break; @@ -453,116 +449,100 @@ namespace pcr case PROPERTY_ID_XSD_MAX_EXCLUSIVE_DATE: case PROPERTY_ID_XSD_MIN_INCLUSIVE_DATE: case PROPERTY_ID_XSD_MIN_EXCLUSIVE_DATE: - _rDescriptor.eControlType = BCT_DATEFIELD; + nControlType = PropertyControlType::DateField; break; case PROPERTY_ID_XSD_MAX_INCLUSIVE_TIME: case PROPERTY_ID_XSD_MAX_EXCLUSIVE_TIME: case PROPERTY_ID_XSD_MIN_INCLUSIVE_TIME: case PROPERTY_ID_XSD_MIN_EXCLUSIVE_TIME: - _rDescriptor.eControlType = BCT_TIMEFIELD; + nControlType = PropertyControlType::TimeField; break; case PROPERTY_ID_XSD_MAX_INCLUSIVE_DATE_TIME: case PROPERTY_ID_XSD_MAX_EXCLUSIVE_DATE_TIME: case PROPERTY_ID_XSD_MIN_INCLUSIVE_DATE_TIME: case PROPERTY_ID_XSD_MIN_EXCLUSIVE_DATE_TIME: - _rDescriptor.eControlType = BCT_DATETIME; + nControlType = PropertyControlType::DateTimeField; break; default: - DBG_ERROR( "XSDValidationPropertyHandler::describePropertyUI: cannot handle this property!" ); + DBG_ERROR( "XSDValidationPropertyHandler::describePropertyLine: cannot handle this property!" ); + break; } - } - //-------------------------------------------------------------------- - bool SAL_CALL XSDValidationPropertyHandler::requestUserInputOnButtonClick( PropertyId _nPropId, bool _bPrimary, Any& _rData ) - { - OSL_ENSURE( m_pHelper.get(), "XSDValidationPropertyHandler::requestUserInputOnButtonClick: we don't have any SupportedProperties!" ); - if ( !m_pHelper.get() ) - return false; - - switch ( _nPropId ) + switch ( nControlType ) { - case PROPERTY_ID_XSD_DATA_TYPE: - { - if ( _bPrimary ) - { - ::rtl::OUString sNewDataTypeName; - if ( implPrepareCloneDataCurrentType( sNewDataTypeName ) ) - { - _rData <<= sNewDataTypeName; - return true; - } - } - else - return implPrepareRemoveCurrentDataType(); - } - break; - + case PropertyControlType::ListBox: + _rDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory, aListEntries, sal_False ); + break; + case PropertyControlType::NumericField: + _rDescriptor.Control = PropertyHandlerHelper::createNumericControl( _rxControlFactory, 0, aMinValue, aMaxValue, sal_False ); + break; default: - DBG_ERROR( "XSDValidationPropertyHandler::requestUserInputOnButtonClick: not yet implemented!" ); + _rDescriptor.Control = _rxControlFactory->createPropertyControl( nControlType, sal_False ); + break; } - return false; + + _rDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Data" ) ); + _rDescriptor.DisplayName = m_pInfoService->getPropertyTranslation( nPropId ); + _rDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nPropId ) ); } //-------------------------------------------------------------------- - void SAL_CALL XSDValidationPropertyHandler::executeButtonClick( PropertyId _nPropId, bool _bPrimary, const Any& _rData, IPropertyBrowserUI* _pUpdater ) + InteractiveSelectionResult SAL_CALL XSDValidationPropertyHandler::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, Any& _rData, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException) { - OSL_ENSURE( m_pHelper.get(), "XSDValidationPropertyHandler::executeButtonClick: we don't have any SupportedProperties!" ); + if ( !_rxInspectorUI.is() ) + throw NullPointerException(); + + ::osl::MutexGuard aGuard( m_aMutex ); + OSL_ENSURE( m_pHelper.get(), "XSDValidationPropertyHandler::onInteractivePropertySelection: we don't have any SupportedProperties!" ); if ( !m_pHelper.get() ) - return; + return InteractiveSelectionResult_Cancelled; - switch ( _nPropId ) + PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) ); + + switch ( nPropId ) { case PROPERTY_ID_XSD_DATA_TYPE: { if ( _bPrimary ) { ::rtl::OUString sNewDataTypeName; - OSL_VERIFY( _rData >>= sNewDataTypeName ); - // if this asserts, the data does not result from my requestUserInputOnButtonClick ... - if ( implDoCloneCurrentDataType( sNewDataTypeName ) ) - // the UI for this property needs to be rebuilt, to reflect the new - // type entry - _pUpdater->rebuildPropertyUI( PROPERTY_XSD_DATA_TYPE ); - } - else - { - if ( implDoRemoveCurrentDataType() ) - { // the UI for this property needs to be rebuilt, to reflect the missing - // type entry - _pUpdater->rebuildPropertyUI( PROPERTY_XSD_DATA_TYPE ); + if ( implPrepareCloneDataCurrentType( sNewDataTypeName ) ) + { + implDoCloneCurrentDataType( sNewDataTypeName ); + return InteractiveSelectionResult_Success; } } + else + return implPrepareRemoveCurrentDataType() && implDoRemoveCurrentDataType() ? InteractiveSelectionResult_Success : InteractiveSelectionResult_Cancelled; } break; default: - DBG_ERROR( "XSDValidationPropertyHandler::executeButtonClick: not yet implemented!" ); + DBG_ERROR( "XSDValidationPropertyHandler::onInteractivePropertySelection: unexpected property to build a dedicated UI!" ); + break; } + return InteractiveSelectionResult_Cancelled; } //-------------------------------------------------------------------- - void SAL_CALL XSDValidationPropertyHandler::startAllPropertyChangeListening( const Reference< XPropertyChangeListener >& _rxListener ) + void SAL_CALL XSDValidationPropertyHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException) { - OSL_ENSURE( m_pHelper.get(), "XSDValidationPropertyHandler::startAllPropertyChangeListening: we don't have any SupportedProperties!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + XSDValidationPropertyHandler_Base::addPropertyChangeListener( _rxListener ); if ( m_pHelper.get() ) - { - PropertyHandler::startAllPropertyChangeListening( _rxListener ); m_pHelper->registerBindingListener( _rxListener ); - } } //-------------------------------------------------------------------- - void SAL_CALL XSDValidationPropertyHandler::stopAllPropertyChangeListening( ) + void SAL_CALL XSDValidationPropertyHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException) { - OSL_ENSURE( m_pHelper.get(), "XSDValidationPropertyHandler::startAllPropertyChangeListening: we don't have any SupportedProperties!" ); + ::osl::MutexGuard aGuard( m_aMutex ); if ( m_pHelper.get() ) - { - m_pHelper->revokeBindingListener(); - PropertyHandler::stopAllPropertyChangeListening(); - } + m_pHelper->revokeBindingListener( _rxListener ); + XSDValidationPropertyHandler_Base::removePropertyChangeListener( _rxListener ); } //-------------------------------------------------------------------- @@ -617,7 +597,7 @@ namespace pcr } // confirmation message - String sConfirmation( ModuleRes( RID_STR_CONFIRM_DELETE_DATA_TYPE ) ); + String sConfirmation( PcrRes( RID_STR_CONFIRM_DELETE_DATA_TYPE ) ); sConfirmation.SearchAndReplaceAscii( "#type#", pType->getName() ); QueryBox aQuery( NULL, WB_YES_NO, sConfirmation ); // TODO/eForms: proper parent if ( aQuery.Execute() != RET_YES ) @@ -647,17 +627,69 @@ namespace pcr } //-------------------------------------------------------------------- - void SAL_CALL XSDValidationPropertyHandler::actuatingPropertyChanged( PropertyId _nActuatingPropId, const Any& _rNewValue, const Any& _rOldValue, IPropertyBrowserUI* _pUpdater, bool _bFirstTimeInit ) + void SAL_CALL XSDValidationPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& _rOldValue, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (NullPointerException, RuntimeException) { - OSL_ENSURE( m_pHelper.get(), "XSDValidationPropertyHandler::actuatingPropertyChanged: we don't have any ActuatingProperties!" ); + if ( !_rxInspectorUI.is() ) + throw NullPointerException(); + + ::osl::MutexGuard aGuard( m_aMutex ); + PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) ); if ( !m_pHelper.get() ) - return; + throw RuntimeException(); + // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties - switch ( _nActuatingPropId ) + switch ( nActuatingPropId ) { case PROPERTY_ID_XSD_DATA_TYPE: - initializePropertyUI( PROPERTY_ID_XSD_DATA_TYPE, _pUpdater ); - break; + { + ::rtl::Reference< XSDDataType > xDataType( m_pHelper->getValidatingDataType() ); + sal_Int16 nTypeClass = xDataType.is() ? xDataType->classify() : DataTypeClass::STRING; + + // is removal of this type possible? + sal_Bool bIsBasicType = xDataType.is() && xDataType->isBasicType(); + _rxInspectorUI->enablePropertyUIElements( PROPERTY_XSD_DATA_TYPE, PropertyLineElement::PrimaryButton, xDataType.is() ); + _rxInspectorUI->enablePropertyUIElements( PROPERTY_XSD_DATA_TYPE, PropertyLineElement::SecondaryButton, xDataType.is() && !bIsBasicType ); + + //------------------------------------------------------------ + // show the facets which are available at the data type + ::rtl::OUString aFacets[] = { + PROPERTY_XSD_WHITESPACES, PROPERTY_XSD_PATTERN, + PROPERTY_XSD_LENGTH, PROPERTY_XSD_MIN_LENGTH, PROPERTY_XSD_MAX_LENGTH, PROPERTY_XSD_TOTAL_DIGITS, + PROPERTY_XSD_FRACTION_DIGITS, + PROPERTY_XSD_MAX_INCLUSIVE_INT, + PROPERTY_XSD_MAX_EXCLUSIVE_INT, + PROPERTY_XSD_MIN_INCLUSIVE_INT, + PROPERTY_XSD_MIN_EXCLUSIVE_INT, + PROPERTY_XSD_MAX_INCLUSIVE_DOUBLE, + PROPERTY_XSD_MAX_EXCLUSIVE_DOUBLE, + PROPERTY_XSD_MIN_INCLUSIVE_DOUBLE, + PROPERTY_XSD_MIN_EXCLUSIVE_DOUBLE, + PROPERTY_XSD_MAX_INCLUSIVE_DATE, + PROPERTY_XSD_MAX_EXCLUSIVE_DATE, + PROPERTY_XSD_MIN_INCLUSIVE_DATE, + PROPERTY_XSD_MIN_EXCLUSIVE_DATE, + PROPERTY_XSD_MAX_INCLUSIVE_TIME, + PROPERTY_XSD_MAX_EXCLUSIVE_TIME, + PROPERTY_XSD_MIN_INCLUSIVE_TIME, + PROPERTY_XSD_MIN_EXCLUSIVE_TIME, + PROPERTY_XSD_MAX_INCLUSIVE_DATE_TIME, + PROPERTY_XSD_MAX_EXCLUSIVE_DATE_TIME, + PROPERTY_XSD_MIN_INCLUSIVE_DATE_TIME, + PROPERTY_XSD_MIN_EXCLUSIVE_DATE_TIME + }; + + sal_Int32 i=0; + const ::rtl::OUString* pLoop = NULL; + for ( i = 0, pLoop = aFacets; + i < sizeof( aFacets ) / sizeof( aFacets[0] ); + ++i, ++pLoop + ) + { + showPropertyUI( _rxInspectorUI, *pLoop, xDataType.is() && xDataType->hasFacet( *pLoop ) ); + _rxInspectorUI->enablePropertyUI( *pLoop, !bIsBasicType ); + } + } + break; case PROPERTY_ID_XML_DATA_MODEL: { @@ -669,7 +701,8 @@ namespace pcr m_pHelper->copyDataType( sOldModelName, sNewModelName, sDataType ); // the list of available data types depends on the chosen model, so update this - _pUpdater->rebuildPropertyUI( PROPERTY_XSD_DATA_TYPE ); + if ( !_bFirstTimeInit ) + _rxInspectorUI->rebuildPropertyUI( PROPERTY_XSD_DATA_TYPE ); } break; |