LCOV - code coverage report
Current view: top level - cui/source/dialogs - cuicharmap.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 269 0.0 %
Date: 2012-08-25 Functions: 0 34 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 508 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <stdio.h>
      30                 :            : 
      31                 :            : #include <tools/shl.hxx>
      32                 :            : #include <vcl/svapp.hxx>
      33                 :            : #include <svtools/colorcfg.hxx>
      34                 :            : #include <svl/eitem.hxx>
      35                 :            : #include <svl/intitem.hxx>
      36                 :            : #include <svl/itempool.hxx>
      37                 :            : 
      38                 :            : #include <rtl/textenc.h>
      39                 :            : #include <svx/ucsubset.hxx>
      40                 :            : #include <sfx2/objsh.hxx>
      41                 :            : #include <vcl/msgbox.hxx>
      42                 :            : #include <svl/stritem.hxx>
      43                 :            : 
      44                 :            : #include <cuires.hrc>
      45                 :            : #include <dialmgr.hxx>
      46                 :            : #include "cuicharmap.hxx"
      47                 :            : #include <sfx2/request.hxx>
      48                 :            : #include <sfx2/sfxsids.hrc>
      49                 :            : #include <sfx2/app.hxx>
      50                 :            : #include <editeng/fontitem.hxx>
      51                 :            : #include "charmap.hrc"
      52                 :            : #include "macroass.hxx"
      53                 :            : 
      54                 :            : // class SvxCharacterMap =================================================
      55                 :            : 
      56                 :          0 : SvxCharacterMap::SvxCharacterMap( Window* pParent, sal_Bool bOne, const SfxItemSet* pSet ) :
      57                 :          0 :     SfxModalDialog( pParent, CUI_RES( RID_SVXDLG_CHARMAP ) ),
      58         [ #  # ]:          0 :     mpCharMapData( 0 )
      59                 :            : {
      60 [ #  # ][ #  # ]:          0 :     SFX_ITEMSET_ARG( pSet, pItem, SfxBoolItem, FN_PARAM_1, sal_False );
      61         [ #  # ]:          0 :     if ( pItem )
      62                 :          0 :         bOne = pItem->GetValue();
      63                 :            : 
      64 [ #  # ][ #  # ]:          0 :     mpCharMapData =  new SvxCharMapData( this, bOne, &CUI_MGR() );
                 [ #  # ]
      65                 :            : 
      66 [ #  # ][ #  # ]:          0 :     SFX_ITEMSET_ARG( pSet, pCharItem, SfxInt32Item, SID_ATTR_CHAR, sal_False );
      67         [ #  # ]:          0 :     if ( pCharItem )
      68         [ #  # ]:          0 :         SetChar( pCharItem->GetValue() );
      69                 :            : 
      70 [ #  # ][ #  # ]:          0 :     SFX_ITEMSET_ARG( pSet, pDisableItem, SfxBoolItem, FN_PARAM_2, sal_False );
      71 [ #  # ][ #  # ]:          0 :     if ( pDisableItem && pDisableItem->GetValue() )
                 [ #  # ]
      72         [ #  # ]:          0 :         DisableFontSelection();
      73                 :            : 
      74 [ #  # ][ #  # ]:          0 :     SFX_ITEMSET_ARG( pSet, pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, sal_False );
      75 [ #  # ][ #  # ]:          0 :     SFX_ITEMSET_ARG( pSet, pFontNameItem, SfxStringItem, SID_FONT_NAME, sal_False );
      76         [ #  # ]:          0 :     if ( pFontItem )
      77                 :            :     {
      78 [ #  # ][ #  # ]:          0 :         Font aFont( pFontItem->GetFamilyName(), pFontItem->GetStyleName(), GetCharFont().GetSize() );
      79         [ #  # ]:          0 :         aFont.SetCharSet( pFontItem->GetCharSet() );
      80         [ #  # ]:          0 :         aFont.SetPitch( pFontItem->GetPitch() );
      81 [ #  # ][ #  # ]:          0 :         SetCharFont( aFont );
      82                 :            :     }
      83         [ #  # ]:          0 :     else if ( pFontNameItem )
      84                 :            :     {
      85         [ #  # ]:          0 :         Font aFont( GetCharFont() );
      86 [ #  # ][ #  # ]:          0 :         aFont.SetName( pFontNameItem->GetValue() );
      87 [ #  # ][ #  # ]:          0 :         SetCharFont( aFont );
      88                 :            :     }
      89                 :            : 
      90         [ #  # ]:          0 :     FreeResource();
      91 [ #  # ][ #  # ]:          0 :     CreateOutputItemSet( pSet ? *pSet->GetPool() : SFX_APP()->GetPool() );
                 [ #  # ]
      92                 :          0 : }
      93                 :            : 
      94                 :            : // -----------------------------------------------------------------------
      95                 :            : 
      96                 :          0 : SvxCharacterMap::~SvxCharacterMap()
      97                 :            : {
      98 [ #  # ][ #  # ]:          0 :     delete mpCharMapData;
      99         [ #  # ]:          0 : }
     100                 :            : 
     101                 :            : // -----------------------------------------------------------------------
     102                 :            : 
     103                 :          0 : const Font& SvxCharacterMap::GetCharFont() const
     104                 :            : {
     105                 :          0 :     return mpCharMapData->aFont;
     106                 :            : }
     107                 :            : 
     108                 :            : // -----------------------------------------------------------------------
     109                 :            : 
     110                 :          0 : void SvxCharacterMap::SetChar( sal_UCS4 c )
     111                 :            : {
     112                 :          0 :     mpCharMapData->aShowSet.SelectCharacter( c );
     113                 :          0 : }
     114                 :            : 
     115                 :            : // -----------------------------------------------------------------------
     116                 :            : 
     117                 :          0 : sal_UCS4 SvxCharacterMap::GetChar() const
     118                 :            : {
     119                 :          0 :     return mpCharMapData->aShowSet.GetSelectCharacter();
     120                 :            : }
     121                 :            : 
     122                 :            : // -----------------------------------------------------------------------
     123                 :            : 
     124                 :          0 : String SvxCharacterMap::GetCharacters() const
     125                 :            : {
     126                 :          0 :     return mpCharMapData->aShowText.GetText();
     127                 :            : }
     128                 :            : 
     129                 :            : 
     130                 :            : // -----------------------------------------------------------------------
     131                 :            : 
     132                 :          0 : void SvxCharacterMap::DisableFontSelection()
     133                 :            : {
     134                 :          0 :     mpCharMapData->aFontText.Disable();
     135                 :          0 :     mpCharMapData->aFontLB.Disable();
     136                 :          0 : }
     137                 :            : 
     138                 :          0 : void SvxCharacterMap::SetCharFont( const Font& rFont )
     139                 :            : {
     140                 :          0 :     mpCharMapData->SetCharFont( rFont );
     141                 :          0 : }
     142                 :            : 
     143                 :          0 : short SvxCharacterMap::Execute()
     144                 :            : {
     145                 :          0 :     short nResult = SfxModalDialog::Execute();
     146         [ #  # ]:          0 :     if ( nResult == RET_OK )
     147                 :            :     {
     148                 :          0 :         SfxItemSet* pSet = GetItemSet();
     149         [ #  # ]:          0 :         if ( pSet )
     150                 :            :         {
     151                 :          0 :             const SfxItemPool* pPool = pSet->GetPool();
     152                 :          0 :             const Font& rFont( GetCharFont() );
     153 [ #  # ][ #  # ]:          0 :             pSet->Put( SfxStringItem( pPool->GetWhich(SID_CHARMAP), GetCharacters() ) );
         [ #  # ][ #  # ]
     154                 :          0 :             pSet->Put( SvxFontItem( rFont.GetFamily(), rFont.GetName(),
     155         [ #  # ]:          0 :                 rFont.GetStyleName(), rFont.GetPitch(), rFont.GetCharSet(), pPool->GetWhich(SID_ATTR_CHAR_FONT) ) );
     156         [ #  # ]:          0 :             pSet->Put( SfxStringItem( pPool->GetWhich(SID_FONT_NAME), rFont.GetName() ) );
     157         [ #  # ]:          0 :             pSet->Put( SfxInt32Item( pPool->GetWhich(SID_ATTR_CHAR), GetChar() ) );
     158                 :            :         }
     159                 :            :     }
     160                 :            : 
     161                 :          0 :     return nResult;
     162                 :            : }
     163                 :            : 
     164                 :            : 
     165                 :            : // class SvxShowText =====================================================
     166                 :            : 
     167                 :          0 : SvxShowText::SvxShowText( Window* pParent, const ResId& rResId, sal_Bool bCenter )
     168                 :            : :   Control( pParent, rResId ),
     169                 :          0 :     mbCenter( bCenter)
     170                 :          0 : {}
     171                 :            : 
     172                 :            : // -----------------------------------------------------------------------
     173                 :            : 
     174                 :          0 : void SvxShowText::Paint( const Rectangle& )
     175                 :            : {
     176                 :          0 :     Color aTextCol = GetTextColor();
     177                 :            : 
     178         [ #  # ]:          0 :     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
     179                 :          0 :     const Color aWindowTextColor( rStyleSettings.GetDialogTextColor() );
     180         [ #  # ]:          0 :     SetTextColor( aWindowTextColor );
     181                 :            : 
     182         [ #  # ]:          0 :     const String aText = GetText();
     183                 :          0 :     const Size aSize = GetOutputSizePixel();
     184                 :          0 :     Point aPoint( 2, mnY );
     185                 :            : 
     186                 :            :     // adjust position using ink boundary if possible
     187         [ #  # ]:          0 :     Rectangle aBoundRect;
     188 [ #  # ][ #  # ]:          0 :     if( !GetTextBoundRect( aBoundRect, aText ) || aBoundRect.IsEmpty() )
         [ #  # ][ #  # ]
                 [ #  # ]
     189         [ #  # ]:          0 :         aPoint.X() = (aSize.Width() - GetTextWidth( aText )) / 2;
     190                 :            :     else
     191                 :            :     {
     192                 :            :         // adjust position before it gets out of bounds
     193         [ #  # ]:          0 :         aBoundRect += aPoint;
     194                 :            : 
     195                 :            :         // shift back vertically if needed
     196                 :          0 :         int nYLDelta = aBoundRect.Top();
     197                 :          0 :         int nYHDelta = aSize.Height() - aBoundRect.Bottom();
     198         [ #  # ]:          0 :         if( nYLDelta <= 0 )
     199                 :          0 :             aPoint.Y() -= nYLDelta - 1;
     200         [ #  # ]:          0 :         else if( nYHDelta <= 0 )
     201                 :          0 :             aPoint.Y() += nYHDelta - 1;
     202                 :            : 
     203         [ #  # ]:          0 :         if( mbCenter )
     204                 :            :         {
     205                 :            :             // move glyph to middle of cell
     206                 :          0 :             aPoint.X() = -aBoundRect.Left()
     207         [ #  # ]:          0 :                        + (aSize.Width() - aBoundRect.GetWidth()) / 2;
     208                 :            :         }
     209                 :            :         else
     210                 :            :         {
     211                 :            :             // shift back horizontally if needed
     212                 :          0 :             int nXLDelta = aBoundRect.Left();
     213                 :          0 :             int nXHDelta = aSize.Width() - aBoundRect.Right();
     214         [ #  # ]:          0 :             if( nXLDelta <= 0 )
     215                 :          0 :                 aPoint.X() -= nXLDelta - 1;
     216         [ #  # ]:          0 :             else if( nXHDelta <= 0 )
     217                 :          0 :                 aPoint.X() += nXHDelta - 1;
     218                 :            :         }
     219                 :            :     }
     220                 :            : 
     221         [ #  # ]:          0 :     DrawText( aPoint, aText );
     222 [ #  # ][ #  # ]:          0 :     SetTextColor( aTextCol );
     223                 :          0 : }
     224                 :            : 
     225                 :            : // -----------------------------------------------------------------------
     226                 :            : 
     227                 :          0 : void SvxShowText::SetFont( const Font& rFont )
     228                 :            : {
     229                 :          0 :     long nWinHeight = GetOutputSizePixel().Height();
     230         [ #  # ]:          0 :     Font aFont = rFont;
     231         [ #  # ]:          0 :     aFont.SetWeight( WEIGHT_NORMAL );
     232         [ #  # ]:          0 :     aFont.SetAlign( ALIGN_TOP );
     233 [ #  # ][ #  # ]:          0 :     aFont.SetSize( PixelToLogic( Size( 0, nWinHeight/2 ) ) );
     234         [ #  # ]:          0 :     aFont.SetTransparent( sal_True );
     235         [ #  # ]:          0 :     Control::SetFont( aFont );
     236         [ #  # ]:          0 :     mnY = ( nWinHeight - GetTextHeight() ) / 2;
     237                 :            : 
     238 [ #  # ][ #  # ]:          0 :     Invalidate();
     239                 :          0 : }
     240                 :            : 
     241                 :            : // -----------------------------------------------------------------------
     242                 :            : 
     243                 :          0 : void SvxShowText::SetText( const String& rText )
     244                 :            : {
     245                 :          0 :     Control::SetText( rText );
     246                 :          0 :     Invalidate();
     247                 :          0 : }
     248                 :            : 
     249                 :            : // -----------------------------------------------------------------------
     250                 :            : 
     251                 :          0 : SvxShowText::~SvxShowText()
     252         [ #  # ]:          0 : {}
     253                 :            : 
     254                 :            : // class SvxCharacterMap =================================================
     255                 :            : 
     256                 :          0 : SvxCharMapData::SvxCharMapData( SfxModalDialog* pDialog, sal_Bool bOne_, ResMgr* pResContext )
     257                 :            : :   mpDialog( pDialog ),
     258                 :            :     aShowSet        ( pDialog, ResId( CT_SHOWSET, *pResContext ) ),
     259                 :            :     aShowText       ( pDialog, ResId( CT_SHOWTEXT, *pResContext ) ),
     260                 :            :     aOKBtn          ( pDialog, ResId( BTN_CHAR_OK, *pResContext ) ),
     261                 :            :     aCancelBtn      ( pDialog, ResId( BTN_CHAR_CANCEL, *pResContext ) ),
     262                 :            :     aHelpBtn        ( pDialog, ResId( BTN_CHAR_HELP, *pResContext ) ),
     263                 :            :     aDeleteBtn      ( pDialog, ResId( BTN_DELETE, *pResContext ) ),
     264                 :            :     aFontText       ( pDialog, ResId( FT_FONT, *pResContext ) ),
     265                 :            :     aFontLB         ( pDialog, ResId( LB_FONT, *pResContext ) ),
     266                 :            :     aSubsetText     ( pDialog, ResId( FT_SUBSET, *pResContext ) ),
     267                 :            :     aSubsetLB       ( pDialog, ResId( LB_SUBSET, *pResContext ) ),
     268                 :            :     aSymbolText     ( pDialog, ResId( FT_SYMBOLE, *pResContext ) ),
     269                 :            :     aShowChar       ( pDialog, ResId( CT_SHOWCHAR, *pResContext ), sal_True ),
     270                 :            :     aCharCodeText   ( pDialog, ResId( FT_CHARCODE, *pResContext ) ),
     271                 :            :     bOne( bOne_ ),
     272 [ #  # ][ #  # ]:          0 :     pSubsetMap( NULL )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     273                 :            : {
     274         [ #  # ]:          0 :     aFont = pDialog->GetFont();
     275         [ #  # ]:          0 :     aFont.SetTransparent( sal_True );
     276         [ #  # ]:          0 :     aFont.SetFamily( FAMILY_DONTKNOW );
     277         [ #  # ]:          0 :     aFont.SetPitch( PITCH_DONTKNOW );
     278         [ #  # ]:          0 :     aFont.SetCharSet( RTL_TEXTENCODING_DONTKNOW );
     279                 :            : 
     280         [ #  # ]:          0 :     if ( bOne )
     281                 :            :     {
     282         [ #  # ]:          0 :         Size aDlgSize = pDialog->GetSizePixel();
     283                 :          0 :         pDialog->SetSizePixel( Size( aDlgSize.Width(),
     284 [ #  # ][ #  # ]:          0 :             aDlgSize.Height()-aShowText.GetSizePixel().Height() ) );
     285         [ #  # ]:          0 :         aSymbolText.Hide();
     286         [ #  # ]:          0 :         aShowText.Hide();
     287         [ #  # ]:          0 :         aDeleteBtn.Hide();
     288                 :            :     }
     289                 :            : 
     290 [ #  # ][ #  # ]:          0 :     rtl::OUString aDefStr( aFont.GetName() );
     291         [ #  # ]:          0 :     String aLastName;
     292         [ #  # ]:          0 :     int nCount = mpDialog->GetDevFontCount();
     293         [ #  # ]:          0 :     for ( int i = 0; i < nCount; i++ )
     294                 :            :     {
     295 [ #  # ][ #  # ]:          0 :         String aFontName( mpDialog->GetDevFont( i ).GetName() );
         [ #  # ][ #  # ]
     296 [ #  # ][ #  # ]:          0 :         if ( aFontName != aLastName )
     297                 :            :         {
     298         [ #  # ]:          0 :             aLastName = aFontName;
     299         [ #  # ]:          0 :             sal_uInt16 nPos = aFontLB.InsertEntry( aFontName );
     300         [ #  # ]:          0 :             aFontLB.SetEntryData( nPos, (void*)(sal_uLong)i );
     301                 :            :         }
     302         [ #  # ]:          0 :     }
     303                 :            :     // the font may not be in the list =>
     304                 :            :     // try to find a font name token in list and select found font,
     305                 :            :     // else select topmost entry
     306 [ #  # ][ #  # ]:          0 :     bool bFound = (aFontLB.GetEntryPos( aDefStr ) == LISTBOX_ENTRY_NOTFOUND );
                 [ #  # ]
     307         [ #  # ]:          0 :     if( !bFound )
     308                 :            :     {
     309                 :          0 :         sal_Int32 nIndex = 0;
     310         [ #  # ]:          0 :         do
     311                 :            :         {
     312                 :          0 :             rtl::OUString aToken = aDefStr.getToken(0, ';', nIndex);
     313 [ #  # ][ #  # ]:          0 :             if ( aFontLB.GetEntryPos( aToken ) != LISTBOX_ENTRY_NOTFOUND )
         [ #  # ][ #  # ]
     314                 :            :             {
     315                 :          0 :                 aDefStr = aToken;
     316                 :          0 :                 bFound = sal_True;
     317                 :            :                 break;
     318         [ #  # ]:          0 :             }
     319                 :            :         }
     320                 :            :         while ( nIndex >= 0 );
     321                 :            :     }
     322                 :            : 
     323         [ #  # ]:          0 :     if ( bFound )
     324 [ #  # ][ #  # ]:          0 :         aFontLB.SelectEntry( aDefStr );
                 [ #  # ]
     325 [ #  # ][ #  # ]:          0 :     else if ( aFontLB.GetEntryCount() )
     326         [ #  # ]:          0 :         aFontLB.SelectEntryPos(0);
     327         [ #  # ]:          0 :     FontSelectHdl( &aFontLB );
     328                 :            : 
     329         [ #  # ]:          0 :     aOKBtn.SetClickHdl( LINK( this, SvxCharMapData, OKHdl ) );
     330         [ #  # ]:          0 :     aFontLB.SetSelectHdl( LINK( this, SvxCharMapData, FontSelectHdl ) );
     331         [ #  # ]:          0 :     aSubsetLB.SetSelectHdl( LINK( this, SvxCharMapData, SubsetSelectHdl ) );
     332         [ #  # ]:          0 :     aShowSet.SetDoubleClickHdl( LINK( this, SvxCharMapData, CharDoubleClickHdl ) );
     333         [ #  # ]:          0 :     aShowSet.SetSelectHdl( LINK( this, SvxCharMapData, CharSelectHdl ) );
     334         [ #  # ]:          0 :     aShowSet.SetHighlightHdl( LINK( this, SvxCharMapData, CharHighlightHdl ) );
     335         [ #  # ]:          0 :     aShowSet.SetPreSelectHdl( LINK( this, SvxCharMapData, CharPreSelectHdl ) );
     336         [ #  # ]:          0 :     aDeleteBtn.SetClickHdl( LINK( this, SvxCharMapData, DeleteHdl ) );
     337                 :            : 
     338 [ #  # ][ #  # ]:          0 :     if( SvxShowCharSet::getSelectedChar() == ' ')
     339         [ #  # ]:          0 :         aOKBtn.Disable();
     340                 :            :     else
     341         [ #  # ]:          0 :         aOKBtn.Enable();
     342                 :            : 
     343                 :            :     // left align aShowText field
     344         [ #  # ]:          0 :     int nLeftEdge = aSymbolText.GetPosPixel().X();
     345 [ #  # ][ #  # ]:          0 :     nLeftEdge += aSymbolText.GetTextWidth( aSymbolText.GetText() );
                 [ #  # ]
     346 [ #  # ][ #  # ]:          0 :     aShowText.SetPosPixel( Point( nLeftEdge+4, aShowText.GetPosPixel().Y() ) );
                 [ #  # ]
     347                 :          0 : }
     348                 :            : 
     349                 :            : // -----------------------------------------------------------------------
     350                 :            : 
     351                 :          0 : void SvxCharMapData::SetCharFont( const Font& rFont )
     352                 :            : {
     353                 :            :     // first get the underlying info in order to get font names
     354                 :            :     // like "Times New Roman;Times" resolved
     355 [ #  # ][ #  # ]:          0 :     Font aTmp( mpDialog->GetFontMetric( rFont ) );
                 [ #  # ]
     356                 :            : 
     357 [ #  # ][ #  # ]:          0 :     if ( aFontLB.GetEntryPos( aTmp.GetName() ) == LISTBOX_ENTRY_NOTFOUND )
                 [ #  # ]
     358                 :          0 :         return;
     359                 :            : 
     360 [ #  # ][ #  # ]:          0 :     aFontLB.SelectEntry( aTmp.GetName() );
     361         [ #  # ]:          0 :     aFont = aTmp;
     362         [ #  # ]:          0 :     FontSelectHdl( &aFontLB );
     363                 :            : 
     364                 :            :     // for compatibility reasons
     365 [ #  # ][ #  # ]:          0 :     mpDialog->ModalDialog::SetFont( aFont );
                 [ #  # ]
     366                 :            : }
     367                 :            : 
     368                 :            : // -----------------------------------------------------------------------
     369                 :            : 
     370                 :          0 : IMPL_LINK_NOARG(SvxCharMapData, OKHdl)
     371                 :            : {
     372         [ #  # ]:          0 :     String aStr = aShowText.GetText();
     373                 :            : 
     374         [ #  # ]:          0 :     if ( !aStr.Len() )
     375                 :            :     {
     376         [ #  # ]:          0 :         sal_UCS4 cChar = aShowSet.GetSelectCharacter();
     377                 :            :         // using the new UCS4 constructor
     378         [ #  # ]:          0 :     rtl::OUString aOUStr( &cChar, 1 );
     379 [ #  # ][ #  # ]:          0 :         aShowText.SetText( aOUStr );
                 [ #  # ]
     380                 :            :     }
     381         [ #  # ]:          0 :     mpDialog->EndDialog( sal_True );
     382         [ #  # ]:          0 :     return 0;
     383                 :            : }
     384                 :            : 
     385                 :            : // -----------------------------------------------------------------------
     386                 :            : 
     387                 :          0 : IMPL_LINK_NOARG(SvxCharMapData, FontSelectHdl)
     388                 :            : {
     389         [ #  # ]:          0 :     sal_uInt16 nPos = aFontLB.GetSelectEntryPos(),
     390         [ #  # ]:          0 :         nFont = (sal_uInt16)(sal_uLong)aFontLB.GetEntryData( nPos );
     391 [ #  # ][ #  # ]:          0 :     aFont = mpDialog->GetDevFont( nFont );
                 [ #  # ]
     392         [ #  # ]:          0 :     aFont.SetWeight( WEIGHT_DONTKNOW );
     393         [ #  # ]:          0 :     aFont.SetItalic( ITALIC_NONE );
     394         [ #  # ]:          0 :     aFont.SetWidthType( WIDTH_DONTKNOW );
     395         [ #  # ]:          0 :     aFont.SetPitch( PITCH_DONTKNOW );
     396         [ #  # ]:          0 :     aFont.SetFamily( FAMILY_DONTKNOW );
     397                 :            : 
     398                 :            :     // notify children using this font
     399         [ #  # ]:          0 :     aShowSet.SetFont( aFont );
     400         [ #  # ]:          0 :     aShowChar.SetFont( aFont );
     401         [ #  # ]:          0 :     aShowText.SetFont( aFont );
     402                 :            : 
     403                 :            :     // right align some fields to aShowSet
     404         [ #  # ]:          0 :     int nRightEdge = aShowSet.GetPosPixel().X() + aShowSet.GetOutputSizePixel().Width();
     405                 :          0 :     Size aNewSize = aSubsetLB.GetOutputSizePixel();
     406         [ #  # ]:          0 :     aNewSize.setWidth( nRightEdge - aSubsetLB.GetPosPixel().X() );
     407         [ #  # ]:          0 :     aSubsetLB.SetOutputSizePixel( aNewSize );
     408                 :            : 
     409                 :            :     // setup unicode subset listbar with font specific subsets,
     410                 :            :     // hide unicode subset listbar for symbol fonts
     411                 :            :     // TODO: get info from the Font once it provides it
     412         [ #  # ]:          0 :     if( pSubsetMap)
     413 [ #  # ][ #  # ]:          0 :         delete pSubsetMap;
     414                 :          0 :     pSubsetMap = NULL;
     415                 :            : 
     416         [ #  # ]:          0 :     sal_Bool bNeedSubset = (aFont.GetCharSet() != RTL_TEXTENCODING_SYMBOL);
     417         [ #  # ]:          0 :     if( bNeedSubset )
     418                 :            :     {
     419         [ #  # ]:          0 :         FontCharMap aFontCharMap;
     420         [ #  # ]:          0 :         aShowSet.GetFontCharMap( aFontCharMap );
     421 [ #  # ][ #  # ]:          0 :         pSubsetMap = new SubsetMap( &aFontCharMap );
     422                 :            : 
     423                 :            :         // update subset listbox for new font's unicode subsets
     424         [ #  # ]:          0 :         aSubsetLB.Clear();
     425                 :            :         // TODO: is it worth to improve the stupid linear search?
     426                 :          0 :         bool bFirst = true;
     427                 :            :         const Subset* s;
     428 [ #  # ][ #  # ]:          0 :         while( NULL != (s = pSubsetMap->GetNextSubset( bFirst ))  )
     429                 :            :         {
     430 [ #  # ][ #  # ]:          0 :             sal_uInt16 nPos_ = aSubsetLB.InsertEntry( s->GetName() );
                 [ #  # ]
     431         [ #  # ]:          0 :             aSubsetLB.SetEntryData( nPos_, (void*)s );
     432                 :            :             // NOTE: subset must live at least as long as the selected font
     433         [ #  # ]:          0 :             if( bFirst )
     434         [ #  # ]:          0 :                 aSubsetLB.SelectEntryPos( nPos_ );
     435                 :          0 :             bFirst = false;
     436                 :            :         }
     437 [ #  # ][ #  # ]:          0 :         if( aSubsetLB.GetEntryCount() <= 1 )
     438         [ #  # ]:          0 :             bNeedSubset = sal_False;
     439                 :            :     }
     440                 :            : 
     441         [ #  # ]:          0 :     aSubsetText.Show( bNeedSubset);
     442         [ #  # ]:          0 :     aSubsetLB.Show( bNeedSubset);
     443                 :            : 
     444                 :          0 :     return 0;
     445                 :            : }
     446                 :            : 
     447                 :            : // -----------------------------------------------------------------------
     448                 :            : 
     449                 :          0 : IMPL_LINK_NOARG(SvxCharMapData, SubsetSelectHdl)
     450                 :            : {
     451                 :          0 :     sal_uInt16 nPos = aSubsetLB.GetSelectEntryPos();
     452                 :          0 :     const Subset* pSubset = reinterpret_cast<const Subset*> (aSubsetLB.GetEntryData(nPos));
     453         [ #  # ]:          0 :     if( pSubset )
     454                 :            :     {
     455                 :          0 :         sal_UCS4 cFirst = pSubset->GetRangeMin();
     456                 :          0 :         aShowSet.SelectCharacter( cFirst );
     457                 :            :     }
     458                 :          0 :     aSubsetLB.SelectEntryPos( nPos );
     459                 :          0 :     return 0;
     460                 :            : }
     461                 :            : 
     462                 :            : // -----------------------------------------------------------------------
     463                 :            : 
     464                 :          0 : IMPL_LINK_NOARG(SvxCharMapData, CharDoubleClickHdl)
     465                 :            : {
     466                 :          0 :     mpDialog->EndDialog( sal_True );
     467                 :          0 :     return 0;
     468                 :            : }
     469                 :            : 
     470                 :            : // -----------------------------------------------------------------------
     471                 :            : 
     472                 :          0 : IMPL_LINK_NOARG(SvxCharMapData, CharSelectHdl)
     473                 :            : {
     474         [ #  # ]:          0 :     if ( !bOne )
     475                 :            :     {
     476         [ #  # ]:          0 :         String aText = aShowText.GetText();
     477                 :            : 
     478         [ #  # ]:          0 :         if ( aText.Len() != CHARMAP_MAXLEN )
     479                 :            :         {
     480         [ #  # ]:          0 :             sal_UCS4 cChar = aShowSet.GetSelectCharacter();
     481                 :            :             // using the new UCS4 constructor
     482         [ #  # ]:          0 :             rtl::OUString aOUStr( &cChar, 1 );
     483 [ #  # ][ #  # ]:          0 :             aShowText.SetText( aText + aOUStr );
         [ #  # ][ #  # ]
     484         [ #  # ]:          0 :         }
     485                 :            : 
     486                 :            :     }
     487                 :          0 :     aOKBtn.Enable();
     488                 :          0 :     return 0;
     489                 :            : }
     490                 :            : 
     491                 :            : // -----------------------------------------------------------------------
     492                 :            : 
     493                 :          0 : IMPL_LINK_NOARG(SvxCharMapData, CharHighlightHdl)
     494                 :            : {
     495         [ #  # ]:          0 :     String aText;
     496         [ #  # ]:          0 :     sal_UCS4 cChar = aShowSet.GetSelectCharacter();
     497                 :          0 :     sal_Bool bSelect = (cChar > 0);
     498                 :            : 
     499                 :            :     // show char sample
     500         [ #  # ]:          0 :     if ( bSelect )
     501                 :            :     {
     502                 :            :         // using the new UCS4 constructor
     503 [ #  # ][ #  # ]:          0 :         aText = rtl::OUString( &cChar, 1 );
     504                 :            : 
     505                 :          0 :         const Subset* pSubset = NULL;
     506         [ #  # ]:          0 :         if( pSubsetMap )
     507         [ #  # ]:          0 :             pSubset = pSubsetMap->GetSubsetByUnicode( cChar );
     508         [ #  # ]:          0 :         if( pSubset )
     509 [ #  # ][ #  # ]:          0 :             aSubsetLB.SelectEntry( pSubset->GetName() );
                 [ #  # ]
     510                 :            :         else
     511         [ #  # ]:          0 :             aSubsetLB.SetNoSelection();
     512                 :            :     }
     513         [ #  # ]:          0 :     aShowChar.SetText( aText );
     514         [ #  # ]:          0 :     aShowChar.Update();
     515                 :            : 
     516                 :            :     // show char code
     517         [ #  # ]:          0 :     if ( bSelect )
     518                 :            :     {
     519                 :            :         char aBuf[32];
     520                 :          0 :         snprintf( aBuf, sizeof(aBuf), "U+%04X", static_cast<unsigned>(cChar) );
     521         [ #  # ]:          0 :         if( cChar < 0x0100 )
     522                 :          0 :             snprintf( aBuf+6, sizeof(aBuf)-6, " (%u)", static_cast<unsigned>(cChar) );
     523         [ #  # ]:          0 :         aText = rtl::OUString::createFromAscii(aBuf);
     524                 :            :     }
     525         [ #  # ]:          0 :     aCharCodeText.SetText( aText );
     526                 :            : 
     527         [ #  # ]:          0 :     return 0;
     528                 :            : }
     529                 :            : 
     530                 :            : // -----------------------------------------------------------------------
     531                 :            : 
     532                 :          0 : IMPL_LINK_NOARG(SvxCharMapData, CharPreSelectHdl)
     533                 :            : {
     534                 :            :     // adjust subset selection
     535         [ #  # ]:          0 :     if( pSubsetMap )
     536                 :            :     {
     537                 :          0 :         sal_UCS4 cChar = aShowSet.GetSelectCharacter();
     538                 :          0 :         const Subset* pSubset = pSubsetMap->GetSubsetByUnicode( cChar );
     539         [ #  # ]:          0 :         if( pSubset )
     540         [ #  # ]:          0 :             aSubsetLB.SelectEntry( pSubset->GetName() );
     541                 :            :     }
     542                 :            : 
     543                 :          0 :     aOKBtn.Enable();
     544                 :          0 :     return 0;
     545                 :            : }
     546                 :            : 
     547                 :            : // -----------------------------------------------------------------------
     548                 :            : 
     549                 :          0 : IMPL_LINK_NOARG(SvxCharMapData, DeleteHdl)
     550                 :            : {
     551         [ #  # ]:          0 :     aShowText.SetText( String() );
     552                 :          0 :     aOKBtn.Disable();
     553                 :          0 :     return 0;
     554                 :            : }
     555                 :            : 
     556                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10