Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _XMLOFF_XMLIMPPR_HXX
29 : : #define _XMLOFF_XMLIMPPR_HXX
30 : :
31 : : #include "sal/config.h"
32 : : #include "xmloff/dllapi.h"
33 : : #include "sal/types.h"
34 : : #include <tools/solar.h>
35 : : #include <com/sun/star/xml/sax/XAttributeList.hpp>
36 : : #include <com/sun/star/beans/XPropertySet.hpp>
37 : : #include <com/sun/star/beans/PropertyValue.hpp>
38 : : #include <com/sun/star/beans/XMultiPropertySet.hpp>
39 : : #include <com/sun/star/beans/XTolerantMultiPropertySet.hpp>
40 : :
41 : : #include <vector>
42 : : #include <xmloff/uniref.hxx>
43 : :
44 : : struct XMLPropertyState;
45 : : class XMLPropertySetMapper;
46 : :
47 : : namespace rtl { class OUString; }
48 : :
49 : : class SvXMLUnitConverter;
50 : : class SvXMLNamespaceMap;
51 : : class SvXMLImport;
52 : :
53 : : /** This struct is used as an optional parameter to the static
54 : : * _FillPropertySet() methods.
55 : : *
56 : : * It should not be used in any other context.
57 : : */
58 : : struct _ContextID_Index_Pair
59 : : {
60 : : sal_Int16 nContextID;
61 : : sal_Int32 nIndex;
62 : : };
63 : :
64 : : class XMLOFF_DLLPUBLIC SvXMLImportPropertyMapper : public UniRefBase
65 : : {
66 : : UniReference< SvXMLImportPropertyMapper> mxNextMapper;
67 : :
68 : : SvXMLImport& rImport; // access to error handling
69 : :
70 : : SAL_DLLPRIVATE SvXMLImportPropertyMapper(SvXMLImportPropertyMapper &);
71 : : // not defined
72 : : SAL_DLLPRIVATE void operator =(SvXMLImportPropertyMapper &); // not defined
73 : :
74 : : protected:
75 : :
76 : : UniReference< XMLPropertySetMapper > maPropMapper;
77 : : SvXMLImport& GetImport() const { return rImport;}
78 : :
79 : : public:
80 : :
81 : : SvXMLImportPropertyMapper(
82 : : const UniReference< XMLPropertySetMapper >& rMapper,
83 : : SvXMLImport& rImport);
84 : : virtual ~SvXMLImportPropertyMapper();
85 : :
86 : : // Add a ImportPropertyMapper at the end of the import mapper chain.
87 : : // The added mapper MUST not be used outside the Mapper chain any longer,
88 : : // because its PropertyMapper will be replaced.
89 : : void ChainImportMapper(
90 : : const UniReference< SvXMLImportPropertyMapper>& rMapper );
91 : :
92 : : /** fills the given itemset with the attributes in the given list
93 : : * the map is only searched within the range
94 : : * [nStartIdx, nEndIdx[
95 : : */
96 : : void importXML(
97 : : ::std::vector< XMLPropertyState >& rProperties,
98 : : ::com::sun::star::uno::Reference<
99 : : ::com::sun::star::xml::sax::XAttributeList > xAttrList,
100 : : const SvXMLUnitConverter& rUnitConverter,
101 : : const SvXMLNamespaceMap& rNamespaceMap,
102 : : sal_uInt32 nPropType,
103 : : sal_Int32 nStartIdx, sal_Int32 nEndIdx ) const;
104 : :
105 : : /** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_IMPORT flag set */
106 : : virtual bool handleSpecialItem(
107 : : XMLPropertyState& rProperty,
108 : : ::std::vector< XMLPropertyState >& rProperties,
109 : : const ::rtl::OUString& rValue,
110 : : const SvXMLUnitConverter& rUnitConverter,
111 : : const SvXMLNamespaceMap& rNamespaceMap ) const;
112 : :
113 : : /** This method is called when all attributes have benn processed. It may be used to remove items that are incomplete */
114 : : virtual void finished(
115 : : ::std::vector< XMLPropertyState >& rProperties,
116 : : sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const;
117 : :
118 : : void CheckSpecialContext(
119 : : const ::std::vector< XMLPropertyState >& aProperties,
120 : : const ::com::sun::star::uno::Reference<
121 : : ::com::sun::star::beans::XPropertySet > rPropSet,
122 : : _ContextID_Index_Pair* pSpecialContextIds ) const;
123 : :
124 : : sal_Bool FillPropertySet(
125 : : const ::std::vector< XMLPropertyState >& aProperties,
126 : : const ::com::sun::star::uno::Reference<
127 : : ::com::sun::star::beans::XPropertySet > rPropSet,
128 : : _ContextID_Index_Pair* pSpecialContextIds = NULL ) const;
129 : :
130 : : void FillPropertySequence(
131 : : const ::std::vector< XMLPropertyState >& aProperties,
132 : : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rValues )
133 : : const;
134 : :
135 : : inline const UniReference< XMLPropertySetMapper >&
136 : : getPropertySetMapper() const;
137 : :
138 : :
139 : :
140 : : /** implementation helper for FillPropertySet: fill an XPropertySet.
141 : : * Exceptions will be asserted. */
142 : : static sal_Bool _FillPropertySet(
143 : : const ::std::vector<XMLPropertyState> & rProperties,
144 : : const ::com::sun::star::uno::Reference<
145 : : ::com::sun::star::beans::XPropertySet> & rPropSet,
146 : : const ::com::sun::star::uno::Reference<
147 : : ::com::sun::star::beans::XPropertySetInfo> & rPropSetInfo,
148 : : const UniReference<XMLPropertySetMapper> & rPropMapper,
149 : : SvXMLImport& rImport,
150 : :
151 : : // parameter for use by txtstyli.cxx; allows efficient
152 : : // catching the combined characters property
153 : : _ContextID_Index_Pair* pSpecialContextIds = NULL );
154 : :
155 : : /** implementation helper for FillPropertySet: fill an XMultiPropertySet.
156 : : * If unsuccessul, set return value. */
157 : : static sal_Bool _FillMultiPropertySet(
158 : : const ::std::vector<XMLPropertyState> & rProperties,
159 : : const ::com::sun::star::uno::Reference<
160 : : ::com::sun::star::beans::XMultiPropertySet> & rMultiPropSet,
161 : : const ::com::sun::star::uno::Reference<
162 : : ::com::sun::star::beans::XPropertySetInfo> & rPropSetInfo,
163 : : const UniReference<XMLPropertySetMapper> & rPropMapper,
164 : :
165 : : // parameters for use by txtstyli.cxx; allows efficient
166 : : // catching the combined characters property
167 : : _ContextID_Index_Pair* pSpecialContextIds = NULL );
168 : :
169 : : /** implementation helper for FillPropertySet: fill an XTolerantMultiPropertySet.
170 : : * If unsuccessul, set return value. */
171 : : static sal_Bool _FillTolerantMultiPropertySet(
172 : : const ::std::vector<XMLPropertyState> & rProperties,
173 : : const ::com::sun::star::uno::Reference<
174 : : ::com::sun::star::beans::XTolerantMultiPropertySet> & rTolPropSet,
175 : : const UniReference<XMLPropertySetMapper> & rPropMapper,
176 : : SvXMLImport& rImport,
177 : :
178 : : // parameters for use by txtstyli.cxx; allows efficient
179 : : // catching the combined characters property
180 : : _ContextID_Index_Pair* pSpecialContextIds = NULL );
181 : :
182 : :
183 : : static void _PrepareForMultiPropertySet(
184 : : const ::std::vector<XMLPropertyState> & rProperties,
185 : : const ::com::sun::star::uno::Reference<
186 : : ::com::sun::star::beans::XPropertySetInfo> & rPropSetInfo,
187 : : const UniReference<XMLPropertySetMapper> & rPropMapper,
188 : : _ContextID_Index_Pair* pSpecialContextIds,
189 : : ::com::sun::star::uno::Sequence< ::rtl::OUString >& rNames,
190 : : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rValues);
191 : : };
192 : :
193 : :
194 : : inline const UniReference< XMLPropertySetMapper >&
195 : 6829 : SvXMLImportPropertyMapper::getPropertySetMapper() const
196 : : {
197 : 6829 : return maPropMapper;
198 : : }
199 : :
200 : : #endif // _XMLOFF_XMLIMPPR_HXX
201 : :
202 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|