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 <salhelper/simplereferenceobject.hxx>
26 #include <o3tl/typed_flags_set.hxx>
27 #include <rtl/ustring.hxx>
32 namespace com::sun::star::uno
{ template <typename
> class Reference
; }
33 namespace com::sun::star::beans
{ class XPropertySet
; }
34 namespace rtl
{ template <class reference_type
> class Reference
; }
36 class XMLPropertySetMapper
;
37 struct XMLPropertyState
;
39 enum class SvXmlExportFlags
{
45 template<> struct typed_flags
<SvXmlExportFlags
> : is_typed_flags
<SvXmlExportFlags
, 0x08> {};
48 class SvXMLUnitConverter
;
49 namespace comphelper
{ class AttributeList
; }
50 class SvXMLNamespaceMap
;
53 class XMLOFF_DLLPUBLIC SvXMLExportPropertyMapper
: public salhelper::SimpleReferenceObject
56 std::unique_ptr
<Impl
> mpImpl
;
60 /** Filter all properties we don't want to export:
61 Take all properties of the XPropertySet which are also found in the
62 XMLPropertyMapEntry-array and which are not set directly (so, the value isn't
63 default and isn't inherited, apart from bDefault is true)
64 After this process It'll called 'Contextfilter' for application-specific
66 std::vector
<XMLPropertyState
> Filter_(
67 SvXMLExport
const& rExport
,
68 const css::uno::Reference
<css::beans::XPropertySet
>& rPropSet
,
69 bool bDefault
, bool bDisableFoFontFamily
) const;
71 /** Application-specific filter. By default do nothing. */
72 virtual void ContextFilter(
73 bool bEnableFoFontFamily
,
74 ::std::vector
< XMLPropertyState
>& rProperties
,
75 const css::uno::Reference
<css::beans::XPropertySet
>& rPropSet
) const;
77 /** fills the given attribute list with the items in the given set */
78 void _exportXML( sal_uInt16 nPropType
, sal_uInt16
& rPropTypeFlags
,
79 comphelper::AttributeList
& rAttrList
,
80 const ::std::vector
< XMLPropertyState
>& rProperties
,
81 const SvXMLUnitConverter
& rUnitConverter
,
82 const SvXMLNamespaceMap
& rNamespaceMap
,
83 std::vector
<sal_uInt16
>* pIndexArray
,
84 sal_Int32 nPropMapStartIdx
, sal_Int32 nPropMapEndIdx
) const;
86 void _exportXML( comphelper::AttributeList
& rAttrList
,
87 const XMLPropertyState
& rProperty
,
88 const SvXMLUnitConverter
& rUnitConverter
,
89 const SvXMLNamespaceMap
& rNamespaceMap
,
90 const ::std::vector
< XMLPropertyState
> *pProperties
,
91 sal_uInt32 nIdx
) const;
93 void exportElementItems(
95 const ::std::vector
< XMLPropertyState
>& rProperties
,
96 SvXmlExportFlags nFlags
,
97 const std::vector
<sal_uInt16
>& rIndexArray
) const;
101 SvXMLExportPropertyMapper(
102 const rtl::Reference
< XMLPropertySetMapper
>& rMapper
);
103 virtual ~SvXMLExportPropertyMapper() override
;
105 // Add a ExportPropertyMapper at the end of the import mapper chain.
106 // The added mapper MUST not be used outside the Mapper chain any longer,
107 // because its PropertyMapper will be replaced.
108 void ChainExportMapper(
109 const rtl::Reference
< SvXMLExportPropertyMapper
>& rMapper
);
111 /** Filter all properties we don't want to export:
112 Take all properties of the XPropertySet which are also found in the
113 XMLPropertyMapEntry-array and which are not set directly (so, the value isn't
114 default and isn't inherited)
115 After this process It'll called 'Contextfilter' for application-specific
117 std::vector
<XMLPropertyState
> Filter(
118 SvXMLExport
const& rExport
,
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 SvXMLExport
const& rExport
,
128 const css::uno::Reference
<css::beans::XPropertySet
>& rPropSet
) const;
130 /** Provides a partial ordering over two arrays of XMLPropertyState,
131 Partial because implementing a full order requires quite a lot of code. */
132 bool LessPartial( const ::std::vector
< XMLPropertyState
>& aProperties1
,
133 const ::std::vector
< XMLPropertyState
>& aProperties2
) const;
135 /** Compare two arrays of XMLPropertyState */
136 bool Equals( const ::std::vector
< XMLPropertyState
>& aProperties1
,
137 const ::std::vector
< XMLPropertyState
>& aProperties2
) const;
139 SvXMLExport
& rExport
,
140 const ::std::vector
< XMLPropertyState
>& rProperties
,
141 SvXmlExportFlags nFlags
,
142 bool bUseExtensionNamespaceForGraphicProperties
= false ) const;
144 /** like above but only properties whose property map index is within the
145 * specified range are exported
147 * @param bExtensionNamespace use the extension namespace for graphic-properties
150 SvXMLExport
& rExport
,
151 const ::std::vector
< XMLPropertyState
>& rProperties
,
152 sal_Int32 nPropMapStartIdx
, sal_Int32 nPropMapEndIdx
,
153 SvXmlExportFlags nFlags
, bool bExtensionNamespace
= false ) const;
155 /** this method is called for every item that has the
156 MID_FLAG_ELEMENT_EXPORT flag set */
157 virtual void handleElementItem(
158 SvXMLExport
& rExport
,
159 const XMLPropertyState
& rProperty
,
160 SvXmlExportFlags nFlags
,
161 const ::std::vector
< XMLPropertyState
> *pProperties
,
162 sal_uInt32 nIdx
) const;
164 /** this method is called for every item that has the
165 MID_FLAG_SPECIAL_ITEM_EXPORT flag set */
166 virtual void handleSpecialItem(
167 comphelper::AttributeList
& rAttrList
,
168 const XMLPropertyState
& rProperty
,
169 const SvXMLUnitConverter
& rUnitConverter
,
170 const SvXMLNamespaceMap
& rNamespaceMap
,
171 const ::std::vector
< XMLPropertyState
> *pProperties
,
172 sal_uInt32 nIdx
) const;
174 const rtl::Reference
<XMLPropertySetMapper
>& getPropertySetMapper() const;
176 void SetStyleName( const OUString
& rStyleName
);
177 const OUString
& GetStyleName() const;
180 #endif // INCLUDED_XMLOFF_XMLEXPPR_HXX
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */