LCOV - code coverage report
Current view: top level - libreoffice/svx/source/dialog - charmap.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 522 0.2 %
Date: 2012-12-27 Functions: 2 46 4.3 %
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             : #define _SVX_CHARMAP_CXX_
      23             : #include <vcl/svapp.hxx>
      24             : #include <svtools/colorcfg.hxx>
      25             : 
      26             : #include <rtl/textenc.h>
      27             : #include <svx/ucsubset.hxx>
      28             : 
      29             : #include <svx/dialogs.hrc>
      30             : 
      31             : #include <svx/charmap.hxx>
      32             : #include <svx/dialmgr.hxx>
      33             : #include <svx/svxdlg.hxx>
      34             : 
      35             : #include "charmapacc.hxx"
      36             : #include <com/sun/star/accessibility/AccessibleEventObject.hpp>
      37             : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      38             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      39             : #include <comphelper/types.hxx>
      40             : #include <svl/itemset.hxx>
      41             : 
      42             : #include "rtl/ustrbuf.hxx"
      43             : 
      44             : using namespace ::com::sun::star::accessibility;
      45             : using namespace ::com::sun::star::uno;
      46             : using namespace ::com::sun::star;
      47             : 
      48             : // -----------------------------------------------------------------------
      49           0 : sal_uInt32& SvxShowCharSet::getSelectedChar()
      50             : {
      51             :     static sal_uInt32 cSelectedChar = ' '; // keeps selected character over app livetime
      52           0 :     return cSelectedChar;
      53             : }
      54             : 
      55             : // class SvxShowCharSet ==================================================
      56             : 
      57             : #define SBWIDTH 16
      58             : 
      59           0 : SvxShowCharSet::SvxShowCharSet(Window* pParent, const ResId& rResId)
      60             :     : Control(pParent, rResId)
      61             :     , m_pAccessible(NULL)
      62           0 :     , aVscrollSB(this, WB_VERT)
      63             : {
      64           0 :     init();
      65           0 :     InitSettings( sal_True, sal_True );
      66           0 : }
      67             : 
      68           0 : SvxShowCharSet::SvxShowCharSet(Window* pParent)
      69             :     : Control(pParent, WB_TABSTOP)
      70             :     , m_pAccessible(NULL)
      71           0 :     , aVscrollSB( this, WB_VERT)
      72             : {
      73           0 :     init();
      74           0 :     InitSettings( sal_True, sal_True );
      75           0 : }
      76             : 
      77           0 : void SvxShowCharSet::init()
      78             : {
      79           0 :     nSelectedIndex = -1;    // TODO: move into init list when it is no longer static
      80             : 
      81           0 :     aOrigSize = GetOutputSizePixel();
      82           0 :     aOrigPos = GetPosPixel();
      83             : 
      84           0 :     SetStyle( GetStyle() | WB_CLIPCHILDREN );
      85           0 :     aVscrollSB.SetScrollHdl( LINK( this, SvxShowCharSet, VscrollHdl ) );
      86           0 :     aVscrollSB.EnableDrag( sal_True );
      87             :     // other settings like aVscroll depend on selected font => see SetFont
      88             : 
      89           0 :     bDrag = sal_False;
      90           0 : }
      91             : 
      92           0 : void SvxShowCharSet::Resize()
      93             : {
      94           0 :     aOrigSize = GetOutputSizePixel();
      95           0 :     aOrigPos = GetPosPixel();
      96             : 
      97           0 :     Control::Resize();
      98             : 
      99           0 :     SetFont(GetFont()); //force recalculation of correct fontsize
     100           0 : }
     101             : 
     102           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxShowCharSet(Window *pParent, VclBuilder::stringmap &)
     103             : {
     104           0 :     return new SvxShowCharSet(pParent);
     105             : }
     106             : 
     107             : // -----------------------------------------------------------------------
     108             : 
     109           0 : void SvxShowCharSet::GetFocus()
     110             : {
     111           0 :     Control::GetFocus();
     112           0 :     SelectIndex( nSelectedIndex, sal_True );
     113           0 : }
     114             : 
     115             : // -----------------------------------------------------------------------
     116             : 
     117           0 : void SvxShowCharSet::LoseFocus()
     118             : {
     119           0 :     Control::LoseFocus();
     120           0 :     SelectIndex( nSelectedIndex, sal_False );
     121           0 : }
     122             : 
     123             : // -----------------------------------------------------------------------
     124             : 
     125           0 : void SvxShowCharSet::StateChanged( StateChangedType nType )
     126             : {
     127           0 :     if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
     128           0 :         InitSettings( sal_True, sal_False );
     129           0 :     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
     130           0 :         InitSettings( sal_False, sal_True );
     131             : 
     132           0 :     Control::StateChanged( nType );
     133           0 : }
     134             : 
     135             : // -----------------------------------------------------------------------
     136             : 
     137           0 : void SvxShowCharSet::DataChanged( const DataChangedEvent& rDCEvt )
     138             : {
     139           0 :     if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS )
     140           0 :       && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
     141           0 :         InitSettings( sal_True, sal_True );
     142             :     else
     143           0 :         Control::DataChanged( rDCEvt );
     144           0 : }
     145             : 
     146             : // -----------------------------------------------------------------------
     147             : 
     148           0 : void SvxShowCharSet::MouseButtonDown( const MouseEvent& rMEvt )
     149             : {
     150           0 :     if ( rMEvt.IsLeft() )
     151             :     {
     152           0 :         if ( rMEvt.GetClicks() == 1 )
     153             :         {
     154           0 :             GrabFocus();
     155           0 :             bDrag = sal_True;
     156           0 :             CaptureMouse();
     157             : 
     158           0 :             int nIndex = PixelToMapIndex( rMEvt.GetPosPixel() );
     159           0 :             SelectIndex( nIndex );
     160             :         }
     161             : 
     162           0 :         if ( !(rMEvt.GetClicks() % 2) )
     163           0 :             aDoubleClkHdl.Call( this );
     164             :     }
     165           0 : }
     166             : 
     167             : // -----------------------------------------------------------------------
     168             : 
     169           0 : void SvxShowCharSet::MouseButtonUp( const MouseEvent& rMEvt )
     170             : {
     171           0 :     if ( bDrag && rMEvt.IsLeft() )
     172             :     {
     173             :         // released mouse over character map
     174           0 :         if ( Rectangle(Point(), GetOutputSize()).IsInside(rMEvt.GetPosPixel()))
     175           0 :             aSelectHdl.Call( this );
     176           0 :         ReleaseMouse();
     177           0 :         bDrag = sal_False;
     178             :     }
     179           0 : }
     180             : 
     181             : // -----------------------------------------------------------------------
     182             : 
     183           0 : void SvxShowCharSet::MouseMove( const MouseEvent& rMEvt )
     184             : {
     185           0 :     if ( rMEvt.IsLeft() && bDrag )
     186             :     {
     187           0 :         Point aPos  = rMEvt.GetPosPixel();
     188           0 :         Size  aSize = GetSizePixel();
     189             : 
     190           0 :         if ( aPos.X() < 0 )
     191           0 :             aPos.X() = 0;
     192           0 :         else if ( aPos.X() > aSize.Width()-5 )
     193           0 :             aPos.X() = aSize.Width()-5;
     194           0 :         if ( aPos.Y() < 0 )
     195           0 :             aPos.Y() = 0;
     196           0 :         else if ( aPos.Y() > aSize.Height()-5 )
     197           0 :             aPos.Y() = aSize.Height()-5;
     198             : 
     199           0 :         int nIndex = PixelToMapIndex( aPos );
     200           0 :         SelectIndex( nIndex );
     201             :     }
     202           0 : }
     203             : 
     204             : // -----------------------------------------------------------------------
     205             : 
     206           0 : void SvxShowCharSet::Command( const CommandEvent& rCEvt )
     207             : {
     208           0 :     if( !HandleScrollCommand( rCEvt, 0, &aVscrollSB ) )
     209           0 :         Control::Command( rCEvt );
     210           0 : }
     211             : 
     212             : // -----------------------------------------------------------------------------
     213             : 
     214           0 : sal_uInt16 SvxShowCharSet::GetRowPos(sal_uInt16 _nPos) const
     215             : {
     216           0 :     return _nPos / COLUMN_COUNT ;
     217             : }
     218             : 
     219             : // -----------------------------------------------------------------------------
     220             : 
     221           0 : sal_uInt16 SvxShowCharSet::GetColumnPos(sal_uInt16 _nPos) const
     222             : {
     223           0 :     return _nPos % COLUMN_COUNT ;
     224             : }
     225             : 
     226             : // -----------------------------------------------------------------------
     227             : 
     228           0 : int SvxShowCharSet::FirstInView( void ) const
     229             : {
     230           0 :     int nIndex = 0;
     231           0 :     if( aVscrollSB.IsVisible() )
     232           0 :         nIndex += aVscrollSB.GetThumbPos() * COLUMN_COUNT;
     233           0 :     return nIndex;
     234             : }
     235             : 
     236             : // -----------------------------------------------------------------------
     237             : 
     238           0 : int SvxShowCharSet::LastInView( void ) const
     239             : {
     240           0 :     sal_uIntPtr nIndex = FirstInView();
     241           0 :     nIndex += ROW_COUNT * COLUMN_COUNT - 1;
     242           0 :     sal_uIntPtr nCompare = sal::static_int_cast<sal_uIntPtr>( maFontCharMap.GetCharCount() - 1 );
     243           0 :     if( nIndex > nCompare )
     244           0 :         nIndex = nCompare;
     245           0 :     return nIndex;
     246             : }
     247             : 
     248             : // -----------------------------------------------------------------------
     249             : 
     250           0 : inline Point SvxShowCharSet::MapIndexToPixel( int nIndex ) const
     251             : {
     252           0 :     const int nBase = FirstInView();
     253           0 :     int x = ((nIndex - nBase) % COLUMN_COUNT) * nX;
     254           0 :     int y = ((nIndex - nBase) / COLUMN_COUNT) * nY;
     255           0 :     return Point( x, y );
     256             : }
     257             : // -----------------------------------------------------------------------------
     258             : 
     259           0 : int SvxShowCharSet::PixelToMapIndex( const Point& point) const
     260             : {
     261           0 :     int nBase = FirstInView();
     262           0 :     return (nBase + (point.X()/nX) + (point.Y()/nY) * COLUMN_COUNT);
     263             : }
     264             : 
     265             : // -----------------------------------------------------------------------
     266             : 
     267           0 : void SvxShowCharSet::KeyInput( const KeyEvent& rKEvt )
     268             : {
     269           0 :     KeyCode aCode = rKEvt.GetKeyCode();
     270             : 
     271           0 :     if( aCode.GetModifier() )
     272             :     {
     273           0 :         Control::KeyInput( rKEvt );
     274           0 :         return;
     275             :     }
     276             : 
     277           0 :     int tmpSelected = nSelectedIndex;
     278             : 
     279           0 :     switch ( aCode.GetCode() )
     280             :     {
     281             :         case KEY_SPACE:
     282           0 :             aSelectHdl.Call( this );
     283           0 :             break;
     284             :         case KEY_LEFT:
     285           0 :             --tmpSelected;
     286           0 :             break;
     287             :         case KEY_RIGHT:
     288           0 :             ++tmpSelected;
     289           0 :             break;
     290             :         case KEY_UP:
     291           0 :             tmpSelected -= COLUMN_COUNT;
     292           0 :             break;
     293             :         case KEY_DOWN:
     294           0 :             tmpSelected += COLUMN_COUNT;
     295           0 :             break;
     296             :         case KEY_PAGEUP:
     297           0 :             tmpSelected -= ROW_COUNT * COLUMN_COUNT;
     298           0 :             break;
     299             :         case KEY_PAGEDOWN:
     300           0 :             tmpSelected += ROW_COUNT * COLUMN_COUNT;
     301           0 :             break;
     302             :         case KEY_HOME:
     303           0 :             tmpSelected = 0;
     304           0 :             break;
     305             :         case KEY_END:
     306           0 :             tmpSelected = maFontCharMap.GetCharCount() - 1;
     307           0 :             break;
     308             :         case KEY_TAB:   // some fonts have a character at these unicode control codes
     309             :         case KEY_ESCAPE:
     310             :         case KEY_RETURN:
     311           0 :             Control::KeyInput( rKEvt );
     312           0 :             tmpSelected = - 1;  // mark as invalid
     313           0 :             break;
     314             :         default:
     315             :             {
     316           0 :                 sal_UCS4 cChar = rKEvt.GetCharCode();
     317           0 :                 sal_UCS4 cNext = maFontCharMap.GetNextChar( cChar - 1 );
     318           0 :                 tmpSelected = maFontCharMap.GetIndexFromChar( cNext );
     319           0 :                 if( tmpSelected < 0 || (cChar != cNext) )
     320             :                 {
     321           0 :                     Control::KeyInput( rKEvt );
     322           0 :                     tmpSelected = - 1;  // mark as invalid
     323             :                 }
     324             :             }
     325             :     }
     326             : 
     327           0 :     if ( tmpSelected >= 0 )
     328             :     {
     329           0 :         SelectIndex( tmpSelected, sal_True );
     330           0 :         aPreSelectHdl.Call( this );
     331             :     }
     332             : }
     333             : 
     334             : // -----------------------------------------------------------------------
     335             : 
     336           0 : void SvxShowCharSet::Paint( const Rectangle& )
     337             : {
     338           0 :     DrawChars_Impl( FirstInView(), LastInView() );
     339           0 : }
     340             : // -----------------------------------------------------------------------------
     341           0 : void SvxShowCharSet::DeSelect()
     342             : {
     343           0 :     DrawChars_Impl(nSelectedIndex,nSelectedIndex);
     344           0 : }
     345             : // -----------------------------------------------------------------------
     346             : 
     347           0 : void SvxShowCharSet::DrawChars_Impl( int n1, int n2 )
     348             : {
     349           0 :     if( n1 > LastInView() || n2 < FirstInView() )
     350           0 :         return;
     351             : 
     352           0 :     Size aOutputSize = GetOutputSizePixel();
     353           0 :     if( aVscrollSB.IsVisible() )
     354           0 :         aOutputSize.setWidth( aOutputSize.Width() - SBWIDTH );
     355             : 
     356             :     int i;
     357           0 :     for ( i = 1; i < COLUMN_COUNT; ++i )
     358           0 :         DrawLine( Point( nX * i, 0 ), Point( nX * i, aOutputSize.Height() ) );
     359           0 :     for ( i = 1; i < ROW_COUNT; ++i )
     360           0 :         DrawLine( Point( 0, nY * i ), Point( aOutputSize.Width(), nY * i ) );
     361             : 
     362           0 :     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
     363           0 :     const Color aWindowTextColor( rStyleSettings.GetFieldTextColor() );
     364           0 :     Color aHighlightColor( rStyleSettings.GetHighlightColor() );
     365           0 :     Color aHighlightTextColor( rStyleSettings.GetHighlightTextColor() );
     366           0 :     Color aFaceColor( rStyleSettings.GetFaceColor() );
     367           0 :     Color aLightColor( rStyleSettings.GetLightColor() );
     368           0 :     Color aShadowColor( rStyleSettings.GetShadowColor() );
     369             : 
     370           0 :     int nTextHeight = GetTextHeight();
     371           0 :     Rectangle aBoundRect;
     372           0 :     for( i = n1; i <= n2; ++i )
     373             :     {
     374           0 :         Point pix = MapIndexToPixel( i );
     375           0 :         int x = pix.X();
     376           0 :         int y = pix.Y();
     377             : 
     378           0 :         rtl::OUStringBuffer buf;
     379           0 :         buf.appendUtf32( maFontCharMap.GetCharFromIndex( i ) );
     380           0 :         String aCharStr(buf.makeStringAndClear());
     381           0 :         int nTextWidth = GetTextWidth(aCharStr);
     382           0 :         int tx = x + (nX - nTextWidth + 1) / 2;
     383           0 :         int ty = y + (nY - nTextHeight + 1) / 2;
     384           0 :         Point aPointTxTy( tx, ty );
     385             : 
     386             :         // adjust position before it gets out of bounds
     387           0 :         if( GetTextBoundRect( aBoundRect, aCharStr ) && !aBoundRect.IsEmpty() )
     388             :         {
     389             :             // zero advance width => use ink width to center glyph
     390           0 :             if( !nTextWidth )
     391             :             {
     392           0 :                 aPointTxTy.X() = x - aBoundRect.Left()
     393           0 :                                + (nX - aBoundRect.GetWidth() + 1) / 2;
     394             :             }
     395             : 
     396           0 :             aBoundRect += aPointTxTy;
     397             : 
     398             :             // shift back vertically if needed
     399           0 :             int nYLDelta = aBoundRect.Top() - y;
     400           0 :             int nYHDelta = (y + nY) - aBoundRect.Bottom();
     401           0 :             if( nYLDelta <= 0 )
     402           0 :                 aPointTxTy.Y() -= nYLDelta - 1;
     403           0 :             else if( nYHDelta <= 0 )
     404           0 :                 aPointTxTy.Y() += nYHDelta - 1;
     405             : 
     406             :             // shift back horizontally if needed
     407           0 :             int nXLDelta = aBoundRect.Left() - x;
     408           0 :             int nXHDelta = (x + nX) - aBoundRect.Right();
     409           0 :             if( nXLDelta <= 0 )
     410           0 :                 aPointTxTy.X() -= nXLDelta - 1;
     411           0 :             else if( nXHDelta <= 0 )
     412           0 :                 aPointTxTy.X() += nXHDelta - 1;
     413             :         }
     414             : 
     415           0 :         Color aTextCol = GetTextColor();
     416           0 :         if ( i != nSelectedIndex )
     417             :         {
     418           0 :             SetTextColor( aWindowTextColor );
     419           0 :             DrawText( aPointTxTy, aCharStr );
     420             :         }
     421             :         else
     422             :         {
     423           0 :             Color aLineCol = GetLineColor();
     424           0 :             Color aFillCol = GetFillColor();
     425           0 :             SetLineColor();
     426           0 :             Point aPointUL( x + 1, y + 1 );
     427           0 :             if( HasFocus() )
     428             :             {
     429           0 :                 SetFillColor( aHighlightColor );
     430           0 :                 DrawRect( Rectangle( aPointUL, Size(nX-1,nY-1) ) );
     431             : 
     432           0 :                 SetTextColor( aHighlightTextColor );
     433           0 :                 DrawText( aPointTxTy, aCharStr );
     434             :             }
     435             :             else
     436             :             {
     437           0 :                 SetFillColor( aFaceColor );
     438           0 :                 DrawRect( Rectangle( aPointUL, Size( nX-1, nY-1) ) );
     439             : 
     440           0 :                 SetLineColor( aLightColor );
     441           0 :                 DrawLine( aPointUL, Point( x+nX-1, y+1) );
     442           0 :                 DrawLine( aPointUL, Point( x+1, y+nY-1) );
     443             : 
     444           0 :                 SetLineColor( aShadowColor );
     445           0 :                 DrawLine( Point( x+1, y+nY-1), Point( x+nX-1, y+nY-1) );
     446           0 :                 DrawLine( Point( x+nX-1, y+nY-1), Point( x+nX-1, y+1) );
     447             : 
     448           0 :                 DrawText( aPointTxTy, aCharStr );
     449             :             }
     450           0 :             SetLineColor( aLineCol );
     451           0 :             SetFillColor( aFillCol );
     452             :         }
     453           0 :         SetTextColor( aTextCol );
     454           0 :     }
     455             : }
     456             : 
     457             : // -----------------------------------------------------------------------
     458             : 
     459           0 : void SvxShowCharSet::InitSettings( sal_Bool bForeground, sal_Bool bBackground )
     460             : {
     461           0 :     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
     462             : 
     463           0 :     if ( bForeground )
     464             :     {
     465           0 :         Color aTextColor( rStyleSettings.GetDialogTextColor() );
     466             : 
     467           0 :         if ( IsControlForeground() )
     468           0 :             aTextColor = GetControlForeground();
     469           0 :         SetTextColor( aTextColor );
     470             :     }
     471             : 
     472           0 :     if ( bBackground )
     473             :     {
     474           0 :         if ( IsControlBackground() )
     475           0 :             SetBackground( GetControlBackground() );
     476             :         else
     477           0 :             SetBackground( rStyleSettings.GetWindowColor() );
     478             :     }
     479             : 
     480           0 :     Invalidate();
     481           0 : }
     482             : 
     483             : // -----------------------------------------------------------------------
     484             : 
     485           0 : sal_UCS4 SvxShowCharSet::GetSelectCharacter() const
     486             : {
     487           0 :     if( nSelectedIndex >= 0 )
     488           0 :         getSelectedChar() = maFontCharMap.GetCharFromIndex( nSelectedIndex );
     489           0 :     return getSelectedChar();
     490             : }
     491             : 
     492             : // -----------------------------------------------------------------------
     493             : 
     494           0 : void SvxShowCharSet::SetFont( const Font& rFont )
     495             : {
     496             :     // save last selected unicode
     497           0 :     if( nSelectedIndex >= 0 )
     498           0 :         getSelectedChar() = maFontCharMap.GetCharFromIndex( nSelectedIndex );
     499             : 
     500           0 :     Font aFont = rFont;
     501           0 :     aFont.SetWeight( WEIGHT_LIGHT );
     502           0 :     aFont.SetAlign( ALIGN_TOP );
     503           0 :     int nFontHeight = (aOrigSize.Height() - 5) * 2 / (3 * ROW_COUNT);
     504           0 :     aFont.SetSize( PixelToLogic( Size( 0, nFontHeight ) ) );
     505           0 :     aFont.SetTransparent( sal_True );
     506           0 :     Control::SetFont( aFont );
     507           0 :     GetFontCharMap( maFontCharMap );
     508             : 
     509             :     // hide scrollbar when there is nothing to scroll
     510           0 :     sal_Bool bNeedVscroll = (maFontCharMap.GetCharCount() > ROW_COUNT*COLUMN_COUNT);
     511             : 
     512           0 :     nX = (aOrigSize.Width() - (bNeedVscroll ? SBWIDTH : 0)) / COLUMN_COUNT;
     513           0 :     nY = aOrigSize.Height() / ROW_COUNT;
     514             : 
     515           0 :     if( bNeedVscroll)
     516             :     {
     517           0 :         aVscrollSB.setPosSizePixel( nX * COLUMN_COUNT, 0, SBWIDTH, nY * ROW_COUNT );
     518           0 :         aVscrollSB.SetRangeMin( 0 );
     519           0 :         int nLastRow = (maFontCharMap.GetCharCount() - 1 + COLUMN_COUNT) / COLUMN_COUNT;
     520           0 :         aVscrollSB.SetRangeMax( nLastRow );
     521           0 :         aVscrollSB.SetPageSize( ROW_COUNT-1 );
     522           0 :         aVscrollSB.SetVisibleSize( ROW_COUNT );
     523             :     }
     524             : 
     525             :     // restore last selected unicode
     526           0 :     int nMapIndex = maFontCharMap.GetIndexFromChar( getSelectedChar() );
     527           0 :     SelectIndex( nMapIndex );
     528             : 
     529             :     // rearrange CharSet element in sync with nX- and nY-multiples
     530           0 :     Size aNewSize( nX * COLUMN_COUNT + (bNeedVscroll ? SBWIDTH : 0), nY * ROW_COUNT );
     531           0 :     Point aNewPos = aOrigPos + Point( (aOrigSize.Width() - aNewSize.Width()) / 2, 0 );
     532           0 :     SetPosPixel( aNewPos );
     533           0 :     SetOutputSizePixel( aNewSize );
     534             : 
     535           0 :     aVscrollSB.Show( bNeedVscroll );
     536           0 :     Invalidate();
     537           0 : }
     538             : 
     539             : // -----------------------------------------------------------------------
     540             : 
     541           0 : void SvxShowCharSet::SelectIndex( int nNewIndex, sal_Bool bFocus )
     542             : {
     543           0 :     if( nNewIndex < 0 )
     544             :     {
     545             :         // need to scroll see closest unicode
     546           0 :         sal_uInt32 cPrev = maFontCharMap.GetPrevChar( getSelectedChar() );
     547           0 :         int nMapIndex = maFontCharMap.GetIndexFromChar( cPrev );
     548           0 :         int nNewPos = nMapIndex / COLUMN_COUNT;
     549           0 :         aVscrollSB.SetThumbPos( nNewPos );
     550           0 :         nSelectedIndex = bFocus ? nMapIndex+1 : -1;
     551           0 :         Invalidate();
     552           0 :         Update();
     553             :     }
     554           0 :     else if( nNewIndex < FirstInView() )
     555             :     {
     556             :         // need to scroll up to see selected item
     557           0 :         int nOldPos = aVscrollSB.GetThumbPos();
     558           0 :         int nDelta = (FirstInView() - nNewIndex + COLUMN_COUNT-1) / COLUMN_COUNT;
     559           0 :         aVscrollSB.SetThumbPos( nOldPos - nDelta );
     560           0 :         nSelectedIndex = nNewIndex;
     561           0 :         Invalidate();
     562           0 :         if( nDelta )
     563           0 :             Update();
     564             :     }
     565           0 :     else if( nNewIndex > LastInView() )
     566             :     {
     567             :         // need to scroll down to see selected item
     568           0 :         int nOldPos = aVscrollSB.GetThumbPos();
     569           0 :         int nDelta = (nNewIndex - LastInView() + COLUMN_COUNT) / COLUMN_COUNT;
     570           0 :         aVscrollSB.SetThumbPos( nOldPos + nDelta );
     571           0 :         if( nNewIndex < maFontCharMap.GetCharCount() )
     572             :         {
     573           0 :             nSelectedIndex = nNewIndex;
     574           0 :             Invalidate();
     575             :         }
     576           0 :         if( nOldPos != aVscrollSB.GetThumbPos() )
     577             :         {
     578           0 :             Invalidate();
     579           0 :             Update();
     580             :         }
     581             :     }
     582             :     else
     583             :     {
     584             :         // remove highlighted view
     585           0 :         Color aLineCol = GetLineColor();
     586           0 :         Color aFillCol = GetFillColor();
     587           0 :         SetLineColor();
     588           0 :         SetFillColor( GetBackground().GetColor() );
     589             : 
     590           0 :         Point aOldPixel = MapIndexToPixel( nSelectedIndex );
     591           0 :         aOldPixel.Move( +1, +1);
     592           0 :         DrawRect( Rectangle( aOldPixel, Size( nX-1, nY-1 ) ) );
     593           0 :         SetLineColor( aLineCol );
     594           0 :         SetFillColor( aFillCol );
     595             : 
     596           0 :         int nOldIndex = nSelectedIndex;
     597           0 :         nSelectedIndex = nNewIndex;
     598           0 :         DrawChars_Impl( nOldIndex, nOldIndex );
     599           0 :         DrawChars_Impl( nNewIndex, nNewIndex );
     600             :     }
     601             : 
     602           0 :     if( nSelectedIndex >= 0 )
     603             :     {
     604           0 :         getSelectedChar() = maFontCharMap.GetCharFromIndex( nSelectedIndex );
     605           0 :         if( m_pAccessible )
     606             :         {
     607           0 :             ::svx::SvxShowCharSetItem* pItem = ImplGetItem(nSelectedIndex);
     608           0 :             m_pAccessible->fireEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, Any(), makeAny(pItem->GetAccessible()) ); // this call asures that m_pItem is set
     609             : 
     610             :             OSL_ENSURE(pItem->m_pItem,"No accessible created!");
     611           0 :             Any aOldAny, aNewAny;
     612           0 :             aNewAny <<= AccessibleStateType::FOCUSED;
     613           0 :             pItem->m_pItem->fireEvent( AccessibleEventId::STATE_CHANGED, aOldAny, aNewAny );
     614             : 
     615           0 :             aNewAny <<= AccessibleStateType::SELECTED;
     616           0 :             pItem->m_pItem->fireEvent( AccessibleEventId::STATE_CHANGED, aOldAny, aNewAny );
     617             :         }
     618             :     }
     619             : 
     620             : 
     621           0 :     aHighHdl.Call( this );
     622           0 : }
     623             : 
     624             : // -----------------------------------------------------------------------
     625             : 
     626           0 : void SvxShowCharSet::SelectCharacter( sal_UCS4 cNew, sal_Bool bFocus )
     627             : {
     628             :     // get next available char of current font
     629           0 :     sal_UCS4 cNext = maFontCharMap.GetNextChar( cNew - 1 );
     630             : 
     631           0 :     int nMapIndex = maFontCharMap.GetIndexFromChar( cNext );
     632           0 :     SelectIndex( nMapIndex, bFocus );
     633           0 :     if( !bFocus )
     634             :     {
     635             :         // move selected item to top row if not in focus
     636           0 :         aVscrollSB.SetThumbPos( nMapIndex / COLUMN_COUNT );
     637           0 :         Invalidate();
     638             :     }
     639           0 : }
     640             : 
     641             : // -----------------------------------------------------------------------
     642             : 
     643           0 : IMPL_LINK_NOARG(SvxShowCharSet, VscrollHdl)
     644             : {
     645           0 :     if( nSelectedIndex < FirstInView() )
     646             :     {
     647           0 :         SelectIndex( FirstInView() + (nSelectedIndex % COLUMN_COUNT) );
     648             :     }
     649           0 :     else if( nSelectedIndex > LastInView() )
     650             :     {
     651           0 :         if( m_pAccessible )
     652             :         {
     653           0 :             ::com::sun::star::uno::Any aOldAny, aNewAny;
     654           0 :             int nLast = LastInView();
     655           0 :             for ( ; nLast != nSelectedIndex; ++nLast)
     656             :             {
     657           0 :                 aOldAny <<= ImplGetItem(nLast)->GetAccessible();
     658           0 :                 m_pAccessible ->fireEvent( AccessibleEventId::CHILD, aOldAny, aNewAny );
     659           0 :             }
     660             :         }
     661           0 :         SelectIndex( (LastInView() - COLUMN_COUNT + 1) + (nSelectedIndex % COLUMN_COUNT) );
     662             :     }
     663             : 
     664           0 :     Invalidate();
     665           0 :     return 0;
     666             : }
     667             : 
     668             : // -----------------------------------------------------------------------
     669             : 
     670           0 : SvxShowCharSet::~SvxShowCharSet()
     671             : {
     672           0 :     if ( m_pAccessible )
     673           0 :         ReleaseAccessible();
     674           0 : }
     675             : // -----------------------------------------------------------------------------
     676           0 : void SvxShowCharSet::ReleaseAccessible()
     677             : {
     678           0 :     m_aItems.clear();
     679           0 :     m_pAccessible = NULL;
     680           0 :     m_xAccessible = NULL;
     681           0 : }
     682             : // -----------------------------------------------------------------------------
     683           0 : ::com::sun::star::uno::Reference< XAccessible > SvxShowCharSet::CreateAccessible()
     684             : {
     685             :     OSL_ENSURE(!m_pAccessible,"Accessible already created!");
     686           0 :     m_pAccessible = new ::svx::SvxShowCharSetVirtualAcc(this);
     687           0 :     m_xAccessible = m_pAccessible;
     688           0 :     return m_xAccessible;
     689             : }
     690             : // -----------------------------------------------------------------------------
     691           0 : ::svx::SvxShowCharSetItem* SvxShowCharSet::ImplGetItem( int _nPos )
     692             : {
     693           0 :     ItemsMap::iterator aFind = m_aItems.find(_nPos);
     694           0 :     if ( aFind == m_aItems.end() )
     695             :     {
     696             :         OSL_ENSURE(m_pAccessible,"Who wants to create a child of my table without a parent?");
     697             :         boost::shared_ptr<svx::SvxShowCharSetItem> xItem(new svx::SvxShowCharSetItem(*this,
     698           0 :             m_pAccessible->getTable(), sal::static_int_cast< sal_uInt16 >(_nPos)));
     699           0 :         aFind = m_aItems.insert(ItemsMap::value_type(_nPos, xItem)).first;
     700           0 :         rtl::OUStringBuffer buf;
     701           0 :         buf.appendUtf32( maFontCharMap.GetCharFromIndex( _nPos ) );
     702           0 :         aFind->second->maText = buf.makeStringAndClear();
     703           0 :         Point pix = MapIndexToPixel( _nPos );
     704           0 :         aFind->second->maRect = Rectangle( Point( pix.X() + 1, pix.Y() + 1 ), Size(nX-1,nY-1) );
     705             :     }
     706             : 
     707           0 :     return aFind->second.get();
     708             : }
     709             : 
     710             : // -----------------------------------------------------------------------------
     711           0 : ScrollBar* SvxShowCharSet::getScrollBar()
     712             : {
     713           0 :     return &aVscrollSB;
     714             : }
     715             : // -----------------------------------------------------------------------
     716           0 : sal_Int32 SvxShowCharSet::getMaxCharCount() const
     717             : {
     718           0 :     return maFontCharMap.GetCharCount();
     719             : }
     720             : 
     721             : 
     722             : // class SubsetMap =======================================================
     723             : // TODO: should be moved into Font Attributes stuff
     724             : // we let it mature here though because it is currently the only use
     725             : 
     726           0 : SubsetMap::SubsetMap( const FontCharMap* pFontCharMap )
     727           0 : :   Resource( SVX_RES(RID_SUBSETMAP) )
     728             : {
     729           0 :     InitList();
     730           0 :     ApplyCharMap( pFontCharMap );
     731           0 :     FreeResource();
     732           0 : }
     733             : 
     734           0 : const Subset* SubsetMap::GetNextSubset( bool bFirst ) const
     735             : {
     736           0 :     if( bFirst )
     737           0 :         maSubsetIterator = maSubsets.begin();
     738           0 :     if( maSubsetIterator == maSubsets.end() )
     739           0 :         return NULL;
     740           0 :     const Subset* s = &*(maSubsetIterator++);
     741           0 :     return s;
     742             : }
     743             : 
     744           0 : const Subset* SubsetMap::GetSubsetByUnicode( sal_UCS4 cChar ) const
     745             : {
     746             :     // TODO: is it worth to avoid a linear search?
     747           0 :     for( const Subset* s = GetNextSubset( true ); s; s = GetNextSubset( false ) )
     748           0 :         if( (s->GetRangeMin() <= cChar) && (cChar <= s->GetRangeMax()) )
     749           0 :             return s;
     750           0 :     return NULL;
     751             : }
     752             : 
     753           0 : inline Subset::Subset( sal_UCS4 nMin, sal_UCS4 nMax, int resId)
     754           0 : :   mnRangeMin(nMin), mnRangeMax(nMax), maRangeName( SVX_RES(resId) )
     755           0 : {}
     756             : 
     757           0 : void SubsetMap::InitList()
     758             : {
     759           0 :     static SubsetList aAllSubsets;
     760             :     static bool bInit = true;
     761           0 :     if( bInit )
     762             :     {
     763           0 :         bInit = false;
     764             : 
     765             :         // TODO: eventually merge or split unicode subranges
     766             :         //       a "native writer" should decide for his subsets
     767           0 :         aAllSubsets.push_back( Subset( 0x0020, 0x007F, RID_SUBSETSTR_BASIC_LATIN ) );
     768           0 :         aAllSubsets.push_back( Subset( 0x0080, 0x00FF, RID_SUBSETSTR_LATIN_1 ) );
     769           0 :         aAllSubsets.push_back( Subset( 0x0100, 0x017F, RID_SUBSETSTR_LATIN_EXTENDED_A ) );
     770           0 :         aAllSubsets.push_back( Subset( 0x0180, 0x024F, RID_SUBSETSTR_LATIN_EXTENDED_B ) );
     771           0 :         aAllSubsets.push_back( Subset( 0x0250, 0x02AF, RID_SUBSETSTR_IPA_EXTENSIONS ) );
     772           0 :         aAllSubsets.push_back( Subset( 0x02B0, 0x02FF, RID_SUBSETSTR_SPACING_MODIFIERS ) );
     773           0 :         aAllSubsets.push_back( Subset( 0x0300, 0x036F, RID_SUBSETSTR_COMB_DIACRITICAL ) );
     774           0 :         aAllSubsets.push_back( Subset( 0x0370, 0x03FF, RID_SUBSETSTR_BASIC_GREEK ) );
     775           0 :         aAllSubsets.push_back( Subset( 0x0400, 0x04FF, RID_SUBSETSTR_CYRILLIC ) );
     776           0 :         aAllSubsets.push_back( Subset( 0x0530, 0x058F, RID_SUBSETSTR_ARMENIAN ) );
     777           0 :         aAllSubsets.push_back( Subset( 0x0590, 0x05FF, RID_SUBSETSTR_BASIC_HEBREW ) );
     778           0 :         aAllSubsets.push_back( Subset( 0x0600, 0x065F, RID_SUBSETSTR_BASIC_ARABIC ) );
     779           0 :         aAllSubsets.push_back( Subset( 0x0660, 0x06FF, RID_SUBSETSTR_ARABIC_EXTENDED ) );
     780           0 :         aAllSubsets.push_back( Subset( 0x0700, 0x074F, RID_SUBSETSTR_SYRIAC ) );
     781           0 :         aAllSubsets.push_back( Subset( 0x0780, 0x07BF, RID_SUBSETSTR_THAANA ) );
     782           0 :         aAllSubsets.push_back( Subset( 0x0900, 0x097F, RID_SUBSETSTR_DEVANAGARI ) );
     783           0 :         aAllSubsets.push_back( Subset( 0x0980, 0x09FF, RID_SUBSETSTR_BENGALI ) );
     784           0 :         aAllSubsets.push_back( Subset( 0x0A00, 0x0A7F, RID_SUBSETSTR_GURMUKHI ) );
     785           0 :         aAllSubsets.push_back( Subset( 0x0A80, 0x0AFF, RID_SUBSETSTR_GUJARATI ) );
     786           0 :         aAllSubsets.push_back( Subset( 0x0B00, 0x0B7F, RID_SUBSETSTR_ORIYA ) );
     787           0 :         aAllSubsets.push_back( Subset( 0x0B80, 0x0BFF, RID_SUBSETSTR_TAMIL ) );
     788           0 :         aAllSubsets.push_back( Subset( 0x0C00, 0x0C7F, RID_SUBSETSTR_TELUGU ) );
     789           0 :         aAllSubsets.push_back( Subset( 0x0C80, 0x0CFF, RID_SUBSETSTR_KANNADA ) );
     790           0 :         aAllSubsets.push_back( Subset( 0x0D00, 0x0D7F, RID_SUBSETSTR_MALAYALAM ) );
     791           0 :         aAllSubsets.push_back( Subset( 0x0D80, 0x0DFF, RID_SUBSETSTR_SINHALA ) );
     792           0 :         aAllSubsets.push_back( Subset( 0x0E00, 0x0E7F, RID_SUBSETSTR_THAI ) );
     793           0 :         aAllSubsets.push_back( Subset( 0x0E80, 0x0EFF, RID_SUBSETSTR_LAO ) );
     794           0 :         aAllSubsets.push_back( Subset( 0x0F00, 0x0FBF, RID_SUBSETSTR_TIBETAN ) );
     795           0 :         aAllSubsets.push_back( Subset( 0x1000, 0x109F, RID_SUBSETSTR_MYANMAR ) );
     796           0 :         aAllSubsets.push_back( Subset( 0x10A0, 0x10FF, RID_SUBSETSTR_BASIC_GEORGIAN ) );
     797             :     //  aAllSubsets.push_back( Subset( 0x10A0, 0x10C5, RID_SUBSETSTR_GEORGIAN_EXTENDED ) );
     798           0 :         aAllSubsets.push_back( Subset( 0x1100, 0x11FF, RID_SUBSETSTR_HANGUL_JAMO ) );
     799           0 :         aAllSubsets.push_back( Subset( 0x1200, 0x137F, RID_SUBSETSTR_ETHIOPIC ) );
     800           0 :         aAllSubsets.push_back( Subset( 0x13A0, 0x13FF, RID_SUBSETSTR_CHEROKEE ) );
     801           0 :         aAllSubsets.push_back( Subset( 0x1400, 0x167F, RID_SUBSETSTR_CANADIAN_ABORIGINAL ) );
     802           0 :         aAllSubsets.push_back( Subset( 0x1680, 0x169F, RID_SUBSETSTR_OGHAM ) );
     803           0 :         aAllSubsets.push_back( Subset( 0x16A0, 0x16F0, RID_SUBSETSTR_RUNIC ) );
     804           0 :         aAllSubsets.push_back( Subset( 0x1700, 0x171F, RID_SUBSETSTR_TAGALOG ) );
     805           0 :         aAllSubsets.push_back( Subset( 0x1720, 0x173F, RID_SUBSETSTR_HANUNOO ) );
     806           0 :         aAllSubsets.push_back( Subset( 0x1740, 0x175F, RID_SUBSETSTR_BUHID ) );
     807           0 :         aAllSubsets.push_back( Subset( 0x1760, 0x177F, RID_SUBSETSTR_TAGBANWA ) );
     808           0 :         aAllSubsets.push_back( Subset( 0x1780, 0x17FF, RID_SUBSETSTR_KHMER ) );
     809           0 :         aAllSubsets.push_back( Subset( 0x1800, 0x18AF, RID_SUBSETSTR_MONGOLIAN ) );
     810           0 :         aAllSubsets.push_back( Subset( 0x1E00, 0x1EFF, RID_SUBSETSTR_LATIN_EXTENDED_ADDS ) );
     811           0 :         aAllSubsets.push_back( Subset( 0x1F00, 0x1FFF, RID_SUBSETSTR_GREEK_EXTENDED ) );
     812             : 
     813           0 :         aAllSubsets.push_back( Subset( 0x2000, 0x206F, RID_SUBSETSTR_GENERAL_PUNCTUATION ) );
     814           0 :         aAllSubsets.push_back( Subset( 0x2070, 0x209F, RID_SUBSETSTR_SUB_SUPER_SCRIPTS ) );
     815           0 :         aAllSubsets.push_back( Subset( 0x20A0, 0x20CF, RID_SUBSETSTR_CURRENCY_SYMBOLS ) );
     816           0 :         aAllSubsets.push_back( Subset( 0x20D0, 0x20FF, RID_SUBSETSTR_COMB_DIACRITIC_SYMS ) );
     817           0 :         aAllSubsets.push_back( Subset( 0x2100, 0x214F, RID_SUBSETSTR_LETTERLIKE_SYMBOLS ) );
     818           0 :         aAllSubsets.push_back( Subset( 0x2150, 0x218F, RID_SUBSETSTR_NUMBER_FORMS ) );
     819           0 :         aAllSubsets.push_back( Subset( 0x2190, 0x21FF, RID_SUBSETSTR_ARROWS ) );
     820           0 :         aAllSubsets.push_back( Subset( 0x2200, 0x22FF, RID_SUBSETSTR_MATH_OPERATORS ) );
     821           0 :         aAllSubsets.push_back( Subset( 0x2300, 0x23FF, RID_SUBSETSTR_MISC_TECHNICAL ) );
     822           0 :         aAllSubsets.push_back( Subset( 0x2400, 0x243F, RID_SUBSETSTR_CONTROL_PICTURES ) );
     823           0 :         aAllSubsets.push_back( Subset( 0x2440, 0x245F, RID_SUBSETSTR_OPTICAL_CHAR_REC ) );
     824           0 :         aAllSubsets.push_back( Subset( 0x2460, 0x24FF, RID_SUBSETSTR_ENCLOSED_ALPHANUM ) );
     825           0 :         aAllSubsets.push_back( Subset( 0x2500, 0x257F, RID_SUBSETSTR_BOX_DRAWING ) );
     826           0 :         aAllSubsets.push_back( Subset( 0x2580, 0x259F, RID_SUBSETSTR_BLOCK_ELEMENTS ) );
     827           0 :         aAllSubsets.push_back( Subset( 0x25A0, 0x25FF, RID_SUBSETSTR_GEOMETRIC_SHAPES ) );
     828           0 :         aAllSubsets.push_back( Subset( 0x2600, 0x26FF, RID_SUBSETSTR_MISC_DINGBATS ) );
     829           0 :         aAllSubsets.push_back( Subset( 0x2700, 0x27BF, RID_SUBSETSTR_DINGBATS ) );
     830             : 
     831           0 :         aAllSubsets.push_back( Subset( 0x27C0, 0x27FF, RID_SUBSETSTR_MISC_MATH_SYMS_A ) );
     832           0 :         aAllSubsets.push_back( Subset( 0x27F0, 0x27FF, RID_SUBSETSTR_SUPPL_ARROWS_A ) );
     833           0 :         aAllSubsets.push_back( Subset( 0x2800, 0x28FF, RID_SUBSETSTR_BRAILLE_PATTERNS ) );
     834           0 :         aAllSubsets.push_back( Subset( 0x2900, 0x297F, RID_SUBSETSTR_SUPPL_ARROWS_B ) );
     835           0 :         aAllSubsets.push_back( Subset( 0x2980, 0x29FF, RID_SUBSETSTR_MISC_MATH_SYMS_B ) );
     836           0 :         aAllSubsets.push_back( Subset( 0x2E80, 0x2EFF, RID_SUBSETSTR_CJK_RADICAL_SUPPL ) );
     837           0 :         aAllSubsets.push_back( Subset( 0x2F00, 0x2FDF, RID_SUBSETSTR_KANGXI_RADICALS ) );
     838           0 :         aAllSubsets.push_back( Subset( 0x2FF0, 0x2FFF, RID_SUBSETSTR_IDEO_DESC_CHARS ) );
     839             : 
     840           0 :         aAllSubsets.push_back( Subset( 0x3000, 0x303F, RID_SUBSETSTR_CJK_SYMS_PUNCTUATION ) );
     841           0 :         aAllSubsets.push_back( Subset( 0x3040, 0x309F, RID_SUBSETSTR_HIRAGANA ) );
     842           0 :         aAllSubsets.push_back( Subset( 0x30A0, 0x30FF, RID_SUBSETSTR_KATAKANA ) );
     843           0 :         aAllSubsets.push_back( Subset( 0x3100, 0x312F, RID_SUBSETSTR_BOPOMOFO ) );
     844           0 :         aAllSubsets.push_back( Subset( 0x3130, 0x318F, RID_SUBSETSTR_HANGUL_COMPAT_JAMO ) );
     845           0 :         aAllSubsets.push_back( Subset( 0x3190, 0x319F, RID_SUBSETSTR_KANBUN ) );
     846           0 :         aAllSubsets.push_back( Subset( 0x31A0, 0x31BF, RID_SUBSETSTR_BOPOMOFO_EXTENDED ) );
     847           0 :         aAllSubsets.push_back( Subset( 0x31C0, 0x31FF, RID_SUBSETSTR_KATAKANA_PHONETIC ) );
     848           0 :         aAllSubsets.push_back( Subset( 0x3200, 0x32FF, RID_SUBSETSTR_ENCLOSED_CJK_LETTERS ) );
     849           0 :         aAllSubsets.push_back( Subset( 0x3300, 0x33FF, RID_SUBSETSTR_CJK_COMPATIBILITY ) );
     850             : 
     851           0 :         aAllSubsets.push_back( Subset( 0x3400, 0x4DFF, RID_SUBSETSTR_CJK_EXT_A_UNIFIED_IDGRAPH ) );
     852           0 :         aAllSubsets.push_back( Subset( 0x4E00, 0x9FA5, RID_SUBSETSTR_CJK_UNIFIED_IDGRAPH ) );
     853           0 :         aAllSubsets.push_back( Subset( 0xA000, 0xA4CF, RID_SUBSETSTR_YI ) );
     854           0 :         aAllSubsets.push_back( Subset( 0xAC00, 0xB097, RID_SUBSETSTR_HANGUL_GA ) );
     855           0 :         aAllSubsets.push_back( Subset( 0xB098, 0xB2E3, RID_SUBSETSTR_HANGUL_NA ) );
     856           0 :         aAllSubsets.push_back( Subset( 0xB2E4, 0xB77B, RID_SUBSETSTR_HANGUL_DA ) );
     857           0 :         aAllSubsets.push_back( Subset( 0xB77C, 0xB9C7, RID_SUBSETSTR_HANGUL_RA ) );
     858           0 :         aAllSubsets.push_back( Subset( 0xB9C8, 0xBC13, RID_SUBSETSTR_HANGUL_MA ) );
     859           0 :         aAllSubsets.push_back( Subset( 0xBC14, 0xC0AB, RID_SUBSETSTR_HANGUL_BA ) );
     860           0 :         aAllSubsets.push_back( Subset( 0xC0AC, 0xC543, RID_SUBSETSTR_HANGUL_SA ) );
     861           0 :         aAllSubsets.push_back( Subset( 0xC544, 0xC78F, RID_SUBSETSTR_HANGUL_AH ) );
     862           0 :         aAllSubsets.push_back( Subset( 0xC790, 0xCC27, RID_SUBSETSTR_HANGUL_JA ) );
     863           0 :         aAllSubsets.push_back( Subset( 0xCC28, 0xCE73, RID_SUBSETSTR_HANGUL_CHA ) );
     864           0 :         aAllSubsets.push_back( Subset( 0xCE74, 0xD0BF, RID_SUBSETSTR_HANGUL_KA ) );
     865           0 :         aAllSubsets.push_back( Subset( 0xD0C0, 0xD30B, RID_SUBSETSTR_HANGUL_TA ) );
     866           0 :         aAllSubsets.push_back( Subset( 0xD30C, 0xD557, RID_SUBSETSTR_HANGUL_PA ) );
     867           0 :         aAllSubsets.push_back( Subset( 0xD558, 0xD7A3, RID_SUBSETSTR_HANGUL_HA ) );
     868             :     //  aAllSubsets.push_back( Subset( 0xAC00, 0xD7AF, RID_SUBSETSTR_HANGUL ) );
     869             : 
     870             :     //  aAllSubsets.push_back( Subset( 0xD800, 0xDFFF, RID_SUBSETSTR_SURROGATE ) );
     871           0 :         aAllSubsets.push_back( Subset( 0xE000, 0xF8FF, RID_SUBSETSTR_PRIVATE_USE_AREA ) );
     872           0 :         aAllSubsets.push_back( Subset( 0xF900, 0xFAFF, RID_SUBSETSTR_CJK_COMPAT_IDGRAPHS ) );
     873           0 :         aAllSubsets.push_back( Subset( 0xFB00, 0xFB4F, RID_SUBSETSTR_ALPHA_PRESENTATION ) );
     874           0 :         aAllSubsets.push_back( Subset( 0xFB50, 0xFDFF, RID_SUBSETSTR_ARABIC_PRESENT_A ) );
     875           0 :         aAllSubsets.push_back( Subset( 0xFE20, 0xFE2F, RID_SUBSETSTR_COMBINING_HALF_MARKS ) );
     876           0 :         aAllSubsets.push_back( Subset( 0xFE30, 0xFE4F, RID_SUBSETSTR_CJK_COMPAT_FORMS ) );
     877           0 :         aAllSubsets.push_back( Subset( 0xFE50, 0xFE6F, RID_SUBSETSTR_SMALL_FORM_VARIANTS ) );
     878           0 :         aAllSubsets.push_back( Subset( 0xFE70, 0xFEFF, RID_SUBSETSTR_ARABIC_PRESENT_B ) );
     879           0 :         aAllSubsets.push_back( Subset( 0xFF00, 0xFFEF, RID_SUBSETSTR_HALFW_FULLW_FORMS ) );
     880           0 :         aAllSubsets.push_back( Subset( 0xFFF0, 0xFFFF, RID_SUBSETSTR_SPECIALS ) );
     881             :     }
     882             : 
     883           0 :     maSubsets = aAllSubsets;
     884           0 : }
     885             : 
     886           0 : void SubsetMap::ApplyCharMap( const FontCharMap* pFontCharMap )
     887             : {
     888           0 :     if( !pFontCharMap )
     889           0 :         return;
     890             : 
     891             :     // remove subsets that are not matched in any range
     892           0 :     SubsetList::iterator it_next = maSubsets.begin();
     893           0 :     while( it_next != maSubsets.end() )
     894             :     {
     895           0 :         SubsetList::iterator it = it_next++;
     896           0 :         const Subset& rSubset = *it;
     897           0 :         sal_uInt32 cMin = rSubset.GetRangeMin();
     898           0 :         sal_uInt32 cMax = rSubset.GetRangeMax();
     899             : 
     900           0 :         int nCount =  pFontCharMap->CountCharsInRange( cMin, cMax );
     901           0 :         if( nCount <= 0 )
     902           0 :             maSubsets.erase( it );
     903             :     }
     904          57 : }
     905             : 
     906             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10