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

Generated by: LCOV version 1.10