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_xmloff.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "SchemaRestrictionContext.hxx"
32*cdf0e10cSrcweir #include "xformsapi.hxx"
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
35*cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
36*cdf0e10cSrcweir #include <xmloff/xmlnmspe.hxx>
37*cdf0e10cSrcweir #include <xmloff/xmltkmap.hxx>
38*cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
39*cdf0e10cSrcweir #include <xmloff/xmlimp.hxx>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/uno/Type.hxx>
43*cdf0e10cSrcweir #include <com/sun/star/util/Date.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/util/Time.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/util/DateTime.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/xforms/XDataTypeRepository.hpp>
47*cdf0e10cSrcweir #include <com/sun/star/xsd/DataTypeClass.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/xsd/WhiteSpaceTreatment.hpp>
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir #include <tools/debug.hxx>
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir using rtl::OUString;
54*cdf0e10cSrcweir using com::sun::star::uno::Reference;
55*cdf0e10cSrcweir using com::sun::star::uno::Exception;
56*cdf0e10cSrcweir using com::sun::star::uno::Any;
57*cdf0e10cSrcweir using com::sun::star::uno::makeAny;
58*cdf0e10cSrcweir using com::sun::star::uno::UNO_QUERY;
59*cdf0e10cSrcweir using com::sun::star::util::Date;
60*cdf0e10cSrcweir using com::sun::star::util::DateTime;
61*cdf0e10cSrcweir using com::sun::star::xml::sax::XAttributeList;
62*cdf0e10cSrcweir using com::sun::star::beans::XPropertySet;
63*cdf0e10cSrcweir using com::sun::star::beans::XPropertySetInfo;
64*cdf0e10cSrcweir using com::sun::star::xforms::XDataTypeRepository;
65*cdf0e10cSrcweir using namespace xmloff::token;
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir static SvXMLTokenMapEntry aAttributes[] =
71*cdf0e10cSrcweir {
72*cdf0e10cSrcweir     TOKEN_MAP_ENTRY( NONE, BASE ),
73*cdf0e10cSrcweir     XML_TOKEN_MAP_END
74*cdf0e10cSrcweir };
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir static SvXMLTokenMapEntry aChildren[] =
77*cdf0e10cSrcweir {
78*cdf0e10cSrcweir     TOKEN_MAP_ENTRY( XSD, LENGTH         ),
79*cdf0e10cSrcweir     TOKEN_MAP_ENTRY( XSD, MINLENGTH      ),
80*cdf0e10cSrcweir     TOKEN_MAP_ENTRY( XSD, MAXLENGTH      ),
81*cdf0e10cSrcweir     TOKEN_MAP_ENTRY( XSD, MININCLUSIVE   ),
82*cdf0e10cSrcweir     TOKEN_MAP_ENTRY( XSD, MINEXCLUSIVE   ),
83*cdf0e10cSrcweir     TOKEN_MAP_ENTRY( XSD, MAXINCLUSIVE   ),
84*cdf0e10cSrcweir     TOKEN_MAP_ENTRY( XSD, MAXEXCLUSIVE   ),
85*cdf0e10cSrcweir     TOKEN_MAP_ENTRY( XSD, PATTERN        ),
86*cdf0e10cSrcweir     // ??? XML_ENUMERATION
87*cdf0e10cSrcweir     TOKEN_MAP_ENTRY( XSD, WHITESPACE     ),
88*cdf0e10cSrcweir     TOKEN_MAP_ENTRY( XSD, TOTALDIGITS    ),
89*cdf0e10cSrcweir     TOKEN_MAP_ENTRY( XSD, FRACTIONDIGITS ),
90*cdf0e10cSrcweir     XML_TOKEN_MAP_END
91*cdf0e10cSrcweir };
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir SchemaRestrictionContext::SchemaRestrictionContext(
95*cdf0e10cSrcweir     SvXMLImport& rImport,
96*cdf0e10cSrcweir     sal_uInt16 nPrefix,
97*cdf0e10cSrcweir     const OUString& rLocalName,
98*cdf0e10cSrcweir     Reference<com::sun::star::xforms::XDataTypeRepository>& rRepository,
99*cdf0e10cSrcweir     const OUString& sTypeName ) :
100*cdf0e10cSrcweir         TokenContext( rImport, nPrefix, rLocalName, aAttributes, aChildren ),
101*cdf0e10cSrcweir         mxRepository( rRepository ),
102*cdf0e10cSrcweir         msTypeName( sTypeName ),
103*cdf0e10cSrcweir         msBaseName()
104*cdf0e10cSrcweir {
105*cdf0e10cSrcweir     DBG_ASSERT( mxRepository.is(), "need repository" );
106*cdf0e10cSrcweir }
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir SchemaRestrictionContext::~SchemaRestrictionContext()
109*cdf0e10cSrcweir {
110*cdf0e10cSrcweir }
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir void SchemaRestrictionContext::CreateDataType()
113*cdf0e10cSrcweir {
114*cdf0e10cSrcweir     // only do something if we don't have a data type already
115*cdf0e10cSrcweir     if( mxDataType.is() )
116*cdf0e10cSrcweir         return;
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir     DBG_ASSERT( msBaseName.getLength() > 0, "no base name?" );
119*cdf0e10cSrcweir     DBG_ASSERT( mxRepository.is(), "no repository?" );
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir     try
122*cdf0e10cSrcweir     {
123*cdf0e10cSrcweir         mxDataType =
124*cdf0e10cSrcweir             Reference<XPropertySet>(
125*cdf0e10cSrcweir                 mxRepository->cloneDataType(
126*cdf0e10cSrcweir                     lcl_getBasicTypeName( mxRepository,
127*cdf0e10cSrcweir                                           GetImport().GetNamespaceMap(),
128*cdf0e10cSrcweir                                           msBaseName ),
129*cdf0e10cSrcweir                     msTypeName ),
130*cdf0e10cSrcweir                 UNO_QUERY );
131*cdf0e10cSrcweir     }
132*cdf0e10cSrcweir     catch( const Exception& )
133*cdf0e10cSrcweir     {
134*cdf0e10cSrcweir         DBG_ERROR( "exception during type creation" );
135*cdf0e10cSrcweir     }
136*cdf0e10cSrcweir     DBG_ASSERT( mxDataType.is(), "can't create type" );
137*cdf0e10cSrcweir }
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir void SchemaRestrictionContext::HandleAttribute(
140*cdf0e10cSrcweir     sal_uInt16 nToken,
141*cdf0e10cSrcweir     const OUString& rValue )
142*cdf0e10cSrcweir {
143*cdf0e10cSrcweir     if( nToken == XML_BASE )
144*cdf0e10cSrcweir     {
145*cdf0e10cSrcweir         msBaseName = rValue;
146*cdf0e10cSrcweir     }
147*cdf0e10cSrcweir }
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir typedef Any (*convert_t)( const OUString& );
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir Any lcl_string( const OUString& rValue )
152*cdf0e10cSrcweir {
153*cdf0e10cSrcweir     return makeAny( rValue );
154*cdf0e10cSrcweir }
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir Any lcl_int32( const OUString& rValue )
157*cdf0e10cSrcweir {
158*cdf0e10cSrcweir     sal_Int32 nValue;
159*cdf0e10cSrcweir     bool bSuccess = SvXMLUnitConverter::convertNumber( nValue, rValue );
160*cdf0e10cSrcweir     return bSuccess ? makeAny( nValue ) : Any();
161*cdf0e10cSrcweir }
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir Any lcl_int16( const OUString& rValue )
164*cdf0e10cSrcweir {
165*cdf0e10cSrcweir     sal_Int32 nValue;
166*cdf0e10cSrcweir     bool bSuccess = SvXMLUnitConverter::convertNumber( nValue, rValue );
167*cdf0e10cSrcweir     return bSuccess ? makeAny( static_cast<sal_Int16>( nValue ) ) : Any();
168*cdf0e10cSrcweir }
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir Any lcl_whitespace( const OUString& rValue )
171*cdf0e10cSrcweir {
172*cdf0e10cSrcweir     Any aValue;
173*cdf0e10cSrcweir     if( IsXMLToken( rValue, XML_PRESERVE ) )
174*cdf0e10cSrcweir         aValue <<= com::sun::star::xsd::WhiteSpaceTreatment::Preserve;
175*cdf0e10cSrcweir     else if( IsXMLToken( rValue, XML_REPLACE ) )
176*cdf0e10cSrcweir         aValue <<= com::sun::star::xsd::WhiteSpaceTreatment::Replace;
177*cdf0e10cSrcweir     else if( IsXMLToken( rValue, XML_COLLAPSE ) )
178*cdf0e10cSrcweir         aValue <<= com::sun::star::xsd::WhiteSpaceTreatment::Collapse;
179*cdf0e10cSrcweir     return aValue;
180*cdf0e10cSrcweir }
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir Any lcl_double( const OUString& rValue )
183*cdf0e10cSrcweir {
184*cdf0e10cSrcweir     double fValue;
185*cdf0e10cSrcweir     bool bSuccess = SvXMLUnitConverter::convertDouble( fValue, rValue );
186*cdf0e10cSrcweir     return bSuccess ? makeAny( fValue ) : Any();
187*cdf0e10cSrcweir }
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir Any lcl_date( const OUString& rValue )
190*cdf0e10cSrcweir {
191*cdf0e10cSrcweir     Any aAny;
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir     // parse ISO date
194*cdf0e10cSrcweir     sal_Int32 nPos1 = rValue.indexOf( sal_Unicode('-') );
195*cdf0e10cSrcweir     sal_Int32 nPos2 = rValue.indexOf( sal_Unicode('-'), nPos1 + 1 );
196*cdf0e10cSrcweir     if( nPos1 > 0  &&  nPos2 > 0 )
197*cdf0e10cSrcweir     {
198*cdf0e10cSrcweir         Date aDate;
199*cdf0e10cSrcweir         aDate.Year = static_cast<sal_uInt16>(
200*cdf0e10cSrcweir                      rValue.copy( 0, nPos1 ).toInt32() );
201*cdf0e10cSrcweir         aDate.Month = static_cast<sal_uInt16>(
202*cdf0e10cSrcweir                       rValue.copy( nPos1 + 1, nPos2 - nPos1 - 1 ).toInt32() );
203*cdf0e10cSrcweir         aDate.Day   = static_cast<sal_uInt16>(
204*cdf0e10cSrcweir                       rValue.copy( nPos2 + 1 ).toInt32() );
205*cdf0e10cSrcweir         aAny <<= aDate;
206*cdf0e10cSrcweir     }
207*cdf0e10cSrcweir     return aAny;
208*cdf0e10cSrcweir }
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir Any lcl_dateTime( const OUString& rValue )
211*cdf0e10cSrcweir {
212*cdf0e10cSrcweir     DateTime aDateTime;
213*cdf0e10cSrcweir     bool bSuccess = SvXMLUnitConverter::convertDateTime( aDateTime, rValue );
214*cdf0e10cSrcweir     return bSuccess ? makeAny( aDateTime ) : Any();
215*cdf0e10cSrcweir }
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir Any lcl_time( const OUString& rValue )
218*cdf0e10cSrcweir {
219*cdf0e10cSrcweir     Any aAny;
220*cdf0e10cSrcweir     DateTime aDateTime;
221*cdf0e10cSrcweir     if( SvXMLUnitConverter::convertTime( aDateTime, rValue ) )
222*cdf0e10cSrcweir     {
223*cdf0e10cSrcweir         com::sun::star::util::Time aTime;
224*cdf0e10cSrcweir         aTime.Hours = aDateTime.Hours;
225*cdf0e10cSrcweir         aTime.Minutes = aDateTime.Minutes;
226*cdf0e10cSrcweir         aTime.Seconds = aDateTime.Seconds;
227*cdf0e10cSrcweir         aTime.HundredthSeconds = aDateTime.HundredthSeconds;
228*cdf0e10cSrcweir         aAny <<= aTime;
229*cdf0e10cSrcweir     }
230*cdf0e10cSrcweir     return aAny;
231*cdf0e10cSrcweir }
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir SvXMLImportContext* SchemaRestrictionContext::HandleChild(
235*cdf0e10cSrcweir     sal_uInt16 nToken,
236*cdf0e10cSrcweir     sal_uInt16 nPrefix,
237*cdf0e10cSrcweir     const OUString& rLocalName,
238*cdf0e10cSrcweir     const Reference<XAttributeList>& xAttrList )
239*cdf0e10cSrcweir {
240*cdf0e10cSrcweir     // find value
241*cdf0e10cSrcweir     OUString sValue;
242*cdf0e10cSrcweir     sal_Int16 nLength = xAttrList->getLength();
243*cdf0e10cSrcweir     for( sal_Int16 n = 0; n < nLength; n++ )
244*cdf0e10cSrcweir     {
245*cdf0e10cSrcweir         if( IsXMLToken( xAttrList->getNameByIndex( n ), XML_VALUE ) )
246*cdf0e10cSrcweir             sValue = xAttrList->getValueByIndex( n );
247*cdf0e10cSrcweir     }
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir     // determine property name + suitable converter
250*cdf0e10cSrcweir     OUString sPropertyName;
251*cdf0e10cSrcweir     convert_t pConvert = NULL;
252*cdf0e10cSrcweir     switch( nToken )
253*cdf0e10cSrcweir     {
254*cdf0e10cSrcweir     case XML_LENGTH:
255*cdf0e10cSrcweir         sPropertyName = OUString(RTL_CONSTASCII_USTRINGPARAM("Length"));
256*cdf0e10cSrcweir         pConvert = &lcl_int32;
257*cdf0e10cSrcweir         break;
258*cdf0e10cSrcweir     case XML_MINLENGTH:
259*cdf0e10cSrcweir         sPropertyName = OUString(RTL_CONSTASCII_USTRINGPARAM("MinLength"));
260*cdf0e10cSrcweir         pConvert = &lcl_int32;
261*cdf0e10cSrcweir         break;
262*cdf0e10cSrcweir     case XML_MAXLENGTH:
263*cdf0e10cSrcweir         sPropertyName = OUString(RTL_CONSTASCII_USTRINGPARAM("MaxLength"));
264*cdf0e10cSrcweir         pConvert = &lcl_int32;
265*cdf0e10cSrcweir         break;
266*cdf0e10cSrcweir     case XML_TOTALDIGITS:
267*cdf0e10cSrcweir         sPropertyName = OUString(RTL_CONSTASCII_USTRINGPARAM("TotalDigits"));
268*cdf0e10cSrcweir         pConvert = &lcl_int32;
269*cdf0e10cSrcweir         break;
270*cdf0e10cSrcweir     case XML_FRACTIONDIGITS:
271*cdf0e10cSrcweir         sPropertyName =OUString(RTL_CONSTASCII_USTRINGPARAM("FractionDigits"));
272*cdf0e10cSrcweir         pConvert = &lcl_int32;
273*cdf0e10cSrcweir         break;
274*cdf0e10cSrcweir     case XML_PATTERN:
275*cdf0e10cSrcweir         sPropertyName = OUString(RTL_CONSTASCII_USTRINGPARAM("Pattern"));
276*cdf0e10cSrcweir         pConvert = &lcl_string;
277*cdf0e10cSrcweir         break;
278*cdf0e10cSrcweir     case XML_WHITESPACE:
279*cdf0e10cSrcweir         sPropertyName = OUString(RTL_CONSTASCII_USTRINGPARAM("WhiteSpace"));
280*cdf0e10cSrcweir         pConvert = &lcl_whitespace;
281*cdf0e10cSrcweir         break;
282*cdf0e10cSrcweir     case XML_MININCLUSIVE:
283*cdf0e10cSrcweir     case XML_MINEXCLUSIVE:
284*cdf0e10cSrcweir     case XML_MAXINCLUSIVE:
285*cdf0e10cSrcweir     case XML_MAXEXCLUSIVE:
286*cdf0e10cSrcweir         {
287*cdf0e10cSrcweir             // these attributes are mapped to different properties.
288*cdf0e10cSrcweir             // To determine the property name, we use an attribute
289*cdf0e10cSrcweir             // dependent prefix and a type dependent suffix. The
290*cdf0e10cSrcweir             // converter is only type dependent.
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir             // first, attribute-dependent prefix
293*cdf0e10cSrcweir             switch( nToken )
294*cdf0e10cSrcweir             {
295*cdf0e10cSrcweir             case XML_MININCLUSIVE:
296*cdf0e10cSrcweir                 sPropertyName = OUString(RTL_CONSTASCII_USTRINGPARAM("MinInclusive"));
297*cdf0e10cSrcweir                 break;
298*cdf0e10cSrcweir             case XML_MINEXCLUSIVE:
299*cdf0e10cSrcweir                 sPropertyName = OUString(RTL_CONSTASCII_USTRINGPARAM("MinExclusive"));
300*cdf0e10cSrcweir                 break;
301*cdf0e10cSrcweir             case XML_MAXINCLUSIVE:
302*cdf0e10cSrcweir                 sPropertyName = OUString(RTL_CONSTASCII_USTRINGPARAM("MaxInclusive"));
303*cdf0e10cSrcweir                 break;
304*cdf0e10cSrcweir             case XML_MAXEXCLUSIVE:
305*cdf0e10cSrcweir                 sPropertyName = OUString(RTL_CONSTASCII_USTRINGPARAM("MaxExclusive"));
306*cdf0e10cSrcweir                 break;
307*cdf0e10cSrcweir             }
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir             // second, type-dependent suffix + converter
310*cdf0e10cSrcweir             switch( lcl_getTypeClass( mxRepository,
311*cdf0e10cSrcweir                                       GetImport().GetNamespaceMap(),
312*cdf0e10cSrcweir                                       msBaseName ) )
313*cdf0e10cSrcweir             {
314*cdf0e10cSrcweir             case com::sun::star::xsd::DataTypeClass::DECIMAL:
315*cdf0e10cSrcweir             case com::sun::star::xsd::DataTypeClass::DOUBLE:
316*cdf0e10cSrcweir             case com::sun::star::xsd::DataTypeClass::FLOAT:
317*cdf0e10cSrcweir                 sPropertyName += OUString(RTL_CONSTASCII_USTRINGPARAM("Double"));
318*cdf0e10cSrcweir                 pConvert = &lcl_double;
319*cdf0e10cSrcweir                 break;
320*cdf0e10cSrcweir             case com::sun::star::xsd::DataTypeClass::DATETIME:
321*cdf0e10cSrcweir                 sPropertyName += OUString(RTL_CONSTASCII_USTRINGPARAM("DateTime"));
322*cdf0e10cSrcweir                 pConvert = &lcl_dateTime;
323*cdf0e10cSrcweir                 break;
324*cdf0e10cSrcweir             case com::sun::star::xsd::DataTypeClass::DATE:
325*cdf0e10cSrcweir                 sPropertyName += OUString(RTL_CONSTASCII_USTRINGPARAM("Date"));
326*cdf0e10cSrcweir                 pConvert = &lcl_date;
327*cdf0e10cSrcweir                 break;
328*cdf0e10cSrcweir             case com::sun::star::xsd::DataTypeClass::TIME:
329*cdf0e10cSrcweir                 sPropertyName += OUString(RTL_CONSTASCII_USTRINGPARAM("Time"));
330*cdf0e10cSrcweir                 pConvert = &lcl_time;
331*cdf0e10cSrcweir                 break;
332*cdf0e10cSrcweir             case com::sun::star::xsd::DataTypeClass::gYear:
333*cdf0e10cSrcweir             case com::sun::star::xsd::DataTypeClass::gDay:
334*cdf0e10cSrcweir             case com::sun::star::xsd::DataTypeClass::gMonth:
335*cdf0e10cSrcweir                 sPropertyName += OUString(RTL_CONSTASCII_USTRINGPARAM("Int"));
336*cdf0e10cSrcweir                 pConvert = &lcl_int16;
337*cdf0e10cSrcweir                 break;
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir             case com::sun::star::xsd::DataTypeClass::STRING:
340*cdf0e10cSrcweir             case com::sun::star::xsd::DataTypeClass::anyURI:
341*cdf0e10cSrcweir             case com::sun::star::xsd::DataTypeClass::BOOLEAN:
342*cdf0e10cSrcweir                 // invalid: These shouldn't have min/max-inclusive
343*cdf0e10cSrcweir                 break;
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir                 /* data types not yet supported:
346*cdf0e10cSrcweir                    case com::sun::star::xsd::DataTypeClass::DURATION:
347*cdf0e10cSrcweir                    case com::sun::star::xsd::DataTypeClass::gYearMonth:
348*cdf0e10cSrcweir                    case com::sun::star::xsd::DataTypeClass::gMonthDay:
349*cdf0e10cSrcweir                    case com::sun::star::xsd::DataTypeClass::hexBinary:
350*cdf0e10cSrcweir                    case com::sun::star::xsd::DataTypeClass::base64Binary:
351*cdf0e10cSrcweir                    case com::sun::star::xsd::DataTypeClass::QName:
352*cdf0e10cSrcweir                    case com::sun::star::xsd::DataTypeClass::NOTATION:
353*cdf0e10cSrcweir                 */
354*cdf0e10cSrcweir             }
355*cdf0e10cSrcweir         }
356*cdf0e10cSrcweir         break;
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir     default:
359*cdf0e10cSrcweir         DBG_ERROR( "unknown facet" );
360*cdf0e10cSrcweir     }
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir     // finally, set the property
363*cdf0e10cSrcweir     CreateDataType();
364*cdf0e10cSrcweir     if( mxDataType.is()
365*cdf0e10cSrcweir         && sPropertyName.getLength() > 0
366*cdf0e10cSrcweir         && pConvert != NULL
367*cdf0e10cSrcweir         && mxDataType->getPropertySetInfo()->hasPropertyByName(sPropertyName) )
368*cdf0e10cSrcweir     {
369*cdf0e10cSrcweir         try
370*cdf0e10cSrcweir         {
371*cdf0e10cSrcweir             mxDataType->setPropertyValue( sPropertyName, pConvert( sValue ) );
372*cdf0e10cSrcweir         }
373*cdf0e10cSrcweir         catch( const Exception& )
374*cdf0e10cSrcweir         {
375*cdf0e10cSrcweir             ; // can't set property? Then ignore.
376*cdf0e10cSrcweir         }
377*cdf0e10cSrcweir     }
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir     return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
380*cdf0e10cSrcweir }
381