tdf#161878 Ignore nested SYMBOL field inside IF field
[LibreOffice.git] / include / xmloff / xmlimppr.hxx
blob1f537a322eea2750bef344a46bfcddd4afa341ba
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 #if defined __GNUC__ // gcc does not like visibility annotation on enum
43 namespace com::sun::star::drawing { enum class FillStyle; }
44 #else
45 namespace com::sun::star::drawing { enum class SAL_DLLPUBLIC_RTTI FillStyle; }
46 #endif
48 struct XMLPropertyState;
49 class XMLPropertySetMapper;
52 class SvXMLUnitConverter;
53 class SvXMLNamespaceMap;
54 class SvXMLImport;
56 /** This struct is used as an optional parameter to the static
57 * _FillPropertySet() methods.
59 * It should not be used in any other context.
61 struct ContextID_Index_Pair
63 sal_Int16 /*const*/ nContextID;
64 sal_Int32 nIndex;
65 css::drawing::FillStyle /*const*/ nExpectedFillStyle;
68 class XMLOFF_DLLPUBLIC SvXMLImportPropertyMapper : public salhelper::SimpleReferenceObject
70 rtl::Reference< SvXMLImportPropertyMapper> mxNextMapper;
72 SvXMLImport& m_rImport; // access to error handling
74 SvXMLImportPropertyMapper(SvXMLImportPropertyMapper const &) = delete;
75 SvXMLImportPropertyMapper& operator =(SvXMLImportPropertyMapper const &) = delete;
77 protected:
79 rtl::Reference< XMLPropertySetMapper > maPropMapper;
80 SvXMLImport& GetImport() const { return m_rImport;}
82 public:
84 SvXMLImportPropertyMapper(
85 rtl::Reference< XMLPropertySetMapper > xMapper,
86 SvXMLImport& rImport);
87 virtual ~SvXMLImportPropertyMapper() override;
89 // Add an ImportPropertyMapper at the end of the import mapper chain.
90 // The added mapper MUST not be used outside the Mapper chain any longer,
91 // because its PropertyMapper will be replaced.
92 void ChainImportMapper(
93 const rtl::Reference< SvXMLImportPropertyMapper>& rMapper );
95 /** fills the given itemset with the attributes in the given list
96 * the map is only searched within the range
97 * [nStartIdx, nEndIdx[
99 void importXML(
100 ::std::vector< XMLPropertyState >& rProperties,
101 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
102 const SvXMLUnitConverter& rUnitConverter,
103 const SvXMLNamespaceMap& rNamespaceMap,
104 sal_uInt32 nPropType,
105 sal_Int32 nStartIdx, sal_Int32 nEndIdx ) const;
107 /** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_IMPORT flag set */
108 virtual bool handleSpecialItem(
109 XMLPropertyState& rProperty,
110 ::std::vector< XMLPropertyState >& rProperties,
111 const OUString& rValue,
112 const SvXMLUnitConverter& rUnitConverter,
113 const SvXMLNamespaceMap& rNamespaceMap ) const;
115 /** This method is called when all attributes have benn processed. It may be used to remove items that are incomplete */
116 virtual void finished(
117 ::std::vector< XMLPropertyState >& rProperties,
118 sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const;
120 void CheckSpecialContext(
121 const ::std::vector< XMLPropertyState >& rProperties,
122 const css::uno::Reference< css::beans::XPropertySet >& rPropSet,
123 ContextID_Index_Pair* pSpecialContextIds ) const;
125 bool FillPropertySet(
126 const ::std::vector< XMLPropertyState >& rProperties,
127 const css::uno::Reference< css::beans::XPropertySet >& rPropSet,
128 ContextID_Index_Pair* pSpecialContextIds = nullptr ) const;
130 void FillPropertySequence(
131 const ::std::vector< XMLPropertyState >& aProperties,
132 css::uno::Sequence< css::beans::PropertyValue >& rValues )
133 const;
135 inline const rtl::Reference< XMLPropertySetMapper >&
136 getPropertySetMapper() const;
139 /** implementation helper for FillPropertySet: fill an XPropertySet.
140 * Exceptions will be asserted. */
141 static bool FillPropertySet_(
142 const ::std::vector<XMLPropertyState> & rProperties,
143 const css::uno::Reference< css::beans::XPropertySet> & rPropSet,
144 const css::uno::Reference< css::beans::XPropertySetInfo> & rPropSetInfo,
145 const rtl::Reference<XMLPropertySetMapper> & rPropMapper,
146 SvXMLImport& rImport,
148 // parameter for use by txtstyli.cxx; allows efficient
149 // catching the combined characters property
150 ContextID_Index_Pair* pSpecialContextIds );
152 /** implementation helper for FillPropertySet: fill an XMultiPropertySet.
153 * If unsuccessful, set return value. */
154 static bool FillMultiPropertySet_(
155 const ::std::vector<XMLPropertyState> & rProperties,
156 const css::uno::Reference< css::beans::XMultiPropertySet> & rMultiPropSet,
157 const css::uno::Reference< css::beans::XPropertySetInfo> & rPropSetInfo,
158 const rtl::Reference<XMLPropertySetMapper> & rPropMapper,
160 // parameters for use by txtstyli.cxx; allows efficient
161 // catching the combined characters property
162 ContextID_Index_Pair* pSpecialContextIds );
164 /** implementation helper for FillPropertySet: fill an XTolerantMultiPropertySet.
165 * If unsuccessful, set return value. */
166 static bool FillTolerantMultiPropertySet_(
167 const ::std::vector<XMLPropertyState> & rProperties,
168 const css::uno::Reference< css::beans::XTolerantMultiPropertySet> & rTolPropSet,
169 const rtl::Reference<XMLPropertySetMapper> & rPropMapper,
170 SvXMLImport& rImport,
172 // parameters for use by txtstyli.cxx; allows efficient
173 // catching the combined characters property
174 ContextID_Index_Pair* pSpecialContextIds );
177 static void PrepareForMultiPropertySet_(
178 const ::std::vector<XMLPropertyState> & rProperties,
179 const css::uno::Reference< css::beans::XPropertySetInfo> & rPropSetInfo,
180 const rtl::Reference<XMLPropertySetMapper> & rPropMapper,
181 ContextID_Index_Pair* pSpecialContextIds,
182 css::uno::Sequence< OUString >& rNames,
183 css::uno::Sequence< css::uno::Any >& rValues);
185 private:
186 void importXMLAttribute(
187 std::vector< XMLPropertyState >& rProperties,
188 const SvXMLUnitConverter& rUnitConverter,
189 const SvXMLNamespaceMap& rNamespaceMap,
190 sal_uInt32 nPropType,
191 sal_Int32 nStartIdx,
192 sal_Int32 nEndIdx,
193 css::uno::Reference< css::container::XNameContainer >& xAttrContainer,
194 const OUString& sAttrName,
195 const OUString& aNamespaceURI,
196 const OUString& sValue) const;
200 inline const rtl::Reference< XMLPropertySetMapper >&
201 SvXMLImportPropertyMapper::getPropertySetMapper() const
203 return maPropMapper;
206 namespace xmloff {
208 bool IsIgnoreFillStyleNamedItem(
209 css::uno::Reference<css::beans::XPropertySet> const& xProps,
210 css::drawing::FillStyle nExpectedFillStyle);
214 #endif // INCLUDED_XMLOFF_XMLIMPPR_HXX
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */