bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / source / text / XMLSectionExport.hxx
blob9163ef2927f86b56756daef2a324ad6970432780
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_SOURCE_TEXT_XMLSECTIONEXPORT_HXX
21 #define INCLUDED_XMLOFF_SOURCE_TEXT_XMLSECTIONEXPORT_HXX
23 #include <rtl/ustring.hxx>
24 #include <com/sun/star/uno/Reference.h>
25 #include <com/sun/star/uno/Sequence.h>
26 #include <com/sun/star/beans/PropertyValue.hpp>
27 #include <xmloff/xmltoken.hxx>
29 class SvXMLExport;
30 class XMLTextParagraphExport;
31 namespace com { namespace sun { namespace star {
32 namespace text
34 class XTextSection;
35 class XDocumentIndex;
36 class XTextContent;
38 namespace beans
40 class XPropertySet;
42 namespace container
44 class XIndexReplace;
46 } } }
49 enum SectionTypeEnum
51 TEXT_SECTION_TYPE_SECTION,
53 // indices: keep index valued together and do not change order,
54 // because they are used to index into array
55 TEXT_SECTION_TYPE_TOC,
56 TEXT_SECTION_TYPE_TABLE,
57 TEXT_SECTION_TYPE_ILLUSTRATION,
58 TEXT_SECTION_TYPE_OBJECT,
59 TEXT_SECTION_TYPE_USER,
60 TEXT_SECTION_TYPE_ALPHABETICAL,
61 TEXT_SECTION_TYPE_BIBLIOGRAPHY,
63 // index header sections:
64 TEXT_SECTION_TYPE_HEADER,
66 TEXT_SECTION_TYPE_UNKNOWN
70 /**
71 * This class handles the export of sections and indices (which are,
72 * internally, just sections). It is intended to be used only from
73 * within the XMLTextParagraphExport class.
75 class XMLSectionExport
77 const OUString sCondition;
78 const OUString sCreateFromChapter;
79 const OUString sCreateFromEmbeddedObjects;
80 const OUString sCreateFromGraphicObjects;
81 const OUString sCreateFromLabels;
82 const OUString sCreateFromMarks;
83 const OUString sCreateFromOtherEmbeddedObjects;
84 const OUString sCreateFromOutline;
85 const OUString sCreateFromStarCalc;
86 const OUString sCreateFromStarChart;
87 const OUString sCreateFromStarDraw;
88 const OUString sCreateFromStarMath;
89 const OUString sCreateFromTables;
90 const OUString sCreateFromTextFrames;
91 const OUString sDdeCommandElement;
92 const OUString sDdeCommandFile;
93 const OUString sDdeCommandType;
94 const OUString sFileLink;
95 const OUString sIsCaseSensitive;
96 const OUString sIsProtected;
97 const OUString sIsVisible;
98 const OUString sLabelCategory;
99 const OUString sLabelDisplayType;
100 const OUString sLevel;
101 const OUString sLevelFormat;
102 const OUString sLevelParagraphStyles;
103 const OUString sLinkRegion;
104 const OUString sMainEntryCharacterStyleName;
105 const OUString sParaStyleHeading;
106 const OUString sTitle;
107 const OUString sName;
108 const OUString sUseAlphabeticalSeparators;
109 const OUString sUseCombinedEntries;
110 const OUString sUseDash;
111 const OUString sUseKeyAsEntry;
112 const OUString sUseLevelFromSource;
113 const OUString sUsePP;
114 const OUString sUseUpperCase;
115 const OUString sIsCommaSeparated;
116 const OUString sIsAutomaticUpdate;
117 const OUString sIsRelativeTabstops;
118 const OUString sCreateFromLevelParagraphStyles;
119 const OUString sDocumentIndex;
120 const OUString sContentSection;
121 const OUString sHeaderSection;
123 const OUString sTextSection;
124 const OUString sIsGlobalDocumentSection;
125 const OUString sProtectionKey;
126 const OUString sSortAlgorithm;
127 const OUString sLocale;
128 const OUString sUserIndexName;
130 const OUString sIsCurrentlyVisible;
131 const OUString sHeadingStyleName;
133 const OUString sEmpty;
135 SvXMLExport& rExport;
136 XMLTextParagraphExport& rParaExport;
138 bool bHeadingDummiesExported;
140 public:
141 XMLSectionExport(SvXMLExport& rExp,
142 XMLTextParagraphExport& rParaExp);
145 * export section or index start and source elements. This
146 * method handles the section styles, and delegates to the
147 * appropriate section or index method.
149 void ExportSectionStart(
150 const ::com::sun::star::uno::Reference <
151 ::com::sun::star::text::XTextSection > & rSection,
152 bool bAutoStyles);
155 * export section or index end elements
157 void ExportSectionEnd(
158 const ::com::sun::star::uno::Reference <
159 ::com::sun::star::text::XTextSection > & rSection,
160 bool bAutoStyles);
163 * Should the content of this section be exported?
164 * (E.g. linked sections in global documents are not always exported)
166 bool IsMuteSection(
167 const ::com::sun::star::uno::Reference <
168 ::com::sun::star::text::XTextSection > & rSection) const;
171 * XTextContent-version of IsMuteSection(Reference<XTextSection>&)
172 * returns *true* for all non-section elements
174 bool IsMuteSection(
175 const ::com::sun::star::uno::Reference <
176 ::com::sun::star::text::XTextContent > & rSection,
177 /// return value if this content doesn't support the section property
178 bool bDefault) const;
181 * Determine whether rContent is contained in rEnclosingSection. If the
182 * current section of rContent can not be determined, return bDefault.
184 bool IsInSection(
185 const ::com::sun::star::uno::Reference <
186 ::com::sun::star::text::XTextSection > & rEnclosingSection,
187 const ::com::sun::star::uno::Reference <
188 ::com::sun::star::text::XTextContent > & rContent,
189 /// return value if this content doesn't support the section property
190 bool bDefault);
193 * Export the configuration element for bibliography indices.
195 * (This is part of XMLSectionExport because all section- and
196 * index-related items are handled here.)
198 static void ExportBibliographyConfiguration(SvXMLExport& rExport);
200 /** export a heading for every level. This is used by master documents
201 * to not lose the heading information if master documents are exported
202 * without section contents
204 void ExportMasterDocHeadingDummies();
208 protected:
210 inline SvXMLExport& GetExport() { return rExport; }
211 inline XMLTextParagraphExport& GetParaExport() { return rParaExport; }
213 // export methods for section and index start:
215 /// export an index start element.
216 void ExportIndexStart(
217 const ::com::sun::star::uno::Reference <
218 ::com::sun::star::text::XDocumentIndex > & rSection);
220 /// export an index header start element.
221 void ExportIndexHeaderStart(
222 const ::com::sun::star::uno::Reference <
223 ::com::sun::star::text::XTextSection > & rSection);
225 /// export a proper section (and source elements)
226 void ExportRegularSectionStart(
227 const ::com::sun::star::uno::Reference <
228 ::com::sun::star::text::XTextSection > & rSection);
230 /// export a table of content (and source element)
231 void ExportTableOfContentStart(
232 const ::com::sun::star::uno::Reference <
233 ::com::sun::star::beans::XPropertySet > & rSection);
235 /// export a table index (and source element)
236 void ExportTableIndexStart(
237 const ::com::sun::star::uno::Reference <
238 ::com::sun::star::beans::XPropertySet > & rSection);
240 /// export an object index (and source element)
241 void ExportObjectIndexStart(
242 const ::com::sun::star::uno::Reference <
243 ::com::sun::star::beans::XPropertySet > & rSection);
245 /// export an illustration index (and source element)
246 void ExportIllustrationIndexStart(
247 const ::com::sun::star::uno::Reference <
248 ::com::sun::star::beans::XPropertySet > & rSection);
250 /// export an alphabetical/keyword index (and source element)
251 void ExportAlphabeticalIndexStart(
252 const ::com::sun::star::uno::Reference <
253 ::com::sun::star::beans::XPropertySet > & rSection);
255 /// export a user index (and source element)
256 void ExportUserIndexStart(
257 const ::com::sun::star::uno::Reference <
258 ::com::sun::star::beans::XPropertySet > & rSection);
260 /// export the bibliography (and source element)
261 void ExportBibliographyStart(
262 const ::com::sun::star::uno::Reference <
263 ::com::sun::star::beans::XPropertySet > & rIndex);
265 // helper methods:
268 * If this section is an index, the index is written in the
269 * rIndex parameter. The return value is sal_True for all "special"
270 * sections.
272 * Thus we have:
273 * return sal_False: regular section
274 * return sal_True, xIndex is empty: index header section
275 * return sal_True, xIndex is set: index section */
276 bool GetIndex(
277 const ::com::sun::star::uno::Reference <
278 ::com::sun::star::text::XTextSection > & rSection,
279 ::com::sun::star::uno::Reference <
280 ::com::sun::star::text::XDocumentIndex > & rIndex) const;
282 /// map service name to section type
283 static enum SectionTypeEnum MapSectionType(const OUString& rSectionName);
286 * Export the index element start (for all index types).
288 * All additional attributes (usually none) for the index element
289 * should have been set at GetExport() before calling this method.
291 void ExportBaseIndexStart(
292 ::xmloff::token::XMLTokenEnum eElement,
293 const ::com::sun::star::uno::Reference <
294 ::com::sun::star::beans::XPropertySet > & rSection);
297 * Export the index source element (common for all index types).
299 * All additional attributes for the source element should have
300 * been set at the GetExport() before calling this method.
302 void ExportBaseIndexSource(
303 SectionTypeEnum eType, /// index type
304 const ::com::sun::star::uno::Reference <
305 ::com::sun::star::beans::XPropertySet > & rSection);
308 * Export the index body (common for all index types).
310 void ExportBaseIndexBody(
311 SectionTypeEnum eType, /// index type
312 const ::com::sun::star::uno::Reference <
313 ::com::sun::star::beans::XPropertySet > & rSection);
317 * Helper method to export common attributes for table and
318 * illustration indices
320 void ExportTableAndIllustrationIndexSourceAttributes(
321 const ::com::sun::star::uno::Reference <
322 ::com::sun::star::beans::XPropertySet > & rSection);
324 /// export one template for the specific index type
325 bool ExportIndexTemplate(
326 SectionTypeEnum eType, /// index type
327 sal_Int32 nLevel, /// outline level (if applicable)
328 const ::com::sun::star::uno::Reference<
329 ::com::sun::star::beans::XPropertySet> & rPropSet,
330 ::com::sun::star::uno::Sequence<
331 ::com::sun::star::uno::Sequence<
332 ::com::sun::star::beans::PropertyValue> > & rValues);
334 /// export a single template element (e.g. span or tab-stop)
335 void ExportIndexTemplateElement(
336 SectionTypeEnum eType, //i90246, needed for ODF 1.0, 1.0 and 1.2 management
337 ::com::sun::star::uno::Sequence<
338 ::com::sun::star::beans::PropertyValue> & rValues);
340 /// export level paragraph styles
341 void ExportLevelParagraphStyles(
342 ::com::sun::star::uno::Reference<
343 ::com::sun::star::container::XIndexReplace> & xStyles);
346 /// helper to export boolean properties
347 void ExportBoolean(
348 const ::com::sun::star::uno::Reference<
349 ::com::sun::star::beans::XPropertySet> & rPropSet,
350 const OUString& sPropertyName,
351 enum ::xmloff::token::XMLTokenEnum eAttributeName,
352 bool bDefault,
353 bool bInvert = false);
356 #endif
358 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */