LCOV - code coverage report
Current view: top level - dbaccess/source/ui/misc - charsets.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 51 0.0 %
Date: 2014-04-14 Functions: 0 15 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 "charsets.hxx"
      21             : #include <osl/diagnose.h>
      22             : #include "dbu_misc.hrc"
      23             : #include <rtl/tencinfo.h>
      24             : #include <tools/rcid.h>
      25             : #include "localresaccess.hxx"
      26             : 
      27             : namespace dbaui
      28             : {
      29             :     using namespace ::dbtools;
      30             : 
      31             :     // OCharsetDisplay
      32           0 :     OCharsetDisplay::OCharsetDisplay()
      33             :         :OCharsetMap()
      34           0 :         ,SvxTextEncodingTable()
      35             :     {
      36             :         {
      37           0 :             LocalResourceAccess aCharsetStrings( RSC_CHARSETS, RSC_RESOURCE );
      38           0 :             m_aSystemDisplayName = ModuleRes( 1 ).toString();
      39             :         }
      40           0 :     }
      41             : 
      42           0 :     bool OCharsetDisplay::approveEncoding( const rtl_TextEncoding _eEncoding, const rtl_TextEncodingInfo& _rInfo ) const
      43             :     {
      44           0 :         if ( !OCharsetMap::approveEncoding( _eEncoding, _rInfo ) )
      45           0 :             return false;
      46             : 
      47           0 :         if ( RTL_TEXTENCODING_DONTKNOW == _eEncoding )
      48           0 :             return true;
      49             : 
      50           0 :         return !GetTextString(_eEncoding).isEmpty();
      51             :     }
      52             : 
      53           0 :     OCharsetDisplay::const_iterator OCharsetDisplay::begin() const
      54             :     {
      55           0 :         return const_iterator( this, OCharsetMap::begin() );
      56             :     }
      57             : 
      58           0 :     OCharsetDisplay::const_iterator OCharsetDisplay::end() const
      59             :     {
      60           0 :         return const_iterator( this, OCharsetMap::end() );
      61             :     }
      62             : 
      63           0 :     OCharsetDisplay::const_iterator OCharsetDisplay::findEncoding(const rtl_TextEncoding _eEncoding) const
      64             :     {
      65           0 :         OCharsetMap::const_iterator aBaseIter = OCharsetMap::find(_eEncoding);
      66           0 :         return const_iterator( this, aBaseIter );
      67             :     }
      68             : 
      69           0 :     OCharsetDisplay::const_iterator OCharsetDisplay::findIanaName(const OUString& _rIanaName) const
      70             :     {
      71           0 :         OCharsetMap::const_iterator aBaseIter = OCharsetMap::find(_rIanaName, OCharsetMap::IANA());
      72           0 :         return const_iterator( this, aBaseIter );
      73             :     }
      74             : 
      75           0 :     OCharsetDisplay::const_iterator OCharsetDisplay::findDisplayName(const OUString& _rDisplayName) const
      76             :     {
      77           0 :         rtl_TextEncoding eEncoding = RTL_TEXTENCODING_DONTKNOW;
      78           0 :         if ( _rDisplayName != m_aSystemDisplayName )
      79             :         {
      80           0 :             eEncoding = GetTextEncoding( _rDisplayName );
      81             :             OSL_ENSURE( RTL_TEXTENCODING_DONTKNOW != eEncoding,
      82             :                 "OCharsetDisplay::find: non-empty display name, but DONTKNOW!" );
      83             :         }
      84           0 :         return const_iterator( this, OCharsetMap::find( eEncoding ) );
      85             :     }
      86             : 
      87             :     // CharsetDisplayDerefHelper
      88           0 :     CharsetDisplayDerefHelper::CharsetDisplayDerefHelper(const CharsetDisplayDerefHelper& _rSource)
      89             :         :CharsetDisplayDerefHelper_Base(_rSource)
      90           0 :         ,m_sDisplayName(_rSource.m_sDisplayName)
      91             :     {
      92           0 :     }
      93             : 
      94           0 :     CharsetDisplayDerefHelper::CharsetDisplayDerefHelper(const CharsetDisplayDerefHelper_Base& _rBase, const OUString& _rDisplayName)
      95             :         :CharsetDisplayDerefHelper_Base(_rBase)
      96           0 :         ,m_sDisplayName(_rDisplayName)
      97             :     {
      98             :         OSL_ENSURE( !m_sDisplayName.isEmpty(), "CharsetDisplayDerefHelper::CharsetDisplayDerefHelper: invalid display name!" );
      99           0 :     }
     100             : 
     101             :     // OCharsetDisplay::ExtendedCharsetIterator
     102           0 :     OCharsetDisplay::ExtendedCharsetIterator::ExtendedCharsetIterator( const OCharsetDisplay* _pContainer, const base_iterator& _rPosition )
     103             :         :m_pContainer(_pContainer)
     104           0 :         ,m_aPosition(_rPosition)
     105             :     {
     106             :         OSL_ENSURE(m_pContainer, "OCharsetDisplay::ExtendedCharsetIterator::ExtendedCharsetIterator : invalid container!");
     107           0 :     }
     108             : 
     109           0 :     OCharsetDisplay::ExtendedCharsetIterator::ExtendedCharsetIterator(const ExtendedCharsetIterator& _rSource)
     110             :         :m_pContainer( _rSource.m_pContainer )
     111           0 :         ,m_aPosition( _rSource.m_aPosition )
     112             :     {
     113           0 :     }
     114             : 
     115           0 :     CharsetDisplayDerefHelper OCharsetDisplay::ExtendedCharsetIterator::operator*() const
     116             :     {
     117             :         OSL_ENSURE( m_aPosition != m_pContainer->OCharsetDisplay_Base::end(), "OCharsetDisplay::ExtendedCharsetIterator::operator* : invalid position!");
     118             : 
     119           0 :         rtl_TextEncoding eEncoding = (*m_aPosition).getEncoding();
     120             :         return CharsetDisplayDerefHelper(
     121             :             *m_aPosition,
     122             :             RTL_TEXTENCODING_DONTKNOW == eEncoding ? m_pContainer->m_aSystemDisplayName : (OUString)m_pContainer->GetTextString( eEncoding )
     123           0 :         );
     124             :     }
     125             : 
     126           0 :     const OCharsetDisplay::ExtendedCharsetIterator& OCharsetDisplay::ExtendedCharsetIterator::operator++()
     127             :     {
     128             :         OSL_ENSURE( m_aPosition != m_pContainer->OCharsetDisplay_Base::end(), "OCharsetDisplay::ExtendedCharsetIterator::operator++ : invalid position!");
     129           0 :         if ( m_aPosition != m_pContainer->OCharsetDisplay_Base::end() )
     130           0 :             ++m_aPosition;
     131           0 :         return *this;
     132             :     }
     133             : 
     134           0 :     const OCharsetDisplay::ExtendedCharsetIterator& OCharsetDisplay::ExtendedCharsetIterator::operator--()
     135             :     {
     136             :         OSL_ENSURE( m_aPosition != m_pContainer->OCharsetDisplay_Base::begin(), "OCharsetDisplay::ExtendedCharsetIterator::operator-- : invalid position!");
     137           0 :         if ( m_aPosition != m_pContainer->OCharsetDisplay_Base::begin() )
     138           0 :             --m_aPosition;
     139           0 :         return *this;
     140             :     }
     141             : 
     142           0 :     bool operator==(const OCharsetDisplay::ExtendedCharsetIterator& lhs, const OCharsetDisplay::ExtendedCharsetIterator& rhs)
     143             :     {
     144           0 :         return (lhs.m_pContainer == rhs.m_pContainer) && (lhs.m_aPosition == rhs.m_aPosition);
     145             :     }
     146             : 
     147             : }   // namespace dbaui
     148             : 
     149             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10