Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_XMLOFF_XMLIMPPR_HXX
20 : #define INCLUDED_XMLOFF_XMLIMPPR_HXX
21 :
22 : #include <sal/config.h>
23 : #include <xmloff/dllapi.h>
24 : #include <sal/types.h>
25 : #include <com/sun/star/xml/sax/XAttributeList.hpp>
26 : #include <com/sun/star/beans/XPropertySet.hpp>
27 : #include <com/sun/star/beans/PropertyValue.hpp>
28 : #include <com/sun/star/beans/XMultiPropertySet.hpp>
29 : #include <com/sun/star/beans/XTolerantMultiPropertySet.hpp>
30 :
31 : #include <vector>
32 : #include <xmloff/uniref.hxx>
33 :
34 : struct XMLPropertyState;
35 : class XMLPropertySetMapper;
36 :
37 :
38 : class SvXMLUnitConverter;
39 : class SvXMLNamespaceMap;
40 : class SvXMLImport;
41 :
42 : /** This struct is used as an optional parameter to the static
43 : * _FillPropertySet() methods.
44 : *
45 : * It should not be used in any other context.
46 : */
47 : struct _ContextID_Index_Pair
48 : {
49 : sal_Int16 nContextID;
50 : sal_Int32 nIndex;
51 : };
52 :
53 : class XMLOFF_DLLPUBLIC SvXMLImportPropertyMapper : public UniRefBase
54 : {
55 : UniReference< SvXMLImportPropertyMapper> mxNextMapper;
56 :
57 : SvXMLImport& rImport; // access to error handling
58 :
59 : SAL_DLLPRIVATE SvXMLImportPropertyMapper(SvXMLImportPropertyMapper &);
60 : // not defined
61 : SAL_DLLPRIVATE void operator =(SvXMLImportPropertyMapper &); // not defined
62 :
63 : protected:
64 :
65 : UniReference< XMLPropertySetMapper > maPropMapper;
66 0 : SvXMLImport& GetImport() const { return rImport;}
67 :
68 : public:
69 :
70 : SvXMLImportPropertyMapper(
71 : const UniReference< XMLPropertySetMapper >& rMapper,
72 : SvXMLImport& rImport);
73 : virtual ~SvXMLImportPropertyMapper();
74 :
75 : // Add a ImportPropertyMapper at the end of the import mapper chain.
76 : // The added mapper MUST not be used outside the Mapper chain any longer,
77 : // because its PropertyMapper will be replaced.
78 : void ChainImportMapper(
79 : const UniReference< SvXMLImportPropertyMapper>& rMapper );
80 :
81 : /** fills the given itemset with the attributes in the given list
82 : * the map is only searched within the range
83 : * [nStartIdx, nEndIdx[
84 : */
85 : void importXML(
86 : ::std::vector< XMLPropertyState >& rProperties,
87 : ::com::sun::star::uno::Reference<
88 : ::com::sun::star::xml::sax::XAttributeList > xAttrList,
89 : const SvXMLUnitConverter& rUnitConverter,
90 : const SvXMLNamespaceMap& rNamespaceMap,
91 : sal_uInt32 nPropType,
92 : sal_Int32 nStartIdx, sal_Int32 nEndIdx ) const;
93 :
94 : /** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_IMPORT flag set */
95 : virtual bool handleSpecialItem(
96 : XMLPropertyState& rProperty,
97 : ::std::vector< XMLPropertyState >& rProperties,
98 : const OUString& rValue,
99 : const SvXMLUnitConverter& rUnitConverter,
100 : const SvXMLNamespaceMap& rNamespaceMap ) const;
101 :
102 : /** This method is called when all attributes have benn processed. It may be used to remove items that are incomplete */
103 : virtual void finished(
104 : ::std::vector< XMLPropertyState >& rProperties,
105 : sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const;
106 :
107 : void CheckSpecialContext(
108 : const ::std::vector< XMLPropertyState >& aProperties,
109 : const ::com::sun::star::uno::Reference<
110 : ::com::sun::star::beans::XPropertySet > rPropSet,
111 : _ContextID_Index_Pair* pSpecialContextIds ) const;
112 :
113 : bool FillPropertySet(
114 : const ::std::vector< XMLPropertyState >& aProperties,
115 : const ::com::sun::star::uno::Reference<
116 : ::com::sun::star::beans::XPropertySet > rPropSet,
117 : _ContextID_Index_Pair* pSpecialContextIds = NULL ) const;
118 :
119 : void FillPropertySequence(
120 : const ::std::vector< XMLPropertyState >& aProperties,
121 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rValues )
122 : const;
123 :
124 : inline const UniReference< XMLPropertySetMapper >&
125 : getPropertySetMapper() const;
126 :
127 :
128 :
129 : /** implementation helper for FillPropertySet: fill an XPropertySet.
130 : * Exceptions will be asserted. */
131 : static bool _FillPropertySet(
132 : const ::std::vector<XMLPropertyState> & rProperties,
133 : const ::com::sun::star::uno::Reference<
134 : ::com::sun::star::beans::XPropertySet> & rPropSet,
135 : const ::com::sun::star::uno::Reference<
136 : ::com::sun::star::beans::XPropertySetInfo> & rPropSetInfo,
137 : const UniReference<XMLPropertySetMapper> & rPropMapper,
138 : SvXMLImport& rImport,
139 :
140 : // parameter for use by txtstyli.cxx; allows efficient
141 : // catching the combined characters property
142 : _ContextID_Index_Pair* pSpecialContextIds = NULL );
143 :
144 : /** implementation helper for FillPropertySet: fill an XMultiPropertySet.
145 : * If unsuccessul, set return value. */
146 : static bool _FillMultiPropertySet(
147 : const ::std::vector<XMLPropertyState> & rProperties,
148 : const ::com::sun::star::uno::Reference<
149 : ::com::sun::star::beans::XMultiPropertySet> & rMultiPropSet,
150 : const ::com::sun::star::uno::Reference<
151 : ::com::sun::star::beans::XPropertySetInfo> & rPropSetInfo,
152 : const UniReference<XMLPropertySetMapper> & rPropMapper,
153 :
154 : // parameters for use by txtstyli.cxx; allows efficient
155 : // catching the combined characters property
156 : _ContextID_Index_Pair* pSpecialContextIds = NULL );
157 :
158 : /** implementation helper for FillPropertySet: fill an XTolerantMultiPropertySet.
159 : * If unsuccessul, set return value. */
160 : static bool _FillTolerantMultiPropertySet(
161 : const ::std::vector<XMLPropertyState> & rProperties,
162 : const ::com::sun::star::uno::Reference<
163 : ::com::sun::star::beans::XTolerantMultiPropertySet> & rTolPropSet,
164 : const UniReference<XMLPropertySetMapper> & rPropMapper,
165 : SvXMLImport& rImport,
166 :
167 : // parameters for use by txtstyli.cxx; allows efficient
168 : // catching the combined characters property
169 : _ContextID_Index_Pair* pSpecialContextIds = NULL );
170 :
171 :
172 : static void _PrepareForMultiPropertySet(
173 : const ::std::vector<XMLPropertyState> & rProperties,
174 : const ::com::sun::star::uno::Reference<
175 : ::com::sun::star::beans::XPropertySetInfo> & rPropSetInfo,
176 : const UniReference<XMLPropertySetMapper> & rPropMapper,
177 : _ContextID_Index_Pair* pSpecialContextIds,
178 : ::com::sun::star::uno::Sequence< OUString >& rNames,
179 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rValues);
180 : };
181 :
182 :
183 : inline const UniReference< XMLPropertySetMapper >&
184 0 : SvXMLImportPropertyMapper::getPropertySetMapper() const
185 : {
186 0 : return maPropMapper;
187 : }
188 :
189 : #endif // INCLUDED_XMLOFF_XMLIMPPR_HXX
190 :
191 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|