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