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 <rtl/ref.hxx>
24 #include <sal/config.h>
25 #include <xmloff/dllapi.h>
26 #include <xmloff/xmlprmap.hxx>
27 #include <salhelper/simplereferenceobject.hxx>
28 #include <o3tl/typed_flags_set.hxx>
30 #include <com/sun/star/beans/XPropertySet.hpp>
32 enum class SvXmlExportFlags
{
34 DEFAULTS
= 0x0001, // export also default items
35 DEEP
= 0x0002, // export also items from
37 EMPTY
= 0x0004, // export attribs element
43 template<> struct typed_flags
<SvXmlExportFlags
> : is_typed_flags
<SvXmlExportFlags
, 0xf> {};
46 class SvXMLUnitConverter
;
47 class SvXMLAttributeList
;
48 class SvXMLNamespaceMap
;
49 class FilterPropertiesInfos_Impl
;
52 class XMLOFF_DLLPUBLIC SvXMLExportPropertyMapper
: public salhelper::SimpleReferenceObject
59 /** Filter all properties we don't want to export:
60 Take all properties of the XPropertySet which are also found in the
61 XMLPropertyMapEntry-array and which are not set directly (so, the value isn't
62 default and isn't inherited, apart from bDefault is true)
63 After this process It'll called 'Contextfilter' for application-specific
65 std::vector
<XMLPropertyState
> _Filter(
66 const css::uno::Reference
<css::beans::XPropertySet
>& rPropSet
,
67 bool bDefault
, bool bDisableFoFontFamily
) const;
69 /** Application-specific filter. By default do nothing. */
70 virtual void ContextFilter(
71 bool bEnableFoFontFamily
,
72 ::std::vector
< XMLPropertyState
>& rProperties
,
73 ::com::sun::star::uno::Reference
<
74 ::com::sun::star::beans::XPropertySet
> rPropSet
) const;
76 /** fills the given attribute list with the items in the given set */
77 void _exportXML( sal_uInt16 nPropType
, sal_uInt16
& rPropTypeFlags
,
78 SvXMLAttributeList
& rAttrList
,
79 const ::std::vector
< XMLPropertyState
>& rProperties
,
80 const SvXMLUnitConverter
& rUnitConverter
,
81 const SvXMLNamespaceMap
& rNamespaceMap
,
82 SvXmlExportFlags nFlags
,
83 std::vector
<sal_uInt16
>* pIndexArray
,
84 sal_Int32 nPropMapStartIdx
, sal_Int32 nPropMapEndIdx
) const;
86 void _exportXML( SvXMLAttributeList
& rAttrList
,
87 const XMLPropertyState
& rProperty
,
88 const SvXMLUnitConverter
& rUnitConverter
,
89 const SvXMLNamespaceMap
& rNamespaceMap
,
90 SvXmlExportFlags nFlags
,
91 const ::std::vector
< XMLPropertyState
> *pProperties
= 0,
92 sal_uInt32 nIdx
= 0 ) const;
94 void exportElementItems(
96 const ::std::vector
< XMLPropertyState
>& rProperties
,
97 SvXmlExportFlags nFlags
,
98 const std::vector
<sal_uInt16
>& rIndexArray
) const;
102 SvXMLExportPropertyMapper(
103 const rtl::Reference
< XMLPropertySetMapper
>& rMapper
);
104 virtual ~SvXMLExportPropertyMapper();
106 // Add a ExportPropertyMapper at the end of the import mapper chain.
107 // The added mapper MUST not be used outside the Mapper chain any longer,
108 // because its PropertyMapper will be replaced.
109 void ChainExportMapper(
110 const rtl::Reference
< SvXMLExportPropertyMapper
>& rMapper
);
112 /** Filter all properties we don't want to export:
113 Take all properties of the XPropertySet which are also found in the
114 XMLPropertyMapEntry-array and which are not set directly (so, the value isn't
115 default and isn't inherited)
116 After this process It'll called 'Contextfilter' for application-specific
118 std::vector
<XMLPropertyState
> Filter(
119 const css::uno::Reference
<css::beans::XPropertySet
>& rPropSet
, bool bEnableFoFontFamily
= false ) const;
121 /** Like Filter(), except that:
122 * - only properties that have the map flag MID_FLAG_DEFAULT_ITEM_EXPORT
124 * - instead of the property's value, its default value is exported.
126 std::vector
<XMLPropertyState
> FilterDefaults(
127 const css::uno::Reference
<css::beans::XPropertySet
>& rPropSet
, bool bEnableFoFontFamily
= false ) const;
129 /** Compare to arrays of XMLPropertyState */
130 bool Equals( const ::std::vector
< XMLPropertyState
>& aProperties1
,
131 const ::std::vector
< XMLPropertyState
>& aProperties2
) const;
133 /** fills the given attribute list with the items in the given set
136 SvXMLAttributeList
& rAttrList
,
137 const ::std::vector
< XMLPropertyState
>& rProperties
,
138 const SvXMLUnitConverter
& rUnitConverter
,
139 const SvXMLNamespaceMap
& rNamespaceMap
,
140 SvXmlExportFlags nFlags
= SvXmlExportFlags::NONE
) const;
141 /** like above but only properties whose property map index is within the
142 specified range are exported */
144 SvXMLAttributeList
& rAttrList
,
145 const ::std::vector
< XMLPropertyState
>& rProperties
,
146 const SvXMLUnitConverter
& rUnitConverter
,
147 const SvXMLNamespaceMap
& rNamespaceMap
,
148 sal_Int32 nPropMapStartIdx
, sal_Int32 nPropMapEndIdx
,
149 SvXmlExportFlags nFlags
= SvXmlExportFlags::NONE
) const;
152 SvXMLExport
& rExport
,
153 const ::std::vector
< XMLPropertyState
>& rProperties
,
154 SvXmlExportFlags nFlags
= SvXmlExportFlags::NONE
,
155 bool bUseExtensionNamespaceForGraphicProperties
= false ) const;
157 /** like above but only properties whose property map index is within the
158 * specified range are exported
160 * @param bExtensionNamespace use the extension namespace for graphic-properties
163 SvXMLExport
& rExport
,
164 const ::std::vector
< XMLPropertyState
>& rProperties
,
165 sal_Int32 nPropMapStartIdx
, sal_Int32 nPropMapEndIdx
,
166 SvXmlExportFlags nFlags
= SvXmlExportFlags::NONE
, bool bExtensionNamespace
= false ) const;
168 /** this method is called for every item that has the
169 MID_FLAG_ELEMENT_EXPORT flag set */
170 virtual void handleElementItem(
171 SvXMLExport
& rExport
,
172 const XMLPropertyState
& rProperty
,
173 SvXmlExportFlags nFlags
,
174 const ::std::vector
< XMLPropertyState
> *pProperties
= 0,
175 sal_uInt32 nIdx
= 0 ) const;
177 /** this method is called for every item that has the
178 MID_FLAG_SPECIAL_ITEM_EXPORT flag set */
179 virtual void handleSpecialItem(
180 SvXMLAttributeList
& rAttrList
,
181 const XMLPropertyState
& rProperty
,
182 const SvXMLUnitConverter
& rUnitConverter
,
183 const SvXMLNamespaceMap
& rNamespaceMap
,
184 const ::std::vector
< XMLPropertyState
> *pProperties
= 0,
185 sal_uInt32 nIdx
= 0 ) const;
187 const rtl::Reference
<XMLPropertySetMapper
>& getPropertySetMapper() const;
189 void SetStyleName( const OUString
& rStyleName
);
190 const OUString
& GetStyleName() const;
193 #endif // INCLUDED_XMLOFF_XMLEXPPR_HXX
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */