LCOV - code coverage report
Current view: top level - dbaccess/source/ui/misc - charsets.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 51 0.0 %
Date: 2012-08-25 Functions: 0 15 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 60 0.0 %

           Branch data     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                 :            : 
      21                 :            : #include "charsets.hxx"
      22                 :            : #include <osl/diagnose.h>
      23                 :            : #include "dbu_misc.hrc"
      24                 :            : #include <rtl/tencinfo.h>
      25                 :            : #include <tools/rcid.h>
      26                 :            : #include "localresaccess.hxx"
      27                 :            : 
      28                 :            : //.........................................................................
      29                 :            : namespace dbaui
      30                 :            : {
      31                 :            : //.........................................................................
      32                 :            :     using namespace ::dbtools;
      33                 :            : 
      34                 :            :     //=========================================================================
      35                 :            :     //= OCharsetDisplay
      36                 :            :     //=========================================================================
      37                 :            :     //-------------------------------------------------------------------------
      38                 :          0 :     OCharsetDisplay::OCharsetDisplay()
      39                 :            :         :OCharsetMap()
      40         [ #  # ]:          0 :         ,SvxTextEncodingTable()
      41                 :            :     {
      42                 :            :         {
      43         [ #  # ]:          0 :             LocalResourceAccess aCharsetStrings( RSC_CHARSETS, RSC_RESOURCE );
      44 [ #  # ][ #  # ]:          0 :             m_aSystemDisplayName = String( ModuleRes( 1 ) );
         [ #  # ][ #  # ]
                 [ #  # ]
      45                 :            :         }
      46                 :          0 :     }
      47                 :            : 
      48                 :            :     //-------------------------------------------------------------------------
      49                 :          0 :     sal_Bool OCharsetDisplay::approveEncoding( const rtl_TextEncoding _eEncoding, const rtl_TextEncodingInfo& _rInfo ) const
      50                 :            :     {
      51         [ #  # ]:          0 :         if ( !OCharsetMap::approveEncoding( _eEncoding, _rInfo ) )
      52                 :          0 :             return sal_False;
      53                 :            : 
      54         [ #  # ]:          0 :         if ( RTL_TEXTENCODING_DONTKNOW == _eEncoding )
      55                 :          0 :             return sal_True;
      56                 :            : 
      57                 :          0 :         return !GetTextString(_eEncoding).isEmpty();
      58                 :            :     }
      59                 :            : 
      60                 :            :     //-------------------------------------------------------------------------
      61                 :          0 :     OCharsetDisplay::const_iterator OCharsetDisplay::begin() const
      62                 :            :     {
      63         [ #  # ]:          0 :         return const_iterator( this, OCharsetMap::begin() );
      64                 :            :     }
      65                 :            : 
      66                 :            :     //-------------------------------------------------------------------------
      67                 :          0 :     OCharsetDisplay::const_iterator OCharsetDisplay::end() const
      68                 :            :     {
      69         [ #  # ]:          0 :         return const_iterator( this, OCharsetMap::end() );
      70                 :            :     }
      71                 :            : 
      72                 :            :     //-------------------------------------------------------------------------
      73                 :          0 :     OCharsetDisplay::const_iterator OCharsetDisplay::findEncoding(const rtl_TextEncoding _eEncoding) const
      74                 :            :     {
      75         [ #  # ]:          0 :         OCharsetMap::const_iterator aBaseIter = OCharsetMap::find(_eEncoding);
      76 [ #  # ][ #  # ]:          0 :         return const_iterator( this, aBaseIter );
      77                 :            :     }
      78                 :            : 
      79                 :            :     //-------------------------------------------------------------------------
      80                 :          0 :     OCharsetDisplay::const_iterator OCharsetDisplay::findIanaName(const ::rtl::OUString& _rIanaName) const
      81                 :            :     {
      82         [ #  # ]:          0 :         OCharsetMap::const_iterator aBaseIter = OCharsetMap::find(_rIanaName, OCharsetMap::IANA());
      83 [ #  # ][ #  # ]:          0 :         return const_iterator( this, aBaseIter );
      84                 :            :     }
      85                 :            : 
      86                 :            :     //-------------------------------------------------------------------------
      87                 :          0 :     OCharsetDisplay::const_iterator OCharsetDisplay::findDisplayName(const ::rtl::OUString& _rDisplayName) const
      88                 :            :     {
      89                 :          0 :         rtl_TextEncoding eEncoding = RTL_TEXTENCODING_DONTKNOW;
      90         [ #  # ]:          0 :         if ( _rDisplayName != m_aSystemDisplayName )
      91                 :            :         {
      92         [ #  # ]:          0 :             eEncoding = GetTextEncoding( _rDisplayName );
      93                 :            :             OSL_ENSURE( RTL_TEXTENCODING_DONTKNOW != eEncoding,
      94                 :            :                 "OCharsetDisplay::find: non-empty display name, but DONTKNOW!" );
      95                 :            :         }
      96         [ #  # ]:          0 :         return const_iterator( this, OCharsetMap::find( eEncoding ) );
      97                 :            :     }
      98                 :            : 
      99                 :            :     //=========================================================================
     100                 :            :     //= CharsetDisplayDerefHelper
     101                 :            :     //=========================================================================
     102                 :            :     //-------------------------------------------------------------------------
     103                 :          0 :     CharsetDisplayDerefHelper::CharsetDisplayDerefHelper(const CharsetDisplayDerefHelper& _rSource)
     104                 :            :         :CharsetDisplayDerefHelper_Base(_rSource)
     105                 :          0 :         ,m_sDisplayName(_rSource.m_sDisplayName)
     106                 :            :     {
     107                 :          0 :     }
     108                 :            : 
     109                 :            :     //-------------------------------------------------------------------------
     110                 :          0 :     CharsetDisplayDerefHelper::CharsetDisplayDerefHelper(const CharsetDisplayDerefHelper_Base& _rBase, const ::rtl::OUString& _rDisplayName)
     111                 :            :         :CharsetDisplayDerefHelper_Base(_rBase)
     112                 :          0 :         ,m_sDisplayName(_rDisplayName)
     113                 :            :     {
     114                 :            :         OSL_ENSURE( !m_sDisplayName.isEmpty(), "CharsetDisplayDerefHelper::CharsetDisplayDerefHelper: invalid display name!" );
     115                 :          0 :     }
     116                 :            : 
     117                 :            :     //=========================================================================
     118                 :            :     //= OCharsetDisplay::ExtendedCharsetIterator
     119                 :            :     //=========================================================================
     120                 :            :     //-------------------------------------------------------------------------
     121                 :          0 :     OCharsetDisplay::ExtendedCharsetIterator::ExtendedCharsetIterator( const OCharsetDisplay* _pContainer, const base_iterator& _rPosition )
     122                 :            :         :m_pContainer(_pContainer)
     123                 :          0 :         ,m_aPosition(_rPosition)
     124                 :            :     {
     125                 :            :         OSL_ENSURE(m_pContainer, "OCharsetDisplay::ExtendedCharsetIterator::ExtendedCharsetIterator : invalid container!");
     126                 :          0 :     }
     127                 :            : 
     128                 :            :     //-------------------------------------------------------------------------
     129                 :          0 :     OCharsetDisplay::ExtendedCharsetIterator::ExtendedCharsetIterator(const ExtendedCharsetIterator& _rSource)
     130                 :            :         :m_pContainer( _rSource.m_pContainer )
     131                 :          0 :         ,m_aPosition( _rSource.m_aPosition )
     132                 :            :     {
     133                 :          0 :     }
     134                 :            : 
     135                 :            :     //-------------------------------------------------------------------------
     136                 :          0 :     CharsetDisplayDerefHelper OCharsetDisplay::ExtendedCharsetIterator::operator*() const
     137                 :            :     {
     138                 :            :         OSL_ENSURE( m_aPosition != m_pContainer->OCharsetDisplay_Base::end(), "OCharsetDisplay::ExtendedCharsetIterator::operator* : invalid position!");
     139                 :            : 
     140                 :          0 :         rtl_TextEncoding eEncoding = (*m_aPosition).getEncoding();
     141                 :            :         return CharsetDisplayDerefHelper(
     142                 :            :             *m_aPosition,
     143                 :            :             RTL_TEXTENCODING_DONTKNOW == eEncoding ? m_pContainer->m_aSystemDisplayName : (::rtl::OUString)m_pContainer->GetTextString( eEncoding )
     144 [ #  # ][ #  # ]:          0 :         );
         [ #  # ][ #  # ]
     145                 :            :     }
     146                 :            : 
     147                 :            :     //-------------------------------------------------------------------------
     148                 :          0 :     const OCharsetDisplay::ExtendedCharsetIterator& OCharsetDisplay::ExtendedCharsetIterator::operator++()
     149                 :            :     {
     150                 :            :         OSL_ENSURE( m_aPosition != m_pContainer->OCharsetDisplay_Base::end(), "OCharsetDisplay::ExtendedCharsetIterator::operator++ : invalid position!");
     151 [ #  # ][ #  # ]:          0 :         if ( m_aPosition != m_pContainer->OCharsetDisplay_Base::end() )
     152                 :          0 :             ++m_aPosition;
     153                 :          0 :         return *this;
     154                 :            :     }
     155                 :            : 
     156                 :            :     //-------------------------------------------------------------------------
     157                 :          0 :     const OCharsetDisplay::ExtendedCharsetIterator& OCharsetDisplay::ExtendedCharsetIterator::operator--()
     158                 :            :     {
     159                 :            :         OSL_ENSURE( m_aPosition != m_pContainer->OCharsetDisplay_Base::begin(), "OCharsetDisplay::ExtendedCharsetIterator::operator-- : invalid position!");
     160 [ #  # ][ #  # ]:          0 :         if ( m_aPosition != m_pContainer->OCharsetDisplay_Base::begin() )
     161                 :          0 :             --m_aPosition;
     162                 :          0 :         return *this;
     163                 :            :     }
     164                 :            : 
     165                 :            :     //-------------------------------------------------------------------------
     166                 :          0 :     bool operator==(const OCharsetDisplay::ExtendedCharsetIterator& lhs, const OCharsetDisplay::ExtendedCharsetIterator& rhs)
     167                 :            :     {
     168 [ #  # ][ #  # ]:          0 :         return (lhs.m_pContainer == rhs.m_pContainer) && (lhs.m_aPosition == rhs.m_aPosition);
     169                 :            :     }
     170                 :            : 
     171                 :            : //.........................................................................
     172                 :            : }   // namespace dbaui
     173                 :            : //.........................................................................
     174                 :            : 
     175                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10