1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_XMLOFF_XMLIMPPR_HXX
20 #define INCLUDED_XMLOFF_XMLIMPPR_HXX
22 #include <rtl/ref.hxx>
23 #include <sal/config.h>
24 #include <xmloff/dllapi.h>
25 #include <sal/types.h>
26 #include <rtl/ustring.hxx>
29 #include <salhelper/simplereferenceobject.hxx>
31 namespace com::sun::star::beans
{ class XMultiPropertySet
; }
32 namespace com::sun::star::beans
{ class XPropertySet
; }
33 namespace com::sun::star::beans
{ class XPropertySetInfo
; }
34 namespace com::sun::star::beans
{ class XTolerantMultiPropertySet
; }
35 namespace com::sun::star::beans
{ struct PropertyValue
; }
36 namespace com::sun::star::container
{ class XNameContainer
; }
37 namespace com::sun::star::uno
{ class Any
; }
38 namespace com::sun::star::uno
{ template <typename
> class Reference
; }
39 namespace com::sun::star::uno
{ template <typename
> class Sequence
; }
40 namespace com::sun::star::xml::sax
{ class XAttributeList
; }
41 namespace com::sun::star::xml::sax
{ class XFastAttributeList
; }
43 struct XMLPropertyState
;
44 class XMLPropertySetMapper
;
47 class SvXMLUnitConverter
;
48 class SvXMLNamespaceMap
;
51 /** This struct is used as an optional parameter to the static
52 * _FillPropertySet() methods.
54 * It should not be used in any other context.
56 struct ContextID_Index_Pair
62 class XMLOFF_DLLPUBLIC SvXMLImportPropertyMapper
: public salhelper::SimpleReferenceObject
64 rtl::Reference
< SvXMLImportPropertyMapper
> mxNextMapper
;
66 SvXMLImport
& rImport
; // access to error handling
68 SvXMLImportPropertyMapper(SvXMLImportPropertyMapper
const &) = delete;
69 SvXMLImportPropertyMapper
& operator =(SvXMLImportPropertyMapper
const &) = delete;
73 rtl::Reference
< XMLPropertySetMapper
> maPropMapper
;
74 SvXMLImport
& GetImport() const { return rImport
;}
78 SvXMLImportPropertyMapper(
79 const rtl::Reference
< XMLPropertySetMapper
>& rMapper
,
80 SvXMLImport
& rImport
);
81 virtual ~SvXMLImportPropertyMapper() override
;
83 // Add an ImportPropertyMapper at the end of the import mapper chain.
84 // The added mapper MUST not be used outside the Mapper chain any longer,
85 // because its PropertyMapper will be replaced.
86 void ChainImportMapper(
87 const rtl::Reference
< SvXMLImportPropertyMapper
>& rMapper
);
89 /** fills the given itemset with the attributes in the given list
90 * the map is only searched within the range
91 * [nStartIdx, nEndIdx[
94 ::std::vector
< XMLPropertyState
>& rProperties
,
95 const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
,
96 const SvXMLUnitConverter
& rUnitConverter
,
97 const SvXMLNamespaceMap
& rNamespaceMap
,
99 sal_Int32 nStartIdx
, sal_Int32 nEndIdx
) const;
101 /** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_IMPORT flag set */
102 virtual bool handleSpecialItem(
103 XMLPropertyState
& rProperty
,
104 ::std::vector
< XMLPropertyState
>& rProperties
,
105 const OUString
& rValue
,
106 const SvXMLUnitConverter
& rUnitConverter
,
107 const SvXMLNamespaceMap
& rNamespaceMap
) const;
109 /** This method is called when all attributes have benn processed. It may be used to remove items that are incomplete */
110 virtual void finished(
111 ::std::vector
< XMLPropertyState
>& rProperties
,
112 sal_Int32 nStartIndex
, sal_Int32 nEndIndex
) const;
114 void CheckSpecialContext(
115 const ::std::vector
< XMLPropertyState
>& rProperties
,
116 const css::uno::Reference
< css::beans::XPropertySet
>& rPropSet
,
117 ContextID_Index_Pair
* pSpecialContextIds
) const;
119 bool FillPropertySet(
120 const ::std::vector
< XMLPropertyState
>& rProperties
,
121 const css::uno::Reference
< css::beans::XPropertySet
>& rPropSet
,
122 ContextID_Index_Pair
* pSpecialContextIds
= nullptr ) const;
124 void FillPropertySequence(
125 const ::std::vector
< XMLPropertyState
>& aProperties
,
126 css::uno::Sequence
< css::beans::PropertyValue
>& rValues
)
129 inline const rtl::Reference
< XMLPropertySetMapper
>&
130 getPropertySetMapper() const;
133 /** implementation helper for FillPropertySet: fill an XPropertySet.
134 * Exceptions will be asserted. */
135 static bool FillPropertySet_(
136 const ::std::vector
<XMLPropertyState
> & rProperties
,
137 const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
,
138 const css::uno::Reference
< css::beans::XPropertySetInfo
> & rPropSetInfo
,
139 const rtl::Reference
<XMLPropertySetMapper
> & rPropMapper
,
140 SvXMLImport
& rImport
,
142 // parameter for use by txtstyli.cxx; allows efficient
143 // catching the combined characters property
144 ContextID_Index_Pair
* pSpecialContextIds
);
146 /** implementation helper for FillPropertySet: fill an XMultiPropertySet.
147 * If unsuccessful, set return value. */
148 static bool FillMultiPropertySet_(
149 const ::std::vector
<XMLPropertyState
> & rProperties
,
150 const css::uno::Reference
< css::beans::XMultiPropertySet
> & rMultiPropSet
,
151 const css::uno::Reference
< css::beans::XPropertySetInfo
> & rPropSetInfo
,
152 const rtl::Reference
<XMLPropertySetMapper
> & rPropMapper
,
154 // parameters for use by txtstyli.cxx; allows efficient
155 // catching the combined characters property
156 ContextID_Index_Pair
* pSpecialContextIds
);
158 /** implementation helper for FillPropertySet: fill an XTolerantMultiPropertySet.
159 * If unsuccessful, set return value. */
160 static bool FillTolerantMultiPropertySet_(
161 const ::std::vector
<XMLPropertyState
> & rProperties
,
162 const css::uno::Reference
< css::beans::XTolerantMultiPropertySet
> & rTolPropSet
,
163 const rtl::Reference
<XMLPropertySetMapper
> & rPropMapper
,
164 SvXMLImport
& rImport
,
166 // parameters for use by txtstyli.cxx; allows efficient
167 // catching the combined characters property
168 ContextID_Index_Pair
* pSpecialContextIds
);
171 static void PrepareForMultiPropertySet_(
172 const ::std::vector
<XMLPropertyState
> & rProperties
,
173 const css::uno::Reference
< css::beans::XPropertySetInfo
> & rPropSetInfo
,
174 const rtl::Reference
<XMLPropertySetMapper
> & rPropMapper
,
175 ContextID_Index_Pair
* pSpecialContextIds
,
176 css::uno::Sequence
< OUString
>& rNames
,
177 css::uno::Sequence
< css::uno::Any
>& rValues
);
180 void importXMLAttribute(
181 std::vector
< XMLPropertyState
>& rProperties
,
182 const SvXMLUnitConverter
& rUnitConverter
,
183 const SvXMLNamespaceMap
& rNamespaceMap
,
184 sal_uInt32 nPropType
,
187 css::uno::Reference
< css::container::XNameContainer
>& xAttrContainer
,
188 const OUString
& sAttrName
,
189 const OUString
& aNamespaceURI
,
190 const OUString
& sValue
) const;
194 inline const rtl::Reference
< XMLPropertySetMapper
>&
195 SvXMLImportPropertyMapper::getPropertySetMapper() const
200 #endif // INCLUDED_XMLOFF_XMLIMPPR_HXX
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */