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 :
20 : #ifndef _XMLOFF_XMLEXPPR_HXX
21 : #define _XMLOFF_XMLEXPPR_HXX
22 :
23 : #include "sal/config.h"
24 : #include "xmloff/dllapi.h"
25 : #include <xmloff/xmlprmap.hxx>
26 : #include <xmloff/uniref.hxx>
27 :
28 :
29 : class SvXMLUnitConverter;
30 : class SvXMLAttributeList;
31 : class SvXMLNamespaceMap;
32 : class FilterPropertiesInfos_Impl;
33 : class SvXMLExport;
34 :
35 : #define XML_EXPORT_FLAG_DEFAULTS 0x0001 // export also default items
36 : #define XML_EXPORT_FLAG_DEEP 0x0002 // export also items from
37 : // parent item sets
38 : #define XML_EXPORT_FLAG_EMPTY 0x0004 // export attribs element
39 : // even if its empty
40 : #define XML_EXPORT_FLAG_IGN_WS 0x0008
41 :
42 : class XMLOFF_DLLPUBLIC SvXMLExportPropertyMapper : public UniRefBase
43 : {
44 : UniReference< SvXMLExportPropertyMapper> mxNextMapper;
45 :
46 : FilterPropertiesInfos_Impl *pCache;
47 :
48 : protected:
49 : UniReference< XMLPropertySetMapper > maPropMapper;
50 :
51 : OUString maStyleName;
52 :
53 : /** Filter all properties we don't want to export:
54 : Take all properties of the XPropertySet which are also found in the
55 : XMLPropertyMapEntry-array and which are not set directly (so, the value isn't
56 : default and isn't inherited, apart from bDefault is true)
57 : After this process It'll called 'Contextfilter' for application-specific
58 : filter-processes. */
59 : ::std::vector< XMLPropertyState > _Filter(
60 : const ::com::sun::star::uno::Reference<
61 : ::com::sun::star::beans::XPropertySet > rPropSet,
62 : const sal_Bool bDefault ) const;
63 :
64 : /** Application-specific filter. By default do nothing. */
65 : virtual void ContextFilter(
66 : ::std::vector< XMLPropertyState >& rProperties,
67 : ::com::sun::star::uno::Reference<
68 : ::com::sun::star::beans::XPropertySet > rPropSet ) const;
69 :
70 : /** fills the given attribute list with the items in the given set */
71 : void _exportXML( sal_uInt16 nPropType, sal_uInt16& rPropTypeFlags,
72 : SvXMLAttributeList& rAttrList,
73 : const ::std::vector< XMLPropertyState >& rProperties,
74 : const SvXMLUnitConverter& rUnitConverter,
75 : const SvXMLNamespaceMap& rNamespaceMap,
76 : sal_uInt16 nFlags,
77 : std::vector<sal_uInt16>* pIndexArray,
78 : sal_Int32 nPropMapStartIdx, sal_Int32 nPropMapEndIdx ) const;
79 :
80 : void _exportXML( SvXMLAttributeList& rAttrList,
81 : const XMLPropertyState& rProperty,
82 : const SvXMLUnitConverter& rUnitConverter,
83 : const SvXMLNamespaceMap& rNamespaceMap,
84 : sal_uInt16 nFlags,
85 : const ::std::vector< XMLPropertyState > *pProperties = 0,
86 : sal_uInt32 nIdx = 0 ) const;
87 :
88 : void exportElementItems(
89 : SvXMLExport& rExport,
90 : const ::std::vector< XMLPropertyState >& rProperties,
91 : sal_uInt16 nFlags,
92 : const std::vector<sal_uInt16>& rIndexArray ) const;
93 :
94 : public:
95 :
96 : SvXMLExportPropertyMapper(
97 : const UniReference< XMLPropertySetMapper >& rMapper );
98 : virtual ~SvXMLExportPropertyMapper();
99 :
100 : // Add a ExportPropertyMapper at the end of the import mapper chain.
101 : // The added mapper MUST not be used outside the Mapper chain any longer,
102 : // because its PropertyMapper will be replaced.
103 : void ChainExportMapper(
104 : const UniReference< SvXMLExportPropertyMapper>& rMapper );
105 :
106 : /** Filter all properties we don't want to export:
107 : Take all properties of the XPropertySet which are also found in the
108 : XMLPropertyMapEntry-array and which are not set directly (so, the value isn't
109 : default and isn't inherited)
110 : After this process It'll called 'Contextfilter' for application-specific
111 : filter-processes. */
112 3378 : ::std::vector< XMLPropertyState > Filter(
113 : const ::com::sun::star::uno::Reference<
114 : ::com::sun::star::beans::XPropertySet > rPropSet ) const
115 3378 : { return _Filter(rPropSet, sal_False); }
116 :
117 : /** Like Filter(), except that:
118 : * - only properties that have the map flag MID_FLAG_DEFAULT_ITEM_EXPORT
119 : * set are exported,
120 : * - instead of the property's value, its default value is exported.
121 : */
122 96 : ::std::vector< XMLPropertyState > FilterDefaults(
123 : const ::com::sun::star::uno::Reference<
124 : ::com::sun::star::beans::XPropertySet > rPropSet ) const
125 96 : { return _Filter(rPropSet, sal_True); }
126 :
127 : /** Compare to arrays of XMLPropertyState */
128 : sal_Bool Equals( const ::std::vector< XMLPropertyState >& aProperties1,
129 : const ::std::vector< XMLPropertyState >& aProperties2 ) const;
130 :
131 : /** fills the given attribute list with the items in the given set */
132 : void exportXML(
133 : SvXMLAttributeList& rAttrList,
134 : const ::std::vector< XMLPropertyState >& rProperties,
135 : const SvXMLUnitConverter& rUnitConverter,
136 : const SvXMLNamespaceMap& rNamespaceMap,
137 : sal_uInt16 nFlags = 0 ) const;
138 : /** like above but only properties whose property map index is within the
139 : specified range are exported */
140 : void exportXML(
141 : SvXMLAttributeList& rAttrList,
142 : const ::std::vector< XMLPropertyState >& rProperties,
143 : const SvXMLUnitConverter& rUnitConverter,
144 : const SvXMLNamespaceMap& rNamespaceMap,
145 : sal_Int32 nPropMapStartIdx, sal_Int32 nPropMapEndIdx,
146 : sal_uInt16 nFlags = 0 ) const;
147 :
148 : void exportXML(
149 : SvXMLExport& rExport,
150 : const ::std::vector< XMLPropertyState >& rProperties,
151 : sal_uInt16 nFlags = 0 ) const;
152 :
153 : /** like above but only properties whose property map index is within the
154 : specified range are exported */
155 : void exportXML(
156 : SvXMLExport& rExport,
157 : const ::std::vector< XMLPropertyState >& rProperties,
158 : sal_Int32 nPropMapStartIdx, sal_Int32 nPropMapEndIdx,
159 : sal_uInt16 nFlags = 0 ) const;
160 :
161 : /** this method is called for every item that has the
162 : MID_FLAG_ELEMENT_EXPORT flag set */
163 : virtual void handleElementItem(
164 : SvXMLExport& rExport,
165 : const XMLPropertyState& rProperty,
166 : sal_uInt16 nFlags,
167 : const ::std::vector< XMLPropertyState > *pProperties = 0,
168 : sal_uInt32 nIdx = 0 ) const;
169 :
170 : /** this method is called for every item that has the
171 : MID_FLAG_SPECIAL_ITEM_EXPORT flag set */
172 : virtual void handleSpecialItem(
173 : SvXMLAttributeList& rAttrList,
174 : const XMLPropertyState& rProperty,
175 : const SvXMLUnitConverter& rUnitConverter,
176 : const SvXMLNamespaceMap& rNamespaceMap,
177 : const ::std::vector< XMLPropertyState > *pProperties = 0,
178 : sal_uInt32 nIdx = 0 ) const;
179 :
180 : inline const UniReference< XMLPropertySetMapper >&
181 18367 : getPropertySetMapper() const { return maPropMapper; }
182 :
183 708 : void SetStyleName( const OUString& rStyleName ) { maStyleName = rStyleName; }
184 : };
185 :
186 : #endif // _XMLOFF_XMLEXPPR_HXX
187 :
188 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|