Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / xmloff / xmlimppr.hxx
blobadfba4eadc609e38bd919aa25f492f388bfb7097
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
28 #include <vector>
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; }
42 namespace com::sun::star::drawing { enum class SAL_DLLPUBLIC_RTTI FillStyle; }
44 struct XMLPropertyState;
45 class XMLPropertySetMapper;
48 class SvXMLUnitConverter;
49 class SvXMLNamespaceMap;
50 class SvXMLImport;
52 /** This struct is used as an optional parameter to the static
53 * _FillPropertySet() methods.
55 * It should not be used in any other context.
57 struct ContextID_Index_Pair
59 sal_Int16 /*const*/ nContextID;
60 sal_Int32 nIndex;
61 css::drawing::FillStyle /*const*/ nExpectedFillStyle;
64 class XMLOFF_DLLPUBLIC SvXMLImportPropertyMapper : public salhelper::SimpleReferenceObject
66 rtl::Reference< SvXMLImportPropertyMapper> mxNextMapper;
68 SvXMLImport& m_rImport; // access to error handling
70 SvXMLImportPropertyMapper(SvXMLImportPropertyMapper const &) = delete;
71 SvXMLImportPropertyMapper& operator =(SvXMLImportPropertyMapper const &) = delete;
73 protected:
75 rtl::Reference< XMLPropertySetMapper > maPropMapper;
76 SvXMLImport& GetImport() const { return m_rImport;}
78 public:
80 SvXMLImportPropertyMapper(
81 rtl::Reference< XMLPropertySetMapper > xMapper,
82 SvXMLImport& rImport);
83 virtual ~SvXMLImportPropertyMapper() override;
85 // Add an ImportPropertyMapper at the end of the import mapper chain.
86 // The added mapper MUST not be used outside the Mapper chain any longer,
87 // because its PropertyMapper will be replaced.
88 void ChainImportMapper(
89 const rtl::Reference< SvXMLImportPropertyMapper>& rMapper );
91 /** fills the given itemset with the attributes in the given list
92 * the map is only searched within the range
93 * [nStartIdx, nEndIdx[
95 void importXML(
96 ::std::vector< XMLPropertyState >& rProperties,
97 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
98 const SvXMLUnitConverter& rUnitConverter,
99 const SvXMLNamespaceMap& rNamespaceMap,
100 sal_uInt32 nPropType,
101 sal_Int32 nStartIdx, sal_Int32 nEndIdx ) const;
103 /** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_IMPORT flag set */
104 virtual bool handleSpecialItem(
105 XMLPropertyState& rProperty,
106 ::std::vector< XMLPropertyState >& rProperties,
107 const OUString& rValue,
108 const SvXMLUnitConverter& rUnitConverter,
109 const SvXMLNamespaceMap& rNamespaceMap ) const;
111 /** This method is called when all attributes have benn processed. It may be used to remove items that are incomplete */
112 virtual void finished(
113 ::std::vector< XMLPropertyState >& rProperties,
114 sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const;
116 void CheckSpecialContext(
117 const ::std::vector< XMLPropertyState >& rProperties,
118 const css::uno::Reference< css::beans::XPropertySet >& rPropSet,
119 ContextID_Index_Pair* pSpecialContextIds ) const;
121 bool FillPropertySet(
122 const ::std::vector< XMLPropertyState >& rProperties,
123 const css::uno::Reference< css::beans::XPropertySet >& rPropSet,
124 ContextID_Index_Pair* pSpecialContextIds = nullptr ) const;
126 void FillPropertySequence(
127 const ::std::vector< XMLPropertyState >& aProperties,
128 css::uno::Sequence< css::beans::PropertyValue >& rValues )
129 const;
131 inline const rtl::Reference< XMLPropertySetMapper >&
132 getPropertySetMapper() const;
135 /** implementation helper for FillPropertySet: fill an XPropertySet.
136 * Exceptions will be asserted. */
137 static bool FillPropertySet_(
138 const ::std::vector<XMLPropertyState> & rProperties,
139 const css::uno::Reference< css::beans::XPropertySet> & rPropSet,
140 const css::uno::Reference< css::beans::XPropertySetInfo> & rPropSetInfo,
141 const rtl::Reference<XMLPropertySetMapper> & rPropMapper,
142 SvXMLImport& rImport,
144 // parameter for use by txtstyli.cxx; allows efficient
145 // catching the combined characters property
146 ContextID_Index_Pair* pSpecialContextIds );
148 /** implementation helper for FillPropertySet: fill an XMultiPropertySet.
149 * If unsuccessful, set return value. */
150 static bool FillMultiPropertySet_(
151 const ::std::vector<XMLPropertyState> & rProperties,
152 const css::uno::Reference< css::beans::XMultiPropertySet> & rMultiPropSet,
153 const css::uno::Reference< css::beans::XPropertySetInfo> & rPropSetInfo,
154 const rtl::Reference<XMLPropertySetMapper> & rPropMapper,
156 // parameters for use by txtstyli.cxx; allows efficient
157 // catching the combined characters property
158 ContextID_Index_Pair* pSpecialContextIds );
160 /** implementation helper for FillPropertySet: fill an XTolerantMultiPropertySet.
161 * If unsuccessful, set return value. */
162 static bool FillTolerantMultiPropertySet_(
163 const ::std::vector<XMLPropertyState> & rProperties,
164 const css::uno::Reference< css::beans::XTolerantMultiPropertySet> & rTolPropSet,
165 const rtl::Reference<XMLPropertySetMapper> & rPropMapper,
166 SvXMLImport& rImport,
168 // parameters for use by txtstyli.cxx; allows efficient
169 // catching the combined characters property
170 ContextID_Index_Pair* pSpecialContextIds );
173 static void PrepareForMultiPropertySet_(
174 const ::std::vector<XMLPropertyState> & rProperties,
175 const css::uno::Reference< css::beans::XPropertySetInfo> & rPropSetInfo,
176 const rtl::Reference<XMLPropertySetMapper> & rPropMapper,
177 ContextID_Index_Pair* pSpecialContextIds,
178 css::uno::Sequence< OUString >& rNames,
179 css::uno::Sequence< css::uno::Any >& rValues);
181 private:
182 void importXMLAttribute(
183 std::vector< XMLPropertyState >& rProperties,
184 const SvXMLUnitConverter& rUnitConverter,
185 const SvXMLNamespaceMap& rNamespaceMap,
186 sal_uInt32 nPropType,
187 sal_Int32 nStartIdx,
188 sal_Int32 nEndIdx,
189 css::uno::Reference< css::container::XNameContainer >& xAttrContainer,
190 const OUString& sAttrName,
191 const OUString& aNamespaceURI,
192 const OUString& sValue) const;
196 inline const rtl::Reference< XMLPropertySetMapper >&
197 SvXMLImportPropertyMapper::getPropertySetMapper() const
199 return maPropMapper;
202 namespace xmloff {
204 bool IsIgnoreFillStyleNamedItem(
205 css::uno::Reference<css::beans::XPropertySet> const& xProps,
206 css::drawing::FillStyle nExpectedFillStyle);
210 #endif // INCLUDED_XMLOFF_XMLIMPPR_HXX
212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */