1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLSectionExport.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _XMLOFF_XMLSECTIONEXPORT_HXX_
32 #define _XMLOFF_XMLSECTIONEXPORT_HXX_
34 #include <rtl/ustring.hxx>
35 #include <com/sun/star/uno/Reference.h>
36 #include <com/sun/star/uno/Sequence.h>
37 #include <com/sun/star/beans/PropertyValue.hpp>
38 #include <xmloff/xmltoken.hxx>
41 class XMLTextParagraphExport
;
42 namespace com
{ namespace sun
{ namespace star
{
62 TEXT_SECTION_TYPE_SECTION
,
64 // indices: keep index valued together and do not change order,
65 // because they are used to index into array
66 TEXT_SECTION_TYPE_TOC
,
67 TEXT_SECTION_TYPE_TABLE
,
68 TEXT_SECTION_TYPE_ILLUSTRATION
,
69 TEXT_SECTION_TYPE_OBJECT
,
70 TEXT_SECTION_TYPE_USER
,
71 TEXT_SECTION_TYPE_ALPHABETICAL
,
72 TEXT_SECTION_TYPE_BIBLIOGRAPHY
,
74 // index header sections:
75 TEXT_SECTION_TYPE_HEADER
,
77 TEXT_SECTION_TYPE_UNKNOWN
82 * This class handles the export of sections and indices (which are,
83 * internally, just sections). It is intended to be used only from
84 * within the XMLTextParagraphExport class.
86 class XMLSectionExport
88 const ::rtl::OUString sCondition
;
89 const ::rtl::OUString sCreateFromChapter
;
90 const ::rtl::OUString sCreateFromEmbeddedObjects
;
91 const ::rtl::OUString sCreateFromGraphicObjects
;
92 const ::rtl::OUString sCreateFromLabels
;
93 const ::rtl::OUString sCreateFromMarks
;
94 const ::rtl::OUString sCreateFromOtherEmbeddedObjects
;
95 const ::rtl::OUString sCreateFromOutline
;
96 const ::rtl::OUString sCreateFromStarCalc
;
97 const ::rtl::OUString sCreateFromStarChart
;
98 const ::rtl::OUString sCreateFromStarDraw
;
99 const ::rtl::OUString sCreateFromStarImage
;
100 const ::rtl::OUString sCreateFromStarMath
;
101 const ::rtl::OUString sCreateFromTables
;
102 const ::rtl::OUString sCreateFromTextFrames
;
103 const ::rtl::OUString sDdeCommandElement
;
104 const ::rtl::OUString sDdeCommandFile
;
105 const ::rtl::OUString sDdeCommandType
;
106 const ::rtl::OUString sFileLink
;
107 const ::rtl::OUString sIsCaseSensitive
;
108 const ::rtl::OUString sIsProtected
;
109 const ::rtl::OUString sIsVisible
;
110 const ::rtl::OUString sLabelCategory
;
111 const ::rtl::OUString sLabelDisplayType
;
112 const ::rtl::OUString sLevel
;
113 const ::rtl::OUString sLevelFormat
;
114 const ::rtl::OUString sLevelParagraphStyles
;
115 const ::rtl::OUString sLinkRegion
;
116 const ::rtl::OUString sMainEntryCharacterStyleName
;
117 const ::rtl::OUString sParaStyleHeading
;
118 const ::rtl::OUString sParaStyleLevel
;
119 const ::rtl::OUString sTitle
;
120 const ::rtl::OUString sName
;
121 const ::rtl::OUString sUseAlphabeticalSeparators
;
122 const ::rtl::OUString sUseCombinedEntries
;
123 const ::rtl::OUString sUseDash
;
124 const ::rtl::OUString sUseKeyAsEntry
;
125 const ::rtl::OUString sUseLevelFromSource
;
126 const ::rtl::OUString sUsePP
;
127 const ::rtl::OUString sUseUpperCase
;
128 const ::rtl::OUString sIsCommaSeparated
;
129 const ::rtl::OUString sIsAutomaticUpdate
;
130 const ::rtl::OUString sIsRelativeTabstops
;
131 const ::rtl::OUString sCreateFromLevelParagraphStyles
;
132 const ::rtl::OUString sDocumentIndex
;
133 const ::rtl::OUString sContentSection
;
134 const ::rtl::OUString sHeaderSection
;
136 const ::rtl::OUString sTextSection
;
137 const ::rtl::OUString sIsGlobalDocumentSection
;
138 const ::rtl::OUString sProtectionKey
;
139 const ::rtl::OUString sSortAlgorithm
;
140 const ::rtl::OUString sLocale
;
141 const ::rtl::OUString sUserIndexName
;
143 const ::rtl::OUString sIsCurrentlyVisible
;
144 const ::rtl::OUString sHeadingStyleName
;
146 const ::rtl::OUString sEmpty
;
148 SvXMLExport
& rExport
;
149 XMLTextParagraphExport
& rParaExport
;
151 sal_Bool bHeadingDummiesExported
;
154 XMLSectionExport(SvXMLExport
& rExp
,
155 XMLTextParagraphExport
& rParaExp
);
158 * export section or index start and source elements. This
159 * method handles the section styles, and delegates to the
160 * appropriate section or index method.
162 void ExportSectionStart(
163 const ::com::sun::star::uno::Reference
<
164 ::com::sun::star::text::XTextSection
> & rSection
,
165 sal_Bool bAutoStyles
);
168 * export section or index end elements
170 void ExportSectionEnd(
171 const ::com::sun::star::uno::Reference
<
172 ::com::sun::star::text::XTextSection
> & rSection
,
173 sal_Bool bAutoStyles
);
176 * Should the content of this section be exported?
177 * (E.g. linked sections in global documents are not always exported)
179 sal_Bool
IsMuteSection(
180 const ::com::sun::star::uno::Reference
<
181 ::com::sun::star::text::XTextSection
> & rSection
) const;
184 * XTextContent-version of IsMuteSection(Reference<XTextSection>&)
185 * returns *true* for all non-section elements
187 sal_Bool
IsMuteSection(
188 const ::com::sun::star::uno::Reference
<
189 ::com::sun::star::text::XTextContent
> & rSection
,
190 /// return value if this content doesn't support the section property
191 sal_Bool bDefault
) const;
194 * Determine whether rContent is contained in rEnclosingSection. If the
195 * current section of rContent can not be determined, return bDefault.
197 sal_Bool
IsInSection(
198 const ::com::sun::star::uno::Reference
<
199 ::com::sun::star::text::XTextSection
> & rEnclosingSection
,
200 const ::com::sun::star::uno::Reference
<
201 ::com::sun::star::text::XTextContent
> & rContent
,
202 /// return value if this content doesn't support the section property
206 * Export the configuration element for bibliography indices.
208 * (This is part of XMLSectionExport because all section- and
209 * index-related items are handled here.)
211 static void ExportBibliographyConfiguration(SvXMLExport
& rExport
);
213 /** export a heading for every level. This is used by master documents
214 * to not loose the heading information if master documents are exported
215 * without section contents
217 void ExportMasterDocHeadingDummies();
223 inline SvXMLExport
& GetExport() { return rExport
; }
224 inline XMLTextParagraphExport
& GetParaExport() { return rParaExport
; }
226 // export methods for section and index start:
228 /// export an index start element.
229 void ExportIndexStart(
230 const ::com::sun::star::uno::Reference
<
231 ::com::sun::star::text::XDocumentIndex
> & rSection
);
233 /// export an index header start element.
234 void ExportIndexHeaderStart(
235 const ::com::sun::star::uno::Reference
<
236 ::com::sun::star::text::XTextSection
> & rSection
);
238 /// export a proper section (and source elements)
239 void ExportRegularSectionStart(
240 const ::com::sun::star::uno::Reference
<
241 ::com::sun::star::text::XTextSection
> & rSection
);
243 /// export a table of content (and source element)
244 void ExportTableOfContentStart(
245 const ::com::sun::star::uno::Reference
<
246 ::com::sun::star::beans::XPropertySet
> & rSection
);
248 /// export a table index (and source element)
249 void ExportTableIndexStart(
250 const ::com::sun::star::uno::Reference
<
251 ::com::sun::star::beans::XPropertySet
> & rSection
);
253 /// export an object index (and source element)
254 void ExportObjectIndexStart(
255 const ::com::sun::star::uno::Reference
<
256 ::com::sun::star::beans::XPropertySet
> & rSection
);
258 /// export an illustration index (and source element)
259 void ExportIllustrationIndexStart(
260 const ::com::sun::star::uno::Reference
<
261 ::com::sun::star::beans::XPropertySet
> & rSection
);
263 /// export an alphabetical/keyword index (and source element)
264 void ExportAlphabeticalIndexStart(
265 const ::com::sun::star::uno::Reference
<
266 ::com::sun::star::beans::XPropertySet
> & rSection
);
268 /// export a user index (and source element)
269 void ExportUserIndexStart(
270 const ::com::sun::star::uno::Reference
<
271 ::com::sun::star::beans::XPropertySet
> & rSection
);
273 /// export the bibliography (and source element)
274 void ExportBibliographyStart(
275 const ::com::sun::star::uno::Reference
<
276 ::com::sun::star::beans::XPropertySet
> & rIndex
);
281 * If this section is an index, the index is written in the
282 * rIndex parameter. The return value is sal_True for all "special"
286 * return sal_False: regular section
287 * return sal_True, xIndex is empty: index header section
288 * return sal_True, xIndex is set: index section */
290 const ::com::sun::star::uno::Reference
<
291 ::com::sun::star::text::XTextSection
> & rSection
,
292 ::com::sun::star::uno::Reference
<
293 ::com::sun::star::text::XDocumentIndex
> & rIndex
) const;
295 /// map service name to section type
296 enum SectionTypeEnum
MapSectionType(const ::rtl::OUString
& rSectionName
);
299 * Export the index element start (for all index types).
301 * All additional attributes (usually none) for the index element
302 * should have been set at GetExport() before calling this method.
304 void ExportBaseIndexStart(
305 ::xmloff::token::XMLTokenEnum eElement
,
306 const ::com::sun::star::uno::Reference
<
307 ::com::sun::star::beans::XPropertySet
> & rSection
);
310 * Export the index source element (common for all index types).
312 * All additional attributes for the source element should have
313 * been set at the GetExport() before calling this method.
315 void ExportBaseIndexSource(
316 SectionTypeEnum eType
, /// index type
317 const ::com::sun::star::uno::Reference
<
318 ::com::sun::star::beans::XPropertySet
> & rSection
);
321 * Export the index body (common for all index types).
323 void ExportBaseIndexBody(
324 SectionTypeEnum eType
, /// index type
325 const ::com::sun::star::uno::Reference
<
326 ::com::sun::star::beans::XPropertySet
> & rSection
);
330 * Helper method to export common attributes for table and
331 * illustration indices
333 void ExportTableAndIllustrationIndexSourceAttributes(
334 const ::com::sun::star::uno::Reference
<
335 ::com::sun::star::beans::XPropertySet
> & rSection
);
337 /// export one template for the specific index type
338 sal_Bool
ExportIndexTemplate(
339 SectionTypeEnum eType
, /// index type
340 sal_Int32 nLevel
, /// outline level (if applicable)
341 const ::com::sun::star::uno::Reference
<
342 ::com::sun::star::beans::XPropertySet
> & rPropSet
,
343 ::com::sun::star::uno::Sequence
<
344 ::com::sun::star::uno::Sequence
<
345 ::com::sun::star::beans::PropertyValue
> > & rValues
);
347 /// export a single template element (e.g. span or tab-stop)
348 void ExportIndexTemplateElement(
349 SectionTypeEnum eType
, //i90246, needed for ODF 1.0, 1.0 and 1.2 management
350 ::com::sun::star::uno::Sequence
<
351 ::com::sun::star::beans::PropertyValue
> & rValues
);
353 /// export level paragraph styles
354 void ExportLevelParagraphStyles(
355 ::com::sun::star::uno::Reference
<
356 ::com::sun::star::container::XIndexReplace
> & xStyles
);
359 /// helper to export boolean properties
361 const ::com::sun::star::uno::Reference
<
362 ::com::sun::star::beans::XPropertySet
> & rPropSet
,
363 const ::rtl::OUString
& sPropertyName
,
364 enum ::xmloff::token::XMLTokenEnum eAttributeName
,
366 sal_Bool bInvert
= sal_False
);