LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLSectionExport.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 3 100.0 %
Date: 2012-08-25 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10