LCOV - code coverage report
Current view: top level - xmloff/source/core - xmltkmap.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 35 35 100.0 %
Date: 2015-06-13 12:38:46 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      614263 : class SvXMLTokenMapEntry_Impl
      28             : {
      29             :     sal_uInt16  nPrefixKey;
      30             :     OUString    sLocalName;
      31             :     sal_uInt16  nToken;
      32             : 
      33             : public:
      34             : 
      35      301411 :     sal_uInt16 GetToken() const { return nToken; }
      36             : 
      37      333912 :     SvXMLTokenMapEntry_Impl( sal_uInt16 nPrefix, const OUString& rLName,
      38             :                              sal_uInt16 nTok=XML_TOK_UNKNOWN ) :
      39             :         nPrefixKey( nPrefix ),
      40             :         sLocalName( rLName  ),
      41      333912 :         nToken( nTok )
      42      333912 :     {}
      43             : 
      44      280375 :     explicit SvXMLTokenMapEntry_Impl( const SvXMLTokenMapEntry& rEntry ) :
      45             :         nPrefixKey( rEntry.nPrefixKey ),
      46      280375 :         sLocalName( GetXMLToken( rEntry.eLocalName ) ),
      47      560750 :         nToken( rEntry.nToken )
      48      280375 :     {}
      49             : 
      50     3025225 :     bool operator<( const SvXMLTokenMapEntry_Impl& r ) const
      51             :     {
      52     7220931 :         return nPrefixKey < r.nPrefixKey ||
      53     5144495 :                ( nPrefixKey == r.nPrefixKey &&
      54     5445855 :                  sLocalName < r.sLocalName);
      55             :     }
      56             : };
      57             : 
      58       39466 : class SvXMLTokenMap_Impl : public boost::ptr_set<SvXMLTokenMapEntry_Impl> {};
      59             : 
      60      333912 : SvXMLTokenMapEntry_Impl *SvXMLTokenMap::_Find( sal_uInt16 nKeyPrefix,
      61             :                                                 const OUString& rLName ) const
      62             : {
      63      333912 :     SvXMLTokenMapEntry_Impl *pRet = 0;
      64      333912 :     SvXMLTokenMapEntry_Impl aTst( nKeyPrefix, rLName );
      65             : 
      66      333912 :     SvXMLTokenMap_Impl::iterator it = pImpl->find( aTst );
      67      333912 :     if( it != pImpl->end() )
      68             :     {
      69      301411 :         pRet = &*it;
      70             :     }
      71             : 
      72      333912 :     return pRet;
      73             : }
      74             : 
      75       19736 : SvXMLTokenMap::SvXMLTokenMap( const SvXMLTokenMapEntry *pMap ) :
      76       19736 :     pImpl( new SvXMLTokenMap_Impl )
      77             : {
      78      319847 :     while( pMap->eLocalName != XML_TOKEN_INVALID )
      79             :     {
      80      280375 :         pImpl->insert( new SvXMLTokenMapEntry_Impl( *pMap ) );
      81      280375 :         pMap++;
      82             :     }
      83       19736 : }
      84             : 
      85       19730 : SvXMLTokenMap::~SvXMLTokenMap()
      86             : {
      87       19730 :     delete pImpl;
      88       19730 : }
      89             : 
      90      333912 : sal_uInt16 SvXMLTokenMap::Get( sal_uInt16 nKeyPrefix,
      91             :                                const OUString& rLName ) const
      92             : {
      93      333912 :     SvXMLTokenMapEntry_Impl *pEntry = _Find( nKeyPrefix, rLName );
      94      333912 :     if( pEntry )
      95      301411 :         return pEntry->GetToken();
      96             :     else
      97       32501 :         return XML_TOK_UNKNOWN;
      98             : }
      99             : 
     100             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11