1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: propertyimport.cxx,v $
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>
56 //.........................................................................
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
70 #define TYPE_DATETIME 3
72 //=====================================================================
73 //= PropertyConversion
74 //=====================================================================
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);
83 aTime
.HundredthSeconds
= (sal_uInt16
)( nIntValue
% 100 );
85 aTime
.Seconds
= (sal_uInt16
)( nIntValue
% 60 );
87 aTime
.Minutes
= (sal_uInt16
)( nIntValue
% 60 );
89 OSL_ENSURE(nIntValue
< 24, "lcl_getTime: more than a day?");
90 aTime
.Hours
= static_cast< sal_uInt16
>( nIntValue
);
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
);
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
)
110 sal_Bool bEnumAsInt
= sal_False
;
111 switch (_rExpectedType
.getTypeClass())
113 case TypeClass_BOOLEAN
: // sal_Bool
116 #if OSL_DEBUG_LEVEL > 0
119 _rImporter
.GetMM100UnitConverter().convertBool(bValue
, _rReadCharacters
);
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
);
127 case TypeClass_SHORT
: // sal_Int16
128 case TypeClass_LONG
: // sal_Int32
130 { // it's a real int32/16 property
132 #if OSL_DEBUG_LEVEL > 0
135 _rImporter
.GetMM100UnitConverter().convertNumber(nValue
, _rReadCharacters
);
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
;
143 aReturn
<<= (sal_Int32
)nValue
;
146 bEnumAsInt
= sal_True
;
147 // NO BREAK! handle it as enum
150 sal_uInt16
nEnumValue(0);
151 #if OSL_DEBUG_LEVEL > 0
154 _rImporter
.GetMM100UnitConverter().convertEnum(nEnumValue
, _rReadCharacters
, _pEnumMap
);
155 OSL_ENSURE(bSuccess
, "PropertyConversion::convertString: could not convert to an enum value!");
157 if (TypeClass_SHORT
== _rExpectedType
.getTypeClass())
158 aReturn
<<= (sal_Int16
)nEnumValue
;
160 aReturn
<<= (sal_Int32
)nEnumValue
;
162 aReturn
= ::cppu::int2enum((sal_Int32
)nEnumValue
, _rExpectedType
);
165 case TypeClass_HYPER
:
167 OSL_ENSURE(sal_False
, "PropertyConversion::convertString: 64-bit integers not implemented yet!");
170 case TypeClass_DOUBLE
:
173 #if OSL_DEBUG_LEVEL > 0
176 _rImporter
.GetMM100UnitConverter().convertDouble(nValue
, _rReadCharacters
);
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
;
184 case TypeClass_STRING
:
185 aReturn
<<= _rReadCharacters
;
187 case TypeClass_STRUCT
:
190 if ( _rExpectedType
.equals( ::cppu::UnoType
< ::com::sun::star::util::Date
>::get() ) )
192 else if ( _rExpectedType
.equals( ::cppu::UnoType
< ::com::sun::star::util::Time
>::get() ) )
194 else if ( _rExpectedType
.equals( ::cppu::UnoType
< ::com::sun::star::util::DateTime
>::get() ) )
195 nType
= TYPE_DATETIME
;
199 // first extract the double
201 #if OSL_DEBUG_LEVEL > 0
204 _rImporter
.GetMM100UnitConverter().convertDouble(nValue
, _rReadCharacters
);
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
215 OSL_ENSURE(((sal_uInt32
)nValue
) - nValue
== 0,
216 "PropertyConversion::convertString: a Date value with a fractional part?");
217 aReturn
<<= lcl_getDate(nValue
);
222 OSL_ENSURE(((sal_uInt32
)nValue
) == 0,
223 "PropertyConversion::convertString: a Time value with more than a fractional part?");
224 aReturn
<<= lcl_getTime(nValue
);
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
;
246 OSL_ENSURE(sal_False
, "PropertyConversion::convertString: unsupported property type!");
250 OSL_ENSURE(sal_False
, "PropertyConversion::convertString: invalid type class!");
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
;
279 //=====================================================================
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);
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
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
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
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
);
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
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() );
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
);
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
);
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
;
469 rMap
.GetKeyByAttrName( rAttrName
,
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();
503 PropertyConversion::convertString(GetImport(), aPropType
,
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
);
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() )
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() );
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
);
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 //.........................................................................