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
{ namespace sun
{ namespace star
{ namespace uno
{ template <typename
> class Reference
; } } } }
33 namespace com
{ namespace sun
{ namespace star
{ namespace 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 class SvXMLAttributeList
;
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 const css::uno::Reference
<css::beans::XPropertySet
>& rPropSet
,
68 bool bDefault
, bool bDisableFoFontFamily
) const;
70 /** Application-specific filter. By default do nothing. */
71 virtual void ContextFilter(
72 bool bEnableFoFontFamily
,
73 ::std::vector
< XMLPropertyState
>& rProperties
,
74 const css::uno::Reference
<css::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 std::vector
<sal_uInt16
>* pIndexArray
,
83 sal_Int32 nPropMapStartIdx
, sal_Int32 nPropMapEndIdx
) const;
85 void _exportXML( SvXMLAttributeList
& rAttrList
,
86 const XMLPropertyState
& rProperty
,
87 const SvXMLUnitConverter
& rUnitConverter
,
88 const SvXMLNamespaceMap
& rNamespaceMap
,
89 const ::std::vector
< XMLPropertyState
> *pProperties
,
90 sal_uInt32 nIdx
) const;
92 void exportElementItems(
94 const ::std::vector
< XMLPropertyState
>& rProperties
,
95 SvXmlExportFlags nFlags
,
96 const std::vector
<sal_uInt16
>& rIndexArray
) const;
100 SvXMLExportPropertyMapper(
101 const rtl::Reference
< XMLPropertySetMapper
>& rMapper
);
102 virtual ~SvXMLExportPropertyMapper() override
;
104 // Add a ExportPropertyMapper at the end of the import mapper chain.
105 // The added mapper MUST not be used outside the Mapper chain any longer,
106 // because its PropertyMapper will be replaced.
107 void ChainExportMapper(
108 const rtl::Reference
< SvXMLExportPropertyMapper
>& rMapper
);
110 /** Filter all properties we don't want to export:
111 Take all properties of the XPropertySet which are also found in the
112 XMLPropertyMapEntry-array and which are not set directly (so, the value isn't
113 default and isn't inherited)
114 After this process It'll called 'Contextfilter' for application-specific
116 std::vector
<XMLPropertyState
> Filter(
117 const css::uno::Reference
<css::beans::XPropertySet
>& rPropSet
, bool bEnableFoFontFamily
= false ) const;
119 /** Like Filter(), except that:
120 * - only properties that have the map flag MID_FLAG_DEFAULT_ITEM_EXPORT
122 * - instead of the property's value, its default value is exported.
124 std::vector
<XMLPropertyState
> FilterDefaults(
125 const css::uno::Reference
<css::beans::XPropertySet
>& rPropSet
) const;
127 /** Provides a partial ordering over two arrays of XMLPropertyState,
128 Partial because implementing a full order requires quite a lot of code. */
129 bool LessPartial( const ::std::vector
< XMLPropertyState
>& aProperties1
,
130 const ::std::vector
< XMLPropertyState
>& aProperties2
) const;
132 /** Compare two arrays of XMLPropertyState */
133 bool Equals( const ::std::vector
< XMLPropertyState
>& aProperties1
,
134 const ::std::vector
< XMLPropertyState
>& aProperties2
) const;
136 SvXMLExport
& rExport
,
137 const ::std::vector
< XMLPropertyState
>& rProperties
,
138 SvXmlExportFlags nFlags
,
139 bool bUseExtensionNamespaceForGraphicProperties
= false ) const;
141 /** like above but only properties whose property map index is within the
142 * specified range are exported
144 * @param bExtensionNamespace use the extension namespace for graphic-properties
147 SvXMLExport
& rExport
,
148 const ::std::vector
< XMLPropertyState
>& rProperties
,
149 sal_Int32 nPropMapStartIdx
, sal_Int32 nPropMapEndIdx
,
150 SvXmlExportFlags nFlags
, bool bExtensionNamespace
= false ) const;
152 /** this method is called for every item that has the
153 MID_FLAG_ELEMENT_EXPORT flag set */
154 virtual void handleElementItem(
155 SvXMLExport
& rExport
,
156 const XMLPropertyState
& rProperty
,
157 SvXmlExportFlags nFlags
,
158 const ::std::vector
< XMLPropertyState
> *pProperties
,
159 sal_uInt32 nIdx
) const;
161 /** this method is called for every item that has the
162 MID_FLAG_SPECIAL_ITEM_EXPORT flag set */
163 virtual void handleSpecialItem(
164 SvXMLAttributeList
& rAttrList
,
165 const XMLPropertyState
& rProperty
,
166 const SvXMLUnitConverter
& rUnitConverter
,
167 const SvXMLNamespaceMap
& rNamespaceMap
,
168 const ::std::vector
< XMLPropertyState
> *pProperties
,
169 sal_uInt32 nIdx
) const;
171 const rtl::Reference
<XMLPropertySetMapper
>& getPropertySetMapper() const;
173 void SetStyleName( const OUString
& rStyleName
);
174 const OUString
& GetStyleName() const;
177 #endif // INCLUDED_XMLOFF_XMLEXPPR_HXX
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */