LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/cui/source/tabpages - chardlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 1905 0.0 %
Date: 2013-07-09 Functions: 0 124 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10