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