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 _XMLOFF_XMLSECTIONEXPORT_HXX_
21 #define _XMLOFF_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>
30 class XMLTextParagraphExport
;
31 namespace com
{ namespace sun
{ namespace star
{
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
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 sCreateFromStarImage
;
89 const OUString sCreateFromStarMath
;
90 const OUString sCreateFromTables
;
91 const OUString sCreateFromTextFrames
;
92 const OUString sDdeCommandElement
;
93 const OUString sDdeCommandFile
;
94 const OUString sDdeCommandType
;
95 const OUString sFileLink
;
96 const OUString sIsCaseSensitive
;
97 const OUString sIsProtected
;
98 const OUString sIsVisible
;
99 const OUString sLabelCategory
;
100 const OUString sLabelDisplayType
;
101 const OUString sLevel
;
102 const OUString sLevelFormat
;
103 const OUString sLevelParagraphStyles
;
104 const OUString sLinkRegion
;
105 const OUString sMainEntryCharacterStyleName
;
106 const OUString sParaStyleHeading
;
107 const OUString sParaStyleLevel
;
108 const OUString sTitle
;
109 const OUString sName
;
110 const OUString sUseAlphabeticalSeparators
;
111 const OUString sUseCombinedEntries
;
112 const OUString sUseDash
;
113 const OUString sUseKeyAsEntry
;
114 const OUString sUseLevelFromSource
;
115 const OUString sUsePP
;
116 const OUString sUseUpperCase
;
117 const OUString sIsCommaSeparated
;
118 const OUString sIsAutomaticUpdate
;
119 const OUString sIsRelativeTabstops
;
120 const OUString sCreateFromLevelParagraphStyles
;
121 const OUString sDocumentIndex
;
122 const OUString sContentSection
;
123 const OUString sHeaderSection
;
125 const OUString sTextSection
;
126 const OUString sIsGlobalDocumentSection
;
127 const OUString sProtectionKey
;
128 const OUString sSortAlgorithm
;
129 const OUString sLocale
;
130 const OUString sUserIndexName
;
132 const OUString sIsCurrentlyVisible
;
133 const OUString sHeadingStyleName
;
135 const OUString sEmpty
;
137 SvXMLExport
& rExport
;
138 XMLTextParagraphExport
& rParaExport
;
140 sal_Bool bHeadingDummiesExported
;
143 XMLSectionExport(SvXMLExport
& rExp
,
144 XMLTextParagraphExport
& rParaExp
);
147 * export section or index start and source elements. This
148 * method handles the section styles, and delegates to the
149 * appropriate section or index method.
151 void ExportSectionStart(
152 const ::com::sun::star::uno::Reference
<
153 ::com::sun::star::text::XTextSection
> & rSection
,
154 sal_Bool bAutoStyles
);
157 * export section or index end elements
159 void ExportSectionEnd(
160 const ::com::sun::star::uno::Reference
<
161 ::com::sun::star::text::XTextSection
> & rSection
,
162 sal_Bool bAutoStyles
);
165 * Should the content of this section be exported?
166 * (E.g. linked sections in global documents are not always exported)
168 sal_Bool
IsMuteSection(
169 const ::com::sun::star::uno::Reference
<
170 ::com::sun::star::text::XTextSection
> & rSection
) const;
173 * XTextContent-version of IsMuteSection(Reference<XTextSection>&)
174 * returns *true* for all non-section elements
176 sal_Bool
IsMuteSection(
177 const ::com::sun::star::uno::Reference
<
178 ::com::sun::star::text::XTextContent
> & rSection
,
179 /// return value if this content doesn't support the section property
180 sal_Bool bDefault
) const;
183 * Determine whether rContent is contained in rEnclosingSection. If the
184 * current section of rContent can not be determined, return bDefault.
186 sal_Bool
IsInSection(
187 const ::com::sun::star::uno::Reference
<
188 ::com::sun::star::text::XTextSection
> & rEnclosingSection
,
189 const ::com::sun::star::uno::Reference
<
190 ::com::sun::star::text::XTextContent
> & rContent
,
191 /// return value if this content doesn't support the section property
195 * Export the configuration element for bibliography indices.
197 * (This is part of XMLSectionExport because all section- and
198 * index-related items are handled here.)
200 static void ExportBibliographyConfiguration(SvXMLExport
& rExport
);
202 /** export a heading for every level. This is used by master documents
203 * to not loose the heading information if master documents are exported
204 * without section contents
206 void ExportMasterDocHeadingDummies();
212 inline SvXMLExport
& GetExport() { return rExport
; }
213 inline XMLTextParagraphExport
& GetParaExport() { return rParaExport
; }
215 // export methods for section and index start:
217 /// export an index start element.
218 void ExportIndexStart(
219 const ::com::sun::star::uno::Reference
<
220 ::com::sun::star::text::XDocumentIndex
> & rSection
);
222 /// export an index header start element.
223 void ExportIndexHeaderStart(
224 const ::com::sun::star::uno::Reference
<
225 ::com::sun::star::text::XTextSection
> & rSection
);
227 /// export a proper section (and source elements)
228 void ExportRegularSectionStart(
229 const ::com::sun::star::uno::Reference
<
230 ::com::sun::star::text::XTextSection
> & rSection
);
232 /// export a table of content (and source element)
233 void ExportTableOfContentStart(
234 const ::com::sun::star::uno::Reference
<
235 ::com::sun::star::beans::XPropertySet
> & rSection
);
237 /// export a table index (and source element)
238 void ExportTableIndexStart(
239 const ::com::sun::star::uno::Reference
<
240 ::com::sun::star::beans::XPropertySet
> & rSection
);
242 /// export an object index (and source element)
243 void ExportObjectIndexStart(
244 const ::com::sun::star::uno::Reference
<
245 ::com::sun::star::beans::XPropertySet
> & rSection
);
247 /// export an illustration index (and source element)
248 void ExportIllustrationIndexStart(
249 const ::com::sun::star::uno::Reference
<
250 ::com::sun::star::beans::XPropertySet
> & rSection
);
252 /// export an alphabetical/keyword index (and source element)
253 void ExportAlphabeticalIndexStart(
254 const ::com::sun::star::uno::Reference
<
255 ::com::sun::star::beans::XPropertySet
> & rSection
);
257 /// export a user index (and source element)
258 void ExportUserIndexStart(
259 const ::com::sun::star::uno::Reference
<
260 ::com::sun::star::beans::XPropertySet
> & rSection
);
262 /// export the bibliography (and source element)
263 void ExportBibliographyStart(
264 const ::com::sun::star::uno::Reference
<
265 ::com::sun::star::beans::XPropertySet
> & rIndex
);
270 * If this section is an index, the index is written in the
271 * rIndex parameter. The return value is sal_True for all "special"
275 * return sal_False: regular section
276 * return sal_True, xIndex is empty: index header section
277 * return sal_True, xIndex is set: index section */
279 const ::com::sun::star::uno::Reference
<
280 ::com::sun::star::text::XTextSection
> & rSection
,
281 ::com::sun::star::uno::Reference
<
282 ::com::sun::star::text::XDocumentIndex
> & rIndex
) const;
284 /// map service name to section type
285 enum SectionTypeEnum
MapSectionType(const OUString
& rSectionName
);
288 * Export the index element start (for all index types).
290 * All additional attributes (usually none) for the index element
291 * should have been set at GetExport() before calling this method.
293 void ExportBaseIndexStart(
294 ::xmloff::token::XMLTokenEnum eElement
,
295 const ::com::sun::star::uno::Reference
<
296 ::com::sun::star::beans::XPropertySet
> & rSection
);
299 * Export the index source element (common for all index types).
301 * All additional attributes for the source element should have
302 * been set at the GetExport() before calling this method.
304 void ExportBaseIndexSource(
305 SectionTypeEnum eType
, /// index type
306 const ::com::sun::star::uno::Reference
<
307 ::com::sun::star::beans::XPropertySet
> & rSection
);
310 * Export the index body (common for all index types).
312 void ExportBaseIndexBody(
313 SectionTypeEnum eType
, /// index type
314 const ::com::sun::star::uno::Reference
<
315 ::com::sun::star::beans::XPropertySet
> & rSection
);
319 * Helper method to export common attributes for table and
320 * illustration indices
322 void ExportTableAndIllustrationIndexSourceAttributes(
323 const ::com::sun::star::uno::Reference
<
324 ::com::sun::star::beans::XPropertySet
> & rSection
);
326 /// export one template for the specific index type
327 sal_Bool
ExportIndexTemplate(
328 SectionTypeEnum eType
, /// index type
329 sal_Int32 nLevel
, /// outline level (if applicable)
330 const ::com::sun::star::uno::Reference
<
331 ::com::sun::star::beans::XPropertySet
> & rPropSet
,
332 ::com::sun::star::uno::Sequence
<
333 ::com::sun::star::uno::Sequence
<
334 ::com::sun::star::beans::PropertyValue
> > & rValues
);
336 /// export a single template element (e.g. span or tab-stop)
337 void ExportIndexTemplateElement(
338 SectionTypeEnum eType
, //i90246, needed for ODF 1.0, 1.0 and 1.2 management
339 ::com::sun::star::uno::Sequence
<
340 ::com::sun::star::beans::PropertyValue
> & rValues
);
342 /// export level paragraph styles
343 void ExportLevelParagraphStyles(
344 ::com::sun::star::uno::Reference
<
345 ::com::sun::star::container::XIndexReplace
> & xStyles
);
348 /// helper to export boolean properties
350 const ::com::sun::star::uno::Reference
<
351 ::com::sun::star::beans::XPropertySet
> & rPropSet
,
352 const OUString
& sPropertyName
,
353 enum ::xmloff::token::XMLTokenEnum eAttributeName
,
355 sal_Bool bInvert
= sal_False
);
360 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */