LCOV - code coverage report
Current view: top level - sw/source/filter/xml - xmlitmpr.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 19 24 79.2 %
Date: 2014-04-11 Functions: 4 6 66.7 %
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 <rtl/ustring.hxx>
      21             : #include "xmlitmap.hxx"
      22             : 
      23             : using ::xmloff::token::IsXMLToken;
      24             : using ::xmloff::token::XML_TOKEN_INVALID;
      25             : 
      26             : // TODO: optimize this!
      27             : class SvXMLItemMapEntries_impl
      28             : {
      29             : public:
      30             :     SvXMLItemMapEntry* mpEntries;
      31             :     sal_uInt16 mnCount;
      32             : };
      33             : 
      34        2260 : SvXMLItemMapEntries::SvXMLItemMapEntries( SvXMLItemMapEntry* pEntries )
      35             : {
      36        2260 :     mpImpl = new SvXMLItemMapEntries_impl;
      37        2260 :     mpImpl->mpEntries = pEntries;
      38             : 
      39        2260 :     mpImpl->mnCount = 0;
      40       32520 :     while( pEntries->eLocalName != XML_TOKEN_INVALID )
      41             :     {
      42       28000 :         pEntries++;
      43       28000 :         mpImpl->mnCount++;
      44             :     }
      45        2260 : }
      46             : 
      47        6780 : SvXMLItemMapEntries::~SvXMLItemMapEntries()
      48             : {
      49        2260 :     delete mpImpl;
      50        4520 : }
      51             : 
      52        1655 : SvXMLItemMapEntry* SvXMLItemMapEntries::getByName(  sal_uInt16 nNameSpace,
      53             :                                                     const OUString& rString,
      54             :                                                     SvXMLItemMapEntry* pStartAt /* = NULL */  ) const
      55             : {
      56             :     SvXMLItemMapEntry* pMap =
      57           0 :         (pStartAt && (pStartAt->eLocalName!=XML_TOKEN_INVALID)) ?
      58        1655 :                                            &(pStartAt[1]) : mpImpl->mpEntries;
      59       20467 :     while( pMap && (pMap->eLocalName != XML_TOKEN_INVALID) )
      60             :     {
      61       28499 :         if( pMap->nNameSpace == nNameSpace &&
      62        9687 :             IsXMLToken( rString, pMap->eLocalName ) )
      63        1655 :             break;
      64       17157 :         pMap++;
      65             :     }
      66             : 
      67        1655 :     return (pMap && (pMap->eLocalName != XML_TOKEN_INVALID)) ? pMap : NULL;
      68             : }
      69             : 
      70           0 : SvXMLItemMapEntry* SvXMLItemMapEntries::getByIndex( sal_uInt16 nIndex ) const
      71             : {
      72           0 :     return &mpImpl->mpEntries[nIndex];
      73             : }
      74             : 
      75           0 : sal_uInt16 SvXMLItemMapEntries::getCount() const
      76             : {
      77           0 :     return mpImpl->mnCount;
      78             : }
      79             : 
      80             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10