1*f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f6e50924SAndrew Rist * distributed with this work for additional information 6*f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9*f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f6e50924SAndrew Rist * software distributed under the License is distributed on an 15*f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17*f6e50924SAndrew Rist * specific language governing permissions and limitations 18*f6e50924SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*f6e50924SAndrew Rist *************************************************************/ 21*f6e50924SAndrew Rist 22*f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svx.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir // include --------------------------------------------------------------- 28cdf0e10cSrcweir #include <sfx2/viewsh.hxx> // SfxViewShell 29cdf0e10cSrcweir #include <sfx2/printer.hxx> // Printer 30cdf0e10cSrcweir #include <vcl/metric.hxx> 31cdf0e10cSrcweir #include <vcl/svapp.hxx> 32cdf0e10cSrcweir #include <unicode/uchar.h> 33cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h> 34cdf0e10cSrcweir #include <com/sun/star/i18n/XBreakIterator.hpp> 35cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 36cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 37cdf0e10cSrcweir 38cdf0e10cSrcweir #ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ 39cdf0e10cSrcweir #include <com/sun/star/i18n/ScriptType.hdl> 40cdf0e10cSrcweir #endif 41cdf0e10cSrcweir 42cdf0e10cSrcweir #ifndef _SVSTDARR_HXX 43cdf0e10cSrcweir #define _SVSTDARR_USHORTS 44cdf0e10cSrcweir #define _SVSTDARR_ULONGS 45cdf0e10cSrcweir #define _SVSTDARR_XUB_STRLEN 46cdf0e10cSrcweir #include <svl/svstdarr.hxx> 47cdf0e10cSrcweir #endif 48cdf0e10cSrcweir #include <svtools/colorcfg.hxx> 49cdf0e10cSrcweir 50cdf0e10cSrcweir #include <svx/fntctrl.hxx> 51cdf0e10cSrcweir #include <svx/dialogs.hrc> 52cdf0e10cSrcweir #define TEXT_WIDTH 20 53cdf0e10cSrcweir 54cdf0e10cSrcweir using namespace ::com::sun::star::uno; 55cdf0e10cSrcweir using namespace ::com::sun::star::lang; 56cdf0e10cSrcweir using ::com::sun::star::i18n::XBreakIterator; 57cdf0e10cSrcweir 58cdf0e10cSrcweir // ----------------------------------------------------------------------- 59cdf0e10cSrcweir // small helper functions to set fonts 60cdf0e10cSrcweir // ----------------------------------------------------------------------- 61cdf0e10cSrcweir namespace 62cdf0e10cSrcweir { 63cdf0e10cSrcweir void scaleFontWidth(Font& _rFont,const OutputDevice& rOutDev,long& _n100PercentFont) 64cdf0e10cSrcweir { 65cdf0e10cSrcweir _rFont.SetWidth( 0 ); 66cdf0e10cSrcweir _n100PercentFont = rOutDev.GetFontMetric( _rFont ).GetWidth(); 67cdf0e10cSrcweir } 68cdf0e10cSrcweir // ----------------------------------------------------------------------- 69cdf0e10cSrcweir void initFont(Font& _rFont) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir _rFont.SetTransparent(sal_True); 72cdf0e10cSrcweir _rFont.SetAlign(ALIGN_BASELINE); 73cdf0e10cSrcweir } 74cdf0e10cSrcweir // ----------------------------------------------------------------------- 75cdf0e10cSrcweir void setFontSize(Font& _rFont) 76cdf0e10cSrcweir { 77cdf0e10cSrcweir Size aSize( _rFont.GetSize() ); 78cdf0e10cSrcweir aSize.Height() = ( aSize.Height() * 3 ) / 5; 79cdf0e10cSrcweir aSize.Width() = ( aSize.Width() * 3 ) / 5; 80cdf0e10cSrcweir _rFont.SetSize( aSize ); 81cdf0e10cSrcweir } 82cdf0e10cSrcweir // ----------------------------------------------------------------------- 83cdf0e10cSrcweir void calcFontHeightAnyAscent(OutputDevice* _pWin,Font& _rFont,long& _nHeight,long& _nAscent) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir if ( !_nHeight ) 86cdf0e10cSrcweir { 87cdf0e10cSrcweir _pWin->SetFont( _rFont ); 88cdf0e10cSrcweir FontMetric aMetric( _pWin->GetFontMetric() ); 89cdf0e10cSrcweir _nHeight = aMetric.GetLineHeight(); 90cdf0e10cSrcweir _nAscent = aMetric.GetAscent(); 91cdf0e10cSrcweir } 92cdf0e10cSrcweir } 93cdf0e10cSrcweir // ----------------------------------------------------------------------- 94cdf0e10cSrcweir void setFont( const SvxFont& rNewFont, SvxFont& rImplFont ) 95cdf0e10cSrcweir { 96cdf0e10cSrcweir rImplFont = rNewFont; 97cdf0e10cSrcweir rImplFont.SetTransparent( sal_True ); 98cdf0e10cSrcweir rImplFont.SetAlign( ALIGN_BASELINE ); 99cdf0e10cSrcweir } 100cdf0e10cSrcweir 101cdf0e10cSrcweir } 102cdf0e10cSrcweir // ----------------------------------------------------------------------- 103cdf0e10cSrcweir 104cdf0e10cSrcweir 105cdf0e10cSrcweir // class FontPrevWin_Impl ----------------------------------------------- 106cdf0e10cSrcweir 107cdf0e10cSrcweir class FontPrevWin_Impl 108cdf0e10cSrcweir { 109cdf0e10cSrcweir friend class SvxFontPrevWindow; 110cdf0e10cSrcweir 111cdf0e10cSrcweir SvxFont aFont; 112cdf0e10cSrcweir Printer* pPrinter; 113cdf0e10cSrcweir sal_Bool bDelPrinter; 114cdf0e10cSrcweir 115cdf0e10cSrcweir Reference < XBreakIterator > xBreak; 116cdf0e10cSrcweir SvULongs aTextWidth; 117cdf0e10cSrcweir SvXub_StrLens aScriptChg; 118cdf0e10cSrcweir SvUShorts aScriptType; 119cdf0e10cSrcweir SvxFont aCJKFont; 120cdf0e10cSrcweir SvxFont aCTLFont; 121cdf0e10cSrcweir String aText; 122cdf0e10cSrcweir String aScriptText; 123cdf0e10cSrcweir Color* pColor; 124cdf0e10cSrcweir Color* pBackColor; 125cdf0e10cSrcweir long nAscent; 126cdf0e10cSrcweir sal_Unicode cStartBracket; 127cdf0e10cSrcweir sal_Unicode cEndBracket; 128cdf0e10cSrcweir 129cdf0e10cSrcweir long n100PercentFontWidth; // initial -1 -> not set yet 130cdf0e10cSrcweir long n100PercentFontWidthCJK; 131cdf0e10cSrcweir long n100PercentFontWidthCTL; 132cdf0e10cSrcweir sal_uInt16 nFontWidthScale; 133cdf0e10cSrcweir 134cdf0e10cSrcweir sal_Bool bSelection : 1, 135cdf0e10cSrcweir bGetSelection : 1, 136cdf0e10cSrcweir bUseResText : 1, 137cdf0e10cSrcweir bTwoLines : 1, 138cdf0e10cSrcweir bIsCJKUI : 1, 139cdf0e10cSrcweir bIsCTLUI : 1, 140cdf0e10cSrcweir bUseFontNameAsText : 1, 141cdf0e10cSrcweir bTextInited : 1; 142cdf0e10cSrcweir 143cdf0e10cSrcweir void _CheckScript(); 144cdf0e10cSrcweir public: 145cdf0e10cSrcweir inline FontPrevWin_Impl() : 146cdf0e10cSrcweir pPrinter( NULL ), bDelPrinter( sal_False ), 147cdf0e10cSrcweir pColor( NULL ), pBackColor( 0 ), 148cdf0e10cSrcweir cStartBracket( 0 ), cEndBracket( 0 ), nFontWidthScale( 100 ), 149cdf0e10cSrcweir bSelection( sal_False ), bGetSelection( sal_False ), bUseResText( sal_False ), 150cdf0e10cSrcweir bTwoLines( sal_False ), 151cdf0e10cSrcweir bIsCJKUI( sal_False ), bIsCTLUI( sal_False ), 152cdf0e10cSrcweir bUseFontNameAsText( sal_False ), bTextInited( sal_False ) 153cdf0e10cSrcweir { 154cdf0e10cSrcweir Invalidate100PercentFontWidth(); 155cdf0e10cSrcweir } 156cdf0e10cSrcweir 157cdf0e10cSrcweir inline ~FontPrevWin_Impl() 158cdf0e10cSrcweir { 159cdf0e10cSrcweir delete pColor; 160cdf0e10cSrcweir delete pBackColor; 161cdf0e10cSrcweir if( bDelPrinter ) 162cdf0e10cSrcweir delete pPrinter; 163cdf0e10cSrcweir } 164cdf0e10cSrcweir 165cdf0e10cSrcweir void CheckScript(); 166cdf0e10cSrcweir Size CalcTextSize( OutputDevice* pWin, OutputDevice* pPrt, SvxFont &rFont ); 167cdf0e10cSrcweir void DrawPrev( OutputDevice* pWin, Printer* pPrt, Point &rPt, SvxFont &rFont ); 168cdf0e10cSrcweir 169cdf0e10cSrcweir sal_Bool SetFontWidthScale( sal_uInt16 nScaleInPercent ); 170cdf0e10cSrcweir inline void Invalidate100PercentFontWidth(); 171cdf0e10cSrcweir inline sal_Bool Is100PercentFontWidthValid() const; 172cdf0e10cSrcweir void ScaleFontWidth( const OutputDevice& rOutDev ); 173cdf0e10cSrcweir // scales rNonCJKFont and aCJKFont depending on nFontWidthScale and 174cdf0e10cSrcweir // sets the 100%-Font-Widths 175cdf0e10cSrcweir }; 176cdf0e10cSrcweir 177cdf0e10cSrcweir void FontPrevWin_Impl::CheckScript() 178cdf0e10cSrcweir { 179cdf0e10cSrcweir if( aText != aScriptText ) 180cdf0e10cSrcweir _CheckScript(); 181cdf0e10cSrcweir } 182cdf0e10cSrcweir 183cdf0e10cSrcweir inline void FontPrevWin_Impl::Invalidate100PercentFontWidth() 184cdf0e10cSrcweir { 185cdf0e10cSrcweir n100PercentFontWidth = n100PercentFontWidthCJK = n100PercentFontWidthCTL = -1; 186cdf0e10cSrcweir } 187cdf0e10cSrcweir 188cdf0e10cSrcweir inline sal_Bool FontPrevWin_Impl::Is100PercentFontWidthValid() const 189cdf0e10cSrcweir { 190cdf0e10cSrcweir DBG_ASSERT( ( n100PercentFontWidth == -1 && n100PercentFontWidthCJK == -1 ) || 191cdf0e10cSrcweir ( n100PercentFontWidth != -1 && n100PercentFontWidthCJK != -1 ) || 192cdf0e10cSrcweir ( n100PercentFontWidth == -1 && n100PercentFontWidthCTL == -1 ) || 193cdf0e10cSrcweir ( n100PercentFontWidth != -1 && n100PercentFontWidthCTL != -1 ), 194cdf0e10cSrcweir "*FontPrevWin_Impl::Is100PercentFontWidthValid(): 100PercentFontWidth's not synchronous" ); 195cdf0e10cSrcweir return n100PercentFontWidth != -1; 196cdf0e10cSrcweir } 197cdf0e10cSrcweir 198cdf0e10cSrcweir // class FontPrevWin_Impl ----------------------------------------------- 199cdf0e10cSrcweir 200cdf0e10cSrcweir /*-----------------19.7.2001 08:44------------------ 201cdf0e10cSrcweir * void FontPrevWin_Impl::_CheckScript() 202cdf0e10cSrcweir * evalutates the scripttypes of the actual string. 203cdf0e10cSrcweir * Afterwards the positions of script change are notified in aScriptChg, 204cdf0e10cSrcweir * the scripttypes in aScriptType. 205cdf0e10cSrcweir * The aTextWidth array will be filled with zero. 206cdf0e10cSrcweir * --------------------------------------------------*/ 207cdf0e10cSrcweir 208cdf0e10cSrcweir void FontPrevWin_Impl::_CheckScript() 209cdf0e10cSrcweir { 210cdf0e10cSrcweir aScriptText = aText; 211cdf0e10cSrcweir size_t nCnt = aScriptChg.size(); 212cdf0e10cSrcweir if( nCnt ) 213cdf0e10cSrcweir { 214cdf0e10cSrcweir aScriptChg.clear(); 215cdf0e10cSrcweir aScriptType.Remove( 0, nCnt ); 216cdf0e10cSrcweir aTextWidth.Remove( 0, nCnt ); 217cdf0e10cSrcweir nCnt = 0; 218cdf0e10cSrcweir } 219cdf0e10cSrcweir if( !xBreak.is() ) 220cdf0e10cSrcweir { 221cdf0e10cSrcweir Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); 222cdf0e10cSrcweir xBreak = Reference< XBreakIterator >(xMSF->createInstance( 223cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "com.sun.star.i18n.BreakIterator" ) ),UNO_QUERY); 224cdf0e10cSrcweir } 225cdf0e10cSrcweir if( xBreak.is() ) 226cdf0e10cSrcweir { 227cdf0e10cSrcweir sal_uInt16 nScript = xBreak->getScriptType( aText, 0 ); 228cdf0e10cSrcweir sal_uInt16 nChg = 0; 229cdf0e10cSrcweir if( com::sun::star::i18n::ScriptType::WEAK == nScript ) 230cdf0e10cSrcweir { 231cdf0e10cSrcweir nChg = (xub_StrLen)xBreak->endOfScript( aText, nChg, nScript ); 232cdf0e10cSrcweir if( nChg < aText.Len() ) 233cdf0e10cSrcweir nScript = xBreak->getScriptType( aText, nChg ); 234cdf0e10cSrcweir else 235cdf0e10cSrcweir nScript = com::sun::star::i18n::ScriptType::LATIN; 236cdf0e10cSrcweir } 237cdf0e10cSrcweir 238cdf0e10cSrcweir do 239cdf0e10cSrcweir { 240cdf0e10cSrcweir nChg = (xub_StrLen)xBreak->endOfScript( aText, nChg, nScript ); 241cdf0e10cSrcweir if (nChg < aText.Len() && nChg > 0 && 242cdf0e10cSrcweir (com::sun::star::i18n::ScriptType::WEAK == 243cdf0e10cSrcweir xBreak->getScriptType(aText, nChg - 1))) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir int8_t nType = u_charType(aText.GetChar(nChg) ); 246cdf0e10cSrcweir if (nType == U_NON_SPACING_MARK || nType == U_ENCLOSING_MARK || 247cdf0e10cSrcweir nType == U_COMBINING_SPACING_MARK ) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir aScriptChg.push_back( nChg - 1 ); 250cdf0e10cSrcweir } 251cdf0e10cSrcweir else 252cdf0e10cSrcweir { 253cdf0e10cSrcweir aScriptChg.push_back( nChg ); 254cdf0e10cSrcweir } 255cdf0e10cSrcweir } 256cdf0e10cSrcweir else 257cdf0e10cSrcweir { 258cdf0e10cSrcweir aScriptChg.push_back( nChg ); 259cdf0e10cSrcweir } 260cdf0e10cSrcweir aScriptType.Insert( nScript, nCnt ); 261cdf0e10cSrcweir aTextWidth.Insert( sal_uIntPtr(0), nCnt++ ); 262cdf0e10cSrcweir 263cdf0e10cSrcweir if( nChg < aText.Len() ) 264cdf0e10cSrcweir nScript = xBreak->getScriptType( aText, nChg ); 265cdf0e10cSrcweir else 266cdf0e10cSrcweir break; 267cdf0e10cSrcweir } while( sal_True ); 268cdf0e10cSrcweir } 269cdf0e10cSrcweir } 270cdf0e10cSrcweir 271cdf0e10cSrcweir /*-----------------19.7.2001 08:48------------------ 272cdf0e10cSrcweir * Size FontPrevWin_Impl::CalcTextSize(..) 273cdf0e10cSrcweir * fills the aTextWidth array with the text width of every part 274cdf0e10cSrcweir * of the actual string without a script change inside. 275cdf0e10cSrcweir * For Latin parts the given rFont will be used, 276cdf0e10cSrcweir * for Asian parts the aCJKFont. 277cdf0e10cSrcweir * The returned size contains the whole string. 278cdf0e10cSrcweir * The member nAscent is calculated to the maximal ascent of all used fonts. 279cdf0e10cSrcweir * --------------------------------------------------*/ 280cdf0e10cSrcweir 281cdf0e10cSrcweir Size FontPrevWin_Impl::CalcTextSize( OutputDevice* pWin, OutputDevice* _pPrinter, 282cdf0e10cSrcweir SvxFont &rFont ) 283cdf0e10cSrcweir { 284cdf0e10cSrcweir sal_uInt16 nScript; 285cdf0e10cSrcweir sal_uInt16 nIdx = 0; 286cdf0e10cSrcweir xub_StrLen nStart = 0; 287cdf0e10cSrcweir xub_StrLen nEnd; 288cdf0e10cSrcweir size_t nCnt = aScriptChg.size(); 289cdf0e10cSrcweir if( nCnt ) 290cdf0e10cSrcweir { 291cdf0e10cSrcweir nEnd = aScriptChg[ nIdx ]; 292cdf0e10cSrcweir nScript = aScriptType[ nIdx ]; 293cdf0e10cSrcweir } 294cdf0e10cSrcweir else 295cdf0e10cSrcweir { 296cdf0e10cSrcweir nEnd = aText.Len(); 297cdf0e10cSrcweir nScript = com::sun::star::i18n::ScriptType::LATIN; 298cdf0e10cSrcweir } 299cdf0e10cSrcweir long nTxtWidth = 0; 300cdf0e10cSrcweir long nCJKHeight = 0; 301cdf0e10cSrcweir long nCTLHeight = 0; 302cdf0e10cSrcweir long nHeight = 0; 303cdf0e10cSrcweir nAscent = 0; 304cdf0e10cSrcweir long nCJKAscent = 0; 305cdf0e10cSrcweir long nCTLAscent = 0; 306cdf0e10cSrcweir do 307cdf0e10cSrcweir { 308cdf0e10cSrcweir SvxFont& rFnt = (nScript==com::sun::star::i18n::ScriptType::ASIAN) ? aCJKFont : ((nScript==com::sun::star::i18n::ScriptType::COMPLEX) ? aCTLFont : rFont); 309cdf0e10cSrcweir sal_uIntPtr nWidth = rFnt.GetTxtSize( _pPrinter, aText, nStart, nEnd-nStart ). 310cdf0e10cSrcweir Width(); 311cdf0e10cSrcweir aTextWidth[ nIdx++ ] = nWidth; 312cdf0e10cSrcweir nTxtWidth += nWidth; 313cdf0e10cSrcweir switch(nScript) 314cdf0e10cSrcweir { 315cdf0e10cSrcweir case com::sun::star::i18n::ScriptType::ASIAN: 316cdf0e10cSrcweir calcFontHeightAnyAscent(pWin,aCJKFont,nCJKHeight,nCJKAscent); 317cdf0e10cSrcweir break; 318cdf0e10cSrcweir case com::sun::star::i18n::ScriptType::COMPLEX: 319cdf0e10cSrcweir calcFontHeightAnyAscent(pWin,aCTLFont,nCTLHeight,nCTLAscent); 320cdf0e10cSrcweir break; 321cdf0e10cSrcweir default: 322cdf0e10cSrcweir calcFontHeightAnyAscent(pWin,rFont,nHeight,nAscent); 323cdf0e10cSrcweir } 324cdf0e10cSrcweir 325cdf0e10cSrcweir if( nEnd < aText.Len() && nIdx < nCnt ) 326cdf0e10cSrcweir { 327cdf0e10cSrcweir nStart = nEnd; 328cdf0e10cSrcweir nEnd = aScriptChg[ nIdx ]; 329cdf0e10cSrcweir nScript = aScriptType[ nIdx ]; 330cdf0e10cSrcweir } 331cdf0e10cSrcweir else 332cdf0e10cSrcweir break; 333cdf0e10cSrcweir } 334cdf0e10cSrcweir while( sal_True ); 335cdf0e10cSrcweir nHeight -= nAscent; 336cdf0e10cSrcweir nCJKHeight -= nCJKAscent; 337cdf0e10cSrcweir nCTLHeight -= nCTLAscent; 338cdf0e10cSrcweir if( nHeight < nCJKHeight ) 339cdf0e10cSrcweir nHeight = nCJKHeight; 340cdf0e10cSrcweir if( nAscent < nCJKAscent ) 341cdf0e10cSrcweir nAscent = nCJKAscent; 342cdf0e10cSrcweir if( nHeight < nCTLHeight ) 343cdf0e10cSrcweir nHeight = nCTLHeight; 344cdf0e10cSrcweir if( nAscent < nCTLAscent ) 345cdf0e10cSrcweir nAscent = nCTLAscent; 346cdf0e10cSrcweir nHeight += nAscent; 347cdf0e10cSrcweir 348cdf0e10cSrcweir Size aTxtSize( nTxtWidth, nHeight ); 349cdf0e10cSrcweir return aTxtSize; 350cdf0e10cSrcweir } 351cdf0e10cSrcweir 352cdf0e10cSrcweir /*-----------------19.7.2001 08:54------------------ 353cdf0e10cSrcweir * void FontPrevWin_Impl::DrawPrev(..) 354cdf0e10cSrcweir * calls SvxFont::DrawPrev(..) for every part of the string without a script 355cdf0e10cSrcweir * change inside, for Asian parts the aCJKFont will be used, otherwise the 356cdf0e10cSrcweir * given rFont. 357cdf0e10cSrcweir * --------------------------------------------------*/ 358cdf0e10cSrcweir 359cdf0e10cSrcweir void FontPrevWin_Impl::DrawPrev( OutputDevice* pWin, Printer* _pPrinter, 360cdf0e10cSrcweir Point &rPt, SvxFont &rFont ) 361cdf0e10cSrcweir { 362cdf0e10cSrcweir Font aOldFont = _pPrinter->GetFont(); 363cdf0e10cSrcweir sal_uInt16 nScript; 364cdf0e10cSrcweir sal_uInt16 nIdx = 0; 365cdf0e10cSrcweir xub_StrLen nStart = 0; 366cdf0e10cSrcweir xub_StrLen nEnd; 367cdf0e10cSrcweir size_t nCnt = aScriptChg.size(); 368cdf0e10cSrcweir if( nCnt ) 369cdf0e10cSrcweir { 370cdf0e10cSrcweir nEnd = aScriptChg[ nIdx ]; 371cdf0e10cSrcweir nScript = aScriptType[ nIdx ]; 372cdf0e10cSrcweir } 373cdf0e10cSrcweir else 374cdf0e10cSrcweir { 375cdf0e10cSrcweir nEnd = aText.Len(); 376cdf0e10cSrcweir nScript = com::sun::star::i18n::ScriptType::LATIN; 377cdf0e10cSrcweir } 378cdf0e10cSrcweir do 379cdf0e10cSrcweir { 380cdf0e10cSrcweir SvxFont& rFnt = (nScript==com::sun::star::i18n::ScriptType::ASIAN) ? aCJKFont : ((nScript==com::sun::star::i18n::ScriptType::COMPLEX) ? aCTLFont : rFont); 381cdf0e10cSrcweir _pPrinter->SetFont( rFnt ); 382cdf0e10cSrcweir 383cdf0e10cSrcweir rFnt.DrawPrev( pWin, _pPrinter, rPt, aText, nStart, nEnd - nStart ); 384cdf0e10cSrcweir 385cdf0e10cSrcweir rPt.X() += aTextWidth[ nIdx++ ]; 386cdf0e10cSrcweir if( nEnd < aText.Len() && nIdx < nCnt ) 387cdf0e10cSrcweir { 388cdf0e10cSrcweir nStart = nEnd; 389cdf0e10cSrcweir nEnd = aScriptChg[ nIdx ]; 390cdf0e10cSrcweir nScript = aScriptType[ nIdx ]; 391cdf0e10cSrcweir } 392cdf0e10cSrcweir else 393cdf0e10cSrcweir break; 394cdf0e10cSrcweir } 395cdf0e10cSrcweir while( sal_True ); 396cdf0e10cSrcweir _pPrinter->SetFont( aOldFont ); 397cdf0e10cSrcweir } 398cdf0e10cSrcweir 399cdf0e10cSrcweir // ----------------------------------------------------------------------- 400cdf0e10cSrcweir 401cdf0e10cSrcweir sal_Bool FontPrevWin_Impl::SetFontWidthScale( sal_uInt16 nScale ) 402cdf0e10cSrcweir { 403cdf0e10cSrcweir if( nFontWidthScale != nScale ) 404cdf0e10cSrcweir { 405cdf0e10cSrcweir nFontWidthScale = nScale; 406cdf0e10cSrcweir return sal_True; 407cdf0e10cSrcweir } 408cdf0e10cSrcweir 409cdf0e10cSrcweir return sal_False; 410cdf0e10cSrcweir } 411cdf0e10cSrcweir 412cdf0e10cSrcweir 413cdf0e10cSrcweir // ----------------------------------------------------------------------- 414cdf0e10cSrcweir 415cdf0e10cSrcweir void FontPrevWin_Impl::ScaleFontWidth( const OutputDevice& rOutDev ) 416cdf0e10cSrcweir { 417cdf0e10cSrcweir if( !Is100PercentFontWidthValid() ) 418cdf0e10cSrcweir { 419cdf0e10cSrcweir scaleFontWidth(aFont,rOutDev,n100PercentFontWidth); 420cdf0e10cSrcweir scaleFontWidth(aCJKFont,rOutDev,n100PercentFontWidthCJK); 421cdf0e10cSrcweir scaleFontWidth(aCTLFont,rOutDev,n100PercentFontWidthCTL); 422cdf0e10cSrcweir } 423cdf0e10cSrcweir 424cdf0e10cSrcweir aFont.SetWidth( n100PercentFontWidth * nFontWidthScale / 100 ); 425cdf0e10cSrcweir aCJKFont.SetWidth( n100PercentFontWidthCJK * nFontWidthScale / 100 ); 426cdf0e10cSrcweir aCTLFont.SetWidth( n100PercentFontWidthCTL * nFontWidthScale / 100 ); 427cdf0e10cSrcweir } 428cdf0e10cSrcweir 429cdf0e10cSrcweir // class SvxFontPrevWindow ----------------------------------------------- 430cdf0e10cSrcweir 431cdf0e10cSrcweir void SvxFontPrevWindow::InitSettings( sal_Bool bForeground, sal_Bool bBackground ) 432cdf0e10cSrcweir { 433cdf0e10cSrcweir const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); 434cdf0e10cSrcweir 435cdf0e10cSrcweir if ( bForeground ) 436cdf0e10cSrcweir { 437cdf0e10cSrcweir svtools::ColorConfig aColorConfig; 438cdf0e10cSrcweir Color aTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor ); 439cdf0e10cSrcweir 440cdf0e10cSrcweir if ( IsControlForeground() ) 441cdf0e10cSrcweir aTextColor = GetControlForeground(); 442cdf0e10cSrcweir SetTextColor( aTextColor ); 443cdf0e10cSrcweir } 444cdf0e10cSrcweir 445cdf0e10cSrcweir if ( bBackground ) 446cdf0e10cSrcweir { 447cdf0e10cSrcweir if ( IsControlBackground() ) 448cdf0e10cSrcweir SetBackground( GetControlBackground() ); 449cdf0e10cSrcweir else 450cdf0e10cSrcweir SetBackground( rStyleSettings.GetWindowColor() ); 451cdf0e10cSrcweir } 452cdf0e10cSrcweir Invalidate(); 453cdf0e10cSrcweir } 454cdf0e10cSrcweir 455cdf0e10cSrcweir // ----------------------------------------------------------------------- 456cdf0e10cSrcweir 457cdf0e10cSrcweir SvxFontPrevWindow::SvxFontPrevWindow( Window* pParent, const ResId& rId ) : 458cdf0e10cSrcweir 459cdf0e10cSrcweir Window ( pParent, rId ) 460cdf0e10cSrcweir { 461cdf0e10cSrcweir pImpl = new FontPrevWin_Impl; 462cdf0e10cSrcweir SfxViewShell* pSh = SfxViewShell::Current(); 463cdf0e10cSrcweir 464cdf0e10cSrcweir if ( pSh ) 465cdf0e10cSrcweir pImpl->pPrinter = pSh->GetPrinter(); 466cdf0e10cSrcweir 467cdf0e10cSrcweir if ( !pImpl->pPrinter ) 468cdf0e10cSrcweir { 469cdf0e10cSrcweir pImpl->pPrinter = new Printer; 470cdf0e10cSrcweir pImpl->bDelPrinter = sal_True; 471cdf0e10cSrcweir } 472cdf0e10cSrcweir SetMapMode( MapMode( MAP_TWIP ) ); 473cdf0e10cSrcweir initFont(pImpl->aFont); 474cdf0e10cSrcweir initFont(pImpl->aCJKFont); 475cdf0e10cSrcweir initFont(pImpl->aCTLFont); 476cdf0e10cSrcweir InitSettings( sal_True, sal_True ); 477cdf0e10cSrcweir SetBorderStyle( WINDOW_BORDER_MONO ); 478cdf0e10cSrcweir 479cdf0e10cSrcweir LanguageType eLanguage = Application::GetSettings().GetUILanguage(); 480cdf0e10cSrcweir switch( eLanguage ) 481cdf0e10cSrcweir { 482cdf0e10cSrcweir case LANGUAGE_CHINESE: 483cdf0e10cSrcweir case LANGUAGE_JAPANESE: 484cdf0e10cSrcweir case LANGUAGE_KOREAN: 485cdf0e10cSrcweir case LANGUAGE_KOREAN_JOHAB: 486cdf0e10cSrcweir case LANGUAGE_CHINESE_SIMPLIFIED: 487cdf0e10cSrcweir case LANGUAGE_CHINESE_HONGKONG: 488cdf0e10cSrcweir case LANGUAGE_CHINESE_SINGAPORE: 489cdf0e10cSrcweir case LANGUAGE_CHINESE_MACAU: 490cdf0e10cSrcweir case LANGUAGE_CHINESE_TRADITIONAL: 491cdf0e10cSrcweir pImpl->bIsCJKUI = sal_True; 492cdf0e10cSrcweir break; 493cdf0e10cSrcweir // TODO: CTL Locale 494cdf0e10cSrcweir // pImpl->bIsCTLUI = sal_True; 495cdf0e10cSrcweir // break; 496cdf0e10cSrcweir default: 497cdf0e10cSrcweir pImpl->bIsCJKUI = pImpl->bIsCTLUI = sal_False; 498cdf0e10cSrcweir break; 499cdf0e10cSrcweir } 500cdf0e10cSrcweir } 501cdf0e10cSrcweir 502cdf0e10cSrcweir // ----------------------------------------------------------------------- 503cdf0e10cSrcweir 504cdf0e10cSrcweir SvxFontPrevWindow::~SvxFontPrevWindow() 505cdf0e10cSrcweir { 506cdf0e10cSrcweir delete pImpl; 507cdf0e10cSrcweir } 508cdf0e10cSrcweir 509cdf0e10cSrcweir // ----------------------------------------------------------------------- 510cdf0e10cSrcweir SvxFont& SvxFontPrevWindow::GetCTLFont() 511cdf0e10cSrcweir { 512cdf0e10cSrcweir return pImpl->aCTLFont; 513cdf0e10cSrcweir } 514cdf0e10cSrcweir 515cdf0e10cSrcweir // ----------------------------------------------------------------------- 516cdf0e10cSrcweir 517cdf0e10cSrcweir SvxFont& SvxFontPrevWindow::GetCJKFont() 518cdf0e10cSrcweir { 519cdf0e10cSrcweir return pImpl->aCJKFont; 520cdf0e10cSrcweir } 521cdf0e10cSrcweir 522cdf0e10cSrcweir // ----------------------------------------------------------------------- 523cdf0e10cSrcweir 524cdf0e10cSrcweir void SvxFontPrevWindow::StateChanged( StateChangedType nType ) 525cdf0e10cSrcweir { 526cdf0e10cSrcweir if ( nType == STATE_CHANGE_CONTROLFOREGROUND ) 527cdf0e10cSrcweir InitSettings( sal_True, sal_False ); 528cdf0e10cSrcweir else if ( nType == STATE_CHANGE_CONTROLBACKGROUND ) 529cdf0e10cSrcweir InitSettings( sal_False, sal_True ); 530cdf0e10cSrcweir 531cdf0e10cSrcweir Window::StateChanged( nType ); 532cdf0e10cSrcweir } 533cdf0e10cSrcweir 534cdf0e10cSrcweir // ----------------------------------------------------------------------- 535cdf0e10cSrcweir 536cdf0e10cSrcweir void SvxFontPrevWindow::DataChanged( const DataChangedEvent& rDCEvt ) 537cdf0e10cSrcweir { 538cdf0e10cSrcweir if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) ) 539cdf0e10cSrcweir InitSettings( sal_True, sal_True ); 540cdf0e10cSrcweir else 541cdf0e10cSrcweir Window::DataChanged( rDCEvt ); 542cdf0e10cSrcweir } 543cdf0e10cSrcweir 544cdf0e10cSrcweir SvxFont& SvxFontPrevWindow::GetFont() 545cdf0e10cSrcweir { 546cdf0e10cSrcweir pImpl->Invalidate100PercentFontWidth(); // because the user might change the size 547cdf0e10cSrcweir return pImpl->aFont; 548cdf0e10cSrcweir } 549cdf0e10cSrcweir 550cdf0e10cSrcweir const SvxFont& SvxFontPrevWindow::GetFont() const 551cdf0e10cSrcweir { 552cdf0e10cSrcweir return pImpl->aFont; 553cdf0e10cSrcweir } 554cdf0e10cSrcweir 555cdf0e10cSrcweir // ----------------------------------------------------------------------- 556cdf0e10cSrcweir 557cdf0e10cSrcweir void SvxFontPrevWindow::SetPreviewText( const ::rtl::OUString& rString ) 558cdf0e10cSrcweir { 559cdf0e10cSrcweir pImpl->aText = rString; 560cdf0e10cSrcweir pImpl->bTextInited = sal_True; 561cdf0e10cSrcweir } 562cdf0e10cSrcweir 563cdf0e10cSrcweir // ----------------------------------------------------------------------- 564cdf0e10cSrcweir 565cdf0e10cSrcweir void SvxFontPrevWindow::SetFontNameAsPreviewText() 566cdf0e10cSrcweir { 567cdf0e10cSrcweir pImpl->bUseFontNameAsText = sal_True; 568cdf0e10cSrcweir } 569cdf0e10cSrcweir 570cdf0e10cSrcweir // ----------------------------------------------------------------------- 571cdf0e10cSrcweir 572cdf0e10cSrcweir void SvxFontPrevWindow::SetFont( const SvxFont& rOutFont ) 573cdf0e10cSrcweir { 574cdf0e10cSrcweir setFont( rOutFont, pImpl->aFont ); 575cdf0e10cSrcweir 576cdf0e10cSrcweir pImpl->Invalidate100PercentFontWidth(); 577cdf0e10cSrcweir Invalidate(); 578cdf0e10cSrcweir } 579cdf0e10cSrcweir 580cdf0e10cSrcweir // ----------------------------------------------------------------------- 581cdf0e10cSrcweir 582cdf0e10cSrcweir void SvxFontPrevWindow::SetFont( const SvxFont& rNormalOutFont, const SvxFont& rCJKOutFont, const SvxFont& rCTLFont ) 583cdf0e10cSrcweir { 584cdf0e10cSrcweir setFont( rNormalOutFont, pImpl->aFont ); 585cdf0e10cSrcweir setFont( rCJKOutFont, pImpl->aCJKFont ); 586cdf0e10cSrcweir setFont( rCTLFont, pImpl->aCTLFont ); 587cdf0e10cSrcweir 588cdf0e10cSrcweir 589cdf0e10cSrcweir pImpl->Invalidate100PercentFontWidth(); 590cdf0e10cSrcweir Invalidate(); 591cdf0e10cSrcweir } 592cdf0e10cSrcweir 593cdf0e10cSrcweir // ----------------------------------------------------------------------- 594cdf0e10cSrcweir 595cdf0e10cSrcweir void SvxFontPrevWindow::SetCJKFont( const SvxFont &rCJKOutFont ) 596cdf0e10cSrcweir { 597cdf0e10cSrcweir setFont( rCJKOutFont, pImpl->aCJKFont ); 598cdf0e10cSrcweir 599cdf0e10cSrcweir pImpl->Invalidate100PercentFontWidth(); 600cdf0e10cSrcweir Invalidate(); 601cdf0e10cSrcweir } 602cdf0e10cSrcweir // ----------------------------------------------------------------------------- 603cdf0e10cSrcweir void SvxFontPrevWindow::SetCTLFont( const SvxFont &rCTLOutFont ) 604cdf0e10cSrcweir { 605cdf0e10cSrcweir setFont( rCTLOutFont, pImpl->aCTLFont ); 606cdf0e10cSrcweir 607cdf0e10cSrcweir pImpl->Invalidate100PercentFontWidth(); 608cdf0e10cSrcweir Invalidate(); 609cdf0e10cSrcweir } 610cdf0e10cSrcweir 611cdf0e10cSrcweir // ----------------------------------------------------------------------- 612cdf0e10cSrcweir 613cdf0e10cSrcweir void SvxFontPrevWindow::SetColor(const Color &rColor) 614cdf0e10cSrcweir { 615cdf0e10cSrcweir delete pImpl->pColor; 616cdf0e10cSrcweir pImpl->pColor = new Color( rColor ); 617cdf0e10cSrcweir Invalidate(); 618cdf0e10cSrcweir } 619cdf0e10cSrcweir // ----------------------------------------------------------------------- 620cdf0e10cSrcweir 621cdf0e10cSrcweir void SvxFontPrevWindow::ResetColor() 622cdf0e10cSrcweir { 623cdf0e10cSrcweir delete pImpl->pColor; 624cdf0e10cSrcweir pImpl->pColor = 0; 625cdf0e10cSrcweir Invalidate(); 626cdf0e10cSrcweir } 627cdf0e10cSrcweir 628cdf0e10cSrcweir // ----------------------------------------------------------------------- 629cdf0e10cSrcweir 630cdf0e10cSrcweir void SvxFontPrevWindow::SetBackColor(const Color &rColor) 631cdf0e10cSrcweir { 632cdf0e10cSrcweir delete pImpl->pBackColor; 633cdf0e10cSrcweir pImpl->pBackColor = new Color( rColor ); 634cdf0e10cSrcweir Invalidate(); 635cdf0e10cSrcweir } 636cdf0e10cSrcweir 637cdf0e10cSrcweir // ----------------------------------------------------------------------- 638cdf0e10cSrcweir 639cdf0e10cSrcweir void SvxFontPrevWindow::UseResourceText( sal_Bool bUse ) 640cdf0e10cSrcweir { 641cdf0e10cSrcweir pImpl->bUseResText = bUse; 642cdf0e10cSrcweir } 643cdf0e10cSrcweir 644cdf0e10cSrcweir // ----------------------------------------------------------------------- 645cdf0e10cSrcweir 646cdf0e10cSrcweir void SvxFontPrevWindow::Paint( const Rectangle& ) 647cdf0e10cSrcweir { 648cdf0e10cSrcweir Printer* pPrinter = pImpl->pPrinter; 649cdf0e10cSrcweir SvxFont& rFont = pImpl->aFont; 650cdf0e10cSrcweir SvxFont& rCJKFont = pImpl->aCJKFont; 651cdf0e10cSrcweir // TODO: SvxFont& rCTLFont = pImpl->aCTLFont; 652cdf0e10cSrcweir 653cdf0e10cSrcweir if ( pImpl->bUseResText ) 654cdf0e10cSrcweir pImpl->aText = GetText(); 655cdf0e10cSrcweir else if ( !pImpl->bSelection && !pImpl->bTextInited ) 656cdf0e10cSrcweir { 657cdf0e10cSrcweir SfxViewShell* pSh = SfxViewShell::Current(); 658cdf0e10cSrcweir 659cdf0e10cSrcweir if ( pSh && !pImpl->bGetSelection && !pImpl->bUseFontNameAsText ) 660cdf0e10cSrcweir { 661cdf0e10cSrcweir pImpl->aText = pSh->GetSelectionText(); 662cdf0e10cSrcweir pImpl->bGetSelection = sal_True; 663cdf0e10cSrcweir pImpl->bSelection = pImpl->aText.Len() != 0; 664cdf0e10cSrcweir 665cdf0e10cSrcweir } 666cdf0e10cSrcweir 667cdf0e10cSrcweir if ( !pImpl->bSelection || pImpl->bUseFontNameAsText ) 668cdf0e10cSrcweir { 669cdf0e10cSrcweir pImpl->aText = rFont.GetName(); 670cdf0e10cSrcweir if( pImpl->bIsCJKUI ) 671cdf0e10cSrcweir pImpl->aText += rCJKFont.GetName(); 672cdf0e10cSrcweir //TODO bIsCTLUI 673cdf0e10cSrcweir } 674cdf0e10cSrcweir 675cdf0e10cSrcweir if ( !pImpl->aText.Len() ) 676cdf0e10cSrcweir pImpl->aText = GetText(); 677cdf0e10cSrcweir 678cdf0e10cSrcweir // remove line feeds and carriage returns from string 679cdf0e10cSrcweir bool bNotEmpty = false; 680cdf0e10cSrcweir for ( xub_StrLen i = 0; i < pImpl->aText.Len(); ++i ) 681cdf0e10cSrcweir { 682cdf0e10cSrcweir if ( 0xa == pImpl->aText.GetChar( i ) || 683cdf0e10cSrcweir 0xd == pImpl->aText.GetChar( i ) ) 684cdf0e10cSrcweir pImpl->aText.SetChar( i, ' ' ); 685cdf0e10cSrcweir else 686cdf0e10cSrcweir bNotEmpty = true; 687cdf0e10cSrcweir } 688cdf0e10cSrcweir if ( !bNotEmpty ) 689cdf0e10cSrcweir pImpl->aText = GetText(); 690cdf0e10cSrcweir 691cdf0e10cSrcweir if ( pImpl->aText.Len() > (TEXT_WIDTH-1) ) 692cdf0e10cSrcweir pImpl->aText.Erase( pImpl->aText.Search( sal_Unicode( ' ' ), TEXT_WIDTH ) ); 693cdf0e10cSrcweir } 694cdf0e10cSrcweir 695cdf0e10cSrcweir // calculate text width scaling 696cdf0e10cSrcweir pImpl->ScaleFontWidth( *this/*, rFont*/ ); 697cdf0e10cSrcweir 698cdf0e10cSrcweir pImpl->CheckScript(); 699cdf0e10cSrcweir Size aTxtSize = pImpl->CalcTextSize( this, pPrinter, rFont ); 700cdf0e10cSrcweir 701cdf0e10cSrcweir const Size aLogSize( GetOutputSize() ); 702cdf0e10cSrcweir 703cdf0e10cSrcweir long nX = aLogSize.Width() / 2 - aTxtSize.Width() / 2; 704cdf0e10cSrcweir long nY = aLogSize.Height() / 2 - aTxtSize.Height() / 2; 705cdf0e10cSrcweir 706cdf0e10cSrcweir if ( nY + pImpl->nAscent > aLogSize.Height() ) 707cdf0e10cSrcweir nY = aLogSize.Height() - pImpl->nAscent; 708cdf0e10cSrcweir 709cdf0e10cSrcweir if ( pImpl->pBackColor ) 710cdf0e10cSrcweir { 711cdf0e10cSrcweir Rectangle aRect( Point( 0, 0 ), aLogSize ); 712cdf0e10cSrcweir Color aLineCol = GetLineColor(); 713cdf0e10cSrcweir Color aFillCol = GetFillColor(); 714cdf0e10cSrcweir SetLineColor(); 715cdf0e10cSrcweir SetFillColor( *pImpl->pBackColor ); 716cdf0e10cSrcweir DrawRect( aRect ); 717cdf0e10cSrcweir SetLineColor( aLineCol ); 718cdf0e10cSrcweir SetFillColor( aFillCol ); 719cdf0e10cSrcweir } 720cdf0e10cSrcweir if ( pImpl->pColor ) 721cdf0e10cSrcweir { 722cdf0e10cSrcweir Rectangle aRect( Point( nX, nY ), aTxtSize ); 723cdf0e10cSrcweir Color aLineCol = GetLineColor(); 724cdf0e10cSrcweir Color aFillCol = GetFillColor(); 725cdf0e10cSrcweir SetLineColor(); 726cdf0e10cSrcweir SetFillColor( *pImpl->pColor ); 727cdf0e10cSrcweir DrawRect( aRect ); 728cdf0e10cSrcweir SetLineColor( aLineCol ); 729cdf0e10cSrcweir SetFillColor( aFillCol ); 730cdf0e10cSrcweir } 731cdf0e10cSrcweir 732cdf0e10cSrcweir long nStdAscent = pImpl->nAscent; 733cdf0e10cSrcweir nY += nStdAscent; 734cdf0e10cSrcweir 735cdf0e10cSrcweir if(pImpl->bTwoLines) 736cdf0e10cSrcweir { 737cdf0e10cSrcweir SvxFont aSmallFont( rFont ); 738cdf0e10cSrcweir Size aOldSize = pImpl->aCJKFont.GetSize(); 739cdf0e10cSrcweir setFontSize(aSmallFont); 740cdf0e10cSrcweir setFontSize(pImpl->aCJKFont); 741cdf0e10cSrcweir 742cdf0e10cSrcweir long nStartBracketWidth = 0; 743cdf0e10cSrcweir long nEndBracketWidth = 0; 744cdf0e10cSrcweir long nTextWidth = 0; 745cdf0e10cSrcweir if(pImpl->cStartBracket) 746cdf0e10cSrcweir { 747cdf0e10cSrcweir String sBracket(pImpl->cStartBracket); 748cdf0e10cSrcweir nStartBracketWidth = rFont.GetTxtSize( pPrinter, sBracket ).Width(); 749cdf0e10cSrcweir } 750cdf0e10cSrcweir if(pImpl->cEndBracket) 751cdf0e10cSrcweir { 752cdf0e10cSrcweir String sBracket(pImpl->cEndBracket); 753cdf0e10cSrcweir nEndBracketWidth = rFont.GetTxtSize( pPrinter, sBracket ).Width(); 754cdf0e10cSrcweir } 755cdf0e10cSrcweir nTextWidth = pImpl->CalcTextSize( this, pPrinter, aSmallFont ).Width(); 756cdf0e10cSrcweir long nResultWidth = nStartBracketWidth; 757cdf0e10cSrcweir nResultWidth += nEndBracketWidth; 758cdf0e10cSrcweir nResultWidth += nTextWidth; 759cdf0e10cSrcweir 760cdf0e10cSrcweir long _nX = (aLogSize.Width() - nResultWidth) / 2; 761cdf0e10cSrcweir DrawLine( Point( 0, nY ), Point( _nX, nY ) ); 762cdf0e10cSrcweir DrawLine( Point( _nX + nResultWidth, nY ), Point( aLogSize.Width(), nY ) ); 763cdf0e10cSrcweir 764cdf0e10cSrcweir long nSmallAscent = pImpl->nAscent; 765cdf0e10cSrcweir long nOffset = (nStdAscent - nSmallAscent ) / 2; 766cdf0e10cSrcweir 767cdf0e10cSrcweir if(pImpl->cStartBracket) 768cdf0e10cSrcweir { 769cdf0e10cSrcweir String sBracket(pImpl->cStartBracket); 770cdf0e10cSrcweir rFont.DrawPrev( this, pPrinter, Point( _nX, nY - nOffset - 4), sBracket ); 771cdf0e10cSrcweir _nX += nStartBracketWidth; 772cdf0e10cSrcweir } 773cdf0e10cSrcweir 774cdf0e10cSrcweir Point aTmpPoint1( _nX, nY - nSmallAscent - 2 ); 775cdf0e10cSrcweir Point aTmpPoint2( _nX, nY ); 776cdf0e10cSrcweir pImpl->DrawPrev( this, pPrinter, aTmpPoint1, aSmallFont ); 777cdf0e10cSrcweir pImpl->DrawPrev( this, pPrinter, aTmpPoint2, aSmallFont ); 778cdf0e10cSrcweir 779cdf0e10cSrcweir _nX += nTextWidth; 780cdf0e10cSrcweir if(pImpl->cEndBracket) 781cdf0e10cSrcweir { 782cdf0e10cSrcweir Point aTmpPoint( _nX + 1, nY - nOffset - 4); 783cdf0e10cSrcweir String sBracket(pImpl->cEndBracket); 784cdf0e10cSrcweir rFont.DrawPrev( this, pPrinter, aTmpPoint, sBracket ); 785cdf0e10cSrcweir } 786cdf0e10cSrcweir pImpl->aCJKFont.SetSize( aOldSize ); 787cdf0e10cSrcweir } 788cdf0e10cSrcweir else 789cdf0e10cSrcweir { 790cdf0e10cSrcweir Color aLineCol = GetLineColor(); 791cdf0e10cSrcweir 792cdf0e10cSrcweir SetLineColor( rFont.GetColor() ); 793cdf0e10cSrcweir DrawLine( Point( 0, nY ), Point( nX, nY ) ); 794cdf0e10cSrcweir DrawLine( Point( nX + aTxtSize.Width(), nY ), Point( aLogSize.Width(), nY ) ); 795cdf0e10cSrcweir 796cdf0e10cSrcweir SetLineColor( aLineCol ); 797cdf0e10cSrcweir 798cdf0e10cSrcweir Point aTmpPoint( nX, nY ); 799cdf0e10cSrcweir pImpl->DrawPrev( this, pPrinter, aTmpPoint, rFont ); 800cdf0e10cSrcweir } 801cdf0e10cSrcweir } 802cdf0e10cSrcweir /* -----------------------------04.12.00 16:26-------------------------------- 803cdf0e10cSrcweir 804cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 805cdf0e10cSrcweir sal_Bool SvxFontPrevWindow::IsTwoLines() const 806cdf0e10cSrcweir { 807cdf0e10cSrcweir return pImpl->bTwoLines; 808cdf0e10cSrcweir } 809cdf0e10cSrcweir /* -----------------------------04.12.00 16:26-------------------------------- 810cdf0e10cSrcweir 811cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 812cdf0e10cSrcweir void SvxFontPrevWindow::SetTwoLines(sal_Bool bSet) 813cdf0e10cSrcweir { 814cdf0e10cSrcweir pImpl->bTwoLines = bSet;} 815cdf0e10cSrcweir 816cdf0e10cSrcweir /* -----------------------------04.12.00 16:26-------------------------------- 817cdf0e10cSrcweir 818cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 819cdf0e10cSrcweir void SvxFontPrevWindow::SetBrackets(sal_Unicode cStart, sal_Unicode cEnd) 820cdf0e10cSrcweir { 821cdf0e10cSrcweir pImpl->cStartBracket = cStart; 822cdf0e10cSrcweir pImpl->cEndBracket = cEnd; 823cdf0e10cSrcweir } 824cdf0e10cSrcweir 825cdf0e10cSrcweir // ----------------------------------------------------------------------- 826cdf0e10cSrcweir 827cdf0e10cSrcweir void SvxFontPrevWindow::SetFontWidthScale( sal_uInt16 n ) 828cdf0e10cSrcweir { 829cdf0e10cSrcweir if( pImpl->SetFontWidthScale( n ) ) 830cdf0e10cSrcweir Invalidate(); 831cdf0e10cSrcweir } 832cdf0e10cSrcweir 833cdf0e10cSrcweir // ----------------------------------------------------------------------- 834cdf0e10cSrcweir 835cdf0e10cSrcweir void SvxFontPrevWindow::AutoCorrectFontColor( void ) 836cdf0e10cSrcweir { 837cdf0e10cSrcweir Color aFontColor( GetTextColor() ); 838cdf0e10cSrcweir 839cdf0e10cSrcweir if( COL_AUTO == pImpl->aFont.GetColor().GetColor() ) 840cdf0e10cSrcweir pImpl->aFont.SetColor( aFontColor ); 841cdf0e10cSrcweir 842cdf0e10cSrcweir if( COL_AUTO == pImpl->aCJKFont.GetColor().GetColor() ) 843cdf0e10cSrcweir pImpl->aCJKFont.SetColor( aFontColor ); 844cdf0e10cSrcweir 845cdf0e10cSrcweir if( COL_AUTO == pImpl->aCTLFont.GetColor().GetColor() ) 846cdf0e10cSrcweir pImpl->aCTLFont.SetColor( aFontColor ); 847cdf0e10cSrcweir } 848