LCOV - code coverage report
Current view: top level - libreoffice/svx/source/dialog - fntctrl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 753 0.0 %
Date: 2012-12-17 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/viewsh.hxx>      // SfxViewShell
      21             : #include <sfx2/printer.hxx>     // Printer
      22             : #include <vcl/builder.hxx>
      23             : #include <vcl/metric.hxx>
      24             : #include <vcl/svapp.hxx>
      25             : #include <unicode/uchar.h>
      26             : #include <com/sun/star/uno/Reference.h>
      27             : #include <com/sun/star/i18n/BreakIterator.hpp>
      28             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      29             : #include <comphelper/processfactory.hxx>
      30             : 
      31             : #include <com/sun/star/i18n/ScriptType.hpp>
      32             : 
      33             : #include <vector>
      34             : #include <deque>
      35             : #include <svtools/colorcfg.hxx>
      36             : #include <svtools/sampletext.hxx>
      37             : 
      38             : #include <svx/fntctrl.hxx>
      39             : #include <svx/dialogs.hrc>
      40             : #include <svx/sdasitm.hxx>
      41             : 
      42             : // Item set includes
      43             : #include <svl/itemset.hxx>
      44             : #include <svl/itempool.hxx>
      45             : #include <svl/stritem.hxx>                  // SfxStringItem
      46             : #include <svl/languageoptions.hxx>
      47             : 
      48             : #include <editeng/colritem.hxx>
      49             : #include <editeng/fontitem.hxx>
      50             : #include <editeng/editids.hrc>      // #define SID_ATTR_*
      51             : #include <editeng/fontitem.hxx>     // SvxFontItem
      52             : #include <editeng/postitem.hxx>     // SvxPostureItem
      53             : #include <editeng/udlnitem.hxx>     // SvxUnderlineItem
      54             : #include <editeng/crsditem.hxx>     // SvxCrossedOutItem
      55             : #include <editeng/cntritem.hxx>     // SvxContourItem
      56             : #include <editeng/wghtitem.hxx>     // SvxWeightItem
      57             : #include <editeng/fhgtitem.hxx>     // SvxFontHeightItem
      58             : #include <editeng/shdditem.hxx>     // SvxShadowedItem
      59             : #include <editeng/escpitem.hxx>     // SvxEscapementItem
      60             : #include <editeng/wrlmitem.hxx>     // SvxWordLineModeItem
      61             : #include <editeng/cmapitem.hxx>     // SvxWordLineModeItem
      62             : #include <editeng/kernitem.hxx>     // SvxKerningItem
      63             : #include <editeng/brshitem.hxx>     // SvxBrushItem
      64             : #include <editeng/colritem.hxx>     // SvxColorItem
      65             : #include <editeng/emphitem.hxx>     // SvxEmphasisMarkItem
      66             : #include <editeng/charreliefitem.hxx>       // SvxCharReliefItem
      67             : #include <editeng/twolinesitem.hxx>         // SvxTwoLinesItem
      68             : #include <editeng/charscaleitem.hxx>        // SvxCharScaleWidthItem
      69             : #include <editeng/langitem.hxx>     // SvxLanguageItem
      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(sal_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( sal_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             :     sal_Bool                        bDelPrinter;
     139             : 
     140             :     Reference < XBreakIterator >    xBreak;
     141             :     std::vector<sal_uIntPtr>        aTextWidth;
     142             :     std::deque<xub_StrLen>         aScriptChg;
     143             :     std::vector<sal_uInt16>         aScriptType;
     144             :     SvxFont                         aCJKFont;
     145             :     SvxFont                         aCTLFont;
     146             :     String                          aText;
     147             :     String                          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             :     sal_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( sal_False ),
     174             :         pColor( NULL ), pBackColor( 0 ), nAscent( 0 ),
     175             :         cStartBracket( 0 ), cEndBracket( 0 ), nFontWidthScale( 100 ),
     176             :         bSelection( sal_False ), bGetSelection( sal_False ), bUseResText( sal_False ),
     177             :         bPreviewBackgroundToCharacter( sal_False ), bTwoLines( sal_False ),
     178           0 :         bUseFontNameAsText( sal_False ), bTextInited( sal_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             :     sal_Bool            SetFontWidthScale( sal_uInt16 nScaleInPercent );
     200             :     inline void         Invalidate100PercentFontWidth();
     201             :     inline sal_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 sal_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.Len()); // 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_uInt16 nChg = 0;
     251           0 :     if( com::sun::star::i18n::ScriptType::WEAK == nScript )
     252             :     {
     253           0 :         nChg = (xub_StrLen)xBreak->endOfScript( aText, nChg, nScript );
     254           0 :         if( nChg < aText.Len() )
     255           0 :             nScript = xBreak->getScriptType( aText, nChg );
     256             :         else
     257           0 :             nScript = com::sun::star::i18n::ScriptType::LATIN;
     258             :     }
     259             : 
     260           0 :     do
     261             :     {
     262           0 :         nChg = (xub_StrLen)xBreak->endOfScript( aText, nChg, nScript );
     263           0 :         if (nChg < aText.Len() && 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.GetChar(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.Len() )
     286           0 :             nScript = xBreak->getScriptType( aText, nChg );
     287             :         else
     288           0 :             break;
     289             :     } while( sal_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 :     xub_StrLen nStart = 0;
     308             :     xub_StrLen 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.Len();
     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           0 :     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.Len() && 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( sal_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 :     xub_StrLen nStart = 0;
     390             :     xub_StrLen 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.Len();
     400           0 :         nScript = com::sun::star::i18n::ScriptType::LATIN;
     401             :     }
     402           0 :     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.Len() && 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( sal_True );
     420           0 :     _pPrinter->SetFont( aOldFont );
     421           0 : }
     422             : 
     423             : // -----------------------------------------------------------------------
     424             : 
     425           0 : sal_Bool FontPrevWin_Impl::SetFontWidthScale( sal_uInt16 nScale )
     426             : {
     427           0 :     if( nFontWidthScale != nScale )
     428             :     {
     429           0 :         nFontWidthScale = nScale;
     430           0 :         return sal_True;
     431             :     }
     432             : 
     433           0 :     return sal_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( sal_Bool bForeground, sal_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 = sal_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( sal_True, sal_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 :     m_aInitialSize = GetSizePixel();
     506           0 :     Init();
     507           0 : }
     508             : 
     509           0 : SvxFontPrevWindow::SvxFontPrevWindow(Window* pParent) :
     510           0 :     Window(pParent)
     511             : {
     512           0 :     Init();
     513           0 : }
     514             : 
     515           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxFontPrevWindow(Window *pParent, VclBuilder::stringmap &)
     516             : {
     517           0 :     SvxFontPrevWindow *pWindow = new SvxFontPrevWindow(pParent);
     518           0 :     return pWindow;
     519             : }
     520             : 
     521           0 : SvxFontPrevWindow::~SvxFontPrevWindow()
     522             : {
     523           0 :     delete pImpl;
     524           0 : }
     525             : 
     526             : // -----------------------------------------------------------------------
     527           0 : SvxFont& SvxFontPrevWindow::GetCTLFont()
     528             : {
     529           0 :     return pImpl->aCTLFont;
     530             : }
     531             : 
     532             : // -----------------------------------------------------------------------
     533             : 
     534           0 : SvxFont& SvxFontPrevWindow::GetCJKFont()
     535             : {
     536           0 :     return pImpl->aCJKFont;
     537             : }
     538             : 
     539             : // -----------------------------------------------------------------------
     540             : 
     541           0 : void SvxFontPrevWindow::StateChanged( StateChangedType nType )
     542             : {
     543           0 :     if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
     544           0 :         InitSettings( sal_True, sal_False );
     545           0 :     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
     546           0 :         InitSettings( sal_False, sal_True );
     547             : 
     548           0 :     Window::StateChanged( nType );
     549           0 :     Invalidate();
     550           0 : }
     551             : 
     552             : // -----------------------------------------------------------------------
     553             : 
     554           0 : void SvxFontPrevWindow::DataChanged( const DataChangedEvent& rDCEvt )
     555             : {
     556           0 :     if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
     557           0 :         InitSettings( sal_True, sal_True );
     558             :     else
     559           0 :         Window::DataChanged( rDCEvt );
     560           0 : }
     561             : 
     562           0 : SvxFont& SvxFontPrevWindow::GetFont()
     563             : {
     564           0 :     pImpl->Invalidate100PercentFontWidth();     // because the user might change the size
     565           0 :     return pImpl->aFont;
     566             : }
     567             : 
     568           0 : const SvxFont& SvxFontPrevWindow::GetFont() const
     569             : {
     570           0 :     return pImpl->aFont;
     571             : }
     572             : 
     573             : // -----------------------------------------------------------------------
     574             : 
     575           0 : void SvxFontPrevWindow::SetPreviewText( const ::rtl::OUString& rString )
     576             : {
     577           0 :     pImpl->aText = rString;
     578           0 :     pImpl->bTextInited = sal_True;
     579           0 : }
     580             : 
     581             : // -----------------------------------------------------------------------
     582             : 
     583           0 : void SvxFontPrevWindow::SetFontNameAsPreviewText()
     584             : {
     585           0 :     pImpl->bUseFontNameAsText = sal_True;
     586           0 : }
     587             : 
     588             : // -----------------------------------------------------------------------
     589             : 
     590           0 : void SvxFontPrevWindow::SetFont( const SvxFont& rNormalOutFont, const SvxFont& rCJKOutFont, const SvxFont& rCTLFont )
     591             : {
     592           0 :     setFont( rNormalOutFont, pImpl->aFont );
     593           0 :     setFont( rCJKOutFont, pImpl->aCJKFont );
     594           0 :     setFont( rCTLFont, pImpl->aCTLFont );
     595             : 
     596             : 
     597           0 :     pImpl->Invalidate100PercentFontWidth();
     598           0 :     Invalidate();
     599           0 : }
     600             : 
     601             : // -----------------------------------------------------------------------
     602             : 
     603           0 : void SvxFontPrevWindow::SetColor(const Color &rColor)
     604             : {
     605           0 :     delete pImpl->pColor;
     606           0 :     pImpl->pColor = new Color( rColor );
     607           0 :     Invalidate();
     608           0 : }
     609             : // -----------------------------------------------------------------------
     610             : 
     611           0 : void SvxFontPrevWindow::ResetColor()
     612             : {
     613           0 :     delete pImpl->pColor;
     614           0 :     pImpl->pColor = 0;
     615           0 :     Invalidate();
     616           0 : }
     617             : 
     618             : // -----------------------------------------------------------------------
     619             : 
     620           0 : void SvxFontPrevWindow::SetBackColor(const Color &rColor)
     621             : {
     622           0 :     delete pImpl->pBackColor;
     623           0 :     pImpl->pBackColor = new Color( rColor );
     624           0 :     Invalidate();
     625           0 : }
     626             : 
     627             : // -----------------------------------------------------------------------
     628             : 
     629           0 : void SvxFontPrevWindow::UseResourceText( sal_Bool bUse )
     630             : {
     631           0 :     pImpl->bUseResText = bUse;
     632           0 : }
     633             : 
     634             : // -----------------------------------------------------------------------
     635             : 
     636           0 : void SvxFontPrevWindow::Paint( const Rectangle& )
     637             : {
     638           0 :     Printer* pPrinter = pImpl->pPrinter;
     639           0 :     const SvxFont& rFont = pImpl->aFont;
     640           0 :     const SvxFont& rCJKFont = pImpl->aCJKFont;
     641           0 :     const SvxFont& rCTLFont = pImpl->aCTLFont;
     642             : 
     643           0 :     if ( !IsEnabled() )
     644             :     {
     645           0 :         const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
     646           0 :         const Size aLogSize( GetOutputSize() );
     647             : 
     648           0 :         Rectangle aRect( Point( 0, 0 ), aLogSize );
     649           0 :         SetLineColor();
     650           0 :         SetFillColor( rStyleSettings.GetWindowColor() );
     651           0 :         DrawRect( aRect );
     652             :     }
     653             :     else
     654             :     {
     655           0 :         if ( pImpl->bUseResText )
     656           0 :             pImpl->aText = GetText();
     657           0 :         else if ( !pImpl->bSelection && !pImpl->bTextInited )
     658             :         {
     659           0 :             SfxViewShell* pSh = SfxViewShell::Current();
     660             : 
     661           0 :             if ( pSh && !pImpl->bGetSelection && !pImpl->bUseFontNameAsText )
     662             :             {
     663           0 :                 pImpl->aText = pSh->GetSelectionText();
     664           0 :                 pImpl->bGetSelection = sal_True;
     665           0 :                 pImpl->bSelection = pImpl->aText.Len() != 0;
     666             : 
     667             :             }
     668             : 
     669           0 :             if ( !pImpl->bSelection || pImpl->bUseFontNameAsText )
     670             :             {
     671             :                 using namespace com::sun::star::i18n::ScriptType;
     672             : 
     673             :                 //If we're showing multiple sample texts, then they're all
     674             :                 //sample texts. If only showing Latin, continue to use
     675             :                 //the fontname as the preview
     676           0 :                 if ((pImpl->m_bCJKEnabled) || (pImpl->m_bCTLEnabled))
     677           0 :                     pImpl->aText = makeRepresentativeTextForFont(LATIN, rFont);
     678             :                 else
     679           0 :                     pImpl->aText = rFont.GetName();
     680             : 
     681           0 :                 if (pImpl->m_bCJKEnabled)
     682             :                 {
     683           0 :                     if (pImpl->aText.Len())
     684           0 :                         pImpl->aText.AppendAscii("   ");
     685           0 :                     pImpl->aText += makeRepresentativeTextForFont(ASIAN, rCJKFont);
     686             : 
     687             :                 }
     688           0 :                 if (pImpl->m_bCTLEnabled)
     689             :                 {
     690           0 :                     if (pImpl->aText.Len())
     691           0 :                         pImpl->aText.AppendAscii("   ");
     692           0 :                     pImpl->aText += makeRepresentativeTextForFont(COMPLEX, rCTLFont);
     693             :                 }
     694             :             }
     695             : 
     696           0 :             if ( !pImpl->aText.Len() )
     697           0 :                 pImpl->aText = GetText();
     698             : 
     699             :             // remove line feeds and carriage returns from string
     700           0 :             bool bNotEmpty = false;
     701           0 :             for ( xub_StrLen i = 0; i < pImpl->aText.Len(); ++i )
     702             :             {
     703           0 :                 if ( 0xa == pImpl->aText.GetChar( i ) ||
     704           0 :                      0xd == pImpl->aText.GetChar( i ) )
     705           0 :                      pImpl->aText.SetChar( i, ' ' );
     706             :                 else
     707           0 :                     bNotEmpty = true;
     708             :             }
     709           0 :             if ( !bNotEmpty )
     710           0 :                 pImpl->aText = GetText();
     711             : 
     712           0 :             if ( pImpl->aText.Len() > (TEXT_WIDTH-1) )
     713           0 :                 pImpl->aText.Erase( pImpl->aText.Search( sal_Unicode( ' ' ), TEXT_WIDTH ) );
     714             :         }
     715             : 
     716             :         // calculate text width scaling
     717           0 :         pImpl->ScaleFontWidth( *this/*, rFont*/ );
     718             : 
     719           0 :         pImpl->CheckScript();
     720           0 :         Size aTxtSize = pImpl->CalcTextSize( this, pPrinter, rFont );
     721             : 
     722           0 :         const Size aLogSize( GetOutputSize() );
     723             : 
     724           0 :         long nX = aLogSize.Width()  / 2 - aTxtSize.Width() / 2;
     725           0 :         long nY = aLogSize.Height() / 2 - aTxtSize.Height() / 2;
     726             : 
     727           0 :         if ( nY + pImpl->nAscent > aLogSize.Height() )
     728           0 :             nY = aLogSize.Height() - pImpl->nAscent;
     729             : 
     730           0 :         if ( pImpl->pBackColor )
     731             :         {
     732           0 :             Rectangle aRect( Point( 0, 0 ), aLogSize );
     733           0 :             Color aLineCol = GetLineColor();
     734           0 :             Color aFillCol = GetFillColor();
     735           0 :             SetLineColor();
     736           0 :             SetFillColor( *pImpl->pBackColor );
     737           0 :             DrawRect( aRect );
     738           0 :             SetLineColor( aLineCol );
     739           0 :             SetFillColor( aFillCol );
     740             :         }
     741           0 :         if ( pImpl->pColor )
     742             :         {
     743           0 :             Rectangle aRect( Point( nX, nY ), aTxtSize );
     744           0 :             Color aLineCol = GetLineColor();
     745           0 :             Color aFillCol = GetFillColor();
     746           0 :             SetLineColor();
     747           0 :             SetFillColor( *pImpl->pColor );
     748           0 :             DrawRect( aRect );
     749           0 :             SetLineColor( aLineCol );
     750           0 :             SetFillColor( aFillCol );
     751             :         }
     752             : 
     753           0 :         long nStdAscent = pImpl->nAscent;
     754           0 :         nY += nStdAscent;
     755             : 
     756           0 :         if (IsTwoLines())
     757             :         {
     758           0 :             SvxFont aSmallFont( rFont );
     759           0 :             Size aOldSize = pImpl->aCJKFont.GetSize();
     760           0 :             setFontSize(aSmallFont);
     761           0 :             setFontSize(pImpl->aCJKFont);
     762             : 
     763           0 :             long nStartBracketWidth = 0;
     764           0 :             long nEndBracketWidth = 0;
     765           0 :             long nTextWidth = 0;
     766           0 :             if(pImpl->cStartBracket)
     767             :             {
     768           0 :                 rtl::OUString sBracket(pImpl->cStartBracket);
     769           0 :                 nStartBracketWidth = rFont.GetTxtSize( pPrinter, sBracket ).Width();
     770             :             }
     771           0 :             if(pImpl->cEndBracket)
     772             :             {
     773           0 :                 rtl::OUString sBracket(pImpl->cEndBracket);
     774           0 :                 nEndBracketWidth = rFont.GetTxtSize( pPrinter, sBracket ).Width();
     775             :             }
     776           0 :             nTextWidth = pImpl->CalcTextSize( this, pPrinter, aSmallFont ).Width();
     777           0 :             long nResultWidth = nStartBracketWidth;
     778           0 :             nResultWidth += nEndBracketWidth;
     779           0 :             nResultWidth += nTextWidth;
     780             : 
     781           0 :             long _nX = (aLogSize.Width() - nResultWidth) / 2;
     782           0 :             DrawLine( Point( 0,  nY ), Point( _nX, nY ) );
     783           0 :             DrawLine( Point( _nX + nResultWidth, nY ), Point( aLogSize.Width(), nY ) );
     784             : 
     785           0 :             long nSmallAscent = pImpl->nAscent;
     786           0 :             long nOffset = (nStdAscent - nSmallAscent ) / 2;
     787             : 
     788           0 :             if(pImpl->cStartBracket)
     789             :             {
     790           0 :                 rtl::OUString sBracket(pImpl->cStartBracket);
     791           0 :                 rFont.DrawPrev( this, pPrinter, Point( _nX, nY - nOffset - 4), sBracket );
     792           0 :                 _nX += nStartBracketWidth;
     793             :             }
     794             : 
     795           0 :             Point aTmpPoint1( _nX, nY - nSmallAscent - 2 );
     796           0 :             Point aTmpPoint2( _nX, nY );
     797           0 :             pImpl->DrawPrev( this, pPrinter, aTmpPoint1, aSmallFont );
     798           0 :             pImpl->DrawPrev( this, pPrinter, aTmpPoint2, aSmallFont );
     799             : 
     800           0 :             _nX += nTextWidth;
     801           0 :             if(pImpl->cEndBracket)
     802             :             {
     803           0 :                 Point aTmpPoint( _nX + 1, nY - nOffset - 4);
     804           0 :                 rtl::OUString sBracket(pImpl->cEndBracket);
     805           0 :                 rFont.DrawPrev( this, pPrinter, aTmpPoint, sBracket );
     806             :             }
     807           0 :             pImpl->aCJKFont.SetSize( aOldSize );
     808             :         }
     809             :         else
     810             :         {
     811             : 
     812           0 :             Color aLineCol = GetLineColor();
     813             : 
     814           0 :             SetLineColor( rFont.GetColor() );
     815           0 :             DrawLine( Point( 0,  nY ), Point( nX, nY ) );
     816           0 :             DrawLine( Point( nX + aTxtSize.Width(), nY ), Point( aLogSize.Width(), nY ) );
     817           0 :             SetLineColor( aLineCol );
     818             : 
     819           0 :             Point aTmpPoint( nX, nY );
     820           0 :             pImpl->DrawPrev( this, pPrinter, aTmpPoint, rFont );
     821             :         }
     822             :     }
     823           0 : }
     824             : 
     825           0 : sal_Bool SvxFontPrevWindow::IsTwoLines() const
     826             : {
     827           0 :     return pImpl->bTwoLines;
     828             : }
     829             : 
     830           0 : void SvxFontPrevWindow::SetTwoLines(sal_Bool bSet)
     831             : {
     832           0 :     pImpl->bTwoLines = bSet;
     833           0 : }
     834             : 
     835           0 : void SvxFontPrevWindow::SetBrackets(sal_Unicode cStart, sal_Unicode cEnd)
     836             : {
     837           0 :     pImpl->cStartBracket = cStart;
     838           0 :     pImpl->cEndBracket = cEnd;
     839           0 : }
     840             : 
     841             : // -----------------------------------------------------------------------
     842             : 
     843           0 : void SvxFontPrevWindow::SetFontWidthScale( sal_uInt16 n )
     844             : {
     845           0 :     if( pImpl->SetFontWidthScale( n ) )
     846           0 :         Invalidate();
     847           0 : }
     848             : 
     849             : // -----------------------------------------------------------------------
     850             : 
     851           0 : void SvxFontPrevWindow::AutoCorrectFontColor( void )
     852             : {
     853           0 :     Color   aFontColor( GetTextColor() );
     854             : 
     855           0 :     if( COL_AUTO == pImpl->aFont.GetColor().GetColor() )
     856           0 :         pImpl->aFont.SetColor( aFontColor );
     857             : 
     858           0 :     if( COL_AUTO == pImpl->aCJKFont.GetColor().GetColor() )
     859           0 :         pImpl->aCJKFont.SetColor( aFontColor );
     860             : 
     861           0 :     if( COL_AUTO == pImpl->aCTLFont.GetColor().GetColor() )
     862           0 :         pImpl->aCTLFont.SetColor( aFontColor );
     863           0 : }
     864             : 
     865             : // -----------------------------------------------------------------------
     866             : 
     867           0 : static bool GetWhich (const SfxItemSet &rSet, sal_uInt16 nSlot, sal_uInt16 &rWhich)
     868             : {
     869           0 :     rWhich = rSet.GetPool()->GetWhich( nSlot, sal_True );
     870           0 :     return rSet.GetItemState(rWhich) >= SFX_ITEM_DEFAULT;
     871             : }
     872             : 
     873           0 : static void SetPrevFont( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont )
     874             : {
     875             :     sal_uInt16 nWhich;
     876           0 :     if (GetWhich ( rSet, nSlot, nWhich ) )
     877             :     {
     878           0 :         const SvxFontItem& rFontItem = ( SvxFontItem& ) rSet.Get( nWhich );
     879           0 :         rFont.SetFamily( rFontItem.GetFamily() );
     880           0 :         rFont.SetName( rFontItem.GetFamilyName() );
     881           0 :         rFont.SetPitch( rFontItem.GetPitch() );
     882           0 :         rFont.SetCharSet( rFontItem.GetCharSet() );
     883           0 :         rFont.SetStyleName( rFontItem.GetStyleName() );
     884             :     }
     885           0 : }
     886             : 
     887           0 : static void SetPrevFontStyle( const SfxItemSet& rSet, sal_uInt16 nPosture, sal_uInt16 nWeight, SvxFont& rFont )
     888             : {
     889             :     sal_uInt16 nWhich;
     890           0 :     if( GetWhich( rSet, nPosture, nWhich ) )
     891             :     {
     892           0 :         const SvxPostureItem& rItem = ( const SvxPostureItem& ) rSet.Get( nWhich );
     893           0 :         rFont.SetItalic( ( FontItalic ) rItem.GetValue() != ITALIC_NONE ? ITALIC_NORMAL : ITALIC_NONE );
     894             :     }
     895             : 
     896           0 :     if( GetWhich( rSet, nWeight, nWhich ) )
     897             :     {
     898           0 :         const SvxWeightItem& rItem = ( const SvxWeightItem& ) rSet.Get( nWhich );
     899           0 :         rFont.SetWeight( ( FontWeight ) rItem.GetValue() != WEIGHT_NORMAL ? WEIGHT_BOLD : WEIGHT_NORMAL );
     900             :     }
     901           0 : }
     902             : 
     903           0 : void SvxFontPrevWindow::SetFontSize( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont )
     904             : {
     905             :     sal_uInt16 nWhich;
     906             :     long nH;
     907           0 :     if( GetWhich( rSet, nSlot, nWhich ) )
     908             :     {
     909           0 :         nH = LogicToLogic( ( ( SvxFontHeightItem& ) rSet.Get( nWhich ) ).GetHeight(),
     910           0 :                             ( MapUnit ) rSet.GetPool()->GetMetric( nWhich ),
     911           0 :                             MAP_TWIP );
     912             :     }
     913             :     else
     914           0 :         nH = 240;   // as default 12pt
     915             : 
     916           0 :     rFont.SetSize( Size( 0, nH ) );
     917           0 : }
     918             : 
     919           0 : void SvxFontPrevWindow::SetFontLang(const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont)
     920             : {
     921             :     sal_uInt16 nWhich;
     922             :     LanguageType nLang;
     923           0 :     if( GetWhich( rSet, nSlot, nWhich ) )
     924           0 :         nLang = static_cast<const SvxLanguageItem&>(rSet.Get(nWhich)).GetLanguage();
     925             :     else
     926           0 :         nLang = LANGUAGE_NONE;
     927           0 :     rFont.SetLanguage(nLang);
     928           0 : }
     929             : 
     930           0 : static void SetPrevFontEscapement(SvxFont& _rFont, sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
     931             : {
     932           0 :     _rFont.SetPropr( nProp );
     933           0 :     _rFont.SetProprRel( nEscProp );
     934           0 :     _rFont.SetEscapement( nEsc );
     935           0 : }
     936             : 
     937           0 : void SvxFontPrevWindow::SetFromItemSet( const SfxItemSet &rSet,
     938             :                     bool bPreviewBackgroundToCharacter )
     939             : {
     940             :     sal_uInt16 nWhich;
     941           0 :     SvxFont& rFont = GetFont();
     942           0 :     SvxFont& rCJKFont = GetCJKFont();
     943           0 :     SvxFont& rCTLFont = GetCTLFont();
     944             : 
     945             :     // Preview string
     946           0 :     if( GetWhich( rSet, SID_CHAR_DLG_PREVIEW_STRING, nWhich ) )
     947             :     {
     948           0 :         const SfxStringItem& rItem = ( SfxStringItem& ) rSet.Get( nWhich );
     949           0 :         ::rtl::OUString aString = rItem.GetValue();
     950           0 :         if( !aString.isEmpty() )
     951           0 :             SetPreviewText( aString );
     952             :         else
     953           0 :             SetFontNameAsPreviewText();
     954             :     }
     955             : 
     956             :     // Underline
     957             :     FontUnderline eUnderline;
     958           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_UNDERLINE, nWhich ) )
     959             :     {
     960           0 :         const SvxUnderlineItem& rItem = ( SvxUnderlineItem& ) rSet.Get( nWhich );
     961           0 :         eUnderline = ( FontUnderline ) rItem.GetValue();
     962           0 :         SetTextLineColor( rItem.GetColor() );
     963             :     }
     964             :     else
     965           0 :         eUnderline = UNDERLINE_NONE;
     966             : 
     967           0 :     rFont.SetUnderline( eUnderline );
     968           0 :     rCJKFont.SetUnderline( eUnderline );
     969           0 :     rCTLFont.SetUnderline( eUnderline );
     970             : 
     971             :     // Overline
     972             :     FontUnderline eOverline;
     973           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_OVERLINE, nWhich ) )
     974             :     {
     975           0 :         const SvxOverlineItem& rItem = ( SvxOverlineItem& ) rSet.Get( nWhich );
     976           0 :         eOverline = ( FontUnderline ) rItem.GetValue();
     977           0 :         SetOverlineColor( rItem.GetColor() );
     978             :     }
     979             :     else
     980           0 :         eOverline = UNDERLINE_NONE;
     981             : 
     982           0 :     rFont.SetOverline( eOverline );
     983           0 :     rCJKFont.SetOverline( eOverline );
     984           0 :     rCTLFont.SetOverline( eOverline );
     985             : 
     986             :     //  Strikeout
     987             :     FontStrikeout eStrikeout;
     988           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_STRIKEOUT, nWhich ) )
     989             :     {
     990           0 :         const SvxCrossedOutItem& rItem = ( SvxCrossedOutItem& ) rSet.Get( nWhich );
     991           0 :         eStrikeout = ( FontStrikeout ) rItem.GetValue();
     992             :     }
     993             :     else
     994           0 :         eStrikeout = STRIKEOUT_NONE;
     995             : 
     996           0 :     rFont.SetStrikeout( eStrikeout );
     997           0 :     rCJKFont.SetStrikeout( eStrikeout );
     998           0 :     rCTLFont.SetStrikeout( eStrikeout );
     999             : 
    1000             :     // WordLineMode
    1001           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_WORDLINEMODE, nWhich ) )
    1002             :     {
    1003           0 :         const SvxWordLineModeItem& rItem = ( SvxWordLineModeItem& ) rSet.Get( nWhich );
    1004           0 :         rFont.SetWordLineMode( rItem.GetValue() );
    1005           0 :         rCJKFont.SetWordLineMode( rItem.GetValue() );
    1006           0 :         rCTLFont.SetWordLineMode( rItem.GetValue() );
    1007             :     }
    1008             : 
    1009             :     // Emphasis
    1010           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_EMPHASISMARK, nWhich ) )
    1011             :     {
    1012           0 :         const SvxEmphasisMarkItem& rItem = ( SvxEmphasisMarkItem& ) rSet.Get( nWhich );
    1013           0 :         FontEmphasisMark eMark = rItem.GetEmphasisMark();
    1014           0 :         rFont.SetEmphasisMark( eMark );
    1015           0 :         rCJKFont.SetEmphasisMark( eMark );
    1016           0 :         rCTLFont.SetEmphasisMark( eMark );
    1017             :     }
    1018             : 
    1019             :     // Relief
    1020           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_RELIEF, nWhich ) )
    1021             :     {
    1022           0 :         const SvxCharReliefItem& rItem = ( SvxCharReliefItem& ) rSet.Get( nWhich );
    1023           0 :         FontRelief eFontRelief = ( FontRelief ) rItem.GetValue();
    1024           0 :         rFont.SetRelief( eFontRelief );
    1025           0 :         rCJKFont.SetRelief( eFontRelief );
    1026           0 :         rCTLFont.SetRelief( eFontRelief );
    1027             :     }
    1028             : 
    1029             :     // Effects
    1030           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_CASEMAP, nWhich ) )
    1031             :     {
    1032           0 :         const SvxCaseMapItem& rItem = ( SvxCaseMapItem& ) rSet.Get( nWhich );
    1033           0 :         SvxCaseMap eCaseMap = ( SvxCaseMap ) rItem.GetValue();
    1034           0 :         rFont.SetCaseMap( eCaseMap );
    1035           0 :         rCJKFont.SetCaseMap( eCaseMap );
    1036             :         // #i78474# small caps do not exist in CTL fonts
    1037           0 :         rCTLFont.SetCaseMap( eCaseMap == SVX_CASEMAP_KAPITAELCHEN ? SVX_CASEMAP_NOT_MAPPED : eCaseMap );
    1038             :     }
    1039             : 
    1040             :     // Outline
    1041           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_CONTOUR, nWhich ) )
    1042             :     {
    1043           0 :         const SvxContourItem& rItem = ( SvxContourItem& ) rSet.Get( nWhich );
    1044           0 :         sal_Bool bOutline = rItem.GetValue();
    1045           0 :         rFont.SetOutline( bOutline );
    1046           0 :         rCJKFont.SetOutline( bOutline );
    1047           0 :         rCTLFont.SetOutline( bOutline );
    1048             :     }
    1049             : 
    1050             :     // Shadow
    1051           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_SHADOWED, nWhich ) )
    1052             :     {
    1053           0 :         const SvxShadowedItem& rItem = ( SvxShadowedItem& ) rSet.Get( nWhich );
    1054           0 :         sal_Bool bShadow = rItem.GetValue();
    1055           0 :         rFont.SetShadow( bShadow );
    1056           0 :         rCJKFont.SetShadow( bShadow );
    1057           0 :         rCTLFont.SetShadow( bShadow );
    1058             :     }
    1059             : 
    1060             :     // Background
    1061             :     sal_Bool bTransparent;
    1062           0 :     if( GetWhich( rSet, bPreviewBackgroundToCharacter ? SID_ATTR_BRUSH : SID_ATTR_BRUSH_CHAR, nWhich ) )
    1063             :     {
    1064           0 :          const SvxBrushItem& rBrush = ( SvxBrushItem& ) rSet.Get( nWhich );
    1065           0 :          const Color& rColor = rBrush.GetColor();
    1066           0 :          bTransparent = rColor.GetTransparency() > 0;
    1067           0 :          rFont.SetFillColor( rColor );
    1068           0 :          rCJKFont.SetFillColor( rColor );
    1069           0 :          rCTLFont.SetFillColor( rColor );
    1070             :     }
    1071             :     else
    1072           0 :         bTransparent = TRUE;
    1073             : 
    1074           0 :     rFont.SetTransparent( bTransparent );
    1075           0 :     rCJKFont.SetTransparent( bTransparent );
    1076           0 :     rCTLFont.SetTransparent( bTransparent );
    1077             : 
    1078           0 :     Color aBackCol( COL_TRANSPARENT );
    1079           0 :     if( !bPreviewBackgroundToCharacter )
    1080             :     {
    1081           0 :         if( GetWhich( rSet, SID_ATTR_BRUSH, nWhich ) )
    1082             :         {
    1083           0 :             const SvxBrushItem& rBrush = ( SvxBrushItem& ) rSet.Get( nWhich );
    1084           0 :             if( GPOS_NONE == rBrush.GetGraphicPos() )
    1085           0 :                 aBackCol = rBrush.GetColor();
    1086             :         }
    1087             :     }
    1088           0 :     SetBackColor( aBackCol );
    1089             : 
    1090             :     // Font
    1091           0 :     SetPrevFont( rSet, SID_ATTR_CHAR_FONT, rFont );
    1092           0 :     SetPrevFont( rSet, SID_ATTR_CHAR_CJK_FONT, rCJKFont );
    1093           0 :     SetPrevFont( rSet, SID_ATTR_CHAR_CTL_FONT, rCTLFont );
    1094             : 
    1095             :     // Style
    1096           0 :     SetPrevFontStyle( rSet, SID_ATTR_CHAR_POSTURE, SID_ATTR_CHAR_WEIGHT, rFont );
    1097           0 :     SetPrevFontStyle( rSet, SID_ATTR_CHAR_CJK_POSTURE, SID_ATTR_CHAR_CJK_WEIGHT, rCJKFont );
    1098           0 :     SetPrevFontStyle( rSet, SID_ATTR_CHAR_CTL_POSTURE, SID_ATTR_CHAR_CTL_WEIGHT, rCTLFont );
    1099             : 
    1100             :     // Size
    1101           0 :     SetFontSize( rSet, SID_ATTR_CHAR_FONTHEIGHT, rFont );
    1102           0 :     SetFontSize( rSet, SID_ATTR_CHAR_CJK_FONTHEIGHT, rCJKFont );
    1103           0 :     SetFontSize( rSet, SID_ATTR_CHAR_CTL_FONTHEIGHT, rCTLFont );
    1104             : 
    1105             :     // Language
    1106           0 :     SetFontLang( rSet, SID_ATTR_CHAR_LANGUAGE, rFont );
    1107           0 :     SetFontLang( rSet, SID_ATTR_CHAR_CJK_LANGUAGE, rCJKFont );
    1108           0 :     SetFontLang( rSet, SID_ATTR_CHAR_CTL_LANGUAGE, rCTLFont );
    1109             : 
    1110             :     // Color
    1111           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_COLOR, nWhich ) )
    1112             :     {
    1113           0 :         const SvxColorItem& rItem = ( SvxColorItem& ) rSet.Get( nWhich );
    1114           0 :         Color aCol( rItem.GetValue() );
    1115           0 :         rFont.SetColor( aCol );
    1116             : 
    1117           0 :         rCJKFont.SetColor( aCol );
    1118           0 :         rCTLFont.SetColor( aCol );
    1119             : 
    1120           0 :         AutoCorrectFontColor(); // handle color COL_AUTO
    1121             :     }
    1122             : 
    1123             :     // Kerning
    1124           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_KERNING, nWhich ) )
    1125             :     {
    1126           0 :         const SvxKerningItem& rItem = ( SvxKerningItem& ) rSet.Get( nWhich );
    1127             :         short nKern = ( short )
    1128           0 :                         LogicToLogic( rItem.GetValue(), ( MapUnit ) rSet.GetPool()->GetMetric( nWhich ), MAP_TWIP );
    1129           0 :         rFont.SetFixKerning( nKern );
    1130           0 :         rCJKFont.SetFixKerning( nKern );
    1131           0 :         rCTLFont.SetFixKerning( nKern );
    1132             :     }
    1133             : 
    1134             :     // Escapement
    1135           0 :     const sal_uInt8 nProp = 100;
    1136             :     short nEsc;
    1137             :     sal_uInt8 nEscProp;
    1138           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_ESCAPEMENT, nWhich ) )
    1139             :     {
    1140           0 :         const SvxEscapementItem& rItem = ( SvxEscapementItem& ) rSet.Get( nWhich );
    1141           0 :         nEsc = rItem.GetEsc();
    1142           0 :         nEscProp = rItem.GetProp();
    1143             : 
    1144           0 :         if( nEsc == DFLT_ESC_AUTO_SUPER )
    1145           0 :             nEsc = DFLT_ESC_SUPER;
    1146           0 :         else if( nEsc == DFLT_ESC_AUTO_SUB )
    1147           0 :             nEsc = DFLT_ESC_SUB;
    1148             :     }
    1149             :     else
    1150             :     {
    1151           0 :         nEsc  = 0;
    1152           0 :         nEscProp = 100;
    1153             :     }
    1154           0 :     SetPrevFontEscapement( rFont, nProp, nEscProp, nEsc );
    1155           0 :     SetPrevFontEscapement( rCJKFont, nProp, nEscProp, nEsc );
    1156           0 :     SetPrevFontEscapement( rCTLFont, nProp, nEscProp, nEsc );
    1157             : 
    1158             :     // Font width scale
    1159           0 :     if( GetWhich( rSet, SID_ATTR_CHAR_SCALEWIDTH, nWhich ) )
    1160             :     {
    1161           0 :         const SvxCharScaleWidthItem&rItem = ( SvxCharScaleWidthItem& ) rSet.Get( nWhich );
    1162           0 :         SetFontWidthScale( rItem.GetValue() );
    1163             :     }
    1164             : 
    1165           0 :     Invalidate();
    1166           0 : }
    1167             : 
    1168             : // -----------------------------------------------------------------------
    1169             : 
    1170           0 : void SvxFontPrevWindow::Init( const SfxItemSet& rSet )
    1171             : {
    1172           0 :     SvxFont&        rFont = GetFont();
    1173           0 :     SvxFont&        rCJKFont = GetCJKFont();
    1174           0 :     SvxFont&        rCTLFont = GetCTLFont();
    1175             : 
    1176           0 :     initFont(rFont);
    1177           0 :     initFont(rCJKFont);
    1178           0 :     initFont(rCTLFont);
    1179           0 :     InitSettings( sal_True, sal_True );
    1180             : 
    1181             :     sal_uInt16 nWhich;
    1182           0 :     nWhich = rSet.GetPool()->GetWhich( SID_CHAR_DLG_PREVIEW_STRING );
    1183           0 :     if( ISITEMSET )
    1184             :     {
    1185           0 :         const SfxStringItem& rItem = ( SfxStringItem& ) rSet.Get( nWhich );
    1186           0 :         ::rtl::OUString aString = rItem.GetValue();
    1187           0 :         if( !aString.isEmpty() )
    1188           0 :             SetPreviewText( aString );
    1189             :         else
    1190           0 :             SetFontNameAsPreviewText();
    1191             :     }
    1192             : 
    1193             :     // Underline
    1194             :     FontUnderline eUnderline;
    1195           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_UNDERLINE );
    1196           0 :     if( ISITEMSET )
    1197             :     {
    1198           0 :         const SvxUnderlineItem& rItem = ( SvxUnderlineItem& ) rSet.Get( nWhich );
    1199           0 :         eUnderline = ( FontUnderline ) rItem.GetValue();
    1200           0 :         SetTextLineColor( rItem.GetColor() );
    1201             :     }
    1202             :     else
    1203           0 :         eUnderline = UNDERLINE_NONE;
    1204             : 
    1205           0 :     rFont.SetUnderline( eUnderline );
    1206           0 :     rCJKFont.SetUnderline( eUnderline );
    1207           0 :     rCTLFont.SetUnderline( eUnderline );
    1208             : 
    1209             :     // Overline
    1210             :     FontUnderline eOverline;
    1211           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_OVERLINE );
    1212           0 :     if( ISITEMSET )
    1213             :     {
    1214           0 :         const SvxOverlineItem& rItem = ( SvxOverlineItem& ) rSet.Get( nWhich );
    1215           0 :         eOverline = ( FontUnderline ) rItem.GetValue();
    1216           0 :         SetOverlineColor( rItem.GetColor() );
    1217             :     }
    1218             :     else
    1219           0 :         eOverline = UNDERLINE_NONE;
    1220             : 
    1221           0 :     rFont.SetOverline( eOverline );
    1222           0 :     rCJKFont.SetOverline( eOverline );
    1223           0 :     rCTLFont.SetOverline( eOverline );
    1224             : 
    1225             :     //  Strikeout
    1226             :     FontStrikeout eStrikeout;
    1227           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_STRIKEOUT );
    1228           0 :     if( ISITEMSET )
    1229             :     {
    1230           0 :         const SvxCrossedOutItem& rItem = ( SvxCrossedOutItem& ) rSet.Get( nWhich );
    1231           0 :         eStrikeout = ( FontStrikeout ) rItem.GetValue();
    1232             :     }
    1233             :     else
    1234           0 :         eStrikeout = STRIKEOUT_NONE;
    1235             : 
    1236           0 :     rFont.SetStrikeout( eStrikeout );
    1237           0 :     rCJKFont.SetStrikeout( eStrikeout );
    1238           0 :     rCTLFont.SetStrikeout( eStrikeout );
    1239             : 
    1240             :     // WordLineMode
    1241           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
    1242           0 :     if( ISITEMSET )
    1243             :     {
    1244           0 :         const SvxWordLineModeItem& rItem = ( SvxWordLineModeItem& ) rSet.Get( nWhich );
    1245           0 :         rFont.SetWordLineMode( rItem.GetValue() );
    1246           0 :         rCJKFont.SetWordLineMode( rItem.GetValue() );
    1247           0 :         rCTLFont.SetWordLineMode( rItem.GetValue() );
    1248             :     }
    1249             : 
    1250             :     // Emphasis
    1251           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_EMPHASISMARK );
    1252           0 :     if( ISITEMSET )
    1253             :     {
    1254           0 :         const SvxEmphasisMarkItem& rItem = ( SvxEmphasisMarkItem& ) rSet.Get( nWhich );
    1255           0 :         FontEmphasisMark eMark = rItem.GetEmphasisMark();
    1256           0 :         rFont.SetEmphasisMark( eMark );
    1257           0 :         rCJKFont.SetEmphasisMark( eMark );
    1258           0 :         rCTLFont.SetEmphasisMark( eMark );
    1259             :     }
    1260             : 
    1261             :     // Relief
    1262           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_RELIEF );
    1263           0 :     if( ISITEMSET )
    1264             :     {
    1265           0 :         const SvxCharReliefItem& rItem = ( SvxCharReliefItem& ) rSet.Get( nWhich );
    1266           0 :         FontRelief eFontRelief = ( FontRelief ) rItem.GetValue();
    1267           0 :         rFont.SetRelief( eFontRelief );
    1268           0 :         rCJKFont.SetRelief( eFontRelief );
    1269           0 :         rCTLFont.SetRelief( eFontRelief );
    1270             :     }
    1271             : 
    1272             :     // Effects
    1273           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_CASEMAP );
    1274           0 :     if( ISITEMSET )
    1275             :     {
    1276           0 :         const SvxCaseMapItem& rItem = ( SvxCaseMapItem& ) rSet.Get( nWhich );
    1277           0 :         SvxCaseMap eCaseMap = ( SvxCaseMap ) rItem.GetValue();
    1278           0 :         rFont.SetCaseMap( eCaseMap );
    1279           0 :         rCJKFont.SetCaseMap( eCaseMap );
    1280             :         // #i78474# small caps do not exist in CTL fonts
    1281           0 :         rCTLFont.SetCaseMap( eCaseMap == SVX_CASEMAP_KAPITAELCHEN ? SVX_CASEMAP_NOT_MAPPED : eCaseMap );
    1282             :     }
    1283             : 
    1284             :     // Outline
    1285           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_CONTOUR );
    1286           0 :     if( ISITEMSET )
    1287             :     {
    1288           0 :         const SvxContourItem& rItem = ( SvxContourItem& ) rSet.Get( nWhich );
    1289           0 :         sal_Bool bOutline = rItem.GetValue();
    1290           0 :         rFont.SetOutline( bOutline );
    1291           0 :         rCJKFont.SetOutline( bOutline );
    1292           0 :         rCTLFont.SetOutline( bOutline );
    1293             :     }
    1294             : 
    1295             :     // Shadow
    1296           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_SHADOWED );
    1297           0 :     if( ISITEMSET )
    1298             :     {
    1299           0 :         const SvxShadowedItem& rItem = ( SvxShadowedItem& ) rSet.Get( nWhich );
    1300           0 :         sal_Bool bShadow = rItem.GetValue();
    1301           0 :         rFont.SetShadow( bShadow );
    1302           0 :         rCJKFont.SetShadow( bShadow );
    1303           0 :         rCTLFont.SetShadow( bShadow );
    1304             :     }
    1305             : 
    1306             :     // Background
    1307             :     sal_Bool bTransparent;
    1308           0 :     nWhich = rSet.GetPool()->GetWhich( pImpl->bPreviewBackgroundToCharacter ? SID_ATTR_BRUSH : SID_ATTR_BRUSH_CHAR );
    1309           0 :     if( ISITEMSET )
    1310             :     {
    1311           0 :          const SvxBrushItem& rBrush = ( SvxBrushItem& ) rSet.Get( nWhich );
    1312           0 :          const Color& rColor = rBrush.GetColor();
    1313           0 :          bTransparent = rColor.GetTransparency() > 0;
    1314           0 :          rFont.SetFillColor( rColor );
    1315           0 :          rCJKFont.SetFillColor( rColor );
    1316           0 :          rCTLFont.SetFillColor( rColor );
    1317             :     }
    1318             :     else
    1319           0 :         bTransparent = sal_True;
    1320             : 
    1321           0 :     rFont.SetTransparent( bTransparent );
    1322           0 :     rCJKFont.SetTransparent( bTransparent );
    1323           0 :     rCTLFont.SetTransparent( bTransparent );
    1324             : 
    1325           0 :     Color aBackCol( COL_TRANSPARENT );
    1326           0 :     if( !pImpl->bPreviewBackgroundToCharacter )
    1327             :     {
    1328           0 :         nWhich = rSet.GetPool()->GetWhich( SID_ATTR_BRUSH );
    1329           0 :         if( ISITEMSET )
    1330             :         {
    1331           0 :             const SvxBrushItem& rBrush = ( SvxBrushItem& ) rSet.Get( nWhich );
    1332           0 :             if( GPOS_NONE == rBrush.GetGraphicPos() )
    1333           0 :                 aBackCol = rBrush.GetColor();
    1334             :         }
    1335             :     }
    1336           0 :     SetBackColor( aBackCol );
    1337             : 
    1338             :     // Font
    1339           0 :     SetFont( rSet, SID_ATTR_CHAR_FONT, rFont );
    1340           0 :     SetFont( rSet, SID_ATTR_CHAR_CJK_FONT, rCJKFont );
    1341           0 :     SetFont( rSet, SID_ATTR_CHAR_CTL_FONT, rCTLFont );
    1342             : 
    1343             :     // Style
    1344           0 :     SetFontStyle( rSet, SID_ATTR_CHAR_POSTURE, SID_ATTR_CHAR_WEIGHT, rFont );
    1345           0 :     SetFontStyle( rSet, SID_ATTR_CHAR_CJK_POSTURE, SID_ATTR_CHAR_CJK_WEIGHT, rCJKFont );
    1346           0 :     SetFontStyle( rSet, SID_ATTR_CHAR_CTL_POSTURE, SID_ATTR_CHAR_CTL_WEIGHT, rCTLFont );
    1347             : 
    1348             :     // Size
    1349           0 :     SetFontSize( rSet, SID_ATTR_CHAR_FONTHEIGHT, rFont );
    1350           0 :     SetFontSize( rSet, SID_ATTR_CHAR_CJK_FONTHEIGHT, rCJKFont );
    1351           0 :     SetFontSize( rSet, SID_ATTR_CHAR_CTL_FONTHEIGHT, rCTLFont );
    1352             : 
    1353             :     // Language
    1354           0 :     SetFontLang( rSet, SID_ATTR_CHAR_LANGUAGE, rFont );
    1355           0 :     SetFontLang( rSet, SID_ATTR_CHAR_CJK_LANGUAGE, rCJKFont );
    1356           0 :     SetFontLang( rSet, SID_ATTR_CHAR_CTL_LANGUAGE, rCTLFont );
    1357             : 
    1358             :     // Color
    1359           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_COLOR );
    1360           0 :     if( ISITEMSET )
    1361             :     {
    1362           0 :         const SvxColorItem& rItem = ( SvxColorItem& ) rSet.Get( nWhich );
    1363           0 :         Color aCol( rItem.GetValue() );
    1364           0 :         rFont.SetColor( aCol );
    1365           0 :         rCJKFont.SetColor( aCol );
    1366           0 :         rCTLFont.SetColor( aCol );
    1367             : 
    1368           0 :         AutoCorrectFontColor(); // handle color COL_AUTO
    1369             :     }
    1370             : 
    1371             :     // Kerning
    1372           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_KERNING );
    1373           0 :     if( ISITEMSET )
    1374             :     {
    1375           0 :         const SvxKerningItem& rItem = ( SvxKerningItem& ) rSet.Get( nWhich );
    1376             :         short nKern = ( short )
    1377           0 :                         LogicToLogic( rItem.GetValue(), ( MapUnit ) rSet.GetPool()->GetMetric( nWhich ), MAP_TWIP );
    1378           0 :         rFont.SetFixKerning( nKern );
    1379           0 :         rCJKFont.SetFixKerning( nKern );
    1380           0 :         rCTLFont.SetFixKerning( nKern );
    1381             :     }
    1382             : 
    1383             :     // Escapement
    1384           0 :     nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_ESCAPEMENT );
    1385           0 :     const sal_uInt8 nProp = 100;
    1386             :     short nEsc;
    1387             :     sal_uInt8 nEscProp;
    1388           0 :     if( ISITEMSET )
    1389             :     {
    1390           0 :         const SvxEscapementItem& rItem = ( SvxEscapementItem& ) rSet.Get( nWhich );
    1391           0 :         nEsc = rItem.GetEsc();
    1392           0 :         nEscProp = rItem.GetProp();
    1393             : 
    1394           0 :         if( nEsc == DFLT_ESC_AUTO_SUPER )
    1395           0 :             nEsc = DFLT_ESC_SUPER;
    1396           0 :         else if( nEsc == DFLT_ESC_AUTO_SUB )
    1397           0 :             nEsc = DFLT_ESC_SUB;
    1398             :     }
    1399             :     else
    1400             :     {
    1401           0 :         nEsc  = 0;
    1402           0 :         nEscProp = 100;
    1403             :     }
    1404             : 
    1405           0 :     SetFontEscapement( nProp, nEscProp, nEsc );
    1406             : 
    1407             :     // Font width scale
    1408           0 :     SetFontWidthScale( rSet );
    1409             : 
    1410           0 :     Invalidate();
    1411           0 : }
    1412             : 
    1413             : // -----------------------------------------------------------------------
    1414             : 
    1415             : 
    1416             : // -----------------------------------------------------------------------
    1417             : 
    1418           0 : void SvxFontPrevWindow::SetFont( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont )
    1419             : {
    1420           0 :     sal_uInt16 nWhich = rSet.GetPool()->GetWhich( nSlot );
    1421           0 :     if( ISITEMSET )
    1422             :     {
    1423           0 :         const SvxFontItem& rFontItem = (const SvxFontItem&)rSet.Get(nWhich);
    1424           0 :         rFont.SetFamily( rFontItem.GetFamily() );
    1425           0 :         rFont.SetName( rFontItem.GetFamilyName() );
    1426           0 :         rFont.SetPitch( rFontItem.GetPitch() );
    1427           0 :         rFont.SetCharSet( rFontItem.GetCharSet() );
    1428           0 :         rFont.SetStyleName( rFontItem.GetStyleName() );
    1429             :     }
    1430           0 : }
    1431             : 
    1432             : // -----------------------------------------------------------------------
    1433             : 
    1434           0 : void SvxFontPrevWindow::SetFontStyle( const SfxItemSet& rSet, sal_uInt16 nPosture, sal_uInt16 nWeight, SvxFont& rFont )
    1435             : {
    1436           0 :     sal_uInt16 nWhich = rSet.GetPool()->GetWhich( nPosture );
    1437           0 :     if( ISITEMSET )
    1438             :     {
    1439           0 :         const SvxPostureItem& rItem = ( SvxPostureItem& ) rSet.Get( nWhich );
    1440           0 :         rFont.SetItalic( ( FontItalic ) rItem.GetValue() != ITALIC_NONE ? ITALIC_NORMAL : ITALIC_NONE );
    1441             :     }
    1442             : 
    1443           0 :     nWhich = rSet.GetPool()->GetWhich( nWeight );
    1444           0 :     if( ISITEMSET )
    1445             :     {
    1446           0 :         SvxWeightItem& rItem = ( SvxWeightItem& ) rSet.Get( nWhich );
    1447           0 :         rFont.SetWeight( ( FontWeight ) rItem.GetValue() != WEIGHT_NORMAL ? WEIGHT_BOLD : WEIGHT_NORMAL );
    1448             :     }
    1449           0 : }
    1450             : 
    1451             : // -----------------------------------------------------------------------
    1452             : 
    1453           0 : void SvxFontPrevWindow::SetFontWidthScale( const SfxItemSet& rSet )
    1454             : {
    1455           0 :     sal_uInt16  nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
    1456           0 :     if( ISITEMSET )
    1457             :     {
    1458           0 :         const SvxCharScaleWidthItem&    rItem = ( SvxCharScaleWidthItem& ) rSet.Get( nWhich );
    1459             : 
    1460           0 :         SetFontWidthScale( rItem.GetValue() );
    1461             :     }
    1462           0 : }
    1463             : 
    1464             : // -----------------------------------------------------------------------
    1465             : namespace
    1466             : {
    1467             :     // -----------------------------------------------------------------------
    1468           0 :     void setFontEscapement(SvxFont& _rFont,sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
    1469             :     {
    1470           0 :         _rFont.SetPropr( nProp );
    1471           0 :         _rFont.SetProprRel( nEscProp );
    1472           0 :         _rFont.SetEscapement( nEsc );
    1473           0 :     }
    1474             :     // -----------------------------------------------------------------------
    1475             :     // -----------------------------------------------------------------------
    1476             : }
    1477             : // -----------------------------------------------------------------------
    1478             : 
    1479           0 : void SvxFontPrevWindow::SetFontEscapement( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
    1480             : {
    1481           0 :     setFontEscapement(GetFont(),nProp,nEscProp,nEsc);
    1482           0 :     setFontEscapement(GetCJKFont(),nProp,nEscProp,nEsc);
    1483           0 :     setFontEscapement(GetCTLFont(),nProp,nEscProp,nEsc);
    1484           0 :     Invalidate();
    1485           0 : }
    1486             : 
    1487           0 : Size SvxFontPrevWindow::GetOptimalSize(WindowSizeType eType) const
    1488             : {
    1489           0 :     if (eType == WINDOWSIZE_MAXIMUM)
    1490           0 :         return Window::GetOptimalSize(eType);
    1491             : 
    1492           0 :     return m_aInitialSize;
    1493             : }
    1494             : 
    1495             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10