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