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

Generated by: LCOV version 1.10