merge the formfield patch from ooo-build
[ooovba.git] / xmloff / source / forms / propertyimport.cxx
blob3d88b29271714b081aa30a18236119c36f3c30ec
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: propertyimport.cxx,v $
10 * $Revision: 1.27 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include "propertyimport.hxx"
34 #include <xmloff/xmlimp.hxx>
35 #include <xmloff/xmluconv.hxx>
36 #include <xmloff/nmspmap.hxx>
37 #include <osl/diagnose.h>
38 #include <comphelper/extract.hxx>
39 #include "callbacks.hxx"
40 #include "xmlnmspe.hxx"
41 #include <tools/date.hxx>
42 #include <tools/time.hxx>
43 #include <tools/datetime.hxx>
44 #include <com/sun/star/util/Date.hpp>
45 #include <com/sun/star/util/Time.hpp>
46 #include <com/sun/star/util/DateTime.hpp>
47 #include <unotools/datetime.hxx>
48 #include <rtl/logfile.hxx>
50 #if OSL_DEBUG_LEVEL > 0
51 #ifndef _OSL_THREAD_H_
52 #include <osl/thread.h>
53 #endif
54 #endif
56 //.........................................................................
57 namespace xmloff
59 //.........................................................................
61 using namespace ::com::sun::star::uno;
62 using namespace ::com::sun::star::beans;
63 using namespace ::com::sun::star::xml;
65 // NO using namespace ...util !!!
66 // need a tools Date/Time/DateTime below, which would conflict with the uno types then
68 #define TYPE_DATE 1
69 #define TYPE_TIME 2
70 #define TYPE_DATETIME 3
72 //=====================================================================
73 //= PropertyConversion
74 //=====================================================================
75 namespace
77 //---------------------------------------------------------------------
78 ::com::sun::star::util::Time lcl_getTime(double _nValue)
80 ::com::sun::star::util::Time aTime;
81 sal_uInt32 nIntValue = sal_Int32(_nValue * 8640000);
82 nIntValue *= 8640000;
83 aTime.HundredthSeconds = (sal_uInt16)( nIntValue % 100 );
84 nIntValue /= 100;
85 aTime.Seconds = (sal_uInt16)( nIntValue % 60 );
86 nIntValue /= 60;
87 aTime.Minutes = (sal_uInt16)( nIntValue % 60 );
88 nIntValue /= 60;
89 OSL_ENSURE(nIntValue < 24, "lcl_getTime: more than a day?");
90 aTime.Hours = static_cast< sal_uInt16 >( nIntValue );
92 return aTime;
95 //---------------------------------------------------------------------
96 static ::com::sun::star::util::Date lcl_getDate( double _nValue )
98 Date aToolsDate((sal_uInt32)_nValue);
99 ::com::sun::star::util::Date aDate;
100 ::utl::typeConvert(aToolsDate, aDate);
101 return aDate;
105 //---------------------------------------------------------------------
106 Any PropertyConversion::convertString( SvXMLImport& _rImporter, const ::com::sun::star::uno::Type& _rExpectedType,
107 const ::rtl::OUString& _rReadCharacters, const SvXMLEnumMapEntry* _pEnumMap, const sal_Bool _bInvertBoolean )
109 Any aReturn;
110 sal_Bool bEnumAsInt = sal_False;
111 switch (_rExpectedType.getTypeClass())
113 case TypeClass_BOOLEAN: // sal_Bool
115 sal_Bool bValue;
116 #if OSL_DEBUG_LEVEL > 0
117 sal_Bool bSuccess =
118 #endif
119 _rImporter.GetMM100UnitConverter().convertBool(bValue, _rReadCharacters);
120 OSL_ENSURE(bSuccess,
121 ::rtl::OString("PropertyConversion::convertString: could not convert \"")
122 += ::rtl::OString(_rReadCharacters.getStr(), _rReadCharacters.getLength(), RTL_TEXTENCODING_ASCII_US)
123 += ::rtl::OString("\" into a boolean!"));
124 aReturn = ::cppu::bool2any(_bInvertBoolean ? !bValue : bValue);
126 break;
127 case TypeClass_SHORT: // sal_Int16
128 case TypeClass_LONG: // sal_Int32
129 if (!_pEnumMap)
130 { // it's a real int32/16 property
131 sal_Int32 nValue(0);
132 #if OSL_DEBUG_LEVEL > 0
133 sal_Bool bSuccess =
134 #endif
135 _rImporter.GetMM100UnitConverter().convertNumber(nValue, _rReadCharacters);
136 OSL_ENSURE(bSuccess,
137 ::rtl::OString("PropertyConversion::convertString: could not convert \"")
138 += ::rtl::OString(_rReadCharacters.getStr(), _rReadCharacters.getLength(), RTL_TEXTENCODING_ASCII_US)
139 += ::rtl::OString("\" into an integer!"));
140 if (TypeClass_SHORT == _rExpectedType.getTypeClass())
141 aReturn <<= (sal_Int16)nValue;
142 else
143 aReturn <<= (sal_Int32)nValue;
144 break;
146 bEnumAsInt = sal_True;
147 // NO BREAK! handle it as enum
148 case TypeClass_ENUM:
150 sal_uInt16 nEnumValue(0);
151 #if OSL_DEBUG_LEVEL > 0
152 sal_Bool bSuccess =
153 #endif
154 _rImporter.GetMM100UnitConverter().convertEnum(nEnumValue, _rReadCharacters, _pEnumMap);
155 OSL_ENSURE(bSuccess, "PropertyConversion::convertString: could not convert to an enum value!");
156 if (bEnumAsInt)
157 if (TypeClass_SHORT == _rExpectedType.getTypeClass())
158 aReturn <<= (sal_Int16)nEnumValue;
159 else
160 aReturn <<= (sal_Int32)nEnumValue;
161 else
162 aReturn = ::cppu::int2enum((sal_Int32)nEnumValue, _rExpectedType);
164 break;
165 case TypeClass_HYPER:
167 OSL_ENSURE(sal_False, "PropertyConversion::convertString: 64-bit integers not implemented yet!");
169 break;
170 case TypeClass_DOUBLE:
172 double nValue;
173 #if OSL_DEBUG_LEVEL > 0
174 sal_Bool bSuccess =
175 #endif
176 _rImporter.GetMM100UnitConverter().convertDouble(nValue, _rReadCharacters);
177 OSL_ENSURE(bSuccess,
178 ::rtl::OString("PropertyConversion::convertString: could not convert \"")
179 += ::rtl::OString(_rReadCharacters.getStr(), _rReadCharacters.getLength(), RTL_TEXTENCODING_ASCII_US)
180 += ::rtl::OString("\" into a double!"));
181 aReturn <<= (double)nValue;
183 break;
184 case TypeClass_STRING:
185 aReturn <<= _rReadCharacters;
186 break;
187 case TypeClass_STRUCT:
189 sal_Int32 nType = 0;
190 if ( _rExpectedType.equals( ::cppu::UnoType< ::com::sun::star::util::Date >::get() ) )
191 nType = TYPE_DATE;
192 else if ( _rExpectedType.equals( ::cppu::UnoType< ::com::sun::star::util::Time >::get() ) )
193 nType = TYPE_TIME;
194 else if ( _rExpectedType.equals( ::cppu::UnoType< ::com::sun::star::util::DateTime >::get() ) )
195 nType = TYPE_DATETIME;
197 if ( nType )
199 // first extract the double
200 double nValue = 0;
201 #if OSL_DEBUG_LEVEL > 0
202 sal_Bool bSuccess =
203 #endif
204 _rImporter.GetMM100UnitConverter().convertDouble(nValue, _rReadCharacters);
205 OSL_ENSURE(bSuccess,
206 ::rtl::OString("PropertyConversion::convertString: could not convert \"")
207 += ::rtl::OString(_rReadCharacters.getStr(), _rReadCharacters.getLength(), RTL_TEXTENCODING_ASCII_US)
208 += ::rtl::OString("\" into a double!"));
210 // then convert it into the target type
211 switch (nType)
213 case TYPE_DATE:
215 OSL_ENSURE(((sal_uInt32)nValue) - nValue == 0,
216 "PropertyConversion::convertString: a Date value with a fractional part?");
217 aReturn <<= lcl_getDate(nValue);
219 break;
220 case TYPE_TIME:
222 OSL_ENSURE(((sal_uInt32)nValue) == 0,
223 "PropertyConversion::convertString: a Time value with more than a fractional part?");
224 aReturn <<= lcl_getTime(nValue);
226 break;
227 case TYPE_DATETIME:
229 ::com::sun::star::util::Time aTime = lcl_getTime(nValue);
230 ::com::sun::star::util::Date aDate = lcl_getDate(nValue);
232 ::com::sun::star::util::DateTime aDateTime;
233 aDateTime.HundredthSeconds = aTime.HundredthSeconds;
234 aDateTime.Seconds = aTime.Seconds;
235 aDateTime.Minutes = aTime.Minutes;
236 aDateTime.Hours = aTime.Hours;
237 aDateTime.Day = aDate.Day;
238 aDateTime.Month = aDate.Month;
239 aDateTime.Year = aDate.Year;
240 aReturn <<= aDateTime;
242 break;
245 else
246 OSL_ENSURE(sal_False, "PropertyConversion::convertString: unsupported property type!");
248 break;
249 default:
250 OSL_ENSURE(sal_False, "PropertyConversion::convertString: invalid type class!");
253 return aReturn;
256 //---------------------------------------------------------------------
257 Type PropertyConversion::xmlTypeToUnoType( const ::rtl::OUString& _rType )
259 Type aUnoType( ::getVoidCppuType() );
261 DECLARE_STL_USTRINGACCESS_MAP( ::com::sun::star::uno::Type, MapString2Type );
262 static MapString2Type s_aTypeNameMap;
263 if ( s_aTypeNameMap.empty() )
265 s_aTypeNameMap[ token::GetXMLToken( token::XML_BOOLEAN ) ] = ::getBooleanCppuType();
266 s_aTypeNameMap[ token::GetXMLToken( token::XML_FLOAT ) ] = ::getCppuType( static_cast< double* >(NULL) );
267 s_aTypeNameMap[ token::GetXMLToken( token::XML_STRING ) ] = ::getCppuType( static_cast< ::rtl::OUString* >(NULL) );
268 s_aTypeNameMap[ token::GetXMLToken( token::XML_VOID ) ] = ::getVoidCppuType();
271 const ConstMapString2TypeIterator aTypePos = s_aTypeNameMap.find( _rType );
272 OSL_ENSURE( s_aTypeNameMap.end() != aTypePos, "PropertyConversion::xmlTypeToUnoType: invalid property name!" );
273 if ( s_aTypeNameMap.end() != aTypePos )
274 aUnoType = aTypePos->second;
276 return aUnoType;
279 //=====================================================================
280 //= OPropertyImport
281 //=====================================================================
282 //---------------------------------------------------------------------
283 OPropertyImport::OPropertyImport(OFormLayerXMLImport_Impl& _rImport, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName)
284 :SvXMLImportContext(_rImport.getGlobalContext(), _nPrefix, _rName)
285 ,m_rContext(_rImport)
286 ,m_bTrackAttributes(sal_False)
290 //---------------------------------------------------------------------
291 SvXMLImportContext* OPropertyImport::CreateChildContext(sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName,
292 const Reference< sax::XAttributeList >& _rxAttrList)
294 if( token::IsXMLToken( _rLocalName, token::XML_PROPERTIES) )
296 return new OPropertyElementsContext( m_rContext.getGlobalContext(),
297 _nPrefix, _rLocalName, this);
299 else
301 OSL_ENSURE(sal_False,
302 ::rtl::OString("OPropertyImport::CreateChildContext: unknown sub element (only \"properties\" is recognized, but it is ")
303 += ::rtl::OString(_rLocalName.getStr(), _rLocalName.getLength(), RTL_TEXTENCODING_ASCII_US)
304 += ::rtl::OString(")!"));
305 return SvXMLImportContext::CreateChildContext(_nPrefix, _rLocalName, _rxAttrList);
309 //---------------------------------------------------------------------
310 void OPropertyImport::StartElement(const Reference< sax::XAttributeList >& _rxAttrList)
312 OSL_ENSURE(_rxAttrList.is(), "OPropertyImport::StartElement: invalid attribute list!");
313 const sal_Int32 nAttributeCount = _rxAttrList->getLength();
315 // assume the 'worst' case: all attributes describe properties. This should save our property array
316 // some reallocs
317 m_aValues.reserve(nAttributeCount);
319 const SvXMLNamespaceMap& rMap = m_rContext.getGlobalContext().GetNamespaceMap();
320 sal_uInt16 nNamespace;
321 ::rtl::OUString sLocalName;
322 for (sal_Int16 i=0; i<nAttributeCount; ++i)
324 nNamespace = rMap.GetKeyByAttrName(_rxAttrList->getNameByIndex(i), &sLocalName);
325 handleAttribute(nNamespace, sLocalName, _rxAttrList->getValueByIndex(i));
327 if (m_bTrackAttributes)
328 m_aEncounteredAttributes.insert(sLocalName);
331 // TODO: create PropertyValues for all the attributes which were not present, because they were implied
332 // this is necessary as soon as we have properties where the XML default is different from the property
333 // default
336 //---------------------------------------------------------------------
337 sal_Bool OPropertyImport::encounteredAttribute(const ::rtl::OUString& _rAttributeName) const
339 OSL_ENSURE(m_bTrackAttributes, "OPropertyImport::encounteredAttribute: attribute tracking not enabled!");
340 return m_aEncounteredAttributes.end() != m_aEncounteredAttributes.find(_rAttributeName);
343 //---------------------------------------------------------------------
344 void OPropertyImport::Characters(const ::rtl::OUString&
345 #if OSL_DEBUG_LEVEL > 0
346 _rChars
347 #endif
350 // ignore them (should be whitespaces only)
351 OSL_ENSURE(0 == _rChars.trim().getLength(), "OPropertyImport::Characters: non-whitespace characters!");
354 //---------------------------------------------------------------------
355 void OPropertyImport::handleAttribute(sal_uInt16 /*_nNamespaceKey*/, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue)
357 const OAttribute2Property::AttributeAssignment* pProperty = m_rContext.getAttributeMap().getAttributeTranslation(_rLocalName);
358 if (pProperty)
360 // create and store a new PropertyValue
361 PropertyValue aNewValue;
362 aNewValue.Name = pProperty->sPropertyName;
364 // convert the value string into the target type
365 aNewValue.Value = PropertyConversion::convertString(m_rContext.getGlobalContext(), pProperty->aPropertyType, _rValue, pProperty->pEnumMap, pProperty->bInverseSemantics);
366 implPushBackPropertyValue( aNewValue );
368 #if OSL_DEBUG_LEVEL > 0
369 else
371 ::rtl::OString sMessage( "OPropertyImport::handleAttribute: Can't handle the following:\n" );
372 sMessage += ::rtl::OString( " Attribute name: " );
373 sMessage += ::rtl::OString( _rLocalName.getStr(), _rLocalName.getLength(), osl_getThreadTextEncoding() );
374 sMessage += ::rtl::OString( "\n value: " );
375 sMessage += ::rtl::OString( _rValue.getStr(), _rValue.getLength(), osl_getThreadTextEncoding() );
376 OSL_ENSURE( sal_False, sMessage.getStr() );
378 #endif
381 //=====================================================================
382 //= OPropertyElementsContext
383 //=====================================================================
384 //---------------------------------------------------------------------
385 OPropertyElementsContext::OPropertyElementsContext(SvXMLImport& _rImport, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
386 const OPropertyImportRef& _rPropertyImporter)
387 :SvXMLImportContext(_rImport, _nPrefix, _rName)
388 ,m_xPropertyImporter(_rPropertyImporter)
392 //---------------------------------------------------------------------
393 SvXMLImportContext* OPropertyElementsContext::CreateChildContext(sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName,
394 const Reference< sax::XAttributeList >&)
396 if( token::IsXMLToken( _rLocalName, token::XML_PROPERTY ) )
398 return new OSinglePropertyContext(GetImport(), _nPrefix, _rLocalName, m_xPropertyImporter);
400 else if( token::IsXMLToken( _rLocalName, token::XML_LIST_PROPERTY ) )
402 return new OListPropertyContext( GetImport(), _nPrefix, _rLocalName, m_xPropertyImporter );
404 else
406 OSL_ENSURE(sal_False,
407 ::rtl::OString("OPropertyElementsContext::CreateChildContext: unknown child element (\"")
408 += ::rtl::OString(_rLocalName.getStr(), _rLocalName.getLength(), RTL_TEXTENCODING_ASCII_US)
409 += ::rtl::OString("\")!"));
410 return new SvXMLImportContext(GetImport(), _nPrefix, _rLocalName);
414 #if OSL_DEBUG_LEVEL > 0
415 //---------------------------------------------------------------------
416 void OPropertyElementsContext::StartElement(const Reference< sax::XAttributeList >& _rxAttrList)
418 OSL_ENSURE(0 == _rxAttrList->getLength(), "OPropertyElementsContext::StartElement: the form:properties element should not have attributes!");
419 SvXMLImportContext::StartElement(_rxAttrList);
422 //---------------------------------------------------------------------
423 void OPropertyElementsContext::Characters(const ::rtl::OUString& _rChars)
425 OSL_ENSURE(0 == _rChars.trim(), "OPropertyElementsContext::Characters: non-whitespace characters detected!");
426 SvXMLImportContext::Characters(_rChars);
429 #endif
431 //=====================================================================
432 //= OSinglePropertyContext
433 //=====================================================================
434 //---------------------------------------------------------------------
435 OSinglePropertyContext::OSinglePropertyContext(SvXMLImport& _rImport, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
436 const OPropertyImportRef& _rPropertyImporter)
437 :SvXMLImportContext(_rImport, _nPrefix, _rName)
438 ,m_xPropertyImporter(_rPropertyImporter)
442 //---------------------------------------------------------------------
443 SvXMLImportContext* OSinglePropertyContext::CreateChildContext(sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName,
444 const Reference< sax::XAttributeList >&)
446 OSL_ENSURE(sal_False,
447 ::rtl::OString("OSinglePropertyContext::CreateChildContext: unknown child element (\"")
448 += ::rtl::OString(_rLocalName.getStr(), _rLocalName.getLength(), RTL_TEXTENCODING_ASCII_US)
449 += ::rtl::OString("\")!"));
450 return new SvXMLImportContext(GetImport(), _nPrefix, _rLocalName);
453 //---------------------------------------------------------------------
454 void OSinglePropertyContext::StartElement(const Reference< sax::XAttributeList >& _rxAttrList)
456 ::com::sun::star::beans::PropertyValue aPropValue; // the property the instance imports currently
457 ::com::sun::star::uno::Type aPropType; // the type of the property the instance imports currently
459 ::rtl::OUString sType, sValue;
460 const SvXMLNamespaceMap& rMap = GetImport().GetNamespaceMap();
461 const sal_Int16 nAttrCount = _rxAttrList.is() ? _rxAttrList->getLength() : 0;
462 for( sal_Int16 i=0; i < nAttrCount; i++ )
464 const ::rtl::OUString& rAttrName = _rxAttrList->getNameByIndex( i );
465 //const ::rtl::OUString& rValue = _rxAttrList->getValueByIndex( i );
467 ::rtl::OUString aLocalName;
468 sal_uInt16 nPrefix =
469 rMap.GetKeyByAttrName( rAttrName,
470 &aLocalName );
471 if( XML_NAMESPACE_FORM == nPrefix )
473 if( token::IsXMLToken( aLocalName, token::XML_PROPERTY_NAME ) )
474 aPropValue.Name = _rxAttrList->getValueByIndex( i );
477 else if( XML_NAMESPACE_OFFICE == nPrefix )
479 if( token::IsXMLToken( aLocalName, token::XML_VALUE_TYPE ) )
480 sType = _rxAttrList->getValueByIndex( i );
481 else if( token::IsXMLToken( aLocalName,
482 token::XML_VALUE ) ||
483 token::IsXMLToken( aLocalName,
484 token::XML_BOOLEAN_VALUE ) ||
485 token::IsXMLToken( aLocalName,
486 token::XML_STRING_VALUE ) )
487 sValue = _rxAttrList->getValueByIndex( i );
491 // the name of the property
492 OSL_ENSURE(aPropValue.Name.getLength(), "OSinglePropertyContext::StartElement: invalid property name!");
494 // needs to be translated into a ::com::sun::star::uno::Type
495 aPropType = PropertyConversion::xmlTypeToUnoType( sType );
496 if( TypeClass_VOID == aPropType.getTypeClass() )
498 aPropValue.Value = Any();
500 else
502 aPropValue.Value =
503 PropertyConversion::convertString(GetImport(), aPropType,
504 sValue);
507 // now that we finally have our property value, add it to our parent object
508 if( aPropValue.Name.getLength() )
509 m_xPropertyImporter->implPushBackGenericPropertyValue(aPropValue);
512 //=====================================================================
513 //= OListPropertyContext
514 //=====================================================================
515 //---------------------------------------------------------------------
516 OListPropertyContext::OListPropertyContext( SvXMLImport& _rImport, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName,
517 const OPropertyImportRef& _rPropertyImporter )
518 :SvXMLImportContext( _rImport, _nPrefix, _rName )
519 ,m_xPropertyImporter( _rPropertyImporter )
523 //---------------------------------------------------------------------
524 void OListPropertyContext::StartElement( const Reference< sax::XAttributeList >& _rxAttrList )
526 sal_Int32 nAttributeCount = _rxAttrList->getLength();
528 sal_uInt16 nNamespace;
529 ::rtl::OUString sAttributeName;
530 const SvXMLNamespaceMap& rMap = GetImport().GetNamespaceMap();
531 for ( sal_Int16 i = 0; i < nAttributeCount; ++i )
533 nNamespace = rMap.GetKeyByAttrName( _rxAttrList->getNameByIndex( i ), &sAttributeName );
534 if ( ( XML_NAMESPACE_FORM == nNamespace )
535 && ( token::IsXMLToken( sAttributeName, token::XML_PROPERTY_NAME ) )
538 m_sPropertyName = _rxAttrList->getValueByIndex( i );
540 else if ( ( XML_NAMESPACE_OFFICE == nNamespace )
541 && ( token::IsXMLToken( sAttributeName, token::XML_VALUE_TYPE ) )
544 m_sPropertyType = _rxAttrList->getValueByIndex( i );
546 else
548 OSL_ENSURE( false,
549 ::rtl::OString( "OListPropertyContext::StartElement: unknown child element (\"")
550 += ::rtl::OString( sAttributeName.getStr(), sAttributeName.getLength(), RTL_TEXTENCODING_ASCII_US )
551 += ::rtl::OString( "\")!" ) );
556 //---------------------------------------------------------------------
557 void OListPropertyContext::EndElement()
559 OSL_ENSURE( m_sPropertyName.getLength() && m_sPropertyType.getLength(),
560 "OListPropertyContext::EndElement: no property name or type!" );
562 if ( !m_sPropertyName.getLength() || !m_sPropertyType.getLength() )
563 return;
565 Sequence< Any > aListElements( m_aListValues.size() );
566 Any* pListElement = aListElements.getArray();
567 com::sun::star::uno::Type aType = PropertyConversion::xmlTypeToUnoType( m_sPropertyType );
568 for ( ::std::vector< ::rtl::OUString >::const_iterator values = m_aListValues.begin();
569 values != m_aListValues.end();
570 ++values, ++pListElement
573 *pListElement = PropertyConversion::convertString( GetImport(), aType, *values );
576 PropertyValue aSequenceValue;
577 aSequenceValue.Name = m_sPropertyName;
578 aSequenceValue.Value <<= aListElements;
580 m_xPropertyImporter->implPushBackGenericPropertyValue( aSequenceValue );
583 //---------------------------------------------------------------------
584 SvXMLImportContext* OListPropertyContext::CreateChildContext( sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName, const Reference< sax::XAttributeList >& /*_rxAttrList*/ )
586 if ( token::IsXMLToken( _rLocalName, token::XML_LIST_VALUE ) )
588 m_aListValues.resize( m_aListValues.size() + 1 );
589 return new OListValueContext( GetImport(), _nPrefix, _rLocalName, *m_aListValues.rbegin() );
591 else
593 OSL_ENSURE( sal_False,
594 ::rtl::OString("OListPropertyContext::CreateChildContext: unknown child element (\"")
595 += ::rtl::OString(_rLocalName.getStr(), _rLocalName.getLength(), RTL_TEXTENCODING_ASCII_US)
596 += ::rtl::OString("\")!"));
597 return new SvXMLImportContext( GetImport(), _nPrefix, _rLocalName );
601 //=====================================================================
602 //= OListValueContext
603 //=====================================================================
604 //---------------------------------------------------------------------
605 OListValueContext::OListValueContext( SvXMLImport& _rImport, sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, ::rtl::OUString& _rListValueHolder )
606 :SvXMLImportContext( _rImport, _nPrefix, _rName )
607 ,m_rListValueHolder( _rListValueHolder )
611 //---------------------------------------------------------------------
612 void OListValueContext::StartElement( const Reference< sax::XAttributeList >& _rxAttrList )
614 const sal_Int32 nAttributeCount = _rxAttrList->getLength();
616 sal_uInt16 nNamespace;
617 ::rtl::OUString sAttributeName;
618 const SvXMLNamespaceMap& rMap = GetImport().GetNamespaceMap();
619 for ( sal_Int16 i = 0; i < nAttributeCount; ++i )
621 nNamespace = rMap.GetKeyByAttrName( _rxAttrList->getNameByIndex( i ), &sAttributeName );
622 if ( XML_NAMESPACE_OFFICE == nNamespace )
624 if ( token::IsXMLToken( sAttributeName, token::XML_VALUE )
625 || token::IsXMLToken( sAttributeName, token::XML_STRING_VALUE )
626 || token::IsXMLToken( sAttributeName, token::XML_BOOLEAN_VALUE )
629 m_rListValueHolder = _rxAttrList->getValueByIndex( i );
630 continue;
634 OSL_ENSURE( false,
635 ::rtl::OString( "OListValueContext::StartElement: unknown child element (\"")
636 += ::rtl::OString( sAttributeName.getStr(), sAttributeName.getLength(), RTL_TEXTENCODING_ASCII_US )
637 += ::rtl::OString( "\")!" ) );
641 //.........................................................................
642 } // namespace xmloff
643 //.........................................................................