LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLIndexTOCSourceContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 34 47 72.3 %
Date: 2012-08-25 Functions: 6 11 54.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 40 95 42.1 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "XMLIndexTOCSourceContext.hxx"
      30                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      31                 :            : #include <com/sun/star/container/XIndexReplace.hpp>
      32                 :            : #include <sax/tools/converter.hxx>
      33                 :            : #include "XMLIndexTemplateContext.hxx"
      34                 :            : #include "XMLIndexTitleTemplateContext.hxx"
      35                 :            : #include "XMLIndexTOCStylesContext.hxx"
      36                 :            : #include <xmloff/xmlictxt.hxx>
      37                 :            : #include <xmloff/xmlimp.hxx>
      38                 :            : #include <xmloff/txtimp.hxx>
      39                 :            : #include "xmloff/xmlnmspe.hxx"
      40                 :            : #include <xmloff/nmspmap.hxx>
      41                 :            : #include <xmloff/xmltoken.hxx>
      42                 :            : #include <rtl/ustring.hxx>
      43                 :            : 
      44                 :            : 
      45                 :            : 
      46                 :            : using namespace ::xmloff::token;
      47                 :            : 
      48                 :            : using ::rtl::OUString;
      49                 :            : using ::com::sun::star::beans::XPropertySet;
      50                 :            : using ::com::sun::star::uno::Reference;
      51                 :            : using ::com::sun::star::uno::Any;
      52                 :            : using ::com::sun::star::xml::sax::XAttributeList;
      53                 :            : 
      54                 :            : const sal_Char sAPI_CreateFromChapter[] = "CreateFromChapter";
      55                 :            : const sal_Char sAPI_CreateFromOutline[] = "CreateFromOutline";
      56                 :            : const sal_Char sAPI_CreateFromMarks[] = "CreateFromMarks";
      57                 :            : const sal_Char sAPI_Level[] = "Level";
      58                 :            : const sal_Char sAPI_CreateFromLevelParagraphStyles[] = "CreateFromLevelParagraphStyles";
      59                 :            : 
      60                 :            : 
      61 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLIndexTOCSourceContext, XMLIndexSourceBaseContext );
      62                 :            : 
      63                 :          4 : XMLIndexTOCSourceContext::XMLIndexTOCSourceContext(
      64                 :            :     SvXMLImport& rImport,
      65                 :            :     sal_uInt16 nPrfx,
      66                 :            :     const OUString& rLocalName,
      67                 :            :     Reference<XPropertySet> & rPropSet)
      68                 :            : :   XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName, rPropSet, sal_True)
      69                 :            : ,   sCreateFromMarks(RTL_CONSTASCII_USTRINGPARAM(sAPI_CreateFromMarks))
      70                 :            : ,   sLevel(RTL_CONSTASCII_USTRINGPARAM(sAPI_Level))
      71                 :            : ,   sCreateFromOutline(RTL_CONSTASCII_USTRINGPARAM(sAPI_CreateFromOutline))
      72                 :            : ,   sCreateFromLevelParagraphStyles(RTL_CONSTASCII_USTRINGPARAM(sAPI_CreateFromLevelParagraphStyles))
      73                 :            :     // use all chapters by default
      74 [ +  - ][ +  - ]:          4 : ,   nOutlineLevel(rImport.GetTextImport()->GetChapterNumbering()->getCount())
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      75                 :            : ,   bUseOutline(sal_True)
      76                 :            : ,   bUseMarks(sal_True)
      77 [ +  - ][ +  - ]:          4 : ,   bUseParagraphStyles(sal_False)
         [ +  - ][ +  - ]
      78                 :            : {
      79                 :          4 : }
      80                 :            : 
      81                 :          4 : XMLIndexTOCSourceContext::~XMLIndexTOCSourceContext()
      82                 :            : {
      83         [ -  + ]:          8 : }
      84                 :            : 
      85                 :          4 : void XMLIndexTOCSourceContext::ProcessAttribute(
      86                 :            :     enum IndexSourceParamEnum eParam,
      87                 :            :     const OUString& rValue)
      88                 :            : {
      89   [ +  -  -  -  :          4 :     switch (eParam)
                      - ]
      90                 :            :     {
      91                 :            :         case XML_TOK_INDEXSOURCE_OUTLINE_LEVEL:
      92         [ -  + ]:          4 :             if ( IsXMLToken( rValue, XML_NONE ) )
      93                 :            :             {
      94                 :            :                 // #104651# use OUTLINE_LEVEL and USE_OUTLINE_LEVEL instead of
      95                 :            :                 // OUTLINE_LEVEL with values none|1..10. For backwards
      96                 :            :                 // compatibility, 'none' must still be read.
      97                 :          0 :                 bUseOutline = sal_False;
      98                 :            :             }
      99                 :            :             else
     100                 :            :             {
     101                 :            :                 sal_Int32 nTmp;
     102 [ +  - ][ +  - ]:          8 :                 if (::sax::Converter::convertNumber(
     103                 :          4 :                     nTmp, rValue, 1, GetImport().GetTextImport()->
     104 [ +  - ][ +  - ]:          8 :                     GetChapterNumbering()->getCount()))
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     105                 :            :                 {
     106                 :          4 :                     bUseOutline = sal_True;
     107                 :          4 :                     nOutlineLevel = nTmp;
     108                 :            :                 }
     109                 :            :             }
     110                 :          4 :             break;
     111                 :            : 
     112                 :            :         case XML_TOK_INDEXSOURCE_USE_OUTLINE_LEVEL:
     113                 :            :         {
     114                 :          0 :             bool bTmp(false);
     115 [ #  # ][ #  # ]:          0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     116                 :            :             {
     117                 :          0 :                 bUseOutline = bTmp;
     118                 :            :             }
     119                 :            :             break;
     120                 :            :         }
     121                 :            : 
     122                 :            : 
     123                 :            :         case XML_TOK_INDEXSOURCE_USE_INDEX_MARKS:
     124                 :            :         {
     125                 :          0 :             bool bTmp(false);
     126 [ #  # ][ #  # ]:          0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     127                 :            :             {
     128                 :          0 :                 bUseMarks = bTmp;
     129                 :            :             }
     130                 :            :             break;
     131                 :            :         }
     132                 :            : 
     133                 :            :         case XML_TOK_INDEXSOURCE_USE_INDEX_SOURCE_STYLES:
     134                 :            :         {
     135                 :          0 :             bool bTmp(false);
     136 [ #  # ][ #  # ]:          0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     137                 :            :             {
     138                 :          0 :                 bUseParagraphStyles = bTmp;
     139                 :            :             }
     140                 :            :             break;
     141                 :            :         }
     142                 :            : 
     143                 :            :         default:
     144                 :            :             // default: ask superclass
     145                 :          0 :             XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
     146                 :          0 :             break;
     147                 :            :     }
     148                 :          4 : }
     149                 :            : 
     150                 :          4 : void XMLIndexTOCSourceContext::EndElement()
     151                 :            : {
     152                 :          4 :     Any aAny;
     153                 :            : 
     154         [ +  - ]:          4 :     aAny.setValue(&bUseMarks, ::getBooleanCppuType());
     155 [ +  - ][ +  - ]:          4 :     rIndexPropertySet->setPropertyValue(sCreateFromMarks, aAny);
     156                 :            : 
     157         [ +  - ]:          4 :     aAny.setValue(&bUseOutline, ::getBooleanCppuType());
     158 [ +  - ][ +  - ]:          4 :     rIndexPropertySet->setPropertyValue(sCreateFromOutline, aAny);
     159                 :            : 
     160         [ +  - ]:          4 :     aAny.setValue(&bUseParagraphStyles, ::getBooleanCppuType());
     161 [ +  - ][ +  - ]:          4 :     rIndexPropertySet->setPropertyValue(sCreateFromLevelParagraphStyles, aAny);
     162                 :            : 
     163         [ +  - ]:          4 :     aAny <<= (sal_Int16)nOutlineLevel;
     164 [ +  - ][ +  - ]:          4 :     rIndexPropertySet->setPropertyValue(sLevel, aAny);
     165                 :            : 
     166                 :            :     // process common attributes
     167         [ +  - ]:          4 :     XMLIndexSourceBaseContext::EndElement();
     168                 :          4 : }
     169                 :            : 
     170                 :            : 
     171                 :         44 : SvXMLImportContext* XMLIndexTOCSourceContext::CreateChildContext(
     172                 :            :     sal_uInt16 nPrefix,
     173                 :            :     const OUString& rLocalName,
     174                 :            :     const Reference<XAttributeList> & xAttrList )
     175                 :            : {
     176   [ +  -  +  + ]:         88 :     if ( (XML_NAMESPACE_TEXT == nPrefix) &&
                 [ +  + ]
     177                 :         44 :          IsXMLToken(rLocalName, XML_TABLE_OF_CONTENT_ENTRY_TEMPLATE) )
     178                 :            :     {
     179                 :         40 :         return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
     180                 :            :                                            nPrefix, rLocalName,
     181                 :            :                                            aLevelNameTOCMap,
     182                 :            :                                            XML_OUTLINE_LEVEL,
     183                 :            :                                            aLevelStylePropNameTOCMap,
     184         [ +  - ]:         40 :                                            aAllowedTokenTypesTOC, sal_True );
     185                 :            :     }
     186                 :            :     else
     187                 :            :     {
     188                 :            :         return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
     189                 :            :                                                              rLocalName,
     190                 :         44 :                                                              xAttrList);
     191                 :            :     }
     192                 :            : }
     193                 :            : 
     194                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10