LCOV - code coverage report
Current view: top level - libreoffice/dbaccess/source/ui/control - charsetlistbox.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 32 0.0 %
Date: 2012-12-27 Functions: 0 5 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 "charsetlistbox.hxx"
      21             : 
      22             : #include <svl/itemset.hxx>
      23             : #include <svl/stritem.hxx>
      24             : #include <osl/diagnose.h>
      25             : 
      26             : //........................................................................
      27             : namespace dbaui
      28             : {
      29             : //........................................................................
      30             : 
      31             :     /** === begin UNO using === **/
      32             :     /** === end UNO using === **/
      33             : 
      34             :     //====================================================================
      35             :     //= CharSetListBox
      36             :     //====================================================================
      37             :     //--------------------------------------------------------------------
      38           0 :     CharSetListBox::CharSetListBox( Window* _pParent, const ResId& _rResId )
      39           0 :         :ListBox( _pParent, _rResId )
      40             :     {
      41           0 :         SetDropDownLineCount( 20 );
      42             : 
      43           0 :         OCharsetDisplay::const_iterator charSet = m_aCharSets.begin();
      44           0 :         while ( charSet != m_aCharSets.end() )
      45             :         {
      46           0 :             InsertEntry( (*charSet).getDisplayName() );
      47           0 :             ++charSet;
      48           0 :         }
      49           0 :     }
      50             : 
      51             :     //--------------------------------------------------------------------
      52           0 :     CharSetListBox::~CharSetListBox()
      53             :     {
      54           0 :     }
      55             : 
      56             :     //--------------------------------------------------------------------
      57           0 :     void CharSetListBox::SelectEntryByIanaName( const String& _rIanaName )
      58             :     {
      59           0 :         OCharsetDisplay::const_iterator aFind = m_aCharSets.findIanaName( _rIanaName );
      60           0 :         if (aFind == m_aCharSets.end())
      61             :         {
      62             :             OSL_FAIL( "CharSetListBox::SelectEntryByIanaName: unknown charset falling back to system language!" );
      63           0 :             aFind = m_aCharSets.findEncoding( RTL_TEXTENCODING_DONTKNOW );
      64             :         }
      65             : 
      66           0 :         if ( aFind == m_aCharSets.end() )
      67             :         {
      68           0 :             SelectEntry( String() );
      69             :         }
      70             :         else
      71             :         {
      72           0 :             String sDisplayName = (*aFind).getDisplayName();
      73           0 :             if ( LISTBOX_ENTRY_NOTFOUND == GetEntryPos( sDisplayName ) )
      74             :             {
      75             :                 // in our settings, there was an encoding selected which is not valid for the current
      76             :                 // data source type
      77             :                 // This is worth at least an assertion.
      78             :                 OSL_FAIL( "CharSetListBox::SelectEntryByIanaName: invalid character set!" );
      79           0 :                 sDisplayName = String();
      80             :             }
      81             : 
      82           0 :             SelectEntry( sDisplayName );
      83           0 :         }
      84           0 :     }
      85             : 
      86             :     //--------------------------------------------------------------------
      87           0 :     bool CharSetListBox::StoreSelectedCharSet( SfxItemSet& _rSet, const sal_uInt16 _nItemId )
      88             :     {
      89           0 :         bool bChangedSomething = false;
      90           0 :         if ( GetSelectEntryPos() != GetSavedValue() )
      91             :         {
      92           0 :             OCharsetDisplay::const_iterator aFind = m_aCharSets.findDisplayName( GetSelectEntry() );
      93             :             OSL_ENSURE( aFind != m_aCharSets.end(), "CharSetListBox::StoreSelectedCharSet: could not translate the selected character set!" );
      94           0 :             if ( aFind != m_aCharSets.end() )
      95             :             {
      96           0 :                 _rSet.Put( SfxStringItem( _nItemId, (*aFind).getIanaName() ) );
      97           0 :                 bChangedSomething = true;
      98           0 :             }
      99             :         }
     100           0 :         return bChangedSomething;
     101             :     }
     102             : 
     103             : //........................................................................
     104             : } // namespace dbaui
     105             : //........................................................................
     106             : 
     107             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10