Bump version to 6.4-15
[LibreOffice.git] / include / xmloff / xmlimppr.hxx
blobde10dd3b7b108ed23203dd835e1921bb0017feb9
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 { namespace sun { namespace star { namespace beans { class XMultiPropertySet; } } } }
32 namespace com { namespace sun { namespace star { namespace beans { class XPropertySet; } } } }
33 namespace com { namespace sun { namespace star { namespace beans { class XPropertySetInfo; } } } }
34 namespace com { namespace sun { namespace star { namespace beans { class XTolerantMultiPropertySet; } } } }
35 namespace com { namespace sun { namespace star { namespace beans { struct PropertyValue; } } } }
36 namespace com { namespace sun { namespace star { namespace uno { class Any; } } } }
37 namespace com { namespace sun { namespace star { namespace uno { template <typename > class Reference; } } } }
38 namespace com { namespace sun { namespace star { namespace uno { template <typename > class Sequence; } } } }
39 namespace com { namespace sun { namespace star { namespace xml { namespace sax { class XAttributeList; } } } } }
41 struct XMLPropertyState;
42 class XMLPropertySetMapper;
45 class SvXMLUnitConverter;
46 class SvXMLNamespaceMap;
47 class SvXMLImport;
49 /** This struct is used as an optional parameter to the static
50 * _FillPropertySet() methods.
52 * It should not be used in any other context.
54 struct ContextID_Index_Pair
56 sal_Int16 nContextID;
57 sal_Int32 nIndex;
60 class XMLOFF_DLLPUBLIC SvXMLImportPropertyMapper : public salhelper::SimpleReferenceObject
62 rtl::Reference< SvXMLImportPropertyMapper> mxNextMapper;
64 SvXMLImport& rImport; // access to error handling
66 SvXMLImportPropertyMapper(SvXMLImportPropertyMapper const &) = delete;
67 SvXMLImportPropertyMapper& operator =(SvXMLImportPropertyMapper const &) = delete;
69 protected:
71 rtl::Reference< XMLPropertySetMapper > maPropMapper;
72 SvXMLImport& GetImport() const { return rImport;}
74 public:
76 SvXMLImportPropertyMapper(
77 const rtl::Reference< XMLPropertySetMapper >& rMapper,
78 SvXMLImport& rImport);
79 virtual ~SvXMLImportPropertyMapper() override;
81 // Add an ImportPropertyMapper at the end of the import mapper chain.
82 // The added mapper MUST not be used outside the Mapper chain any longer,
83 // because its PropertyMapper will be replaced.
84 void ChainImportMapper(
85 const rtl::Reference< SvXMLImportPropertyMapper>& rMapper );
87 /** fills the given itemset with the attributes in the given list
88 * the map is only searched within the range
89 * [nStartIdx, nEndIdx[
91 void importXML(
92 ::std::vector< XMLPropertyState >& rProperties,
93 const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList,
94 const SvXMLUnitConverter& rUnitConverter,
95 const SvXMLNamespaceMap& rNamespaceMap,
96 sal_uInt32 nPropType,
97 sal_Int32 nStartIdx, sal_Int32 nEndIdx ) const;
99 /** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_IMPORT flag set */
100 virtual bool handleSpecialItem(
101 XMLPropertyState& rProperty,
102 ::std::vector< XMLPropertyState >& rProperties,
103 const OUString& rValue,
104 const SvXMLUnitConverter& rUnitConverter,
105 const SvXMLNamespaceMap& rNamespaceMap ) const;
107 /** This method is called when all attributes have benn processed. It may be used to remove items that are incomplete */
108 virtual void finished(
109 ::std::vector< XMLPropertyState >& rProperties,
110 sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const;
112 void CheckSpecialContext(
113 const ::std::vector< XMLPropertyState >& rProperties,
114 const css::uno::Reference< css::beans::XPropertySet >& rPropSet,
115 ContextID_Index_Pair* pSpecialContextIds ) const;
117 bool FillPropertySet(
118 const ::std::vector< XMLPropertyState >& rProperties,
119 const css::uno::Reference< css::beans::XPropertySet >& rPropSet,
120 ContextID_Index_Pair* pSpecialContextIds = nullptr ) const;
122 void FillPropertySequence(
123 const ::std::vector< XMLPropertyState >& aProperties,
124 css::uno::Sequence< css::beans::PropertyValue >& rValues )
125 const;
127 inline const rtl::Reference< XMLPropertySetMapper >&
128 getPropertySetMapper() const;
131 /** implementation helper for FillPropertySet: fill an XPropertySet.
132 * Exceptions will be asserted. */
133 static bool FillPropertySet_(
134 const ::std::vector<XMLPropertyState> & rProperties,
135 const css::uno::Reference< css::beans::XPropertySet> & rPropSet,
136 const css::uno::Reference< css::beans::XPropertySetInfo> & rPropSetInfo,
137 const rtl::Reference<XMLPropertySetMapper> & rPropMapper,
138 SvXMLImport& rImport,
140 // parameter for use by txtstyli.cxx; allows efficient
141 // catching the combined characters property
142 ContextID_Index_Pair* pSpecialContextIds );
144 /** implementation helper for FillPropertySet: fill an XMultiPropertySet.
145 * If unsuccessful, set return value. */
146 static bool FillMultiPropertySet_(
147 const ::std::vector<XMLPropertyState> & rProperties,
148 const css::uno::Reference< css::beans::XMultiPropertySet> & rMultiPropSet,
149 const css::uno::Reference< css::beans::XPropertySetInfo> & rPropSetInfo,
150 const rtl::Reference<XMLPropertySetMapper> & rPropMapper,
152 // parameters for use by txtstyli.cxx; allows efficient
153 // catching the combined characters property
154 ContextID_Index_Pair* pSpecialContextIds );
156 /** implementation helper for FillPropertySet: fill an XTolerantMultiPropertySet.
157 * If unsuccessful, set return value. */
158 static bool FillTolerantMultiPropertySet_(
159 const ::std::vector<XMLPropertyState> & rProperties,
160 const css::uno::Reference< css::beans::XTolerantMultiPropertySet> & rTolPropSet,
161 const rtl::Reference<XMLPropertySetMapper> & rPropMapper,
162 SvXMLImport& rImport,
164 // parameters for use by txtstyli.cxx; allows efficient
165 // catching the combined characters property
166 ContextID_Index_Pair* pSpecialContextIds );
169 static void PrepareForMultiPropertySet_(
170 const ::std::vector<XMLPropertyState> & rProperties,
171 const css::uno::Reference< css::beans::XPropertySetInfo> & rPropSetInfo,
172 const rtl::Reference<XMLPropertySetMapper> & rPropMapper,
173 ContextID_Index_Pair* pSpecialContextIds,
174 css::uno::Sequence< OUString >& rNames,
175 css::uno::Sequence< css::uno::Any >& rValues);
179 inline const rtl::Reference< XMLPropertySetMapper >&
180 SvXMLImportPropertyMapper::getPropertySetMapper() const
182 return maPropMapper;
185 #endif // INCLUDED_XMLOFF_XMLIMPPR_HXX
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */