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