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 .
22 #include <sal/types.h>
23 #include <rtl/ustring.hxx>
24 #include <rtl/ref.hxx>
30 #include <comphelper/stl_types.hxx>
32 #include <xmloff/maptype.hxx>
33 #include <xmloff/xmlexppr.hxx>
34 #include <AutoStyleEntry.hxx>
36 class SvXMLAutoStylePoolP
;
37 class XMLAutoStylePoolParent
;
38 struct XMLAutoStyleFamily
;
39 class SvXMLExportPropertyMapper
;
41 enum class XmlStyleFamily
;
43 // Properties of a pool
45 class XMLAutoStylePoolProperties
48 ::std::vector
< XMLPropertyState
> maProperties
;
53 XMLAutoStylePoolProperties( XMLAutoStyleFamily
& rFamilyData
, std::vector
< XMLPropertyState
>&& rProperties
, OUString
const & rParentname
);
55 const OUString
& GetName() const { return msName
; }
56 const ::std::vector
< XMLPropertyState
>& GetProperties() const { return maProperties
; }
57 sal_uInt32
GetPos() const { return mnPos
; }
59 void SetName( const OUString
& rNew
) { msName
= rNew
; }
62 // Parents of AutoStylePool's
63 class XMLAutoStylePoolParent
66 typedef std::vector
<XMLAutoStylePoolProperties
> PropertiesListType
;
70 PropertiesListType m_PropertiesList
;
74 explicit XMLAutoStylePoolParent( OUString aParent
) :
75 msParent(std::move( aParent
))
79 ~XMLAutoStylePoolParent();
81 bool Add( XMLAutoStyleFamily
& rFamilyData
, std::vector
< XMLPropertyState
>&& rProperties
, OUString
& rName
, bool bDontSeek
);
83 bool AddNamed( XMLAutoStyleFamily
& rFamilyData
, std::vector
< XMLPropertyState
>&& rProperties
, const OUString
& rName
);
85 OUString
Find( const XMLAutoStyleFamily
& rFamilyData
, const ::std::vector
< XMLPropertyState
>& rProperties
) const;
87 const OUString
& GetParent() const { return msParent
; }
89 const PropertiesListType
& GetPropertiesList() const { return m_PropertiesList
; }
91 bool operator< (const XMLAutoStylePoolParent
& rOther
) const;
94 // Implementationclass for stylefamily-information
96 struct XMLAutoStyleFamily
98 typedef std::set
<XMLAutoStylePoolParent
> ParentSetType
;
100 XmlStyleFamily mnFamily
;
101 OUString maStrFamilyName
;
102 rtl::Reference
<SvXMLExportPropertyMapper
> mxMapper
;
104 ParentSetType m_ParentSet
;
105 std::set
<OUString
> maNameSet
;
106 std::set
<OUString
> maReservedNameSet
;
109 OUString maStrPrefix
;
112 XMLAutoStyleFamily( XmlStyleFamily nFamily
, OUString aStrName
,
113 rtl::Reference
<SvXMLExportPropertyMapper
> xMapper
,
114 OUString aStrPrefix
, bool bAsFamily
);
116 explicit XMLAutoStyleFamily( XmlStyleFamily nFamily
);
118 XMLAutoStyleFamily(const XMLAutoStyleFamily
&) = delete;
119 XMLAutoStyleFamily
& operator=(const XMLAutoStyleFamily
&) = delete;
121 friend bool operator<(const XMLAutoStyleFamily
& r1
, const XMLAutoStyleFamily
& r2
);
126 // Implementationclass of SvXMLAutoStylePool
128 class SvXMLAutoStylePoolP_Impl
130 // A set that finds and sorts based only on mnFamily
131 typedef std::set
<XMLAutoStyleFamily
> FamilySetType
;
133 SvXMLExport
& rExport
;
134 FamilySetType m_FamilySet
;
138 explicit SvXMLAutoStylePoolP_Impl( SvXMLExport
& rExport
);
139 ~SvXMLAutoStylePoolP_Impl();
141 SvXMLExport
& GetExport() const { return rExport
; }
143 void AddFamily( XmlStyleFamily nFamily
, const OUString
& rStrName
,
144 const rtl::Reference
< SvXMLExportPropertyMapper
> & rMapper
,
145 const OUString
& rStrPrefix
, bool bAsFamily
);
146 void SetFamilyPropSetMapper( XmlStyleFamily nFamily
,
147 const rtl::Reference
< SvXMLExportPropertyMapper
> & rMapper
);
148 void RegisterName( XmlStyleFamily nFamily
, const OUString
& rName
);
149 void RegisterDefinedName( XmlStyleFamily nFamily
, const OUString
& rName
);
150 void GetRegisteredNames(
151 css::uno::Sequence
<sal_Int32
>& aFamilies
,
152 css::uno::Sequence
<OUString
>& aNames
);
155 OUString
& rName
, XmlStyleFamily nFamily
,
156 const OUString
& rParentName
,
157 std::vector
< XMLPropertyState
>&& rProperties
,
158 bool bDontSeek
= false );
161 const OUString
& rName
, XmlStyleFamily nFamily
,
162 const OUString
& rParentName
,
163 std::vector
< XMLPropertyState
>&& rProperties
);
165 OUString
Find( XmlStyleFamily nFamily
, const OUString
& rParent
,
166 const ::std::vector
< XMLPropertyState
>& rProperties
) const;
168 void exportXML( XmlStyleFamily nFamily
,
169 const SvXMLAutoStylePoolP
*pAntiImpl
) const;
173 std::vector
<xmloff::AutoStyleEntry
> GetAutoStyleEntries() const;
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */