LCOV - code coverage report
Current view: top level - cui/source/dialogs - cuicharmap.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 330 0.0 %
Date: 2014-04-11 Functions: 0 41 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 <stdio.h>
      21             : 
      22             : #include <tools/shl.hxx>
      23             : #include <vcl/svapp.hxx>
      24             : #include <svtools/colorcfg.hxx>
      25             : #include <svl/eitem.hxx>
      26             : #include <svl/intitem.hxx>
      27             : #include <svl/itempool.hxx>
      28             : 
      29             : #include <rtl/textenc.h>
      30             : #include <svx/ucsubset.hxx>
      31             : #include <sfx2/objsh.hxx>
      32             : #include <vcl/msgbox.hxx>
      33             : #include <vcl/settings.hxx>
      34             : #include <svl/stritem.hxx>
      35             : 
      36             : #include <cuires.hrc>
      37             : #include <dialmgr.hxx>
      38             : #include "cuicharmap.hxx"
      39             : #include <sfx2/request.hxx>
      40             : #include <sfx2/sfxsids.hrc>
      41             : #include <sfx2/app.hxx>
      42             : #include <editeng/fontitem.hxx>
      43             : #include "macroass.hxx"
      44             : 
      45             : // class SvxCharacterMap =================================================
      46             : 
      47           0 : SvxCharacterMap::SvxCharacterMap( Window* pParent, sal_Bool bOne_, const SfxItemSet* pSet )
      48             :     : SfxModalDialog(pParent, "SpecialCharactersDialog", "cui/ui/specialcharacters.ui")
      49             :     , bOne( bOne_ )
      50           0 :     , pSubsetMap( NULL )
      51             : {
      52           0 :     get(m_pShowSet, "showcharset");
      53           0 :     get(m_pShowChar, "showchar");
      54           0 :     m_pShowChar->SetCentered(true);
      55           0 :     get(m_pShowText, "showtext");
      56           0 :     get(m_pOKBtn, "ok");
      57           0 :     get(m_pDeleteBtn, "delete");
      58           0 :     get(m_pDeleteLastBtn, "deletelast");
      59           0 :     get(m_pFontText, "fontft");
      60           0 :     get(m_pFontLB, "fontlb");
      61           0 :     m_pFontLB->SetStyle(m_pFontLB->GetStyle() | WB_SORT);
      62           0 :     get(m_pSubsetText, "subsetft");
      63           0 :     get(m_pSubsetLB, "subsetlb");
      64             :     //lock the size request of this widget to the width of all possible entries
      65           0 :     fillAllSubsets(*m_pSubsetLB);
      66           0 :     m_pSubsetLB->set_width_request(m_pSubsetLB->get_preferred_size().Width());
      67           0 :     get(m_pCharCodeText, "charcodeft");
      68             :     //lock the size request of this widget to the width of the original .ui string
      69           0 :     m_pCharCodeText->set_width_request(m_pCharCodeText->get_preferred_size().Width());
      70           0 :     get(m_pSymbolText, "symboltext");
      71             :     //lock the size request of this widget to double the height of the label
      72           0 :     m_pShowText->set_height_request(m_pSymbolText->get_preferred_size().Height() * 3);
      73             : 
      74           0 :     SFX_ITEMSET_ARG( pSet, pItem, SfxBoolItem, FN_PARAM_1, false );
      75           0 :     if ( pItem )
      76           0 :         bOne = pItem->GetValue();
      77             : 
      78           0 :     init();
      79             : 
      80           0 :     SFX_ITEMSET_ARG( pSet, pCharItem, SfxInt32Item, SID_ATTR_CHAR, false );
      81           0 :     if ( pCharItem )
      82           0 :         SetChar( pCharItem->GetValue() );
      83             : 
      84           0 :     SFX_ITEMSET_ARG( pSet, pDisableItem, SfxBoolItem, FN_PARAM_2, false );
      85           0 :     if ( pDisableItem && pDisableItem->GetValue() )
      86           0 :         DisableFontSelection();
      87             : 
      88           0 :     SFX_ITEMSET_ARG( pSet, pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, false );
      89           0 :     SFX_ITEMSET_ARG( pSet, pFontNameItem, SfxStringItem, SID_FONT_NAME, false );
      90           0 :     if ( pFontItem )
      91             :     {
      92           0 :         Font aTmpFont( pFontItem->GetFamilyName(), pFontItem->GetStyleName(), GetCharFont().GetSize() );
      93           0 :         aTmpFont.SetCharSet( pFontItem->GetCharSet() );
      94           0 :         aTmpFont.SetPitch( pFontItem->GetPitch() );
      95           0 :         SetCharFont( aTmpFont );
      96             :     }
      97           0 :     else if ( pFontNameItem )
      98             :     {
      99           0 :         Font aTmpFont( GetCharFont() );
     100           0 :         aTmpFont.SetName( pFontNameItem->GetValue() );
     101           0 :         SetCharFont( aTmpFont );
     102             :     }
     103             : 
     104           0 :     CreateOutputItemSet( pSet ? *pSet->GetPool() : SFX_APP()->GetPool() );
     105           0 : }
     106             : 
     107             : 
     108             : 
     109           0 : SvxCharacterMap::~SvxCharacterMap()
     110             : {
     111           0 : }
     112             : 
     113             : 
     114             : 
     115           0 : const Font& SvxCharacterMap::GetCharFont() const
     116             : {
     117           0 :     return aFont;
     118             : }
     119             : 
     120             : 
     121             : 
     122           0 : void SvxCharacterMap::SetChar( sal_UCS4 c )
     123             : {
     124           0 :     m_pShowSet->SelectCharacter( c );
     125           0 : }
     126             : 
     127             : 
     128             : 
     129           0 : sal_UCS4 SvxCharacterMap::GetChar() const
     130             : {
     131           0 :     return m_pShowSet->GetSelectCharacter();
     132             : }
     133             : 
     134             : 
     135             : 
     136           0 : OUString SvxCharacterMap::GetCharacters() const
     137             : {
     138           0 :     return m_pShowText->GetText();
     139             : }
     140             : 
     141             : 
     142             : 
     143             : 
     144           0 : void SvxCharacterMap::DisableFontSelection()
     145             : {
     146           0 :     m_pFontText->Disable();
     147           0 :     m_pFontLB->Disable();
     148           0 : }
     149             : 
     150           0 : short SvxCharacterMap::Execute()
     151             : {
     152           0 :     short nResult = SfxModalDialog::Execute();
     153           0 :     if ( nResult == RET_OK )
     154             :     {
     155           0 :         SfxItemSet* pSet = GetItemSet();
     156           0 :         if ( pSet )
     157             :         {
     158           0 :             const SfxItemPool* pPool = pSet->GetPool();
     159           0 :             const Font& rFont( GetCharFont() );
     160           0 :             pSet->Put( SfxStringItem( pPool->GetWhich(SID_CHARMAP), GetCharacters() ) );
     161           0 :             pSet->Put( SvxFontItem( rFont.GetFamily(), rFont.GetName(),
     162           0 :                 rFont.GetStyleName(), rFont.GetPitch(), rFont.GetCharSet(), pPool->GetWhich(SID_ATTR_CHAR_FONT) ) );
     163           0 :             pSet->Put( SfxStringItem( pPool->GetWhich(SID_FONT_NAME), rFont.GetName() ) );
     164           0 :             pSet->Put( SfxInt32Item( pPool->GetWhich(SID_ATTR_CHAR), GetChar() ) );
     165             :         }
     166             :     }
     167             : 
     168           0 :     return nResult;
     169             : }
     170             : 
     171             : 
     172             : // class SvxShowText =====================================================
     173             : 
     174           0 : SvxShowText::SvxShowText(Window* pParent, sal_Bool bCenter)
     175             :     : Control(pParent)
     176             :     , mnY(0)
     177           0 :     , mbCenter(bCenter)
     178           0 : {}
     179             : 
     180           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxShowText(Window *pParent, VclBuilder::stringmap &)
     181             : {
     182           0 :     return new SvxShowText(pParent);
     183             : }
     184             : 
     185             : 
     186             : 
     187           0 : void SvxShowText::Paint( const Rectangle& )
     188             : {
     189           0 :     Color aTextCol = GetTextColor();
     190             : 
     191           0 :     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
     192           0 :     const Color aWindowTextColor( rStyleSettings.GetDialogTextColor() );
     193           0 :     SetTextColor( aWindowTextColor );
     194             : 
     195           0 :     const OUString aText = GetText();
     196           0 :     const Size aSize = GetOutputSizePixel();
     197             : 
     198           0 :     long nAvailWidth = aSize.Width();
     199           0 :     long nWinHeight = GetOutputSizePixel().Height();
     200             : 
     201           0 :     bool bGotBoundary = true;
     202           0 :     bool bShrankFont = false;
     203           0 :     Font aOrigFont(GetFont());
     204           0 :     Size aFontSize(aOrigFont.GetSize());
     205           0 :     Rectangle aBoundRect;
     206             : 
     207           0 :     for (long nFontHeight = aFontSize.Height(); nFontHeight > 0; nFontHeight -= 5)
     208             :     {
     209           0 :         if( !GetTextBoundRect( aBoundRect, aText ) || aBoundRect.IsEmpty() )
     210             :         {
     211           0 :             bGotBoundary = false;
     212           0 :             break;
     213             :         }
     214           0 :         if (!mbCenter)
     215           0 :             break;
     216             :         //only shrink in the single glyph large view mode
     217           0 :         long nTextWidth = aBoundRect.GetWidth();
     218           0 :         if (nAvailWidth > nTextWidth)
     219           0 :             break;
     220           0 :         Font aFont(aOrigFont);
     221           0 :         aFontSize.Height() = nFontHeight;
     222           0 :         aFont.SetSize(aFontSize);
     223           0 :         Control::SetFont(aFont);
     224           0 :         mnY = ( nWinHeight - GetTextHeight() ) / 2;
     225           0 :         bShrankFont = true;
     226           0 :     }
     227             : 
     228           0 :     Point aPoint( 2, mnY );
     229             :     // adjust position using ink boundary if possible
     230           0 :     if( !bGotBoundary )
     231           0 :         aPoint.X() = (aSize.Width() - GetTextWidth( aText )) / 2;
     232             :     else
     233             :     {
     234             :         // adjust position before it gets out of bounds
     235           0 :         aBoundRect += aPoint;
     236             : 
     237             :         // shift back vertically if needed
     238           0 :         int nYLDelta = aBoundRect.Top();
     239           0 :         int nYHDelta = aSize.Height() - aBoundRect.Bottom();
     240           0 :         if( nYLDelta <= 0 )
     241           0 :             aPoint.Y() -= nYLDelta - 1;
     242           0 :         else if( nYHDelta <= 0 )
     243           0 :             aPoint.Y() += nYHDelta - 1;
     244             : 
     245           0 :         if( mbCenter )
     246             :         {
     247             :             // move glyph to middle of cell
     248           0 :             aPoint.X() = -aBoundRect.Left()
     249           0 :                        + (aSize.Width() - aBoundRect.GetWidth()) / 2;
     250             :         }
     251             :         else
     252             :         {
     253             :             // shift back horizontally if needed
     254           0 :             int nXLDelta = aBoundRect.Left();
     255           0 :             int nXHDelta = aSize.Width() - aBoundRect.Right();
     256           0 :             if( nXLDelta <= 0 )
     257           0 :                 aPoint.X() -= nXLDelta - 1;
     258           0 :             else if( nXHDelta <= 0 )
     259           0 :                 aPoint.X() += nXHDelta - 1;
     260             :         }
     261             :     }
     262             : 
     263           0 :     DrawText( aPoint, aText );
     264           0 :     SetTextColor( aTextCol );
     265           0 :     if (bShrankFont)
     266           0 :         Control::SetFont(aOrigFont);
     267           0 : }
     268             : 
     269             : 
     270             : 
     271           0 : void SvxShowText::SetFont( const Font& rFont )
     272             : {
     273           0 :     long nWinHeight = GetOutputSizePixel().Height();
     274           0 :     Font aFont = rFont;
     275           0 :     aFont.SetWeight( WEIGHT_NORMAL );
     276           0 :     aFont.SetAlign( ALIGN_TOP );
     277           0 :     aFont.SetSize( PixelToLogic( Size( 0, nWinHeight/2 ) ) );
     278           0 :     aFont.SetTransparent( true );
     279           0 :     Control::SetFont( aFont );
     280           0 :     mnY = ( nWinHeight - GetTextHeight() ) / 2;
     281             : 
     282           0 :     Invalidate();
     283           0 : }
     284             : 
     285           0 : Size SvxShowText::GetOptimalSize() const
     286             : {
     287           0 :     const Font &rFont = GetFont();
     288           0 :     const Size rFontSize = rFont.GetSize();
     289           0 :     long nWinHeight = LogicToPixel(rFontSize).Height() * 2;
     290           0 :     return Size( GetTextWidth( GetText() ) + 2 * 12, nWinHeight );
     291             : }
     292             : 
     293           0 : void SvxShowText::Resize()
     294             : {
     295           0 :     Control::Resize();
     296           0 :     SetFont(GetFont()); //force recalculation of size
     297           0 : }
     298             : 
     299             : 
     300             : 
     301           0 : void SvxShowText::SetText( const OUString& rText )
     302             : {
     303           0 :     Control::SetText( rText );
     304           0 :     Invalidate();
     305           0 : }
     306             : 
     307             : 
     308             : 
     309           0 : SvxShowText::~SvxShowText()
     310           0 : {}
     311             : 
     312             : // class SvxCharacterMap =================================================
     313             : 
     314           0 : void SvxCharacterMap::init()
     315             : {
     316           0 :     aFont = GetFont();
     317           0 :     aFont.SetTransparent( true );
     318           0 :     aFont.SetFamily( FAMILY_DONTKNOW );
     319           0 :     aFont.SetPitch( PITCH_DONTKNOW );
     320           0 :     aFont.SetCharSet( RTL_TEXTENCODING_DONTKNOW );
     321             : 
     322           0 :     if (bOne)
     323             :     {
     324           0 :         m_pSymbolText->Hide();
     325           0 :         m_pShowText->Hide();
     326           0 :         m_pDeleteBtn->Hide();
     327           0 :         m_pDeleteLastBtn->Hide();
     328             :     }
     329             : 
     330           0 :     OUString aDefStr( aFont.GetName() );
     331           0 :     OUString aLastName;
     332           0 :     int nCount = GetDevFontCount();
     333           0 :     for ( int i = 0; i < nCount; i++ )
     334             :     {
     335           0 :         OUString aFontName( GetDevFont( i ).GetName() );
     336           0 :         if ( aFontName != aLastName )
     337             :         {
     338           0 :             aLastName = aFontName;
     339           0 :             sal_uInt16 nPos = m_pFontLB->InsertEntry( aFontName );
     340           0 :             m_pFontLB->SetEntryData( nPos, (void*)(sal_uLong)i );
     341             :         }
     342           0 :     }
     343             :     // the font may not be in the list =>
     344             :     // try to find a font name token in list and select found font,
     345             :     // else select topmost entry
     346           0 :     bool bFound = (m_pFontLB->GetEntryPos( aDefStr ) == LISTBOX_ENTRY_NOTFOUND );
     347           0 :     if( !bFound )
     348             :     {
     349           0 :         sal_Int32 nIndex = 0;
     350           0 :         do
     351             :         {
     352           0 :             OUString aToken = aDefStr.getToken(0, ';', nIndex);
     353           0 :             if ( m_pFontLB->GetEntryPos( aToken ) != LISTBOX_ENTRY_NOTFOUND )
     354             :             {
     355           0 :                 aDefStr = aToken;
     356           0 :                 bFound = true;
     357           0 :                 break;
     358           0 :             }
     359             :         }
     360           0 :         while ( nIndex >= 0 );
     361             :     }
     362             : 
     363           0 :     if ( bFound )
     364           0 :         m_pFontLB->SelectEntry( aDefStr );
     365           0 :     else if ( m_pFontLB->GetEntryCount() )
     366           0 :         m_pFontLB->SelectEntryPos(0);
     367           0 :     FontSelectHdl(m_pFontLB);
     368             : 
     369           0 :     m_pOKBtn->SetClickHdl( LINK( this, SvxCharacterMap, OKHdl ) );
     370           0 :     m_pFontLB->SetSelectHdl( LINK( this, SvxCharacterMap, FontSelectHdl ) );
     371           0 :     m_pSubsetLB->SetSelectHdl( LINK( this, SvxCharacterMap, SubsetSelectHdl ) );
     372           0 :     m_pShowSet->SetDoubleClickHdl( LINK( this, SvxCharacterMap, CharDoubleClickHdl ) );
     373           0 :     m_pShowSet->SetSelectHdl( LINK( this, SvxCharacterMap, CharSelectHdl ) );
     374           0 :     m_pShowSet->SetHighlightHdl( LINK( this, SvxCharacterMap, CharHighlightHdl ) );
     375           0 :     m_pShowSet->SetPreSelectHdl( LINK( this, SvxCharacterMap, CharPreSelectHdl ) );
     376           0 :     m_pDeleteLastBtn->SetClickHdl( LINK( this, SvxCharacterMap, DeleteLastHdl ) );
     377           0 :     m_pDeleteBtn->SetClickHdl( LINK( this, SvxCharacterMap, DeleteHdl ) );
     378             : 
     379           0 :     if( SvxShowCharSet::getSelectedChar() == ' ')
     380           0 :         m_pOKBtn->Disable();
     381             :     else
     382           0 :         m_pOKBtn->Enable();
     383           0 : }
     384             : 
     385             : 
     386             : 
     387           0 : void SvxCharacterMap::SetCharFont( const Font& rFont )
     388             : {
     389             :     // first get the underlying info in order to get font names
     390             :     // like "Times New Roman;Times" resolved
     391           0 :     Font aTmp( GetFontMetric( rFont ) );
     392             : 
     393           0 :     if ( m_pFontLB->GetEntryPos( aTmp.GetName() ) == LISTBOX_ENTRY_NOTFOUND )
     394           0 :         return;
     395             : 
     396           0 :     m_pFontLB->SelectEntry( aTmp.GetName() );
     397           0 :     aFont = aTmp;
     398           0 :     FontSelectHdl(m_pFontLB);
     399             : 
     400             :     // for compatibility reasons
     401           0 :     ModalDialog::SetFont( aFont );
     402             : }
     403             : 
     404             : 
     405             : 
     406           0 : IMPL_LINK_NOARG(SvxCharacterMap, OKHdl)
     407             : {
     408           0 :     OUString aStr = m_pShowText->GetText();
     409             : 
     410           0 :     if ( aStr.isEmpty() )
     411             :     {
     412           0 :         sal_UCS4 cChar = m_pShowSet->GetSelectCharacter();
     413             :         // using the new UCS4 constructor
     414           0 :         OUString aOUStr( &cChar, 1 );
     415           0 :         m_pShowText->SetText( aOUStr );
     416             :     }
     417           0 :     EndDialog( sal_True );
     418           0 :     return 0;
     419             : }
     420             : 
     421           0 : void SvxCharacterMap::fillAllSubsets(ListBox &rListBox)
     422             : {
     423           0 :     SubsetMap aAll(NULL);
     424           0 :     rListBox.Clear();
     425           0 :     bool bFirst = true;
     426           0 :     while (const Subset *s = aAll.GetNextSubset(bFirst))
     427             :     {
     428           0 :         rListBox.InsertEntry( s->GetName() );
     429           0 :         bFirst = false;
     430           0 :     }
     431           0 : }
     432             : 
     433             : 
     434             : 
     435           0 : IMPL_LINK_NOARG(SvxCharacterMap, FontSelectHdl)
     436             : {
     437           0 :     sal_uInt16 nPos = m_pFontLB->GetSelectEntryPos(),
     438           0 :         nFont = (sal_uInt16)(sal_uLong)m_pFontLB->GetEntryData( nPos );
     439           0 :     aFont = GetDevFont( nFont );
     440           0 :     aFont.SetWeight( WEIGHT_DONTKNOW );
     441           0 :     aFont.SetItalic( ITALIC_NONE );
     442           0 :     aFont.SetWidthType( WIDTH_DONTKNOW );
     443           0 :     aFont.SetPitch( PITCH_DONTKNOW );
     444           0 :     aFont.SetFamily( FAMILY_DONTKNOW );
     445             : 
     446             :     // notify children using this font
     447           0 :     m_pShowSet->SetFont( aFont );
     448           0 :     m_pShowChar->SetFont( aFont );
     449           0 :     m_pShowText->SetFont( aFont );
     450             : 
     451             :     // setup unicode subset listbar with font specific subsets,
     452             :     // hide unicode subset listbar for symbol fonts
     453             :     // TODO: get info from the Font once it provides it
     454           0 :     delete pSubsetMap;
     455           0 :     pSubsetMap = NULL;
     456           0 :     m_pSubsetLB->Clear();
     457             : 
     458           0 :     sal_Bool bNeedSubset = (aFont.GetCharSet() != RTL_TEXTENCODING_SYMBOL);
     459           0 :     if( bNeedSubset )
     460             :     {
     461           0 :         FontCharMap aFontCharMap;
     462           0 :         m_pShowSet->GetFontCharMap( aFontCharMap );
     463           0 :         pSubsetMap = new SubsetMap( &aFontCharMap );
     464             : 
     465             :         // update subset listbox for new font's unicode subsets
     466             :         // TODO: is it worth to improve the stupid linear search?
     467           0 :         bool bFirst = true;
     468             :         const Subset* s;
     469           0 :         while( NULL != (s = pSubsetMap->GetNextSubset( bFirst ))  )
     470             :         {
     471           0 :             sal_uInt16 nPos_ = m_pSubsetLB->InsertEntry( s->GetName() );
     472           0 :             m_pSubsetLB->SetEntryData( nPos_, (void*)s );
     473             :             // NOTE: subset must live at least as long as the selected font
     474           0 :             if( bFirst )
     475           0 :                 m_pSubsetLB->SelectEntryPos( nPos_ );
     476           0 :             bFirst = false;
     477             :         }
     478           0 :         if( m_pSubsetLB->GetEntryCount() <= 1 )
     479           0 :             bNeedSubset = sal_False;
     480             :     }
     481             : 
     482           0 :     m_pSubsetText->Enable(bNeedSubset);
     483           0 :     m_pSubsetLB->Enable(bNeedSubset);
     484             : 
     485           0 :     return 0;
     486             : }
     487             : 
     488             : 
     489             : 
     490           0 : IMPL_LINK_NOARG(SvxCharacterMap, SubsetSelectHdl)
     491             : {
     492           0 :     sal_uInt16 nPos = m_pSubsetLB->GetSelectEntryPos();
     493           0 :     const Subset* pSubset = reinterpret_cast<const Subset*> (m_pSubsetLB->GetEntryData(nPos));
     494           0 :     if( pSubset )
     495             :     {
     496           0 :         sal_UCS4 cFirst = pSubset->GetRangeMin();
     497           0 :         m_pShowSet->SelectCharacter( cFirst );
     498             :     }
     499           0 :     m_pSubsetLB->SelectEntryPos( nPos );
     500           0 :     return 0;
     501             : }
     502             : 
     503             : 
     504             : 
     505           0 : IMPL_LINK_NOARG(SvxCharacterMap, CharDoubleClickHdl)
     506             : {
     507           0 :     if (bOne)
     508             :     {
     509           0 :         sal_UCS4 cChar = m_pShowSet->GetSelectCharacter();
     510           0 :         m_pShowText->SetText(OUString(&cChar, 1));
     511             :     }
     512           0 :     EndDialog( sal_True );
     513           0 :     return 0;
     514             : }
     515             : 
     516             : 
     517             : 
     518           0 : IMPL_LINK_NOARG(SvxCharacterMap, CharSelectHdl)
     519             : {
     520           0 :     if ( !bOne )
     521             :     {
     522           0 :         OUString aText = m_pShowText->GetText();
     523             : 
     524           0 :         if ( aText.getLength() != CHARMAP_MAXLEN )
     525             :         {
     526           0 :             sal_UCS4 cChar = m_pShowSet->GetSelectCharacter();
     527             :             // using the new UCS4 constructor
     528           0 :             OUString aOUStr( &cChar, 1 );
     529           0 :             m_pShowText->SetText( aText + aOUStr );
     530           0 :         }
     531             : 
     532             :     }
     533           0 :     m_pOKBtn->Enable();
     534           0 :     m_pDeleteLastBtn->Enable();
     535           0 :     return 0;
     536             : }
     537             : 
     538             : 
     539             : 
     540           0 : IMPL_LINK_NOARG(SvxCharacterMap, CharHighlightHdl)
     541             : {
     542           0 :     OUString aText;
     543           0 :     sal_UCS4 cChar = m_pShowSet->GetSelectCharacter();
     544           0 :     sal_Bool bSelect = (cChar > 0);
     545             : 
     546             :     // show char sample
     547           0 :     if ( bSelect )
     548             :     {
     549             :         // using the new UCS4 constructor
     550           0 :         aText = OUString( &cChar, 1 );
     551             : 
     552           0 :         const Subset* pSubset = NULL;
     553           0 :         if( pSubsetMap )
     554           0 :             pSubset = pSubsetMap->GetSubsetByUnicode( cChar );
     555           0 :         if( pSubset )
     556           0 :             m_pSubsetLB->SelectEntry( pSubset->GetName() );
     557             :         else
     558           0 :             m_pSubsetLB->SetNoSelection();
     559             :     }
     560           0 :     m_pShowChar->SetText( aText );
     561           0 :     m_pShowChar->Update();
     562             : 
     563             :     // show char code
     564           0 :     if ( bSelect )
     565             :     {
     566             :         char aBuf[32];
     567           0 :         snprintf( aBuf, sizeof(aBuf), "U+%04X", static_cast<unsigned>(cChar) );
     568           0 :         if( cChar < 0x0100 )
     569           0 :             snprintf( aBuf+6, sizeof(aBuf)-6, " (%u)", static_cast<unsigned>(cChar) );
     570           0 :         aText = OUString::createFromAscii(aBuf);
     571             :     }
     572           0 :     m_pCharCodeText->SetText( aText );
     573             : 
     574           0 :     return 0;
     575             : }
     576             : 
     577             : 
     578             : 
     579           0 : IMPL_LINK_NOARG(SvxCharacterMap, CharPreSelectHdl)
     580             : {
     581             :     // adjust subset selection
     582           0 :     if( pSubsetMap )
     583             :     {
     584           0 :         sal_UCS4 cChar = m_pShowSet->GetSelectCharacter();
     585           0 :         const Subset* pSubset = pSubsetMap->GetSubsetByUnicode( cChar );
     586           0 :         if( pSubset )
     587           0 :             m_pSubsetLB->SelectEntry( pSubset->GetName() );
     588             :     }
     589             : 
     590           0 :     m_pOKBtn->Enable();
     591           0 :     return 0;
     592             : }
     593             : 
     594             : 
     595             : 
     596           0 : IMPL_LINK_NOARG(SvxCharacterMap, DeleteLastHdl)
     597             : {
     598           0 :     OUString aCurrentText = m_pShowText->GetText();
     599           0 :     m_pShowText->SetText( aCurrentText.copy( 0, aCurrentText.getLength() - 1 ) );
     600           0 :     if ( m_pShowText->GetText() == "" )
     601             :     {
     602           0 :         m_pOKBtn->Disable();
     603           0 :         m_pDeleteLastBtn->Disable();
     604             :     }
     605           0 :     return 0;
     606             : }
     607             : 
     608           0 : IMPL_LINK_NOARG(SvxCharacterMap, DeleteHdl)
     609             : {
     610           0 :     m_pShowText->SetText( OUString() );
     611           0 :     m_pOKBtn->Disable();
     612           0 :     m_pDeleteLastBtn->Disable();
     613           0 :     return 0;
     614           0 : }
     615             : 
     616             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10