LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLTextListItemContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 41 67 61.2 %
Date: 2012-08-25 Functions: 5 10 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 32 122 26.2 %

           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 <xmloff/xmlimp.hxx>
      30                 :            : #include <xmloff/nmspmap.hxx>
      31                 :            : #include "xmloff/xmlnmspe.hxx"
      32                 :            : #include <xmloff/xmltoken.hxx>
      33                 :            : #include "txtparai.hxx"
      34                 :            : #include "txtlists.hxx"
      35                 :            : #include "XMLTextListBlockContext.hxx"
      36                 :            : #include <xmloff/txtimp.hxx>
      37                 :            : #include <com/sun/star/container/XNameContainer.hpp>
      38                 :            : #include <com/sun/star/style/XStyle.hpp>
      39                 :            : #include <xmloff/xmlnumi.hxx>
      40                 :            : #include "XMLTextListItemContext.hxx"
      41                 :            : 
      42                 :            : using ::rtl::OUString;
      43                 :            : using ::rtl::OUStringBuffer;
      44                 :            : 
      45                 :            : using namespace ::com::sun::star;
      46                 :            : using namespace ::com::sun::star::uno;
      47                 :            : using namespace ::xmloff::token;
      48                 :            : 
      49 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLTextListItemContext, SvXMLImportContext );
      50                 :            : 
      51                 :         73 : XMLTextListItemContext::XMLTextListItemContext(
      52                 :            :                         SvXMLImport& rImport,
      53                 :            :                         XMLTextImportHelper& rTxtImp,
      54                 :            :                         const sal_uInt16 nPrfx,
      55                 :            :                         const OUString& rLName,
      56                 :            :                         const Reference< xml::sax::XAttributeList > & xAttrList,
      57                 :            :                         const sal_Bool bIsHeader )
      58                 :            :     : SvXMLImportContext( rImport, nPrfx, rLName ),
      59                 :            :       rTxtImport( rTxtImp ),
      60                 :            :       nStartValue( -1 ),
      61                 :            :       mnSubListCount( 0 ),
      62                 :         73 :       mxNumRulesOverride()
      63                 :            : {
      64                 :            :     static ::rtl::OUString s_NumberingRules(
      65 [ +  - ][ +  - ]:         73 :         RTL_CONSTASCII_USTRINGPARAM("NumberingRules"));
         [ #  # ][ +  + ]
      66 [ +  - ][ +  - ]:         73 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
                 [ +  - ]
      67         [ +  + ]:         77 :     for( sal_Int16 i=0; i < nAttrCount; i++ )
      68                 :            :     {
      69 [ +  - ][ +  - ]:          4 :         const OUString& rAttrName = xAttrList->getNameByIndex( i );
      70 [ +  - ][ +  - ]:          4 :         const OUString& rValue = xAttrList->getValueByIndex( i );
      71                 :            : 
      72                 :          4 :         OUString aLocalName;
      73                 :            :         sal_uInt16 nPrefix =
      74                 :          4 :             GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
      75         [ +  - ]:          4 :                                                             &aLocalName );
      76 [ +  - ][ +  - ]:          8 :         if( !bIsHeader && XML_NAMESPACE_TEXT == nPrefix &&
         [ +  - ][ +  - ]
      77         [ +  - ]:          4 :             IsXMLToken( aLocalName, XML_START_VALUE ) )
      78                 :            :         {
      79                 :          4 :             sal_Int32 nTmp = rValue.toInt32();
      80 [ +  - ][ +  - ]:          4 :             if( nTmp >= 0 && nTmp <= SHRT_MAX )
      81                 :          4 :                 nStartValue = (sal_Int16)nTmp;
      82                 :            :         }
      83 [ #  # ][ #  # ]:          0 :         else if ( nPrefix == XML_NAMESPACE_TEXT &&
                 [ #  # ]
      84         [ #  # ]:          0 :                   IsXMLToken( aLocalName, XML_STYLE_OVERRIDE ) )
      85                 :            :         {
      86                 :          0 :             const ::rtl::OUString sListStyleOverrideName = rValue;
      87         [ #  # ]:          0 :             if ( !sListStyleOverrideName.isEmpty() )
      88                 :            :             {
      89                 :            :                 OUString sDisplayStyleName(
      90                 :          0 :                         GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_LIST,
      91         [ #  # ]:          0 :                                                          sListStyleOverrideName ) );
      92                 :            :                 const Reference < container::XNameContainer >& rNumStyles =
      93         [ #  # ]:          0 :                                                     rTxtImp.GetNumberingStyles();
      94 [ #  # ][ #  # ]:          0 :                 if( rNumStyles.is() && rNumStyles->hasByName( sDisplayStyleName ) )
         [ #  # ][ #  # ]
                 [ #  # ]
      95                 :            :                 {
      96                 :          0 :                     Reference < style::XStyle > xStyle;
      97 [ #  # ][ #  # ]:          0 :                     Any aAny = rNumStyles->getByName( sDisplayStyleName );
      98         [ #  # ]:          0 :                     aAny >>= xStyle;
      99                 :            : 
     100         [ #  # ]:          0 :                     uno::Reference< beans::XPropertySet > xPropSet( xStyle, UNO_QUERY );
     101 [ #  # ][ #  # ]:          0 :                     aAny = xPropSet->getPropertyValue(s_NumberingRules);
     102         [ #  # ]:          0 :                     aAny >>= mxNumRulesOverride;
     103                 :            :                 }
     104                 :            :                 else
     105                 :            :                 {
     106                 :            :                     const SvxXMLListStyleContext* pListStyle =
     107         [ #  # ]:          0 :                                         rTxtImp.FindAutoListStyle( sListStyleOverrideName );
     108         [ #  # ]:          0 :                     if( pListStyle )
     109                 :            :                     {
     110         [ #  # ]:          0 :                         mxNumRulesOverride = pListStyle->GetNumRules();
     111         [ #  # ]:          0 :                         if( !mxNumRulesOverride.is() )
     112                 :            :                         {
     113         [ #  # ]:          0 :                             pListStyle->CreateAndInsertAuto();
     114         [ #  # ]:          0 :                             mxNumRulesOverride = pListStyle->GetNumRules();
     115                 :            :                         }
     116                 :            :                     }
     117                 :          0 :                 }
     118                 :          0 :             }
     119                 :            :         }
     120 [ #  # ][ #  # ]:          0 :         else if ( (XML_NAMESPACE_XML == nPrefix) &&
     121         [ #  # ]:          0 :              IsXMLToken(aLocalName, XML_ID)   )
     122                 :            :         {
     123                 :            :             (void) rValue;
     124                 :            : //FIXME: there is no UNO API for list items
     125                 :            :         }
     126                 :          4 :     }
     127                 :            : 
     128                 :            :     // If this is a <text:list-item> element, then remember it as a sign
     129                 :            :     // that a bullet has to be generated.
     130         [ +  - ]:         73 :     if( !bIsHeader ) {
     131 [ +  - ][ +  - ]:         73 :         rTxtImport.GetTextListHelper().SetListItem( this );
     132                 :            :     }
     133                 :            : 
     134                 :         73 : }
     135                 :            : 
     136                 :         73 : XMLTextListItemContext::~XMLTextListItemContext()
     137                 :            : {
     138         [ -  + ]:        146 : }
     139                 :            : 
     140                 :         73 : void XMLTextListItemContext::EndElement()
     141                 :            : {
     142                 :            :     // finish current list item
     143                 :         73 :     rTxtImport.GetTextListHelper().SetListItem( 0 );
     144                 :         73 : }
     145                 :            : 
     146                 :         98 : SvXMLImportContext *XMLTextListItemContext::CreateChildContext(
     147                 :            :         sal_uInt16 nPrefix,
     148                 :            :         const OUString& rLocalName,
     149                 :            :         const Reference< xml::sax::XAttributeList > & xAttrList )
     150                 :            : {
     151                 :         98 :     SvXMLImportContext *pContext = 0;
     152                 :            : 
     153                 :         98 :     const SvXMLTokenMap& rTokenMap = rTxtImport.GetTextElemTokenMap();
     154                 :         98 :     sal_Bool bHeading = sal_False;
     155   [ +  +  +  - ]:         98 :     switch( rTokenMap.Get( nPrefix, rLocalName ) )
     156                 :            :     {
     157                 :            :     case XML_TOK_TEXT_H:
     158                 :          6 :         bHeading = sal_True;
     159                 :            :     case XML_TOK_TEXT_P:
     160                 :         63 :         pContext = new XMLParaContext( GetImport(),
     161                 :            :                                        nPrefix, rLocalName,
     162         [ +  - ]:         63 :                                        xAttrList, bHeading );
     163         [ +  - ]:         63 :         if (rTxtImport.IsProgress())
     164                 :         63 :             GetImport().GetProgressBarHelper()->Increment();
     165                 :            : 
     166                 :         63 :         break;
     167                 :            :     case XML_TOK_TEXT_LIST:
     168                 :         35 :         ++mnSubListCount;
     169                 :         35 :         pContext = new XMLTextListBlockContext( GetImport(), rTxtImport,
     170                 :            :                                                 nPrefix, rLocalName,
     171                 :            :                                                 xAttrList,
     172         [ +  - ]:         35 :                                                 (mnSubListCount > 1) );
     173                 :         35 :         break;
     174                 :            :     }
     175                 :            : 
     176         [ -  + ]:         98 :     if( !pContext )
     177         [ #  # ]:          0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
     178                 :            : 
     179                 :         98 :     return pContext;
     180                 :            : }
     181                 :            : 
     182                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10