Avoid potential negative array index access to cached text.
[LibreOffice.git] / xmloff / source / text / XMLSectionExport.hxx
blob05180e2f2d6faf65438fdcc994cbf56ebb4b3825
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 #pragma once
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>
28 class SvXMLExport;
29 class XMLTextParagraphExport;
30 namespace com::sun::star {
31 namespace text
33 class XTextSection;
34 class XDocumentIndex;
35 class XTextContent;
37 namespace beans
39 class XPropertySet;
41 namespace container
43 class XIndexReplace;
48 enum SectionTypeEnum
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
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.
66 class XMLSectionExport
68 SvXMLExport& rExport;
69 XMLTextParagraphExport& rParaExport;
71 bool bHeadingDummiesExported;
73 public:
74 XMLSectionExport(SvXMLExport& rExp,
75 XMLTextParagraphExport& rParaExp);
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.
82 void ExportSectionStart(
83 const css::uno::Reference < css::text::XTextSection > & rSection,
84 bool bAutoStyles);
86 /**
87 * export section or index end elements
89 void ExportSectionEnd(
90 const css::uno::Reference < css::text::XTextSection > & rSection,
91 bool bAutoStyles);
93 /**
94 * Should the content of this section be exported?
95 * (E.g. linked sections in global documents are not always exported)
97 bool IsMuteSection(
98 const css::uno::Reference < css::text::XTextSection > & rSection) const;
101 * XTextContent-version of IsMuteSection(Reference<XTextSection>&)
102 * returns *true* for all non-section elements
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;
110 * Determine whether rContent is contained in rEnclosingSection. If the
111 * current section of rContent can not be determined, return bDefault.
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);
120 * Export the configuration element for bibliography indices.
122 * (This is part of XMLSectionExport because all section- and
123 * index-related items are handled here.)
125 static void ExportBibliographyConfiguration(SvXMLExport& rExport);
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
131 void ExportMasterDocHeadingDummies();
134 private:
136 SvXMLExport& GetExport() { return rExport; }
137 XMLTextParagraphExport& GetParaExport() { return rParaExport; }
139 // export methods for section and index start:
141 /// export an index start element.
142 void ExportIndexStart(
143 const css::uno::Reference < css::text::XDocumentIndex > & rSection);
145 /// export an index header start element.
146 void ExportIndexHeaderStart(
147 const css::uno::Reference < css::text::XTextSection > & rSection);
149 /// export a proper section (and source elements)
150 void ExportRegularSectionStart(
151 const css::uno::Reference < css::text::XTextSection > & rSection);
153 /// export a table of content (and source element)
154 void ExportTableOfContentStart(
155 const css::uno::Reference < css::beans::XPropertySet > & rSection);
157 /// export a table index (and source element)
158 void ExportTableIndexStart(
159 const css::uno::Reference < css::beans::XPropertySet > & rSection);
161 /// export an object index (and source element)
162 void ExportObjectIndexStart(
163 const css::uno::Reference < css::beans::XPropertySet > & rSection);
165 /// export an illustration index (and source element)
166 void ExportIllustrationIndexStart(
167 const css::uno::Reference < css::beans::XPropertySet > & rSection);
169 /// export an alphabetical/keyword index (and source element)
170 void ExportAlphabeticalIndexStart(
171 const css::uno::Reference < css::beans::XPropertySet > & rSection);
173 /// export a user index (and source element)
174 void ExportUserIndexStart(
175 const css::uno::Reference < css::beans::XPropertySet > & rSection);
177 /// export the bibliography (and source element)
178 void ExportBibliographyStart(
179 const css::uno::Reference < css::beans::XPropertySet > & rIndex);
181 // helper methods:
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.
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);
196 /// map service name to section type
197 static enum SectionTypeEnum MapSectionType(std::u16string_view rSectionName);
200 * Export the index element start (for all index types).
202 * All additional attributes (usually none) for the index element
203 * should have been set at GetExport() before calling this method.
205 void ExportBaseIndexStart(
206 ::xmloff::token::XMLTokenEnum eElement,
207 const css::uno::Reference < css::beans::XPropertySet > & rSection);
210 * Export the index source element (common for all index types).
212 * All additional attributes for the source element should have
213 * been set at the GetExport() before calling this method.
215 void ExportBaseIndexSource(
216 SectionTypeEnum eType, /// index type
217 const css::uno::Reference <
218 css::beans::XPropertySet > & rSection);
221 * Export the index body (common for all index types).
223 void ExportBaseIndexBody(
224 SectionTypeEnum eType, /// index type
225 const css::uno::Reference < css::beans::XPropertySet > & rSection);
229 * Helper method to export common attributes for table and
230 * illustration indices
232 void ExportTableAndIllustrationIndexSourceAttributes(
233 const css::uno::Reference < css::beans::XPropertySet > & rSection);
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);
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);
248 /// export level paragraph styles
249 void ExportLevelParagraphStyles(
250 css::uno::Reference< css::container::XIndexReplace> const & xStyles);
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);
262 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */