Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_XMLOFF_SOURCE_STYLE_IMPASTPL_HXX
21 : #define INCLUDED_XMLOFF_SOURCE_STYLE_IMPASTPL_HXX
22 :
23 : #include <boost/ptr_container/ptr_set.hpp>
24 : #include <sal/types.h>
25 : #include <rtl/ustring.hxx>
26 : #include <set>
27 : #include <vector>
28 : #include <com/sun/star/uno/Reference.h>
29 : #include <com/sun/star/xml/sax/XAttributeList.hpp>
30 : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
31 : #include <xmloff/maptype.hxx>
32 : #include <xmloff/xmlexppr.hxx>
33 :
34 : #include <boost/noncopyable.hpp>
35 : #include <boost/ptr_container/ptr_vector.hpp>
36 :
37 : class SvXMLAutoStylePoolP;
38 : class XMLAutoStylePoolParent;
39 : class SvXMLExportPropertyMapper;
40 : class SvXMLExport;
41 :
42 : // Implementationclass for stylefamily-information
43 :
44 : struct XMLAutoStyleFamily : boost::noncopyable
45 : {
46 : typedef boost::ptr_set<XMLAutoStylePoolParent> ParentSetType;
47 : typedef std::set<OUString> NameSetType;
48 :
49 : sal_uInt32 mnFamily;
50 : OUString maStrFamilyName;
51 : rtl::Reference < SvXMLExportPropertyMapper > mxMapper;
52 :
53 : ParentSetType maParentSet;
54 : NameSetType maNameSet;
55 : sal_uInt32 mnCount;
56 : sal_uInt32 mnName;
57 : OUString maStrPrefix;
58 : bool mbAsFamily;
59 :
60 : XMLAutoStyleFamily( sal_Int32 nFamily, const OUString& rStrName,
61 : const rtl::Reference<SvXMLExportPropertyMapper>& rMapper,
62 : const OUString& rStrPrefix, bool bAsFamily = true );
63 :
64 : explicit XMLAutoStyleFamily( sal_Int32 nFamily );
65 : ~XMLAutoStyleFamily();
66 :
67 : friend bool operator<(const XMLAutoStyleFamily& r1, const XMLAutoStyleFamily& r2);
68 :
69 : void ClearEntries();
70 : };
71 :
72 : // Properties of a pool
73 :
74 : class XMLAutoStylePoolProperties
75 : {
76 : OUString msName;
77 : ::std::vector< XMLPropertyState > maProperties;
78 : sal_uInt32 mnPos;
79 :
80 : public:
81 :
82 : XMLAutoStylePoolProperties( XMLAutoStyleFamily& rFamilyData, const ::std::vector< XMLPropertyState >& rProperties, OUString& rParentname );
83 :
84 4086 : ~XMLAutoStylePoolProperties()
85 4086 : {
86 4086 : }
87 :
88 9985 : const OUString& GetName() const { return msName; }
89 49769 : const ::std::vector< XMLPropertyState >& GetProperties() const { return maProperties; }
90 4087 : sal_uInt32 GetPos() const { return mnPos; }
91 :
92 0 : void SetName( const OUString& rNew ) { msName = rNew; }
93 : };
94 :
95 : // Parents of AutoStylePool's
96 : class XMLAutoStylePoolParent
97 : {
98 : public:
99 : typedef boost::ptr_vector<XMLAutoStylePoolProperties> PropertiesListType;
100 :
101 : private:
102 : OUString msParent;
103 : PropertiesListType maPropertiesList;
104 :
105 : public:
106 :
107 6980 : explicit XMLAutoStylePoolParent( const OUString & rParent ) :
108 6980 : msParent( rParent )
109 : {
110 6980 : }
111 :
112 : ~XMLAutoStylePoolParent();
113 :
114 : bool Add( XMLAutoStyleFamily& rFamilyData, const ::std::vector< XMLPropertyState >& rProperties, OUString& rName, bool bDontSeek = false );
115 :
116 : bool AddNamed( XMLAutoStyleFamily& rFamilyData, const ::std::vector< XMLPropertyState >& rProperties, const OUString& rName );
117 :
118 : OUString Find( const XMLAutoStyleFamily& rFamilyData, const ::std::vector< XMLPropertyState >& rProperties ) const;
119 :
120 4087 : const OUString& GetParent() const { return msParent; }
121 :
122 4805 : PropertiesListType& GetPropertiesList()
123 : {
124 4805 : return maPropertiesList;
125 : }
126 :
127 : bool operator< (const XMLAutoStylePoolParent& rOther) const;
128 : };
129 :
130 : // Implementationclass of SvXMLAutoStylePool
131 :
132 : class SvXMLAutoStylePoolP_Impl
133 : {
134 : // A set that finds and sorts based only on mnFamily
135 : typedef boost::ptr_set<XMLAutoStyleFamily> FamilySetType;
136 :
137 : SvXMLExport& rExport;
138 : FamilySetType maFamilySet;
139 :
140 : public:
141 :
142 : explicit SvXMLAutoStylePoolP_Impl( SvXMLExport& rExport );
143 : ~SvXMLAutoStylePoolP_Impl();
144 :
145 68576 : SvXMLExport& GetExport() const { return rExport; }
146 :
147 : void AddFamily( sal_Int32 nFamily, const OUString& rStrName,
148 : const rtl::Reference < SvXMLExportPropertyMapper > & rMapper,
149 : const OUString& rStrPrefix, bool bAsFamily = true );
150 : void SetFamilyPropSetMapper( sal_Int32 nFamily,
151 : const rtl::Reference < SvXMLExportPropertyMapper > & rMapper );
152 : void RegisterName( sal_Int32 nFamily, const OUString& rName );
153 : void GetRegisteredNames(
154 : com::sun::star::uno::Sequence<sal_Int32>& aFamilies,
155 : com::sun::star::uno::Sequence<OUString>& aNames );
156 :
157 : bool Add(
158 : OUString& rName, sal_Int32 nFamily,
159 : const OUString& rParentName,
160 : const ::std::vector< XMLPropertyState >& rProperties,
161 : bool bDontSeek = false );
162 :
163 : bool AddNamed(
164 : const OUString& rName, sal_Int32 nFamily,
165 : const OUString& rParentName,
166 : const ::std::vector< XMLPropertyState >& rProperties );
167 :
168 : OUString Find( sal_Int32 nFamily, const OUString& rParent,
169 : const ::std::vector< XMLPropertyState >& rProperties ) const;
170 :
171 : void exportXML( sal_Int32 nFamily,
172 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > & rHandler,
173 : const SvXMLUnitConverter& rUnitConverter,
174 : const SvXMLNamespaceMap& rNamespaceMap,
175 : const SvXMLAutoStylePoolP *pAntiImpl) const;
176 :
177 : void ClearEntries();
178 : };
179 :
180 : #endif
181 :
182 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|