LCOV - code coverage report
Current view: top level - basctl/source/basicide - basicbox.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 258 0.0 %
Date: 2012-08-25 Functions: 0 46 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 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                 :            : #include <basidesh.hrc>
      21                 :            : #include <basidesh.hxx>
      22                 :            : #include <basobj.hxx>
      23                 :            : 
      24                 :            : #include <basicbox.hxx>
      25                 :            : #include <iderid.hxx>
      26                 :            : #include <iderdll.hxx>
      27                 :            : #include <bastypes.hxx>
      28                 :            : #include "bastype2.hxx"
      29                 :            : #include "basdoc.hxx"
      30                 :            : 
      31                 :            : #include "localizationmgr.hxx"
      32                 :            : #include "managelang.hxx"
      33                 :            : #include "dlgresid.hrc"
      34                 :            : #include <editeng/unolingu.hxx>
      35                 :            : 
      36                 :            : #include <sfx2/dinfdlg.hxx>
      37                 :            : #include <sfx2/dispatch.hxx>
      38                 :            : #include <svtools/langtab.hxx>
      39                 :            : 
      40                 :            : using namespace ::com::sun::star;
      41                 :            : using namespace ::com::sun::star::lang;
      42                 :            : using namespace ::com::sun::star::uno;
      43                 :            : 
      44                 :          0 : SFX_IMPL_TOOLBOX_CONTROL( LibBoxControl, SfxStringItem );
      45                 :            : 
      46                 :          0 : LibBoxControl::LibBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx )
      47                 :          0 :     : SfxToolBoxControl( nSlotId, nId, rTbx )
      48                 :            : {
      49                 :          0 : }
      50                 :            : 
      51                 :            : 
      52                 :            : 
      53                 :          0 : LibBoxControl::~LibBoxControl()
      54                 :            : {
      55                 :          0 : }
      56                 :            : 
      57                 :            : 
      58                 :            : 
      59                 :          0 : void LibBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* pState )
      60                 :            : {
      61                 :          0 :     BasicLibBox* pBox = (BasicLibBox*) GetToolBox().GetItemWindow( GetId() );
      62                 :            : 
      63                 :            :     DBG_ASSERT( pBox, "Box not found" );
      64                 :          0 :     if ( !pBox )
      65                 :          0 :         return;
      66                 :            : 
      67                 :          0 :     if ( eState != SFX_ITEM_AVAILABLE )
      68                 :          0 :         pBox->Disable();
      69                 :            :     else
      70                 :            :     {
      71                 :          0 :         pBox->Enable();
      72                 :          0 :         pBox->Update(dynamic_cast<SfxStringItem const*>(pState));
      73                 :            :     }
      74                 :            : }
      75                 :            : 
      76                 :            : 
      77                 :            : 
      78                 :          0 : Window* LibBoxControl::CreateItemWindow( Window *pParent )
      79                 :            : {
      80                 :          0 :     return new BasicLibBox( pParent, m_xFrame );
      81                 :            : }
      82                 :            : 
      83                 :            : //=============================================================================
      84                 :            : //= DocListenerBox
      85                 :            : //=============================================================================
      86                 :            : 
      87                 :          0 : DocListenerBox::DocListenerBox( Window* pParent )
      88                 :            :     :ListBox( pParent, WinBits( WB_BORDER | WB_DROPDOWN ) )
      89                 :          0 :     ,m_aNotifier( *this )
      90                 :            : {
      91                 :          0 : }
      92                 :            : 
      93                 :          0 : DocListenerBox::~DocListenerBox()
      94                 :            : {
      95                 :          0 :     m_aNotifier.dispose();
      96                 :          0 : }
      97                 :            : 
      98                 :          0 : void DocListenerBox::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
      99                 :            : {
     100                 :          0 :     FillBox();
     101                 :          0 : }
     102                 :            : 
     103                 :          0 : void DocListenerBox::onDocumentOpened( const ScriptDocument& /*_rDocument*/ )
     104                 :            : {
     105                 :          0 :     FillBox();
     106                 :          0 : }
     107                 :            : 
     108                 :          0 : void DocListenerBox::onDocumentSave( const ScriptDocument& /*_rDocument*/ )
     109                 :            : {
     110                 :            :     // not interested in
     111                 :          0 : }
     112                 :            : 
     113                 :          0 : void DocListenerBox::onDocumentSaveDone( const ScriptDocument& /*_rDocument*/ )
     114                 :            : {
     115                 :            :     // not interested in
     116                 :          0 : }
     117                 :            : 
     118                 :          0 : void DocListenerBox::onDocumentSaveAs( const ScriptDocument& /*_rDocument*/ )
     119                 :            : {
     120                 :            :     // not interested in
     121                 :          0 : }
     122                 :            : 
     123                 :          0 : void DocListenerBox::onDocumentSaveAsDone( const ScriptDocument& /*_rDocument*/ )
     124                 :            : {
     125                 :          0 :     FillBox();
     126                 :          0 : }
     127                 :            : 
     128                 :          0 : void DocListenerBox::onDocumentClosed( const ScriptDocument& /*_rDocument*/ )
     129                 :            : {
     130                 :          0 :     FillBox();
     131                 :          0 : }
     132                 :            : 
     133                 :          0 : void DocListenerBox::onDocumentTitleChanged( const ScriptDocument& /*_rDocument*/ )
     134                 :            : {
     135                 :            :     // not interested in
     136                 :          0 : }
     137                 :            : 
     138                 :          0 : void DocListenerBox::onDocumentModeChanged( const ScriptDocument& /*_rDocument*/ )
     139                 :            : {
     140                 :            :     // not interested in
     141                 :          0 : }
     142                 :            : 
     143                 :            : //=============================================================================
     144                 :            : //= BasicLibBox
     145                 :            : //=============================================================================
     146                 :          0 : BasicLibBox::BasicLibBox( Window* pParent, const uno::Reference< frame::XFrame >& rFrame ) :
     147                 :            :     DocListenerBox( pParent ),
     148                 :          0 :     m_xFrame( rFrame )
     149                 :            : {
     150                 :          0 :     FillBox();
     151                 :          0 :     bIgnoreSelect = true;   // do not yet transfer select of 0
     152                 :          0 :     bFillBox = true;
     153                 :          0 :     SelectEntryPos( 0 );
     154                 :          0 :     aCurText = GetEntry( 0 );
     155                 :          0 :     SetSizePixel( Size( 250, 200 ) );
     156                 :          0 :     bIgnoreSelect = false;
     157                 :          0 : }
     158                 :            : 
     159                 :            : 
     160                 :            : 
     161                 :          0 : BasicLibBox::~BasicLibBox()
     162                 :            : {
     163                 :          0 :     ClearBox();
     164                 :          0 : }
     165                 :            : 
     166                 :          0 : void BasicLibBox::Update( const SfxStringItem* pItem )
     167                 :            : {
     168                 :            : 
     169                 :            : //  if ( !pItem  || !pItem->GetValue().Len() )
     170                 :          0 :         FillBox();
     171                 :            : 
     172                 :          0 :     if ( pItem )
     173                 :            :     {
     174                 :          0 :         aCurText = pItem->GetValue();
     175                 :          0 :         if ( aCurText.Len() == 0 )
     176                 :          0 :             aCurText = String( IDEResId( RID_STR_ALL ) );
     177                 :            :     }
     178                 :            : 
     179                 :          0 :     if ( GetSelectEntry() != aCurText )
     180                 :          0 :         SelectEntry( aCurText );
     181                 :          0 : }
     182                 :            : 
     183                 :          0 : void BasicLibBox::ReleaseFocus()
     184                 :            : {
     185                 :          0 :     SfxViewShell* pCurSh = SfxViewShell::Current();
     186                 :            :     DBG_ASSERT( pCurSh, "Current ViewShell not found!" );
     187                 :            : 
     188                 :          0 :     if ( pCurSh )
     189                 :            :     {
     190                 :          0 :         Window* pShellWin = pCurSh->GetWindow();
     191                 :          0 :         if ( !pShellWin )
     192                 :          0 :             pShellWin = Application::GetDefDialogParent();
     193                 :            : 
     194                 :          0 :         pShellWin->GrabFocus();
     195                 :            :     }
     196                 :          0 : }
     197                 :            : 
     198                 :          0 : void BasicLibBox::FillBox()
     199                 :            : {
     200                 :          0 :     SetUpdateMode(false);
     201                 :          0 :     bIgnoreSelect = true;
     202                 :            : 
     203                 :          0 :     aCurText = GetSelectEntry();
     204                 :            : 
     205                 :          0 :     SelectEntryPos( 0 );
     206                 :          0 :     ClearBox();
     207                 :            : 
     208                 :            :     // create list box entries
     209                 :          0 :     sal_uInt16 nPos = InsertEntry( String( IDEResId( RID_STR_ALL ) ), LISTBOX_APPEND );
     210                 :          0 :     SetEntryData( nPos, new BasicLibEntry( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_UNKNOWN, String() ) );
     211                 :          0 :     InsertEntries( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_USER );
     212                 :          0 :     InsertEntries( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_SHARE );
     213                 :            : 
     214                 :          0 :     ScriptDocuments aDocuments( ScriptDocument::getAllScriptDocuments( ScriptDocument::DocumentsSorted ) );
     215                 :          0 :     for (   ScriptDocuments::const_iterator doc = aDocuments.begin();
     216                 :          0 :             doc != aDocuments.end();
     217                 :            :             ++doc
     218                 :            :         )
     219                 :            :     {
     220                 :          0 :         InsertEntries( *doc, LIBRARY_LOCATION_DOCUMENT );
     221                 :            :     }
     222                 :            : 
     223                 :          0 :     SetUpdateMode(true);
     224                 :            : 
     225                 :          0 :     SelectEntry( aCurText );
     226                 :          0 :     if ( !GetSelectEntryCount() )
     227                 :            :     {
     228                 :          0 :         SelectEntryPos( GetEntryCount() );
     229                 :          0 :         aCurText = GetSelectEntry();
     230                 :            :     }
     231                 :          0 :     bIgnoreSelect = false;
     232                 :          0 : }
     233                 :            : 
     234                 :          0 : void BasicLibBox::InsertEntries( const ScriptDocument& rDocument, LibraryLocation eLocation )
     235                 :            : {
     236                 :            :     // get a sorted list of library names
     237                 :          0 :     Sequence< ::rtl::OUString > aLibNames = rDocument.getLibraryNames();
     238                 :          0 :     sal_Int32 nLibCount = aLibNames.getLength();
     239                 :          0 :     const ::rtl::OUString* pLibNames = aLibNames.getConstArray();
     240                 :            : 
     241                 :          0 :     for ( sal_Int32 i = 0 ; i < nLibCount ; ++i )
     242                 :            :     {
     243                 :          0 :         String aLibName = pLibNames[ i ];
     244                 :          0 :         if ( eLocation == rDocument.getLibraryLocation( aLibName ) )
     245                 :            :         {
     246                 :          0 :             String aName( rDocument.getTitle( eLocation ) );
     247                 :          0 :             String aEntryText( CreateMgrAndLibStr( aName, aLibName ) );
     248                 :          0 :             sal_uInt16 nPos = InsertEntry( aEntryText, LISTBOX_APPEND );
     249                 :          0 :             SetEntryData( nPos, new BasicLibEntry( rDocument, eLocation, aLibName ) );
     250                 :            :         }
     251                 :          0 :     }
     252                 :          0 : }
     253                 :            : 
     254                 :          0 : long BasicLibBox::PreNotify( NotifyEvent& rNEvt )
     255                 :            : {
     256                 :          0 :     long nDone = 0;
     257                 :          0 :     if( rNEvt.GetType() == EVENT_KEYINPUT )
     258                 :            :     {
     259                 :          0 :         KeyEvent aKeyEvt = *rNEvt.GetKeyEvent();
     260                 :          0 :         sal_uInt16 nKeyCode = aKeyEvt.GetKeyCode().GetCode();
     261                 :          0 :         switch( nKeyCode )
     262                 :            :         {
     263                 :            :             case KEY_RETURN:
     264                 :            :             {
     265                 :          0 :                 NotifyIDE();
     266                 :          0 :                 nDone = 1;
     267                 :            :             }
     268                 :          0 :             break;
     269                 :            : 
     270                 :            :             case KEY_ESCAPE:
     271                 :            :             {
     272                 :          0 :                 SelectEntry( aCurText );
     273                 :          0 :                 ReleaseFocus();
     274                 :          0 :                 nDone = 1;
     275                 :            :             }
     276                 :          0 :             break;
     277                 :            :         }
     278                 :            :     }
     279                 :          0 :     else if( rNEvt.GetType() == EVENT_GETFOCUS )
     280                 :            :     {
     281                 :          0 :         if ( bFillBox )
     282                 :            :         {
     283                 :          0 :             FillBox();
     284                 :          0 :             bFillBox = false;
     285                 :            :         }
     286                 :            :     }
     287                 :          0 :     else if( rNEvt.GetType() == EVENT_LOSEFOCUS )
     288                 :            :     {
     289                 :          0 :         if ( !HasChildPathFocus(true) )
     290                 :            :         {
     291                 :          0 :             bIgnoreSelect = true;
     292                 :          0 :             bFillBox = true;
     293                 :            :         }
     294                 :            :     }
     295                 :            : 
     296                 :          0 :     return nDone ? nDone : ListBox::PreNotify( rNEvt );
     297                 :            : }
     298                 :            : 
     299                 :          0 : void BasicLibBox::Select()
     300                 :            : {
     301                 :          0 :     if ( !IsTravelSelect() )
     302                 :            :     {
     303                 :          0 :         if ( !bIgnoreSelect )
     304                 :          0 :             NotifyIDE();
     305                 :            :         else
     306                 :          0 :             SelectEntry( aCurText );    // since 306... (Select after Escape)
     307                 :            :     }
     308                 :          0 : }
     309                 :            : 
     310                 :          0 : void BasicLibBox::NotifyIDE()
     311                 :            : {
     312                 :          0 :     sal_uInt16 nSelPos = GetSelectEntryPos();
     313                 :          0 :     BasicLibEntry* pEntry = static_cast<BasicLibEntry*>(GetEntryData( nSelPos ));
     314                 :          0 :     if ( pEntry )
     315                 :            :     {
     316                 :          0 :         ScriptDocument aDocument( pEntry->GetDocument() );
     317                 :          0 :         SfxUsrAnyItem aDocumentItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, uno::makeAny( aDocument.getDocumentOrNull() ) );
     318                 :          0 :         String aLibName = pEntry->GetLibName();
     319                 :          0 :         SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
     320                 :          0 :         BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
     321                 :          0 :         SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
     322                 :          0 :         SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
     323                 :          0 :         if ( pDispatcher )
     324                 :            :         {
     325                 :            :             pDispatcher->Execute( SID_BASICIDE_LIBSELECTED,
     326                 :          0 :                                   SFX_CALLMODE_SYNCHRON, &aDocumentItem, &aLibNameItem, 0L );
     327                 :          0 :         }
     328                 :            :     }
     329                 :          0 :     ReleaseFocus();
     330                 :          0 : }
     331                 :            : 
     332                 :          0 : void BasicLibBox::ClearBox()
     333                 :            : {
     334                 :          0 :     sal_uInt16 nCount = GetEntryCount();
     335                 :          0 :     for ( sal_uInt16 i = 0; i < nCount; ++i )
     336                 :            :     {
     337                 :          0 :         BasicLibEntry* pEntry = static_cast<BasicLibEntry*>(GetEntryData( i ));
     338                 :          0 :         delete pEntry;
     339                 :            :     }
     340                 :          0 :     ListBox::Clear();
     341                 :          0 : }
     342                 :            : 
     343                 :            : // class LanguageBoxControl ----------------------------------------------
     344                 :            : 
     345                 :          0 : SFX_IMPL_TOOLBOX_CONTROL( LanguageBoxControl, SfxStringItem );
     346                 :            : 
     347                 :          0 : LanguageBoxControl::LanguageBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx )
     348                 :          0 :     : SfxToolBoxControl( nSlotId, nId, rTbx )
     349                 :            : {
     350                 :          0 : }
     351                 :            : 
     352                 :          0 : LanguageBoxControl::~LanguageBoxControl()
     353                 :            : {
     354                 :          0 : }
     355                 :            : 
     356                 :          0 : void LanguageBoxControl::StateChanged( sal_uInt16 nID, SfxItemState eState, const SfxPoolItem* pItem )
     357                 :            : {
     358                 :            :     (void)nID;
     359                 :          0 :     if (BasicLanguageBox* pBox = static_cast<BasicLanguageBox*>(GetToolBox().GetItemWindow(GetId())))
     360                 :            :     {
     361                 :          0 :         if (eState != SFX_ITEM_AVAILABLE)
     362                 :          0 :             pBox->Disable();
     363                 :            :         else
     364                 :            :         {
     365                 :          0 :             pBox->Enable();
     366                 :          0 :             pBox->Update(dynamic_cast<SfxStringItem const*>(pItem));
     367                 :            :         }
     368                 :            :     }
     369                 :          0 : }
     370                 :            : 
     371                 :          0 : Window* LanguageBoxControl::CreateItemWindow( Window *pParent )
     372                 :            : {
     373                 :          0 :     return new BasicLanguageBox( pParent );
     374                 :            : }
     375                 :            : 
     376                 :            : // class BasicLanguageBox ------------------------------------------------
     377                 :            : 
     378                 :          0 : BasicLanguageBox::BasicLanguageBox( Window* pParent ) :
     379                 :            : 
     380                 :            :     DocListenerBox( pParent ),
     381                 :            : 
     382                 :            :     m_sNotLocalizedStr( IDEResId( RID_STR_TRANSLATION_NOTLOCALIZED ) ),
     383                 :            :     m_sDefaultLanguageStr( IDEResId( RID_STR_TRANSLATION_DEFAULT ) ),
     384                 :            : 
     385                 :          0 :     m_bIgnoreSelect( false )
     386                 :            : 
     387                 :            : {
     388                 :          0 :     SetSizePixel( Size( 210, 200 ) );
     389                 :            : 
     390                 :          0 :     FillBox();
     391                 :          0 : }
     392                 :            : 
     393                 :          0 : BasicLanguageBox::~BasicLanguageBox()
     394                 :            : {
     395                 :          0 :     ClearBox();
     396                 :          0 : }
     397                 :            : 
     398                 :          0 : void BasicLanguageBox::FillBox()
     399                 :            : {
     400                 :          0 :     SetUpdateMode(false);
     401                 :          0 :     m_bIgnoreSelect = true;
     402                 :          0 :     m_sCurrentText = GetSelectEntry();
     403                 :          0 :     ClearBox();
     404                 :            : 
     405                 :          0 :     boost::shared_ptr<LocalizationMgr> pCurMgr(BasicIDEGlobals::GetShell()->GetCurLocalizationMgr());
     406                 :          0 :     if ( pCurMgr->isLibraryLocalized() )
     407                 :            :     {
     408                 :          0 :         Enable();
     409                 :          0 :         SvtLanguageTable aLangTable;
     410                 :          0 :         Locale aDefaultLocale = pCurMgr->getStringResourceManager()->getDefaultLocale();
     411                 :          0 :         Locale aCurrentLocale = pCurMgr->getStringResourceManager()->getCurrentLocale();
     412                 :          0 :         Sequence< Locale > aLocaleSeq = pCurMgr->getStringResourceManager()->getLocales();
     413                 :          0 :         const Locale* pLocale = aLocaleSeq.getConstArray();
     414                 :          0 :         sal_Int32 i, nCount = aLocaleSeq.getLength();
     415                 :          0 :         sal_uInt16 nSelPos = LISTBOX_ENTRY_NOTFOUND;
     416                 :          0 :         for ( i = 0;  i < nCount;  ++i )
     417                 :            :         {
     418                 :          0 :             bool bIsDefault = localesAreEqual( aDefaultLocale, pLocale[i] );
     419                 :          0 :             bool bIsCurrent = localesAreEqual( aCurrentLocale, pLocale[i] );
     420                 :          0 :             LanguageType eLangType = SvxLocaleToLanguage( pLocale[i] );
     421                 :          0 :             String sLanguage = aLangTable.GetString( eLangType );
     422                 :          0 :             if ( bIsDefault )
     423                 :            :             {
     424                 :          0 :                 sLanguage += ' ';
     425                 :          0 :                 sLanguage += m_sDefaultLanguageStr;
     426                 :            :             }
     427                 :          0 :             sal_uInt16 nPos = InsertEntry( sLanguage );
     428                 :          0 :             SetEntryData( nPos, new LanguageEntry( sLanguage, pLocale[i], bIsDefault ) );
     429                 :            : 
     430                 :          0 :             if ( bIsCurrent )
     431                 :          0 :                 nSelPos = nPos;
     432                 :          0 :         }
     433                 :            : 
     434                 :          0 :         if ( nSelPos != LISTBOX_ENTRY_NOTFOUND )
     435                 :            :         {
     436                 :          0 :             SelectEntryPos( nSelPos );
     437                 :          0 :             m_sCurrentText = GetSelectEntry();
     438                 :          0 :         }
     439                 :            :     }
     440                 :            :     else
     441                 :            :     {
     442                 :          0 :         InsertEntry( m_sNotLocalizedStr );
     443                 :          0 :         SelectEntryPos(0);
     444                 :          0 :         Disable();
     445                 :            :     }
     446                 :            : 
     447                 :          0 :     SetUpdateMode(true);
     448                 :          0 :     m_bIgnoreSelect = false;
     449                 :          0 : }
     450                 :            : 
     451                 :          0 : void BasicLanguageBox::ClearBox()
     452                 :            : {
     453                 :          0 :     sal_uInt16 nCount = GetEntryCount();
     454                 :          0 :     for ( sal_uInt16 i = 0; i < nCount; ++i )
     455                 :            :     {
     456                 :          0 :         LanguageEntry* pEntry = (LanguageEntry*)GetEntryData(i);
     457                 :          0 :         delete pEntry;
     458                 :            :     }
     459                 :          0 :     ListBox::Clear();
     460                 :          0 : }
     461                 :            : 
     462                 :          0 : void BasicLanguageBox::SetLanguage()
     463                 :            : {
     464                 :          0 :     LanguageEntry* pEntry = (LanguageEntry*)GetEntryData( GetSelectEntryPos() );
     465                 :          0 :     if ( pEntry )
     466                 :          0 :         BasicIDEGlobals::GetShell()->GetCurLocalizationMgr()->handleSetCurrentLocale( pEntry->m_aLocale );
     467                 :          0 : }
     468                 :            : 
     469                 :          0 : void BasicLanguageBox::Select()
     470                 :            : {
     471                 :          0 :     if ( !m_bIgnoreSelect )
     472                 :          0 :         SetLanguage();
     473                 :            :     else
     474                 :          0 :         SelectEntry( m_sCurrentText );  // Select after Escape
     475                 :          0 : }
     476                 :            : 
     477                 :          0 : long BasicLanguageBox::PreNotify( NotifyEvent& rNEvt )
     478                 :            : {
     479                 :          0 :     long nDone = 0;
     480                 :          0 :     if( rNEvt.GetType() == EVENT_KEYINPUT )
     481                 :            :     {
     482                 :          0 :         sal_uInt16 nKeyCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
     483                 :          0 :         switch( nKeyCode )
     484                 :            :         {
     485                 :            :             case KEY_RETURN:
     486                 :            :             {
     487                 :          0 :                 SetLanguage();
     488                 :          0 :                 nDone = 1;
     489                 :            :             }
     490                 :          0 :             break;
     491                 :            : 
     492                 :            :             case KEY_ESCAPE:
     493                 :            :             {
     494                 :          0 :                 SelectEntry( m_sCurrentText );
     495                 :          0 :                 nDone = 1;
     496                 :            :             }
     497                 :          0 :             break;
     498                 :            :         }
     499                 :            :     }
     500                 :          0 :     else if( rNEvt.GetType() == EVENT_GETFOCUS )
     501                 :            :     {
     502                 :            :     }
     503                 :          0 :     else if( rNEvt.GetType() == EVENT_LOSEFOCUS )
     504                 :            :     {
     505                 :            :     }
     506                 :            : 
     507                 :          0 :     return nDone ? nDone : ListBox::PreNotify( rNEvt );
     508                 :            : }
     509                 :            : 
     510                 :          0 : void BasicLanguageBox::Update( const SfxStringItem* pItem )
     511                 :            : {
     512                 :          0 :     FillBox();
     513                 :            : 
     514                 :          0 :     if ( pItem && pItem->GetValue().Len() > 0 )
     515                 :            :     {
     516                 :          0 :         m_sCurrentText = pItem->GetValue();
     517                 :          0 :         if ( GetSelectEntry() != m_sCurrentText )
     518                 :          0 :             SelectEntry( m_sCurrentText );
     519                 :            :     }
     520                 :          0 : }
     521                 :            : 
     522                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10