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

Generated by: LCOV version 1.10