1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #ifndef INCLUDED_XMLOFF_XMLEXPPR_HXX
21 #define INCLUDED_XMLOFF_XMLEXPPR_HXX
23 #include <sal/config.h>
24 #include <xmloff/dllapi.h>
25 #include <xmloff/xmlprmap.hxx>
26 #include <xmloff/uniref.hxx>
29 class SvXMLUnitConverter
;
30 class SvXMLAttributeList
;
31 class SvXMLNamespaceMap
;
32 class FilterPropertiesInfos_Impl
;
35 #define XML_EXPORT_FLAG_DEFAULTS 0x0001 // export also default items
36 #define XML_EXPORT_FLAG_DEEP 0x0002 // export also items from
38 #define XML_EXPORT_FLAG_EMPTY 0x0004 // export attribs element
40 #define XML_EXPORT_FLAG_IGN_WS 0x0008
42 class XMLOFF_DLLPUBLIC SvXMLExportPropertyMapper
: public UniRefBase
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
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;
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;
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
,
74 std::vector
<sal_uInt16
>* pIndexArray
,
75 sal_Int32 nPropMapStartIdx
, sal_Int32 nPropMapEndIdx
) const;
77 void _exportXML( SvXMLAttributeList
& rAttrList
,
78 const XMLPropertyState
& rProperty
,
79 const SvXMLUnitConverter
& rUnitConverter
,
80 const SvXMLNamespaceMap
& rNamespaceMap
,
82 const ::std::vector
< XMLPropertyState
> *pProperties
= 0,
83 sal_uInt32 nIdx
= 0 ) const;
85 void exportElementItems(
87 const ::std::vector
< XMLPropertyState
>& rProperties
,
89 const std::vector
<sal_uInt16
>& rIndexArray
) const;
93 SvXMLExportPropertyMapper(
94 const UniReference
< XMLPropertySetMapper
>& rMapper
);
95 virtual ~SvXMLExportPropertyMapper();
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
);
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
109 ::std::vector
< XMLPropertyState
> Filter(
110 const ::com::sun::star::uno::Reference
<
111 ::com::sun::star::beans::XPropertySet
> rPropSet
, bool bEnableFoFontFamily
= false) const
112 { return _Filter(rPropSet
, false, bEnableFoFontFamily
); }
114 /** Like Filter(), except that:
115 * - only properties that have the map flag MID_FLAG_DEFAULT_ITEM_EXPORT
117 * - instead of the property's value, its default value is exported.
119 ::std::vector
< XMLPropertyState
> FilterDefaults(
120 const ::com::sun::star::uno::Reference
<
121 ::com::sun::star::beans::XPropertySet
> rPropSet
, bool bEnableFoFontFamily
= false) const
122 { return _Filter(rPropSet
, true, bEnableFoFontFamily
); }
124 /** Compare to arrays of XMLPropertyState */
125 sal_Bool
Equals( const ::std::vector
< XMLPropertyState
>& aProperties1
,
126 const ::std::vector
< XMLPropertyState
>& aProperties2
) const;
128 /** fills the given attribute list with the items in the given set */
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 */
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;
146 SvXMLExport
& rExport
,
147 const ::std::vector
< XMLPropertyState
>& rProperties
,
148 sal_uInt16 nFlags
= 0 ) const;
150 /** like above but only properties whose property map index is within the
151 specified range are exported */
153 SvXMLExport
& rExport
,
154 const ::std::vector
< XMLPropertyState
>& rProperties
,
155 sal_Int32 nPropMapStartIdx
, sal_Int32 nPropMapEndIdx
,
156 sal_uInt16 nFlags
= 0 ) const;
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
,
164 const ::std::vector
< XMLPropertyState
> *pProperties
= 0,
165 sal_uInt32 nIdx
= 0 ) const;
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;
177 const UniReference
<XMLPropertySetMapper
>& getPropertySetMapper() const;
179 void SetStyleName( const OUString
& rStyleName
);
180 const OUString
& GetStyleName() const;
183 #endif // INCLUDED_XMLOFF_XMLEXPPR_HXX
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */