LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLSectionExport.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 3 3 100.0 %
Date: 2015-06-13 12:38:46 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_XMLOFF_SOURCE_TEXT_XMLSECTIONEXPORT_HXX
      21             : #define INCLUDED_XMLOFF_SOURCE_TEXT_XMLSECTIONEXPORT_HXX
      22             : 
      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>
      28             : 
      29             : class SvXMLExport;
      30             : class XMLTextParagraphExport;
      31             : namespace com { namespace sun { namespace star {
      32             :     namespace text
      33             :     {
      34             :         class XTextSection;
      35             :         class XDocumentIndex;
      36             :         class XTextContent;
      37             :     }
      38             :     namespace beans
      39             :     {
      40             :         class XPropertySet;
      41             :     }
      42             :     namespace container
      43             :     {
      44             :         class XIndexReplace;
      45             :     }
      46             : } } }
      47             : 
      48             : 
      49             : enum SectionTypeEnum
      50             : {
      51             :     TEXT_SECTION_TYPE_SECTION,
      52             : 
      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,
      62             : 
      63             :     // index header sections:
      64             :     TEXT_SECTION_TYPE_HEADER,
      65             : 
      66             :     TEXT_SECTION_TYPE_UNKNOWN
      67             : };
      68             : 
      69             : 
      70             : /**
      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.
      74             :  */
      75        1059 : class XMLSectionExport
      76             : {
      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 sCreateFromStarMath;
      89             :     const OUString sCreateFromTables;
      90             :     const OUString sCreateFromTextFrames;
      91             :     const OUString sDdeCommandElement;
      92             :     const OUString sDdeCommandFile;
      93             :     const OUString sDdeCommandType;
      94             :     const OUString sFileLink;
      95             :     const OUString sIsCaseSensitive;
      96             :     const OUString sIsProtected;
      97             :     const OUString sIsVisible;
      98             :     const OUString sLabelCategory;
      99             :     const OUString sLabelDisplayType;
     100             :     const OUString sLevel;
     101             :     const OUString sLevelFormat;
     102             :     const OUString sLevelParagraphStyles;
     103             :     const OUString sLinkRegion;
     104             :     const OUString sMainEntryCharacterStyleName;
     105             :     const OUString sParaStyleHeading;
     106             :     const OUString sTitle;
     107             :     const OUString sName;
     108             :     const OUString sUseAlphabeticalSeparators;
     109             :     const OUString sUseCombinedEntries;
     110             :     const OUString sUseDash;
     111             :     const OUString sUseKeyAsEntry;
     112             :     const OUString sUseLevelFromSource;
     113             :     const OUString sUsePP;
     114             :     const OUString sUseUpperCase;
     115             :     const OUString sIsCommaSeparated;
     116             :     const OUString sIsAutomaticUpdate;
     117             :     const OUString sIsRelativeTabstops;
     118             :     const OUString sCreateFromLevelParagraphStyles;
     119             :     const OUString sDocumentIndex;
     120             :     const OUString sContentSection;
     121             :     const OUString sHeaderSection;
     122             : 
     123             :     const OUString sTextSection;
     124             :     const OUString sIsGlobalDocumentSection;
     125             :     const OUString sProtectionKey;
     126             :     const OUString sSortAlgorithm;
     127             :     const OUString sLocale;
     128             :     const OUString sUserIndexName;
     129             : 
     130             :     const OUString sIsCurrentlyVisible;
     131             :     const OUString sHeadingStyleName;
     132             : 
     133             :     const OUString sEmpty;
     134             : 
     135             :     SvXMLExport& rExport;
     136             :     XMLTextParagraphExport& rParaExport;
     137             : 
     138             :     bool bHeadingDummiesExported;
     139             : 
     140             : public:
     141             :     XMLSectionExport(SvXMLExport& rExp,
     142             :                      XMLTextParagraphExport& rParaExp);
     143             : 
     144             :     /**
     145             :      * export section or index start and source elements. This
     146             :      * method handles the section styles, and delegates to the
     147             :      * appropriate section or index method.
     148             :      */
     149             :     void ExportSectionStart(
     150             :         const ::com::sun::star::uno::Reference <
     151             :             ::com::sun::star::text::XTextSection > & rSection,
     152             :         bool bAutoStyles);
     153             : 
     154             :     /**
     155             :      * export section or index end elements
     156             :      */
     157             :     void ExportSectionEnd(
     158             :         const ::com::sun::star::uno::Reference <
     159             :             ::com::sun::star::text::XTextSection > & rSection,
     160             :         bool bAutoStyles);
     161             : 
     162             :     /**
     163             :      * Should the content of this section be exported?
     164             :      * (E.g. linked sections in global documents are not always exported)
     165             :      */
     166             :     bool IsMuteSection(
     167             :         const ::com::sun::star::uno::Reference <
     168             :             ::com::sun::star::text::XTextSection > & rSection) const;
     169             : 
     170             :     /**
     171             :      * XTextContent-version of IsMuteSection(Reference<XTextSection>&)
     172             :      * returns *true* for all non-section elements
     173             :      */
     174             :     bool IsMuteSection(
     175             :         const ::com::sun::star::uno::Reference <
     176             :             ::com::sun::star::text::XTextContent > & rSection,
     177             :         /// return value if this content doesn't support the section property
     178             :         bool bDefault) const;
     179             : 
     180             :     /**
     181             :      * Determine whether rContent is contained in rEnclosingSection. If the
     182             :      * current section of rContent can not be determined, return bDefault.
     183             :      */
     184             :     bool IsInSection(
     185             :         const ::com::sun::star::uno::Reference <
     186             :             ::com::sun::star::text::XTextSection > & rEnclosingSection,
     187             :         const ::com::sun::star::uno::Reference <
     188             :             ::com::sun::star::text::XTextContent > & rContent,
     189             :         /// return value if this content doesn't support the section property
     190             :         bool bDefault);
     191             : 
     192             :     /**
     193             :      * Export the configuration element for bibliography indices.
     194             :      *
     195             :      * (This is part of XMLSectionExport because all section- and
     196             :      *  index-related items are handled here.)
     197             :      */
     198             :     static void ExportBibliographyConfiguration(SvXMLExport& rExport);
     199             : 
     200             :     /** export a heading for every level. This is used by master documents
     201             :      *  to not lose the heading information if master documents are exported
     202             :      *  without section contents
     203             :      */
     204             :     void ExportMasterDocHeadingDummies();
     205             : 
     206             : 
     207             : 
     208             : protected:
     209             : 
     210        1551 :     inline SvXMLExport& GetExport() { return rExport; }
     211          38 :     inline XMLTextParagraphExport& GetParaExport() { return rParaExport; }
     212             : 
     213             :     // export methods for section and index start:
     214             : 
     215             :     /// export an index start element.
     216             :     void ExportIndexStart(
     217             :         const ::com::sun::star::uno::Reference <
     218             :             ::com::sun::star::text::XDocumentIndex > & rSection);
     219             : 
     220             :     /// export an index header start element.
     221             :     void ExportIndexHeaderStart(
     222             :         const ::com::sun::star::uno::Reference <
     223             :             ::com::sun::star::text::XTextSection > & rSection);
     224             : 
     225             :     /// export a proper section (and source elements)
     226             :     void ExportRegularSectionStart(
     227             :         const ::com::sun::star::uno::Reference <
     228             :             ::com::sun::star::text::XTextSection > & rSection);
     229             : 
     230             :     /// export a table of content (and source element)
     231             :     void ExportTableOfContentStart(
     232             :         const ::com::sun::star::uno::Reference <
     233             :             ::com::sun::star::beans::XPropertySet > & rSection);
     234             : 
     235             :     /// export a table index (and source element)
     236             :     void ExportTableIndexStart(
     237             :         const ::com::sun::star::uno::Reference <
     238             :             ::com::sun::star::beans::XPropertySet > & rSection);
     239             : 
     240             :     /// export an object index (and source element)
     241             :     void ExportObjectIndexStart(
     242             :         const ::com::sun::star::uno::Reference <
     243             :             ::com::sun::star::beans::XPropertySet > & rSection);
     244             : 
     245             :     /// export an illustration index (and source element)
     246             :     void ExportIllustrationIndexStart(
     247             :         const ::com::sun::star::uno::Reference <
     248             :             ::com::sun::star::beans::XPropertySet > & rSection);
     249             : 
     250             :     /// export an alphabetical/keyword index (and source element)
     251             :     void ExportAlphabeticalIndexStart(
     252             :         const ::com::sun::star::uno::Reference <
     253             :             ::com::sun::star::beans::XPropertySet > & rSection);
     254             : 
     255             :     /// export a user index (and source element)
     256             :     void ExportUserIndexStart(
     257             :         const ::com::sun::star::uno::Reference <
     258             :             ::com::sun::star::beans::XPropertySet > & rSection);
     259             : 
     260             :     /// export the bibliography (and source element)
     261             :     void ExportBibliographyStart(
     262             :         const ::com::sun::star::uno::Reference <
     263             :             ::com::sun::star::beans::XPropertySet > & rIndex);
     264             : 
     265             :     // helper methods:
     266             : 
     267             :     /**
     268             :      * If this section is an index, the index is written in the
     269             :      * rIndex parameter. The return value is sal_True for all "special"
     270             :      * sections.
     271             :      *
     272             :      * Thus we have:
     273             :      * return sal_False: regular section
     274             :      * return sal_True, xIndex is empty: index header section
     275             :      * return sal_True, xIndex is set: index section */
     276             :     bool GetIndex(
     277             :         const ::com::sun::star::uno::Reference <
     278             :             ::com::sun::star::text::XTextSection > & rSection,
     279             :         ::com::sun::star::uno::Reference <
     280             :             ::com::sun::star::text::XDocumentIndex > & rIndex) const;
     281             : 
     282             :     /// map service name to section type
     283             :     static enum SectionTypeEnum MapSectionType(const OUString& rSectionName);
     284             : 
     285             :     /**
     286             :      * Export the index element start (for all index types).
     287             :      *
     288             :      * All additional attributes (usually none) for the index element
     289             :      * should have been set at GetExport() before calling this method.
     290             :      */
     291             :     void ExportBaseIndexStart(
     292             :         ::xmloff::token::XMLTokenEnum eElement,
     293             :         const ::com::sun::star::uno::Reference <
     294             :             ::com::sun::star::beans::XPropertySet > & rSection);
     295             : 
     296             :     /**
     297             :      * Export the index source element (common for all index types).
     298             :      *
     299             :      * All additional attributes for the source element should have
     300             :      * been set at the GetExport() before calling this method.
     301             :      */
     302             :     void ExportBaseIndexSource(
     303             :         SectionTypeEnum eType,                /// index type
     304             :         const ::com::sun::star::uno::Reference <
     305             :             ::com::sun::star::beans::XPropertySet > & rSection);
     306             : 
     307             :     /**
     308             :      * Export the index body (common for all index types).
     309             :      */
     310             :     void ExportBaseIndexBody(
     311             :         SectionTypeEnum eType,                /// index type
     312             :         const ::com::sun::star::uno::Reference <
     313             :             ::com::sun::star::beans::XPropertySet > & rSection);
     314             : 
     315             : 
     316             :     /**
     317             :      * Helper method to export common attributes for table and
     318             :      * illustration indices
     319             :      */
     320             :      void ExportTableAndIllustrationIndexSourceAttributes(
     321             :          const ::com::sun::star::uno::Reference <
     322             :             ::com::sun::star::beans::XPropertySet > & rSection);
     323             : 
     324             :     /// export one template for the specific index type
     325             :     bool ExportIndexTemplate(
     326             :         SectionTypeEnum eType,                /// index type
     327             :         sal_Int32 nLevel,                     /// outline level (if applicable)
     328             :         const ::com::sun::star::uno::Reference<
     329             :             ::com::sun::star::beans::XPropertySet> & rPropSet,
     330             :         ::com::sun::star::uno::Sequence<
     331             :             ::com::sun::star::uno::Sequence<
     332             :                 ::com::sun::star::beans::PropertyValue> > & rValues);
     333             : 
     334             :     /// export a single template element (e.g. span or tab-stop)
     335             :     void ExportIndexTemplateElement(
     336             :         SectionTypeEnum eType, //i90246, needed for ODF 1.0, 1.0 and 1.2 management
     337             :         ::com::sun::star::uno::Sequence<
     338             :             ::com::sun::star::beans::PropertyValue> & rValues);
     339             : 
     340             :     /// export level paragraph styles
     341             :     void ExportLevelParagraphStyles(
     342             :         ::com::sun::star::uno::Reference<
     343             :             ::com::sun::star::container::XIndexReplace> & xStyles);
     344             : 
     345             : 
     346             :     /// helper to export boolean properties
     347             :     void ExportBoolean(
     348             :         const ::com::sun::star::uno::Reference<
     349             :             ::com::sun::star::beans::XPropertySet> & rPropSet,
     350             :         const OUString& sPropertyName,
     351             :         enum ::xmloff::token::XMLTokenEnum eAttributeName,
     352             :         bool bDefault,
     353             :         bool bInvert = false);
     354             : };
     355             : 
     356             : #endif
     357             : 
     358             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11