LCOV - code coverage report
Current view: top level - unotools/source/misc - atom.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 39 0.0 %
Date: 2014-04-14 Functions: 0 8 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 <unotools/atom.hxx>
      21             : 
      22             : using namespace utl;
      23             : using namespace ::com::sun::star::uno;
      24             : using namespace ::com::sun::star::util;
      25             : 
      26           0 : AtomProvider::AtomProvider()
      27             : {
      28           0 :     m_nAtoms = 1;
      29           0 : }
      30             : 
      31           0 : AtomProvider::~AtomProvider()
      32             : {
      33           0 : }
      34             : 
      35           0 : int AtomProvider::getAtom( const OUString& rString, bool bCreate )
      36             : {
      37           0 :     ::boost::unordered_map< OUString, int, OUStringHash >::iterator it = m_aAtomMap.find( rString );
      38           0 :     if( it != m_aAtomMap.end() )
      39           0 :         return it->second;
      40           0 :     if( ! bCreate )
      41           0 :         return INVALID_ATOM;
      42           0 :     m_aAtomMap[ rString ] = m_nAtoms;
      43           0 :     m_aStringMap[ m_nAtoms ] = rString;
      44           0 :     m_nAtoms++;
      45           0 :     return m_nAtoms-1;
      46             : }
      47             : 
      48           0 : const OUString& AtomProvider::getString( int nAtom ) const
      49             : {
      50           0 :     static OUString aEmpty;
      51           0 :     ::boost::unordered_map< int, OUString, ::boost::hash< int > >::const_iterator it = m_aStringMap.find( nAtom );
      52             : 
      53           0 :     return it == m_aStringMap.end() ? aEmpty : it->second;
      54             : }
      55             : 
      56           0 : MultiAtomProvider::MultiAtomProvider()
      57             : {
      58           0 : }
      59             : 
      60           0 : MultiAtomProvider::~MultiAtomProvider()
      61             : {
      62           0 :     for( ::boost::unordered_map< int, AtomProvider*, ::boost::hash< int > >::iterator it = m_aAtomLists.begin(); it != m_aAtomLists.end(); ++it )
      63           0 :         delete it->second;
      64           0 : }
      65             : 
      66           0 : int MultiAtomProvider::getAtom( int atomClass, const OUString& rString, bool bCreate )
      67             : {
      68             :     ::boost::unordered_map< int, AtomProvider*, ::boost::hash< int > >::iterator it =
      69           0 :           m_aAtomLists.find( atomClass );
      70           0 :     if( it != m_aAtomLists.end() )
      71           0 :         return it->second->getAtom( rString, bCreate );
      72             : 
      73           0 :     if( bCreate )
      74             :     {
      75             :         AtomProvider* pNewClass;
      76           0 :         m_aAtomLists[ atomClass ] = pNewClass = new AtomProvider();
      77           0 :         return pNewClass->getAtom( rString, bCreate );
      78             :     }
      79           0 :     return INVALID_ATOM;
      80             : }
      81             : 
      82           0 : const OUString& MultiAtomProvider::getString( int atomClass, int atom ) const
      83             : {
      84             :     ::boost::unordered_map< int, AtomProvider*, ::boost::hash< int > >::const_iterator it =
      85           0 :           m_aAtomLists.find( atomClass );
      86           0 :     if( it != m_aAtomLists.end() )
      87           0 :         return it->second->getString( atom );
      88             : 
      89           0 :     static OUString aEmpty;
      90           0 :     return aEmpty;
      91             : }
      92             : 
      93             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10