LCOV - code coverage report
Current view: top level - svx/source/dialog - fntctrl.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 755 0.0 %
Date: 2014-04-11 Functions: 0 54 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 <sfx2/dialoghelper.hxx>
      21             : #include <sfx2/viewsh.hxx>
      22             : #include <sfx2/printer.hxx>
      23             : #include <vcl/builder.hxx>
      24             : #include <vcl/metric.hxx>
      25             : #include <vcl/svapp.hxx>
      26             : #include <vcl/settings.hxx>
      27             : #include <unicode/uchar.h>
      28             : #include <com/sun/star/uno/Reference.h>
      29             : #include <com/sun/star/i18n/BreakIterator.hpp>
      30             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      31             : #include <comphelper/processfactory.hxx>
      32             : 
      33             : #include <com/sun/star/i18n/ScriptType.hpp>
      34             : 
      35             : #include <vector>
      36             : #include <deque>
      37             : #include <svtools/colorcfg.hxx>
      38             : #include <svtools/sampletext.hxx>
      39             : 
      40             : #include <svx/fntctrl.hxx>
      41             : #include <svx/dialogs.hrc>
      42             : #include <svx/sdasitm.hxx>
      43             : 
      44             : // Item set includes
      45             : #include <svl/itemset.hxx>
      46             : #include <svl/itempool.hxx>
      47             : #include <svl/stritem.hxx>
      48             : #include <svl/languageoptions.hxx>
      49             : 
      50             : #include <editeng/colritem.hxx>
      51             : #include <editeng/fontitem.hxx>
      52             : #include <editeng/editids.hrc>
      53             : #include <editeng/postitem.hxx>
      54             : #include <editeng/udlnitem.hxx>
      55             : #include <editeng/crossedoutitem.hxx>
      56             : #include <editeng/contouritem.hxx>
      57             : #include <editeng/wghtitem.hxx>
      58             : #include <editeng/fhgtitem.hxx>
      59             : #include <editeng/shdditem.hxx>
      60             : #include <editeng/escapementitem.hxx>
      61             : #include <editeng/wrlmitem.hxx>
      62             : #include <editeng/cmapitem.hxx>
      63             : #include <editeng/kernitem.hxx>
      64             : #include <editeng/brushitem.hxx>
      65             : #include <editeng/emphasismarkitem.hxx>
      66             : #include <editeng/charreliefitem.hxx>
      67             : #include <editeng/twolinesitem.hxx>
      68             : #include <editeng/charscaleitem.hxx>
      69             : #include <editeng/langitem.hxx>
      70             : 
      71             : // define ----------------------------------------------------------------
      72             : 
      73             : //TODO: remove this and calculate off the actual size of text, not
      74             : //an arbitrary number of characters
      75             : #define TEXT_WIDTH 80
      76             : #define ISITEMSET rSet.GetItemState(nWhich)>=SFX_ITEM_DEFAULT
      77             : 
      78             : using namespace ::com::sun::star::uno;
      79             : using namespace ::com::sun::star::lang;
      80             : using ::com::sun::star::i18n::XBreakIterator;
      81             : using ::com::sun::star::i18n::BreakIterator;
      82             : 
      83             : 
      84             : // small helper functions to set fonts
      85             : 
      86             : namespace
      87             : {
      88           0 :     void scaleFontWidth(Font& _rFont,const OutputDevice& rOutDev,long& _n100PercentFont)
      89             :     {
      90           0 :         _rFont.SetWidth( 0 );
      91           0 :         _n100PercentFont = rOutDev.GetFontMetric( _rFont ).GetWidth();
      92           0 :     }
      93             : 
      94           0 :     void initFont(Font& _rFont)
      95             :     {
      96           0 :         _rFont.SetTransparent(true);
      97           0 :         _rFont.SetAlign(ALIGN_BASELINE);
      98           0 :     }
      99             : 
     100           0 :     void setFontSize(Font& _rFont)
     101             :     {
     102           0 :         Size aSize( _rFont.GetSize() );
     103           0 :         aSize.Height() = ( aSize.Height() * 3 ) / 5;
     104           0 :         aSize.Width() = ( aSize.Width() * 3 ) / 5;
     105           0 :         _rFont.SetSize( aSize );
     106           0 :     }
     107             : 
     108           0 :     void calcFontHeightAnyAscent(OutputDevice* _pWin,const Font& _rFont,long& _nHeight,long& _nAscent)
     109             :     {
     110           0 :         if ( !_nHeight )
     111             :         {
     112           0 :             _pWin->SetFont( _rFont );
     113           0 :             FontMetric aMetric( _pWin->GetFontMetric() );
     114           0 :             _nHeight = aMetric.GetLineHeight();
     115           0 :             _nAscent = aMetric.GetAscent();
     116             :         }
     117           0 :     }
     118             : 
     119           0 :     void setFont( const SvxFont& rNewFont, SvxFont& rImplFont )
     120             :     {
     121           0 :         rImplFont = rNewFont;
     122           0 :         rImplFont.SetTransparent( true );
     123           0 :         rImplFont.SetAlign( ALIGN_BASELINE );
     124           0 :     }
     125             : 
     126             : }
     127             : 
     128             : 
     129             : 
     130             : // class FontPrevWin_Impl -----------------------------------------------
     131             : 
     132             : class FontPrevWin_Impl
     133             : {
     134             :     friend class SvxFontPrevWindow;
     135             : 
     136             :     SvxFont                         aFont;
     137             :     Printer*                        pPrinter;
     138             :     bool                        bDelPrinter;
     139             : 
     140             :     Reference < XBreakIterator >    xBreak;
     141             :     std::vector<sal_uIntPtr>        aTextWidth;
     142             :     std::deque<sal_Int32>           aScriptChg;
     143             :     std::vector<sal_uInt16>         aScriptType;
     144             :     SvxFont                         aCJKFont;
     145             :     SvxFont                         aCTLFont;
     146             :     OUString                        aText;
     147             :     OUString                        aScriptText;
     148             :     Color*                          pColor;
     149             :     Color*                          pBackColor;
     150             :     long                            nAscent;
     151             :     sal_Unicode                     cStartBracket;
     152             :     sal_Unicode                     cEndBracket;
     153             : 
     154             :     long                            n100PercentFontWidth;       // initial -1 -> not set yet
     155             :     long                            n100PercentFontWidthCJK;
     156             :     long                            n100PercentFontWidthCTL;
     157             :     sal_uInt16                      nFontWidthScale;
     158             : 
     159             :     bool                        bSelection      : 1,
     160             :                                     bGetSelection   : 1,
     161             :                                     bUseResText     : 1,
     162             :                                     bPreviewBackgroundToCharacter : 1,
     163             :                                     bTwoLines       : 1,
     164             :                                     bUseFontNameAsText : 1,
     165             :                                     bTextInited     : 1;
     166             : 
     167             :     bool m_bCJKEnabled;
     168             :     bool m_bCTLEnabled;
     169             : 
     170             : 
     171             : public:
     172           0 :     inline FontPrevWin_Impl() :
     173             :         pPrinter( NULL ), bDelPrinter( false ),
     174             :         pColor( NULL ), pBackColor( 0 ), nAscent( 0 ),
     175             :         cStartBracket( 0 ), cEndBracket( 0 ), nFontWidthScale( 100 ),
     176             :         bSelection( false ), bGetSelection( false ), bUseResText( false ),
     177             :         bPreviewBackgroundToCharacter( false ), bTwoLines( false ),
     178           0 :         bUseFontNameAsText( false ), bTextInited( false )
     179             :     {
     180           0 :         SvtLanguageOptions aLanguageOptions;
     181           0 :         m_bCJKEnabled = aLanguageOptions.IsAnyEnabled();
     182           0 :         m_bCTLEnabled = aLanguageOptions.IsCTLFontEnabled();
     183             : 
     184           0 :         Invalidate100PercentFontWidth();
     185           0 :     }
     186             : 
     187           0 :     inline ~FontPrevWin_Impl()
     188           0 :     {
     189           0 :         delete pColor;
     190           0 :         delete pBackColor;
     191           0 :         if( bDelPrinter )
     192           0 :             delete pPrinter;
     193           0 :     }
     194             : 
     195             :     void                CheckScript();
     196             :     Size                CalcTextSize( OutputDevice* pWin, OutputDevice* pPrt, const SvxFont &rFont );
     197             :     void                DrawPrev( OutputDevice* pWin, Printer* pPrt, Point &rPt, const SvxFont &rFont );
     198             : 
     199             :     bool                SetFontWidthScale( sal_uInt16 nScaleInPercent );
     200             :     inline void         Invalidate100PercentFontWidth();
     201             :     inline bool         Is100PercentFontWidthValid() const;
     202             :     void                ScaleFontWidth( const OutputDevice& rOutDev );
     203             :                             // scales rNonCJKFont and aCJKFont depending on nFontWidthScale and
     204             :                             //  sets the 100%-Font-Widths
     205             : };
     206             : 
     207           0 : inline void FontPrevWin_Impl::Invalidate100PercentFontWidth()
     208             : {
     209           0 :     n100PercentFontWidth = n100PercentFontWidthCJK = n100PercentFontWidthCTL = -1;
     210           0 : }
     211             : 
     212           0 : inline bool FontPrevWin_Impl::Is100PercentFontWidthValid() const
     213             : {
     214             :     DBG_ASSERT( ( n100PercentFontWidth == -1 && n100PercentFontWidthCJK == -1 ) ||
     215             :                 ( n100PercentFontWidth != -1 && n100PercentFontWidthCJK != -1 ) ||
     216             :                 ( n100PercentFontWidth == -1 && n100PercentFontWidthCTL == -1 ) ||
     217             :                 ( n100PercentFontWidth != -1 && n100PercentFontWidthCTL != -1 ),
     218             :                 "*FontPrevWin_Impl::Is100PercentFontWidthValid(): 100PercentFontWidth's not synchronous" );
     219           0 :     return n100PercentFontWidth != -1;
     220             : }
     221             : 
     222             : // class FontPrevWin_Impl -----------------------------------------------
     223             : 
     224             : /*
     225             :  * evalutates the scripttypes of the actual string.
     226             :  * Afterwards the positions of script change are notified in aScriptChg,
     227             :  * the scripttypes in aScriptType.
     228             :  * The aTextWidth array will be filled with zero.
     229             :  */
     230           0 : void FontPrevWin_Impl::CheckScript()
     231             : {
     232             :     assert(!aText.isEmpty()); // must have a preview text here!
     233           0 :     if (aText == aScriptText)
     234             :     {
     235           0 :         return; // already initialized
     236             :     }
     237             : 
     238           0 :     aScriptText = aText;
     239             : 
     240           0 :     aScriptChg.clear();
     241           0 :     aScriptType.clear();
     242           0 :     aTextWidth.clear();
     243             : 
     244           0 :     if( !xBreak.is() )
     245             :     {
     246           0 :         Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
     247           0 :         xBreak = BreakIterator::create(xContext);
     248             :     }
     249           0 :     sal_uInt16 nScript = xBreak->getScriptType( aText, 0 );
     250           0 :     sal_Int32 nChg = 0;
     251           0 :     if( com::sun::star::i18n::ScriptType::WEAK == nScript )
     252             :     {
     253           0 :         nChg = xBreak->endOfScript( aText, nChg, nScript );
     254           0 :         if (nChg < aText.getLength() && nChg >= 0)
     255           0 :             nScript = xBreak->getScriptType( aText, nChg );
     256             :         else
     257           0 :             nScript = com::sun::star::i18n::ScriptType::LATIN;
     258             :     }
     259             : 
     260             :     do
     261             :     {
     262           0 :         nChg = xBreak->endOfScript( aText, nChg, nScript );
     263           0 :         if (nChg < aText.getLength() && nChg > 0 &&
     264             :             (com::sun::star::i18n::ScriptType::WEAK ==
     265           0 :              xBreak->getScriptType(aText, nChg - 1)))
     266             :         {
     267           0 :             int8_t nType = u_charType(aText[nChg] );
     268           0 :             if (nType == U_NON_SPACING_MARK || nType == U_ENCLOSING_MARK ||
     269             :                 nType == U_COMBINING_SPACING_MARK )
     270             :             {
     271           0 :                 aScriptChg.push_back( nChg - 1 );
     272             :             }
     273             :             else
     274             :             {
     275           0 :                 aScriptChg.push_back( nChg );
     276             :             }
     277             :         }
     278             :         else
     279             :         {
     280           0 :             aScriptChg.push_back( nChg );
     281             :         }
     282           0 :         aScriptType.push_back( nScript );
     283           0 :         aTextWidth.push_back( 0 );
     284             : 
     285           0 :         if( nChg < aText.getLength() )
     286           0 :             nScript = xBreak->getScriptType( aText, nChg );
     287             :         else
     288           0 :             break;
     289           0 :     } while( true );
     290             : }
     291             : 
     292             : /*
     293             :  * Size FontPrevWin_Impl::CalcTextSize(..)
     294             :  * fills the aTextWidth array with the text width of every part
     295             :  * of the actual string without a script change inside.
     296             :  * For Latin parts the given rFont will be used,
     297             :  * for Asian parts the aCJKFont.
     298             :  * The returned size contains the whole string.
     299             :  * The member nAscent is calculated to the maximal ascent of all used fonts.
     300             :  */
     301             : 
     302           0 : Size FontPrevWin_Impl::CalcTextSize( OutputDevice* pWin, OutputDevice* _pPrinter,
     303             :     const SvxFont &rFont )
     304             : {
     305             :     sal_uInt16 nScript;
     306           0 :     sal_uInt16 nIdx = 0;
     307           0 :     sal_Int32 nStart = 0;
     308             :     sal_Int32 nEnd;
     309           0 :     size_t nCnt = aScriptChg.size();
     310           0 :     if( nCnt )
     311             :     {
     312           0 :         nEnd = aScriptChg[ nIdx ];
     313           0 :         nScript = aScriptType[ nIdx ];
     314             :     }
     315             :     else
     316             :     {
     317           0 :         nEnd = aText.getLength();
     318           0 :         nScript = com::sun::star::i18n::ScriptType::LATIN;
     319             :     }
     320           0 :     long nTxtWidth = 0;
     321           0 :     long nCJKHeight = 0;
     322           0 :     long nCTLHeight = 0;
     323           0 :     long nHeight = 0;
     324           0 :     nAscent = 0;
     325           0 :     long nCJKAscent = 0;
     326           0 :     long nCTLAscent = 0;
     327             : 
     328             :     do
     329             :     {
     330           0 :         const SvxFont& rFnt = (nScript==com::sun::star::i18n::ScriptType::ASIAN) ? aCJKFont : ((nScript==com::sun::star::i18n::ScriptType::COMPLEX) ? aCTLFont : rFont);
     331           0 :         sal_uIntPtr nWidth = rFnt.GetTxtSize( _pPrinter, aText, nStart, nEnd-nStart ).
     332           0 :                        Width();
     333           0 :         if (nIdx >= aTextWidth.size())
     334           0 :             break;
     335           0 :         aTextWidth[ nIdx++ ] = nWidth;
     336           0 :         nTxtWidth += nWidth;
     337           0 :         switch(nScript)
     338             :         {
     339             :             case com::sun::star::i18n::ScriptType::ASIAN:
     340           0 :                 calcFontHeightAnyAscent(pWin,aCJKFont,nCJKHeight,nCJKAscent);
     341           0 :                 break;
     342             :             case com::sun::star::i18n::ScriptType::COMPLEX:
     343           0 :                 calcFontHeightAnyAscent(pWin,aCTLFont,nCTLHeight,nCTLAscent);
     344           0 :                 break;
     345             :             default:
     346           0 :                 calcFontHeightAnyAscent(pWin,rFont,nHeight,nAscent);
     347             :         }
     348             : 
     349           0 :         if( nEnd < aText.getLength() && nIdx < nCnt )
     350             :         {
     351           0 :             nStart = nEnd;
     352           0 :             nEnd = aScriptChg[ nIdx ];
     353           0 :             nScript = aScriptType[ nIdx ];
     354             :         }
     355             :         else
     356           0 :             break;
     357             :     }
     358             :     while( true );
     359           0 :     nHeight -= nAscent;
     360           0 :     nCJKHeight -= nCJKAscent;
     361           0 :     nCTLHeight -= nCTLAscent;
     362           0 :     if( nHeight < nCJKHeight )
     363           0 :         nHeight = nCJKHeight;
     364           0 :     if( nAscent < nCJKAscent )
     365           0 :         nAscent = nCJKAscent;
     366           0 :     if( nHeight < nCTLHeight )
     367           0 :         nHeight = nCTLHeight;
     368           0 :     if( nAscent < nCTLAscent )
     369           0 :         nAscent = nCTLAscent;
     370           0 :     nHeight += nAscent;
     371             : 
     372           0 :     Size aTxtSize( nTxtWidth, nHeight );
     373           0 :     return aTxtSize;
     374             : }
     375             : 
     376             : /*
     377             :  * void FontPrevWin_Impl::DrawPrev(..)
     378             :  * calls SvxFont::DrawPrev(..) for every part of the string without a script
     379             :  * change inside, for Asian parts the aCJKFont will be used, otherwise the
     380             :  * given rFont.
     381             :  */
     382             : 
     383           0 : void FontPrevWin_Impl::DrawPrev( OutputDevice* pWin, Printer* _pPrinter,
     384             :     Point &rPt, const SvxFont &rFont )
     385             : {
     386           0 :     Font aOldFont = _pPrinter->GetFont();
     387             :     sal_uInt16 nScript;
     388           0 :     sal_uInt16 nIdx = 0;
     389           0 :     sal_Int32 nStart = 0;
     390             :     sal_Int32 nEnd;
     391           0 :     size_t nCnt = aScriptChg.size();
     392           0 :     if( nCnt )
     393             :     {
     394           0 :         nEnd = aScriptChg[ nIdx ];
     395           0 :         nScript = aScriptType[ nIdx ];
     396             :     }
     397             :     else
     398             :     {
     399           0 :         nEnd = aText.getLength();
     400           0 :         nScript = com::sun::star::i18n::ScriptType::LATIN;
     401             :     }
     402             :     do
     403             :     {
     404           0 :         const SvxFont& rFnt = (nScript==com::sun::star::i18n::ScriptType::ASIAN) ? aCJKFont : ((nScript==com::sun::star::i18n::ScriptType::COMPLEX) ? aCTLFont : rFont);
     405           0 :         _pPrinter->SetFont( rFnt );
     406             : 
     407           0 :         rFnt.DrawPrev( pWin, _pPrinter, rPt, aText, nStart, nEnd - nStart );
     408             : 
     409           0 :         rPt.X() += aTextWidth[ nIdx++ ];
     410           0 :         if( nEnd < aText.getLength() && nIdx < nCnt )
     411             :         {
     412           0 :             nStart = nEnd;
     413           0 :             nEnd = aScriptChg[ nIdx ];
     414           0 :             nScript = aScriptType[ nIdx ];
     415             :         }
     416             :         else
     417           0 :             break;
     418             :     }
     419             :     while( true );
     420           0 :     _pPrinter->SetFont( aOldFont );
     421           0 : }
     422             : 
     423             : 
     424             : 
     425           0 : bool FontPrevWin_Impl::SetFontWidthScale( sal_uInt16 nScale )
     426             : {
     427           0 :     if( nFontWidthScale != nScale )
     428             :     {
     429           0 :         nFontWidthScale = nScale;
     430           0 :         return true;
     431             :     }
     432             : 
     433           0 :     return false;
     434             : }
     435             : 
     436             : 
     437             : 
     438             : 
     439           0 : void FontPrevWin_Impl::ScaleFontWidth( const OutputDevice& rOutDev )
     440             : {
     441           0 :     if( !Is100PercentFontWidthValid() )
     442             :     {
     443           0 :         scaleFontWidth(aFont,rOutDev,n100PercentFontWidth);
     444           0 :         scaleFontWidth(aCJKFont,rOutDev,n100PercentFontWidthCJK);
     445           0 :         scaleFontWidth(aCTLFont,rOutDev,n100PercentFontWidthCTL);
     446             :     }
     447             : 
     448           0 :     aFont.SetWidth( n100PercentFontWidth * nFontWidthScale / 100 );
     449           0 :     aCJKFont.SetWidth( n100PercentFontWidthCJK * nFontWidthScale / 100 );
     450           0 :     aCTLFont.SetWidth( n100PercentFontWidthCTL * nFontWidthScale / 100 );
     451           0 : }
     452             : 
     453             : // class SvxFontPrevWindow -----------------------------------------------
     454             : 
     455           0 : void SvxFontPrevWindow::InitSettings( bool bForeground, bool bBackground )
     456             : {
     457           0 :     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
     458             : 
     459           0 :     if ( bForeground )
     460             :     {
     461           0 :         svtools::ColorConfig aColorConfig;
     462           0 :         Color aTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
     463             : 
     464           0 :         if ( IsControlForeground() )
     465           0 :             aTextColor = GetControlForeground();
     466           0 :         SetTextColor( aTextColor );
     467             :     }
     468             : 
     469           0 :     if ( bBackground )
     470             :     {
     471           0 :         if ( IsControlBackground() )
     472           0 :             SetBackground( GetControlBackground() );
     473             :         else
     474           0 :             SetBackground( rStyleSettings.GetWindowColor() );
     475             :     }
     476           0 :     Invalidate();
     477           0 : }
     478             : 
     479             : 
     480             : 
     481           0 : void SvxFontPrevWindow::Init()
     482             : {
     483           0 :     pImpl = new FontPrevWin_Impl;
     484           0 :     SfxViewShell* pSh = SfxViewShell::Current();
     485             : 
     486           0 :     if ( pSh )
     487           0 :         pImpl->pPrinter = pSh->GetPrinter();
     488             : 
     489           0 :     if ( !pImpl->pPrinter )
     490             :     {
     491           0 :         pImpl->pPrinter = new Printer;
     492           0 :         pImpl->bDelPrinter = true;
     493             :     }
     494           0 :     SetMapMode( MapMode( MAP_TWIP ) );
     495           0 :     initFont(pImpl->aFont);
     496           0 :     initFont(pImpl->aCJKFont);
     497           0 :     initFont(pImpl->aCTLFont);
     498           0 :     InitSettings( true, true );
     499           0 :     SetBorderStyle( WINDOW_BORDER_MONO );
     500           0 : }
     501             : 
     502           0 : SvxFontPrevWindow::SvxFontPrevWindow( Window* pParent, const ResId& rId ) :
     503           0 :     Window( pParent, rId )
     504             : {
     505           0 :     Init();
     506           0 : }
     507             : 
     508           0 : SvxFontPrevWindow::SvxFontPrevWindow(Window* pParent, WinBits nStyle)
     509           0 :     : Window(pParent, nStyle)
     510             : {
     511           0 :     Init();
     512           0 : }
     513             : 
     514           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxFontPrevWindow(Window *pParent, VclBuilder::stringmap &rMap)
     515             : {
     516           0 :     WinBits nWinStyle = 0;
     517           0 :     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     518           0 :     if (!sBorder.isEmpty())
     519           0 :         nWinStyle |= WB_BORDER;
     520           0 :     SvxFontPrevWindow *pWindow = new SvxFontPrevWindow(pParent, nWinStyle);
     521           0 :     return pWindow;
     522             : }
     523             : 
     524           0 : SvxFontPrevWindow::~SvxFontPrevWindow()
     525             : {
     526           0 :     delete pImpl;
     527           0 : }
     528             : 
     529             : 
     530           0 : SvxFont& SvxFontPrevWindow::GetCTLFont()
     531             : {
     532           0 :     return pImpl->aCTLFont;
     533             : }
     534             : 
     535             : 
     536             : 
     537           0 : SvxFont& SvxFontPrevWindow::GetCJKFont()
     538             : {
     539           0 :     return pImpl->aCJKFont;
     540             : }
     541             : 
     542             : 
     543             : 
     544           0 : void SvxFontPrevWindow::StateChanged( StateChangedType nType )
     545             : {
     546           0 :     if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
     547           0 :         InitSettings( true, false );
     548           0 :     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
     549           0 :         InitSettings( false, true );
     550             : 
     551           0 :     Window::StateChanged( nType );
     552           0 :     Invalidate();
     553           0 : }
     554             : 
     555             : 
     556             : 
     557           0 : void SvxFontPrevWindow::DataChanged( const DataChangedEvent& rDCEvt )
     558             : {
     559           0 :     if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
     560           0 :         InitSettings( true, true );
     561             :     else
     562           0 :         Window::DataChanged( rDCEvt );
     563           0 : }
     564             : 
     565           0 : SvxFont& SvxFontPrevWindow::GetFont()
     566             : {
     567           0 :     pImpl->Invalidate100PercentFontWidth();     // because the user might change the size
     568           0 :     return pImpl->aFont;
     569             : }
     570             : 
     571           0 : const SvxFont& SvxFontPrevWindow::GetFont() const
     572             : {
     573           0 :     return pImpl->aFont;
     574             : }
     575             : 
     576             : 
     577             : 
     578           0 : void SvxFontPrevWindow::SetPreviewText( const OUString& rString )
     579             : {
     580           0 :     pImpl->aText = rString;
     581           0 :     pImpl->bTextInited = true;
     582           0 : }
     583             : 
     584             : 
     585             : 
     586           0 : void SvxFontPrevWindow::SetFontNameAsPreviewText()
     587             : {
     588           0 :     pImpl->bUseFontNameAsText = true;
     589           0 : }
     590             : 
     591             : 
     592             : 
     593           0 : void SvxFontPrevWindow::SetFont( const SvxFont& rNormalOutFont, const SvxFont& rCJKOutFont, const SvxFont& rCTLFont )
     594             : {
     595           0 :     setFont( rNormalOutFont, pImpl->aFont );
     596           0 :     setFont( rCJKOutFont, pImpl->aCJKFont );
     597           0 :     setFont( rCTLFont, pImpl->aCTLFont );
     598             : 
     599             : 
     600           0 :     pImpl->Invalidate100PercentFontWidth();
     601           0 :     Invalidate();
     602           0 : }
     603             : 
     604             : 
     605             : 
     606           0 : void SvxFontPrevWindow::SetColor(const Color &rColor)
     607             : {
     608           0 :     delete pImpl->pColor;
     609           0 :     pImpl->pColor = new Color( rColor );
     610           0 :     Invalidate();
     611           0 : }
     612             : 
     613             : 
     614           0 : void SvxFontPrevWindow::ResetColor()
     615             : {
     616           0 :     delete pImpl->pColor;
     617           0 :     pImpl->pColor = 0;
     618           0 :     Invalidate();
     619           0 : }
     620             : 
     621             : 
     622             : 
     623           0 : void SvxFontPrevWindow::SetBackColor(const Color &rColor)
     624             : {
     625           0 :     delete pImpl->pBackColor;
     626           0 :     pImpl->pBackColor = new Color( rColor );
     627           0 :     Invalidate();
     628           0 : }
     629             : 
     630             : 
     631             : 
     632           0 : void SvxFontPrevWindow::UseResourceText( bool bUse )
     633             : {
     634           0 :     pImpl->bUseResText = bUse;
     635           0 : }
     636             : 
     637             : 
     638             : 
     639           0 : void SvxFontPrevWindow::Paint( const Rectangle& )
     640             : {
     641           0 :     Printer* pPrinter = pImpl->pPrinter;
     642           0 :     const SvxFont& rFont = pImpl->aFont;
     643           0 :     const SvxFont& rCJKFont = pImpl->aCJKFont;
     644           0 :     const SvxFont& rCTLFont = pImpl->aCTLFont;
     645             : 
     646           0 :     if ( !IsEnabled() )
     647             :     {
     648           0 :         const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
     649           0 :         const Size aLogSize( GetOutputSize() );
     650             : 
     651           0 :         Rectangle aRect( Point( 0, 0 ), aLogSize );
     652           0 :         SetLineColor();
     653           0 :         SetFillColor( rStyleSettings.GetWindowColor() );
     654           0 :         DrawRect( aRect );
     655             :     }
     656             :     else
     657             :     {
     658           0 :         if ( pImpl->bUseResText )
     659           0 :             pImpl->aText = GetText();
     660           0 :         else if ( !pImpl->bSelection && !pImpl->bTextInited )
     661             :         {
     662             :             using namespace com::sun::star::i18n::ScriptType;
     663             : 
     664           0 :             SfxViewShell* pSh = SfxViewShell::Current();
     665             : 
     666           0 :             if ( pSh && !pImpl->bGetSelection && !pImpl->bUseFontNameAsText )
     667             :             {
     668           0 :                 pImpl->aText = pSh->GetSelectionText();
     669           0 :                 pImpl->bGetSelection = true;
     670           0 :                 pImpl->bSelection = !pImpl->aText.isEmpty();
     671             : 
     672             :             }
     673             : 
     674           0 :             if ( !pImpl->bSelection || pImpl->bUseFontNameAsText )
     675             :             {
     676             :                 //If we're showing multiple sample texts, then they're all
     677             :                 //sample texts. If only showing Latin, continue to use
     678             :                 //the fontname as the preview
     679           0 :                 if ((pImpl->m_bCJKEnabled) || (pImpl->m_bCTLEnabled))
     680           0 :                     pImpl->aText = makeRepresentativeTextForFont(LATIN, rFont);
     681             :                 else
     682           0 :                     pImpl->aText = rFont.GetName();
     683             : 
     684           0 :                 if (pImpl->m_bCJKEnabled)
     685             :                 {
     686           0 :                     if (!pImpl->aText.isEmpty())
     687           0 :                         pImpl->aText += "   ";
     688           0 :                     pImpl->aText += makeRepresentativeTextForFont(ASIAN, rCJKFont);
     689             : 
     690             :                 }
     691           0 :                 if (pImpl->m_bCTLEnabled)
     692             :                 {
     693           0 :                     if (!pImpl->aText.isEmpty())
     694           0 :                         pImpl->aText += "   ";
     695           0 :                     pImpl->aText += makeRepresentativeTextForFont(COMPLEX, rCTLFont);
     696             :                 }
     697             :             }
     698             : 
     699           0 :             if ( pImpl->aText.isEmpty() )
     700           0 :                 pImpl->aText = GetText();
     701             : 
     702           0 :             if (pImpl->aText.isEmpty())
     703             :             {   // fdo#58427: still no text? let's try that one...
     704           0 :                 pImpl->aText = makeRepresentativeTextForFont(LATIN, rFont);
     705             :             }
     706             : 
     707             :             // remove line feeds and carriage returns from string
     708           0 :             bool bNotEmpty = false;
     709           0 :             for ( sal_Int32 i = 0; i < pImpl->aText.getLength(); ++i )
     710             :             {
     711           0 :                 if ( 0xa == pImpl->aText[i] || 0xd == pImpl->aText[i] )
     712           0 :                      pImpl->aText = pImpl->aText.replaceAt( i, 1, " " );
     713             :                 else
     714           0 :                     bNotEmpty = true;
     715             :             }
     716           0 :             if ( !bNotEmpty )
     717           0 :                 pImpl->aText = GetText();
     718             : 
     719           0 :             if ( pImpl->aText.getLength() > (TEXT_WIDTH-1) )
     720             :             {
     721           0 :                 sal_Int32 nSpaceIdx = pImpl->aText.indexOf(" ", TEXT_WIDTH);
     722           0 :                 if (nSpaceIdx != -1)
     723           0 :                     pImpl->aText = pImpl->aText.copy(0, nSpaceIdx);
     724             :             }
     725             :         }
     726             : 
     727             :         // calculate text width scaling
     728           0 :         pImpl->ScaleFontWidth( *this/*, rFont*/ );
     729             : 
     730           0 :         pImpl->CheckScript();
     731           0 :         Size aTxtSize = pImpl->CalcTextSize( this, pPrinter, rFont );
     732             : 
     733           0 :         const Size aLogSize( GetOutputSize() );
     734             : 
     735           0 :         long nX = aLogSize.Width()  / 2 - aTxtSize.Width() / 2;
     736           0 :         long nY = aLogSize.Height() / 2 - aTxtSize.Height() / 2;
     737             : 
     738           0 :         if ( nY + pImpl->nAscent > aLogSize.Height() )
     739           0 :             nY = aLogSize.Height() - pImpl->nAscent;
     740             : 
     741           0 :         if ( pImpl->pBackColor )
     742             :         {
     743           0 :             Rectangle aRect( Point( 0, 0 ), aLogSize );
     744           0 :             Color aLineCol = GetLineColor();
     745           0 :             Color aFillCol = GetFillColor();
     746           0 :             SetLineColor();
     747           0 :             SetFillColor( *pImpl->pBackColor );
     748           0 :             DrawRect( aRect );
     749           0 :             SetLineColor( aLineCol );
     750           0 :             SetFillColor( aFillCol );
     751             :         }
     752           0 :         if ( pImpl->pColor )
     753             :         {
     754           0 :             Rectangle aRect( Point( nX, nY ), aTxtSize );
     755           0 :             Color aLineCol = GetLineColor();
     756           0 :             Color aFillCol = GetFillColor();
     757           0 :             SetLineColor();
     758           0 :             SetFillColor( *pImpl->pColor );
     759           0 :             DrawRect( aRect );
     760           0 :             SetLineColor( aLineCol );
     761           0 :             SetFillColor( aFillCol );
     762             :         }
     763             : 
     764           0 :         long nStdAscent = pImpl->nAscent;
     765           0 :         nY += nStdAscent;
     766             : 
     767           0 :         if (IsTwoLines())
     768             :         {
     769           0 :             SvxFont aSmallFont( rFont );
     770           0 :             Size aOldSize = pImpl->aCJKFont.GetSize();
     771           0 :             setFontSize(aSmallFont);
     772           0 :             setFontSize(pImpl->aCJKFont);
     773             : 
     774           0 :             long nStartBracketWidth = 0;
     775           0 :             long nEndBracketWidth = 0;
     776           0 :             long nTextWidth = 0;
     777           0 :             if(pImpl->cStartBracket)
     778             :             {
     779           0 :                 OUString sBracket(pImpl->cStartBracket);
     780           0 :                 nStartBracketWidth = rFont.GetTxtSize( pPrinter, sBracket ).Width();
     781             :             }
     782           0 :             if(pImpl->cEndBracket)
     783             :             {
     784           0 :                 OUString sBracket(pImpl->cEndBracket);
     785           0 :                 nEndBracketWidth = rFont.GetTxtSize( pPrinter, sBracket ).Width();
     786             :             }
     787           0 :             nTextWidth = pImpl->CalcTextSize( this, pPrinter, aSmallFont ).Width();
     788           0 :             long nResultWidth = nStartBracketWidth;
     789           0 :             nResultWidth += nEndBracketWidth;
     790           0 :             nResultWidth += nTextWidth;
     791             : 
     792           0 :             long _nX = (aLogSize.Width() - nResultWidth) / 2;
     793           0 :             DrawLine( Point( 0,  nY ), Point( _nX, nY ) );
     794           0 :             DrawLine( Point( _nX + nResultWidth, nY ), Point( aLogSize.Width(), nY ) );
     795             : 
     796           0 :             long nSmallAscent = pImpl->nAscent;
     797           0 :             long nOffset = (nStdAscent - nSmallAscent ) / 2;
     798             : 
     799           0 :             if(pImpl->cStartBracket)
     800             :             {
     801           0 :                 OUString sBracket(pImpl->cStartBracket);
     802           0 :                 rFont.DrawPrev( this, pPrinter, Point( _nX, nY - nOffset - 4), sBracket );
     803           0 :                 _nX += nStartBracketWidth;
     804             :             }
     805             : 
     806           0 :             Point aTmpPoint1( _nX, nY - nSmallAscent - 2 );
     807           0 :             Point aTmpPoint2( _nX, nY );
     808           0 :             pImpl->DrawPrev( this, pPrinter, aTmpPoint1, aSmallFont );
     809           0 :             pImpl->DrawPrev( this, pPrinter, aTmpPoint2, aSmallFont );
     810             : 
     811           0 :             _nX += nTextWidth;
     812           0 :             if(pImpl->cEndBracket)
     813             :             {
     814           0 :                 Point aTmpPoint( _nX + 1, nY - nOffset - 4);
     815           0 :                 OUString sBracket(pImpl->cEndBracket);
     816           0 :                 rFont.DrawPrev( this, pPrinter, aTmpPoint, sBracket );
     817             :             }
     818           0 :             pImpl->aCJKFont.SetSize( aOldSize );
     819             :         }
     820             :         else
     821             :         {
     822             : 
     823           0 :             Color aLineCol = GetLineColor();
     824             : 
     825           0 :             SetLineColor( rFont.GetColor() );
     826           0 :             DrawLine( Point( 0,  nY ), Point( nX, nY ) );
     827           0 :             DrawLine( Point( nX + aTxtSize.Width(), nY ), Point( aLogSize.Width(), nY ) );
     828           0 :             SetLineColor( aLineCol );
     829             : 
     830           0 :             Point aTmpPoint( nX, nY );
     831           0 :             pImpl->DrawPrev( this, pPrinter, aTmpPoint, rFont );
     832             :         }
     833             :     }
     834           0 : }
     835             : 
     836           0 : bool SvxFontPrevWindow::IsTwoLines() const
     837             : {
     838           0 :     return pImpl->bTwoLines;
     839             : }
     840             : 
     841           0 : void SvxFontPrevWindow::SetTwoLines(bool bSet)
     842             : {
     843           0 :     pImpl->bTwoLines = bSet;
     844           0 : }
     845             : 
     846           0 : void SvxFontPrevWindow::SetBrackets(sal_Unicode cStart, sal_Unicode cEnd)
     847             : {
     848           0 :     pImpl->cStartBracket = cStart;
     849           0 :     pImpl->cEndBracket = cEnd;
     850           0 : }
     851             : 
     852             : 
     853             : 
     854           0 : void SvxFontPrevWindow::SetFontWidthScale( sal_uInt16 n )
     855             : {
     856           0 :     if( pImpl->SetFontWidthScale( n ) )
     857           0 :         Invalidate();
     858           0 : }
     859             : 
     860             : 
     861             : 
     862           0 : void SvxFontPrevWindow::AutoCorrectFontColor( void )
     863             : {
     864           0 :     Color   aFontColor( GetTextColor() );
     865             : 
     866           0 :     if( COL_AUTO == pImpl->aFont.GetColor().GetColor() )
     867           0 :         pImpl->aFont.SetColor( aFontColor );
     868             : 
     869           0 :     if( COL_AUTO == pImpl->aCJKFont.GetColor().GetColor() )
     870           0 :         pImpl->aCJKFont.SetColor( aFontColor );
     871             : 
     872           0 :     if( COL_AUTO == pImpl->aCTLFont.GetColor().GetColor() )
     873           0 :         pImpl->aCTLFont.SetColor( aFontColor );
     874           0 : }
     875             : 
     876             : 
     877             : 
     878           0 : static bool GetWhich (const SfxItemSet &rSet, sal_uInt16 nSlot, sal_uInt16 &rWhich)
     879             : {
     880           0 :     rWhich = rSet.GetPool()->GetWhich( nSlot, true );
     881           0 :     return rSet.GetItemState(rWhich) >= SFX_ITEM_DEFAULT;
     882             : }
     883             : 
     884           0 : static void SetPrevFont( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont )
     885             : {
     886             :     sal_uInt16 nWhich;
     887           0 :     if (GetWhich ( rSet, nSlot, nWhich ) )
     888             :     {
     889           0 :         const SvxFontItem& rFontItem = ( SvxFontItem& ) rSet.Get( nWhich );
     890           0 :         rFont.SetFamily( rFontItem.GetFamily() );
     891           0 :         rFont.SetName( rFontItem.GetFamilyName() );
     892           0 :         rFont.SetPitch( rFontItem.GetPitch() );
     893           0 :         rFont.SetCharSet( rFontItem.GetCharSet() );
     894           0 :         rFont.SetStyleName( rFontItem.GetStyleName() );
     895             :     }
     896           0 : }
     897             : 
     898           0 : static void SetPrevFontStyle( const SfxItemSet& rSet, sal_uInt16 nPosture, sal_uInt16 nWeight, SvxFont& rFont )
     899             : {
     900             :     sal_uInt16 nWhich;
     901           0 :     if( GetWhich( rSet, nPosture, nWhich ) )
     902             :     {
     903           0 :         const SvxPostureItem& rItem = ( const SvxPostureItem& ) rSet.Get( nWhich );
     904           0 :         rFont.SetItalic( ( FontItalic ) rItem.GetValue() != ITALIC_NONE ? ITALIC_NORMAL : ITALIC_NONE );
     905             :     }
     906             : 
     907           0 :     if( GetWhich( rSet, nWeight, nWhich ) )
     908             :     {
     909           0 :         const SvxWeightItem& rItem = ( const SvxWeightItem& ) rSet.Get( nWhich );
     910           0 :         rFont.SetWeight( ( FontWeight ) rItem.GetValue() != WEIGHT_NORMAL ? WEIGHT_BOLD : WEIGHT_NORMAL );
     911             :     }
     912           0 : }
     913             : 
     914           0 : void SvxFontPrevWindow::SetFontSize( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont )
     915             : {
     916             :     sal_uInt16 nWhich;
     917             :     long nH;
     918           0 :     if( GetWhich( rSet, nSlot, nWhich ) )
     919             :     {
     920           0 :         nH = LogicToLogic( ( ( SvxFontHeightItem& ) rSet.Get( nWhich ) ).GetHeight(),
     921           0 :                             ( MapUnit ) rSet.GetPool()->GetMetric( nWhich ),
     922           0 :                             MAP_TWIP );
     923             :     }
     924             :     else
     925           0 :         nH = 240;   // as default 12pt
     926             : 
     927           0 :     rFont.SetSize( Size( 0, nH ) );
     928           0 : }
     929             : 
     930           0 : void SvxFontPrevWindow::SetFontLang(const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont)
     931             : {
     932             :     sal_uInt16 nWhich;
     933             :     LanguageType nLang;
     934           0 :     if( GetWhich( rSet, nSlot, nWhich ) )
     935           0 :         nLang = static_cast<const SvxLanguageItem&>(rSet.Get(nWhich)).GetLanguage();
     936             :     else
     937           0 :         nLang = LANGUAGE_NONE;
     938           0 :     rFont.SetLanguage(nLang);
     939           0 : }
     940             : 
     941           0 : static void SetPrevFontEscapement(SvxFont& _rFont, sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
     942             : {
     943           0 :     _rFont.SetPropr( nProp );
     944           0 :     _rFont.SetProprRel( nEscProp );
     945           0 :     _rFont.SetEscapement( nEsc );
     946           0 : }
     947             : 
     948           0 : void SvxFontPrevWindow::SetFromItemSet( const SfxItemSet &rSet,
     949             :                     bool bPreviewBackgroundToCharacter )
     950             : {
     951             :     sal_uInt16 nWhich;
     952           0 :     SvxFont& rFont = GetFont();
     953           0 :     SvxFont& rCJKFont = GetCJKFont();
     954           0 :     SvxFont& rCTLFont = GetCTLFont();
     955             : 
     956             :     // Preview string
     957           0 :     if( GetWhich( rSet, SID_CHAR_DLG_PREVIEW_STRING, nWhich ) )
     958             :     {
     959           0 :         const SfxStringItem& rItem = ( SfxStringItem& ) rSet.Get( nWhich );
     960           0 :         OUString aString = rItem.GetValue();
     961           0 :         if( !aString.isEmpty() )
     962           0 :             SetPreviewText( aString );
     963             :         else
     964           0 :             SetFontNameAsPreviewText();
     965             :     }
     966             : 
     967             :     // Underline
     968             :     FontUnderline eUnderline;
     969           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_UNDERLINE, nWhich ) )
     970             :     {
     971           0 :         const SvxUnderlineItem& rItem = ( SvxUnderlineItem& ) rSet.Get( nWhich );
     972           0 :         eUnderline = ( FontUnderline ) rItem.GetValue();
     973           0 :         SetTextLineColor( rItem.GetColor() );
     974             :     }
     975             :     else
     976           0 :         eUnderline = UNDERLINE_NONE;
     977             : 
     978           0 :     rFont.SetUnderline( eUnderline );
     979           0 :     rCJKFont.SetUnderline( eUnderline );
     980           0 :     rCTLFont.SetUnderline( eUnderline );
     981             : 
     982             :     // Overline
     983             :     FontUnderline eOverline;
     984           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_OVERLINE, nWhich ) )
     985             :     {
     986           0 :         const SvxOverlineItem& rItem = ( SvxOverlineItem& ) rSet.Get( nWhich );
     987           0 :         eOverline = ( FontUnderline ) rItem.GetValue();
     988           0 :         SetOverlineColor( rItem.GetColor() );
     989             :     }
     990             :     else
     991           0 :         eOverline = UNDERLINE_NONE;
     992             : 
     993           0 :     rFont.SetOverline( eOverline );
     994           0 :     rCJKFont.SetOverline( eOverline );
     995           0 :     rCTLFont.SetOverline( eOverline );
     996             : 
     997             :     //  Strikeout
     998             :     FontStrikeout eStrikeout;
     999           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_STRIKEOUT, nWhich ) )
    1000             :     {
    1001           0 :         const SvxCrossedOutItem& rItem = ( SvxCrossedOutItem& ) rSet.Get( nWhich );
    1002           0 :         eStrikeout = ( FontStrikeout ) rItem.GetValue();
    1003             :     }
    1004             :     else
    1005           0 :         eStrikeout = STRIKEOUT_NONE;
    1006             : 
    1007           0 :     rFont.SetStrikeout( eStrikeout );
    1008           0 :     rCJKFont.SetStrikeout( eStrikeout );
    1009           0 :     rCTLFont.SetStrikeout( eStrikeout );
    1010             : 
    1011             :     // WordLineMode
    1012           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_WORDLINEMODE, nWhich ) )
    1013             :     {
    1014           0 :         const SvxWordLineModeItem& rItem = ( SvxWordLineModeItem& ) rSet.Get( nWhich );
    1015           0 :         rFont.SetWordLineMode( rItem.GetValue() );
    1016           0 :         rCJKFont.SetWordLineMode( rItem.GetValue() );
    1017           0 :         rCTLFont.SetWordLineMode( rItem.GetValue() );
    1018             :     }
    1019             : 
    1020             :     // Emphasis
    1021           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_EMPHASISMARK, nWhich ) )
    1022             :     {
    1023           0 :         const SvxEmphasisMarkItem& rItem = ( SvxEmphasisMarkItem& ) rSet.Get( nWhich );
    1024           0 :         FontEmphasisMark eMark = rItem.GetEmphasisMark();
    1025           0 :         rFont.SetEmphasisMark( eMark );
    1026           0 :         rCJKFont.SetEmphasisMark( eMark );
    1027           0 :         rCTLFont.SetEmphasisMark( eMark );
    1028             :     }
    1029             : 
    1030             :     // Relief
    1031           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_RELIEF, nWhich ) )
    1032             :     {
    1033           0 :         const SvxCharReliefItem& rItem = ( SvxCharReliefItem& ) rSet.Get( nWhich );
    1034           0 :         FontRelief eFontRelief = ( FontRelief ) rItem.GetValue();
    1035           0 :         rFont.SetRelief( eFontRelief );
    1036           0 :         rCJKFont.SetRelief( eFontRelief );
    1037           0 :         rCTLFont.SetRelief( eFontRelief );
    1038             :     }
    1039             : 
    1040             :     // Effects
    1041           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_CASEMAP, nWhich ) )
    1042             :     {
    1043           0 :         const SvxCaseMapItem& rItem = ( SvxCaseMapItem& ) rSet.Get( nWhich );
    1044           0 :         SvxCaseMap eCaseMap = ( SvxCaseMap ) rItem.GetValue();
    1045           0 :         rFont.SetCaseMap( eCaseMap );
    1046           0 :         rCJKFont.SetCaseMap( eCaseMap );
    1047             :         // #i78474# small caps do not exist in CTL fonts
    1048           0 :         rCTLFont.SetCaseMap( eCaseMap == SVX_CASEMAP_KAPITAELCHEN ? SVX_CASEMAP_NOT_MAPPED : eCaseMap );
    1049             :     }
    1050             : 
    1051             :     // Outline
    1052           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_CONTOUR, nWhich ) )
    1053             :     {
    1054           0 :         const SvxContourItem& rItem = ( SvxContourItem& ) rSet.Get( nWhich );
    1055           0 :         sal_Bool bOutline = rItem.GetValue();
    1056           0 :         rFont.SetOutline( bOutline );
    1057           0 :         rCJKFont.SetOutline( bOutline );
    1058           0 :         rCTLFont.SetOutline( bOutline );
    1059             :     }
    1060             : 
    1061             :     // Shadow
    1062           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_SHADOWED, nWhich ) )
    1063             :     {
    1064           0 :         const SvxShadowedItem& rItem = ( SvxShadowedItem& ) rSet.Get( nWhich );
    1065           0 :         sal_Bool bShadow = rItem.GetValue();
    1066           0 :         rFont.SetShadow( bShadow );
    1067           0 :         rCJKFont.SetShadow( bShadow );
    1068           0 :         rCTLFont.SetShadow( bShadow );
    1069             :     }
    1070             : 
    1071             :     // Background
    1072             :     sal_Bool bTransparent;
    1073           0 :     if( GetWhich( rSet, bPreviewBackgroundToCharacter ? SID_ATTR_BRUSH : SID_ATTR_BRUSH_CHAR, nWhich ) )
    1074             :     {
    1075           0 :          const SvxBrushItem& rBrush = ( SvxBrushItem& ) rSet.Get( nWhich );
    1076           0 :          const Color& rColor = rBrush.GetColor();
    1077           0 :          bTransparent = rColor.GetTransparency() > 0;
    1078           0 :          rFont.SetFillColor( rColor );
    1079           0 :          rCJKFont.SetFillColor( rColor );
    1080           0 :          rCTLFont.SetFillColor( rColor );
    1081             :     }
    1082             :     else
    1083           0 :         bTransparent = TRUE;
    1084             : 
    1085           0 :     rFont.SetTransparent( bTransparent );
    1086           0 :     rCJKFont.SetTransparent( bTransparent );
    1087           0 :     rCTLFont.SetTransparent( bTransparent );
    1088             : 
    1089           0 :     Color aBackCol( COL_TRANSPARENT );
    1090           0 :     if( !bPreviewBackgroundToCharacter )
    1091             :     {
    1092           0 :         if( GetWhich( rSet, SID_ATTR_BRUSH, nWhich ) )
    1093             :         {
    1094           0 :             const SvxBrushItem& rBrush = ( SvxBrushItem& ) rSet.Get( nWhich );
    1095           0 :             if( GPOS_NONE == rBrush.GetGraphicPos() )
    1096           0 :                 aBackCol = rBrush.GetColor();
    1097             :         }
    1098             :     }
    1099           0 :     SetBackColor( aBackCol );
    1100             : 
    1101             :     // Font
    1102           0 :     SetPrevFont( rSet, SID_ATTR_CHAR_FONT, rFont );
    1103           0 :     SetPrevFont( rSet, SID_ATTR_CHAR_CJK_FONT, rCJKFont );
    1104           0 :     SetPrevFont( rSet, SID_ATTR_CHAR_CTL_FONT, rCTLFont );
    1105             : 
    1106             :     // Style
    1107           0 :     SetPrevFontStyle( rSet, SID_ATTR_CHAR_POSTURE, SID_ATTR_CHAR_WEIGHT, rFont );
    1108           0 :     SetPrevFontStyle( rSet, SID_ATTR_CHAR_CJK_POSTURE, SID_ATTR_CHAR_CJK_WEIGHT, rCJKFont );
    1109           0 :     SetPrevFontStyle( rSet, SID_ATTR_CHAR_CTL_POSTURE, SID_ATTR_CHAR_CTL_WEIGHT, rCTLFont );
    1110             : 
    1111             :     // Size
    1112           0 :     SetFontSize( rSet, SID_ATTR_CHAR_FONTHEIGHT, rFont );
    1113           0 :     SetFontSize( rSet, SID_ATTR_CHAR_CJK_FONTHEIGHT, rCJKFont );
    1114           0 :     SetFontSize( rSet, SID_ATTR_CHAR_CTL_FONTHEIGHT, rCTLFont );
    1115             : 
    1116             :     // Language
    1117           0 :     SetFontLang( rSet, SID_ATTR_CHAR_LANGUAGE, rFont );
    1118           0 :     SetFontLang( rSet, SID_ATTR_CHAR_CJK_LANGUAGE, rCJKFont );
    1119           0 :     SetFontLang( rSet, SID_ATTR_CHAR_CTL_LANGUAGE, rCTLFont );
    1120             : 
    1121             :     // Color
    1122           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_COLOR, nWhich ) )
    1123             :     {
    1124           0 :         const SvxColorItem& rItem = ( SvxColorItem& ) rSet.Get( nWhich );
    1125           0 :         Color aCol( rItem.GetValue() );
    1126           0 :         rFont.SetColor( aCol );
    1127             : 
    1128           0 :         rCJKFont.SetColor( aCol );
    1129           0 :         rCTLFont.SetColor( aCol );
    1130             : 
    1131           0 :         AutoCorrectFontColor(); // handle color COL_AUTO
    1132             :     }
    1133             : 
    1134             :     // Kerning
    1135           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_KERNING, nWhich ) )
    1136             :     {
    1137           0 :         const SvxKerningItem& rItem = ( SvxKerningItem& ) rSet.Get( nWhich );
    1138             :         short nKern = ( short )
    1139           0 :                         LogicToLogic( rItem.GetValue(), ( MapUnit ) rSet.GetPool()->GetMetric( nWhich ), MAP_TWIP );
    1140           0 :         rFont.SetFixKerning( nKern );
    1141           0 :         rCJKFont.SetFixKerning( nKern );
    1142           0 :         rCTLFont.SetFixKerning( nKern );
    1143             :     }
    1144             : 
    1145             :     // Escapement
    1146           0 :     const sal_uInt8 nProp = 100;
    1147             :     short nEsc;
    1148             :     sal_uInt8 nEscProp;
    1149           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_ESCAPEMENT, nWhich ) )
    1150             :     {
    1151           0 :         const SvxEscapementItem& rItem = ( SvxEscapementItem& ) rSet.Get( nWhich );
    1152           0 :         nEsc = rItem.GetEsc();
    1153           0 :         nEscProp = rItem.GetProp();
    1154             : 
    1155           0 :         if( nEsc == DFLT_ESC_AUTO_SUPER )
    1156           0 :             nEsc = DFLT_ESC_SUPER;
    1157           0 :         else if( nEsc == DFLT_ESC_AUTO_SUB )
    1158           0 :             nEsc = DFLT_ESC_SUB;
    1159             :     }
    1160             :     else
    1161             :     {
    1162           0 :         nEsc  = 0;
    1163           0 :         nEscProp = 100;
    1164             :     }
    1165           0 :     SetPrevFontEscapement( rFont, nProp, nEscProp, nEsc );
    1166           0 :     SetPrevFontEscapement( rCJKFont, nProp, nEscProp, nEsc );
    1167           0 :     SetPrevFontEscapement( rCTLFont, nProp, nEscProp, nEsc );
    1168             : 
    1169             :     // Font width scale
    1170           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_SCALEWIDTH, nWhich ) )
    1171             :     {
    1172           0 :         const SvxCharScaleWidthItem&rItem = ( SvxCharScaleWidthItem& ) rSet.Get( nWhich );
    1173           0 :         SetFontWidthScale( rItem.GetValue() );
    1174             :     }
    1175             : 
    1176           0 :     Invalidate();
    1177           0 : }
    1178             : 
    1179             : 
    1180             : 
    1181           0 : void SvxFontPrevWindow::Init( const SfxItemSet& rSet )
    1182             : {
    1183           0 :     SvxFont&        rFont = GetFont();
    1184           0 :     SvxFont&        rCJKFont = GetCJKFont();
    1185           0 :     SvxFont&        rCTLFont = GetCTLFont();
    1186             : 
    1187           0 :     initFont(rFont);
    1188           0 :     initFont(rCJKFont);
    1189           0 :     initFont(rCTLFont);
    1190           0 :     InitSettings( true, true );
    1191             : 
    1192             :     sal_uInt16 nWhich;
    1193           0 :     nWhich = rSet.GetPool()->GetWhich( SID_CHAR_DLG_PREVIEW_STRING );
    1194           0 :     if( ISITEMSET )
    1195             :     {
    1196           0 :         const SfxStringItem& rItem = ( SfxStringItem& ) rSet.Get( nWhich );
    1197           0 :         OUString aString = rItem.GetValue();
    1198           0 :         if( !aString.isEmpty() )
    1199           0 :             SetPreviewText( aString );
    1200             :         else
    1201           0 :             SetFontNameAsPreviewText();
    1202             :     }
    1203             : 
    1204             :     // Underline
    1205             :     FontUnderline eUnderline;
    1206           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_UNDERLINE );
    1207           0 :     if( ISITEMSET )
    1208             :     {
    1209           0 :         const SvxUnderlineItem& rItem = ( SvxUnderlineItem& ) rSet.Get( nWhich );
    1210           0 :         eUnderline = ( FontUnderline ) rItem.GetValue();
    1211           0 :         SetTextLineColor( rItem.GetColor() );
    1212             :     }
    1213             :     else
    1214           0 :         eUnderline = UNDERLINE_NONE;
    1215             : 
    1216           0 :     rFont.SetUnderline( eUnderline );
    1217           0 :     rCJKFont.SetUnderline( eUnderline );
    1218           0 :     rCTLFont.SetUnderline( eUnderline );
    1219             : 
    1220             :     // Overline
    1221             :     FontUnderline eOverline;
    1222           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_OVERLINE );
    1223           0 :     if( ISITEMSET )
    1224             :     {
    1225           0 :         const SvxOverlineItem& rItem = ( SvxOverlineItem& ) rSet.Get( nWhich );
    1226           0 :         eOverline = ( FontUnderline ) rItem.GetValue();
    1227           0 :         SetOverlineColor( rItem.GetColor() );
    1228             :     }
    1229             :     else
    1230           0 :         eOverline = UNDERLINE_NONE;
    1231             : 
    1232           0 :     rFont.SetOverline( eOverline );
    1233           0 :     rCJKFont.SetOverline( eOverline );
    1234           0 :     rCTLFont.SetOverline( eOverline );
    1235             : 
    1236             :     //  Strikeout
    1237             :     FontStrikeout eStrikeout;
    1238           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_STRIKEOUT );
    1239           0 :     if( ISITEMSET )
    1240             :     {
    1241           0 :         const SvxCrossedOutItem& rItem = ( SvxCrossedOutItem& ) rSet.Get( nWhich );
    1242           0 :         eStrikeout = ( FontStrikeout ) rItem.GetValue();
    1243             :     }
    1244             :     else
    1245           0 :         eStrikeout = STRIKEOUT_NONE;
    1246             : 
    1247           0 :     rFont.SetStrikeout( eStrikeout );
    1248           0 :     rCJKFont.SetStrikeout( eStrikeout );
    1249           0 :     rCTLFont.SetStrikeout( eStrikeout );
    1250             : 
    1251             :     // WordLineMode
    1252           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
    1253           0 :     if( ISITEMSET )
    1254             :     {
    1255           0 :         const SvxWordLineModeItem& rItem = ( SvxWordLineModeItem& ) rSet.Get( nWhich );
    1256           0 :         rFont.SetWordLineMode( rItem.GetValue() );
    1257           0 :         rCJKFont.SetWordLineMode( rItem.GetValue() );
    1258           0 :         rCTLFont.SetWordLineMode( rItem.GetValue() );
    1259             :     }
    1260             : 
    1261             :     // Emphasis
    1262           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_EMPHASISMARK );
    1263           0 :     if( ISITEMSET )
    1264             :     {
    1265           0 :         const SvxEmphasisMarkItem& rItem = ( SvxEmphasisMarkItem& ) rSet.Get( nWhich );
    1266           0 :         FontEmphasisMark eMark = rItem.GetEmphasisMark();
    1267           0 :         rFont.SetEmphasisMark( eMark );
    1268           0 :         rCJKFont.SetEmphasisMark( eMark );
    1269           0 :         rCTLFont.SetEmphasisMark( eMark );
    1270             :     }
    1271             : 
    1272             :     // Relief
    1273           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_RELIEF );
    1274           0 :     if( ISITEMSET )
    1275             :     {
    1276           0 :         const SvxCharReliefItem& rItem = ( SvxCharReliefItem& ) rSet.Get( nWhich );
    1277           0 :         FontRelief eFontRelief = ( FontRelief ) rItem.GetValue();
    1278           0 :         rFont.SetRelief( eFontRelief );
    1279           0 :         rCJKFont.SetRelief( eFontRelief );
    1280           0 :         rCTLFont.SetRelief( eFontRelief );
    1281             :     }
    1282             : 
    1283             :     // Effects
    1284           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_CASEMAP );
    1285           0 :     if( ISITEMSET )
    1286             :     {
    1287           0 :         const SvxCaseMapItem& rItem = ( SvxCaseMapItem& ) rSet.Get( nWhich );
    1288           0 :         SvxCaseMap eCaseMap = ( SvxCaseMap ) rItem.GetValue();
    1289           0 :         rFont.SetCaseMap( eCaseMap );
    1290           0 :         rCJKFont.SetCaseMap( eCaseMap );
    1291             :         // #i78474# small caps do not exist in CTL fonts
    1292           0 :         rCTLFont.SetCaseMap( eCaseMap == SVX_CASEMAP_KAPITAELCHEN ? SVX_CASEMAP_NOT_MAPPED : eCaseMap );
    1293             :     }
    1294             : 
    1295             :     // Outline
    1296           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_CONTOUR );
    1297           0 :     if( ISITEMSET )
    1298             :     {
    1299           0 :         const SvxContourItem& rItem = ( SvxContourItem& ) rSet.Get( nWhich );
    1300           0 :         sal_Bool bOutline = rItem.GetValue();
    1301           0 :         rFont.SetOutline( bOutline );
    1302           0 :         rCJKFont.SetOutline( bOutline );
    1303           0 :         rCTLFont.SetOutline( bOutline );
    1304             :     }
    1305             : 
    1306             :     // Shadow
    1307           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_SHADOWED );
    1308           0 :     if( ISITEMSET )
    1309             :     {
    1310           0 :         const SvxShadowedItem& rItem = ( SvxShadowedItem& ) rSet.Get( nWhich );
    1311           0 :         sal_Bool bShadow = rItem.GetValue();
    1312           0 :         rFont.SetShadow( bShadow );
    1313           0 :         rCJKFont.SetShadow( bShadow );
    1314           0 :         rCTLFont.SetShadow( bShadow );
    1315             :     }
    1316             : 
    1317             :     // Background
    1318             :     sal_Bool bTransparent;
    1319           0 :     nWhich = rSet.GetPool()->GetWhich( pImpl->bPreviewBackgroundToCharacter ? SID_ATTR_BRUSH : SID_ATTR_BRUSH_CHAR );
    1320           0 :     if( ISITEMSET )
    1321             :     {
    1322           0 :          const SvxBrushItem& rBrush = ( SvxBrushItem& ) rSet.Get( nWhich );
    1323           0 :          const Color& rColor = rBrush.GetColor();
    1324           0 :          bTransparent = rColor.GetTransparency() > 0;
    1325           0 :          rFont.SetFillColor( rColor );
    1326           0 :          rCJKFont.SetFillColor( rColor );
    1327           0 :          rCTLFont.SetFillColor( rColor );
    1328             :     }
    1329             :     else
    1330           0 :         bTransparent = sal_True;
    1331             : 
    1332           0 :     rFont.SetTransparent( bTransparent );
    1333           0 :     rCJKFont.SetTransparent( bTransparent );
    1334           0 :     rCTLFont.SetTransparent( bTransparent );
    1335             : 
    1336           0 :     Color aBackCol( COL_TRANSPARENT );
    1337           0 :     if( !pImpl->bPreviewBackgroundToCharacter )
    1338             :     {
    1339           0 :         nWhich = rSet.GetPool()->GetWhich( SID_ATTR_BRUSH );
    1340           0 :         if( ISITEMSET )
    1341             :         {
    1342           0 :             const SvxBrushItem& rBrush = ( SvxBrushItem& ) rSet.Get( nWhich );
    1343           0 :             if( GPOS_NONE == rBrush.GetGraphicPos() )
    1344           0 :                 aBackCol = rBrush.GetColor();
    1345             :         }
    1346             :     }
    1347           0 :     SetBackColor( aBackCol );
    1348             : 
    1349             :     // Font
    1350           0 :     SetFont( rSet, SID_ATTR_CHAR_FONT, rFont );
    1351           0 :     SetFont( rSet, SID_ATTR_CHAR_CJK_FONT, rCJKFont );
    1352           0 :     SetFont( rSet, SID_ATTR_CHAR_CTL_FONT, rCTLFont );
    1353             : 
    1354             :     // Style
    1355           0 :     SetFontStyle( rSet, SID_ATTR_CHAR_POSTURE, SID_ATTR_CHAR_WEIGHT, rFont );
    1356           0 :     SetFontStyle( rSet, SID_ATTR_CHAR_CJK_POSTURE, SID_ATTR_CHAR_CJK_WEIGHT, rCJKFont );
    1357           0 :     SetFontStyle( rSet, SID_ATTR_CHAR_CTL_POSTURE, SID_ATTR_CHAR_CTL_WEIGHT, rCTLFont );
    1358             : 
    1359             :     // Size
    1360           0 :     SetFontSize( rSet, SID_ATTR_CHAR_FONTHEIGHT, rFont );
    1361           0 :     SetFontSize( rSet, SID_ATTR_CHAR_CJK_FONTHEIGHT, rCJKFont );
    1362           0 :     SetFontSize( rSet, SID_ATTR_CHAR_CTL_FONTHEIGHT, rCTLFont );
    1363             : 
    1364             :     // Language
    1365           0 :     SetFontLang( rSet, SID_ATTR_CHAR_LANGUAGE, rFont );
    1366           0 :     SetFontLang( rSet, SID_ATTR_CHAR_CJK_LANGUAGE, rCJKFont );
    1367           0 :     SetFontLang( rSet, SID_ATTR_CHAR_CTL_LANGUAGE, rCTLFont );
    1368             : 
    1369             :     // Color
    1370           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_COLOR );
    1371           0 :     if( ISITEMSET )
    1372             :     {
    1373           0 :         const SvxColorItem& rItem = ( SvxColorItem& ) rSet.Get( nWhich );
    1374           0 :         Color aCol( rItem.GetValue() );
    1375           0 :         rFont.SetColor( aCol );
    1376           0 :         rCJKFont.SetColor( aCol );
    1377           0 :         rCTLFont.SetColor( aCol );
    1378             : 
    1379           0 :         AutoCorrectFontColor(); // handle color COL_AUTO
    1380             :     }
    1381             : 
    1382             :     // Kerning
    1383           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_KERNING );
    1384           0 :     if( ISITEMSET )
    1385             :     {
    1386           0 :         const SvxKerningItem& rItem = ( SvxKerningItem& ) rSet.Get( nWhich );
    1387             :         short nKern = ( short )
    1388           0 :                         LogicToLogic( rItem.GetValue(), ( MapUnit ) rSet.GetPool()->GetMetric( nWhich ), MAP_TWIP );
    1389           0 :         rFont.SetFixKerning( nKern );
    1390           0 :         rCJKFont.SetFixKerning( nKern );
    1391           0 :         rCTLFont.SetFixKerning( nKern );
    1392             :     }
    1393             : 
    1394             :     // Escapement
    1395           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_ESCAPEMENT );
    1396           0 :     const sal_uInt8 nProp = 100;
    1397             :     short nEsc;
    1398             :     sal_uInt8 nEscProp;
    1399           0 :     if( ISITEMSET )
    1400             :     {
    1401           0 :         const SvxEscapementItem& rItem = ( SvxEscapementItem& ) rSet.Get( nWhich );
    1402           0 :         nEsc = rItem.GetEsc();
    1403           0 :         nEscProp = rItem.GetProp();
    1404             : 
    1405           0 :         if( nEsc == DFLT_ESC_AUTO_SUPER )
    1406           0 :             nEsc = DFLT_ESC_SUPER;
    1407           0 :         else if( nEsc == DFLT_ESC_AUTO_SUB )
    1408           0 :             nEsc = DFLT_ESC_SUB;
    1409             :     }
    1410             :     else
    1411             :     {
    1412           0 :         nEsc  = 0;
    1413           0 :         nEscProp = 100;
    1414             :     }
    1415             : 
    1416           0 :     SetFontEscapement( nProp, nEscProp, nEsc );
    1417             : 
    1418             :     // Font width scale
    1419           0 :     SetFontWidthScale( rSet );
    1420             : 
    1421           0 :     Invalidate();
    1422           0 : }
    1423             : 
    1424             : 
    1425             : 
    1426             : 
    1427             : 
    1428             : 
    1429           0 : void SvxFontPrevWindow::SetFont( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont )
    1430             : {
    1431           0 :     sal_uInt16 nWhich = rSet.GetPool()->GetWhich( nSlot );
    1432           0 :     if( ISITEMSET )
    1433             :     {
    1434           0 :         const SvxFontItem& rFontItem = (const SvxFontItem&)rSet.Get(nWhich);
    1435           0 :         rFont.SetFamily( rFontItem.GetFamily() );
    1436           0 :         rFont.SetName( rFontItem.GetFamilyName() );
    1437           0 :         rFont.SetPitch( rFontItem.GetPitch() );
    1438           0 :         rFont.SetCharSet( rFontItem.GetCharSet() );
    1439           0 :         rFont.SetStyleName( rFontItem.GetStyleName() );
    1440             :     }
    1441           0 : }
    1442             : 
    1443             : 
    1444             : 
    1445           0 : void SvxFontPrevWindow::SetFontStyle( const SfxItemSet& rSet, sal_uInt16 nPosture, sal_uInt16 nWeight, SvxFont& rFont )
    1446             : {
    1447           0 :     sal_uInt16 nWhich = rSet.GetPool()->GetWhich( nPosture );
    1448           0 :     if( ISITEMSET )
    1449             :     {
    1450           0 :         const SvxPostureItem& rItem = ( SvxPostureItem& ) rSet.Get( nWhich );
    1451           0 :         rFont.SetItalic( ( FontItalic ) rItem.GetValue() != ITALIC_NONE ? ITALIC_NORMAL : ITALIC_NONE );
    1452             :     }
    1453             : 
    1454           0 :     nWhich = rSet.GetPool()->GetWhich( nWeight );
    1455           0 :     if( ISITEMSET )
    1456             :     {
    1457           0 :         SvxWeightItem& rItem = ( SvxWeightItem& ) rSet.Get( nWhich );
    1458           0 :         rFont.SetWeight( ( FontWeight ) rItem.GetValue() != WEIGHT_NORMAL ? WEIGHT_BOLD : WEIGHT_NORMAL );
    1459             :     }
    1460           0 : }
    1461             : 
    1462             : 
    1463             : 
    1464           0 : void SvxFontPrevWindow::SetFontWidthScale( const SfxItemSet& rSet )
    1465             : {
    1466           0 :     sal_uInt16  nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
    1467           0 :     if( ISITEMSET )
    1468             :     {
    1469           0 :         const SvxCharScaleWidthItem&    rItem = ( SvxCharScaleWidthItem& ) rSet.Get( nWhich );
    1470             : 
    1471           0 :         SetFontWidthScale( rItem.GetValue() );
    1472             :     }
    1473           0 : }
    1474             : 
    1475             : 
    1476             : namespace
    1477             : {
    1478             : 
    1479           0 :     void setFontEscapement(SvxFont& _rFont,sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
    1480             :     {
    1481           0 :         _rFont.SetPropr( nProp );
    1482           0 :         _rFont.SetProprRel( nEscProp );
    1483           0 :         _rFont.SetEscapement( nEsc );
    1484           0 :     }
    1485             : 
    1486             : 
    1487             : }
    1488             : 
    1489             : 
    1490           0 : void SvxFontPrevWindow::SetFontEscapement( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
    1491             : {
    1492           0 :     setFontEscapement(GetFont(),nProp,nEscProp,nEsc);
    1493           0 :     setFontEscapement(GetCJKFont(),nProp,nEscProp,nEsc);
    1494           0 :     setFontEscapement(GetCTLFont(),nProp,nEscProp,nEsc);
    1495           0 :     Invalidate();
    1496           0 : }
    1497             : 
    1498           0 : Size SvxFontPrevWindow::GetOptimalSize() const
    1499             : {
    1500           0 :     return getPreviewStripSize(this);
    1501             : }
    1502             : 
    1503             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10