LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLIndexTitleTemplateContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 34 35 97.1 %
Date: 2012-08-25 Functions: 6 11 54.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 30 62 48.4 %

           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                 :            : #include "XMLIndexTitleTemplateContext.hxx"
      21                 :            : #include <xmloff/xmlictxt.hxx>
      22                 :            : #include <xmloff/xmlimp.hxx>
      23                 :            : #include <xmloff/nmspmap.hxx>
      24                 :            : #include "xmloff/xmlnmspe.hxx"
      25                 :            : #include <xmloff/xmltoken.hxx>
      26                 :            : 
      27                 :            : 
      28                 :            : using ::rtl::OUString;
      29                 :            : using ::rtl::OUStringBuffer;
      30                 :            : using ::com::sun::star::beans::XPropertySet;
      31                 :            : using ::com::sun::star::uno::Any;
      32                 :            : using ::com::sun::star::uno::Reference;
      33                 :            : using ::com::sun::star::xml::sax::XAttributeList;
      34                 :            : using ::xmloff::token::IsXMLToken;
      35                 :            : using ::xmloff::token::XML_STYLE_NAME;
      36                 :            : 
      37                 :            : 
      38 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLIndexTitleTemplateContext, SvXMLImportContext );
      39                 :            : 
      40                 :         28 : XMLIndexTitleTemplateContext::XMLIndexTitleTemplateContext(
      41                 :            :     SvXMLImport& rImport,
      42                 :            :     Reference<XPropertySet> & rPropSet,
      43                 :            :     sal_uInt16 nPrfx,
      44                 :            :     const OUString& rLocalName)
      45                 :            : :   SvXMLImportContext(rImport, nPrfx, rLocalName)
      46                 :            : ,   sTitle("Title")
      47                 :            : ,   sParaStyleHeading("ParaStyleHeading")
      48                 :            : ,   bStyleNameOK(sal_False)
      49                 :         28 : ,   rTOCPropertySet(rPropSet)
      50                 :            : {
      51                 :         28 : }
      52                 :            : 
      53                 :            : 
      54                 :         28 : XMLIndexTitleTemplateContext::~XMLIndexTitleTemplateContext()
      55                 :            : {
      56         [ -  + ]:         56 : }
      57                 :            : 
      58                 :         28 : void XMLIndexTitleTemplateContext::StartElement(
      59                 :            :     const Reference<XAttributeList> & xAttrList)
      60                 :            : {
      61                 :            :     // there's only one attribute: style-name
      62                 :         28 :     sal_Int16 nLength = xAttrList->getLength();
      63         [ +  + ]:         56 :     for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
      64                 :            :     {
      65                 :         28 :         OUString sLocalName;
      66                 :         28 :         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
      67         [ +  - ]:         28 :             GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
      68   [ +  -  +  - ]:         56 :                               &sLocalName );
      69 [ +  - ][ +  - ]:         56 :         if ( (XML_NAMESPACE_TEXT == nPrefix) &&
                 [ +  - ]
      70         [ +  - ]:         28 :              (IsXMLToken(sLocalName, XML_STYLE_NAME)) )
      71                 :            :         {
      72 [ +  - ][ +  - ]:         28 :             sStyleName = xAttrList->getValueByIndex(nAttr);
      73                 :         28 :             OUString sDisplayStyleName = GetImport().GetStyleDisplayName(
      74         [ +  - ]:         28 :                 XML_STYLE_FAMILY_TEXT_PARAGRAPH, sStyleName );
      75                 :            :             const Reference < ::com::sun::star::container::XNameContainer >&
      76 [ +  - ][ +  - ]:         28 :                 rStyles = GetImport().GetTextImport()->GetParaStyles();
         [ +  - ][ +  - ]
      77 [ +  - ][ +  - ]:         28 :             bStyleNameOK = rStyles.is() && rStyles->hasByName( sDisplayStyleName );
         [ +  - ][ +  - ]
      78                 :            :         }
      79                 :         28 :     }
      80                 :         28 : }
      81                 :            : 
      82                 :         28 : void XMLIndexTitleTemplateContext::EndElement()
      83                 :            : {
      84                 :         28 :     Any aAny;
      85                 :            : 
      86 [ +  - ][ +  - ]:         28 :     aAny <<= sContent.makeStringAndClear();
      87 [ +  - ][ +  - ]:         28 :     rTOCPropertySet->setPropertyValue(sTitle, aAny);
      88                 :            : 
      89         [ +  - ]:         28 :     if (bStyleNameOK)
      90                 :            :     {
      91                 :         28 :         aAny <<= GetImport().GetStyleDisplayName(
      92                 :            :                                 XML_STYLE_FAMILY_TEXT_PARAGRAPH,
      93 [ +  - ][ +  - ]:         28 :                                 sStyleName );
      94 [ +  - ][ +  - ]:         28 :         rTOCPropertySet->setPropertyValue(sParaStyleHeading, aAny);
      95                 :         28 :     }
      96                 :         28 : }
      97                 :            : 
      98                 :         28 : void XMLIndexTitleTemplateContext::Characters(
      99                 :            :     const OUString& sString)
     100                 :            : {
     101                 :         28 :     sContent.append(sString);
     102                 :         28 : }
     103                 :            : 
     104                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10