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: xmlimppr.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 <com/sun/star/xml/AttributeData.hpp>
34 #include <com/sun/star/beans/XMultiPropertySet.hpp>
35 #include <com/sun/star/lang/IllegalArgumentException.hpp>
36 #include <com/sun/star/lang/WrappedTargetException.hpp>
37 #include <com/sun/star/beans/UnknownPropertyException.hpp>
38 #include <com/sun/star/beans/PropertyVetoException.hpp>
39 #include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
40 #include <rtl/ustrbuf.hxx>
41 #include <xmloff/xmlprmap.hxx>
42 #include <xmloff/nmspmap.hxx>
43 #include <xmloff/xmlimppr.hxx>
44 #include <xmloff/xmlimp.hxx>
46 #include "xmlkywd.hxx"
47 #include "unoatrcn.hxx"
48 #include "xmlnmspe.hxx"
49 #include <xmloff/xmltoken.hxx>
50 #include "xmlerror.hxx"
51 #include <tools/debug.hxx>
53 #include "xmloff/contextid.hxx"
61 using namespace ::com::sun::star::uno
;
62 using namespace ::com::sun::star::beans
;
63 using namespace ::com::sun::star::container
;
64 using namespace ::com::sun::star::xml
;
65 using namespace ::com::sun::star::xml::sax
;
66 using ::rtl::OUString
;
67 using ::rtl::OUStringBuffer
;
69 using namespace ::std
;
70 using namespace ::xmloff::token
;
71 using ::com::sun::star::lang::IllegalArgumentException
;
72 using ::com::sun::star::lang::WrappedTargetException
;
73 using ::com::sun::star::beans::UnknownPropertyException
;
74 using ::com::sun::star::beans::PropertyVetoException
;
77 SvXMLImportPropertyMapper::SvXMLImportPropertyMapper(
78 const UniReference
< XMLPropertySetMapper
>& rMapper
,
81 maPropMapper ( rMapper
)
85 SvXMLImportPropertyMapper::~SvXMLImportPropertyMapper()
90 void SvXMLImportPropertyMapper::ChainImportMapper(
91 const UniReference
< SvXMLImportPropertyMapper
>& rMapper
)
93 // add map entries from rMapper to current map
94 maPropMapper
->AddMapperEntry( rMapper
->getPropertySetMapper() );
95 // rMapper uses the same map as 'this'
96 rMapper
->maPropMapper
= maPropMapper
;
98 // set rMapper as last mapper in current chain
99 UniReference
< SvXMLImportPropertyMapper
> xNext
= mxNextMapper
;
102 while( xNext
->mxNextMapper
.is())
103 xNext
= xNext
->mxNextMapper
;
104 xNext
->mxNextMapper
= rMapper
;
107 mxNextMapper
= rMapper
;
109 // if rMapper was already chained, correct
110 // map pointer of successors
113 while( xNext
->mxNextMapper
.is())
115 xNext
= xNext
->mxNextMapper
;
116 xNext
->maPropMapper
= maPropMapper
;
120 void SvXMLImportPropertyMapper::importXML(
121 vector
< XMLPropertyState
>& rProperties
,
122 Reference
< XAttributeList
> xAttrList
,
123 const SvXMLUnitConverter
& rUnitConverter
,
124 const SvXMLNamespaceMap
& rNamespaceMap
,
125 sal_uInt32 nPropType
) const
127 importXML( rProperties
, xAttrList
, rUnitConverter
, rNamespaceMap
,
131 /** fills the given itemset with the attributes in the given list */
132 void SvXMLImportPropertyMapper::importXML(
133 vector
< XMLPropertyState
>& rProperties
,
134 Reference
< XAttributeList
> xAttrList
,
135 const SvXMLUnitConverter
& rUnitConverter
,
136 const SvXMLNamespaceMap
& rNamespaceMap
,
137 sal_uInt32 nPropType
,
139 sal_Int32 nEndIdx
) const
141 INT16 nAttr
= xAttrList
->getLength();
143 Reference
< XNameContainer
> xAttrContainer
;
145 if( -1 == nStartIdx
)
148 nEndIdx
= maPropMapper
->GetEntryCount();
149 for( INT16 i
=0; i
< nAttr
; i
++ )
151 const OUString
& rAttrName
= xAttrList
->getNameByIndex( i
);
152 OUString aLocalName
, aPrefix
, aNamespace
;
153 USHORT nPrefix
= rNamespaceMap
.GetKeyByAttrName( rAttrName
, &aPrefix
,
154 &aLocalName
, &aNamespace
);
156 if( XML_NAMESPACE_XMLNS
== nPrefix
)
159 const OUString
& rValue
= xAttrList
->getValueByIndex( i
);
161 // index of actual property map entry
162 // This looks very strange, but it works well:
163 // If the start index is 0, the new value will become -1, and
164 // GetEntryIndex will start searching with position 0.
165 // Otherwise GetEntryIndex will start with the next position specified.
166 sal_Int32 nIndex
= nStartIdx
- 1;
167 sal_uInt32 nFlags
= 0; // flags of actual property map entry
168 sal_Bool bFound
= sal_False
;
170 // for better error reporting: this should be set true if no
172 sal_Bool bNoWarning
= sal_False
;
173 bool bAlienImport
= false;
177 // find an entry for this attribute
178 nIndex
= maPropMapper
->GetEntryIndex( nPrefix
, aLocalName
,
181 if( nIndex
> -1 && nIndex
< nEndIdx
)
183 // create a XMLPropertyState with an empty value
185 nFlags
= maPropMapper
->GetEntryFlags( nIndex
);
186 if( (( nFlags
& MID_FLAG_NO_PROPERTY
) == MID_FLAG_NO_PROPERTY
) && (maPropMapper
->GetEntryContextId( nIndex
) == CTF_ALIEN_ATTRIBUTE_IMPORT
) )
193 if( ( nFlags
& MID_FLAG_ELEMENT_ITEM_IMPORT
) == 0 )
195 XMLPropertyState
aNewProperty( nIndex
);
196 sal_Int32 nReference
= -1;
198 // if this is a multi attribute check if another attribute already set
199 // this any. If so use this as a initial value
200 if( ( nFlags
& MID_FLAG_MERGE_PROPERTY
) != 0 )
202 const OUString
aAPIName( maPropMapper
->GetEntryAPIName( nIndex
) );
203 const sal_Int32 nSize
= rProperties
.size();
204 for( nReference
= 0; nReference
< nSize
; nReference
++ )
206 sal_Int32 nRefIdx
= rProperties
[nReference
].mnIndex
;
207 if( (nRefIdx
!= -1) && (nIndex
!= nRefIdx
) &&
208 (maPropMapper
->GetEntryAPIName( nRefIdx
) == aAPIName
))
210 aNewProperty
= rProperties
[nReference
];
211 aNewProperty
.mnIndex
= nIndex
;
216 if( nReference
== nSize
)
220 sal_Bool bSet
= sal_False
;
221 if( ( nFlags
& MID_FLAG_SPECIAL_ITEM_IMPORT
) == 0 )
223 // let the XMLPropertySetMapper decide how to import the value
224 bSet
= maPropMapper
->importXML( rValue
, aNewProperty
,
229 sal_uInt32 nOldSize
= rProperties
.size();
231 bSet
= handleSpecialItem( aNewProperty
, rProperties
,
232 rValue
, rUnitConverter
,
235 // no warning if handleSpecialItem added properties
236 bNoWarning
|= ( nOldSize
!= rProperties
.size() );
239 // no warning if we found could set the item. This
240 // 'remembers' bSet across multi properties.
243 // store the property in the given vector
246 if( nReference
== -1 )
247 rProperties
.push_back( aNewProperty
);
249 rProperties
[nReference
] = aNewProperty
;
253 // warn about unknown value. Unless it's a
254 // multi property: Then we get another chance
257 ((nFlags
& MID_FLAG_MULTI_PROPERTY
) == 0) )
259 Sequence
<OUString
> aSeq(2);
262 rImport
.SetError( XMLERROR_FLAG_WARNING
|
263 XMLERROR_STYLE_ATTR_VALUE
,
275 if( (XML_NAMESPACE_UNKNOWN_FLAG
& nPrefix
) || (XML_NAMESPACE_NONE
== nPrefix
) || bAlienImport
)
277 OSL_ENSURE( XML_NAMESPACE_NONE
== nPrefix
||
278 (XML_NAMESPACE_UNKNOWN_FLAG
& nPrefix
) ||
280 "unknown attribute - might be a new feature?" );
281 if( !xAttrContainer
.is() )
283 // add an unknown attribute container to the properties
284 Reference
< XNameContainer
> xNew( SvUnoAttributeContainer_CreateInstance(), UNO_QUERY
);
285 xAttrContainer
= xNew
;
287 // find map entry and create new property state
292 case XML_TYPE_PROP_CHART
:
293 nIndex
= maPropMapper
->FindEntryIndex( "ChartUserDefinedAttributes", XML_NAMESPACE_TEXT
, GetXMLToken(XML_XMLNS
) );
295 case XML_TYPE_PROP_PARAGRAPH
:
296 nIndex
= maPropMapper
->FindEntryIndex( "ParaUserDefinedAttributes", XML_NAMESPACE_TEXT
, GetXMLToken(XML_XMLNS
) );
298 case XML_TYPE_PROP_TEXT
:
299 nIndex
= maPropMapper
->FindEntryIndex( "TextUserDefinedAttributes", XML_NAMESPACE_TEXT
, GetXMLToken(XML_XMLNS
) );
304 // other property type or property not found
306 nIndex
= maPropMapper
->FindEntryIndex( "UserDefinedAttributes", XML_NAMESPACE_TEXT
, GetXMLToken(XML_XMLNS
) );
309 // #106963#; use userdefined attribute only if it is in the specified property range
310 if( nIndex
!= -1 && nIndex
>= nStartIdx
&& nIndex
< nEndIdx
)
313 aAny
<<= xAttrContainer
;
314 XMLPropertyState
aNewProperty( nIndex
, aAny
);
316 // push it on our stack so we export it later
317 rProperties
.push_back( aNewProperty
);
321 if( xAttrContainer
.is() )
324 aData
.Type
= GetXMLToken( XML_CDATA
);
325 aData
.Value
= rValue
;
327 OUStringBuffer sName
;
328 if( XML_NAMESPACE_NONE
!= nPrefix
)
330 sName
.append( aPrefix
);
331 sName
.append( sal_Unicode(':') );
332 aData
.Namespace
= aNamespace
;
335 sName
.append( aLocalName
);
339 xAttrContainer
->insertByName( sName
.makeStringAndClear(), aAny
);
344 while( ( nIndex
>= 0 ) && (( nFlags
& MID_FLAG_MULTI_PROPERTY
) != 0 ) );
347 finished( rProperties
, nStartIdx
, nEndIdx
);
349 // Have to do if we change from a vector to a list or something like that
350 /*std::vector <XMLPropertyState>::iterator aItr = rProperties.begin();
351 while (aItr != rProperties.end())
353 if (aItr->mnIndex == -1)
354 aItr = rProperties.erase(aItr);
360 /** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_IMPORT flag set */
361 BOOL
SvXMLImportPropertyMapper::handleSpecialItem(
362 XMLPropertyState
& rProperty
,
363 vector
< XMLPropertyState
>& rProperties
,
364 const OUString
& rValue
,
365 const SvXMLUnitConverter
& rUnitConverter
,
366 const SvXMLNamespaceMap
& rNamespaceMap
) const
368 OSL_ENSURE( mxNextMapper
.is(), "unsuported special item in xml import" );
369 if( mxNextMapper
.is() )
370 return mxNextMapper
->handleSpecialItem( rProperty
, rProperties
, rValue
,
371 rUnitConverter
, rNamespaceMap
);
376 void SvXMLImportPropertyMapper::FillPropertySequence(
377 const ::std::vector
< XMLPropertyState
>& rProperties
,
378 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& rValues
)
381 sal_Int32 nCount
= rProperties
.size();
382 sal_Int32 nValueCount
= 0;
383 rValues
.realloc( nCount
);
384 PropertyValue
*pProps
= rValues
.getArray();
385 for( sal_Int32 i
=0; i
< nCount
; i
++ )
387 const XMLPropertyState
& rProp
= rProperties
[i
];
388 sal_Int32 nIdx
= rProp
.mnIndex
;
391 pProps
->Name
= maPropMapper
->GetEntryAPIName( nIdx
);
392 if( pProps
->Name
.getLength() )
394 pProps
->Value
<<= rProp
.maValue
;
399 if( nValueCount
< nCount
)
400 rValues
.realloc( nValueCount
);
403 void SvXMLImportPropertyMapper::CheckSpecialContext(
404 const ::std::vector
< XMLPropertyState
>& aProperties
,
405 const ::com::sun::star::uno::Reference
<
406 ::com::sun::star::beans::XPropertySet
> rPropSet
,
407 _ContextID_Index_Pair
* pSpecialContextIds
) const
409 OSL_ENSURE( rPropSet
.is(), "need an XPropertySet" );
410 sal_Int32 nCount
= aProperties
.size();
412 Reference
< XPropertySetInfo
> xInfo(rPropSet
->getPropertySetInfo());
414 for( sal_Int32 i
=0; i
< nCount
; i
++ )
416 const XMLPropertyState
& rProp
= aProperties
[i
];
417 sal_Int32 nIdx
= rProp
.mnIndex
;
419 // disregard property state if it has an invalid index
423 const sal_Int32 nPropFlags
= maPropMapper
->GetEntryFlags( nIdx
);
425 // handle no-property and special items
426 if( ( pSpecialContextIds
!= NULL
) &&
427 ( ( 0 != ( nPropFlags
& MID_FLAG_NO_PROPERTY_IMPORT
) ) ||
428 ( 0 != ( nPropFlags
& MID_FLAG_SPECIAL_ITEM_IMPORT
) ) ) )
430 // maybe it's one of our special context ids?
431 sal_Int16 nContextId
= maPropMapper
->GetEntryContextId(nIdx
);
433 for ( sal_Int32 n
= 0;
434 pSpecialContextIds
[n
].nContextID
!= -1;
437 // found: set index in pSpecialContextIds array
438 if ( pSpecialContextIds
[n
].nContextID
== nContextId
)
440 pSpecialContextIds
[n
].nIndex
= i
;
449 sal_Bool
SvXMLImportPropertyMapper::FillPropertySet(
450 const vector
< XMLPropertyState
>& aProperties
,
451 const Reference
< XPropertySet
> rPropSet
,
452 _ContextID_Index_Pair
* pSpecialContextIds
) const
454 sal_Bool bSet
= sal_False
;
456 Reference
< XTolerantMultiPropertySet
> xTolPropSet( rPropSet
, UNO_QUERY
);
457 if (xTolPropSet
.is())
458 bSet
= _FillTolerantMultiPropertySet( aProperties
, xTolPropSet
, maPropMapper
, rImport
,
459 pSpecialContextIds
);
463 // get property set info
464 Reference
< XPropertySetInfo
> xInfo(rPropSet
->getPropertySetInfo());
466 // check for multi-property set
467 Reference
<XMultiPropertySet
> xMultiPropSet( rPropSet
, UNO_QUERY
);
468 if ( xMultiPropSet
.is() )
470 // Try XMultiPropertySet. If that fails, try the regular route.
471 bSet
= _FillMultiPropertySet( aProperties
, xMultiPropSet
,
473 pSpecialContextIds
);
475 bSet
= _FillPropertySet( aProperties
, rPropSet
,
476 xInfo
, maPropMapper
, rImport
,
480 bSet
= _FillPropertySet( aProperties
, rPropSet
, xInfo
,
481 maPropMapper
, rImport
,
482 pSpecialContextIds
);
488 sal_Bool
SvXMLImportPropertyMapper::_FillPropertySet(
489 const vector
<XMLPropertyState
> & rProperties
,
490 const Reference
<XPropertySet
> & rPropSet
,
491 const Reference
<XPropertySetInfo
> & rPropSetInfo
,
492 const UniReference
<XMLPropertySetMapper
> & rPropMapper
,
493 SvXMLImport
& rImport
,
494 _ContextID_Index_Pair
* pSpecialContextIds
)
496 OSL_ENSURE( rPropSet
.is(), "need an XPropertySet" );
497 OSL_ENSURE( rPropSetInfo
.is(), "need an XPropertySetInfo" );
500 sal_Bool bSet
= sal_False
;
501 sal_Int32 nCount
= rProperties
.size();
503 // iterate over property states that we want to set
504 for( sal_Int32 i
=0; i
< nCount
; i
++ )
506 const XMLPropertyState
& rProp
= rProperties
[i
];
507 sal_Int32 nIdx
= rProp
.mnIndex
;
509 // disregard property state if it has an invalid index
513 const OUString
& rPropName
= rPropMapper
->GetEntryAPIName( nIdx
);
514 const sal_Int32 nPropFlags
= rPropMapper
->GetEntryFlags( nIdx
);
516 if ( ( 0 == ( nPropFlags
& MID_FLAG_NO_PROPERTY
) ) &&
517 ( ( 0 != ( nPropFlags
& MID_FLAG_MUST_EXIST
) ) ||
518 rPropSetInfo
->hasPropertyByName( rPropName
) ) )
520 // try setting the property
523 rPropSet
->setPropertyValue( rPropName
, rProp
.maValue
);
526 catch ( IllegalArgumentException
& e
)
528 // illegal value: check whether this property is
529 // allowed to throw this exception
530 if ( 0 == ( nPropFlags
& MID_FLAG_PROPERTY_MAY_EXCEPT
) )
532 Sequence
<OUString
> aSeq(1);
535 XMLERROR_STYLE_PROP_VALUE
| XMLERROR_FLAG_ERROR
,
536 aSeq
, e
.Message
, NULL
);
539 catch ( UnknownPropertyException
& e
)
541 // unknown property: This is always an error!
542 Sequence
<OUString
> aSeq(1);
545 XMLERROR_STYLE_PROP_UNKNOWN
| XMLERROR_FLAG_ERROR
,
546 aSeq
, e
.Message
, NULL
);
548 catch ( PropertyVetoException
& e
)
550 // property veto: this shouldn't happen
551 Sequence
<OUString
> aSeq(1);
554 XMLERROR_STYLE_PROP_OTHER
| XMLERROR_FLAG_ERROR
,
555 aSeq
, e
.Message
, NULL
);
557 catch ( WrappedTargetException
& e
)
559 // wrapped target: this shouldn't happen either
560 Sequence
<OUString
> aSeq(1);
563 XMLERROR_STYLE_PROP_OTHER
| XMLERROR_FLAG_ERROR
,
564 aSeq
, e
.Message
, NULL
);
568 // handle no-property and special items
569 if( ( pSpecialContextIds
!= NULL
) &&
570 ( ( 0 != ( nPropFlags
& MID_FLAG_NO_PROPERTY_IMPORT
) ) ||
571 ( 0 != ( nPropFlags
& MID_FLAG_SPECIAL_ITEM_IMPORT
) ) ) )
573 // maybe it's one of our special context ids?
574 sal_Int16 nContextId
= rPropMapper
->GetEntryContextId(nIdx
);
576 for ( sal_Int32 n
= 0;
577 pSpecialContextIds
[n
].nContextID
!= -1;
580 // found: set index in pSpecialContextIds array
581 if ( pSpecialContextIds
[n
].nContextID
== nContextId
)
583 pSpecialContextIds
[n
].nIndex
= i
;
595 typedef pair
<const OUString
*, const Any
* > PropertyPair
;
596 typedef vector
<PropertyPair
> PropertyPairs
;
598 struct PropertyPairLessFunctor
:
599 public binary_function
<PropertyPair
, PropertyPair
, bool>
601 bool operator()( const PropertyPair
& a
, const PropertyPair
& b
) const
603 return (*a
.first
< *b
.first
? true : false);
607 void SvXMLImportPropertyMapper::_PrepareForMultiPropertySet(
608 const vector
<XMLPropertyState
> & rProperties
,
609 const Reference
<XPropertySetInfo
> & rPropSetInfo
,
610 const UniReference
<XMLPropertySetMapper
> & rPropMapper
,
611 _ContextID_Index_Pair
* pSpecialContextIds
,
612 Sequence
<OUString
>& rNames
,
613 Sequence
<Any
>& rValues
)
615 sal_Int32 nCount
= rProperties
.size();
617 // property pairs structure stores names + values of properties to be set.
618 PropertyPairs aPropertyPairs
;
619 aPropertyPairs
.reserve( nCount
);
621 // iterate over property states that we want to set
623 for( i
= 0; i
< nCount
; i
++ )
625 const XMLPropertyState
& rProp
= rProperties
[i
];
626 sal_Int32 nIdx
= rProp
.mnIndex
;
628 // disregard property state if it has an invalid index
632 const OUString
& rPropName
= rPropMapper
->GetEntryAPIName( nIdx
);
633 const sal_Int32 nPropFlags
= rPropMapper
->GetEntryFlags( nIdx
);
635 if ( ( 0 == ( nPropFlags
& MID_FLAG_NO_PROPERTY
) ) &&
636 ( ( 0 != ( nPropFlags
& MID_FLAG_MUST_EXIST
) ) ||
637 !rPropSetInfo
.is() ||
638 (rPropSetInfo
.is() && rPropSetInfo
->hasPropertyByName( rPropName
)) ) )
640 // save property into property pair structure
641 aPropertyPairs
.push_back( PropertyPair( &rPropName
, &rProp
.maValue
) );
644 // handle no-property and special items
645 if( ( pSpecialContextIds
!= NULL
) &&
646 ( ( 0 != ( nPropFlags
& MID_FLAG_NO_PROPERTY_IMPORT
) ) ||
647 ( 0 != ( nPropFlags
& MID_FLAG_SPECIAL_ITEM_IMPORT
) ) ) )
649 // maybe it's one of our special context ids?
650 sal_Int16 nContextId
= rPropMapper
->GetEntryContextId(nIdx
);
651 for ( sal_Int32 n
= 0;
652 pSpecialContextIds
[n
].nContextID
!= -1;
655 // found: set index in pSpecialContextIds array
656 if ( pSpecialContextIds
[n
].nContextID
== nContextId
)
658 pSpecialContextIds
[n
].nIndex
= i
;
665 // We now need to construct the sequences and actually the set
668 // sort the property pairs
669 sort( aPropertyPairs
.begin(), aPropertyPairs
.end(),
670 PropertyPairLessFunctor());
673 rNames
.realloc( aPropertyPairs
.size() );
674 OUString
* pNamesArray
= rNames
.getArray();
675 rValues
.realloc( aPropertyPairs
.size() );
676 Any
* pValuesArray
= rValues
.getArray();
678 // copy values into sequences
680 for( PropertyPairs::iterator aIter
= aPropertyPairs
.begin();
681 aIter
!= aPropertyPairs
.end();
684 pNamesArray
[i
] = *(aIter
->first
);
685 pValuesArray
[i
++] = *(aIter
->second
);
689 sal_Bool
SvXMLImportPropertyMapper::_FillMultiPropertySet(
690 const vector
<XMLPropertyState
> & rProperties
,
691 const Reference
<XMultiPropertySet
> & rMultiPropSet
,
692 const Reference
<XPropertySetInfo
> & rPropSetInfo
,
693 const UniReference
<XMLPropertySetMapper
> & rPropMapper
,
694 _ContextID_Index_Pair
* pSpecialContextIds
)
696 OSL_ENSURE( rMultiPropSet
.is(), "Need multi property set. ");
697 OSL_ENSURE( rPropSetInfo
.is(), "Need property set info." );
699 sal_Bool bSuccessful
= sal_False
;
701 Sequence
<OUString
> aNames
;
702 Sequence
<Any
> aValues
;
704 _PrepareForMultiPropertySet(rProperties
, rPropSetInfo
, rPropMapper
, pSpecialContextIds
,
707 // and, finally, try to set the values
710 rMultiPropSet
->setPropertyValues( aNames
, aValues
);
711 bSuccessful
= sal_True
;
715 OSL_ENSURE(bSuccessful
, "Exception caught; style may not be imported correctly.");
721 sal_Bool
SvXMLImportPropertyMapper::_FillTolerantMultiPropertySet(
722 const vector
<XMLPropertyState
> & rProperties
,
723 const Reference
<XTolerantMultiPropertySet
> & rTolMultiPropSet
,
724 const UniReference
<XMLPropertySetMapper
> & rPropMapper
,
725 SvXMLImport
& rImport
,
726 _ContextID_Index_Pair
* pSpecialContextIds
)
728 OSL_ENSURE( rTolMultiPropSet
.is(), "Need tolerant multi property set. ");
730 sal_Bool bSuccessful
= sal_False
;
732 Sequence
<OUString
> aNames
;
733 Sequence
<Any
> aValues
;
735 _PrepareForMultiPropertySet(rProperties
, Reference
<XPropertySetInfo
>(NULL
), rPropMapper
, pSpecialContextIds
,
738 // and, finally, try to set the values
741 Sequence
< SetPropertyTolerantFailed
> aResults(rTolMultiPropSet
->setPropertyValuesTolerant( aNames
, aValues
));
742 if (aResults
.getLength() == 0)
743 bSuccessful
= sal_True
;
746 sal_Int32
nCount(aResults
.getLength());
747 for( sal_Int32 i
= 0; i
< nCount
; ++i
)
749 Sequence
<OUString
> aSeq(1);
750 aSeq
[0] = aResults
[i
].Name
;
751 rtl::OUString sMessage
;
752 switch (aResults
[i
].Result
)
754 case TolerantPropertySetResultType::UNKNOWN_PROPERTY
:
755 sMessage
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UNKNOWN_PROPERTY"));
757 case TolerantPropertySetResultType::ILLEGAL_ARGUMENT
:
758 sMessage
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ILLEGAL_ARGUMENT"));
760 case TolerantPropertySetResultType::PROPERTY_VETO
:
761 sMessage
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PROPERTY_VETO"));
763 case TolerantPropertySetResultType::WRAPPED_TARGET
:
764 sMessage
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WRAPPED_TARGET"));
768 XMLERROR_STYLE_PROP_OTHER
| XMLERROR_FLAG_ERROR
,
769 aSeq
, sMessage
, NULL
);
775 OSL_ENSURE(bSuccessful
, "Exception caught; style may not be imported correctly.");
781 void SvXMLImportPropertyMapper::finished(
782 vector
< XMLPropertyState
>& rProperties
,
783 sal_Int32 nStartIndex
, sal_Int32 nEndIndex
) const
785 // nothing to do here
786 if( mxNextMapper
.is() )
787 mxNextMapper
->finished( rProperties
, nStartIndex
, nEndIndex
);