/src/libreoffice/xmloff/source/text/XMLSectionExport.hxx
Line | Count | Source |
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 | | #pragma once |
21 | | |
22 | | #include <rtl/ustring.hxx> |
23 | | #include <com/sun/star/uno/Reference.h> |
24 | | #include <com/sun/star/uno/Sequence.h> |
25 | | #include <com/sun/star/beans/PropertyValue.hpp> |
26 | | #include <xmloff/xmltoken.hxx> |
27 | | |
28 | | class SvXMLExport; |
29 | | class XMLTextParagraphExport; |
30 | | namespace com::sun::star { |
31 | | namespace text |
32 | | { |
33 | | class XTextSection; |
34 | | class XDocumentIndex; |
35 | | class XTextContent; |
36 | | } |
37 | | namespace beans |
38 | | { |
39 | | class XPropertySet; |
40 | | } |
41 | | namespace container |
42 | | { |
43 | | class XIndexReplace; |
44 | | } |
45 | | } |
46 | | |
47 | | |
48 | | enum SectionTypeEnum |
49 | | { |
50 | | TEXT_SECTION_TYPE_TOC, |
51 | | TEXT_SECTION_TYPE_TABLE, |
52 | | TEXT_SECTION_TYPE_ILLUSTRATION, |
53 | | TEXT_SECTION_TYPE_OBJECT, |
54 | | TEXT_SECTION_TYPE_USER, |
55 | | TEXT_SECTION_TYPE_ALPHABETICAL, |
56 | | TEXT_SECTION_TYPE_BIBLIOGRAPHY, |
57 | | TEXT_SECTION_TYPE_UNKNOWN |
58 | | }; |
59 | | |
60 | | |
61 | | /** |
62 | | * This class handles the export of sections and indices (which are, |
63 | | * internally, just sections). It is intended to be used only from |
64 | | * within the XMLTextParagraphExport class. |
65 | | */ |
66 | | class XMLSectionExport |
67 | | { |
68 | | SvXMLExport& rExport; |
69 | | XMLTextParagraphExport& rParaExport; |
70 | | |
71 | | bool bHeadingDummiesExported; |
72 | | |
73 | | public: |
74 | | XMLSectionExport(SvXMLExport& rExp, |
75 | | XMLTextParagraphExport& rParaExp); |
76 | | |
77 | | /** |
78 | | * export section or index start and source elements. This |
79 | | * method handles the section styles, and delegates to the |
80 | | * appropriate section or index method. |
81 | | */ |
82 | | void ExportSectionStart( |
83 | | const css::uno::Reference < css::text::XTextSection > & rSection, |
84 | | bool bAutoStyles); |
85 | | |
86 | | /** |
87 | | * export section or index end elements |
88 | | */ |
89 | | void ExportSectionEnd( |
90 | | const css::uno::Reference < css::text::XTextSection > & rSection, |
91 | | bool bAutoStyles); |
92 | | |
93 | | /** |
94 | | * Should the content of this section be exported? |
95 | | * (E.g. linked sections in global documents are not always exported) |
96 | | */ |
97 | | bool IsMuteSection( |
98 | | const css::uno::Reference < css::text::XTextSection > & rSection) const; |
99 | | |
100 | | /** |
101 | | * XTextContent-version of IsMuteSection(Reference<XTextSection>&) |
102 | | * returns *true* for all non-section elements |
103 | | */ |
104 | | bool IsMuteSection( |
105 | | const css::uno::Reference < css::text::XTextContent > & rSection, |
106 | | /// return value if this content doesn't support the section property |
107 | | bool bDefault) const; |
108 | | |
109 | | /** |
110 | | * Determine whether rContent is contained in rEnclosingSection. If the |
111 | | * current section of rContent can not be determined, return bDefault. |
112 | | */ |
113 | | static bool IsInSection( |
114 | | const css::uno::Reference < css::text::XTextSection > & rEnclosingSection, |
115 | | const css::uno::Reference < css::text::XTextContent > & rContent, |
116 | | /// return value if this content doesn't support the section property |
117 | | bool bDefault); |
118 | | |
119 | | /** |
120 | | * Export the configuration element for bibliography indices. |
121 | | * |
122 | | * (This is part of XMLSectionExport because all section- and |
123 | | * index-related items are handled here.) |
124 | | */ |
125 | | static void ExportBibliographyConfiguration(SvXMLExport& rExport); |
126 | | |
127 | | /** export a heading for every level. This is used by master documents |
128 | | * to not lose the heading information if master documents are exported |
129 | | * without section contents |
130 | | */ |
131 | | void ExportMasterDocHeadingDummies(); |
132 | | |
133 | | |
134 | | private: |
135 | | |
136 | 0 | SvXMLExport& GetExport() { return rExport; } |
137 | 0 | XMLTextParagraphExport& GetParaExport() { return rParaExport; } |
138 | | |
139 | | // export methods for section and index start: |
140 | | |
141 | | /// export an index start element. |
142 | | void ExportIndexStart( |
143 | | const css::uno::Reference < css::text::XDocumentIndex > & rSection); |
144 | | |
145 | | /// export an index header start element. |
146 | | void ExportIndexHeaderStart( |
147 | | const css::uno::Reference < css::text::XTextSection > & rSection); |
148 | | |
149 | | /// export a proper section (and source elements) |
150 | | void ExportRegularSectionStart( |
151 | | const css::uno::Reference < css::text::XTextSection > & rSection); |
152 | | |
153 | | /// export a table of content (and source element) |
154 | | void ExportTableOfContentStart( |
155 | | const css::uno::Reference < css::beans::XPropertySet > & rSection); |
156 | | |
157 | | /// export a table index (and source element) |
158 | | void ExportTableIndexStart( |
159 | | const css::uno::Reference < css::beans::XPropertySet > & rSection); |
160 | | |
161 | | /// export an object index (and source element) |
162 | | void ExportObjectIndexStart( |
163 | | const css::uno::Reference < css::beans::XPropertySet > & rSection); |
164 | | |
165 | | /// export an illustration index (and source element) |
166 | | void ExportIllustrationIndexStart( |
167 | | const css::uno::Reference < css::beans::XPropertySet > & rSection); |
168 | | |
169 | | /// export an alphabetical/keyword index (and source element) |
170 | | void ExportAlphabeticalIndexStart( |
171 | | const css::uno::Reference < css::beans::XPropertySet > & rSection); |
172 | | |
173 | | /// export a user index (and source element) |
174 | | void ExportUserIndexStart( |
175 | | const css::uno::Reference < css::beans::XPropertySet > & rSection); |
176 | | |
177 | | /// export the bibliography (and source element) |
178 | | void ExportBibliographyStart( |
179 | | const css::uno::Reference < css::beans::XPropertySet > & rIndex); |
180 | | |
181 | | // helper methods: |
182 | | |
183 | | /** |
184 | | * If this section is an index, the index is written in the |
185 | | * rIndex parameter. The return value is sal_True for all "special" |
186 | | * sections. |
187 | | * |
188 | | * Thus we have: |
189 | | * return sal_False: regular section |
190 | | * return sal_True, xIndex is empty: index header section |
191 | | * return sal_True, xIndex is set: index section */ |
192 | | static bool GetIndex( |
193 | | const css::uno::Reference < css::text::XTextSection > & rSection, |
194 | | css::uno::Reference < css::text::XDocumentIndex > & rIndex); |
195 | | |
196 | | /// map service name to section type |
197 | | static enum SectionTypeEnum MapSectionType(std::u16string_view rSectionName); |
198 | | |
199 | | /** |
200 | | * Export the index element start (for all index types). |
201 | | * |
202 | | * All additional attributes (usually none) for the index element |
203 | | * should have been set at GetExport() before calling this method. |
204 | | */ |
205 | | void ExportBaseIndexStart( |
206 | | ::xmloff::token::XMLTokenEnum eElement, |
207 | | const css::uno::Reference < css::beans::XPropertySet > & rSection); |
208 | | |
209 | | /** |
210 | | * Export the index source element (common for all index types). |
211 | | * |
212 | | * All additional attributes for the source element should have |
213 | | * been set at the GetExport() before calling this method. |
214 | | */ |
215 | | void ExportBaseIndexSource( |
216 | | SectionTypeEnum eType, /// index type |
217 | | const css::uno::Reference < |
218 | | css::beans::XPropertySet > & rSection); |
219 | | |
220 | | /** |
221 | | * Export the index body (common for all index types). |
222 | | */ |
223 | | void ExportBaseIndexBody( |
224 | | SectionTypeEnum eType, /// index type |
225 | | const css::uno::Reference < css::beans::XPropertySet > & rSection); |
226 | | |
227 | | |
228 | | /** |
229 | | * Helper method to export common attributes for table and |
230 | | * illustration indices |
231 | | */ |
232 | | void ExportTableAndIllustrationIndexSourceAttributes( |
233 | | const css::uno::Reference < css::beans::XPropertySet > & rSection); |
234 | | |
235 | | /// export one template for the specific index type |
236 | | bool ExportIndexTemplate( |
237 | | SectionTypeEnum eType, /// index type |
238 | | sal_Int32 nLevel, /// outline level (if applicable) |
239 | | const css::uno::Reference< css::beans::XPropertySet> & rPropSet, |
240 | | const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue> > & rValues); |
241 | | |
242 | | /// export a single template element (e.g. span or tab-stop) |
243 | | void ExportIndexTemplateElement( |
244 | | SectionTypeEnum eType, //i90246, needed for ODF 1.0, 1.0 and 1.2 management |
245 | | const css::uno::Sequence< |
246 | | css::beans::PropertyValue> & rValues); |
247 | | |
248 | | /// export level paragraph styles |
249 | | void ExportLevelParagraphStyles( |
250 | | css::uno::Reference< css::container::XIndexReplace> const & xStyles); |
251 | | |
252 | | |
253 | | /// helper to export boolean properties |
254 | | void ExportBoolean( |
255 | | const css::uno::Reference<css::beans::XPropertySet> & rPropSet, |
256 | | const OUString& sPropertyName, |
257 | | enum ::xmloff::token::XMLTokenEnum eAttributeName, |
258 | | bool bDefault, |
259 | | bool bInvert = false); |
260 | | }; |
261 | | |
262 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |