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

Generated by: LCOV version 1.10