xref: /AOO41X/main/extensions/source/propctrlr/xsdvalidationpropertyhandler.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 "xsdvalidationpropertyhandler.hxx"
31*cdf0e10cSrcweir #include "formstrings.hxx"
32*cdf0e10cSrcweir #include "formmetadata.hxx"
33*cdf0e10cSrcweir #include "xsddatatypes.hxx"
34*cdf0e10cSrcweir #include "modulepcr.hxx"
35*cdf0e10cSrcweir #include "formresid.hrc"
36*cdf0e10cSrcweir #include "formlocalid.hrc"
37*cdf0e10cSrcweir #include "propctrlr.hrc"
38*cdf0e10cSrcweir #include "newdatatype.hxx"
39*cdf0e10cSrcweir #include "xsdvalidationhelper.hxx"
40*cdf0e10cSrcweir #include "pcrcommon.hxx"
41*cdf0e10cSrcweir #include "handlerhelper.hxx"
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir /** === begin UNO includes === **/
44*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/xsd/WhiteSpaceTreatment.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/xsd/DataTypeClass.hpp>
47*cdf0e10cSrcweir #include <com/sun/star/inspection/PropertyControlType.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/beans/Optional.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/inspection/XObjectInspectorUI.hpp>
50*cdf0e10cSrcweir #include <com/sun/star/inspection/PropertyLineElement.hpp>
51*cdf0e10cSrcweir /** === end UNO includes === **/
52*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
53*cdf0e10cSrcweir #include <tools/debug.hxx>
54*cdf0e10cSrcweir #include <svtools/localresaccess.hxx>
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir #include <algorithm>
57*cdf0e10cSrcweir #include <functional>
58*cdf0e10cSrcweir #include <limits>
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir //------------------------------------------------------------------------
61*cdf0e10cSrcweir extern "C" void SAL_CALL createRegistryInfo_XSDValidationPropertyHandler()
62*cdf0e10cSrcweir {
63*cdf0e10cSrcweir     ::pcr::XSDValidationPropertyHandler::registerImplementation();
64*cdf0e10cSrcweir }
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir //........................................................................
67*cdf0e10cSrcweir namespace pcr
68*cdf0e10cSrcweir {
69*cdf0e10cSrcweir //........................................................................
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir     using namespace ::com::sun::star;
72*cdf0e10cSrcweir     using namespace ::com::sun::star::uno;
73*cdf0e10cSrcweir     using namespace ::com::sun::star::lang;
74*cdf0e10cSrcweir     using namespace ::com::sun::star::beans;
75*cdf0e10cSrcweir     using namespace ::com::sun::star::xforms;
76*cdf0e10cSrcweir     using namespace ::com::sun::star::xsd;
77*cdf0e10cSrcweir     using namespace ::com::sun::star::script;
78*cdf0e10cSrcweir     using namespace ::com::sun::star::inspection;
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir     using ::com::sun::star::beans::PropertyAttribute::MAYBEVOID;
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir     //====================================================================
83*cdf0e10cSrcweir 	//= XSDValidationPropertyHandler
84*cdf0e10cSrcweir 	//====================================================================
85*cdf0e10cSrcweir     DBG_NAME( XSDValidationPropertyHandler )
86*cdf0e10cSrcweir 	//--------------------------------------------------------------------
87*cdf0e10cSrcweir     XSDValidationPropertyHandler::XSDValidationPropertyHandler( const Reference< XComponentContext >& _rxContext )
88*cdf0e10cSrcweir         :XSDValidationPropertyHandler_Base( _rxContext )
89*cdf0e10cSrcweir     {
90*cdf0e10cSrcweir         DBG_CTOR( XSDValidationPropertyHandler, NULL );
91*cdf0e10cSrcweir     }
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir 	//--------------------------------------------------------------------
94*cdf0e10cSrcweir     XSDValidationPropertyHandler::~XSDValidationPropertyHandler()
95*cdf0e10cSrcweir     {
96*cdf0e10cSrcweir         DBG_DTOR( XSDValidationPropertyHandler, NULL );
97*cdf0e10cSrcweir     }
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir     //--------------------------------------------------------------------
100*cdf0e10cSrcweir     ::rtl::OUString SAL_CALL XSDValidationPropertyHandler::getImplementationName_static(  ) throw (RuntimeException)
101*cdf0e10cSrcweir     {
102*cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.XSDValidationPropertyHandler" ) );
103*cdf0e10cSrcweir     }
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir     //--------------------------------------------------------------------
106*cdf0e10cSrcweir     Sequence< ::rtl::OUString > SAL_CALL XSDValidationPropertyHandler::getSupportedServiceNames_static(  ) throw (RuntimeException)
107*cdf0e10cSrcweir     {
108*cdf0e10cSrcweir         Sequence< ::rtl::OUString > aSupported( 1 );
109*cdf0e10cSrcweir         aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.XSDValidationPropertyHandler" ) );
110*cdf0e10cSrcweir         return aSupported;
111*cdf0e10cSrcweir     }
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir     //--------------------------------------------------------------------
114*cdf0e10cSrcweir     Any SAL_CALL XSDValidationPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
115*cdf0e10cSrcweir     {
116*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
117*cdf0e10cSrcweir         PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir         OSL_ENSURE( m_pHelper.get(), "XSDValidationPropertyHandler::getPropertyValue: inconsistency!" );
120*cdf0e10cSrcweir             // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir         Any aReturn;
123*cdf0e10cSrcweir         ::rtl::Reference< XSDDataType > pType = m_pHelper->getValidatingDataType();
124*cdf0e10cSrcweir         switch ( nPropId )
125*cdf0e10cSrcweir         {
126*cdf0e10cSrcweir         // common facets
127*cdf0e10cSrcweir         case PROPERTY_ID_XSD_DATA_TYPE:  aReturn = pType.is() ? pType->getFacet( PROPERTY_NAME ) : makeAny( ::rtl::OUString() ); break;
128*cdf0e10cSrcweir         case PROPERTY_ID_XSD_WHITESPACES:aReturn = pType.is() ? pType->getFacet( PROPERTY_XSD_WHITESPACES ) : makeAny( WhiteSpaceTreatment::Preserve ); break;
129*cdf0e10cSrcweir         case PROPERTY_ID_XSD_PATTERN:    aReturn = pType.is() ? pType->getFacet( PROPERTY_XSD_PATTERN ) : makeAny( ::rtl::OUString() ); break;
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir         // all other properties are simply forwarded, if they exist at the given type
132*cdf0e10cSrcweir         default:
133*cdf0e10cSrcweir         {
134*cdf0e10cSrcweir             if ( pType.is() && pType->hasFacet( _rPropertyName ) )
135*cdf0e10cSrcweir                 aReturn = pType->getFacet( _rPropertyName );
136*cdf0e10cSrcweir         }
137*cdf0e10cSrcweir         break;
138*cdf0e10cSrcweir         }
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir         return aReturn;
141*cdf0e10cSrcweir     }
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir     //--------------------------------------------------------------------
144*cdf0e10cSrcweir     void SAL_CALL XSDValidationPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
145*cdf0e10cSrcweir     {
146*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
147*cdf0e10cSrcweir         PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir         OSL_ENSURE( m_pHelper.get(), "XSDValidationPropertyHandler::getPropertyValue: inconsistency!" );
150*cdf0e10cSrcweir             // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir         if ( PROPERTY_ID_XSD_DATA_TYPE == nPropId )
153*cdf0e10cSrcweir         {
154*cdf0e10cSrcweir             ::rtl::OUString sTypeName;
155*cdf0e10cSrcweir             OSL_VERIFY( _rValue >>= sTypeName );
156*cdf0e10cSrcweir             m_pHelper->setValidatingDataTypeByName( sTypeName );
157*cdf0e10cSrcweir             impl_setContextDocumentModified_nothrow();
158*cdf0e10cSrcweir             return;
159*cdf0e10cSrcweir         }
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir         ::rtl::Reference< XSDDataType > pType = m_pHelper->getValidatingDataType();
162*cdf0e10cSrcweir         if ( !pType.is() )
163*cdf0e10cSrcweir         {
164*cdf0e10cSrcweir             DBG_ERROR( "XSDValidationPropertyHandler::setPropertyValue: you're trying to set a type facet, without a current type!" );
165*cdf0e10cSrcweir             return;
166*cdf0e10cSrcweir         }
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir         pType->setFacet( _rPropertyName, _rValue );
169*cdf0e10cSrcweir         impl_setContextDocumentModified_nothrow();
170*cdf0e10cSrcweir     }
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir     //--------------------------------------------------------------------
173*cdf0e10cSrcweir     void XSDValidationPropertyHandler::onNewComponent()
174*cdf0e10cSrcweir     {
175*cdf0e10cSrcweir         XSDValidationPropertyHandler_Base::onNewComponent();
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir         Reference< frame::XModel > xDocument( impl_getContextDocument_nothrow() );
178*cdf0e10cSrcweir         DBG_ASSERT( xDocument.is(), "XSDValidationPropertyHandler::onNewComponent: no document!" );
179*cdf0e10cSrcweir         if ( EFormsHelper::isEForm( xDocument ) )
180*cdf0e10cSrcweir             m_pHelper.reset( new XSDValidationHelper( m_aMutex, m_xComponent, xDocument ) );
181*cdf0e10cSrcweir         else
182*cdf0e10cSrcweir             m_pHelper.reset( NULL );
183*cdf0e10cSrcweir     }
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir     //--------------------------------------------------------------------
186*cdf0e10cSrcweir     Sequence< Property > XSDValidationPropertyHandler::doDescribeSupportedProperties() const
187*cdf0e10cSrcweir     {
188*cdf0e10cSrcweir         ::std::vector< Property > aProperties;
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir         if ( m_pHelper.get() )
191*cdf0e10cSrcweir         {
192*cdf0e10cSrcweir             bool bAllowBinding = m_pHelper->canBindToAnyDataType();
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir             if ( bAllowBinding )
195*cdf0e10cSrcweir             {
196*cdf0e10cSrcweir                 aProperties.reserve( 12 );
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir                 addStringPropertyDescription( aProperties, PROPERTY_XSD_DATA_TYPE   );
199*cdf0e10cSrcweir                 addInt16PropertyDescription ( aProperties, PROPERTY_XSD_WHITESPACES );
200*cdf0e10cSrcweir                 addStringPropertyDescription( aProperties, PROPERTY_XSD_PATTERN     );
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir                 // string facets
203*cdf0e10cSrcweir                 addInt32PropertyDescription( aProperties, PROPERTY_XSD_LENGTH,          MAYBEVOID );
204*cdf0e10cSrcweir                 addInt32PropertyDescription( aProperties, PROPERTY_XSD_MIN_LENGTH,      MAYBEVOID );
205*cdf0e10cSrcweir                 addInt32PropertyDescription( aProperties, PROPERTY_XSD_MAX_LENGTH,      MAYBEVOID );
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir                 // decimal facets
208*cdf0e10cSrcweir                 addInt32PropertyDescription( aProperties, PROPERTY_XSD_TOTAL_DIGITS,    MAYBEVOID );
209*cdf0e10cSrcweir                 addInt32PropertyDescription( aProperties, PROPERTY_XSD_FRACTION_DIGITS, MAYBEVOID );
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir                 // facets for different types
212*cdf0e10cSrcweir                 addInt16PropertyDescription( aProperties, PROPERTY_XSD_MAX_INCLUSIVE_INT, MAYBEVOID );
213*cdf0e10cSrcweir                 addInt16PropertyDescription( aProperties, PROPERTY_XSD_MAX_EXCLUSIVE_INT, MAYBEVOID );
214*cdf0e10cSrcweir                 addInt16PropertyDescription( aProperties, PROPERTY_XSD_MIN_INCLUSIVE_INT, MAYBEVOID );
215*cdf0e10cSrcweir                 addInt16PropertyDescription( aProperties, PROPERTY_XSD_MIN_EXCLUSIVE_INT, MAYBEVOID );
216*cdf0e10cSrcweir                 addDoublePropertyDescription( aProperties, PROPERTY_XSD_MAX_INCLUSIVE_DOUBLE, MAYBEVOID );
217*cdf0e10cSrcweir                 addDoublePropertyDescription( aProperties, PROPERTY_XSD_MAX_EXCLUSIVE_DOUBLE, MAYBEVOID );
218*cdf0e10cSrcweir                 addDoublePropertyDescription( aProperties, PROPERTY_XSD_MIN_INCLUSIVE_DOUBLE, MAYBEVOID );
219*cdf0e10cSrcweir                 addDoublePropertyDescription( aProperties, PROPERTY_XSD_MIN_EXCLUSIVE_DOUBLE, MAYBEVOID );
220*cdf0e10cSrcweir                 addDatePropertyDescription( aProperties, PROPERTY_XSD_MAX_INCLUSIVE_DATE, MAYBEVOID );
221*cdf0e10cSrcweir                 addDatePropertyDescription( aProperties, PROPERTY_XSD_MAX_EXCLUSIVE_DATE, MAYBEVOID );
222*cdf0e10cSrcweir                 addDatePropertyDescription( aProperties, PROPERTY_XSD_MIN_INCLUSIVE_DATE, MAYBEVOID );
223*cdf0e10cSrcweir                 addDatePropertyDescription( aProperties, PROPERTY_XSD_MIN_EXCLUSIVE_DATE, MAYBEVOID );
224*cdf0e10cSrcweir                 addTimePropertyDescription( aProperties, PROPERTY_XSD_MAX_INCLUSIVE_TIME, MAYBEVOID );
225*cdf0e10cSrcweir                 addTimePropertyDescription( aProperties, PROPERTY_XSD_MAX_EXCLUSIVE_TIME, MAYBEVOID );
226*cdf0e10cSrcweir                 addTimePropertyDescription( aProperties, PROPERTY_XSD_MIN_INCLUSIVE_TIME, MAYBEVOID );
227*cdf0e10cSrcweir                 addTimePropertyDescription( aProperties, PROPERTY_XSD_MIN_EXCLUSIVE_TIME, MAYBEVOID );
228*cdf0e10cSrcweir                 addDateTimePropertyDescription( aProperties, PROPERTY_XSD_MAX_INCLUSIVE_DATE_TIME, MAYBEVOID );
229*cdf0e10cSrcweir                 addDateTimePropertyDescription( aProperties, PROPERTY_XSD_MAX_EXCLUSIVE_DATE_TIME, MAYBEVOID );
230*cdf0e10cSrcweir                 addDateTimePropertyDescription( aProperties, PROPERTY_XSD_MIN_INCLUSIVE_DATE_TIME, MAYBEVOID );
231*cdf0e10cSrcweir                 addDateTimePropertyDescription( aProperties, PROPERTY_XSD_MIN_EXCLUSIVE_DATE_TIME, MAYBEVOID );
232*cdf0e10cSrcweir             }
233*cdf0e10cSrcweir         }
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir         if ( aProperties.empty() )
236*cdf0e10cSrcweir             return Sequence< Property >();
237*cdf0e10cSrcweir         return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
238*cdf0e10cSrcweir     }
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir     //--------------------------------------------------------------------
241*cdf0e10cSrcweir     Sequence< ::rtl::OUString > SAL_CALL XSDValidationPropertyHandler::getSupersededProperties( ) throw (RuntimeException)
242*cdf0e10cSrcweir     {
243*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir         ::std::vector< ::rtl::OUString > aSuperfluous;
246*cdf0e10cSrcweir         if ( m_pHelper.get() )
247*cdf0e10cSrcweir         {
248*cdf0e10cSrcweir             aSuperfluous.push_back( PROPERTY_CONTROLSOURCE );
249*cdf0e10cSrcweir             aSuperfluous.push_back( PROPERTY_EMPTY_IS_NULL );
250*cdf0e10cSrcweir             aSuperfluous.push_back( PROPERTY_FILTERPROPOSAL );
251*cdf0e10cSrcweir             aSuperfluous.push_back( PROPERTY_LISTSOURCETYPE );
252*cdf0e10cSrcweir             aSuperfluous.push_back( PROPERTY_LISTSOURCE );
253*cdf0e10cSrcweir             aSuperfluous.push_back( PROPERTY_BOUNDCOLUMN );
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir             bool bAllowBinding = m_pHelper->canBindToAnyDataType();
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir             if ( bAllowBinding )
258*cdf0e10cSrcweir             {
259*cdf0e10cSrcweir                 aSuperfluous.push_back( PROPERTY_MAXTEXTLEN );
260*cdf0e10cSrcweir                 aSuperfluous.push_back( PROPERTY_VALUEMIN );
261*cdf0e10cSrcweir                 aSuperfluous.push_back( PROPERTY_VALUEMAX );
262*cdf0e10cSrcweir                 aSuperfluous.push_back( PROPERTY_DECIMAL_ACCURACY );
263*cdf0e10cSrcweir                 aSuperfluous.push_back( PROPERTY_TIMEMIN );
264*cdf0e10cSrcweir                 aSuperfluous.push_back( PROPERTY_TIMEMAX );
265*cdf0e10cSrcweir                 aSuperfluous.push_back( PROPERTY_DATEMIN );
266*cdf0e10cSrcweir                 aSuperfluous.push_back( PROPERTY_DATEMAX );
267*cdf0e10cSrcweir                 aSuperfluous.push_back( PROPERTY_EFFECTIVE_MIN );
268*cdf0e10cSrcweir                 aSuperfluous.push_back( PROPERTY_EFFECTIVE_MAX );
269*cdf0e10cSrcweir             }
270*cdf0e10cSrcweir         }
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir         if ( aSuperfluous.empty() )
273*cdf0e10cSrcweir             return Sequence< ::rtl::OUString >();
274*cdf0e10cSrcweir         return Sequence< ::rtl::OUString >( &(*aSuperfluous.begin()), aSuperfluous.size() );
275*cdf0e10cSrcweir     }
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir     //--------------------------------------------------------------------
278*cdf0e10cSrcweir     Sequence< ::rtl::OUString > SAL_CALL XSDValidationPropertyHandler::getActuatingProperties( ) throw (RuntimeException)
279*cdf0e10cSrcweir     {
280*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
281*cdf0e10cSrcweir         ::std::vector< ::rtl::OUString > aInterestedInActuations( 2 );
282*cdf0e10cSrcweir         if ( m_pHelper.get() )
283*cdf0e10cSrcweir         {
284*cdf0e10cSrcweir             aInterestedInActuations.push_back( PROPERTY_XSD_DATA_TYPE );
285*cdf0e10cSrcweir             aInterestedInActuations.push_back( PROPERTY_XML_DATA_MODEL );
286*cdf0e10cSrcweir         }
287*cdf0e10cSrcweir         if ( aInterestedInActuations.empty() )
288*cdf0e10cSrcweir             return Sequence< ::rtl::OUString >();
289*cdf0e10cSrcweir         return Sequence< ::rtl::OUString >( &(*aInterestedInActuations.begin()), aInterestedInActuations.size() );
290*cdf0e10cSrcweir     }
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir     //--------------------------------------------------------------------
293*cdf0e10cSrcweir     namespace
294*cdf0e10cSrcweir     {
295*cdf0e10cSrcweir         void showPropertyUI( const Reference< XObjectInspectorUI >& _rxInspectorUI, const ::rtl::OUString& _rPropertyName, bool _bShow )
296*cdf0e10cSrcweir         {
297*cdf0e10cSrcweir             if ( _bShow )
298*cdf0e10cSrcweir                 _rxInspectorUI->showPropertyUI( _rPropertyName );
299*cdf0e10cSrcweir             else
300*cdf0e10cSrcweir                 _rxInspectorUI->hidePropertyUI( _rPropertyName );
301*cdf0e10cSrcweir         }
302*cdf0e10cSrcweir     }
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir     //--------------------------------------------------------------------
305*cdf0e10cSrcweir     LineDescriptor SAL_CALL XSDValidationPropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
306*cdf0e10cSrcweir         const Reference< XPropertyControlFactory >& _rxControlFactory )
307*cdf0e10cSrcweir         throw (UnknownPropertyException, NullPointerException, RuntimeException)
308*cdf0e10cSrcweir     {
309*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
310*cdf0e10cSrcweir         if ( !_rxControlFactory.is() )
311*cdf0e10cSrcweir             throw NullPointerException();
312*cdf0e10cSrcweir         if ( !m_pHelper.get() )
313*cdf0e10cSrcweir             throw RuntimeException();
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir         PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir         LineDescriptor aDescriptor;
318*cdf0e10cSrcweir         if ( nPropId != PROPERTY_ID_XSD_DATA_TYPE )
319*cdf0e10cSrcweir             aDescriptor.IndentLevel = 1;
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir         // collect some information about the to-be-created control
322*cdf0e10cSrcweir         sal_Int16 nControlType = PropertyControlType::TextField;
323*cdf0e10cSrcweir         ::std::vector< ::rtl::OUString > aListEntries;
324*cdf0e10cSrcweir         Optional< double > aMinValue( sal_False, 0 );
325*cdf0e10cSrcweir         Optional< double > aMaxValue( sal_False, 0 );
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir         switch ( nPropId )
328*cdf0e10cSrcweir         {
329*cdf0e10cSrcweir         case PROPERTY_ID_XSD_DATA_TYPE:
330*cdf0e10cSrcweir             nControlType = PropertyControlType::ListBox;
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir             implGetAvailableDataTypeNames( aListEntries );
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir             aDescriptor.PrimaryButtonId = rtl::OUString::createFromAscii(UID_PROP_ADD_DATA_TYPE);
335*cdf0e10cSrcweir             aDescriptor.SecondaryButtonId = rtl::OUString::createFromAscii(UID_PROP_REMOVE_DATA_TYPE);;
336*cdf0e10cSrcweir             aDescriptor.HasPrimaryButton = aDescriptor.HasSecondaryButton = sal_True;
337*cdf0e10cSrcweir             aDescriptor.PrimaryButtonImageURL = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/extensions/res/buttonplus.png" ) );
338*cdf0e10cSrcweir             aDescriptor.SecondaryButtonImageURL = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/extensions/res/buttonminus.png" ) );
339*cdf0e10cSrcweir             break;
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir         case PROPERTY_ID_XSD_WHITESPACES:
342*cdf0e10cSrcweir         {
343*cdf0e10cSrcweir             nControlType = PropertyControlType::ListBox;
344*cdf0e10cSrcweir             aListEntries = m_pInfoService->getPropertyEnumRepresentations( PROPERTY_ID_XSD_WHITESPACES );
345*cdf0e10cSrcweir         }
346*cdf0e10cSrcweir         break;
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir         case PROPERTY_ID_XSD_PATTERN:
349*cdf0e10cSrcweir             nControlType = PropertyControlType::TextField;
350*cdf0e10cSrcweir             break;
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir         case PROPERTY_ID_XSD_LENGTH:
353*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MIN_LENGTH:
354*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MAX_LENGTH:
355*cdf0e10cSrcweir             nControlType = PropertyControlType::NumericField;
356*cdf0e10cSrcweir             break;
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir         case PROPERTY_ID_XSD_TOTAL_DIGITS:
359*cdf0e10cSrcweir         case PROPERTY_ID_XSD_FRACTION_DIGITS:
360*cdf0e10cSrcweir             nControlType = PropertyControlType::NumericField;
361*cdf0e10cSrcweir             break;
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MAX_INCLUSIVE_INT:
364*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MAX_EXCLUSIVE_INT:
365*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MIN_INCLUSIVE_INT:
366*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MIN_EXCLUSIVE_INT:
367*cdf0e10cSrcweir         {
368*cdf0e10cSrcweir             nControlType = PropertyControlType::NumericField;
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir             // handle limits for various 'INT' types according to
371*cdf0e10cSrcweir             // their actual semantics (year, month, day)
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir             ::rtl::Reference< XSDDataType > xDataType( m_pHelper->getValidatingDataType() );
374*cdf0e10cSrcweir             sal_Int16 nTypeClass = xDataType.is() ? xDataType->classify() : DataTypeClass::STRING;
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir             aMinValue.IsPresent = aMaxValue.IsPresent = sal_True;
377*cdf0e10cSrcweir             aMinValue.Value = DataTypeClass::gYear == nTypeClass ? 0 : 1;
378*cdf0e10cSrcweir             aMaxValue.Value = ::std::numeric_limits< sal_Int32 >::max();
379*cdf0e10cSrcweir             if ( DataTypeClass::gMonth == nTypeClass )
380*cdf0e10cSrcweir                 aMaxValue.Value = 12;
381*cdf0e10cSrcweir             else if ( DataTypeClass::gDay == nTypeClass )
382*cdf0e10cSrcweir                 aMaxValue.Value = 31;
383*cdf0e10cSrcweir         }
384*cdf0e10cSrcweir         break;
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MAX_INCLUSIVE_DOUBLE:
387*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MAX_EXCLUSIVE_DOUBLE:
388*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MIN_INCLUSIVE_DOUBLE:
389*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MIN_EXCLUSIVE_DOUBLE:
390*cdf0e10cSrcweir             nControlType = PropertyControlType::NumericField;
391*cdf0e10cSrcweir             // TODO/eForms: do we have "auto-digits"?
392*cdf0e10cSrcweir             break;
393*cdf0e10cSrcweir 
394*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MAX_INCLUSIVE_DATE:
395*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MAX_EXCLUSIVE_DATE:
396*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MIN_INCLUSIVE_DATE:
397*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MIN_EXCLUSIVE_DATE:
398*cdf0e10cSrcweir             nControlType = PropertyControlType::DateField;
399*cdf0e10cSrcweir             break;
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MAX_INCLUSIVE_TIME:
402*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MAX_EXCLUSIVE_TIME:
403*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MIN_INCLUSIVE_TIME:
404*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MIN_EXCLUSIVE_TIME:
405*cdf0e10cSrcweir             nControlType = PropertyControlType::TimeField;
406*cdf0e10cSrcweir             break;
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MAX_INCLUSIVE_DATE_TIME:
409*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MAX_EXCLUSIVE_DATE_TIME:
410*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MIN_INCLUSIVE_DATE_TIME:
411*cdf0e10cSrcweir         case PROPERTY_ID_XSD_MIN_EXCLUSIVE_DATE_TIME:
412*cdf0e10cSrcweir             nControlType = PropertyControlType::DateTimeField;
413*cdf0e10cSrcweir             break;
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir         default:
416*cdf0e10cSrcweir             DBG_ERROR( "XSDValidationPropertyHandler::describePropertyLine: cannot handle this property!" );
417*cdf0e10cSrcweir             break;
418*cdf0e10cSrcweir         }
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir         switch ( nControlType )
421*cdf0e10cSrcweir         {
422*cdf0e10cSrcweir         case PropertyControlType::ListBox:
423*cdf0e10cSrcweir             aDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory, aListEntries, sal_False, sal_False );
424*cdf0e10cSrcweir             break;
425*cdf0e10cSrcweir         case PropertyControlType::NumericField:
426*cdf0e10cSrcweir             aDescriptor.Control = PropertyHandlerHelper::createNumericControl( _rxControlFactory, 0, aMinValue, aMaxValue, sal_False );
427*cdf0e10cSrcweir             break;
428*cdf0e10cSrcweir         default:
429*cdf0e10cSrcweir             aDescriptor.Control = _rxControlFactory->createPropertyControl( nControlType, sal_False );
430*cdf0e10cSrcweir             break;
431*cdf0e10cSrcweir         }
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir         aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Data" ) );
434*cdf0e10cSrcweir         aDescriptor.DisplayName = m_pInfoService->getPropertyTranslation( nPropId );
435*cdf0e10cSrcweir         aDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nPropId ) );
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir         return aDescriptor;
438*cdf0e10cSrcweir     }
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir     //--------------------------------------------------------------------
441*cdf0e10cSrcweir     InteractiveSelectionResult SAL_CALL XSDValidationPropertyHandler::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, Any& /*_rData*/, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
442*cdf0e10cSrcweir     {
443*cdf0e10cSrcweir         if ( !_rxInspectorUI.is() )
444*cdf0e10cSrcweir             throw NullPointerException();
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
447*cdf0e10cSrcweir         OSL_ENSURE( m_pHelper.get(), "XSDValidationPropertyHandler::onInteractivePropertySelection: we don't have any SupportedProperties!" );
448*cdf0e10cSrcweir         if ( !m_pHelper.get() )
449*cdf0e10cSrcweir             return InteractiveSelectionResult_Cancelled;
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir         PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir         switch ( nPropId )
454*cdf0e10cSrcweir         {
455*cdf0e10cSrcweir         case PROPERTY_ID_XSD_DATA_TYPE:
456*cdf0e10cSrcweir         {
457*cdf0e10cSrcweir             if ( _bPrimary )
458*cdf0e10cSrcweir             {
459*cdf0e10cSrcweir                 ::rtl::OUString sNewDataTypeName;
460*cdf0e10cSrcweir                 if ( implPrepareCloneDataCurrentType( sNewDataTypeName ) )
461*cdf0e10cSrcweir                 {
462*cdf0e10cSrcweir                     implDoCloneCurrentDataType( sNewDataTypeName );
463*cdf0e10cSrcweir                     return InteractiveSelectionResult_Success;
464*cdf0e10cSrcweir                 }
465*cdf0e10cSrcweir             }
466*cdf0e10cSrcweir             else
467*cdf0e10cSrcweir                 return implPrepareRemoveCurrentDataType() && implDoRemoveCurrentDataType() ? InteractiveSelectionResult_Success : InteractiveSelectionResult_Cancelled;
468*cdf0e10cSrcweir         }
469*cdf0e10cSrcweir         break;
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir         default:
472*cdf0e10cSrcweir             DBG_ERROR( "XSDValidationPropertyHandler::onInteractivePropertySelection: unexpected property to build a dedicated UI!" );
473*cdf0e10cSrcweir             break;
474*cdf0e10cSrcweir         }
475*cdf0e10cSrcweir         return InteractiveSelectionResult_Cancelled;
476*cdf0e10cSrcweir     }
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir     //--------------------------------------------------------------------
479*cdf0e10cSrcweir     void SAL_CALL XSDValidationPropertyHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
480*cdf0e10cSrcweir     {
481*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
482*cdf0e10cSrcweir         XSDValidationPropertyHandler_Base::addPropertyChangeListener( _rxListener );
483*cdf0e10cSrcweir         if ( m_pHelper.get() )
484*cdf0e10cSrcweir             m_pHelper->registerBindingListener( _rxListener );
485*cdf0e10cSrcweir     }
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir     //--------------------------------------------------------------------
488*cdf0e10cSrcweir     void SAL_CALL XSDValidationPropertyHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
489*cdf0e10cSrcweir     {
490*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
491*cdf0e10cSrcweir         if ( m_pHelper.get() )
492*cdf0e10cSrcweir             m_pHelper->revokeBindingListener( _rxListener );
493*cdf0e10cSrcweir         XSDValidationPropertyHandler_Base::removePropertyChangeListener( _rxListener );
494*cdf0e10cSrcweir     }
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir     //--------------------------------------------------------------------
497*cdf0e10cSrcweir     bool XSDValidationPropertyHandler::implPrepareCloneDataCurrentType( ::rtl::OUString& _rNewName ) SAL_THROW(())
498*cdf0e10cSrcweir     {
499*cdf0e10cSrcweir         OSL_PRECOND( m_pHelper.get(), "XSDValidationPropertyHandler::implPrepareCloneDataCurrentType: this will crash!" );
500*cdf0e10cSrcweir 
501*cdf0e10cSrcweir         ::rtl::Reference< XSDDataType > pType = m_pHelper->getValidatingDataType();
502*cdf0e10cSrcweir         if ( !pType.is() )
503*cdf0e10cSrcweir         {
504*cdf0e10cSrcweir             DBG_ERROR( "XSDValidationPropertyHandler::implPrepareCloneDataCurrentType: invalid current data type!" );
505*cdf0e10cSrcweir             return false;
506*cdf0e10cSrcweir         }
507*cdf0e10cSrcweir 
508*cdf0e10cSrcweir         ::std::vector< ::rtl::OUString > aExistentNames;
509*cdf0e10cSrcweir         m_pHelper->getAvailableDataTypeNames( aExistentNames );
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir         NewDataTypeDialog aDialog( NULL, pType->getName(), aExistentNames );  // TODO/eForms: proper parent
512*cdf0e10cSrcweir         if ( aDialog.Execute() != RET_OK )
513*cdf0e10cSrcweir             return false;
514*cdf0e10cSrcweir 
515*cdf0e10cSrcweir         _rNewName = aDialog.GetName();
516*cdf0e10cSrcweir         return true;
517*cdf0e10cSrcweir     }
518*cdf0e10cSrcweir 
519*cdf0e10cSrcweir     //--------------------------------------------------------------------
520*cdf0e10cSrcweir     bool XSDValidationPropertyHandler::implDoCloneCurrentDataType( const ::rtl::OUString& _rNewName ) SAL_THROW(())
521*cdf0e10cSrcweir     {
522*cdf0e10cSrcweir         OSL_PRECOND( m_pHelper.get(), "XSDValidationPropertyHandler::implDoCloneCurrentDataType: this will crash!" );
523*cdf0e10cSrcweir 
524*cdf0e10cSrcweir         ::rtl::Reference< XSDDataType > pType = m_pHelper->getValidatingDataType();
525*cdf0e10cSrcweir         if ( !pType.is() )
526*cdf0e10cSrcweir             return false;
527*cdf0e10cSrcweir 
528*cdf0e10cSrcweir         if ( !m_pHelper->cloneDataType( pType, _rNewName ) )
529*cdf0e10cSrcweir             return false;
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir         m_pHelper->setValidatingDataTypeByName( _rNewName );
532*cdf0e10cSrcweir         return true;
533*cdf0e10cSrcweir     }
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir     //--------------------------------------------------------------------
536*cdf0e10cSrcweir     bool XSDValidationPropertyHandler::implPrepareRemoveCurrentDataType() SAL_THROW(())
537*cdf0e10cSrcweir     {
538*cdf0e10cSrcweir         OSL_PRECOND( m_pHelper.get(), "XSDValidationPropertyHandler::implPrepareRemoveCurrentDataType: this will crash!" );
539*cdf0e10cSrcweir 
540*cdf0e10cSrcweir         ::rtl::Reference< XSDDataType > pType = m_pHelper->getValidatingDataType();
541*cdf0e10cSrcweir         if ( !pType.is() )
542*cdf0e10cSrcweir         {
543*cdf0e10cSrcweir             DBG_ERROR( "XSDValidationPropertyHandler::implPrepareRemoveCurrentDataType: invalid current data type!" );
544*cdf0e10cSrcweir             return false;
545*cdf0e10cSrcweir         }
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir         // confirmation message
548*cdf0e10cSrcweir         String sConfirmation( PcrRes( RID_STR_CONFIRM_DELETE_DATA_TYPE ) );
549*cdf0e10cSrcweir         sConfirmation.SearchAndReplaceAscii( "#type#", pType->getName() );
550*cdf0e10cSrcweir         QueryBox aQuery( NULL, WB_YES_NO, sConfirmation ); // TODO/eForms: proper parent
551*cdf0e10cSrcweir         if ( aQuery.Execute() != RET_YES )
552*cdf0e10cSrcweir             return false;
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir         return true;
555*cdf0e10cSrcweir     }
556*cdf0e10cSrcweir 
557*cdf0e10cSrcweir     //--------------------------------------------------------------------
558*cdf0e10cSrcweir     bool XSDValidationPropertyHandler::implDoRemoveCurrentDataType() SAL_THROW(())
559*cdf0e10cSrcweir     {
560*cdf0e10cSrcweir         OSL_PRECOND( m_pHelper.get(), "XSDValidationPropertyHandler::implDoRemoveCurrentDataType: this will crash!" );
561*cdf0e10cSrcweir 
562*cdf0e10cSrcweir         ::rtl::Reference< XSDDataType > pType = m_pHelper->getValidatingDataType();
563*cdf0e10cSrcweir         if ( !pType.is() )
564*cdf0e10cSrcweir             return false;
565*cdf0e10cSrcweir 
566*cdf0e10cSrcweir         // set a new data type at the binding, which is the "basic" type for the one
567*cdf0e10cSrcweir         // we are going to delete
568*cdf0e10cSrcweir         // (do this before the actual deletion, so the old type is still valid for property change
569*cdf0e10cSrcweir         // notifications)
570*cdf0e10cSrcweir         m_pHelper->setValidatingDataTypeByName( m_pHelper->getBasicTypeNameForClass( pType->classify() ) );
571*cdf0e10cSrcweir         // now remove the type
572*cdf0e10cSrcweir         m_pHelper->removeDataTypeFromRepository( pType->getName() );
573*cdf0e10cSrcweir 
574*cdf0e10cSrcweir         return true;
575*cdf0e10cSrcweir     }
576*cdf0e10cSrcweir 
577*cdf0e10cSrcweir     //--------------------------------------------------------------------
578*cdf0e10cSrcweir     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)
579*cdf0e10cSrcweir     {
580*cdf0e10cSrcweir         if ( !_rxInspectorUI.is() )
581*cdf0e10cSrcweir             throw NullPointerException();
582*cdf0e10cSrcweir 
583*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
584*cdf0e10cSrcweir         PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
585*cdf0e10cSrcweir         if ( !m_pHelper.get() )
586*cdf0e10cSrcweir             throw RuntimeException();
587*cdf0e10cSrcweir             // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
588*cdf0e10cSrcweir 
589*cdf0e10cSrcweir         switch ( nActuatingPropId )
590*cdf0e10cSrcweir         {
591*cdf0e10cSrcweir         case PROPERTY_ID_XSD_DATA_TYPE:
592*cdf0e10cSrcweir         {
593*cdf0e10cSrcweir             ::rtl::Reference< XSDDataType > xDataType( m_pHelper->getValidatingDataType() );
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir             // is removal of this type possible?
596*cdf0e10cSrcweir             sal_Bool bIsBasicType = xDataType.is() && xDataType->isBasicType();
597*cdf0e10cSrcweir             _rxInspectorUI->enablePropertyUIElements( PROPERTY_XSD_DATA_TYPE, PropertyLineElement::PrimaryButton, xDataType.is() );
598*cdf0e10cSrcweir             _rxInspectorUI->enablePropertyUIElements( PROPERTY_XSD_DATA_TYPE, PropertyLineElement::SecondaryButton, xDataType.is() && !bIsBasicType );
599*cdf0e10cSrcweir 
600*cdf0e10cSrcweir             //------------------------------------------------------------
601*cdf0e10cSrcweir             // show the facets which are available at the data type
602*cdf0e10cSrcweir             ::rtl::OUString aFacets[] = {
603*cdf0e10cSrcweir                 PROPERTY_XSD_WHITESPACES, PROPERTY_XSD_PATTERN,
604*cdf0e10cSrcweir                 PROPERTY_XSD_LENGTH, PROPERTY_XSD_MIN_LENGTH, PROPERTY_XSD_MAX_LENGTH, PROPERTY_XSD_TOTAL_DIGITS,
605*cdf0e10cSrcweir                 PROPERTY_XSD_FRACTION_DIGITS,
606*cdf0e10cSrcweir                 PROPERTY_XSD_MAX_INCLUSIVE_INT,
607*cdf0e10cSrcweir                 PROPERTY_XSD_MAX_EXCLUSIVE_INT,
608*cdf0e10cSrcweir                 PROPERTY_XSD_MIN_INCLUSIVE_INT,
609*cdf0e10cSrcweir                 PROPERTY_XSD_MIN_EXCLUSIVE_INT,
610*cdf0e10cSrcweir                 PROPERTY_XSD_MAX_INCLUSIVE_DOUBLE,
611*cdf0e10cSrcweir                 PROPERTY_XSD_MAX_EXCLUSIVE_DOUBLE,
612*cdf0e10cSrcweir                 PROPERTY_XSD_MIN_INCLUSIVE_DOUBLE,
613*cdf0e10cSrcweir                 PROPERTY_XSD_MIN_EXCLUSIVE_DOUBLE,
614*cdf0e10cSrcweir                 PROPERTY_XSD_MAX_INCLUSIVE_DATE,
615*cdf0e10cSrcweir                 PROPERTY_XSD_MAX_EXCLUSIVE_DATE,
616*cdf0e10cSrcweir                 PROPERTY_XSD_MIN_INCLUSIVE_DATE,
617*cdf0e10cSrcweir                 PROPERTY_XSD_MIN_EXCLUSIVE_DATE,
618*cdf0e10cSrcweir                 PROPERTY_XSD_MAX_INCLUSIVE_TIME,
619*cdf0e10cSrcweir                 PROPERTY_XSD_MAX_EXCLUSIVE_TIME,
620*cdf0e10cSrcweir                 PROPERTY_XSD_MIN_INCLUSIVE_TIME,
621*cdf0e10cSrcweir                 PROPERTY_XSD_MIN_EXCLUSIVE_TIME,
622*cdf0e10cSrcweir                 PROPERTY_XSD_MAX_INCLUSIVE_DATE_TIME,
623*cdf0e10cSrcweir                 PROPERTY_XSD_MAX_EXCLUSIVE_DATE_TIME,
624*cdf0e10cSrcweir                 PROPERTY_XSD_MIN_INCLUSIVE_DATE_TIME,
625*cdf0e10cSrcweir                 PROPERTY_XSD_MIN_EXCLUSIVE_DATE_TIME
626*cdf0e10cSrcweir             };
627*cdf0e10cSrcweir 
628*cdf0e10cSrcweir             size_t i=0;
629*cdf0e10cSrcweir             const ::rtl::OUString* pLoop = NULL;
630*cdf0e10cSrcweir             for ( i = 0, pLoop = aFacets;
631*cdf0e10cSrcweir                   i < sizeof( aFacets ) / sizeof( aFacets[0] );
632*cdf0e10cSrcweir                   ++i, ++pLoop
633*cdf0e10cSrcweir                 )
634*cdf0e10cSrcweir             {
635*cdf0e10cSrcweir                 showPropertyUI( _rxInspectorUI, *pLoop, xDataType.is() && xDataType->hasFacet( *pLoop ) );
636*cdf0e10cSrcweir                 _rxInspectorUI->enablePropertyUI( *pLoop, !bIsBasicType );
637*cdf0e10cSrcweir             }
638*cdf0e10cSrcweir         }
639*cdf0e10cSrcweir         break;
640*cdf0e10cSrcweir 
641*cdf0e10cSrcweir         case PROPERTY_ID_XML_DATA_MODEL:
642*cdf0e10cSrcweir         {
643*cdf0e10cSrcweir             // The data type which the current binding works with may not be present in the
644*cdf0e10cSrcweir             // new model. Thus, transfer it.
645*cdf0e10cSrcweir             ::rtl::OUString sOldModelName; _rOldValue >>= sOldModelName;
646*cdf0e10cSrcweir             ::rtl::OUString sNewModelName; _rNewValue >>= sNewModelName;
647*cdf0e10cSrcweir             ::rtl::OUString sDataType = m_pHelper->getValidatingDataTypeName();
648*cdf0e10cSrcweir             m_pHelper->copyDataType( sOldModelName, sNewModelName, sDataType );
649*cdf0e10cSrcweir 
650*cdf0e10cSrcweir             // the list of available data types depends on the chosen model, so update this
651*cdf0e10cSrcweir             if ( !_bFirstTimeInit )
652*cdf0e10cSrcweir                 _rxInspectorUI->rebuildPropertyUI( PROPERTY_XSD_DATA_TYPE );
653*cdf0e10cSrcweir         }
654*cdf0e10cSrcweir         break;
655*cdf0e10cSrcweir 
656*cdf0e10cSrcweir         default:
657*cdf0e10cSrcweir             DBG_ERROR( "XSDValidationPropertyHandler::actuatingPropertyChanged: cannot handle this property!" );
658*cdf0e10cSrcweir             return;
659*cdf0e10cSrcweir         }
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir         // in both cases, we need to care for the current value of the XSD_DATA_TYPE property,
662*cdf0e10cSrcweir         // and update the FormatKey of the formatted field we're inspecting (if any)
663*cdf0e10cSrcweir         if ( !_bFirstTimeInit && m_pHelper->isInspectingFormattedField() )
664*cdf0e10cSrcweir             m_pHelper->findDefaultFormatForIntrospectee();
665*cdf0e10cSrcweir     }
666*cdf0e10cSrcweir 
667*cdf0e10cSrcweir     //--------------------------------------------------------------------
668*cdf0e10cSrcweir     void XSDValidationPropertyHandler::implGetAvailableDataTypeNames( ::std::vector< ::rtl::OUString >& /* [out] */ _rNames ) const SAL_THROW(())
669*cdf0e10cSrcweir     {
670*cdf0e10cSrcweir         OSL_PRECOND( m_pHelper.get(), "XSDValidationPropertyHandler::implGetAvailableDataTypeNames: this will crash!" );
671*cdf0e10cSrcweir         // start with *all* types which are available at the model
672*cdf0e10cSrcweir         ::std::vector< ::rtl::OUString > aAllTypes;
673*cdf0e10cSrcweir         m_pHelper->getAvailableDataTypeNames( aAllTypes );
674*cdf0e10cSrcweir         _rNames.clear();
675*cdf0e10cSrcweir         _rNames.reserve( aAllTypes.size() );
676*cdf0e10cSrcweir 
677*cdf0e10cSrcweir         // then allow only those which are "compatible" with our control
678*cdf0e10cSrcweir         for ( ::std::vector< ::rtl::OUString >::const_iterator dataType = aAllTypes.begin();
679*cdf0e10cSrcweir               dataType != aAllTypes.end();
680*cdf0e10cSrcweir               ++dataType
681*cdf0e10cSrcweir             )
682*cdf0e10cSrcweir         {
683*cdf0e10cSrcweir             ::rtl::Reference< XSDDataType > pType = m_pHelper->getDataTypeByName( *dataType );
684*cdf0e10cSrcweir             if ( pType.is() && m_pHelper->canBindToDataType( pType->classify() ) )
685*cdf0e10cSrcweir                 _rNames.push_back( *dataType );
686*cdf0e10cSrcweir         }
687*cdf0e10cSrcweir     }
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir //........................................................................
690*cdf0e10cSrcweir } // namespace pcr
691*cdf0e10cSrcweir //........................................................................
692*cdf0e10cSrcweir 
693