LCOV - code coverage report
Current view: top level - xmloff/source/core - xmltkmap.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 35 35 100.0 %
Date: 2014-11-03 Functions: 11 11 100.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 <rtl/ustring.hxx>
      21             : #include <xmloff/xmltkmap.hxx>
      22             : #include <xmloff/xmltoken.hxx>
      23             : #include <boost/ptr_container/ptr_set.hpp>
      24             : 
      25             : using namespace ::xmloff::token;
      26             : 
      27      802420 : class SvXMLTokenMapEntry_Impl
      28             : {
      29             :     sal_uInt16  nPrefixKey;
      30             :     OUString    sLocalName;
      31             :     sal_uInt16  nToken;
      32             : 
      33             : public:
      34             : 
      35      386642 :     sal_uInt16 GetToken() const { return nToken; }
      36             : 
      37      427250 :     SvXMLTokenMapEntry_Impl( sal_uInt16 nPrefix, const OUString& rLName,
      38             :                              sal_uInt16 nTok=XML_TOK_UNKNOWN ) :
      39             :         nPrefixKey( nPrefix ),
      40             :         sLocalName( rLName  ),
      41      427250 :         nToken( nTok )
      42      427250 :     {}
      43             : 
      44      375210 :     SvXMLTokenMapEntry_Impl( const SvXMLTokenMapEntry& rEntry ) :
      45             :         nPrefixKey( rEntry.nPrefixKey ),
      46      375210 :         sLocalName( GetXMLToken( rEntry.eLocalName ) ),
      47      750420 :         nToken( rEntry.nToken )
      48      375210 :     {}
      49             : 
      50     3903922 :     bool operator<( const SvXMLTokenMapEntry_Impl& r ) const
      51             :     {
      52     9343447 :         return nPrefixKey < r.nPrefixKey ||
      53     6747454 :                ( nPrefixKey == r.nPrefixKey &&
      54     7083760 :                  sLocalName < r.sLocalName);
      55             :     }
      56             : };
      57             : 
      58       55250 : class SvXMLTokenMap_Impl : public boost::ptr_set<SvXMLTokenMapEntry_Impl> {};
      59             : 
      60      427250 : SvXMLTokenMapEntry_Impl *SvXMLTokenMap::_Find( sal_uInt16 nKeyPrefix,
      61             :                                                 const OUString& rLName ) const
      62             : {
      63      427250 :     SvXMLTokenMapEntry_Impl *pRet = 0;
      64      427250 :     SvXMLTokenMapEntry_Impl aTst( nKeyPrefix, rLName );
      65             : 
      66      427250 :     SvXMLTokenMap_Impl::iterator it = pImpl->find( aTst );
      67      427250 :     if( it != pImpl->end() )
      68             :     {
      69      386642 :         pRet = &*it;
      70             :     }
      71             : 
      72      427250 :     return pRet;
      73             : }
      74             : 
      75       27629 : SvXMLTokenMap::SvXMLTokenMap( const SvXMLTokenMapEntry *pMap ) :
      76       27629 :     pImpl( new SvXMLTokenMap_Impl )
      77             : {
      78      430468 :     while( pMap->eLocalName != XML_TOKEN_INVALID )
      79             :     {
      80      375210 :         pImpl->insert( new SvXMLTokenMapEntry_Impl( *pMap ) );
      81      375210 :         pMap++;
      82             :     }
      83       27629 : }
      84             : 
      85       27621 : SvXMLTokenMap::~SvXMLTokenMap()
      86             : {
      87       27621 :     delete pImpl;
      88       27621 : }
      89             : 
      90      427250 : sal_uInt16 SvXMLTokenMap::Get( sal_uInt16 nKeyPrefix,
      91             :                                const OUString& rLName ) const
      92             : {
      93      427250 :     SvXMLTokenMapEntry_Impl *pEntry = _Find( nKeyPrefix, rLName );
      94      427250 :     if( pEntry )
      95      386642 :         return pEntry->GetToken();
      96             :     else
      97       40608 :         return XML_TOK_UNKNOWN;
      98             : }
      99             : 
     100             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10