1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _XMLOFF_XMLSECTIONEXPORT_HXX_ 25 #define _XMLOFF_XMLSECTIONEXPORT_HXX_ 26 27 #include <rtl/ustring.hxx> 28 #include <com/sun/star/uno/Reference.h> 29 #include <com/sun/star/uno/Sequence.h> 30 #include <com/sun/star/beans/PropertyValue.hpp> 31 #include <xmloff/xmltoken.hxx> 32 33 class SvXMLExport; 34 class XMLTextParagraphExport; 35 namespace com { namespace sun { namespace star { 36 namespace text 37 { 38 class XTextSection; 39 class XDocumentIndex; 40 class XTextContent; 41 } 42 namespace beans 43 { 44 class XPropertySet; 45 } 46 namespace container 47 { 48 class XIndexReplace; 49 } 50 } } } 51 52 53 enum SectionTypeEnum 54 { 55 TEXT_SECTION_TYPE_SECTION, 56 57 // indices: keep index valued together and do not change order, 58 // because they are used to index into array 59 TEXT_SECTION_TYPE_TOC, 60 TEXT_SECTION_TYPE_TABLE, 61 TEXT_SECTION_TYPE_ILLUSTRATION, 62 TEXT_SECTION_TYPE_OBJECT, 63 TEXT_SECTION_TYPE_USER, 64 TEXT_SECTION_TYPE_ALPHABETICAL, 65 TEXT_SECTION_TYPE_BIBLIOGRAPHY, 66 67 // index header sections: 68 TEXT_SECTION_TYPE_HEADER, 69 70 TEXT_SECTION_TYPE_UNKNOWN 71 }; 72 73 74 /** 75 * This class handles the export of sections and indices (which are, 76 * internally, just sections). It is intended to be used only from 77 * within the XMLTextParagraphExport class. 78 */ 79 class XMLSectionExport 80 { 81 const ::rtl::OUString sCondition; 82 const ::rtl::OUString sCreateFromChapter; 83 const ::rtl::OUString sCreateFromEmbeddedObjects; 84 const ::rtl::OUString sCreateFromGraphicObjects; 85 const ::rtl::OUString sCreateFromLabels; 86 const ::rtl::OUString sCreateFromMarks; 87 const ::rtl::OUString sCreateFromOtherEmbeddedObjects; 88 const ::rtl::OUString sCreateFromOutline; 89 const ::rtl::OUString sCreateFromStarCalc; 90 const ::rtl::OUString sCreateFromStarChart; 91 const ::rtl::OUString sCreateFromStarDraw; 92 const ::rtl::OUString sCreateFromStarImage; 93 const ::rtl::OUString sCreateFromStarMath; 94 const ::rtl::OUString sCreateFromTables; 95 const ::rtl::OUString sCreateFromTextFrames; 96 const ::rtl::OUString sDdeCommandElement; 97 const ::rtl::OUString sDdeCommandFile; 98 const ::rtl::OUString sDdeCommandType; 99 const ::rtl::OUString sFileLink; 100 const ::rtl::OUString sIsCaseSensitive; 101 const ::rtl::OUString sIsProtected; 102 const ::rtl::OUString sIsVisible; 103 const ::rtl::OUString sLabelCategory; 104 const ::rtl::OUString sLabelDisplayType; 105 const ::rtl::OUString sLevel; 106 const ::rtl::OUString sLevelFormat; 107 const ::rtl::OUString sLevelParagraphStyles; 108 const ::rtl::OUString sLinkRegion; 109 const ::rtl::OUString sMainEntryCharacterStyleName; 110 const ::rtl::OUString sParaStyleHeading; 111 const ::rtl::OUString sParaStyleLevel; 112 const ::rtl::OUString sTitle; 113 const ::rtl::OUString sName; 114 const ::rtl::OUString sUseAlphabeticalSeparators; 115 const ::rtl::OUString sUseCombinedEntries; 116 const ::rtl::OUString sUseDash; 117 const ::rtl::OUString sUseKeyAsEntry; 118 const ::rtl::OUString sUseLevelFromSource; 119 const ::rtl::OUString sUsePP; 120 const ::rtl::OUString sUseUpperCase; 121 const ::rtl::OUString sIsCommaSeparated; 122 const ::rtl::OUString sIsAutomaticUpdate; 123 const ::rtl::OUString sIsRelativeTabstops; 124 const ::rtl::OUString sCreateFromLevelParagraphStyles; 125 const ::rtl::OUString sDocumentIndex; 126 const ::rtl::OUString sContentSection; 127 const ::rtl::OUString sHeaderSection; 128 129 const ::rtl::OUString sTextSection; 130 const ::rtl::OUString sIsGlobalDocumentSection; 131 const ::rtl::OUString sProtectionKey; 132 const ::rtl::OUString sSortAlgorithm; 133 const ::rtl::OUString sLocale; 134 const ::rtl::OUString sUserIndexName; 135 136 const ::rtl::OUString sIsCurrentlyVisible; 137 const ::rtl::OUString sHeadingStyleName; 138 139 const ::rtl::OUString sEmpty; 140 141 SvXMLExport& rExport; 142 XMLTextParagraphExport& rParaExport; 143 144 sal_Bool bHeadingDummiesExported; 145 146 public: 147 XMLSectionExport(SvXMLExport& rExp, 148 XMLTextParagraphExport& rParaExp); 149 150 /** 151 * export section or index start and source elements. This 152 * method handles the section styles, and delegates to the 153 * appropriate section or index method. 154 */ 155 void ExportSectionStart( 156 const ::com::sun::star::uno::Reference < 157 ::com::sun::star::text::XTextSection > & rSection, 158 sal_Bool bAutoStyles); 159 160 /** 161 * export section or index end elements 162 */ 163 void ExportSectionEnd( 164 const ::com::sun::star::uno::Reference < 165 ::com::sun::star::text::XTextSection > & rSection, 166 sal_Bool bAutoStyles); 167 168 /** 169 * Should the content of this section be exported? 170 * (E.g. linked sections in global documents are not always exported) 171 */ 172 sal_Bool IsMuteSection( 173 const ::com::sun::star::uno::Reference < 174 ::com::sun::star::text::XTextSection > & rSection) const; 175 176 /** 177 * XTextContent-version of IsMuteSection(Reference<XTextSection>&) 178 * returns *true* for all non-section elements 179 */ 180 sal_Bool IsMuteSection( 181 const ::com::sun::star::uno::Reference < 182 ::com::sun::star::text::XTextContent > & rSection, 183 /// return value if this content doesn't support the section property 184 sal_Bool bDefault) const; 185 186 /** 187 * Determine whether rContent is contained in rEnclosingSection. If the 188 * current section of rContent can not be determined, return bDefault. 189 */ 190 sal_Bool IsInSection( 191 const ::com::sun::star::uno::Reference < 192 ::com::sun::star::text::XTextSection > & rEnclosingSection, 193 const ::com::sun::star::uno::Reference < 194 ::com::sun::star::text::XTextContent > & rContent, 195 /// return value if this content doesn't support the section property 196 sal_Bool bDefault); 197 198 /** 199 * Export the configuration element for bibliography indices. 200 * 201 * (This is part of XMLSectionExport because all section- and 202 * index-related items are handled here.) 203 */ 204 static void ExportBibliographyConfiguration(SvXMLExport& rExport); 205 206 /** export a heading for every level. This is used by master documents 207 * to not loose the heading information if master documents are exported 208 * without section contents 209 */ 210 void ExportMasterDocHeadingDummies(); 211 212 213 214 protected: 215 GetExport()216 inline SvXMLExport& GetExport() { return rExport; } GetParaExport()217 inline XMLTextParagraphExport& GetParaExport() { return rParaExport; } 218 219 // export methods for section and index start: 220 221 /// export an index start element. 222 void ExportIndexStart( 223 const ::com::sun::star::uno::Reference < 224 ::com::sun::star::text::XDocumentIndex > & rSection); 225 226 /// export an index header start element. 227 void ExportIndexHeaderStart( 228 const ::com::sun::star::uno::Reference < 229 ::com::sun::star::text::XTextSection > & rSection); 230 231 /// export a proper section (and source elements) 232 void ExportRegularSectionStart( 233 const ::com::sun::star::uno::Reference < 234 ::com::sun::star::text::XTextSection > & rSection); 235 236 /// export a table of content (and source element) 237 void ExportTableOfContentStart( 238 const ::com::sun::star::uno::Reference < 239 ::com::sun::star::beans::XPropertySet > & rSection); 240 241 /// export a table index (and source element) 242 void ExportTableIndexStart( 243 const ::com::sun::star::uno::Reference < 244 ::com::sun::star::beans::XPropertySet > & rSection); 245 246 /// export an object index (and source element) 247 void ExportObjectIndexStart( 248 const ::com::sun::star::uno::Reference < 249 ::com::sun::star::beans::XPropertySet > & rSection); 250 251 /// export an illustration index (and source element) 252 void ExportIllustrationIndexStart( 253 const ::com::sun::star::uno::Reference < 254 ::com::sun::star::beans::XPropertySet > & rSection); 255 256 /// export an alphabetical/keyword index (and source element) 257 void ExportAlphabeticalIndexStart( 258 const ::com::sun::star::uno::Reference < 259 ::com::sun::star::beans::XPropertySet > & rSection); 260 261 /// export a user index (and source element) 262 void ExportUserIndexStart( 263 const ::com::sun::star::uno::Reference < 264 ::com::sun::star::beans::XPropertySet > & rSection); 265 266 /// export the bibliography (and source element) 267 void ExportBibliographyStart( 268 const ::com::sun::star::uno::Reference < 269 ::com::sun::star::beans::XPropertySet > & rIndex); 270 271 // helper methods: 272 273 /** 274 * If this section is an index, the index is written in the 275 * rIndex parameter. The return value is sal_True for all "special" 276 * sections. 277 * 278 * Thus we have: 279 * return sal_False: regular section 280 * return sal_True, xIndex is empty: index header section 281 * return sal_True, xIndex is set: index section */ 282 sal_Bool GetIndex( 283 const ::com::sun::star::uno::Reference < 284 ::com::sun::star::text::XTextSection > & rSection, 285 ::com::sun::star::uno::Reference < 286 ::com::sun::star::text::XDocumentIndex > & rIndex) const; 287 288 /// map service name to section type 289 enum SectionTypeEnum MapSectionType(const ::rtl::OUString& rSectionName); 290 291 /** 292 * Export the index element start (for all index types). 293 * 294 * All additional attributes (usually none) for the index element 295 * should have been set at GetExport() before calling this method. 296 */ 297 void ExportBaseIndexStart( 298 ::xmloff::token::XMLTokenEnum eElement, 299 const ::com::sun::star::uno::Reference < 300 ::com::sun::star::beans::XPropertySet > & rSection); 301 302 /** 303 * Export the index source element (common for all index types). 304 * 305 * All additional attributes for the source element should have 306 * been set at the GetExport() before calling this method. 307 */ 308 void ExportBaseIndexSource( 309 SectionTypeEnum eType, /// index type 310 const ::com::sun::star::uno::Reference < 311 ::com::sun::star::beans::XPropertySet > & rSection); 312 313 /** 314 * Export the index body (common for all index types). 315 */ 316 void ExportBaseIndexBody( 317 SectionTypeEnum eType, /// index type 318 const ::com::sun::star::uno::Reference < 319 ::com::sun::star::beans::XPropertySet > & rSection); 320 321 322 /** 323 * Helper method to export common attributes for table and 324 * illustration indices 325 */ 326 void ExportTableAndIllustrationIndexSourceAttributes( 327 const ::com::sun::star::uno::Reference < 328 ::com::sun::star::beans::XPropertySet > & rSection); 329 330 /// export one template for the specific index type 331 sal_Bool ExportIndexTemplate( 332 SectionTypeEnum eType, /// index type 333 sal_Int32 nLevel, /// outline level (if applicable) 334 const ::com::sun::star::uno::Reference< 335 ::com::sun::star::beans::XPropertySet> & rPropSet, 336 ::com::sun::star::uno::Sequence< 337 ::com::sun::star::uno::Sequence< 338 ::com::sun::star::beans::PropertyValue> > & rValues); 339 340 /// export a single template element (e.g. span or tab-stop) 341 void ExportIndexTemplateElement( 342 SectionTypeEnum eType, //i90246, needed for ODF 1.0, 1.0 and 1.2 management 343 ::com::sun::star::uno::Sequence< 344 ::com::sun::star::beans::PropertyValue> & rValues); 345 346 /// export level paragraph styles 347 void ExportLevelParagraphStyles( 348 ::com::sun::star::uno::Reference< 349 ::com::sun::star::container::XIndexReplace> & xStyles); 350 351 352 /// helper to export boolean properties 353 void ExportBoolean( 354 const ::com::sun::star::uno::Reference< 355 ::com::sun::star::beans::XPropertySet> & rPropSet, 356 const ::rtl::OUString& sPropertyName, 357 enum ::xmloff::token::XMLTokenEnum eAttributeName, 358 sal_Bool bDefault, 359 sal_Bool bInvert = sal_False); 360 }; 361 362 #endif 363