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