LCOV - code coverage report
Current view: top level - libreoffice/cui/source/tabpages - chardlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 1898 0.1 %
Date: 2012-12-17 Functions: 2 125 1.6 %
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 <editeng/unolingu.hxx>
      21             : #include <vcl/svapp.hxx>
      22             : #include <unotools/pathoptions.hxx>
      23             : #include <svtools/ctrltool.hxx>
      24             : #include <svl/sfontitm.hxx>
      25             : #include <sfx2/printer.hxx>
      26             : #include <sfx2/objsh.hxx>
      27             : #include <sfx2/viewsh.hxx>
      28             : #include <sfx2/bindings.hxx>
      29             : #include <sfx2/viewfrm.hxx>
      30             : #include <vcl/msgbox.hxx>
      31             : #include <svx/dialmgr.hxx>
      32             : #include <svx/dialogs.hrc>
      33             : #include <svtools/unitconv.hxx>
      34             : #include <svl/languageoptions.hxx>
      35             : #include <svx/xtable.hxx>       // XColorList
      36             : #include "chardlg.hxx"
      37             : #include "editeng/fontitem.hxx"
      38             : #include <editeng/postitem.hxx>
      39             : #include <editeng/udlnitem.hxx>
      40             : #include <editeng/crsditem.hxx>
      41             : #include <editeng/cntritem.hxx>
      42             : #include <editeng/langitem.hxx>
      43             : #include <editeng/wghtitem.hxx>
      44             : #include <editeng/fhgtitem.hxx>
      45             : #include <editeng/shdditem.hxx>
      46             : #include <editeng/escpitem.hxx>
      47             : #include <editeng/prszitem.hxx>
      48             : #include <editeng/wrlmitem.hxx>
      49             : #include <editeng/cmapitem.hxx>
      50             : #include <editeng/kernitem.hxx>
      51             : #include <editeng/blnkitem.hxx>
      52             : #include "editeng/flstitem.hxx"
      53             : #include <editeng/akrnitem.hxx>
      54             : #include <editeng/brshitem.hxx>
      55             : #include <editeng/colritem.hxx>
      56             : #include "svx/drawitem.hxx"
      57             : #include "svx/dlgutil.hxx"
      58             : #include <dialmgr.hxx>
      59             : #include "svx/htmlmode.hxx"
      60             : #include "cuicharmap.hxx"
      61             : #include "chardlg.h"
      62             : #include <editeng/emphitem.hxx>
      63             : #include <editeng/charreliefitem.hxx>
      64             : #include <editeng/twolinesitem.hxx>
      65             : #include <editeng/charhiddenitem.hxx>
      66             : #include <svl/stritem.hxx>
      67             : #include <editeng/charscaleitem.hxx>
      68             : #include <editeng/charrotateitem.hxx>
      69             : #include <svx/svxdlg.hxx>
      70             : #include <cuires.hrc>
      71             : #include <svl/intitem.hxx>
      72             : #include <sfx2/request.hxx>
      73             : #include "svx/flagsdef.hxx"
      74             : 
      75             : using namespace ::com::sun::star;
      76             : 
      77             : // define ----------------------------------------------------------------
      78             : 
      79             : #define ISITEMSET   rSet.GetItemState(nWhich)>=SFX_ITEM_DEFAULT
      80             : 
      81             : #define CLEARTITEM  rSet.InvalidateItem(nWhich)
      82             : 
      83             : #define LW_NORMAL   0
      84             : #define LW_GESPERRT 1
      85             : #define LW_SCHMAL   2
      86             : 
      87             : // static ----------------------------------------------------------------
      88             : 
      89             : static sal_uInt16 pNameRanges[] =
      90             : {
      91             :     SID_ATTR_CHAR_FONT,
      92             :     SID_ATTR_CHAR_WEIGHT,
      93             :     SID_ATTR_CHAR_FONTHEIGHT,
      94             :     SID_ATTR_CHAR_FONTHEIGHT,
      95             :     SID_ATTR_CHAR_COLOR,
      96             :     SID_ATTR_CHAR_COLOR,
      97             :     SID_ATTR_CHAR_LANGUAGE,
      98             :     SID_ATTR_CHAR_LANGUAGE,
      99             :     SID_ATTR_CHAR_CJK_FONT,
     100             :     SID_ATTR_CHAR_CJK_WEIGHT,
     101             :     SID_ATTR_CHAR_CTL_FONT,
     102             :     SID_ATTR_CHAR_CTL_WEIGHT,
     103             :     0
     104             : };
     105             : 
     106             : static sal_uInt16 pEffectsRanges[] =
     107             : {
     108             :     SID_ATTR_CHAR_SHADOWED,
     109             :     SID_ATTR_CHAR_UNDERLINE,
     110             :     SID_ATTR_CHAR_COLOR,
     111             :     SID_ATTR_CHAR_COLOR,
     112             :     SID_ATTR_CHAR_CASEMAP,
     113             :     SID_ATTR_CHAR_CASEMAP,
     114             :     SID_ATTR_FLASH,
     115             :     SID_ATTR_FLASH,
     116             :     SID_ATTR_CHAR_EMPHASISMARK,
     117             :     SID_ATTR_CHAR_EMPHASISMARK,
     118             :     SID_ATTR_CHAR_RELIEF,
     119             :     SID_ATTR_CHAR_RELIEF,
     120             :     SID_ATTR_CHAR_HIDDEN,
     121             :     SID_ATTR_CHAR_HIDDEN,
     122             :     SID_ATTR_CHAR_OVERLINE,
     123             :     SID_ATTR_CHAR_OVERLINE,
     124             :     0
     125             : };
     126             : 
     127             : static sal_uInt16 pPositionRanges[] =
     128             : {
     129             :     SID_ATTR_CHAR_KERNING,
     130             :     SID_ATTR_CHAR_KERNING,
     131             :     SID_ATTR_CHAR_ESCAPEMENT,
     132             :     SID_ATTR_CHAR_ESCAPEMENT,
     133             :     SID_ATTR_CHAR_AUTOKERN,
     134             :     SID_ATTR_CHAR_AUTOKERN,
     135             :     SID_ATTR_CHAR_ROTATED,
     136             :     SID_ATTR_CHAR_SCALEWIDTH,
     137             :     SID_ATTR_CHAR_WIDTH_FIT_TO_LINE,
     138             :     SID_ATTR_CHAR_WIDTH_FIT_TO_LINE,
     139             :     0
     140             : };
     141             : 
     142             : static sal_uInt16 pTwoLinesRanges[] =
     143             : {
     144             :     SID_ATTR_CHAR_TWO_LINES,
     145             :     SID_ATTR_CHAR_TWO_LINES,
     146             :     0
     147             : };
     148             : 
     149             : // C-Funktion ------------------------------------------------------------
     150             : 
     151           0 : inline sal_Bool StateToAttr( TriState aState )
     152             : {
     153           0 :     return ( STATE_CHECK == aState );
     154             : }
     155             : 
     156             : // class SvxCharBasePage -------------------------------------------------
     157             : 
     158           0 : inline SvxFont& SvxCharBasePage::GetPreviewFont()
     159             : {
     160           0 :     return m_pPreviewWin->GetFont();
     161             : }
     162             : 
     163             : // -----------------------------------------------------------------------
     164             : 
     165           0 : inline SvxFont& SvxCharBasePage::GetPreviewCJKFont()
     166             : {
     167           0 :     return m_pPreviewWin->GetCJKFont();
     168             : }
     169             : // -----------------------------------------------------------------------
     170             : 
     171           0 : inline SvxFont& SvxCharBasePage::GetPreviewCTLFont()
     172             : {
     173           0 :     return m_pPreviewWin->GetCTLFont();
     174             : }
     175             : 
     176             : // -----------------------------------------------------------------------
     177             : 
     178           0 : SvxCharBasePage::SvxCharBasePage(Window* pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription, const SfxItemSet& rItemset)
     179             :     : SfxTabPage( pParent, rID, rUIXMLDescription, rItemset )
     180             :     , m_pPreviewWin(NULL)
     181           0 :     , m_bPreviewBackgroundToCharacter( sal_False )
     182             : {
     183           0 : }
     184             : 
     185             : // -----------------------------------------------------------------------
     186             : 
     187           0 : SvxCharBasePage::~SvxCharBasePage()
     188             : {
     189           0 : }
     190             : 
     191             : // -----------------------------------------------------------------------
     192             : 
     193           0 : void SvxCharBasePage::ActivatePage( const SfxItemSet& rSet )
     194             : {
     195           0 :     m_pPreviewWin->SetFromItemSet( rSet, m_bPreviewBackgroundToCharacter );
     196           0 : }
     197             : 
     198             : 
     199             : // -----------------------------------------------------------------------
     200             : 
     201           0 : void SvxCharBasePage::SetPrevFontWidthScale( const SfxItemSet& rSet )
     202             : {
     203           0 :     sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
     204           0 :     if( ISITEMSET )
     205             :     {
     206           0 :         const SvxCharScaleWidthItem &rItem = ( SvxCharScaleWidthItem& ) rSet.Get( nWhich );
     207           0 :         m_pPreviewWin->SetFontWidthScale( rItem.GetValue() );
     208             :     }
     209           0 : }
     210             : 
     211             : // -----------------------------------------------------------------------
     212             : namespace
     213             : {
     214             :     // -----------------------------------------------------------------------
     215           0 :     void setPrevFontEscapement(SvxFont& _rFont,sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
     216             :     {
     217           0 :         _rFont.SetPropr( nProp );
     218           0 :         _rFont.SetProprRel( nEscProp );
     219           0 :         _rFont.SetEscapement( nEsc );
     220           0 :     }
     221             :     // -----------------------------------------------------------------------
     222             :     // -----------------------------------------------------------------------
     223             : }
     224             : // -----------------------------------------------------------------------
     225             : 
     226           0 : void SvxCharBasePage::SetPrevFontEscapement( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
     227             : {
     228           0 :     setPrevFontEscapement(GetPreviewFont(),nProp,nEscProp,nEsc);
     229           0 :     setPrevFontEscapement(GetPreviewCJKFont(),nProp,nEscProp,nEsc);
     230           0 :     setPrevFontEscapement(GetPreviewCTLFont(),nProp,nEscProp,nEsc);
     231           0 :     m_pPreviewWin->Invalidate();
     232           0 : }
     233             : 
     234             : // SvxCharNamePage_Impl --------------------------------------------------
     235             : 
     236             : struct SvxCharNamePage_Impl
     237             : {
     238             :     Timer           m_aUpdateTimer;
     239             :     String          m_aNoStyleText;
     240             :     String          m_aTransparentText;
     241             :     const FontList* m_pFontList;
     242             :     sal_uInt16          m_nExtraEntryPos;
     243             :     sal_Bool            m_bMustDelete;
     244             :     sal_Bool            m_bInSearchMode;
     245             : 
     246           0 :     SvxCharNamePage_Impl() :
     247             : 
     248             :         m_pFontList     ( NULL ),
     249             :         m_nExtraEntryPos( LISTBOX_ENTRY_NOTFOUND ),
     250             :         m_bMustDelete   ( sal_False ),
     251           0 :         m_bInSearchMode ( sal_False )
     252             : 
     253             :     {
     254           0 :         m_aUpdateTimer.SetTimeout( 350 );
     255           0 :     }
     256             : 
     257           0 :     ~SvxCharNamePage_Impl()
     258           0 :     {
     259           0 :         if ( m_bMustDelete )
     260           0 :             delete m_pFontList;
     261           0 :     }
     262             : };
     263             : 
     264             : namespace
     265             : {
     266           0 :     void equalize_width_requests(Window *pA, Window *pB, Window *pC)
     267             :     {
     268           0 :         long nWidthWest = pA->get_preferred_size().Width();
     269           0 :         long nWidthEast = pB->get_preferred_size().Width();
     270           0 :         long nWidthCTL = pC->get_preferred_size().Width();
     271           0 :         long nLargest = std::max(nWidthWest, std::max(nWidthEast, nWidthCTL));
     272           0 :         pA->set_width_request(nLargest);
     273           0 :         pB->set_width_request(nLargest);
     274           0 :         pC->set_width_request(nLargest);
     275           0 :     }
     276             : }
     277             : 
     278             : // class SvxCharNamePage -------------------------------------------------
     279             : 
     280           0 : SvxCharNamePage::SvxCharNamePage( Window* pParent, const SfxItemSet& rInSet )
     281             :     : SvxCharBasePage(pParent, "CharNamePage", "cui/ui/charnamepage.ui", rInSet)
     282           0 :     , m_pImpl(new SvxCharNamePage_Impl)
     283             : {
     284           0 :     m_pImpl->m_aNoStyleText = String( CUI_RES( RID_SVXSTR_CHARNAME_NOSTYLE ) );
     285           0 :     m_pImpl->m_aTransparentText = String( CUI_RES( RID_SVXSTR_CHARNAME_TRANSPARENT ) );
     286             : 
     287           0 :     SvtLanguageOptions aLanguageOptions;
     288           0 :     sal_Bool bShowCJK = aLanguageOptions.IsCJKFontEnabled();
     289           0 :     sal_Bool bShowCTL = aLanguageOptions.IsCTLFontEnabled();
     290           0 :     sal_Bool bShowNonWestern = bShowCJK || bShowCTL;
     291             : 
     292           0 :     if (bShowNonWestern)
     293             :     {
     294           0 :         get(m_pWestFrame, "western");
     295           0 :         get(m_pWestFontNameFT, "westfontnameft-cjk");
     296           0 :         get(m_pWestFontNameLB, "westfontnamelb-cjk");
     297           0 :         get(m_pWestFontStyleFT, "weststyleft-cjk");
     298           0 :         get(m_pWestFontStyleLB, "weststylelb-cjk");
     299           0 :         get(m_pWestFontSizeFT, "westsizeft-cjk");
     300           0 :         get(m_pWestFontSizeLB, "westsizelb-cjk");
     301             : 
     302           0 :         get(m_pWestFontLanguageFT, "westlangft-cjk");
     303           0 :         get(m_pWestFontLanguageLB, "westlanglb-cjk");
     304             :     }
     305             :     else
     306             :     {
     307           0 :         get(m_pWestFrame, "simple");
     308           0 :         get(m_pWestFontNameFT, "westfontnameft-nocjk");
     309           0 :         get(m_pWestFontNameLB, "westfontnamelb-nocjk");
     310           0 :         get(m_pWestFontStyleFT, "weststyleft-nocjk");
     311           0 :         get(m_pWestFontStyleLB, "weststylelb-nocjk");
     312           0 :         get(m_pWestFontSizeFT, "westsizeft-nocjk");
     313           0 :         get(m_pWestFontSizeLB, "westsizelb-nocjk");
     314             : 
     315           0 :         get(m_pWestFontLanguageFT, "westlangft-nocjk");
     316           0 :         get(m_pWestFontLanguageLB, "westlanglb-nocjk");
     317             :     }
     318             : 
     319           0 :     get(m_pEastFrame, "asian");
     320           0 :     get(m_pEastFontNameFT, "eastfontnameft");
     321           0 :     get(m_pEastFontNameLB, "eastfontnamelb");
     322           0 :     get(m_pEastFontStyleFT, "eaststyleft");
     323           0 :     get(m_pEastFontStyleLB, "eaststylelb");
     324           0 :     get(m_pEastFontSizeFT, "eastsizeft");
     325           0 :     get(m_pEastFontSizeLB, "eastsizelb");
     326           0 :     get(m_pEastFontLanguageFT, "eastlangft");
     327           0 :     get(m_pEastFontLanguageLB, "eastlanglb");
     328             : 
     329           0 :     get(m_pCTLFrame, "ctl");
     330           0 :     get(m_pCTLFontNameFT, "ctlfontnameft");
     331           0 :     get(m_pCTLFontNameLB, "ctlfontnamelb");
     332           0 :     get(m_pCTLFontStyleFT, "ctlstyleft");
     333           0 :     get(m_pCTLFontStyleLB, "ctlstylelb");
     334           0 :     get(m_pCTLFontSizeFT, "ctlsizeft");
     335           0 :     get(m_pCTLFontSizeLB, "ctlsizelb");
     336           0 :     get(m_pCTLFontLanguageFT, "ctllangft");
     337           0 :     get(m_pCTLFontLanguageLB, "ctllanglb");
     338             : 
     339             :     //In MacOSX the standard dialogs name font-name, font-style as
     340             :     //Family, Typeface
     341             :     //In GNOME the standard dialogs name font-name, font-style as
     342             :     //Family, Style
     343             :     //In Windows the standard dialogs name font-name, font-style as
     344             :     //Font, Style
     345             : #ifdef WNT
     346             :     String sFontFamilyString(CUI_RES(RID_SVXSTR_CHARNAME_FONT));
     347             : #else
     348           0 :     String sFontFamilyString(CUI_RES(RID_SVXSTR_CHARNAME_FAMILY));
     349             : #endif
     350           0 :     m_pWestFontNameFT->SetText(sFontFamilyString);
     351           0 :     m_pEastFontNameFT->SetText(sFontFamilyString);
     352           0 :     m_pCTLFontNameFT->SetText(sFontFamilyString);
     353             : 
     354             : #ifdef MACOSX
     355             :     String sFontStyleString(CUI_RES(RID_SVXSTR_CHARNAME_TYPEFACE));
     356             : #else
     357           0 :     String sFontStyleString(CUI_RES(RID_SVXSTR_CHARNAME_STYLE));
     358             : #endif
     359           0 :     m_pWestFontStyleFT->SetText(sFontStyleString);
     360           0 :     m_pEastFontStyleFT->SetText(sFontStyleString);
     361           0 :     m_pCTLFontStyleFT->SetText(sFontStyleString);
     362             : 
     363           0 :     m_pWestFrame->Show(true);
     364           0 :     m_pEastFrame->Show(bShowCJK);
     365           0 :     m_pCTLFrame->Show(bShowCTL);
     366             : 
     367           0 :     get(m_pPreviewWin, "preview");
     368             : 
     369           0 :     m_pWestFontLanguageLB->SetLanguageList(LANG_LIST_WESTERN, sal_True, sal_False, sal_True);
     370           0 :     m_pEastFontLanguageLB->SetLanguageList(LANG_LIST_CJK, sal_True, sal_False, sal_True);
     371           0 :     m_pCTLFontLanguageLB->SetLanguageList(LANG_LIST_CTL, sal_True, sal_False, sal_True);
     372             : 
     373           0 :     if (!bShowNonWestern)
     374             :     {
     375             :         //10 lines
     376           0 :         sal_Int32 nHeight = m_pWestFontSizeLB->CalcWindowSizePixel(10);
     377           0 :         m_pWestFontNameLB->set_height_request(nHeight);
     378           0 :         m_pWestFontStyleLB->set_height_request(nHeight);
     379           0 :         m_pWestFontSizeLB->set_height_request(nHeight);
     380             :     }
     381             :     else
     382             :     {
     383           0 :         equalize_width_requests(m_pWestFontLanguageLB, m_pEastFontLanguageLB, m_pCTLFontLanguageLB);
     384             :     }
     385             : 
     386           0 :     Initialize();
     387           0 : }
     388             : 
     389             : // -----------------------------------------------------------------------
     390             : 
     391           0 : SvxCharNamePage::~SvxCharNamePage()
     392             : {
     393           0 :     delete m_pImpl;
     394           0 : }
     395             : 
     396             : // -----------------------------------------------------------------------
     397             : 
     398           0 : void SvxCharNamePage::Initialize()
     399             : {
     400             :     // to handle the changes of the other pages
     401           0 :     SetExchangeSupport();
     402             : 
     403           0 :     Link aLink = LINK( this, SvxCharNamePage, FontModifyHdl_Impl );
     404           0 :     m_pWestFontNameLB->SetModifyHdl( aLink );
     405           0 :     m_pWestFontStyleLB->SetModifyHdl( aLink );
     406           0 :     m_pWestFontSizeLB->SetModifyHdl( aLink );
     407           0 :     m_pWestFontLanguageLB->SetSelectHdl( aLink );
     408           0 :     m_pEastFontNameLB->SetModifyHdl( aLink );
     409           0 :     m_pEastFontStyleLB->SetModifyHdl( aLink );
     410           0 :     m_pEastFontSizeLB->SetModifyHdl( aLink );
     411           0 :     m_pEastFontLanguageLB->SetSelectHdl( aLink );
     412           0 :     m_pCTLFontNameLB->SetModifyHdl( aLink );
     413           0 :     m_pCTLFontStyleLB->SetModifyHdl( aLink );
     414           0 :     m_pCTLFontSizeLB->SetModifyHdl( aLink );
     415           0 :     m_pCTLFontLanguageLB->SetSelectHdl( aLink );
     416             : 
     417           0 :     m_pImpl->m_aUpdateTimer.SetTimeoutHdl( LINK( this, SvxCharNamePage, UpdateHdl_Impl ) );
     418           0 : }
     419             : 
     420             : // -----------------------------------------------------------------------
     421             : 
     422           0 : const FontList* SvxCharNamePage::GetFontList() const
     423             : {
     424           0 :     if ( !m_pImpl->m_pFontList )
     425             :     {
     426           0 :         SfxObjectShell* pDocSh = SfxObjectShell::Current();
     427             :         const SfxPoolItem* pItem;
     428             : 
     429             :         /* #110771# SvxFontListItem::GetFontList can return NULL */
     430           0 :         if ( pDocSh )
     431             :         {
     432           0 :             pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
     433           0 :             if ( pItem != NULL )
     434             :             {
     435             :                 DBG_ASSERT(NULL != ( (SvxFontListItem*)pItem )->GetFontList(),
     436             :                            "Where is the font list?");
     437           0 :                     m_pImpl->m_pFontList =  static_cast<const SvxFontListItem*>(pItem )->GetFontList()->Clone();
     438           0 :                 m_pImpl->m_bMustDelete = sal_True;
     439             :             }
     440             :         }
     441           0 :         if(!m_pImpl->m_pFontList)
     442             :         {
     443             :             m_pImpl->m_pFontList =
     444           0 :                 new FontList( Application::GetDefaultDevice() );
     445           0 :             m_pImpl->m_bMustDelete = sal_True;
     446             :         }
     447             :     }
     448             : 
     449           0 :     return m_pImpl->m_pFontList;
     450             : }
     451             : 
     452             : // -----------------------------------------------------------------------------
     453             : namespace
     454             : {
     455           0 :     FontInfo calcFontInfo(  SvxFont& _rFont,
     456             :                     SvxCharNamePage* _pPage,
     457             :                     const FontNameBox* _pFontNameLB,
     458             :                     const FontStyleBox* _pFontStyleLB,
     459             :                     const FontSizeBox* _pFontSizeLB,
     460             :                     const SvxLanguageBox* _pLanguageLB,
     461             :                     const FontList* _pFontList,
     462             :                     sal_uInt16 _nFontWhich,
     463             :                     sal_uInt16 _nFontHeightWhich)
     464             :     {
     465           0 :         Size aSize = _rFont.GetSize();
     466           0 :         aSize.Width() = 0;
     467           0 :         FontInfo aFontInfo;
     468           0 :         String sFontName(_pFontNameLB->GetText());
     469           0 :         sal_Bool bFontAvailable = _pFontList->IsAvailable( sFontName );
     470           0 :         if (bFontAvailable  || _pFontNameLB->GetSavedValue() != sFontName)
     471           0 :             aFontInfo = _pFontList->Get( sFontName, _pFontStyleLB->GetText() );
     472             :         else
     473             :         {
     474             :             //get the font from itemset
     475           0 :             SfxItemState eState = _pPage->GetItemSet().GetItemState( _nFontWhich );
     476           0 :             if ( eState >= SFX_ITEM_DEFAULT )
     477             :             {
     478           0 :                 const SvxFontItem* pFontItem = (const SvxFontItem*)&( _pPage->GetItemSet().Get( _nFontWhich ) );
     479           0 :                 aFontInfo.SetName(pFontItem->GetFamilyName());
     480           0 :                 aFontInfo.SetStyleName(pFontItem->GetStyleName());
     481           0 :                 aFontInfo.SetFamily(pFontItem->GetFamily());
     482           0 :                 aFontInfo.SetPitch(pFontItem->GetPitch());
     483           0 :                 aFontInfo.SetCharSet(pFontItem->GetCharSet());
     484             :             }
     485             :         }
     486           0 :         if ( _pFontSizeLB->IsRelative() )
     487             :         {
     488             :             DBG_ASSERT( _pPage->GetItemSet().GetParent(), "No parent set" );
     489           0 :             const SvxFontHeightItem& rOldItem = (SvxFontHeightItem&)_pPage->GetItemSet().GetParent()->Get( _nFontHeightWhich );
     490             : 
     491             :             // old value, scaled
     492             :             long nHeight;
     493           0 :             if ( _pFontSizeLB->IsPtRelative() )
     494           0 :                 nHeight = rOldItem.GetHeight() + PointToTwips( static_cast<long>(_pFontSizeLB->GetValue() / 10) );
     495             :             else
     496           0 :                 nHeight = static_cast<long>(rOldItem.GetHeight() * _pFontSizeLB->GetValue() / 100);
     497             : 
     498             :             // conversion twips for the example-window
     499           0 :             aSize.Height() =
     500           0 :                 ItemToControl( nHeight, _pPage->GetItemSet().GetPool()->GetMetric( _nFontHeightWhich ), SFX_FUNIT_TWIP );
     501             :         }
     502           0 :         else if ( _pFontSizeLB->GetText().Len() )
     503           0 :             aSize.Height() = PointToTwips( static_cast<long>(_pFontSizeLB->GetValue() / 10) );
     504             :         else
     505           0 :             aSize.Height() = 200;   // default 10pt
     506           0 :         aFontInfo.SetSize( aSize );
     507             : 
     508           0 :         _rFont.SetLanguage(_pLanguageLB->GetSelectLanguage());
     509             : 
     510           0 :         _rFont.SetFamily( aFontInfo.GetFamily() );
     511           0 :         _rFont.SetName( aFontInfo.GetName() );
     512           0 :         _rFont.SetStyleName( aFontInfo.GetStyleName() );
     513           0 :         _rFont.SetPitch( aFontInfo.GetPitch() );
     514           0 :         _rFont.SetCharSet( aFontInfo.GetCharSet() );
     515           0 :         _rFont.SetWeight( aFontInfo.GetWeight() );
     516           0 :         _rFont.SetItalic( aFontInfo.GetItalic() );
     517           0 :         _rFont.SetSize( aFontInfo.GetSize() );
     518             : 
     519           0 :         return aFontInfo;
     520             :     }
     521             : }
     522             : 
     523             : // -----------------------------------------------------------------------
     524             : 
     525           0 : void SvxCharNamePage::UpdatePreview_Impl()
     526             : {
     527           0 :     SvxFont& rFont = GetPreviewFont();
     528           0 :     SvxFont& rCJKFont = GetPreviewCJKFont();
     529           0 :     SvxFont& rCTLFont = GetPreviewCTLFont();
     530             :     // Size
     531           0 :     Size aSize = rFont.GetSize();
     532           0 :     aSize.Width() = 0;
     533           0 :     Size aCJKSize = rCJKFont.GetSize();
     534           0 :     aCJKSize.Width() = 0;
     535           0 :     Size aCTLSize = rCTLFont.GetSize();
     536           0 :     aCTLSize.Width() = 0;
     537             :     // Font
     538           0 :     const FontList* pFontList = GetFontList();
     539             : 
     540           0 :     calcFontInfo(rFont,this,m_pWestFontNameLB,m_pWestFontStyleLB,m_pWestFontSizeLB,m_pWestFontLanguageLB,pFontList,GetWhich( SID_ATTR_CHAR_FONT ),GetWhich( SID_ATTR_CHAR_FONTHEIGHT ));
     541             : 
     542           0 :     calcFontInfo(rCJKFont,this,m_pEastFontNameLB,m_pEastFontStyleLB,m_pEastFontSizeLB,m_pEastFontLanguageLB,pFontList,GetWhich( SID_ATTR_CHAR_CJK_FONT ),GetWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT ));
     543             : 
     544           0 :     calcFontInfo(rCTLFont,this,m_pCTLFontNameLB,m_pCTLFontStyleLB,m_pCTLFontSizeLB,m_pCTLFontLanguageLB,pFontList,GetWhich( SID_ATTR_CHAR_CTL_FONT ),GetWhich( SID_ATTR_CHAR_CTL_FONTHEIGHT ));
     545             : 
     546           0 :     m_pPreviewWin->Invalidate();
     547           0 : }
     548             : 
     549             : // -----------------------------------------------------------------------
     550             : 
     551           0 : void SvxCharNamePage::FillStyleBox_Impl( const FontNameBox* pNameBox )
     552             : {
     553           0 :     const FontList* pFontList = GetFontList();
     554             :     DBG_ASSERT( pFontList, "no fontlist" );
     555             : 
     556           0 :     FontStyleBox* pStyleBox = NULL;
     557             : 
     558           0 :     if ( m_pWestFontNameLB == pNameBox )
     559           0 :         pStyleBox = m_pWestFontStyleLB;
     560           0 :     else if ( m_pEastFontNameLB == pNameBox )
     561           0 :         pStyleBox = m_pEastFontStyleLB;
     562           0 :     else if ( m_pCTLFontNameLB == pNameBox )
     563           0 :         pStyleBox = m_pCTLFontStyleLB;
     564             :     else
     565             :     {
     566             :         SAL_WARN( "cui.tabpages", "invalid font name box" );
     567           0 :         return;
     568             :     }
     569             : 
     570           0 :     pStyleBox->Fill( pNameBox->GetText(), pFontList );
     571             : 
     572           0 :     if ( m_pImpl->m_bInSearchMode )
     573             :     {
     574             :         // additional entries for the search:
     575             :         // "not bold" and "not italic"
     576           0 :         String aEntry = m_pImpl->m_aNoStyleText;
     577           0 :         const sal_Char sS[] = "%1";
     578           0 :         aEntry.SearchAndReplaceAscii( sS, pFontList->GetBoldStr() );
     579           0 :         m_pImpl->m_nExtraEntryPos = pStyleBox->InsertEntry( aEntry );
     580           0 :         aEntry = m_pImpl->m_aNoStyleText;
     581           0 :         aEntry.SearchAndReplaceAscii( sS, pFontList->GetItalicStr() );
     582           0 :         pStyleBox->InsertEntry( aEntry );
     583             :     }
     584             : }
     585             : 
     586             : // -----------------------------------------------------------------------
     587             : 
     588           0 : void SvxCharNamePage::FillSizeBox_Impl( const FontNameBox* pNameBox )
     589             : {
     590           0 :     const FontList* pFontList = GetFontList();
     591             :     DBG_ASSERT( pFontList, "no fontlist" );
     592             : 
     593           0 :     FontStyleBox* pStyleBox = NULL;
     594           0 :     FontSizeBox* pSizeBox = NULL;
     595             : 
     596           0 :     if ( m_pWestFontNameLB == pNameBox )
     597             :     {
     598           0 :         pStyleBox = m_pWestFontStyleLB;
     599           0 :         pSizeBox = m_pWestFontSizeLB;
     600             :     }
     601           0 :     else if ( m_pEastFontNameLB == pNameBox )
     602             :     {
     603           0 :         pStyleBox = m_pEastFontStyleLB;
     604           0 :         pSizeBox = m_pEastFontSizeLB;
     605             :     }
     606           0 :     else if ( m_pCTLFontNameLB == pNameBox )
     607             :     {
     608           0 :         pStyleBox = m_pCTLFontStyleLB;
     609           0 :         pSizeBox = m_pCTLFontSizeLB;
     610             :     }
     611             :     else
     612             :     {
     613             :         SAL_WARN( "cui.tabpages", "invalid font name box" );
     614           0 :         return;
     615             :     }
     616             : 
     617           0 :     FontInfo _aFontInfo( pFontList->Get( pNameBox->GetText(), pStyleBox->GetText() ) );
     618           0 :     pSizeBox->Fill( &_aFontInfo, pFontList );
     619             : }
     620             : 
     621             : // -----------------------------------------------------------------------
     622             : 
     623           0 : void SvxCharNamePage::Reset_Impl( const SfxItemSet& rSet, LanguageGroup eLangGrp )
     624             : {
     625           0 :     FontNameBox* pNameBox = NULL;
     626           0 :     FixedText* pStyleLabel = NULL;
     627           0 :     FontStyleBox* pStyleBox = NULL;
     628           0 :     FixedText* pSizeLabel = NULL;
     629           0 :     FontSizeBox* pSizeBox = NULL;
     630           0 :     FixedText* pLangFT = NULL;
     631           0 :     SvxLanguageBox* pLangBox = NULL;
     632           0 :     sal_uInt16 nWhich = 0;
     633             : 
     634           0 :     switch ( eLangGrp )
     635             :     {
     636             :         case Western :
     637           0 :             pNameBox = m_pWestFontNameLB;
     638           0 :             pStyleLabel = m_pWestFontStyleFT;
     639           0 :             pStyleBox = m_pWestFontStyleLB;
     640           0 :             pSizeLabel = m_pWestFontSizeFT;
     641           0 :             pSizeBox = m_pWestFontSizeLB;
     642           0 :             pLangFT = m_pWestFontLanguageFT;
     643           0 :             pLangBox = m_pWestFontLanguageLB;
     644           0 :             nWhich = GetWhich( SID_ATTR_CHAR_FONT );
     645           0 :             break;
     646             : 
     647             :         case Asian :
     648           0 :             pNameBox = m_pEastFontNameLB;
     649           0 :             pStyleLabel = m_pEastFontStyleFT;
     650           0 :             pStyleBox = m_pEastFontStyleLB;
     651           0 :             pSizeLabel = m_pEastFontSizeFT;
     652           0 :             pSizeBox = m_pEastFontSizeLB;
     653           0 :             pLangFT = m_pEastFontLanguageFT;
     654           0 :             pLangBox = m_pEastFontLanguageLB;
     655           0 :             nWhich = GetWhich( SID_ATTR_CHAR_CJK_FONT );
     656           0 :             break;
     657             : 
     658             :         case Ctl :
     659           0 :             pNameBox = m_pCTLFontNameLB;
     660           0 :             pStyleLabel = m_pCTLFontStyleFT;
     661           0 :             pStyleBox = m_pCTLFontStyleLB;
     662           0 :             pSizeLabel = m_pCTLFontSizeFT;
     663           0 :             pSizeBox = m_pCTLFontSizeLB;
     664           0 :             pLangFT = m_pCTLFontLanguageFT;
     665           0 :             pLangBox = m_pCTLFontLanguageLB;
     666           0 :             nWhich = GetWhich( SID_ATTR_CHAR_CTL_FONT );
     667           0 :             break;
     668             :     }
     669             : 
     670           0 :     const FontList* pFontList = GetFontList();
     671           0 :     pNameBox->Fill( pFontList );
     672             : 
     673           0 :     const SvxFontItem* pFontItem = NULL;
     674           0 :     SfxItemState eState = rSet.GetItemState( nWhich );
     675             : 
     676           0 :     if ( eState >= SFX_ITEM_DEFAULT )
     677             :     {
     678           0 :         pFontItem = (const SvxFontItem*)&( rSet.Get( nWhich ) );
     679           0 :         pNameBox->SetText( pFontItem->GetFamilyName() );
     680             :     }
     681             :     else
     682             :     {
     683           0 :         pNameBox->SetText( String() );
     684             :     }
     685             : 
     686           0 :     FillStyleBox_Impl( pNameBox );
     687             : 
     688           0 :     bool bStyle = false;
     689           0 :     bool bStyleAvailable = true;
     690           0 :     FontItalic eItalic = ITALIC_NONE;
     691           0 :     FontWeight eWeight = WEIGHT_NORMAL;
     692           0 :     switch ( eLangGrp )
     693             :     {
     694           0 :         case Western : nWhich = GetWhich( SID_ATTR_CHAR_POSTURE ); break;
     695           0 :         case Asian : nWhich = GetWhich( SID_ATTR_CHAR_CJK_POSTURE ); break;
     696           0 :         case Ctl : nWhich = GetWhich( SID_ATTR_CHAR_CTL_POSTURE ); break;
     697             :     }
     698           0 :     eState = rSet.GetItemState( nWhich );
     699             : 
     700           0 :     if ( eState >= SFX_ITEM_DEFAULT )
     701             :     {
     702           0 :         const SvxPostureItem& rItem = (SvxPostureItem&)rSet.Get( nWhich );
     703           0 :         eItalic = (FontItalic)rItem.GetValue();
     704           0 :         bStyle = true;
     705             :     }
     706           0 :     bStyleAvailable = bStyleAvailable && (eState >= SFX_ITEM_DONTCARE);
     707             : 
     708           0 :     switch ( eLangGrp )
     709             :     {
     710           0 :         case Western : nWhich = GetWhich( SID_ATTR_CHAR_WEIGHT ); break;
     711           0 :         case Asian : nWhich = GetWhich( SID_ATTR_CHAR_CJK_WEIGHT ); break;
     712           0 :         case Ctl : nWhich = GetWhich( SID_ATTR_CHAR_CTL_WEIGHT ); break;
     713             :     }
     714           0 :     eState = rSet.GetItemState( nWhich );
     715             : 
     716           0 :     if ( eState >= SFX_ITEM_DEFAULT )
     717             :     {
     718           0 :         SvxWeightItem& rItem = (SvxWeightItem&)rSet.Get( nWhich );
     719           0 :         eWeight = (FontWeight)rItem.GetValue();
     720             :     }
     721             :     else
     722           0 :         bStyle = false;
     723           0 :     bStyleAvailable = bStyleAvailable && (eState >= SFX_ITEM_DONTCARE);
     724             : 
     725             :     // currently chosen font
     726           0 :     if ( bStyle && pFontItem )
     727             :     {
     728           0 :         FontInfo aInfo = pFontList->Get( pFontItem->GetFamilyName(), eWeight, eItalic );
     729           0 :         pStyleBox->SetText( pFontList->GetStyleName( aInfo ) );
     730             :     }
     731           0 :     else if ( !m_pImpl->m_bInSearchMode || !bStyle )
     732             :     {
     733           0 :         pStyleBox->SetText( String() );
     734             :     }
     735           0 :     else if ( bStyle )
     736             :     {
     737           0 :         FontInfo aInfo = pFontList->Get( String(), eWeight, eItalic );
     738           0 :         pStyleBox->SetText( pFontList->GetStyleName( aInfo ) );
     739             :     }
     740           0 :     if (!bStyleAvailable)
     741             :     {
     742           0 :         pStyleBox->Disable( );
     743           0 :         pStyleLabel->Disable( );
     744             :     }
     745             : 
     746           0 :     FillSizeBox_Impl( pNameBox );
     747           0 :     switch ( eLangGrp )
     748             :     {
     749           0 :         case Western : nWhich = GetWhich( SID_ATTR_CHAR_FONTHEIGHT ); break;
     750           0 :         case Asian : nWhich = GetWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT ); break;
     751           0 :         case Ctl : nWhich = GetWhich( SID_ATTR_CHAR_CTL_FONTHEIGHT ); break;
     752             :     }
     753           0 :     eState = rSet.GetItemState( nWhich );
     754             : 
     755           0 :     if ( pSizeBox->IsRelativeMode() )
     756             :     {
     757           0 :         SfxMapUnit eUnit = rSet.GetPool()->GetMetric( nWhich );
     758           0 :         const SvxFontHeightItem& rItem = (SvxFontHeightItem&)rSet.Get( nWhich );
     759             : 
     760           0 :         if( rItem.GetProp() != 100 || SFX_MAPUNIT_RELATIVE != rItem.GetPropUnit() )
     761             :         {
     762           0 :             sal_Bool bPtRel = SFX_MAPUNIT_POINT == rItem.GetPropUnit();
     763           0 :             pSizeBox->SetPtRelative( bPtRel );
     764           0 :             pSizeBox->SetValue( bPtRel ? ((short)rItem.GetProp()) * 10 : rItem.GetProp() );
     765             :         }
     766             :         else
     767             :         {
     768           0 :             pSizeBox->SetRelative();
     769           0 :             pSizeBox->SetValue( (long)CalcToPoint( rItem.GetHeight(), eUnit, 10 ) );
     770             :         }
     771             :     }
     772           0 :     else if ( eState >= SFX_ITEM_DEFAULT )
     773             :     {
     774           0 :         SfxMapUnit eUnit = rSet.GetPool()->GetMetric( nWhich );
     775           0 :         const SvxFontHeightItem& rItem = (SvxFontHeightItem&)rSet.Get( nWhich );
     776           0 :         pSizeBox->SetValue( (long)CalcToPoint( rItem.GetHeight(), eUnit, 10 ) );
     777             :     }
     778             :     else
     779             :     {
     780           0 :         pSizeBox->SetText( String() );
     781           0 :         if ( eState <= SFX_ITEM_READONLY )
     782             :         {
     783           0 :             pSizeBox->Disable( );
     784           0 :             pSizeLabel->Disable( );
     785             :         }
     786             :     }
     787             : 
     788           0 :     switch ( eLangGrp )
     789             :     {
     790           0 :         case Western : nWhich = GetWhich( SID_ATTR_CHAR_LANGUAGE ); break;
     791           0 :         case Asian : nWhich = GetWhich( SID_ATTR_CHAR_CJK_LANGUAGE ); break;
     792           0 :         case Ctl : nWhich = GetWhich( SID_ATTR_CHAR_CTL_LANGUAGE ); break;
     793             :     }
     794           0 :     pLangBox->SetNoSelection();
     795           0 :     eState = rSet.GetItemState( nWhich );
     796             : 
     797           0 :     switch ( eState )
     798             :     {
     799             :         case SFX_ITEM_UNKNOWN:
     800           0 :             pLangFT->Hide();
     801           0 :             pLangBox->Hide();
     802           0 :             break;
     803             : 
     804             :         case SFX_ITEM_DISABLED:
     805             :         case SFX_ITEM_READONLY:
     806           0 :             pLangFT->Disable();
     807           0 :             pLangBox->Disable();
     808           0 :             break;
     809             : 
     810             :         case SFX_ITEM_DEFAULT:
     811             :         case SFX_ITEM_SET:
     812             :         {
     813           0 :             const SvxLanguageItem& rItem = (SvxLanguageItem&)rSet.Get( nWhich );
     814           0 :             LanguageType eLangType = (LanguageType)rItem.GetValue();
     815             :             DBG_ASSERT( eLangType != LANGUAGE_SYSTEM, "LANGUAGE_SYSTEM not allowed" );
     816           0 :             if ( eLangType != LANGUAGE_DONTKNOW )
     817           0 :                 pLangBox->SelectLanguage( eLangType );
     818           0 :             break;
     819             :         }
     820             :     }
     821             : 
     822             :     // save these settings
     823           0 :     pNameBox->SaveValue();
     824           0 :     pStyleBox->SaveValue();
     825           0 :     pSizeBox->SaveValue();
     826           0 :     pLangBox->SaveValue();
     827           0 : }
     828             : 
     829             : // -----------------------------------------------------------------------
     830             : 
     831           0 : sal_Bool SvxCharNamePage::FillItemSet_Impl( SfxItemSet& rSet, LanguageGroup eLangGrp )
     832             : {
     833           0 :     sal_Bool bModified = sal_False;
     834             : 
     835           0 :     FontNameBox* pNameBox = NULL;
     836           0 :     FontStyleBox* pStyleBox = NULL;
     837           0 :     FontSizeBox* pSizeBox = NULL;
     838           0 :     SvxLanguageBox* pLangBox = NULL;
     839           0 :     sal_uInt16 nWhich = 0;
     840           0 :     sal_uInt16 nSlot = 0;
     841             : 
     842           0 :     switch ( eLangGrp )
     843             :     {
     844             :         case Western :
     845           0 :             pNameBox = m_pWestFontNameLB;
     846           0 :             pStyleBox = m_pWestFontStyleLB;
     847           0 :             pSizeBox = m_pWestFontSizeLB;
     848           0 :             pLangBox = m_pWestFontLanguageLB;
     849           0 :             nSlot = SID_ATTR_CHAR_FONT;
     850           0 :             break;
     851             : 
     852             :         case Asian :
     853           0 :             pNameBox = m_pEastFontNameLB;
     854           0 :             pStyleBox = m_pEastFontStyleLB;
     855           0 :             pSizeBox = m_pEastFontSizeLB;
     856           0 :             pLangBox = m_pEastFontLanguageLB;
     857           0 :             nSlot = SID_ATTR_CHAR_CJK_FONT;
     858           0 :             break;
     859             : 
     860             :         case Ctl :
     861           0 :             pNameBox = m_pCTLFontNameLB;
     862           0 :             pStyleBox = m_pCTLFontStyleLB;
     863           0 :             pSizeBox = m_pCTLFontSizeLB;
     864           0 :             pLangBox = m_pCTLFontLanguageLB;
     865           0 :             nSlot = SID_ATTR_CHAR_CTL_FONT;
     866           0 :             break;
     867             :     }
     868             : 
     869           0 :     nWhich = GetWhich( nSlot );
     870           0 :     const SfxPoolItem* pItem = NULL;
     871           0 :     const SfxItemSet& rOldSet = GetItemSet();
     872           0 :     const SfxPoolItem* pOld = NULL;
     873             : 
     874           0 :     const SfxItemSet* pExampleSet = GetTabDialog() ? GetTabDialog()->GetExampleSet() : NULL;
     875             : 
     876           0 :     bool bChanged = true;
     877           0 :     const String& rFontName  = pNameBox->GetText();
     878           0 :     const FontList* pFontList = GetFontList();
     879           0 :     String aStyleBoxText =pStyleBox->GetText();
     880           0 :     sal_uInt16 nEntryPos = pStyleBox->GetEntryPos( aStyleBoxText );
     881           0 :     if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
     882           0 :         aStyleBoxText.Erase();
     883           0 :     FontInfo aInfo( pFontList->Get( rFontName, aStyleBoxText ) );
     884           0 :     SvxFontItem aFontItem( aInfo.GetFamily(), aInfo.GetName(), aInfo.GetStyleName(),
     885           0 :                            aInfo.GetPitch(), aInfo.GetCharSet(), nWhich );
     886           0 :     pOld = GetOldItem( rSet, nSlot );
     887             : 
     888           0 :     if ( pOld )
     889             :     {
     890           0 :         const SvxFontItem& rItem = *( (const SvxFontItem*)pOld );
     891             : 
     892           0 :         if ( rItem.GetFamilyName() == aFontItem.GetFamilyName() )
     893           0 :             bChanged = false;
     894             :     }
     895             : 
     896           0 :     if ( !bChanged )
     897           0 :         bChanged = !pNameBox->GetSavedValue().Len();
     898             : 
     899           0 :     if ( !bChanged && pExampleSet &&
     900           0 :          pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET &&
     901           0 :          ( (SvxFontItem*)pItem )->GetFamilyName() != aFontItem.GetFamilyName() )
     902           0 :         bChanged = true;
     903             : 
     904           0 :     if ( bChanged && rFontName.Len() )
     905             :     {
     906           0 :         rSet.Put( aFontItem );
     907           0 :         bModified = sal_True;
     908             :     }
     909           0 :     else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
     910           0 :         rSet.ClearItem( nWhich );
     911             : 
     912             : 
     913           0 :     bChanged = sal_True;
     914           0 :     switch ( eLangGrp )
     915             :     {
     916           0 :         case Western : nSlot = SID_ATTR_CHAR_WEIGHT; break;
     917           0 :         case Asian : nSlot = SID_ATTR_CHAR_CJK_WEIGHT; break;
     918           0 :         case Ctl : nSlot = SID_ATTR_CHAR_CTL_WEIGHT; break;
     919             :     }
     920           0 :     nWhich = GetWhich( nSlot );
     921           0 :     FontWeight eWeight = aInfo.GetWeight();
     922           0 :     if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
     923           0 :         eWeight = WEIGHT_NORMAL;
     924           0 :     SvxWeightItem aWeightItem( eWeight, nWhich );
     925           0 :     pOld = GetOldItem( rSet, nSlot );
     926             : 
     927           0 :     if ( pOld )
     928             :     {
     929           0 :         const SvxWeightItem& rItem = *( (const SvxWeightItem*)pOld );
     930             : 
     931           0 :         if ( rItem.GetValue() == aWeightItem.GetValue() )
     932           0 :             bChanged = false;
     933             :     }
     934             : 
     935           0 :     if ( !bChanged )
     936             :     {
     937           0 :         bChanged = !pStyleBox->GetSavedValue().Len();
     938             : 
     939           0 :         if ( m_pImpl->m_bInSearchMode && bChanged &&
     940           0 :              aInfo.GetWeight() == WEIGHT_NORMAL && aInfo.GetItalic() != ITALIC_NONE )
     941           0 :             bChanged = true;
     942             :     }
     943             : 
     944           0 :     if ( !bChanged && pExampleSet &&
     945           0 :          pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET &&
     946           0 :          ( (SvxWeightItem*)pItem )->GetValue() != aWeightItem.GetValue() )
     947           0 :         bChanged = true;
     948             : 
     949           0 :     if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
     950           0 :         bChanged = ( nEntryPos == m_pImpl->m_nExtraEntryPos );
     951             : 
     952           0 :     String aText( pStyleBox->GetText() ); // Tristate, then text empty
     953             : 
     954           0 :     if ( bChanged && aText.Len() )
     955             :     {
     956           0 :         rSet.Put( aWeightItem );
     957           0 :         bModified = sal_True;
     958             :     }
     959           0 :     else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
     960           0 :         CLEARTITEM;
     961             : 
     962           0 :     bChanged = true;
     963           0 :     switch ( eLangGrp )
     964             :     {
     965           0 :         case Western : nSlot = SID_ATTR_CHAR_POSTURE; break;
     966           0 :         case Asian : nSlot = SID_ATTR_CHAR_CJK_POSTURE; break;
     967           0 :         case Ctl : nSlot = SID_ATTR_CHAR_CTL_POSTURE; break;
     968             :     }
     969           0 :     nWhich = GetWhich( nSlot );
     970           0 :     FontItalic eItalic = aInfo.GetItalic();
     971           0 :     if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
     972           0 :         eItalic = ITALIC_NONE;
     973           0 :     SvxPostureItem aPostureItem( eItalic, nWhich );
     974           0 :     pOld = GetOldItem( rSet, nSlot );
     975             : 
     976           0 :     if ( pOld )
     977             :     {
     978           0 :         const SvxPostureItem& rItem = *( (const SvxPostureItem*)pOld );
     979             : 
     980           0 :         if ( rItem.GetValue() == aPostureItem.GetValue() )
     981           0 :             bChanged = false;
     982             :     }
     983             : 
     984           0 :     if ( !bChanged )
     985             :     {
     986           0 :         bChanged = !pStyleBox->GetSavedValue().Len();
     987             : 
     988           0 :         if ( m_pImpl->m_bInSearchMode && bChanged &&
     989           0 :              aInfo.GetItalic() == ITALIC_NONE && aInfo.GetWeight() != WEIGHT_NORMAL )
     990           0 :             bChanged = false;
     991             :     }
     992             : 
     993           0 :     if ( !bChanged && pExampleSet &&
     994           0 :          pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET &&
     995           0 :          ( (SvxPostureItem*)pItem )->GetValue() != aPostureItem.GetValue() )
     996           0 :         bChanged = true;
     997             : 
     998           0 :     if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
     999           0 :         bChanged = ( nEntryPos == ( m_pImpl->m_nExtraEntryPos + 1 ) );
    1000             : 
    1001           0 :     if ( bChanged && aText.Len() )
    1002             :     {
    1003           0 :         rSet.Put( aPostureItem );
    1004           0 :         bModified = sal_True;
    1005             :     }
    1006           0 :     else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
    1007           0 :         CLEARTITEM;
    1008             : 
    1009             :     // FontSize
    1010           0 :     long nSize = static_cast<long>(pSizeBox->GetValue());
    1011             : 
    1012           0 :     if ( !pSizeBox->GetText().Len() )   // GetValue() returns the min-value
    1013           0 :         nSize = 0;
    1014           0 :     long nSavedSize = pSizeBox->GetSavedValue().ToInt32();
    1015           0 :     bool bRel = true;
    1016             : 
    1017           0 :     if ( !pSizeBox->IsRelative() )
    1018             :     {
    1019           0 :         nSavedSize *= 10;
    1020           0 :         bRel = false;
    1021             :     }
    1022             : 
    1023           0 :     switch ( eLangGrp )
    1024             :     {
    1025           0 :         case Western : nSlot = SID_ATTR_CHAR_FONTHEIGHT; break;
    1026           0 :         case Asian : nSlot = SID_ATTR_CHAR_CJK_FONTHEIGHT; break;
    1027           0 :         case Ctl : nSlot = SID_ATTR_CHAR_CTL_FONTHEIGHT; break;
    1028             :     }
    1029           0 :     nWhich = GetWhich( nSlot );
    1030           0 :     const SvxFontHeightItem* pOldHeight = (const SvxFontHeightItem*)GetOldItem( rSet, nSlot );
    1031           0 :     bChanged = ( nSize != nSavedSize );
    1032             : 
    1033           0 :     if ( !bChanged && pExampleSet &&
    1034           0 :          pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET )
    1035             :     {
    1036           0 :         float fSize = (float)nSize / 10;
    1037           0 :         long nVal = CalcToUnit( fSize, rSet.GetPool()->GetMetric( nWhich ) );
    1038           0 :         if ( ( (SvxFontHeightItem*)pItem )->GetHeight() != (sal_uInt32)nVal )
    1039           0 :             bChanged = true;
    1040             :     }
    1041             : 
    1042           0 :     if ( bChanged || !pOldHeight ||
    1043           0 :          bRel != ( SFX_MAPUNIT_RELATIVE != pOldHeight->GetPropUnit() || 100 != pOldHeight->GetProp() ) )
    1044             :     {
    1045           0 :         SfxMapUnit eUnit = rSet.GetPool()->GetMetric( nWhich );
    1046           0 :         if ( pSizeBox->IsRelative() )
    1047             :         {
    1048             :             DBG_ASSERT( GetItemSet().GetParent(), "No parent set" );
    1049             :             const SvxFontHeightItem& rOldItem =
    1050           0 :                 (const SvxFontHeightItem&)GetItemSet().GetParent()->Get( nWhich );
    1051             : 
    1052           0 :             SvxFontHeightItem aHeight( 240, 100, nWhich );
    1053           0 :             if ( pSizeBox->IsPtRelative() )
    1054           0 :                 aHeight.SetHeight( rOldItem.GetHeight(), (sal_uInt16)( nSize / 10 ), SFX_MAPUNIT_POINT, eUnit );
    1055             :             else
    1056           0 :                 aHeight.SetHeight( rOldItem.GetHeight(), (sal_uInt16)nSize, SFX_MAPUNIT_RELATIVE );
    1057           0 :             rSet.Put( aHeight );
    1058             :         }
    1059             :         else
    1060             :         {
    1061           0 :             float fSize = (float)nSize / 10;
    1062           0 :             rSet.Put( SvxFontHeightItem( CalcToUnit( fSize, eUnit ), 100, nWhich ) );
    1063             :         }
    1064           0 :         bModified = sal_True;
    1065             :     }
    1066           0 :     else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
    1067           0 :         CLEARTITEM;
    1068             : 
    1069           0 :     bChanged = true;
    1070           0 :     switch ( eLangGrp )
    1071             :     {
    1072           0 :         case Western : nSlot = SID_ATTR_CHAR_LANGUAGE; break;
    1073           0 :         case Asian : nSlot = SID_ATTR_CHAR_CJK_LANGUAGE; break;
    1074           0 :         case Ctl : nSlot = SID_ATTR_CHAR_CTL_LANGUAGE; break;
    1075             :     }
    1076           0 :     nWhich = GetWhich( nSlot );
    1077           0 :     pOld = GetOldItem( rSet, nSlot );
    1078           0 :     sal_uInt16 nLangPos = pLangBox->GetSelectEntryPos();
    1079           0 :     LanguageType eLangType = (LanguageType)(sal_uLong)pLangBox->GetEntryData( nLangPos );
    1080             : 
    1081           0 :     if ( pOld )
    1082             :     {
    1083           0 :         const SvxLanguageItem& rItem = *( (const SvxLanguageItem*)pOld );
    1084             : 
    1085           0 :         if ( nLangPos == LISTBOX_ENTRY_NOTFOUND || eLangType == (LanguageType)rItem.GetValue() )
    1086           0 :             bChanged = false;
    1087             :     }
    1088             : 
    1089           0 :     if ( !bChanged )
    1090           0 :         bChanged = ( pLangBox->GetSavedValue() == LISTBOX_ENTRY_NOTFOUND );
    1091             : 
    1092           0 :     if ( bChanged && nLangPos != LISTBOX_ENTRY_NOTFOUND )
    1093             :     {
    1094           0 :         rSet.Put( SvxLanguageItem( eLangType, nWhich ) );
    1095           0 :         bModified = sal_True;
    1096             :     }
    1097           0 :     else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
    1098           0 :         CLEARTITEM;
    1099             : 
    1100           0 :     return bModified;
    1101             : }
    1102             : 
    1103             : // -----------------------------------------------------------------------
    1104             : 
    1105           0 : IMPL_LINK_NOARG(SvxCharNamePage, UpdateHdl_Impl)
    1106             : {
    1107           0 :     UpdatePreview_Impl();
    1108           0 :     return 0;
    1109             : }
    1110             : 
    1111             : // -----------------------------------------------------------------------
    1112             : 
    1113           0 : IMPL_LINK( SvxCharNamePage, FontModifyHdl_Impl, void*, pNameBox )
    1114             : {
    1115           0 :     m_pImpl->m_aUpdateTimer.Start();
    1116             : 
    1117           0 :     if ( m_pWestFontNameLB == pNameBox || m_pEastFontNameLB == pNameBox || m_pCTLFontNameLB == pNameBox )
    1118             :     {
    1119           0 :         FillStyleBox_Impl( (FontNameBox*)pNameBox );
    1120           0 :         FillSizeBox_Impl( (FontNameBox*)pNameBox );
    1121             :     }
    1122           0 :     return 0;
    1123             : }
    1124             : 
    1125             : // -----------------------------------------------------------------------
    1126             : 
    1127           0 : void SvxCharNamePage::ActivatePage( const SfxItemSet& rSet )
    1128             : {
    1129           0 :     SvxCharBasePage::ActivatePage( rSet );
    1130             : 
    1131           0 :     UpdatePreview_Impl();       // instead of asynchronous calling in ctor
    1132           0 : }
    1133             : 
    1134             : // -----------------------------------------------------------------------
    1135             : 
    1136           0 : int SvxCharNamePage::DeactivatePage( SfxItemSet* _pSet )
    1137             : {
    1138           0 :     if ( _pSet )
    1139           0 :         FillItemSet( *_pSet );
    1140           0 :     return LEAVE_PAGE;
    1141             : }
    1142             : 
    1143             : // -----------------------------------------------------------------------
    1144             : 
    1145           0 : SfxTabPage* SvxCharNamePage::Create( Window* pParent, const SfxItemSet& rSet )
    1146             : {
    1147           0 :     return new SvxCharNamePage( pParent, rSet );
    1148             : }
    1149             : 
    1150             : // -----------------------------------------------------------------------
    1151             : 
    1152           0 : sal_uInt16* SvxCharNamePage::GetRanges()
    1153             : {
    1154           0 :     return pNameRanges;
    1155             : }
    1156             : 
    1157             : // -----------------------------------------------------------------------
    1158             : 
    1159           0 : void SvxCharNamePage::Reset( const SfxItemSet& rSet )
    1160             : {
    1161           0 :     Reset_Impl( rSet, Western );
    1162           0 :     Reset_Impl( rSet, Asian );
    1163           0 :     Reset_Impl( rSet, Ctl );
    1164             : 
    1165           0 :     equalize_width_requests(m_pWestFontNameLB, m_pEastFontNameLB, m_pCTLFontNameLB);
    1166           0 :     equalize_width_requests(m_pWestFontStyleLB, m_pEastFontStyleLB, m_pCTLFontStyleLB);
    1167           0 :     equalize_width_requests(m_pWestFontSizeLB, m_pEastFontSizeLB, m_pCTLFontSizeLB);
    1168             : 
    1169           0 :     SetPrevFontWidthScale( rSet );
    1170           0 :     UpdatePreview_Impl();
    1171           0 : }
    1172             : 
    1173             : // -----------------------------------------------------------------------
    1174             : 
    1175           0 : sal_Bool SvxCharNamePage::FillItemSet( SfxItemSet& rSet )
    1176             : {
    1177           0 :     sal_Bool bModified = FillItemSet_Impl( rSet, Western );
    1178           0 :     bModified |= FillItemSet_Impl( rSet, Asian );
    1179           0 :     bModified |= FillItemSet_Impl( rSet, Ctl );
    1180           0 :     return bModified;
    1181             : }
    1182             : 
    1183             : // -----------------------------------------------------------------------
    1184             : 
    1185           0 : void SvxCharNamePage::SetFontList( const SvxFontListItem& rItem )
    1186             : {
    1187           0 :     if ( m_pImpl->m_bMustDelete )
    1188             :     {
    1189           0 :         delete m_pImpl->m_pFontList;
    1190             :     }
    1191           0 :     m_pImpl->m_pFontList = rItem.GetFontList()->Clone();
    1192           0 :     m_pImpl->m_bMustDelete = sal_True;
    1193           0 : }
    1194             : 
    1195             : // -----------------------------------------------------------------------
    1196             : namespace
    1197             : {
    1198           0 :     void enableRelativeMode( SvxCharNamePage* _pPage, FontSizeBox* _pFontSizeLB, sal_uInt16 _nHeightWhich )
    1199             :     {
    1200           0 :         _pFontSizeLB->EnableRelativeMode( 5, 995, 5 ); // min 5%, max 995%, step 5
    1201             : 
    1202             :         const SvxFontHeightItem& rHeightItem =
    1203           0 :             (SvxFontHeightItem&)_pPage->GetItemSet().GetParent()->Get( _nHeightWhich );
    1204           0 :         SfxMapUnit eUnit = _pPage->GetItemSet().GetPool()->GetMetric( _nHeightWhich );
    1205             :         short nCurHeight =
    1206           0 :             static_cast< short >( CalcToPoint( rHeightItem.GetHeight(), eUnit, 1 ) * 10 );
    1207             : 
    1208             :         // based on the current height:
    1209             :         //      - negative until minimum of 2 pt
    1210             :         //      - positive until maximum of 999 pt
    1211           0 :         _pFontSizeLB->EnablePtRelativeMode( sal::static_int_cast< short >(-(nCurHeight - 20)), (9999 - nCurHeight), 10 );
    1212           0 :     }
    1213             : }
    1214             : // -----------------------------------------------------------------------------
    1215             : 
    1216           0 : void SvxCharNamePage::EnableRelativeMode()
    1217             : {
    1218             :     DBG_ASSERT( GetItemSet().GetParent(), "RelativeMode, but no ParentSet!" );
    1219           0 :     enableRelativeMode(this,m_pWestFontSizeLB,GetWhich( SID_ATTR_CHAR_FONTHEIGHT ));
    1220           0 :     enableRelativeMode(this,m_pEastFontSizeLB,GetWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT ));
    1221           0 :     enableRelativeMode(this,m_pCTLFontSizeLB,GetWhich( SID_ATTR_CHAR_CTL_FONTHEIGHT ));
    1222           0 : }
    1223             : 
    1224             : // -----------------------------------------------------------------------
    1225             : 
    1226           0 : void SvxCharNamePage::EnableSearchMode()
    1227             : {
    1228           0 :     m_pImpl->m_bInSearchMode = sal_True;
    1229           0 : }
    1230             : // -----------------------------------------------------------------------
    1231           0 : void SvxCharNamePage::DisableControls( sal_uInt16 nDisable )
    1232             : {
    1233           0 :     if ( DISABLE_LANGUAGE & nDisable )
    1234             :     {
    1235           0 :         if ( m_pWestFontLanguageFT ) m_pWestFontLanguageFT->Disable();
    1236           0 :         if ( m_pWestFontLanguageLB ) m_pWestFontLanguageLB->Disable();
    1237           0 :         if ( m_pEastFontLanguageFT ) m_pEastFontLanguageFT->Disable();
    1238           0 :         if ( m_pEastFontLanguageLB ) m_pEastFontLanguageLB->Disable();
    1239           0 :         if ( m_pCTLFontLanguageFT ) m_pCTLFontLanguageFT->Disable();
    1240           0 :         if ( m_pCTLFontLanguageLB ) m_pCTLFontLanguageLB->Disable();
    1241             :     }
    1242             : 
    1243           0 :     if ( DISABLE_HIDE_LANGUAGE & nDisable )
    1244             :     {
    1245           0 :         if ( m_pWestFontLanguageFT ) m_pWestFontLanguageFT->Hide();
    1246           0 :         if ( m_pWestFontLanguageLB ) m_pWestFontLanguageLB->Hide();
    1247           0 :         if ( m_pEastFontLanguageFT ) m_pEastFontLanguageFT->Hide();
    1248           0 :         if ( m_pEastFontLanguageLB ) m_pEastFontLanguageLB->Hide();
    1249           0 :         if ( m_pCTLFontLanguageFT ) m_pCTLFontLanguageFT->Hide();
    1250           0 :         if ( m_pCTLFontLanguageLB ) m_pCTLFontLanguageLB->Hide();
    1251             :     }
    1252           0 : }
    1253             : 
    1254             : // -----------------------------------------------------------------------
    1255           0 : void SvxCharNamePage::SetPreviewBackgroundToCharacter()
    1256             : {
    1257           0 :     m_bPreviewBackgroundToCharacter = sal_True;
    1258           0 : }
    1259             : 
    1260             : // -----------------------------------------------------------------------
    1261           0 : void SvxCharNamePage::PageCreated (SfxAllItemSet aSet)
    1262             : {
    1263           0 :     SFX_ITEMSET_ARG (&aSet,pFontListItem,SvxFontListItem,SID_ATTR_CHAR_FONTLIST,sal_False);
    1264           0 :     SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,sal_False);
    1265           0 :     SFX_ITEMSET_ARG (&aSet,pDisalbeItem,SfxUInt16Item,SID_DISABLE_CTL,sal_False);
    1266           0 :     if (pFontListItem)
    1267           0 :         SetFontList(*pFontListItem);
    1268             : 
    1269           0 :     if (pFlagItem)
    1270             :     {
    1271           0 :         sal_uInt32 nFlags=pFlagItem->GetValue();
    1272           0 :         if ( ( nFlags & SVX_RELATIVE_MODE ) == SVX_RELATIVE_MODE )
    1273           0 :             EnableRelativeMode();
    1274           0 :         if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
    1275           0 :             SetPreviewBackgroundToCharacter();
    1276             :     }
    1277           0 :     if (pDisalbeItem)
    1278           0 :         DisableControls(pDisalbeItem->GetValue());
    1279           0 : }
    1280             : // class SvxCharEffectsPage ----------------------------------------------
    1281             : 
    1282           0 : SvxCharEffectsPage::SvxCharEffectsPage( Window* pParent, const SfxItemSet& rInSet )
    1283             :     : SvxCharBasePage(pParent, "EffectsPage", "cui/ui/effectspage.ui", rInSet)
    1284           0 :     , m_aTransparentColorName(CUI_RES(RID_SVXSTR_CHARNAME_TRANSPARENT))
    1285             : {
    1286           0 :     get(m_pFontColorFT, "fontcolorft");
    1287           0 :     get(m_pFontColorLB, "fontcolorlb");
    1288           0 :     get(m_pEffectsFT, "effectsft");
    1289           0 :     get(m_pEffectsLB, "effectslb");
    1290           0 :     get(m_pReliefFT, "reliefft");
    1291           0 :     get(m_pReliefLB, "relieflb");
    1292           0 :     get(m_pOutlineBtn, "outlinecb");
    1293           0 :     get(m_pShadowBtn, "shadowcb");
    1294           0 :     get(m_pBlinkingBtn, "blinkingcb");
    1295           0 :     get(m_pHiddenBtn, "hiddencb");
    1296           0 :     get(m_pOverlineLB, "overlinelb");
    1297           0 :     get(m_pOverlineColorFT, "overlinecolorft");
    1298           0 :     get(m_pOverlineColorLB, "overlinecolorlb");
    1299           0 :     get(m_pStrikeoutLB, "strikeoutlb");
    1300           0 :     get(m_pUnderlineLB, "underlinelb");
    1301           0 :     get(m_pUnderlineColorFT, "underlinecolorft");
    1302           0 :     get(m_pUnderlineColorLB, "underlinecolorlb");
    1303           0 :     get(m_pIndividualWordsBtn, "individualwordscb");
    1304           0 :     get(m_pAsianLine, "asianfl");
    1305           0 :     get(m_pEmphasisFT, "emphasisft");
    1306           0 :     get(m_pEmphasisLB, "emphasislb");
    1307           0 :     get(m_pPositionFT, "positionft");
    1308           0 :     get(m_pPositionLB, "positionlb");
    1309             : 
    1310           0 :     get(m_pPreviewWin, "preview");
    1311           0 :     Initialize();
    1312           0 : }
    1313             : 
    1314             : // -----------------------------------------------------------------------
    1315             : 
    1316           0 : void SvxCharEffectsPage::Initialize()
    1317             : {
    1318             :     // to handle the changes of the other pages
    1319           0 :     SetExchangeSupport();
    1320             : 
    1321             :     // HTML-Mode
    1322             :     const SfxPoolItem* pItem;
    1323             :     SfxObjectShell* pShell;
    1324           0 :     if ( SFX_ITEM_SET == GetItemSet().GetItemState( SID_HTML_MODE, sal_False, &pItem ) ||
    1325             :          ( NULL != ( pShell = SfxObjectShell::Current() ) &&
    1326           0 :            NULL != ( pItem = pShell->GetItem( SID_HTML_MODE ) ) ) )
    1327             :     {
    1328           0 :         m_nHtmlMode = ( (const SfxUInt16Item*)pItem )->GetValue();
    1329           0 :         if ( ( m_nHtmlMode & HTMLMODE_ON ) == HTMLMODE_ON )
    1330             :         {
    1331             :             //!!! hide some controls please
    1332             :         }
    1333             :     }
    1334             : 
    1335             :     // fill the color box
    1336           0 :     SfxObjectShell* pDocSh = SfxObjectShell::Current();
    1337             :     DBG_ASSERT( pDocSh, "DocShell not found!" );
    1338           0 :     XColorListRef pColorTable;
    1339             : 
    1340           0 :     if ( pDocSh )
    1341             :     {
    1342           0 :         pItem = pDocSh->GetItem( SID_COLOR_TABLE );
    1343           0 :         if ( pItem != NULL )
    1344           0 :             pColorTable = ( (SvxColorListItem*)pItem )->GetColorList();
    1345             :     }
    1346             : 
    1347           0 :     if ( !pColorTable.is() )
    1348           0 :         pColorTable = XColorList::CreateStdColorList();
    1349             : 
    1350           0 :     m_pUnderlineColorLB->SetUpdateMode( sal_False );
    1351           0 :     m_pOverlineColorLB->SetUpdateMode( sal_False );
    1352           0 :     m_pFontColorLB->SetUpdateMode( sal_False );
    1353             : 
    1354             :     {
    1355             :         SfxPoolItem* pDummy;
    1356           0 :         SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocSh );
    1357           0 :         if ( !pFrame ||
    1358           0 :              SFX_ITEM_DEFAULT > pFrame->GetBindings().QueryState( SID_ATTR_AUTO_COLOR_INVALID, pDummy ) )
    1359             :         {
    1360           0 :             m_pUnderlineColorLB->InsertAutomaticEntryColor( Color( COL_AUTO ) );
    1361           0 :             m_pOverlineColorLB->InsertAutomaticEntryColor( Color( COL_AUTO ) );
    1362           0 :             m_pFontColorLB->InsertAutomaticEntryColor( Color( COL_AUTO ) );
    1363             :         }
    1364             :     }
    1365           0 :     for ( long i = 0; i < pColorTable->Count(); i++ )
    1366             :     {
    1367           0 :         XColorEntry* pEntry = pColorTable->GetColor(i);
    1368           0 :         m_pUnderlineColorLB->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
    1369           0 :         m_pOverlineColorLB->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
    1370           0 :         m_pFontColorLB->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
    1371             :     }
    1372             : 
    1373           0 :     m_pUnderlineColorLB->SetUpdateMode( sal_True );
    1374           0 :     m_pOverlineColorLB->SetUpdateMode( sal_True );
    1375           0 :     m_pFontColorLB->SetUpdateMode( sal_True );
    1376           0 :     m_pFontColorLB->SetSelectHdl( LINK( this, SvxCharEffectsPage, ColorBoxSelectHdl_Impl ) );
    1377             : 
    1378             :     // handler
    1379           0 :     Link aLink = LINK( this, SvxCharEffectsPage, SelectHdl_Impl );
    1380           0 :     m_pUnderlineLB->SetSelectHdl( aLink );
    1381           0 :     m_pUnderlineColorLB->SetSelectHdl( aLink );
    1382           0 :     m_pOverlineLB->SetSelectHdl( aLink );
    1383           0 :     m_pOverlineColorLB->SetSelectHdl( aLink );
    1384           0 :     m_pStrikeoutLB->SetSelectHdl( aLink );
    1385           0 :     m_pEmphasisLB->SetSelectHdl( aLink );
    1386           0 :     m_pPositionLB->SetSelectHdl( aLink );
    1387           0 :     m_pEffectsLB->SetSelectHdl( aLink );
    1388           0 :     m_pReliefLB->SetSelectHdl( aLink );
    1389             : 
    1390           0 :     m_pUnderlineLB->SelectEntryPos( 0 );
    1391           0 :     m_pUnderlineColorLB->SelectEntryPos( 0 );
    1392           0 :     m_pOverlineLB->SelectEntryPos( 0 );
    1393           0 :     m_pOverlineColorLB->SelectEntryPos( 0 );
    1394           0 :     m_pStrikeoutLB->SelectEntryPos( 0 );
    1395           0 :     m_pEmphasisLB->SelectEntryPos( 0 );
    1396           0 :     m_pPositionLB->SelectEntryPos( 0 );
    1397           0 :     SelectHdl_Impl( NULL );
    1398           0 :     SelectHdl_Impl( m_pEmphasisLB );
    1399             : 
    1400           0 :     m_pEffectsLB->SelectEntryPos( 0 );
    1401             : 
    1402           0 :     m_pIndividualWordsBtn->SetClickHdl( LINK( this, SvxCharEffectsPage, CbClickHdl_Impl ) );
    1403           0 :     aLink = LINK( this, SvxCharEffectsPage, TristClickHdl_Impl );
    1404           0 :     m_pOutlineBtn->SetClickHdl( aLink );
    1405           0 :     m_pShadowBtn->SetClickHdl( aLink );
    1406             : 
    1407           0 :     if ( !SvtLanguageOptions().IsAsianTypographyEnabled() )
    1408             :     {
    1409           0 :         m_pAsianLine->Hide();
    1410           0 :         m_pEmphasisFT->Hide();
    1411           0 :         m_pEmphasisLB->Hide();
    1412           0 :         m_pPositionFT->Hide();
    1413           0 :         m_pPositionLB->Hide();
    1414           0 :     }
    1415           0 : }
    1416             : 
    1417           0 : SvxCharEffectsPage::~SvxCharEffectsPage()
    1418             : {
    1419           0 : }
    1420             : 
    1421             : // -----------------------------------------------------------------------
    1422             : 
    1423           0 : void SvxCharEffectsPage::UpdatePreview_Impl()
    1424             : {
    1425           0 :     SvxFont& rFont = GetPreviewFont();
    1426           0 :     SvxFont& rCJKFont = GetPreviewCJKFont();
    1427           0 :     SvxFont& rCTLFont = GetPreviewCTLFont();
    1428             : 
    1429           0 :     sal_uInt16 nPos = m_pUnderlineLB->GetSelectEntryPos();
    1430           0 :     FontUnderline eUnderline = (FontUnderline)(sal_uLong)m_pUnderlineLB->GetEntryData( nPos );
    1431           0 :     nPos = m_pOverlineLB->GetSelectEntryPos();
    1432           0 :     FontUnderline eOverline = (FontUnderline)(sal_uLong)m_pOverlineLB->GetEntryData( nPos );
    1433           0 :     nPos = m_pStrikeoutLB->GetSelectEntryPos();
    1434           0 :     FontStrikeout eStrikeout = (FontStrikeout)(sal_uLong)m_pStrikeoutLB->GetEntryData( nPos );
    1435           0 :     rFont.SetUnderline( eUnderline );
    1436           0 :     rCJKFont.SetUnderline( eUnderline );
    1437           0 :     rCTLFont.SetUnderline( eUnderline );
    1438           0 :     m_pPreviewWin->SetTextLineColor( m_pUnderlineColorLB->GetSelectEntryColor() );
    1439           0 :     rFont.SetOverline( eOverline );
    1440           0 :     rCJKFont.SetOverline( eOverline );
    1441           0 :     rCTLFont.SetOverline( eOverline );
    1442           0 :     m_pPreviewWin->SetOverlineColor( m_pOverlineColorLB->GetSelectEntryColor() );
    1443           0 :     rFont.SetStrikeout( eStrikeout );
    1444           0 :     rCJKFont.SetStrikeout( eStrikeout );
    1445           0 :     rCTLFont.SetStrikeout( eStrikeout );
    1446             : 
    1447           0 :     nPos = m_pPositionLB->GetSelectEntryPos();
    1448           0 :     sal_Bool bUnder = ( CHRDLG_POSITION_UNDER == (sal_uLong)m_pPositionLB->GetEntryData( nPos ) );
    1449           0 :     FontEmphasisMark eMark = (FontEmphasisMark)m_pEmphasisLB->GetSelectEntryPos();
    1450           0 :     eMark |= bUnder ? EMPHASISMARK_POS_BELOW : EMPHASISMARK_POS_ABOVE;
    1451           0 :     rFont.SetEmphasisMark( eMark );
    1452           0 :     rCJKFont.SetEmphasisMark( eMark );
    1453           0 :     rCTLFont.SetEmphasisMark( eMark );
    1454             : 
    1455           0 :     sal_uInt16 nRelief = m_pReliefLB->GetSelectEntryPos();
    1456           0 :     if(LISTBOX_ENTRY_NOTFOUND != nRelief)
    1457             :     {
    1458           0 :         rFont.SetRelief( (FontRelief)nRelief );
    1459           0 :         rCJKFont.SetRelief( (FontRelief)nRelief );
    1460           0 :         rCTLFont.SetRelief( (FontRelief)nRelief );
    1461             :     }
    1462             : 
    1463           0 :     rFont.SetOutline( StateToAttr( m_pOutlineBtn->GetState() ) );
    1464           0 :     rCJKFont.SetOutline( rFont.IsOutline() );
    1465           0 :     rCTLFont.SetOutline( rFont.IsOutline() );
    1466             : 
    1467           0 :     rFont.SetShadow( StateToAttr( m_pShadowBtn->GetState() ) );
    1468           0 :     rCJKFont.SetShadow( rFont.IsShadow() );
    1469           0 :     rCTLFont.SetShadow( rFont.IsShadow() );
    1470             : 
    1471           0 :     sal_uInt16 nCapsPos = m_pEffectsLB->GetSelectEntryPos();
    1472           0 :     if ( nCapsPos != LISTBOX_ENTRY_NOTFOUND )
    1473             :     {
    1474           0 :         rFont.SetCaseMap( (SvxCaseMap)nCapsPos );
    1475           0 :         rCJKFont.SetCaseMap( (SvxCaseMap)nCapsPos );
    1476             :         // #i78474# small caps do not exist in CTL fonts
    1477           0 :         rCTLFont.SetCaseMap( static_cast<SvxCaseMap>( nCapsPos == SVX_CASEMAP_KAPITAELCHEN ? SVX_CASEMAP_NOT_MAPPED : (SvxCaseMap)nCapsPos) );
    1478             :     }
    1479             : 
    1480           0 :     sal_Bool bWordLine = m_pIndividualWordsBtn->IsChecked();
    1481           0 :     rFont.SetWordLineMode( bWordLine );
    1482           0 :     rCJKFont.SetWordLineMode( bWordLine );
    1483           0 :     rCTLFont.SetWordLineMode( bWordLine );
    1484             : 
    1485           0 :     m_pPreviewWin->Invalidate();
    1486           0 : }
    1487             : 
    1488             : // -----------------------------------------------------------------------
    1489             : 
    1490           0 : void SvxCharEffectsPage::SetCaseMap_Impl( SvxCaseMap eCaseMap )
    1491             : {
    1492           0 :     if ( SVX_CASEMAP_END > eCaseMap )
    1493             :         m_pEffectsLB->SelectEntryPos(
    1494           0 :             sal::static_int_cast< sal_uInt16 >( eCaseMap ) );
    1495             :     else
    1496             :     {
    1497           0 :         m_pEffectsLB->SetNoSelection();
    1498           0 :         eCaseMap = SVX_CASEMAP_NOT_MAPPED;
    1499             :     }
    1500             : 
    1501           0 :     UpdatePreview_Impl();
    1502           0 : }
    1503             : 
    1504             : // -----------------------------------------------------------------------
    1505             : 
    1506           0 : void SvxCharEffectsPage::ResetColor_Impl( const SfxItemSet& rSet )
    1507             : {
    1508           0 :     sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_COLOR );
    1509           0 :     SfxItemState eState = rSet.GetItemState( nWhich );
    1510             : 
    1511           0 :     switch ( eState )
    1512             :     {
    1513             :         case SFX_ITEM_UNKNOWN:
    1514           0 :             m_pFontColorFT->Hide();
    1515           0 :             m_pFontColorLB->Hide();
    1516           0 :             break;
    1517             : 
    1518             :         case SFX_ITEM_DISABLED:
    1519             :         case SFX_ITEM_READONLY:
    1520           0 :             m_pFontColorFT->Disable();
    1521           0 :             m_pFontColorLB->Disable();
    1522           0 :             break;
    1523             : 
    1524             :         case SFX_ITEM_DONTCARE:
    1525           0 :             m_pFontColorLB->SetNoSelection();
    1526           0 :             break;
    1527             : 
    1528             :         case SFX_ITEM_DEFAULT:
    1529             :         case SFX_ITEM_SET:
    1530             :         {
    1531           0 :             SvxFont& rFont = GetPreviewFont();
    1532           0 :             SvxFont& rCJKFont = GetPreviewCJKFont();
    1533           0 :             SvxFont& rCTLFont = GetPreviewCTLFont();
    1534             : 
    1535           0 :             const SvxColorItem& rItem = (SvxColorItem&)rSet.Get( nWhich );
    1536           0 :             Color aColor = rItem.GetValue();
    1537           0 :             rFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor );
    1538           0 :             rCJKFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor );
    1539           0 :             rCTLFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor );
    1540             : 
    1541           0 :             m_pPreviewWin->Invalidate();
    1542           0 :             sal_uInt16 nSelPos = m_pFontColorLB->GetEntryPos( aColor );
    1543           0 :             if ( nSelPos == LISTBOX_ENTRY_NOTFOUND && aColor == Color( COL_TRANSPARENT ) )
    1544           0 :                 nSelPos = m_pFontColorLB->GetEntryPos( m_aTransparentColorName );
    1545             : 
    1546           0 :             if ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
    1547           0 :                 m_pFontColorLB->SelectEntryPos( nSelPos );
    1548             :             else
    1549             :             {
    1550           0 :                 nSelPos = m_pFontColorLB->GetEntryPos( aColor );
    1551           0 :                 if ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
    1552           0 :                     m_pFontColorLB->SelectEntryPos( nSelPos );
    1553             :                 else
    1554             :                     m_pFontColorLB->SelectEntryPos(
    1555           0 :                         m_pFontColorLB->InsertEntry( aColor, String( SVX_RES( RID_SVXSTR_COLOR_USER ) ) ) );
    1556             :             }
    1557             :             break;
    1558             :         }
    1559             :     }
    1560           0 : }
    1561             : 
    1562             : // -----------------------------------------------------------------------
    1563             : 
    1564           0 : sal_Bool SvxCharEffectsPage::FillItemSetColor_Impl( SfxItemSet& rSet )
    1565             : {
    1566           0 :     sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_COLOR );
    1567           0 :     const SvxColorItem* pOld = (const SvxColorItem*)GetOldItem( rSet, SID_ATTR_CHAR_COLOR );
    1568           0 :     const SvxColorItem* pItem = NULL;
    1569           0 :     sal_Bool bChanged = sal_True;
    1570           0 :     const SfxItemSet* pExampleSet = GetTabDialog() ? GetTabDialog()->GetExampleSet() : NULL;
    1571           0 :     const SfxItemSet& rOldSet = GetItemSet();
    1572             : 
    1573           0 :     Color aSelectedColor;
    1574           0 :     if ( m_pFontColorLB->GetSelectEntry() == m_aTransparentColorName )
    1575           0 :         aSelectedColor = Color( COL_TRANSPARENT );
    1576             :     else
    1577           0 :         aSelectedColor = m_pFontColorLB->GetSelectEntryColor();
    1578             : 
    1579           0 :     if ( pOld && pOld->GetValue() == aSelectedColor )
    1580           0 :         bChanged = sal_False;
    1581             : 
    1582           0 :     if ( !bChanged )
    1583           0 :         bChanged = ( m_pFontColorLB->GetSavedValue() == LISTBOX_ENTRY_NOTFOUND );
    1584             : 
    1585           0 :     if ( !bChanged && pExampleSet &&
    1586           0 :          pExampleSet->GetItemState( nWhich, sal_False, (const SfxPoolItem**)&pItem ) == SFX_ITEM_SET &&
    1587           0 :          ( (SvxColorItem*)pItem )->GetValue() != aSelectedColor )
    1588           0 :         bChanged = sal_True;
    1589             : 
    1590           0 :     sal_Bool bModified = sal_False;
    1591             : 
    1592           0 :     if ( bChanged && m_pFontColorLB->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
    1593             :     {
    1594           0 :         rSet.Put( SvxColorItem( aSelectedColor, nWhich ) );
    1595           0 :         bModified = sal_True;
    1596             :     }
    1597           0 :     else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
    1598           0 :         CLEARTITEM;
    1599             : 
    1600           0 :     return bModified;
    1601             : }
    1602             : 
    1603             : // -----------------------------------------------------------------------
    1604             : 
    1605           0 : IMPL_LINK( SvxCharEffectsPage, SelectHdl_Impl, ListBox*, pBox )
    1606             : {
    1607           0 :     if ( m_pEmphasisLB == pBox )
    1608             :     {
    1609           0 :         sal_uInt16 nEPos = m_pEmphasisLB->GetSelectEntryPos();
    1610           0 :         sal_Bool bEnable = ( nEPos > 0 && nEPos != LISTBOX_ENTRY_NOTFOUND );
    1611           0 :         m_pPositionFT->Enable( bEnable );
    1612           0 :         m_pPositionLB->Enable( bEnable );
    1613             :     }
    1614           0 :     else if( m_pReliefLB == pBox)
    1615             :     {
    1616           0 :         sal_Bool bEnable = ( pBox->GetSelectEntryPos() == 0 );
    1617           0 :         m_pOutlineBtn->Enable( bEnable );
    1618           0 :         m_pShadowBtn->Enable( bEnable );
    1619             :     }
    1620           0 :     else if ( m_pPositionLB != pBox )
    1621             :     {
    1622           0 :         sal_uInt16 nUPos = m_pUnderlineLB->GetSelectEntryPos(),
    1623           0 :                nOPos = m_pOverlineLB->GetSelectEntryPos(),
    1624           0 :                nSPos = m_pStrikeoutLB->GetSelectEntryPos();
    1625           0 :         sal_Bool bUEnable = ( nUPos > 0 && nUPos != LISTBOX_ENTRY_NOTFOUND );
    1626           0 :         sal_Bool bOEnable = ( nOPos > 0 && nOPos != LISTBOX_ENTRY_NOTFOUND );
    1627           0 :         m_pUnderlineColorFT->Enable( bUEnable );
    1628           0 :         m_pUnderlineColorLB->Enable( bUEnable );
    1629           0 :         m_pOverlineColorFT->Enable( bOEnable );
    1630           0 :         m_pOverlineColorLB->Enable( bOEnable );
    1631           0 :         m_pIndividualWordsBtn->Enable( bUEnable || bOEnable || ( nSPos > 0 && nSPos != LISTBOX_ENTRY_NOTFOUND ) );
    1632             :     }
    1633           0 :     UpdatePreview_Impl();
    1634           0 :     return 0;
    1635             : }
    1636             : 
    1637             : // -----------------------------------------------------------------------
    1638             : 
    1639           0 : IMPL_LINK_NOARG(SvxCharEffectsPage, UpdatePreview_Impl)
    1640             : {
    1641           0 :     bool bEnable = ( ( m_pUnderlineLB->GetSelectEntryPos() > 0 ) ||
    1642           0 :                      ( m_pOverlineLB->GetSelectEntryPos()  > 0 ) ||
    1643           0 :                      ( m_pStrikeoutLB->GetSelectEntryPos() > 0 ) );
    1644           0 :     m_pIndividualWordsBtn->Enable( bEnable );
    1645             : 
    1646           0 :     UpdatePreview_Impl();
    1647           0 :     return 0;
    1648             : }
    1649             : 
    1650             : // -----------------------------------------------------------------------
    1651             : 
    1652           0 : IMPL_LINK_NOARG(SvxCharEffectsPage, CbClickHdl_Impl)
    1653             : {
    1654           0 :     UpdatePreview_Impl();
    1655           0 :     return 0;
    1656             : }
    1657             : 
    1658             : // -----------------------------------------------------------------------
    1659             : 
    1660           0 : IMPL_LINK_NOARG(SvxCharEffectsPage, TristClickHdl_Impl)
    1661             : {
    1662           0 :     UpdatePreview_Impl();
    1663           0 :     return 0;
    1664             : }
    1665             : 
    1666             : // -----------------------------------------------------------------------
    1667             : 
    1668           0 : IMPL_LINK( SvxCharEffectsPage, ColorBoxSelectHdl_Impl, ColorListBox*, pBox )
    1669             : {
    1670           0 :     SvxFont& rFont = GetPreviewFont();
    1671           0 :     SvxFont& rCJKFont = GetPreviewCJKFont();
    1672           0 :     SvxFont& rCTLFont = GetPreviewCTLFont();
    1673             : 
    1674           0 :     Color aSelectedColor;
    1675           0 :     if ( pBox->GetSelectEntry() == m_aTransparentColorName )
    1676           0 :         aSelectedColor = Color( COL_TRANSPARENT );
    1677             :     else
    1678           0 :         aSelectedColor = pBox->GetSelectEntryColor();
    1679           0 :     rFont.SetColor( aSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aSelectedColor );
    1680           0 :     rCJKFont.SetColor( aSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aSelectedColor );
    1681           0 :     rCTLFont.SetColor( aSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aSelectedColor );
    1682             : 
    1683           0 :     m_pPreviewWin->Invalidate();
    1684           0 :     return 0;
    1685             : }
    1686             : // -----------------------------------------------------------------------
    1687             : 
    1688           0 : int SvxCharEffectsPage::DeactivatePage( SfxItemSet* _pSet )
    1689             : {
    1690           0 :     if ( _pSet )
    1691           0 :         FillItemSet( *_pSet );
    1692           0 :     return LEAVE_PAGE;
    1693             : }
    1694             : 
    1695             : // -----------------------------------------------------------------------
    1696             : 
    1697           0 : SfxTabPage* SvxCharEffectsPage::Create( Window* pParent, const SfxItemSet& rSet )
    1698             : {
    1699           0 :     return new SvxCharEffectsPage( pParent, rSet );
    1700             : }
    1701             : 
    1702             : // -----------------------------------------------------------------------
    1703             : 
    1704           0 : sal_uInt16* SvxCharEffectsPage::GetRanges()
    1705             : {
    1706           0 :     return pEffectsRanges;
    1707             : }
    1708             : 
    1709             : // -----------------------------------------------------------------------
    1710             : 
    1711           0 : void SvxCharEffectsPage::Reset( const SfxItemSet& rSet )
    1712             : {
    1713           0 :     SvxFont& rFont = GetPreviewFont();
    1714           0 :     SvxFont& rCJKFont = GetPreviewCJKFont();
    1715           0 :     SvxFont& rCTLFont = GetPreviewCTLFont();
    1716             : 
    1717           0 :     sal_Bool bEnable = sal_False;
    1718             : 
    1719             :     // Underline
    1720           0 :     sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_UNDERLINE );
    1721           0 :     rFont.SetUnderline( UNDERLINE_NONE );
    1722           0 :     rCJKFont.SetUnderline( UNDERLINE_NONE );
    1723           0 :     rCTLFont.SetUnderline( UNDERLINE_NONE );
    1724             : 
    1725           0 :     m_pUnderlineLB->SelectEntryPos( 0 );
    1726           0 :     SfxItemState eState = rSet.GetItemState( nWhich );
    1727             : 
    1728           0 :     if ( eState >= SFX_ITEM_DONTCARE )
    1729             :     {
    1730           0 :         if ( eState == SFX_ITEM_DONTCARE )
    1731           0 :             m_pUnderlineLB->SetNoSelection();
    1732             :         else
    1733             :         {
    1734           0 :             const SvxUnderlineItem& rItem = (SvxUnderlineItem&)rSet.Get( nWhich );
    1735           0 :             FontUnderline eUnderline = (FontUnderline)rItem.GetValue();
    1736           0 :             rFont.SetUnderline( eUnderline );
    1737           0 :             rCJKFont.SetUnderline( eUnderline );
    1738           0 :             rCTLFont.SetUnderline( eUnderline );
    1739             : 
    1740           0 :             if ( eUnderline != UNDERLINE_NONE )
    1741             :             {
    1742           0 :                 for ( sal_uInt16 i = 0; i < m_pUnderlineLB->GetEntryCount(); ++i )
    1743             :                 {
    1744           0 :                     if ( (FontUnderline)(sal_uLong)m_pUnderlineLB->GetEntryData(i) == eUnderline )
    1745             :                     {
    1746           0 :                         m_pUnderlineLB->SelectEntryPos(i);
    1747           0 :                         bEnable = sal_True;
    1748           0 :                         break;
    1749             :                     }
    1750             :                 }
    1751             : 
    1752           0 :                 Color aColor = rItem.GetColor();
    1753           0 :                 sal_uInt16 nPos = m_pUnderlineColorLB->GetEntryPos( aColor );
    1754             : 
    1755           0 :                 if ( LISTBOX_ENTRY_NOTFOUND != nPos )
    1756           0 :                     m_pUnderlineColorLB->SelectEntryPos( nPos );
    1757             :                 else
    1758             :                 {
    1759           0 :                     nPos = m_pUnderlineColorLB->GetEntryPos( aColor );
    1760           0 :                     if ( LISTBOX_ENTRY_NOTFOUND != nPos )
    1761           0 :                         m_pUnderlineColorLB->SelectEntryPos( nPos );
    1762             :                     else
    1763             :                         m_pUnderlineColorLB->SelectEntryPos(
    1764             :                             m_pUnderlineColorLB->InsertEntry( aColor,
    1765           0 :                                 String( SVX_RES( RID_SVXSTR_COLOR_USER ) ) ) );
    1766             :                 }
    1767             :             }
    1768             :             else
    1769             :             {
    1770           0 :                 m_pUnderlineColorLB->SelectEntry( Color( COL_AUTO ));
    1771           0 :                 m_pUnderlineColorLB->Disable();
    1772             :             }
    1773             :         }
    1774             :     }
    1775             : 
    1776             :     // Overline
    1777           0 :     nWhich = GetWhich( SID_ATTR_CHAR_OVERLINE );
    1778           0 :     rFont.SetOverline( UNDERLINE_NONE );
    1779           0 :     rCJKFont.SetOverline( UNDERLINE_NONE );
    1780           0 :     rCTLFont.SetOverline( UNDERLINE_NONE );
    1781             : 
    1782           0 :     m_pOverlineLB->SelectEntryPos( 0 );
    1783           0 :     eState = rSet.GetItemState( nWhich );
    1784             : 
    1785           0 :     if ( eState >= SFX_ITEM_DONTCARE )
    1786             :     {
    1787           0 :         if ( eState == SFX_ITEM_DONTCARE )
    1788           0 :             m_pOverlineLB->SetNoSelection();
    1789             :         else
    1790             :         {
    1791           0 :             const SvxOverlineItem& rItem = (SvxOverlineItem&)rSet.Get( nWhich );
    1792           0 :             FontUnderline eOverline = (FontUnderline)rItem.GetValue();
    1793           0 :             rFont.SetOverline( eOverline );
    1794           0 :             rCJKFont.SetOverline( eOverline );
    1795           0 :             rCTLFont.SetOverline( eOverline );
    1796             : 
    1797           0 :             if ( eOverline != UNDERLINE_NONE )
    1798             :             {
    1799           0 :                 for ( sal_uInt16 i = 0; i < m_pOverlineLB->GetEntryCount(); ++i )
    1800             :                 {
    1801           0 :                     if ( (FontUnderline)(sal_uLong)m_pOverlineLB->GetEntryData(i) == eOverline )
    1802             :                     {
    1803           0 :                         m_pOverlineLB->SelectEntryPos(i);
    1804           0 :                         bEnable = sal_True;
    1805           0 :                         break;
    1806             :                     }
    1807             :                 }
    1808             : 
    1809           0 :                 Color aColor = rItem.GetColor();
    1810           0 :                 sal_uInt16 nPos = m_pOverlineColorLB->GetEntryPos( aColor );
    1811             : 
    1812           0 :                 if ( LISTBOX_ENTRY_NOTFOUND != nPos )
    1813           0 :                     m_pOverlineColorLB->SelectEntryPos( nPos );
    1814             :                 else
    1815             :                 {
    1816           0 :                     nPos = m_pOverlineColorLB->GetEntryPos( aColor );
    1817           0 :                     if ( LISTBOX_ENTRY_NOTFOUND != nPos )
    1818           0 :                         m_pOverlineColorLB->SelectEntryPos( nPos );
    1819             :                     else
    1820             :                         m_pOverlineColorLB->SelectEntryPos(
    1821             :                             m_pOverlineColorLB->InsertEntry( aColor,
    1822           0 :                                 String( SVX_RES( RID_SVXSTR_COLOR_USER ) ) ) );
    1823             :                 }
    1824             :             }
    1825             :             else
    1826             :             {
    1827           0 :                 m_pOverlineColorLB->SelectEntry( Color( COL_AUTO ));
    1828           0 :                 m_pOverlineColorLB->Disable();
    1829             :             }
    1830             :         }
    1831             :     }
    1832             : 
    1833             :     //  Strikeout
    1834           0 :     nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT );
    1835           0 :     rFont.SetStrikeout( STRIKEOUT_NONE );
    1836           0 :     rCJKFont.SetStrikeout( STRIKEOUT_NONE );
    1837           0 :     rCTLFont.SetStrikeout( STRIKEOUT_NONE );
    1838             : 
    1839           0 :     m_pStrikeoutLB->SelectEntryPos( 0 );
    1840           0 :     eState = rSet.GetItemState( nWhich );
    1841             : 
    1842           0 :     if ( eState >= SFX_ITEM_DONTCARE )
    1843             :     {
    1844           0 :         if ( eState == SFX_ITEM_DONTCARE )
    1845           0 :             m_pStrikeoutLB->SetNoSelection();
    1846             :         else
    1847             :         {
    1848           0 :             const SvxCrossedOutItem& rItem = (SvxCrossedOutItem&)rSet.Get( nWhich );
    1849           0 :             FontStrikeout eStrikeout = (FontStrikeout)rItem.GetValue();
    1850           0 :             rFont.SetStrikeout( eStrikeout );
    1851           0 :             rCJKFont.SetStrikeout( eStrikeout );
    1852           0 :             rCTLFont.SetStrikeout( eStrikeout );
    1853             : 
    1854           0 :             if ( eStrikeout != STRIKEOUT_NONE )
    1855             :             {
    1856           0 :                 for ( sal_uInt16 i = 0; i < m_pStrikeoutLB->GetEntryCount(); ++i )
    1857             :                 {
    1858           0 :                     if ( (FontStrikeout)(sal_uLong)m_pStrikeoutLB->GetEntryData(i) == eStrikeout )
    1859             :                     {
    1860           0 :                         m_pStrikeoutLB->SelectEntryPos(i);
    1861           0 :                         bEnable = sal_True;
    1862           0 :                         break;
    1863             :                     }
    1864             :                 }
    1865             :             }
    1866             :         }
    1867             :     }
    1868             : 
    1869             :     // WordLineMode
    1870           0 :     nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
    1871           0 :     switch ( eState )
    1872             :     {
    1873             :         case SFX_ITEM_UNKNOWN:
    1874           0 :             m_pIndividualWordsBtn->Hide();
    1875           0 :             break;
    1876             : 
    1877             :         case SFX_ITEM_DISABLED:
    1878             :         case SFX_ITEM_READONLY:
    1879           0 :             m_pIndividualWordsBtn->Disable();
    1880           0 :             break;
    1881             : 
    1882             :         case SFX_ITEM_DONTCARE:
    1883           0 :             m_pIndividualWordsBtn->SetState( STATE_DONTKNOW );
    1884           0 :             break;
    1885             : 
    1886             :         case SFX_ITEM_DEFAULT:
    1887             :         case SFX_ITEM_SET:
    1888             :         {
    1889           0 :             const SvxWordLineModeItem& rItem = (SvxWordLineModeItem&)rSet.Get( nWhich );
    1890           0 :             rFont.SetWordLineMode( rItem.GetValue() );
    1891           0 :             rCJKFont.SetWordLineMode( rItem.GetValue() );
    1892           0 :             rCTLFont.SetWordLineMode( rItem.GetValue() );
    1893             : 
    1894           0 :             m_pIndividualWordsBtn->Check( rItem.GetValue() );
    1895           0 :             m_pIndividualWordsBtn->Enable( bEnable );
    1896           0 :             break;
    1897             :         }
    1898             :     }
    1899             : 
    1900             :     // Emphasis
    1901           0 :     nWhich = GetWhich( SID_ATTR_CHAR_EMPHASISMARK );
    1902           0 :     eState = rSet.GetItemState( nWhich );
    1903             : 
    1904           0 :     if ( eState >= SFX_ITEM_DEFAULT )
    1905             :     {
    1906           0 :         const SvxEmphasisMarkItem& rItem = (SvxEmphasisMarkItem&)rSet.Get( nWhich );
    1907           0 :         FontEmphasisMark eMark = rItem.GetEmphasisMark();
    1908           0 :         rFont.SetEmphasisMark( eMark );
    1909           0 :         rCJKFont.SetEmphasisMark( eMark );
    1910           0 :         rCTLFont.SetEmphasisMark( eMark );
    1911             : 
    1912           0 :         m_pEmphasisLB->SelectEntryPos( (sal_uInt16)( eMark & EMPHASISMARK_STYLE ) );
    1913           0 :         eMark &= ~EMPHASISMARK_STYLE;
    1914             :         sal_uLong nEntryData = ( eMark == EMPHASISMARK_POS_ABOVE )
    1915             :             ? CHRDLG_POSITION_OVER
    1916           0 :             : ( eMark == EMPHASISMARK_POS_BELOW ) ? CHRDLG_POSITION_UNDER : 0;
    1917             : 
    1918           0 :         for ( sal_uInt16 i = 0; i < m_pPositionLB->GetEntryCount(); i++ )
    1919             :         {
    1920           0 :             if ( nEntryData == (sal_uLong)m_pPositionLB->GetEntryData(i) )
    1921             :             {
    1922           0 :                 m_pPositionLB->SelectEntryPos(i);
    1923           0 :                 break;
    1924             :             }
    1925             :         }
    1926             :     }
    1927           0 :     else if ( eState == SFX_ITEM_DONTCARE )
    1928           0 :         m_pEmphasisLB->SetNoSelection( );
    1929           0 :     else if ( eState == SFX_ITEM_UNKNOWN )
    1930             :     {
    1931           0 :         m_pEmphasisFT->Hide();
    1932           0 :         m_pEmphasisLB->Hide();
    1933             :     }
    1934             :     else // SFX_ITEM_DISABLED or SFX_ITEM_READONLY
    1935             :     {
    1936           0 :         m_pEmphasisFT->Disable();
    1937           0 :         m_pEmphasisLB->Disable();
    1938             :     }
    1939             : 
    1940             :     // the select handler for the underline/overline/strikeout list boxes
    1941             : //  SelectHdl_Impl( NULL );
    1942             :     DBG_ASSERT(m_pUnderlineLB->GetSelectHdl() == m_pOverlineLB->GetSelectHdl(),
    1943             :         "SvxCharEffectsPage::Reset: inconsistence (1)!");
    1944             :     DBG_ASSERT(m_pUnderlineLB->GetSelectHdl() == m_pStrikeoutLB->GetSelectHdl(),
    1945             :         "SvxCharEffectsPage::Reset: inconsistence (1)!");
    1946           0 :     m_pUnderlineLB->GetSelectHdl().Call(NULL);
    1947             :         // don't call SelectHdl_Impl directly!
    1948             :         // in DisableControls, we may have re-reouted the select handler
    1949             : 
    1950             :     // the select handler for the emphasis listbox
    1951             : //  SelectHdl_Impl( m_pEmphasisLB );
    1952             :     DBG_ASSERT(m_pEmphasisLB->GetSelectHdl() == LINK(this, SvxCharEffectsPage, SelectHdl_Impl),
    1953             :         "SvxCharEffectsPage::Reset: inconsistence (2)!");
    1954           0 :     m_pEmphasisLB->GetSelectHdl().Call( m_pEmphasisLB );
    1955             :         // this is for consistency only. Here it would be allowed to call SelectHdl_Impl directly ...
    1956             : 
    1957             :     // Effects
    1958           0 :     SvxCaseMap eCaseMap = SVX_CASEMAP_END;
    1959           0 :     nWhich = GetWhich( SID_ATTR_CHAR_CASEMAP );
    1960           0 :     eState = rSet.GetItemState( nWhich );
    1961           0 :     switch ( eState )
    1962             :     {
    1963             :         case SFX_ITEM_UNKNOWN:
    1964           0 :             m_pEffectsFT->Hide();
    1965           0 :             m_pEffectsLB->Hide();
    1966           0 :             break;
    1967             : 
    1968             :         case SFX_ITEM_DISABLED:
    1969             :         case SFX_ITEM_READONLY:
    1970           0 :             m_pEffectsFT->Disable();
    1971           0 :             m_pEffectsLB->Disable();
    1972           0 :             break;
    1973             : 
    1974             :         case SFX_ITEM_DONTCARE:
    1975           0 :             m_pEffectsLB->SetNoSelection();
    1976           0 :             break;
    1977             : 
    1978             :         case SFX_ITEM_DEFAULT:
    1979             :         case SFX_ITEM_SET:
    1980             :         {
    1981           0 :             const SvxCaseMapItem& rItem = (const SvxCaseMapItem&)rSet.Get( nWhich );
    1982           0 :             eCaseMap = (SvxCaseMap)rItem.GetValue();
    1983           0 :             break;
    1984             :         }
    1985             :     }
    1986           0 :     SetCaseMap_Impl( eCaseMap );
    1987             : 
    1988             :     //Relief
    1989           0 :     nWhich = GetWhich(SID_ATTR_CHAR_RELIEF);
    1990           0 :     eState = rSet.GetItemState( nWhich );
    1991           0 :     switch ( eState )
    1992             :     {
    1993             :         case SFX_ITEM_UNKNOWN:
    1994           0 :             m_pReliefFT->Hide();
    1995           0 :             m_pReliefLB->Hide();
    1996           0 :             break;
    1997             : 
    1998             :         case SFX_ITEM_DISABLED:
    1999             :         case SFX_ITEM_READONLY:
    2000           0 :             m_pReliefFT->Disable();
    2001           0 :             m_pReliefLB->Disable();
    2002           0 :             break;
    2003             : 
    2004             :         case SFX_ITEM_DONTCARE:
    2005           0 :             m_pReliefLB->SetNoSelection();
    2006           0 :             break;
    2007             : 
    2008             :         case SFX_ITEM_DEFAULT:
    2009             :         case SFX_ITEM_SET:
    2010             :         {
    2011           0 :             const SvxCharReliefItem& rItem = (const SvxCharReliefItem&)rSet.Get( nWhich );
    2012           0 :             m_pReliefLB->SelectEntryPos(rItem.GetValue());
    2013           0 :             SelectHdl_Impl(m_pReliefLB);
    2014           0 :             break;
    2015             :         }
    2016             :     }
    2017             : 
    2018             :     // Outline
    2019           0 :     nWhich = GetWhich( SID_ATTR_CHAR_CONTOUR );
    2020           0 :     eState = rSet.GetItemState( nWhich );
    2021           0 :     switch ( eState )
    2022             :     {
    2023             :         case SFX_ITEM_UNKNOWN:
    2024           0 :             m_pOutlineBtn->Hide();
    2025           0 :             break;
    2026             : 
    2027             :         case SFX_ITEM_DISABLED:
    2028             :         case SFX_ITEM_READONLY:
    2029           0 :             m_pOutlineBtn->Disable();
    2030           0 :             break;
    2031             : 
    2032             :         case SFX_ITEM_DONTCARE:
    2033           0 :             m_pOutlineBtn->SetState( STATE_DONTKNOW );
    2034           0 :             break;
    2035             : 
    2036             :         case SFX_ITEM_DEFAULT:
    2037             :         case SFX_ITEM_SET:
    2038             :         {
    2039           0 :             const SvxContourItem& rItem = (SvxContourItem&)rSet.Get( nWhich );
    2040           0 :             m_pOutlineBtn->SetState( (TriState)rItem.GetValue() );
    2041           0 :             m_pOutlineBtn->EnableTriState( sal_False );
    2042           0 :             break;
    2043             :         }
    2044             :     }
    2045             : 
    2046             :     // Shadow
    2047           0 :     nWhich = GetWhich( SID_ATTR_CHAR_SHADOWED );
    2048           0 :     eState = rSet.GetItemState( nWhich );
    2049             : 
    2050           0 :     switch ( eState )
    2051             :     {
    2052             :         case SFX_ITEM_UNKNOWN:
    2053           0 :             m_pShadowBtn->Hide();
    2054           0 :             break;
    2055             : 
    2056             :         case SFX_ITEM_DISABLED:
    2057             :         case SFX_ITEM_READONLY:
    2058           0 :             m_pShadowBtn->Disable();
    2059           0 :             break;
    2060             : 
    2061             :         case SFX_ITEM_DONTCARE:
    2062           0 :             m_pShadowBtn->SetState( STATE_DONTKNOW );
    2063           0 :             break;
    2064             : 
    2065             :         case SFX_ITEM_DEFAULT:
    2066             :         case SFX_ITEM_SET:
    2067             :         {
    2068           0 :             const SvxShadowedItem& rItem = (SvxShadowedItem&)rSet.Get( nWhich );
    2069           0 :             m_pShadowBtn->SetState( (TriState)rItem.GetValue() );
    2070           0 :             m_pShadowBtn->EnableTriState( sal_False );
    2071           0 :             break;
    2072             :         }
    2073             :     }
    2074             : 
    2075             :     // Blinking
    2076           0 :     nWhich = GetWhich( SID_ATTR_FLASH );
    2077           0 :     eState = rSet.GetItemState( nWhich );
    2078             : 
    2079           0 :     switch ( eState )
    2080             :     {
    2081             :         case SFX_ITEM_UNKNOWN:
    2082           0 :             m_pBlinkingBtn->Hide();
    2083           0 :             break;
    2084             : 
    2085             :         case SFX_ITEM_DISABLED:
    2086             :         case SFX_ITEM_READONLY:
    2087           0 :             m_pBlinkingBtn->Disable();
    2088           0 :             break;
    2089             : 
    2090             :         case SFX_ITEM_DONTCARE:
    2091           0 :             m_pBlinkingBtn->SetState( STATE_DONTKNOW );
    2092           0 :             break;
    2093             : 
    2094             :         case SFX_ITEM_DEFAULT:
    2095             :         case SFX_ITEM_SET:
    2096             :         {
    2097           0 :             const SvxBlinkItem& rItem = (SvxBlinkItem&)rSet.Get( nWhich );
    2098           0 :             m_pBlinkingBtn->SetState( (TriState)rItem.GetValue() );
    2099           0 :             m_pBlinkingBtn->EnableTriState( sal_False );
    2100           0 :             break;
    2101             :         }
    2102             :     }
    2103             :     // Hidden
    2104           0 :     nWhich = GetWhich( SID_ATTR_CHAR_HIDDEN );
    2105           0 :     eState = rSet.GetItemState( nWhich );
    2106             : 
    2107           0 :     switch ( eState )
    2108             :     {
    2109             :         case SFX_ITEM_UNKNOWN:
    2110           0 :             m_pHiddenBtn->Hide();
    2111           0 :             break;
    2112             : 
    2113             :         case SFX_ITEM_DISABLED:
    2114             :         case SFX_ITEM_READONLY:
    2115           0 :             m_pHiddenBtn->Disable();
    2116           0 :             break;
    2117             : 
    2118             :         case SFX_ITEM_DONTCARE:
    2119           0 :             m_pHiddenBtn->SetState( STATE_DONTKNOW );
    2120           0 :             break;
    2121             : 
    2122             :         case SFX_ITEM_DEFAULT:
    2123             :         case SFX_ITEM_SET:
    2124             :         {
    2125           0 :             const SvxCharHiddenItem& rItem = (SvxCharHiddenItem&)rSet.Get( nWhich );
    2126           0 :             m_pHiddenBtn->SetState( (TriState)rItem.GetValue() );
    2127           0 :             m_pHiddenBtn->EnableTriState( sal_False );
    2128           0 :             break;
    2129             :         }
    2130             :     }
    2131             : 
    2132           0 :     SetPrevFontWidthScale( rSet );
    2133           0 :     ResetColor_Impl( rSet );
    2134             : 
    2135             :     // preview update
    2136           0 :     m_pPreviewWin->Invalidate();
    2137             : 
    2138             :     // save this settings
    2139           0 :     m_pUnderlineLB->SaveValue();
    2140           0 :     m_pUnderlineColorLB->SaveValue();
    2141           0 :     m_pOverlineLB->SaveValue();
    2142           0 :     m_pOverlineColorLB->SaveValue();
    2143           0 :     m_pStrikeoutLB->SaveValue();
    2144           0 :     m_pIndividualWordsBtn->SaveValue();
    2145           0 :     m_pEmphasisLB->SaveValue();
    2146           0 :     m_pPositionLB->SaveValue();
    2147           0 :     m_pEffectsLB->SaveValue();
    2148           0 :     m_pReliefLB->SaveValue();
    2149           0 :     m_pOutlineBtn->SaveValue();
    2150           0 :     m_pShadowBtn->SaveValue();
    2151           0 :     m_pBlinkingBtn->SaveValue();
    2152           0 :     m_pHiddenBtn->SaveValue();
    2153           0 :     m_pFontColorLB->SaveValue();
    2154           0 : }
    2155             : 
    2156             : // -----------------------------------------------------------------------
    2157             : 
    2158           0 : sal_Bool SvxCharEffectsPage::FillItemSet( SfxItemSet& rSet )
    2159             : {
    2160           0 :     const SfxPoolItem* pOld = 0;
    2161           0 :     const SfxItemSet& rOldSet = GetItemSet();
    2162           0 :     sal_Bool bModified = sal_False;
    2163           0 :     bool bChanged = true;
    2164             : 
    2165             :     // Underline
    2166           0 :     sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_UNDERLINE );
    2167           0 :     pOld = GetOldItem( rSet, SID_ATTR_CHAR_UNDERLINE );
    2168           0 :     sal_uInt16 nPos = m_pUnderlineLB->GetSelectEntryPos();
    2169           0 :     FontUnderline eUnder = (FontUnderline)(sal_uLong)m_pUnderlineLB->GetEntryData( nPos );
    2170             : 
    2171           0 :     if ( pOld )
    2172             :     {
    2173             :         //! if there are different underline styles in the selection the
    2174             :         //! item-state in the 'rOldSet' will be invalid. In this case
    2175             :         //! changing the underline style will be allowed if a style is
    2176             :         //! selected in the listbox.
    2177             :         sal_Bool bAllowChg = LISTBOX_ENTRY_NOTFOUND != nPos  &&
    2178           0 :                          SFX_ITEM_DEFAULT > rOldSet.GetItemState( nWhich, sal_True );
    2179             : 
    2180           0 :         const SvxUnderlineItem& rItem = *( (const SvxUnderlineItem*)pOld );
    2181           0 :         if ( (FontUnderline)rItem.GetValue() == eUnder &&
    2182           0 :              ( UNDERLINE_NONE == eUnder || rItem.GetColor() == m_pUnderlineColorLB->GetSelectEntryColor() ) &&
    2183             :              ! bAllowChg )
    2184           0 :             bChanged = false;
    2185             :     }
    2186             : 
    2187           0 :     if ( bChanged )
    2188             :     {
    2189           0 :         SvxUnderlineItem aNewItem( eUnder, nWhich );
    2190           0 :         aNewItem.SetColor( m_pUnderlineColorLB->GetSelectEntryColor() );
    2191           0 :         rSet.Put( aNewItem );
    2192           0 :         bModified = sal_True;
    2193             :     }
    2194           0 :      else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
    2195           0 :         CLEARTITEM;
    2196             : 
    2197           0 :     bChanged = true;
    2198             : 
    2199             :     // Overline
    2200           0 :     nWhich = GetWhich( SID_ATTR_CHAR_OVERLINE );
    2201           0 :     pOld = GetOldItem( rSet, SID_ATTR_CHAR_OVERLINE );
    2202           0 :     nPos = m_pOverlineLB->GetSelectEntryPos();
    2203           0 :     FontUnderline eOver = (FontUnderline)(sal_uLong)m_pOverlineLB->GetEntryData( nPos );
    2204             : 
    2205           0 :     if ( pOld )
    2206             :     {
    2207             :         //! if there are different underline styles in the selection the
    2208             :         //! item-state in the 'rOldSet' will be invalid. In this case
    2209             :         //! changing the underline style will be allowed if a style is
    2210             :         //! selected in the listbox.
    2211             :         sal_Bool bAllowChg = LISTBOX_ENTRY_NOTFOUND != nPos  &&
    2212           0 :                          SFX_ITEM_DEFAULT > rOldSet.GetItemState( nWhich, sal_True );
    2213             : 
    2214           0 :         const SvxOverlineItem& rItem = *( (const SvxOverlineItem*)pOld );
    2215           0 :         if ( (FontUnderline)rItem.GetValue() == eOver &&
    2216           0 :              ( UNDERLINE_NONE == eOver || rItem.GetColor() == m_pOverlineColorLB->GetSelectEntryColor() ) &&
    2217             :              ! bAllowChg )
    2218           0 :             bChanged = false;
    2219             :     }
    2220             : 
    2221           0 :     if ( bChanged )
    2222             :     {
    2223           0 :         SvxOverlineItem aNewItem( eOver, nWhich );
    2224           0 :         aNewItem.SetColor( m_pOverlineColorLB->GetSelectEntryColor() );
    2225           0 :         rSet.Put( aNewItem );
    2226           0 :         bModified = sal_True;
    2227             :     }
    2228           0 :      else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
    2229           0 :         CLEARTITEM;
    2230             : 
    2231           0 :     bChanged = true;
    2232             : 
    2233             :     // Strikeout
    2234           0 :     nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT );
    2235           0 :     pOld = GetOldItem( rSet, SID_ATTR_CHAR_STRIKEOUT );
    2236           0 :     nPos = m_pStrikeoutLB->GetSelectEntryPos();
    2237           0 :     FontStrikeout eStrike = (FontStrikeout)(sal_uLong)m_pStrikeoutLB->GetEntryData( nPos );
    2238             : 
    2239           0 :     if ( pOld )
    2240             :     {
    2241             :         //! if there are different strikeout styles in the selection the
    2242             :         //! item-state in the 'rOldSet' will be invalid. In this case
    2243             :         //! changing the strikeout style will be allowed if a style is
    2244             :         //! selected in the listbox.
    2245             :         sal_Bool bAllowChg = LISTBOX_ENTRY_NOTFOUND != nPos  &&
    2246           0 :                          SFX_ITEM_DEFAULT > rOldSet.GetItemState( nWhich, sal_True );
    2247             : 
    2248           0 :         const SvxCrossedOutItem& rItem = *( (const SvxCrossedOutItem*)pOld );
    2249           0 :         if ( !m_pStrikeoutLB->IsEnabled()
    2250           0 :             || ((FontStrikeout)rItem.GetValue() == eStrike  && !bAllowChg) )
    2251           0 :             bChanged = false;
    2252             :     }
    2253             : 
    2254           0 :     if ( bChanged )
    2255             :     {
    2256           0 :         rSet.Put( SvxCrossedOutItem( eStrike, nWhich ) );
    2257           0 :         bModified = sal_True;
    2258             :     }
    2259           0 :     else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
    2260           0 :         CLEARTITEM;
    2261             : 
    2262           0 :     bChanged = true;
    2263             : 
    2264             :     // Individual words
    2265           0 :     nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
    2266           0 :     pOld = GetOldItem( rSet, SID_ATTR_CHAR_WORDLINEMODE );
    2267             : 
    2268           0 :     if ( pOld )
    2269             :     {
    2270           0 :         const SvxWordLineModeItem& rItem = *( (const SvxWordLineModeItem*)pOld );
    2271           0 :         if ( rItem.GetValue() == m_pIndividualWordsBtn->IsChecked() )
    2272           0 :             bChanged = false;
    2273             :     }
    2274             : 
    2275           0 :     if ( rOldSet.GetItemState( nWhich ) == SFX_ITEM_DONTCARE &&
    2276           0 :          m_pIndividualWordsBtn->IsChecked() == m_pIndividualWordsBtn->GetSavedValue() )
    2277           0 :         bChanged = false;
    2278             : 
    2279           0 :     if ( bChanged )
    2280             :     {
    2281           0 :         rSet.Put( SvxWordLineModeItem( m_pIndividualWordsBtn->IsChecked(), nWhich ) );
    2282           0 :         bModified = sal_True;
    2283             :     }
    2284           0 :     else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
    2285           0 :         CLEARTITEM;
    2286             : 
    2287           0 :     bChanged = true;
    2288             : 
    2289             :     // Emphasis
    2290           0 :     nWhich = GetWhich( SID_ATTR_CHAR_EMPHASISMARK );
    2291           0 :     pOld = GetOldItem( rSet, SID_ATTR_CHAR_EMPHASISMARK );
    2292           0 :     sal_uInt16 nMarkPos = m_pEmphasisLB->GetSelectEntryPos();
    2293           0 :     sal_uInt16 nPosPos = m_pPositionLB->GetSelectEntryPos();
    2294           0 :     FontEmphasisMark eMark = (FontEmphasisMark)nMarkPos;
    2295           0 :     if ( m_pPositionLB->IsEnabled() )
    2296             :     {
    2297           0 :         eMark |= ( CHRDLG_POSITION_UNDER == (sal_uLong)m_pPositionLB->GetEntryData( nPosPos ) )
    2298           0 :             ? EMPHASISMARK_POS_BELOW : EMPHASISMARK_POS_ABOVE;
    2299             :     }
    2300             : 
    2301           0 :     if ( pOld )
    2302             :     {
    2303           0 :         if( rOldSet.GetItemState( nWhich ) != SFX_ITEM_DONTCARE )
    2304             :         {
    2305           0 :             const SvxEmphasisMarkItem& rItem = *( (const SvxEmphasisMarkItem*)pOld );
    2306           0 :             if ( rItem.GetEmphasisMark() == eMark )
    2307           0 :                 bChanged = false;
    2308             :         }
    2309             :     }
    2310             : 
    2311           0 :     if ( rOldSet.GetItemState( nWhich ) == SFX_ITEM_DONTCARE &&
    2312           0 :          m_pEmphasisLB->GetSavedValue() == nMarkPos && m_pPositionLB->GetSavedValue() == nPosPos )
    2313           0 :         bChanged = false;
    2314             : 
    2315           0 :     if ( bChanged )
    2316             :     {
    2317           0 :         rSet.Put( SvxEmphasisMarkItem( eMark, nWhich ) );
    2318           0 :         bModified = sal_True;
    2319             :     }
    2320           0 :     else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
    2321           0 :         CLEARTITEM;
    2322             : 
    2323           0 :     bChanged = true;
    2324             : 
    2325             :     // Effects
    2326           0 :     nWhich = GetWhich( SID_ATTR_CHAR_CASEMAP );
    2327           0 :     pOld = GetOldItem( rSet, SID_ATTR_CHAR_CASEMAP );
    2328           0 :     SvxCaseMap eCaseMap = SVX_CASEMAP_NOT_MAPPED;
    2329           0 :     bool bChecked = false;
    2330           0 :     sal_uInt16 nCapsPos = m_pEffectsLB->GetSelectEntryPos();
    2331           0 :     if ( nCapsPos != LISTBOX_ENTRY_NOTFOUND )
    2332             :     {
    2333           0 :         eCaseMap = (SvxCaseMap)nCapsPos;
    2334           0 :         bChecked = true;
    2335             :     }
    2336             : 
    2337           0 :     if ( pOld )
    2338             :     {
    2339             :         //! if there are different effect styles in the selection the
    2340             :         //! item-state in the 'rOldSet' will be invalid. In this case
    2341             :         //! changing the effect style will be allowed if a style is
    2342             :         //! selected in the listbox.
    2343             :         sal_Bool bAllowChg = LISTBOX_ENTRY_NOTFOUND != nPos  &&
    2344           0 :                          SFX_ITEM_DEFAULT > rOldSet.GetItemState( nWhich, sal_True );
    2345             : 
    2346           0 :         const SvxCaseMapItem& rItem = *( (const SvxCaseMapItem*)pOld );
    2347           0 :         if ( (SvxCaseMap)rItem.GetValue() == eCaseMap  &&  !bAllowChg )
    2348           0 :             bChanged = false;
    2349             :     }
    2350             : 
    2351           0 :     if ( bChanged && bChecked )
    2352             :     {
    2353           0 :         rSet.Put( SvxCaseMapItem( eCaseMap, nWhich ) );
    2354           0 :         bModified = sal_True;
    2355             :     }
    2356           0 :     else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
    2357           0 :         CLEARTITEM;
    2358             : 
    2359           0 :     bChanged = true;
    2360             : 
    2361             :     //Relief
    2362           0 :     nWhich = GetWhich(SID_ATTR_CHAR_RELIEF);
    2363           0 :     if(m_pReliefLB->GetSelectEntryPos() != m_pReliefLB->GetSavedValue())
    2364             :     {
    2365           0 :         m_pReliefLB->SaveValue();
    2366           0 :         SvxCharReliefItem aRelief((FontRelief)m_pReliefLB->GetSelectEntryPos(), nWhich);
    2367           0 :         rSet.Put(aRelief);
    2368             :     }
    2369             : 
    2370             :     // Outline
    2371           0 :     const SfxItemSet* pExampleSet = GetTabDialog() ? GetTabDialog()->GetExampleSet() : NULL;
    2372           0 :     nWhich = GetWhich( SID_ATTR_CHAR_CONTOUR );
    2373           0 :     pOld = GetOldItem( rSet, SID_ATTR_CHAR_CONTOUR );
    2374           0 :     TriState eState = m_pOutlineBtn->GetState();
    2375             :     const SfxPoolItem* pItem;
    2376             : 
    2377           0 :     if ( pOld )
    2378             :     {
    2379           0 :         const SvxContourItem& rItem = *( (const SvxContourItem*)pOld );
    2380           0 :         if ( rItem.GetValue() == StateToAttr( eState ) && m_pOutlineBtn->GetSavedValue() == eState )
    2381           0 :             bChanged = false;
    2382             :     }
    2383             : 
    2384           0 :     if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET &&
    2385           0 :          !StateToAttr( eState ) && ( (SvxContourItem*)pItem )->GetValue() )
    2386           0 :         bChanged = true;
    2387             : 
    2388           0 :     if ( bChanged && eState != STATE_DONTKNOW )
    2389             :     {
    2390           0 :         rSet.Put( SvxContourItem( StateToAttr( eState ), nWhich ) );
    2391           0 :         bModified = sal_True;
    2392             :     }
    2393           0 :     else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
    2394           0 :         CLEARTITEM;
    2395             : 
    2396           0 :     bChanged = true;
    2397             : 
    2398             :     // Shadow
    2399           0 :     nWhich = GetWhich( SID_ATTR_CHAR_SHADOWED );
    2400           0 :     pOld = GetOldItem( rSet, SID_ATTR_CHAR_SHADOWED );
    2401           0 :     eState = m_pShadowBtn->GetState();
    2402             : 
    2403           0 :     if ( pOld )
    2404             :     {
    2405           0 :         const SvxShadowedItem& rItem = *( (const SvxShadowedItem*)pOld );
    2406           0 :         if ( rItem.GetValue() == StateToAttr( eState ) && m_pShadowBtn->GetSavedValue() == eState )
    2407           0 :             bChanged = false;
    2408             :     }
    2409             : 
    2410           0 :     if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET &&
    2411           0 :          !StateToAttr( eState ) && ( (SvxShadowedItem*)pItem )->GetValue() )
    2412           0 :         bChanged = true;
    2413             : 
    2414           0 :     if ( bChanged && eState != STATE_DONTKNOW )
    2415             :     {
    2416           0 :         rSet.Put( SvxShadowedItem( StateToAttr( eState ), nWhich ) );
    2417           0 :         bModified = sal_True;
    2418             :     }
    2419           0 :     else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
    2420           0 :         CLEARTITEM;
    2421             : 
    2422           0 :     bChanged = true;
    2423             : 
    2424             :     // Blinking
    2425           0 :     nWhich = GetWhich( SID_ATTR_FLASH );
    2426           0 :     pOld = GetOldItem( rSet, SID_ATTR_FLASH );
    2427           0 :     eState = m_pBlinkingBtn->GetState();
    2428             : 
    2429           0 :     if ( pOld )
    2430             :     {
    2431           0 :         const SvxBlinkItem& rItem = *( (const SvxBlinkItem*)pOld );
    2432           0 :         if ( rItem.GetValue() == StateToAttr( eState ) && m_pBlinkingBtn->GetSavedValue() == eState )
    2433           0 :             bChanged = false;
    2434             :     }
    2435             : 
    2436           0 :     if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET &&
    2437           0 :          !StateToAttr( eState ) && ( (SvxBlinkItem*)pItem )->GetValue() )
    2438           0 :         bChanged = true;
    2439             : 
    2440           0 :     if ( bChanged && eState != STATE_DONTKNOW )
    2441             :     {
    2442           0 :         rSet.Put( SvxBlinkItem( StateToAttr( eState ), nWhich ) );
    2443           0 :         bModified = true;
    2444             :     }
    2445           0 :     else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
    2446           0 :         CLEARTITEM;
    2447             : 
    2448             :     // Hidden
    2449           0 :     nWhich = GetWhich( SID_ATTR_CHAR_HIDDEN );
    2450           0 :     pOld = GetOldItem( rSet, SID_ATTR_CHAR_HIDDEN );
    2451           0 :     eState = m_pHiddenBtn->GetState();
    2452           0 :     bChanged = true;
    2453             : 
    2454           0 :     if ( pOld )
    2455             :     {
    2456           0 :         const SvxCharHiddenItem& rItem = *( (const SvxCharHiddenItem*)pOld );
    2457           0 :         if ( rItem.GetValue() == StateToAttr( eState ) && m_pHiddenBtn->GetSavedValue() == eState )
    2458           0 :             bChanged = false;
    2459             :     }
    2460             : 
    2461           0 :     if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET &&
    2462           0 :          !StateToAttr( eState ) && ( (SvxCharHiddenItem*)pItem )->GetValue() )
    2463           0 :         bChanged = true;
    2464             : 
    2465           0 :     if ( bChanged && eState != STATE_DONTKNOW )
    2466             :     {
    2467           0 :         rSet.Put( SvxCharHiddenItem( StateToAttr( eState ), nWhich ) );
    2468           0 :         bModified = sal_True;
    2469             :     }
    2470           0 :     else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
    2471           0 :         CLEARTITEM;
    2472             : 
    2473           0 :     bModified |= FillItemSetColor_Impl( rSet );
    2474             : 
    2475           0 :     return bModified;
    2476             : }
    2477             : 
    2478           0 : void SvxCharEffectsPage::DisableControls( sal_uInt16 nDisable )
    2479             : {
    2480           0 :     if ( ( DISABLE_CASEMAP & nDisable ) == DISABLE_CASEMAP )
    2481             :     {
    2482           0 :         m_pEffectsFT->Disable();
    2483           0 :         m_pEffectsLB->Disable();
    2484             :     }
    2485             : 
    2486           0 :     if ( ( DISABLE_WORDLINE & nDisable ) == DISABLE_WORDLINE )
    2487           0 :         m_pIndividualWordsBtn->Disable();
    2488             : 
    2489           0 :     if ( ( DISABLE_BLINK & nDisable ) == DISABLE_BLINK )
    2490           0 :         m_pBlinkingBtn->Disable();
    2491             : 
    2492           0 :     if ( ( DISABLE_UNDERLINE_COLOR & nDisable ) == DISABLE_UNDERLINE_COLOR )
    2493             :     {
    2494             :         // disable the controls
    2495           0 :         m_pUnderlineColorFT->Disable( );
    2496           0 :         m_pUnderlineColorLB->Disable( );
    2497             :         // and reroute the selection handler of the controls which normally would affect the color box dis-/enabling
    2498           0 :         m_pUnderlineLB->SetSelectHdl(LINK(this, SvxCharEffectsPage, UpdatePreview_Impl));
    2499           0 :         m_pStrikeoutLB->SetSelectHdl(LINK(this, SvxCharEffectsPage, UpdatePreview_Impl));
    2500             :     }
    2501           0 : }
    2502             : 
    2503           0 : void SvxCharEffectsPage::EnableFlash()
    2504             : {
    2505           0 :     m_pBlinkingBtn->Show();
    2506           0 : }
    2507             : 
    2508             : // -----------------------------------------------------------------------
    2509           0 : void SvxCharEffectsPage::SetPreviewBackgroundToCharacter()
    2510             : {
    2511           0 :     m_bPreviewBackgroundToCharacter = sal_True;
    2512           0 : }
    2513             : 
    2514             : // -----------------------------------------------------------------------
    2515           0 : void SvxCharEffectsPage::PageCreated (SfxAllItemSet aSet)
    2516             : {
    2517           0 :     SFX_ITEMSET_ARG (&aSet,pDisableCtlItem,SfxUInt16Item,SID_DISABLE_CTL,sal_False);
    2518           0 :     SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,sal_False);
    2519           0 :     if (pDisableCtlItem)
    2520           0 :         DisableControls(pDisableCtlItem->GetValue());
    2521             : 
    2522           0 :     if (pFlagItem)
    2523             :     {
    2524           0 :         sal_uInt32 nFlags=pFlagItem->GetValue();
    2525           0 :         if ( ( nFlags & SVX_ENABLE_FLASH ) == SVX_ENABLE_FLASH )
    2526           0 :             EnableFlash();
    2527           0 :         if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
    2528           0 :             SetPreviewBackgroundToCharacter();
    2529             :     }
    2530           0 : }
    2531             : 
    2532             : // class SvxCharPositionPage ---------------------------------------------
    2533             : 
    2534           0 : SvxCharPositionPage::SvxCharPositionPage( Window* pParent, const SfxItemSet& rInSet )
    2535             :     : SvxCharBasePage(pParent, "PositionPage", "cui/ui/positionpage.ui", rInSet)
    2536             :     , m_nSuperEsc((short)DFLT_ESC_SUPER)
    2537             :     , m_nSubEsc((short)DFLT_ESC_SUB)
    2538             :     , m_nScaleWidthItemSetVal(100)
    2539             :     , m_nScaleWidthInitialVal(100)
    2540             :     , m_nSuperProp((sal_uInt8)DFLT_ESC_PROP)
    2541           0 :     , m_nSubProp((sal_uInt8)DFLT_ESC_PROP)
    2542             : {
    2543           0 :     get(m_pHighPosBtn, "superscript");
    2544           0 :     get(m_pNormalPosBtn, "normal");
    2545           0 :     get(m_pLowPosBtn, "subscript");
    2546           0 :     get(m_pHighLowFT, "raiselower");
    2547           0 :     get(m_pHighLowMF, "raiselowersb");
    2548           0 :     get(m_pHighLowRB, "automatic");
    2549           0 :     get(m_pFontSizeFT, "relativefontsize");
    2550           0 :     get(m_pFontSizeMF, "fontsizesb");
    2551           0 :     get(m_pRotationContainer, "rotationcontainer");
    2552           0 :     get(m_pScalingFT, "rotate");
    2553           0 :     get(m_pScalingAndRotationFT, "rotateandscale");
    2554           0 :     get(m_p0degRB, "0deg");
    2555           0 :     get(m_p90degRB, "90deg");
    2556           0 :     get(m_p270degRB, "270deg");
    2557           0 :     get(m_pFitToLineCB, "fittoline");
    2558           0 :     get(m_pScaleWidthMF, "scalewidthsb");
    2559           0 :     get(m_pKerningLB, "kerninglb");
    2560           0 :     get(m_pKerningFT, "kerningft");
    2561           0 :     get(m_pKerningMF, "kerningsb");
    2562           0 :     get(m_pPairKerningBtn, "pairkerning");
    2563             : 
    2564           0 :     get(m_pPreviewWin, "preview");
    2565             : 
    2566           0 :     Initialize();
    2567           0 : }
    2568             : 
    2569             : // -----------------------------------------------------------------------
    2570             : 
    2571           0 : void SvxCharPositionPage::Initialize()
    2572             : {
    2573             :     // to handle the changes of the other pages
    2574           0 :     SetExchangeSupport();
    2575             : 
    2576           0 :     GetPreviewFont().SetSize( Size( 0, 240 ) );
    2577           0 :     GetPreviewCJKFont().SetSize( Size( 0, 240 ) );
    2578           0 :     GetPreviewCTLFont().SetSize( Size( 0, 240 ) );
    2579             : 
    2580           0 :     m_pNormalPosBtn->Check();
    2581           0 :     PositionHdl_Impl( m_pNormalPosBtn );
    2582           0 :     m_pKerningLB->SelectEntryPos( 0 );
    2583           0 :     KerningSelectHdl_Impl( NULL );
    2584             : 
    2585           0 :     Link aLink = LINK( this, SvxCharPositionPage, PositionHdl_Impl );
    2586           0 :     m_pHighPosBtn->SetClickHdl( aLink );
    2587           0 :     m_pNormalPosBtn->SetClickHdl( aLink );
    2588           0 :     m_pLowPosBtn->SetClickHdl( aLink );
    2589             : 
    2590           0 :     aLink = LINK( this, SvxCharPositionPage, RotationHdl_Impl );
    2591           0 :     m_p0degRB->SetClickHdl( aLink );
    2592           0 :     m_p90degRB->SetClickHdl( aLink );
    2593           0 :     m_p270degRB->SetClickHdl( aLink );
    2594             : 
    2595           0 :     aLink = LINK( this, SvxCharPositionPage, FontModifyHdl_Impl );
    2596           0 :     m_pHighLowMF->SetModifyHdl( aLink );
    2597           0 :     m_pFontSizeMF->SetModifyHdl( aLink );
    2598             : 
    2599           0 :     aLink = LINK( this, SvxCharPositionPage, LoseFocusHdl_Impl );
    2600           0 :     m_pHighLowMF->SetLoseFocusHdl( aLink );
    2601           0 :     m_pFontSizeMF->SetLoseFocusHdl( aLink );
    2602             : 
    2603           0 :     m_pHighLowRB->SetClickHdl( LINK( this, SvxCharPositionPage, AutoPositionHdl_Impl ) );
    2604           0 :     m_pFitToLineCB->SetClickHdl( LINK( this, SvxCharPositionPage, FitToLineHdl_Impl ) );
    2605           0 :     m_pKerningLB->SetSelectHdl( LINK( this, SvxCharPositionPage, KerningSelectHdl_Impl ) );
    2606           0 :     m_pKerningMF->SetModifyHdl( LINK( this, SvxCharPositionPage, KerningModifyHdl_Impl ) );
    2607           0 :     m_pPairKerningBtn->SetClickHdl( LINK( this, SvxCharPositionPage, PairKerningHdl_Impl ) );
    2608           0 :     m_pScaleWidthMF->SetModifyHdl( LINK( this, SvxCharPositionPage, ScaleWidthModifyHdl_Impl ) );
    2609           0 : }
    2610             : 
    2611           0 : SvxCharPositionPage::~SvxCharPositionPage()
    2612             : {
    2613           0 : }
    2614             : 
    2615             : // -----------------------------------------------------------------------
    2616             : 
    2617           0 : void SvxCharPositionPage::UpdatePreview_Impl( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
    2618             : {
    2619           0 :     SetPrevFontEscapement( nProp, nEscProp, nEsc );
    2620           0 : }
    2621             : 
    2622             : // -----------------------------------------------------------------------
    2623             : 
    2624           0 : void SvxCharPositionPage::SetEscapement_Impl( sal_uInt16 nEsc )
    2625             : {
    2626           0 :     SvxEscapementItem aEscItm( (SvxEscapement)nEsc, SID_ATTR_CHAR_ESCAPEMENT );
    2627             : 
    2628           0 :     if ( SVX_ESCAPEMENT_SUPERSCRIPT == nEsc )
    2629             :     {
    2630           0 :         aEscItm.GetEsc() = m_nSuperEsc;
    2631           0 :         aEscItm.GetProp() = m_nSuperProp;
    2632             :     }
    2633           0 :     else if ( SVX_ESCAPEMENT_SUBSCRIPT == nEsc )
    2634             :     {
    2635           0 :         aEscItm.GetEsc() = m_nSubEsc;
    2636           0 :         aEscItm.GetProp() = m_nSubProp;
    2637             :     }
    2638             : 
    2639           0 :     short nFac = aEscItm.GetEsc() < 0 ? -1 : 1;
    2640             : 
    2641           0 :     m_pHighLowMF->SetValue( aEscItm.GetEsc() * nFac );
    2642           0 :     m_pFontSizeMF->SetValue( aEscItm.GetProp() );
    2643             : 
    2644           0 :     if ( SVX_ESCAPEMENT_OFF == nEsc )
    2645             :     {
    2646           0 :         m_pHighLowFT->Disable();
    2647           0 :         m_pHighLowMF->Disable();
    2648           0 :         m_pFontSizeFT->Disable();
    2649           0 :         m_pFontSizeMF->Disable();
    2650           0 :         m_pHighLowRB->Disable();
    2651             :     }
    2652             :     else
    2653             :     {
    2654           0 :         m_pFontSizeFT->Enable();
    2655           0 :         m_pFontSizeMF->Enable();
    2656           0 :         m_pHighLowRB->Enable();
    2657             : 
    2658           0 :         if ( !m_pHighLowRB->IsChecked() )
    2659             :         {
    2660           0 :             m_pHighLowFT->Enable();
    2661           0 :             m_pHighLowMF->Enable();
    2662             :         }
    2663             :         else
    2664           0 :             AutoPositionHdl_Impl( m_pHighLowRB );
    2665             :     }
    2666             : 
    2667           0 :     UpdatePreview_Impl( 100, aEscItm.GetProp(), aEscItm.GetEsc() );
    2668           0 : }
    2669             : 
    2670             : // -----------------------------------------------------------------------
    2671             : 
    2672           0 : IMPL_LINK( SvxCharPositionPage, PositionHdl_Impl, RadioButton*, pBtn )
    2673             : {
    2674           0 :     sal_uInt16 nEsc = SVX_ESCAPEMENT_OFF;   // also when pBtn == NULL
    2675             : 
    2676           0 :     if ( m_pHighPosBtn == pBtn )
    2677           0 :         nEsc = SVX_ESCAPEMENT_SUPERSCRIPT;
    2678           0 :     else if ( m_pLowPosBtn == pBtn )
    2679           0 :         nEsc = SVX_ESCAPEMENT_SUBSCRIPT;
    2680             : 
    2681           0 :     SetEscapement_Impl( nEsc );
    2682           0 :     return 0;
    2683             : }
    2684             : 
    2685             : // -----------------------------------------------------------------------
    2686             : 
    2687           0 : IMPL_LINK( SvxCharPositionPage, RotationHdl_Impl, RadioButton*, pBtn )
    2688             : {
    2689           0 :     sal_Bool bEnable = sal_False;
    2690           0 :     if (m_p90degRB == pBtn  || m_p270degRB == pBtn)
    2691           0 :         bEnable = sal_True;
    2692             :     else
    2693             :         OSL_ENSURE( m_p0degRB == pBtn, "unexpected button" );
    2694           0 :     m_pFitToLineCB->Enable( bEnable );
    2695           0 :     return 0;
    2696             : }
    2697             : 
    2698             : // -----------------------------------------------------------------------
    2699             : 
    2700           0 : IMPL_LINK_NOARG(SvxCharPositionPage, FontModifyHdl_Impl)
    2701             : {
    2702           0 :     sal_uInt8 nEscProp = (sal_uInt8)m_pFontSizeMF->GetValue();
    2703           0 :     short nEsc  = (short)m_pHighLowMF->GetValue();
    2704           0 :     nEsc *= m_pLowPosBtn->IsChecked() ? -1 : 1;
    2705           0 :     UpdatePreview_Impl( 100, nEscProp, nEsc );
    2706           0 :     return 0;
    2707             : }
    2708             : 
    2709             : // -----------------------------------------------------------------------
    2710             : 
    2711           0 : IMPL_LINK( SvxCharPositionPage, AutoPositionHdl_Impl, CheckBox*, pBox )
    2712             : {
    2713           0 :     if ( pBox->IsChecked() )
    2714             :     {
    2715           0 :         m_pHighLowFT->Disable();
    2716           0 :         m_pHighLowMF->Disable();
    2717             :     }
    2718             :     else
    2719           0 :         PositionHdl_Impl( m_pHighPosBtn->IsChecked() ? m_pHighPosBtn
    2720           0 :                                                       : m_pLowPosBtn->IsChecked() ? m_pLowPosBtn
    2721           0 :                                                                                    : m_pNormalPosBtn );
    2722           0 :     return 0;
    2723             : }
    2724             : 
    2725             : // -----------------------------------------------------------------------
    2726             : 
    2727           0 : IMPL_LINK( SvxCharPositionPage, FitToLineHdl_Impl, CheckBox*, pBox )
    2728             : {
    2729           0 :     if (m_pFitToLineCB == pBox)
    2730             :     {
    2731           0 :         sal_uInt16 nVal = m_nScaleWidthInitialVal;
    2732           0 :         if (m_pFitToLineCB->IsChecked())
    2733           0 :             nVal = m_nScaleWidthItemSetVal;
    2734           0 :         m_pScaleWidthMF->SetValue( nVal );
    2735             : 
    2736           0 :         m_pPreviewWin->SetFontWidthScale( nVal );
    2737             :     }
    2738           0 :     return 0;
    2739             : }
    2740             : 
    2741             : // -----------------------------------------------------------------------
    2742             : 
    2743           0 : IMPL_LINK_NOARG(SvxCharPositionPage, KerningSelectHdl_Impl)
    2744             : {
    2745           0 :     if ( m_pKerningLB->GetSelectEntryPos() > 0 )
    2746             :     {
    2747           0 :         m_pKerningFT->Enable();
    2748           0 :         m_pKerningMF->Enable();
    2749             : 
    2750           0 :         if ( m_pKerningLB->GetSelectEntryPos() == 2 )
    2751             :         {
    2752             :             // Condensed -> max value == 1/6 of the current font height
    2753           0 :             SvxFont& rFont = GetPreviewFont();
    2754           0 :             long nMax = rFont.GetSize().Height() / 6;
    2755           0 :             m_pKerningMF->SetMax( m_pKerningMF->Normalize( nMax ), FUNIT_TWIP );
    2756           0 :             m_pKerningMF->SetLast( m_pKerningMF->GetMax( m_pKerningMF->GetUnit() ) );
    2757             :         }
    2758             :         else
    2759             :         {
    2760           0 :             m_pKerningMF->SetMax( 9999 );
    2761           0 :             m_pKerningMF->SetLast( 9999 );
    2762             :         }
    2763             :     }
    2764             :     else
    2765             :     {
    2766           0 :         m_pKerningMF->SetValue( 0 );
    2767           0 :         m_pKerningFT->Disable();
    2768           0 :         m_pKerningMF->Disable();
    2769             :     }
    2770             : 
    2771           0 :     KerningModifyHdl_Impl( NULL );
    2772             : 
    2773           0 :     return 0;
    2774             : }
    2775             : 
    2776             : // -----------------------------------------------------------------------
    2777             : 
    2778           0 : IMPL_LINK_NOARG(SvxCharPositionPage, KerningModifyHdl_Impl)
    2779             : {
    2780           0 :     long nVal = static_cast<long>(m_pKerningMF->GetValue());
    2781           0 :     nVal = LogicToLogic( nVal, MAP_POINT, MAP_TWIP );
    2782           0 :     long nKern = (short)m_pKerningMF->Denormalize( nVal );
    2783             : 
    2784             :     // Condensed? -> then negative
    2785           0 :     if ( m_pKerningLB->GetSelectEntryPos() == 2 )
    2786           0 :         nKern *= -1;
    2787             : 
    2788           0 :     SvxFont& rFont = GetPreviewFont();
    2789           0 :     SvxFont& rCJKFont = GetPreviewCJKFont();
    2790           0 :     SvxFont& rCTLFont = GetPreviewCTLFont();
    2791             : 
    2792           0 :     rFont.SetFixKerning( (short)nKern );
    2793           0 :     rCJKFont.SetFixKerning( (short)nKern );
    2794           0 :     rCTLFont.SetFixKerning( (short)nKern );
    2795           0 :     m_pPreviewWin->Invalidate();
    2796           0 :     return 0;
    2797             : }
    2798             : 
    2799             : // -----------------------------------------------------------------------
    2800             : 
    2801           0 : IMPL_LINK_NOARG(SvxCharPositionPage, PairKerningHdl_Impl)
    2802             : {
    2803           0 :     return 0;
    2804             : }
    2805             : 
    2806             : // -----------------------------------------------------------------------
    2807             : 
    2808           0 : IMPL_LINK( SvxCharPositionPage, LoseFocusHdl_Impl, MetricField*, pField )
    2809             : {
    2810             : #ifdef DBG_UTIL
    2811             :     sal_Bool bHigh = m_pHighPosBtn->IsChecked();
    2812             : #endif
    2813           0 :     sal_Bool bLow = m_pLowPosBtn->IsChecked();
    2814             :     DBG_ASSERT( bHigh || bLow, "normal position is not valid" );
    2815             : 
    2816           0 :     if ( m_pHighLowMF == pField )
    2817             :     {
    2818           0 :         if ( bLow )
    2819           0 :             m_nSubEsc = (short)m_pHighLowMF->GetValue() * -1;
    2820             :         else
    2821           0 :             m_nSuperEsc = (short)m_pHighLowMF->GetValue();
    2822             :     }
    2823           0 :     else if ( m_pFontSizeMF == pField )
    2824             :     {
    2825           0 :         if ( bLow )
    2826           0 :             m_nSubProp = (sal_uInt8)m_pFontSizeMF->GetValue();
    2827             :         else
    2828           0 :             m_nSuperProp = (sal_uInt8)m_pFontSizeMF->GetValue();
    2829             :     }
    2830           0 :     return 0;
    2831             : }
    2832             : 
    2833             : // -----------------------------------------------------------------------
    2834             : 
    2835           0 : IMPL_LINK_NOARG(SvxCharPositionPage, ScaleWidthModifyHdl_Impl)
    2836             : {
    2837           0 :     m_pPreviewWin->SetFontWidthScale( sal_uInt16( m_pScaleWidthMF->GetValue() ) );
    2838             : 
    2839           0 :     return 0;
    2840             : }
    2841             : 
    2842           0 : void  SvxCharPositionPage::ActivatePage( const SfxItemSet& rSet )
    2843             : {
    2844             :     //update the preview
    2845           0 :     SvxCharBasePage::ActivatePage( rSet );
    2846             : 
    2847             :     //the only thing that has to be checked is the max. allowed value for the
    2848             :     //condense edit field
    2849           0 :     if ( m_pKerningLB->GetSelectEntryPos() == 2 )
    2850             :     {
    2851             :         // Condensed -> max value == 1/6 of the current font height
    2852           0 :         SvxFont& rFont = GetPreviewFont();
    2853           0 :         long nMax = rFont.GetSize().Height() / 6;
    2854           0 :         long nKern = (short)m_pKerningMF->Denormalize( LogicToLogic( static_cast<long>(m_pKerningMF->GetValue()), MAP_POINT, MAP_TWIP ) );
    2855           0 :         m_pKerningMF->SetMax( m_pKerningMF->Normalize( nKern > nMax ? nKern : nMax ), FUNIT_TWIP );
    2856           0 :         m_pKerningMF->SetLast( m_pKerningMF->GetMax( m_pKerningMF->GetUnit() ) );
    2857             :     }
    2858           0 : }
    2859             : 
    2860             : // -----------------------------------------------------------------------
    2861             : 
    2862           0 : int SvxCharPositionPage::DeactivatePage( SfxItemSet* _pSet )
    2863             : {
    2864           0 :     if ( _pSet )
    2865           0 :         FillItemSet( *_pSet );
    2866           0 :     return LEAVE_PAGE;
    2867             : }
    2868             : 
    2869             : // -----------------------------------------------------------------------
    2870             : 
    2871           0 : SfxTabPage* SvxCharPositionPage::Create( Window* pParent, const SfxItemSet& rSet )
    2872             : {
    2873           0 :     return new SvxCharPositionPage( pParent, rSet );
    2874             : }
    2875             : 
    2876             : // -----------------------------------------------------------------------
    2877             : 
    2878           0 : sal_uInt16* SvxCharPositionPage::GetRanges()
    2879             : {
    2880           0 :     return pPositionRanges;
    2881             : }
    2882             : 
    2883             : // -----------------------------------------------------------------------
    2884           0 : void SvxCharPositionPage::Reset( const SfxItemSet& rSet )
    2885             : {
    2886           0 :     String sUser = GetUserData();
    2887             : 
    2888           0 :     if ( sUser.Len() )
    2889             :     {
    2890           0 :         m_nSuperEsc = (short)sUser.GetToken( 0 ).ToInt32();
    2891           0 :         m_nSubEsc = (short)sUser.GetToken( 1 ).ToInt32();
    2892           0 :         m_nSuperProp = (sal_uInt8)sUser.GetToken( 2 ).ToInt32();
    2893           0 :         m_nSubProp = (sal_uInt8)sUser.GetToken( 3 ).ToInt32();
    2894             :     }
    2895             : 
    2896           0 :     short nEsc = 0;
    2897           0 :     sal_uInt8 nEscProp = 100;
    2898           0 :     sal_uInt8 nProp = 100;
    2899             : 
    2900           0 :     m_pHighLowFT->Disable();
    2901           0 :     m_pHighLowMF->Disable();
    2902           0 :     m_pFontSizeFT->Disable();
    2903           0 :     m_pFontSizeMF->Disable();
    2904             : 
    2905           0 :     SvxFont& rFont = GetPreviewFont();
    2906           0 :     SvxFont& rCJKFont = GetPreviewCJKFont();
    2907           0 :     SvxFont& rCTLFont = GetPreviewCTLFont();
    2908           0 :     sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_ESCAPEMENT );
    2909             : 
    2910           0 :     if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT )
    2911             :     {
    2912           0 :         const SvxEscapementItem& rItem = (SvxEscapementItem&)rSet.Get( nWhich );
    2913           0 :         nEsc = rItem.GetEsc();
    2914           0 :         nEscProp = rItem.GetProp();
    2915             : 
    2916           0 :         if ( nEsc != 0 )
    2917             :         {
    2918           0 :             m_pHighLowFT->Enable();
    2919           0 :             m_pHighLowMF->Enable();
    2920           0 :             m_pFontSizeFT->Enable();
    2921           0 :             m_pFontSizeMF->Enable();
    2922             : 
    2923             :             short nFac;
    2924           0 :             sal_Bool bAutomatic(sal_False);
    2925             : 
    2926           0 :             if ( nEsc > 0 )
    2927             :             {
    2928           0 :                 nFac = 1;
    2929           0 :                 m_pHighPosBtn->Check( sal_True );
    2930           0 :                 if ( nEsc == DFLT_ESC_AUTO_SUPER )
    2931             :                 {
    2932           0 :                     nEsc = DFLT_ESC_SUPER;
    2933           0 :                     bAutomatic = sal_True;
    2934             :                 }
    2935             :             }
    2936             :             else
    2937             :             {
    2938           0 :                 nFac = -1;
    2939           0 :                 m_pLowPosBtn->Check( sal_True );
    2940           0 :                 if ( nEsc == DFLT_ESC_AUTO_SUB )
    2941             :                 {
    2942           0 :                     nEsc = DFLT_ESC_SUB;
    2943           0 :                     bAutomatic = sal_True;
    2944             :                 }
    2945             :             }
    2946           0 :             if (!m_pHighLowRB->IsEnabled())
    2947             :             {
    2948           0 :                 m_pHighLowRB->Enable();
    2949             :             }
    2950           0 :             m_pHighLowRB->Check(bAutomatic);
    2951             : 
    2952           0 :             if ( m_pHighLowRB->IsChecked() )
    2953             :             {
    2954           0 :                 m_pHighLowFT->Disable();
    2955           0 :                 m_pHighLowMF->Disable();
    2956             :             }
    2957           0 :             m_pHighLowMF->SetValue( m_pHighLowMF->Normalize( nFac * nEsc ) );
    2958             :         }
    2959             :         else
    2960             :         {
    2961           0 :             m_pNormalPosBtn->Check( sal_True );
    2962           0 :             m_pHighLowRB->Check( sal_True );
    2963           0 :             PositionHdl_Impl( NULL );
    2964             :         }
    2965             :         //the height has to be set after the handler is called to keep the value also if the escapement is zero
    2966           0 :         m_pFontSizeMF->SetValue( m_pFontSizeMF->Normalize( nEscProp ) );
    2967             :     }
    2968             :     else
    2969             :     {
    2970           0 :         m_pHighPosBtn->Check( sal_False );
    2971           0 :         m_pNormalPosBtn->Check( sal_False );
    2972           0 :         m_pLowPosBtn->Check( sal_False );
    2973             :     }
    2974             : 
    2975             :     // set BspFont
    2976           0 :     SetPrevFontEscapement( nProp, nEscProp, nEsc );
    2977             : 
    2978             :     // Kerning
    2979           0 :     nWhich = GetWhich( SID_ATTR_CHAR_KERNING );
    2980             : 
    2981           0 :     if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT )
    2982             :     {
    2983           0 :         const SvxKerningItem& rItem = (SvxKerningItem&)rSet.Get( nWhich );
    2984           0 :         SfxMapUnit eUnit = rSet.GetPool()->GetMetric( nWhich );
    2985           0 :         MapUnit eOrgUnit = (MapUnit)eUnit;
    2986           0 :         MapUnit ePntUnit( MAP_POINT );
    2987           0 :         long nBig = static_cast<long>(m_pKerningMF->Normalize( static_cast<long>(rItem.GetValue()) ));
    2988           0 :         long nKerning = LogicToLogic( nBig, eOrgUnit, ePntUnit );
    2989             : 
    2990             :         // set Kerning at the Font, convert into Twips before
    2991           0 :         long nKern = LogicToLogic( rItem.GetValue(), (MapUnit)eUnit, MAP_TWIP );
    2992           0 :         rFont.SetFixKerning( (short)nKern );
    2993           0 :         rCJKFont.SetFixKerning( (short)nKern );
    2994           0 :         rCTLFont.SetFixKerning( (short)nKern );
    2995             : 
    2996           0 :         if ( nKerning > 0 )
    2997             :         {
    2998           0 :             m_pKerningLB->SelectEntryPos( LW_GESPERRT );
    2999             :         }
    3000           0 :         else if ( nKerning < 0 )
    3001             :         {
    3002           0 :             m_pKerningLB->SelectEntryPos( LW_SCHMAL );
    3003           0 :             nKerning = -nKerning;
    3004             :         }
    3005             :         else
    3006             :         {
    3007           0 :             nKerning = 0;
    3008           0 :             m_pKerningLB->SelectEntryPos( LW_NORMAL );
    3009             :         }
    3010             :         //enable/disable and set min/max of the Edit
    3011           0 :         KerningSelectHdl_Impl(m_pKerningLB);
    3012             :         //the attribute value must be displayed also if it's above the maximum allowed value
    3013           0 :         long nVal = static_cast<long>(m_pKerningMF->GetMax());
    3014           0 :         if(nVal < nKerning)
    3015           0 :             m_pKerningMF->SetMax( nKerning );
    3016           0 :         m_pKerningMF->SetValue( nKerning );
    3017             :     }
    3018             :     else
    3019           0 :         m_pKerningMF->SetText( String() );
    3020             : 
    3021             :     // Pair kerning
    3022           0 :     nWhich = GetWhich( SID_ATTR_CHAR_AUTOKERN );
    3023             : 
    3024           0 :     if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT )
    3025             :     {
    3026           0 :         const SvxAutoKernItem& rItem = (SvxAutoKernItem&)rSet.Get( nWhich );
    3027           0 :         m_pPairKerningBtn->Check( rItem.GetValue() );
    3028             :     }
    3029             :     else
    3030           0 :         m_pPairKerningBtn->Check( sal_False );
    3031             : 
    3032             :     // Scale Width
    3033           0 :     nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
    3034           0 :     if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT )
    3035             :     {
    3036           0 :         const SvxCharScaleWidthItem& rItem = ( SvxCharScaleWidthItem& ) rSet.Get( nWhich );
    3037           0 :         m_nScaleWidthInitialVal = rItem.GetValue();
    3038           0 :         m_pScaleWidthMF->SetValue( m_nScaleWidthInitialVal );
    3039             :     }
    3040             :     else
    3041           0 :         m_pScaleWidthMF->SetValue( 100 );
    3042             : 
    3043           0 :     nWhich = GetWhich( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE );
    3044           0 :     if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT )
    3045           0 :         m_nScaleWidthItemSetVal = ((SfxUInt16Item&) rSet.Get( nWhich )).GetValue();
    3046             : 
    3047             :     // Rotation
    3048           0 :     nWhich = GetWhich( SID_ATTR_CHAR_ROTATED );
    3049           0 :     SfxItemState eState = rSet.GetItemState( nWhich );
    3050           0 :     if( SFX_ITEM_UNKNOWN == eState )
    3051             :     {
    3052           0 :         m_pRotationContainer->Hide();
    3053           0 :         m_pScalingAndRotationFT->Hide();
    3054           0 :         m_pScalingFT->Show();
    3055             :     }
    3056             :     else
    3057             :     {
    3058           0 :         m_pRotationContainer->Show();
    3059           0 :         m_pScalingAndRotationFT->Show();
    3060           0 :         m_pScalingFT->Hide();
    3061             : 
    3062           0 :         Link aOldLink( m_pFitToLineCB->GetClickHdl() );
    3063           0 :         m_pFitToLineCB->SetClickHdl( Link() );
    3064           0 :         if( eState >= SFX_ITEM_DEFAULT )
    3065             :         {
    3066             :             const SvxCharRotateItem& rItem =
    3067           0 :                     (SvxCharRotateItem&) rSet.Get( nWhich );
    3068           0 :             if (rItem.IsBottomToTop())
    3069           0 :                 m_p90degRB->Check( sal_True );
    3070           0 :             else if (rItem.IsTopToBotton())
    3071           0 :                 m_p270degRB->Check( sal_True );
    3072             :             else
    3073             :             {
    3074             :                 DBG_ASSERT( 0 == rItem.GetValue(), "incorrect value" );
    3075           0 :                 m_p0degRB->Check( sal_True );
    3076             :             }
    3077           0 :             m_pFitToLineCB->Check( rItem.IsFitToLine() );
    3078             :         }
    3079             :         else
    3080             :         {
    3081           0 :             if( eState == SFX_ITEM_DONTCARE )
    3082             :             {
    3083           0 :                 m_p0degRB->Check( sal_False );
    3084           0 :                 m_p90degRB->Check( sal_False );
    3085           0 :                 m_p270degRB->Check( sal_False );
    3086             :             }
    3087             :             else
    3088           0 :                 m_p0degRB->Check( sal_True );
    3089             : 
    3090           0 :             m_pFitToLineCB->Check( sal_False );
    3091             :         }
    3092           0 :         m_pFitToLineCB->SetClickHdl( aOldLink );
    3093           0 :         m_pFitToLineCB->Enable( !m_p0degRB->IsChecked() );
    3094             : 
    3095             :         // is this value set?
    3096           0 :         if( SFX_ITEM_UNKNOWN == rSet.GetItemState( GetWhich(
    3097           0 :                                         SID_ATTR_CHAR_WIDTH_FIT_TO_LINE ) ))
    3098           0 :             m_pFitToLineCB->Hide();
    3099             :     }
    3100             : 
    3101           0 :     m_pHighPosBtn->SaveValue();
    3102           0 :     m_pNormalPosBtn->SaveValue();
    3103           0 :     m_pLowPosBtn->SaveValue();
    3104           0 :     m_p0degRB->SaveValue();
    3105           0 :     m_p90degRB->SaveValue();
    3106           0 :     m_p270degRB->SaveValue();
    3107           0 :     m_pFitToLineCB->SaveValue();
    3108           0 :     m_pScaleWidthMF->SaveValue();
    3109           0 :     m_pKerningLB->SaveValue();
    3110           0 :     m_pKerningMF->SaveValue();
    3111           0 :     m_pPairKerningBtn->SaveValue();
    3112           0 : }
    3113             : 
    3114             : // -----------------------------------------------------------------------
    3115             : 
    3116           0 : sal_Bool SvxCharPositionPage::FillItemSet( SfxItemSet& rSet )
    3117             : {
    3118             :     //  Position (high, normal or low)
    3119           0 :     const SfxItemSet& rOldSet = GetItemSet();
    3120           0 :     sal_Bool bModified = sal_False, bChanged = sal_True;
    3121           0 :     sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_ESCAPEMENT );
    3122           0 :     const SfxPoolItem* pOld = GetOldItem( rSet, SID_ATTR_CHAR_ESCAPEMENT );
    3123           0 :     const bool bHigh = m_pHighPosBtn->IsChecked();
    3124             :     short nEsc;
    3125             :     sal_uInt8  nEscProp;
    3126             : 
    3127           0 :     if ( bHigh || m_pLowPosBtn->IsChecked() )
    3128             :     {
    3129           0 :         if ( m_pHighLowRB->IsChecked() )
    3130           0 :             nEsc = bHigh ? DFLT_ESC_AUTO_SUPER : DFLT_ESC_AUTO_SUB;
    3131             :         else
    3132             :         {
    3133           0 :             nEsc = (short)m_pHighLowMF->Denormalize( m_pHighLowMF->GetValue() );
    3134           0 :             nEsc *= (bHigh ? 1 : -1);
    3135             :         }
    3136           0 :         nEscProp = (sal_uInt8)m_pFontSizeMF->Denormalize( m_pFontSizeMF->GetValue() );
    3137             :     }
    3138             :     else
    3139             :     {
    3140           0 :         nEsc  = 0;
    3141           0 :         nEscProp = 100;
    3142             :     }
    3143             : 
    3144           0 :     if ( pOld )
    3145             :     {
    3146           0 :         const SvxEscapementItem& rItem = *( (const SvxEscapementItem*)pOld );
    3147           0 :         if ( rItem.GetEsc() == nEsc && rItem.GetProp() == nEscProp  )
    3148           0 :             bChanged = sal_False;
    3149             :     }
    3150             : 
    3151           0 :     if ( !bChanged && !m_pHighPosBtn->GetSavedValue() &&
    3152           0 :          !m_pNormalPosBtn->GetSavedValue() && !m_pLowPosBtn->GetSavedValue() )
    3153           0 :         bChanged = sal_True;
    3154             : 
    3155           0 :     if ( bChanged &&
    3156           0 :          ( m_pHighPosBtn->IsChecked() || m_pNormalPosBtn->IsChecked() || m_pLowPosBtn->IsChecked() ) )
    3157             :     {
    3158           0 :         rSet.Put( SvxEscapementItem( nEsc, nEscProp, nWhich ) );
    3159           0 :         bModified = sal_True;
    3160             :     }
    3161           0 :     else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
    3162           0 :         CLEARTITEM;
    3163             : 
    3164           0 :     bChanged = sal_True;
    3165             : 
    3166             :     // Kerning
    3167           0 :     nWhich = GetWhich( SID_ATTR_CHAR_KERNING );
    3168           0 :     pOld = GetOldItem( rSet, SID_ATTR_CHAR_KERNING );
    3169           0 :     sal_uInt16 nPos = m_pKerningLB->GetSelectEntryPos();
    3170           0 :     short nKerning = 0;
    3171           0 :     SfxMapUnit eUnit = rSet.GetPool()->GetMetric( nWhich );
    3172             : 
    3173           0 :     if ( nPos == LW_GESPERRT || nPos == LW_SCHMAL )
    3174             :     {
    3175           0 :         long nTmp = static_cast<long>(m_pKerningMF->GetValue());
    3176           0 :         long nVal = LogicToLogic( nTmp, MAP_POINT, (MapUnit)eUnit );
    3177           0 :         nKerning = (short)m_pKerningMF->Denormalize( nVal );
    3178             : 
    3179           0 :         if ( nPos == LW_SCHMAL )
    3180           0 :             nKerning *= - 1;
    3181             :     }
    3182             : 
    3183           0 :     if ( pOld )
    3184             :     {
    3185           0 :         const SvxKerningItem& rItem = *( (const SvxKerningItem*)pOld );
    3186           0 :         if ( rItem.GetValue() == nKerning )
    3187           0 :             bChanged = sal_False;
    3188             :     }
    3189             : 
    3190           0 :     if ( !bChanged &&
    3191           0 :          ( m_pKerningLB->GetSavedValue() == LISTBOX_ENTRY_NOTFOUND ||
    3192           0 :            ( !m_pKerningMF->GetSavedValue().Len() && m_pKerningMF->IsEnabled() ) ) )
    3193           0 :         bChanged = sal_True;
    3194             : 
    3195           0 :     if ( bChanged && nPos != LISTBOX_ENTRY_NOTFOUND )
    3196             :     {
    3197           0 :         rSet.Put( SvxKerningItem( nKerning, nWhich ) );
    3198           0 :         bModified = sal_True;
    3199             :     }
    3200           0 :     else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
    3201           0 :         CLEARTITEM;
    3202             : 
    3203           0 :     bChanged = sal_True;
    3204             : 
    3205             :     // Pair-Kerning
    3206           0 :     nWhich = GetWhich( SID_ATTR_CHAR_AUTOKERN );
    3207             : 
    3208           0 :     if ( m_pPairKerningBtn->IsChecked() != m_pPairKerningBtn->GetSavedValue() )
    3209             :     {
    3210           0 :         rSet.Put( SvxAutoKernItem( m_pPairKerningBtn->IsChecked(), nWhich ) );
    3211           0 :         bModified = sal_True;
    3212             :     }
    3213           0 :     else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
    3214           0 :         CLEARTITEM;
    3215             : 
    3216             :     // Scale Width
    3217           0 :     nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
    3218           0 :     if ( m_pScaleWidthMF->GetText() != m_pScaleWidthMF->GetSavedValue() )
    3219             :     {
    3220           0 :         rSet.Put( SvxCharScaleWidthItem( (sal_uInt16)m_pScaleWidthMF->GetValue(), nWhich ) );
    3221           0 :         bModified = sal_True;
    3222             :     }
    3223           0 :     else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
    3224           0 :         CLEARTITEM;
    3225             : 
    3226             :     // Rotation
    3227           0 :     nWhich = GetWhich( SID_ATTR_CHAR_ROTATED );
    3228           0 :     if ( m_p0degRB->IsChecked() != m_p0degRB->GetSavedValue()  ||
    3229           0 :          m_p90degRB->IsChecked() != m_p90degRB->GetSavedValue()  ||
    3230           0 :          m_p270degRB->IsChecked() != m_p270degRB->GetSavedValue()  ||
    3231           0 :          m_pFitToLineCB->IsChecked() != m_pFitToLineCB->GetSavedValue() )
    3232             :     {
    3233           0 :         SvxCharRotateItem aItem( 0, m_pFitToLineCB->IsChecked(), nWhich );
    3234           0 :         if (m_p90degRB->IsChecked())
    3235           0 :             aItem.SetBottomToTop();
    3236           0 :         else if (m_p270degRB->IsChecked())
    3237           0 :             aItem.SetTopToBotton();
    3238           0 :         rSet.Put( aItem );
    3239           0 :         bModified = sal_True;
    3240             :     }
    3241           0 :     else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
    3242           0 :         CLEARTITEM;
    3243             : 
    3244           0 :     return bModified;
    3245             : }
    3246             : 
    3247             : // -----------------------------------------------------------------------
    3248             : 
    3249           0 : void SvxCharPositionPage::FillUserData()
    3250             : {
    3251           0 :     const sal_Unicode cTok = ';';
    3252             : 
    3253           0 :     OUString sUser( OUString::valueOf( static_cast<sal_Int32>(m_nSuperEsc)) );
    3254           0 :     sUser += OUString( cTok );
    3255           0 :     sUser += OUString::valueOf( static_cast<sal_Int32>(m_nSubEsc) );
    3256           0 :     sUser += OUString (cTok );
    3257           0 :     sUser += OUString::valueOf( static_cast<sal_Int32>(m_nSuperProp) );
    3258           0 :     sUser += OUString ( cTok );
    3259           0 :     sUser += OUString::valueOf( static_cast<sal_Int32>(m_nSubProp) );
    3260           0 :     SetUserData( sUser );
    3261           0 : }
    3262             : 
    3263             : // -----------------------------------------------------------------------
    3264           0 : void SvxCharPositionPage::SetPreviewBackgroundToCharacter()
    3265             : {
    3266           0 :     m_bPreviewBackgroundToCharacter = sal_True;
    3267           0 : }
    3268             : // -----------------------------------------------------------------------
    3269           0 : void SvxCharPositionPage::PageCreated (SfxAllItemSet aSet)
    3270             : {
    3271           0 :     SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,sal_False);
    3272           0 :     if (pFlagItem)
    3273             :     {
    3274           0 :         sal_uInt32 nFlags=pFlagItem->GetValue();
    3275           0 :         if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
    3276           0 :             SetPreviewBackgroundToCharacter();
    3277             :     }
    3278           0 : }
    3279             : // class SvxCharTwoLinesPage ------------------------------------------------
    3280             : 
    3281           0 : SvxCharTwoLinesPage::SvxCharTwoLinesPage(Window* pParent, const SfxItemSet& rInSet)
    3282             :     : SvxCharBasePage(pParent, "TwoLinesPage", "cui/ui/twolinespage.ui", rInSet)
    3283             :     , m_nStartBracketPosition( 0 )
    3284           0 :     , m_nEndBracketPosition( 0 )
    3285             : {
    3286           0 :     get(m_pTwoLinesBtn, "twolines");
    3287           0 :     get(m_pEnclosingFrame, "enclosing");
    3288           0 :     get(m_pStartBracketLB, "startbracket");
    3289           0 :     get(m_pEndBracketLB, "endbracket");
    3290             : 
    3291           0 :     get(m_pPreviewWin, "preview");
    3292             : 
    3293           0 :     Initialize();
    3294           0 : }
    3295             : 
    3296           0 : SvxCharTwoLinesPage::~SvxCharTwoLinesPage()
    3297             : {
    3298           0 : }
    3299             : 
    3300             : // -----------------------------------------------------------------------
    3301             : 
    3302           0 : void SvxCharTwoLinesPage::Initialize()
    3303             : {
    3304           0 :     m_pTwoLinesBtn->Check( sal_False );
    3305           0 :     TwoLinesHdl_Impl( NULL );
    3306             : 
    3307           0 :     m_pTwoLinesBtn->SetClickHdl( LINK( this, SvxCharTwoLinesPage, TwoLinesHdl_Impl ) );
    3308             : 
    3309           0 :     Link aLink = LINK( this, SvxCharTwoLinesPage, CharacterMapHdl_Impl );
    3310           0 :     m_pStartBracketLB->SetSelectHdl( aLink );
    3311           0 :     m_pEndBracketLB->SetSelectHdl( aLink );
    3312             : 
    3313           0 :     SvxFont& rFont = GetPreviewFont();
    3314           0 :     SvxFont& rCJKFont = GetPreviewCJKFont();
    3315           0 :     SvxFont& rCTLFont = GetPreviewCTLFont();
    3316           0 :     rFont.SetSize( Size( 0, 220 ) );
    3317           0 :     rCJKFont.SetSize( Size( 0, 220 ) );
    3318           0 :     rCTLFont.SetSize( Size( 0, 220 ) );
    3319           0 : }
    3320             : 
    3321             : // -----------------------------------------------------------------------
    3322             : 
    3323           0 : void SvxCharTwoLinesPage::SelectCharacter( ListBox* pBox )
    3324             : {
    3325           0 :     bool bStart = pBox == m_pStartBracketLB;
    3326           0 :     SvxCharacterMap* aDlg = new SvxCharacterMap( this );
    3327           0 :     aDlg->DisableFontSelection();
    3328             : 
    3329           0 :     if ( aDlg->Execute() == RET_OK )
    3330             :     {
    3331           0 :         sal_Unicode cChar = (sal_Unicode) aDlg->GetChar();
    3332           0 :         SetBracket( cChar, bStart );
    3333             :     }
    3334             :     else
    3335             :     {
    3336           0 :         pBox->SelectEntryPos( bStart ? m_nStartBracketPosition : m_nEndBracketPosition );
    3337             :     }
    3338           0 :     delete aDlg;
    3339           0 : }
    3340             : 
    3341             : // -----------------------------------------------------------------------
    3342             : 
    3343           0 : void SvxCharTwoLinesPage::SetBracket( sal_Unicode cBracket, sal_Bool bStart )
    3344             : {
    3345           0 :     sal_uInt16 nEntryPos = 0;
    3346           0 :     ListBox* pBox = bStart ? m_pStartBracketLB : m_pEndBracketLB;
    3347           0 :     if ( 0 == cBracket )
    3348           0 :         pBox->SelectEntryPos(0);
    3349             :     else
    3350             :     {
    3351           0 :         bool bFound = false;
    3352           0 :         for ( sal_uInt16 i = 1; i < pBox->GetEntryCount(); ++i )
    3353             :         {
    3354           0 :             if ( (sal_uLong)pBox->GetEntryData(i) != CHRDLG_ENCLOSE_SPECIAL_CHAR )
    3355             :             {
    3356           0 :                 const sal_Unicode cChar = pBox->GetEntry(i).GetChar(0);
    3357           0 :                 if ( cChar == cBracket )
    3358             :                 {
    3359           0 :                     pBox->SelectEntryPos(i);
    3360           0 :                     nEntryPos = i;
    3361           0 :                     bFound = true;
    3362           0 :                     break;
    3363             :                 }
    3364             :             }
    3365             :         }
    3366             : 
    3367           0 :         if ( !bFound )
    3368             :         {
    3369           0 :             nEntryPos = pBox->InsertEntry( rtl::OUString(cBracket) );
    3370           0 :             pBox->SelectEntryPos( nEntryPos );
    3371             :         }
    3372             :     }
    3373           0 :     if( bStart )
    3374           0 :         m_nStartBracketPosition = nEntryPos;
    3375             :     else
    3376           0 :         m_nEndBracketPosition = nEntryPos;
    3377           0 : }
    3378             : 
    3379             : // -----------------------------------------------------------------------
    3380             : 
    3381           0 : IMPL_LINK_NOARG(SvxCharTwoLinesPage, TwoLinesHdl_Impl)
    3382             : {
    3383           0 :     sal_Bool bChecked = m_pTwoLinesBtn->IsChecked();
    3384           0 :     m_pEnclosingFrame->Enable( bChecked );
    3385             : 
    3386           0 :     UpdatePreview_Impl();
    3387           0 :     return 0;
    3388             : }
    3389             : 
    3390             : // -----------------------------------------------------------------------
    3391             : 
    3392           0 : IMPL_LINK( SvxCharTwoLinesPage, CharacterMapHdl_Impl, ListBox*, pBox )
    3393             : {
    3394           0 :     sal_uInt16 nPos = pBox->GetSelectEntryPos();
    3395           0 :     if ( CHRDLG_ENCLOSE_SPECIAL_CHAR == (sal_uLong)pBox->GetEntryData( nPos ) )
    3396           0 :         SelectCharacter( pBox );
    3397             :     else
    3398             :     {
    3399           0 :         bool bStart = pBox == m_pStartBracketLB;
    3400           0 :         if( bStart )
    3401           0 :             m_nStartBracketPosition = nPos;
    3402             :         else
    3403           0 :             m_nEndBracketPosition = nPos;
    3404             :     }
    3405           0 :     UpdatePreview_Impl();
    3406           0 :     return 0;
    3407             : }
    3408             : 
    3409             : // -----------------------------------------------------------------------
    3410             : 
    3411           0 : void SvxCharTwoLinesPage::ActivatePage( const SfxItemSet& rSet )
    3412             : {
    3413           0 :     SvxCharBasePage::ActivatePage( rSet );
    3414           0 : }
    3415             : 
    3416             : // -----------------------------------------------------------------------
    3417             : 
    3418           0 : int SvxCharTwoLinesPage::DeactivatePage( SfxItemSet* _pSet )
    3419             : {
    3420           0 :     if ( _pSet )
    3421           0 :         FillItemSet( *_pSet );
    3422           0 :     return LEAVE_PAGE;
    3423             : }
    3424             : 
    3425             : // -----------------------------------------------------------------------
    3426             : 
    3427           0 : SfxTabPage* SvxCharTwoLinesPage::Create( Window* pParent, const SfxItemSet& rSet )
    3428             : {
    3429           0 :     return new SvxCharTwoLinesPage( pParent, rSet );
    3430             : }
    3431             : 
    3432             : // -----------------------------------------------------------------------
    3433             : 
    3434           0 : sal_uInt16* SvxCharTwoLinesPage::GetRanges()
    3435             : {
    3436           0 :     return pTwoLinesRanges;
    3437             : }
    3438             : 
    3439             : // -----------------------------------------------------------------------
    3440             : 
    3441           0 : void SvxCharTwoLinesPage::Reset( const SfxItemSet& rSet )
    3442             : {
    3443           0 :     m_pTwoLinesBtn->Check( sal_False );
    3444           0 :     sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_TWO_LINES );
    3445           0 :     SfxItemState eState = rSet.GetItemState( nWhich );
    3446             : 
    3447           0 :     if ( eState >= SFX_ITEM_DONTCARE )
    3448             :     {
    3449           0 :         const SvxTwoLinesItem& rItem = (SvxTwoLinesItem&)rSet.Get( nWhich );
    3450           0 :         m_pTwoLinesBtn->Check( rItem.GetValue() );
    3451             : 
    3452           0 :         if ( rItem.GetValue() )
    3453             :         {
    3454           0 :             SetBracket( rItem.GetStartBracket(), sal_True );
    3455           0 :             SetBracket( rItem.GetEndBracket(), sal_False );
    3456             :         }
    3457             :     }
    3458           0 :     TwoLinesHdl_Impl( NULL );
    3459             : 
    3460           0 :     SetPrevFontWidthScale( rSet );
    3461           0 : }
    3462             : 
    3463             : // -----------------------------------------------------------------------
    3464             : 
    3465           0 : sal_Bool SvxCharTwoLinesPage::FillItemSet( SfxItemSet& rSet )
    3466             : {
    3467           0 :     const SfxItemSet& rOldSet = GetItemSet();
    3468           0 :     sal_Bool bModified = sal_False, bChanged = sal_True;
    3469           0 :     sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_TWO_LINES );
    3470           0 :     const SfxPoolItem* pOld = GetOldItem( rSet, SID_ATTR_CHAR_TWO_LINES );
    3471           0 :     sal_Bool bOn = m_pTwoLinesBtn->IsChecked();
    3472           0 :     sal_Unicode cStart = ( bOn && m_pStartBracketLB->GetSelectEntryPos() > 0 )
    3473           0 :         ? m_pStartBracketLB->GetSelectEntry().GetChar(0) : 0;
    3474           0 :     sal_Unicode cEnd = ( bOn && m_pEndBracketLB->GetSelectEntryPos() > 0 )
    3475           0 :         ? m_pEndBracketLB->GetSelectEntry().GetChar(0) : 0;
    3476             : 
    3477           0 :     if ( pOld )
    3478             :     {
    3479           0 :         const SvxTwoLinesItem& rItem = *( (const SvxTwoLinesItem*)pOld );
    3480           0 :         if ( rItem.GetValue() ==  bOn &&
    3481           0 :              ( !bOn || ( rItem.GetStartBracket() == cStart && rItem.GetEndBracket() == cEnd ) ) )
    3482           0 :             bChanged = sal_False;
    3483             :     }
    3484             : 
    3485           0 :     if ( bChanged )
    3486             :     {
    3487           0 :         rSet.Put( SvxTwoLinesItem( bOn, cStart, cEnd, nWhich ) );
    3488           0 :         bModified = sal_True;
    3489             :     }
    3490           0 :     else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) )
    3491           0 :         CLEARTITEM;
    3492             : 
    3493           0 :     return bModified;
    3494             : }
    3495             : 
    3496           0 : void    SvxCharTwoLinesPage::UpdatePreview_Impl()
    3497             : {
    3498           0 :     sal_Unicode cStart = m_pStartBracketLB->GetSelectEntryPos() > 0
    3499           0 :         ? m_pStartBracketLB->GetSelectEntry().GetChar(0) : 0;
    3500           0 :     sal_Unicode cEnd = m_pEndBracketLB->GetSelectEntryPos() > 0
    3501           0 :         ? m_pEndBracketLB->GetSelectEntry().GetChar(0) : 0;
    3502           0 :     m_pPreviewWin->SetBrackets(cStart, cEnd);
    3503           0 :     m_pPreviewWin->SetTwoLines(m_pTwoLinesBtn->IsChecked());
    3504           0 :     m_pPreviewWin->Invalidate();
    3505           0 : }
    3506             : // -----------------------------------------------------------------------
    3507           0 : void SvxCharTwoLinesPage::SetPreviewBackgroundToCharacter()
    3508             : {
    3509           0 :     m_bPreviewBackgroundToCharacter = sal_True;
    3510           0 : }
    3511             : 
    3512             : // -----------------------------------------------------------------------
    3513           0 : void SvxCharTwoLinesPage::PageCreated (SfxAllItemSet aSet)
    3514             : {
    3515           0 :     SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,sal_False);
    3516           0 :     if (pFlagItem)
    3517             :     {
    3518           0 :         sal_uInt32 nFlags=pFlagItem->GetValue();
    3519           0 :         if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
    3520           0 :             SetPreviewBackgroundToCharacter();
    3521             :     }
    3522           6 : }
    3523             : 
    3524             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10