Bump version to 4.3-4
[LibreOffice.git] / cui / source / tabpages / chardlg.cxx
blob85e6d765ed7358ef01db6526ea475d00a4f26999
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <editeng/unolingu.hxx>
21 #include <vcl/svapp.hxx>
22 #include <unotools/pathoptions.hxx>
23 #include <svtools/ctrltool.hxx>
24 #include <sfx2/printer.hxx>
25 #include <sfx2/objsh.hxx>
26 #include <sfx2/viewsh.hxx>
27 #include <sfx2/bindings.hxx>
28 #include <sfx2/viewfrm.hxx>
29 #include <vcl/msgbox.hxx>
30 #include <svx/dialmgr.hxx>
31 #include <svx/dialogs.hrc>
32 #include <svtools/unitconv.hxx>
33 #include <svl/languageoptions.hxx>
34 #include <svx/xtable.hxx>
35 #include "chardlg.hxx"
36 #include "editeng/fontitem.hxx"
37 #include <editeng/postitem.hxx>
38 #include <editeng/udlnitem.hxx>
39 #include <editeng/crossedoutitem.hxx>
40 #include <editeng/contouritem.hxx>
41 #include <editeng/langitem.hxx>
42 #include <editeng/wghtitem.hxx>
43 #include <editeng/fhgtitem.hxx>
44 #include <editeng/shdditem.hxx>
45 #include <editeng/escapementitem.hxx>
46 #include <editeng/prszitem.hxx>
47 #include <editeng/wrlmitem.hxx>
48 #include <editeng/cmapitem.hxx>
49 #include <editeng/kernitem.hxx>
50 #include <editeng/blinkitem.hxx>
51 #include "editeng/flstitem.hxx"
52 #include <editeng/autokernitem.hxx>
53 #include <editeng/brushitem.hxx>
54 #include <editeng/colritem.hxx>
55 #include "svx/drawitem.hxx"
56 #include "svx/dlgutil.hxx"
57 #include <dialmgr.hxx>
58 #include <sfx2/htmlmode.hxx>
59 #include "cuicharmap.hxx"
60 #include "chardlg.h"
61 #include <editeng/emphasismarkitem.hxx>
62 #include <editeng/charreliefitem.hxx>
63 #include <editeng/twolinesitem.hxx>
64 #include <editeng/charhiddenitem.hxx>
65 #include <svl/stritem.hxx>
66 #include <editeng/charscaleitem.hxx>
67 #include <editeng/charrotateitem.hxx>
68 #include <svx/svxdlg.hxx>
69 #include <cuires.hrc>
70 #include <svl/intitem.hxx>
71 #include <sfx2/request.hxx>
72 #include "svx/flagsdef.hxx"
74 using namespace ::com::sun::star;
76 // define ----------------------------------------------------------------
78 #define ISITEMSET rSet.GetItemState(nWhich)>=SFX_ITEM_DEFAULT
80 #define CLEARTITEM rSet.InvalidateItem(nWhich)
82 #define LW_NORMAL 0
83 #define LW_EXPANDED 1
84 #define LW_CONDENSED 2
86 // static ----------------------------------------------------------------
88 static const sal_uInt16 pNameRanges[] =
90 SID_ATTR_CHAR_FONT,
91 SID_ATTR_CHAR_WEIGHT,
92 SID_ATTR_CHAR_FONTHEIGHT,
93 SID_ATTR_CHAR_FONTHEIGHT,
94 SID_ATTR_CHAR_COLOR,
95 SID_ATTR_CHAR_COLOR,
96 SID_ATTR_CHAR_LANGUAGE,
97 SID_ATTR_CHAR_LANGUAGE,
98 SID_ATTR_CHAR_CJK_FONT,
99 SID_ATTR_CHAR_CJK_WEIGHT,
100 SID_ATTR_CHAR_CTL_FONT,
101 SID_ATTR_CHAR_CTL_WEIGHT,
105 static const sal_uInt16 pEffectsRanges[] =
107 SID_ATTR_CHAR_SHADOWED,
108 SID_ATTR_CHAR_UNDERLINE,
109 SID_ATTR_CHAR_COLOR,
110 SID_ATTR_CHAR_COLOR,
111 SID_ATTR_CHAR_CASEMAP,
112 SID_ATTR_CHAR_CASEMAP,
113 SID_ATTR_FLASH,
114 SID_ATTR_FLASH,
115 SID_ATTR_CHAR_EMPHASISMARK,
116 SID_ATTR_CHAR_EMPHASISMARK,
117 SID_ATTR_CHAR_RELIEF,
118 SID_ATTR_CHAR_RELIEF,
119 SID_ATTR_CHAR_HIDDEN,
120 SID_ATTR_CHAR_HIDDEN,
121 SID_ATTR_CHAR_OVERLINE,
122 SID_ATTR_CHAR_OVERLINE,
126 static const sal_uInt16 pPositionRanges[] =
128 SID_ATTR_CHAR_KERNING,
129 SID_ATTR_CHAR_KERNING,
130 SID_ATTR_CHAR_ESCAPEMENT,
131 SID_ATTR_CHAR_ESCAPEMENT,
132 SID_ATTR_CHAR_AUTOKERN,
133 SID_ATTR_CHAR_AUTOKERN,
134 SID_ATTR_CHAR_ROTATED,
135 SID_ATTR_CHAR_SCALEWIDTH,
136 SID_ATTR_CHAR_WIDTH_FIT_TO_LINE,
137 SID_ATTR_CHAR_WIDTH_FIT_TO_LINE,
141 static const sal_uInt16 pTwoLinesRanges[] =
143 SID_ATTR_CHAR_TWO_LINES,
144 SID_ATTR_CHAR_TWO_LINES,
148 // C-Funktion ------------------------------------------------------------
150 inline bool StateToAttr( TriState aState )
152 return ( TRISTATE_TRUE == aState );
155 // class SvxCharBasePage -------------------------------------------------
157 inline SvxFont& SvxCharBasePage::GetPreviewFont()
159 return m_pPreviewWin->GetFont();
164 inline SvxFont& SvxCharBasePage::GetPreviewCJKFont()
166 return m_pPreviewWin->GetCJKFont();
170 inline SvxFont& SvxCharBasePage::GetPreviewCTLFont()
172 return m_pPreviewWin->GetCTLFont();
177 SvxCharBasePage::SvxCharBasePage(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, const SfxItemSet& rItemset)
178 : SfxTabPage( pParent, rID, rUIXMLDescription, rItemset )
179 , m_pPreviewWin(NULL)
180 , m_bPreviewBackgroundToCharacter( false )
186 SvxCharBasePage::~SvxCharBasePage()
192 void SvxCharBasePage::ActivatePage( const SfxItemSet& rSet )
194 m_pPreviewWin->SetFromItemSet( rSet, m_bPreviewBackgroundToCharacter );
200 void SvxCharBasePage::SetPrevFontWidthScale( const SfxItemSet& rSet )
202 sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
203 if( ISITEMSET )
205 const SvxCharScaleWidthItem &rItem = ( SvxCharScaleWidthItem& ) rSet.Get( nWhich );
206 m_pPreviewWin->SetFontWidthScale( rItem.GetValue() );
211 namespace
214 void setPrevFontEscapement(SvxFont& _rFont,sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
216 _rFont.SetPropr( nProp );
217 _rFont.SetProprRel( nEscProp );
218 _rFont.SetEscapement( nEsc );
225 void SvxCharBasePage::SetPrevFontEscapement( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
227 setPrevFontEscapement(GetPreviewFont(),nProp,nEscProp,nEsc);
228 setPrevFontEscapement(GetPreviewCJKFont(),nProp,nEscProp,nEsc);
229 setPrevFontEscapement(GetPreviewCTLFont(),nProp,nEscProp,nEsc);
230 m_pPreviewWin->Invalidate();
233 // SvxCharNamePage_Impl --------------------------------------------------
235 struct SvxCharNamePage_Impl
237 Timer m_aUpdateTimer;
238 OUString m_aNoStyleText;
239 const FontList* m_pFontList;
240 sal_Int32 m_nExtraEntryPos;
241 bool m_bMustDelete;
242 bool m_bInSearchMode;
244 SvxCharNamePage_Impl() :
246 m_pFontList ( NULL ),
247 m_nExtraEntryPos( COMBOBOX_ENTRY_NOTFOUND ),
248 m_bMustDelete ( false ),
249 m_bInSearchMode ( false )
252 m_aUpdateTimer.SetTimeout( 350 );
255 ~SvxCharNamePage_Impl()
257 if ( m_bMustDelete )
258 delete m_pFontList;
262 // class SvxCharNamePage -------------------------------------------------
264 SvxCharNamePage::SvxCharNamePage( Window* pParent, const SfxItemSet& rInSet )
265 : SvxCharBasePage(pParent, "CharNamePage", "cui/ui/charnamepage.ui", rInSet)
266 , m_pImpl(new SvxCharNamePage_Impl)
268 m_pImpl->m_aNoStyleText = CUI_RES( RID_SVXSTR_CHARNAME_NOSTYLE );
270 SvtLanguageOptions aLanguageOptions;
271 bool bShowCJK = aLanguageOptions.IsCJKFontEnabled();
272 bool bShowCTL = aLanguageOptions.IsCTLFontEnabled();
273 bool bShowNonWestern = bShowCJK || bShowCTL;
275 if (bShowNonWestern)
277 get(m_pWestFrame, "western");
278 get(m_pWestFontNameFT, "westfontnameft-cjk");
279 get(m_pWestFontNameLB, "westfontnamelb-cjk");
280 get(m_pWestFontStyleFT, "weststyleft-cjk");
281 get(m_pWestFontStyleLB, "weststylelb-cjk");
282 get(m_pWestFontSizeFT, "westsizeft-cjk");
283 get(m_pWestFontSizeLB, "westsizelb-cjk");
285 get(m_pWestFontLanguageFT, "westlangft-cjk");
286 get(m_pWestFontLanguageLB, "westlanglb-cjk");
287 get(m_pWestFontTypeFT, "westfontinfo-cjk");
289 else
291 get(m_pWestFrame, "simple");
292 get(m_pWestFontNameFT, "westfontnameft-nocjk");
293 get(m_pWestFontNameLB, "westfontnamelb-nocjk");
294 get(m_pWestFontStyleFT, "weststyleft-nocjk");
295 get(m_pWestFontStyleLB, "weststylelb-nocjk");
296 get(m_pWestFontSizeFT, "westsizeft-nocjk");
297 get(m_pWestFontSizeLB, "westsizelb-nocjk");
299 get(m_pWestFontLanguageFT, "westlangft-nocjk");
300 get(m_pWestFontLanguageLB, "westlanglb-nocjk");
301 get(m_pWestFontTypeFT, "westfontinfo-nocjk");
304 get(m_pEastFrame, "asian");
305 get(m_pEastFontNameFT, "eastfontnameft");
306 get(m_pEastFontNameLB, "eastfontnamelb");
307 get(m_pEastFontStyleFT, "eaststyleft");
308 get(m_pEastFontStyleLB, "eaststylelb");
309 get(m_pEastFontSizeFT, "eastsizeft");
310 get(m_pEastFontSizeLB, "eastsizelb");
311 get(m_pEastFontLanguageFT, "eastlangft");
312 get(m_pEastFontLanguageLB, "eastlanglb");
313 get(m_pEastFontTypeFT, "eastfontinfo");
315 get(m_pCTLFrame, "ctl");
316 get(m_pCTLFontNameFT, "ctlfontnameft");
317 get(m_pCTLFontNameLB, "ctlfontnamelb");
318 get(m_pCTLFontStyleFT, "ctlstyleft");
319 get(m_pCTLFontStyleLB, "ctlstylelb");
320 get(m_pCTLFontSizeFT, "ctlsizeft");
321 get(m_pCTLFontSizeLB, "ctlsizelb");
322 get(m_pCTLFontLanguageFT, "ctllangft");
323 get(m_pCTLFontLanguageLB, "ctllanglb");
324 get(m_pCTLFontTypeFT, "ctlfontinfo");
326 //In MacOSX the standard dialogs name font-name, font-style as
327 //Family, Typeface
328 //In GNOME the standard dialogs name font-name, font-style as
329 //Family, Style
330 //In Windows the standard dialogs name font-name, font-style as
331 //Font, Style
332 #ifdef WNT
333 OUString sFontFamilyString(CUI_RES(RID_SVXSTR_CHARNAME_FONT));
334 #else
335 OUString sFontFamilyString(CUI_RES(RID_SVXSTR_CHARNAME_FAMILY));
336 #endif
337 m_pWestFontNameFT->SetText(sFontFamilyString);
338 m_pEastFontNameFT->SetText(sFontFamilyString);
339 m_pCTLFontNameFT->SetText(sFontFamilyString);
341 #ifdef MACOSX
342 OUString sFontStyleString(CUI_RES(RID_SVXSTR_CHARNAME_TYPEFACE));
343 #else
344 OUString sFontStyleString(CUI_RES(RID_SVXSTR_CHARNAME_STYLE));
345 #endif
346 m_pWestFontStyleFT->SetText(sFontStyleString);
347 m_pEastFontStyleFT->SetText(sFontStyleString);
348 m_pCTLFontStyleFT->SetText(sFontStyleString);
350 m_pWestFrame->Show(true);
351 m_pEastFrame->Show(bShowCJK);
352 m_pCTLFrame->Show(bShowCTL);
354 get(m_pPreviewWin, "preview");
356 m_pWestFontLanguageLB->SetLanguageList(LANG_LIST_WESTERN, true, false, true);
357 m_pEastFontLanguageLB->SetLanguageList(LANG_LIST_CJK, true, false, true);
358 m_pCTLFontLanguageLB->SetLanguageList(LANG_LIST_CTL, true, false, true);
360 if (!bShowNonWestern)
362 //10 lines
363 sal_Int32 nHeight = m_pWestFontSizeLB->CalcWindowSizePixel(10);
364 m_pWestFontNameLB->set_height_request(nHeight);
365 m_pWestFontStyleLB->set_height_request(nHeight);
366 m_pWestFontSizeLB->set_height_request(nHeight);
369 Initialize();
374 SvxCharNamePage::~SvxCharNamePage()
376 delete m_pImpl;
381 void SvxCharNamePage::Initialize()
383 // to handle the changes of the other pages
384 SetExchangeSupport();
386 Link aLink = LINK( this, SvxCharNamePage, FontModifyHdl_Impl );
387 m_pWestFontNameLB->SetModifyHdl( aLink );
388 m_pWestFontStyleLB->SetModifyHdl( aLink );
389 m_pWestFontSizeLB->SetModifyHdl( aLink );
390 m_pWestFontLanguageLB->SetSelectHdl( aLink );
391 m_pEastFontNameLB->SetModifyHdl( aLink );
392 m_pEastFontStyleLB->SetModifyHdl( aLink );
393 m_pEastFontSizeLB->SetModifyHdl( aLink );
394 m_pEastFontLanguageLB->SetSelectHdl( aLink );
395 m_pCTLFontNameLB->SetModifyHdl( aLink );
396 m_pCTLFontStyleLB->SetModifyHdl( aLink );
397 m_pCTLFontSizeLB->SetModifyHdl( aLink );
398 m_pCTLFontLanguageLB->SetSelectHdl( aLink );
400 m_pImpl->m_aUpdateTimer.SetTimeoutHdl( LINK( this, SvxCharNamePage, UpdateHdl_Impl ) );
405 const FontList* SvxCharNamePage::GetFontList() const
407 if ( !m_pImpl->m_pFontList )
409 SfxObjectShell* pDocSh = SfxObjectShell::Current();
410 const SfxPoolItem* pItem;
412 /* #110771# SvxFontListItem::GetFontList can return NULL */
413 if ( pDocSh )
415 pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
416 if ( pItem != NULL )
418 DBG_ASSERT(NULL != ( (SvxFontListItem*)pItem )->GetFontList(),
419 "Where is the font list?");
420 m_pImpl->m_pFontList = static_cast<const SvxFontListItem*>(pItem )->GetFontList()->Clone();
421 m_pImpl->m_bMustDelete = true;
424 if(!m_pImpl->m_pFontList)
426 m_pImpl->m_pFontList =
427 new FontList( Application::GetDefaultDevice() );
428 m_pImpl->m_bMustDelete = true;
432 return m_pImpl->m_pFontList;
436 namespace
438 vcl::FontInfo calcFontInfo( SvxFont& _rFont,
439 SvxCharNamePage* _pPage,
440 const FontNameBox* _pFontNameLB,
441 const FontStyleBox* _pFontStyleLB,
442 const FontSizeBox* _pFontSizeLB,
443 const SvxLanguageBoxBase* _pLanguageLB,
444 const FontList* _pFontList,
445 sal_uInt16 _nFontWhich,
446 sal_uInt16 _nFontHeightWhich)
448 Size aSize = _rFont.GetSize();
449 aSize.Width() = 0;
450 vcl::FontInfo aFontInfo;
451 OUString sFontName(_pFontNameLB->GetText());
452 bool bFontAvailable = _pFontList->IsAvailable( sFontName );
453 if (bFontAvailable || _pFontNameLB->IsValueChangedFromSaved())
454 aFontInfo = _pFontList->Get( sFontName, _pFontStyleLB->GetText() );
455 else
457 //get the font from itemset
458 SfxItemState eState = _pPage->GetItemSet().GetItemState( _nFontWhich );
459 if ( eState >= SFX_ITEM_DEFAULT )
461 const SvxFontItem* pFontItem = (const SvxFontItem*)&( _pPage->GetItemSet().Get( _nFontWhich ) );
462 aFontInfo.SetName(pFontItem->GetFamilyName());
463 aFontInfo.SetStyleName(pFontItem->GetStyleName());
464 aFontInfo.SetFamily(pFontItem->GetFamily());
465 aFontInfo.SetPitch(pFontItem->GetPitch());
466 aFontInfo.SetCharSet(pFontItem->GetCharSet());
469 if ( _pFontSizeLB->IsRelative() )
471 DBG_ASSERT( _pPage->GetItemSet().GetParent(), "No parent set" );
472 const SvxFontHeightItem& rOldItem = (SvxFontHeightItem&)_pPage->GetItemSet().GetParent()->Get( _nFontHeightWhich );
474 // old value, scaled
475 long nHeight;
476 if ( _pFontSizeLB->IsPtRelative() )
477 nHeight = rOldItem.GetHeight() + PointToTwips( static_cast<long>(_pFontSizeLB->GetValue() / 10) );
478 else
479 nHeight = static_cast<long>(rOldItem.GetHeight() * _pFontSizeLB->GetValue() / 100);
481 // conversion twips for the example-window
482 aSize.Height() =
483 ItemToControl( nHeight, _pPage->GetItemSet().GetPool()->GetMetric( _nFontHeightWhich ), SFX_FUNIT_TWIP );
485 else if ( !_pFontSizeLB->GetText().isEmpty() )
486 aSize.Height() = PointToTwips( static_cast<long>(_pFontSizeLB->GetValue() / 10) );
487 else
488 aSize.Height() = 200; // default 10pt
489 aFontInfo.SetSize( aSize );
491 _rFont.SetLanguage(_pLanguageLB->GetSelectLanguage());
493 _rFont.SetFamily( aFontInfo.GetFamily() );
494 _rFont.SetName( aFontInfo.GetName() );
495 _rFont.SetStyleName( aFontInfo.GetStyleName() );
496 _rFont.SetPitch( aFontInfo.GetPitch() );
497 _rFont.SetCharSet( aFontInfo.GetCharSet() );
498 _rFont.SetWeight( aFontInfo.GetWeight() );
499 _rFont.SetItalic( aFontInfo.GetItalic() );
500 _rFont.SetSize( aFontInfo.GetSize() );
502 return aFontInfo;
508 void SvxCharNamePage::UpdatePreview_Impl()
510 SvxFont& rFont = GetPreviewFont();
511 SvxFont& rCJKFont = GetPreviewCJKFont();
512 SvxFont& rCTLFont = GetPreviewCTLFont();
513 // Size
514 Size aSize = rFont.GetSize();
515 aSize.Width() = 0;
516 Size aCJKSize = rCJKFont.GetSize();
517 aCJKSize.Width() = 0;
518 Size aCTLSize = rCTLFont.GetSize();
519 aCTLSize.Width() = 0;
520 // Font
521 const FontList* pFontList = GetFontList();
523 vcl::FontInfo aWestFontInfo = calcFontInfo(rFont, this, m_pWestFontNameLB,
524 m_pWestFontStyleLB, m_pWestFontSizeLB, m_pWestFontLanguageLB,
525 pFontList, GetWhich(SID_ATTR_CHAR_FONT),
526 GetWhich(SID_ATTR_CHAR_FONTHEIGHT));
527 m_pWestFontTypeFT->SetText(pFontList->GetFontMapText(aWestFontInfo));
529 vcl::FontInfo aEastFontInfo = calcFontInfo(rCJKFont, this, m_pEastFontNameLB,
530 m_pEastFontStyleLB, m_pEastFontSizeLB, m_pEastFontLanguageLB,
531 pFontList, GetWhich(SID_ATTR_CHAR_CJK_FONT),
532 GetWhich(SID_ATTR_CHAR_CJK_FONTHEIGHT));
533 m_pEastFontTypeFT->SetText(pFontList->GetFontMapText(aEastFontInfo));
535 vcl::FontInfo aCTLFontInfo = calcFontInfo(rCTLFont,
536 this, m_pCTLFontNameLB, m_pCTLFontStyleLB, m_pCTLFontSizeLB,
537 m_pCTLFontLanguageLB, pFontList, GetWhich(SID_ATTR_CHAR_CTL_FONT),
538 GetWhich(SID_ATTR_CHAR_CTL_FONTHEIGHT));
539 m_pCTLFontTypeFT->SetText(pFontList->GetFontMapText(aCTLFontInfo));
541 m_pPreviewWin->Invalidate();
546 void SvxCharNamePage::FillStyleBox_Impl( const FontNameBox* pNameBox )
548 const FontList* pFontList = GetFontList();
549 DBG_ASSERT( pFontList, "no fontlist" );
551 FontStyleBox* pStyleBox = NULL;
553 if ( m_pWestFontNameLB == pNameBox )
554 pStyleBox = m_pWestFontStyleLB;
555 else if ( m_pEastFontNameLB == pNameBox )
556 pStyleBox = m_pEastFontStyleLB;
557 else if ( m_pCTLFontNameLB == pNameBox )
558 pStyleBox = m_pCTLFontStyleLB;
559 else
561 SAL_WARN( "cui.tabpages", "invalid font name box" );
562 return;
565 pStyleBox->Fill( pNameBox->GetText(), pFontList );
567 if ( m_pImpl->m_bInSearchMode )
569 // additional entries for the search:
570 // "not bold" and "not italic"
571 OUString aEntry = m_pImpl->m_aNoStyleText;
572 const sal_Char sS[] = "%1";
573 aEntry = aEntry.replaceFirst( sS, pFontList->GetBoldStr() );
574 m_pImpl->m_nExtraEntryPos = pStyleBox->InsertEntry( aEntry );
575 aEntry = m_pImpl->m_aNoStyleText;
576 aEntry = aEntry.replaceFirst( sS, pFontList->GetItalicStr() );
577 pStyleBox->InsertEntry( aEntry );
583 void SvxCharNamePage::FillSizeBox_Impl( const FontNameBox* pNameBox )
585 const FontList* pFontList = GetFontList();
586 DBG_ASSERT( pFontList, "no fontlist" );
588 FontStyleBox* pStyleBox = NULL;
589 FontSizeBox* pSizeBox = NULL;
591 if ( m_pWestFontNameLB == pNameBox )
593 pStyleBox = m_pWestFontStyleLB;
594 pSizeBox = m_pWestFontSizeLB;
596 else if ( m_pEastFontNameLB == pNameBox )
598 pStyleBox = m_pEastFontStyleLB;
599 pSizeBox = m_pEastFontSizeLB;
601 else if ( m_pCTLFontNameLB == pNameBox )
603 pStyleBox = m_pCTLFontStyleLB;
604 pSizeBox = m_pCTLFontSizeLB;
606 else
608 SAL_WARN( "cui.tabpages", "invalid font name box" );
609 return;
612 vcl::FontInfo _aFontInfo( pFontList->Get( pNameBox->GetText(), pStyleBox->GetText() ) );
613 pSizeBox->Fill( &_aFontInfo, pFontList );
618 void SvxCharNamePage::Reset_Impl( const SfxItemSet& rSet, LanguageGroup eLangGrp )
620 FontNameBox* pNameBox = NULL;
621 FixedText* pStyleLabel = NULL;
622 FontStyleBox* pStyleBox = NULL;
623 FixedText* pSizeLabel = NULL;
624 FontSizeBox* pSizeBox = NULL;
625 FixedText* pLangFT = NULL;
626 SvxLanguageBoxBase* pLangBox = NULL;
627 sal_uInt16 nWhich = 0;
629 switch ( eLangGrp )
631 case Western :
632 pNameBox = m_pWestFontNameLB;
633 pStyleLabel = m_pWestFontStyleFT;
634 pStyleBox = m_pWestFontStyleLB;
635 pSizeLabel = m_pWestFontSizeFT;
636 pSizeBox = m_pWestFontSizeLB;
637 pLangFT = m_pWestFontLanguageFT;
638 pLangBox = m_pWestFontLanguageLB;
639 nWhich = GetWhich( SID_ATTR_CHAR_FONT );
640 break;
642 case Asian :
643 pNameBox = m_pEastFontNameLB;
644 pStyleLabel = m_pEastFontStyleFT;
645 pStyleBox = m_pEastFontStyleLB;
646 pSizeLabel = m_pEastFontSizeFT;
647 pSizeBox = m_pEastFontSizeLB;
648 pLangFT = m_pEastFontLanguageFT;
649 pLangBox = m_pEastFontLanguageLB;
650 nWhich = GetWhich( SID_ATTR_CHAR_CJK_FONT );
651 break;
653 case Ctl :
654 pNameBox = m_pCTLFontNameLB;
655 pStyleLabel = m_pCTLFontStyleFT;
656 pStyleBox = m_pCTLFontStyleLB;
657 pSizeLabel = m_pCTLFontSizeFT;
658 pSizeBox = m_pCTLFontSizeLB;
659 pLangFT = m_pCTLFontLanguageFT;
660 pLangBox = m_pCTLFontLanguageLB;
661 nWhich = GetWhich( SID_ATTR_CHAR_CTL_FONT );
662 break;
665 const FontList* pFontList = GetFontList();
666 pNameBox->Fill( pFontList );
668 const SvxFontItem* pFontItem = NULL;
669 SfxItemState eState = rSet.GetItemState( nWhich );
671 if ( eState >= SFX_ITEM_DEFAULT )
673 pFontItem = (const SvxFontItem*)&( rSet.Get( nWhich ) );
674 pNameBox->SetText( pFontItem->GetFamilyName() );
676 else
678 pNameBox->SetText( OUString() );
681 FillStyleBox_Impl( pNameBox );
683 bool bStyle = false;
684 bool bStyleAvailable = true;
685 FontItalic eItalic = ITALIC_NONE;
686 FontWeight eWeight = WEIGHT_NORMAL;
687 switch ( eLangGrp )
689 case Western : nWhich = GetWhich( SID_ATTR_CHAR_POSTURE ); break;
690 case Asian : nWhich = GetWhich( SID_ATTR_CHAR_CJK_POSTURE ); break;
691 case Ctl : nWhich = GetWhich( SID_ATTR_CHAR_CTL_POSTURE ); break;
693 eState = rSet.GetItemState( nWhich );
695 if ( eState >= SFX_ITEM_DEFAULT )
697 const SvxPostureItem& rItem = (SvxPostureItem&)rSet.Get( nWhich );
698 eItalic = (FontItalic)rItem.GetValue();
699 bStyle = true;
701 bStyleAvailable = bStyleAvailable && (eState >= SFX_ITEM_DONTCARE);
703 switch ( eLangGrp )
705 case Western : nWhich = GetWhich( SID_ATTR_CHAR_WEIGHT ); break;
706 case Asian : nWhich = GetWhich( SID_ATTR_CHAR_CJK_WEIGHT ); break;
707 case Ctl : nWhich = GetWhich( SID_ATTR_CHAR_CTL_WEIGHT ); break;
709 eState = rSet.GetItemState( nWhich );
711 if ( eState >= SFX_ITEM_DEFAULT )
713 SvxWeightItem& rItem = (SvxWeightItem&)rSet.Get( nWhich );
714 eWeight = (FontWeight)rItem.GetValue();
716 else
717 bStyle = false;
718 bStyleAvailable = bStyleAvailable && (eState >= SFX_ITEM_DONTCARE);
720 // currently chosen font
721 if ( bStyle && pFontItem )
723 vcl::FontInfo aInfo = pFontList->Get( pFontItem->GetFamilyName(), eWeight, eItalic );
724 pStyleBox->SetText( pFontList->GetStyleName( aInfo ) );
726 else if ( !m_pImpl->m_bInSearchMode || !bStyle )
728 pStyleBox->SetText( OUString() );
730 else if ( bStyle )
732 vcl::FontInfo aInfo = pFontList->Get( OUString(), eWeight, eItalic );
733 pStyleBox->SetText( pFontList->GetStyleName( aInfo ) );
735 if (!bStyleAvailable)
737 pStyleBox->Disable( );
738 pStyleLabel->Disable( );
741 FillSizeBox_Impl( pNameBox );
742 switch ( eLangGrp )
744 case Western : nWhich = GetWhich( SID_ATTR_CHAR_FONTHEIGHT ); break;
745 case Asian : nWhich = GetWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT ); break;
746 case Ctl : nWhich = GetWhich( SID_ATTR_CHAR_CTL_FONTHEIGHT ); break;
748 eState = rSet.GetItemState( nWhich );
750 if ( pSizeBox->IsRelativeMode() )
752 SfxMapUnit eUnit = rSet.GetPool()->GetMetric( nWhich );
753 const SvxFontHeightItem& rItem = (SvxFontHeightItem&)rSet.Get( nWhich );
755 if( rItem.GetProp() != 100 || SFX_MAPUNIT_RELATIVE != rItem.GetPropUnit() )
757 bool bPtRel = SFX_MAPUNIT_POINT == rItem.GetPropUnit();
758 pSizeBox->SetPtRelative( bPtRel );
759 pSizeBox->SetValue( bPtRel ? ((short)rItem.GetProp()) * 10 : rItem.GetProp() );
761 else
763 pSizeBox->SetRelative();
764 pSizeBox->SetValue( (long)CalcToPoint( rItem.GetHeight(), eUnit, 10 ) );
767 else if ( eState >= SFX_ITEM_DEFAULT )
769 SfxMapUnit eUnit = rSet.GetPool()->GetMetric( nWhich );
770 const SvxFontHeightItem& rItem = (SvxFontHeightItem&)rSet.Get( nWhich );
771 pSizeBox->SetValue( (long)CalcToPoint( rItem.GetHeight(), eUnit, 10 ) );
773 else
775 pSizeBox->SetText( OUString() );
776 if ( eState <= SFX_ITEM_READONLY )
778 pSizeBox->Disable( );
779 pSizeLabel->Disable( );
783 switch ( eLangGrp )
785 case Western : nWhich = GetWhich( SID_ATTR_CHAR_LANGUAGE ); break;
786 case Asian : nWhich = GetWhich( SID_ATTR_CHAR_CJK_LANGUAGE ); break;
787 case Ctl : nWhich = GetWhich( SID_ATTR_CHAR_CTL_LANGUAGE ); break;
789 pLangBox->SetNoSelectionLBB();
790 eState = rSet.GetItemState( nWhich );
792 switch ( eState )
794 case SFX_ITEM_UNKNOWN:
795 pLangFT->Hide();
796 pLangBox->HideLBB();
797 break;
799 case SFX_ITEM_DISABLED:
800 case SFX_ITEM_READONLY:
801 pLangFT->Disable();
802 pLangBox->DisableLBB();
803 break;
805 case SFX_ITEM_DEFAULT:
806 case SFX_ITEM_SET:
808 const SvxLanguageItem& rItem = (SvxLanguageItem&)rSet.Get( nWhich );
809 LanguageType eLangType = (LanguageType)rItem.GetValue();
810 DBG_ASSERT( eLangType != LANGUAGE_SYSTEM, "LANGUAGE_SYSTEM not allowed" );
811 if ( eLangType != LANGUAGE_DONTKNOW )
812 pLangBox->SelectLanguage( eLangType );
813 break;
817 OUString sMapText(pFontList->GetFontMapText(
818 pFontList->Get(pNameBox->GetText(), pStyleBox->GetText())));
820 switch (eLangGrp)
822 case Western:
823 m_pWestFontTypeFT->SetText(sMapText);
824 break;
825 case Asian:
826 m_pEastFontTypeFT->SetText(sMapText);
827 break;
828 case Ctl:
829 m_pCTLFontTypeFT->SetText(sMapText);
830 break;
833 // save these settings
834 pNameBox->SaveValue();
835 pStyleBox->SaveValue();
836 pSizeBox->SaveValue();
837 pLangBox->SaveValueLBB();
842 bool SvxCharNamePage::FillItemSet_Impl( SfxItemSet& rSet, LanguageGroup eLangGrp )
844 bool bModified = false;
846 FontNameBox* pNameBox = NULL;
847 FontStyleBox* pStyleBox = NULL;
848 FontSizeBox* pSizeBox = NULL;
849 SvxLanguageBoxBase* pLangBox = NULL;
850 sal_uInt16 nWhich = 0;
851 sal_uInt16 nSlot = 0;
853 switch ( eLangGrp )
855 case Western :
856 pNameBox = m_pWestFontNameLB;
857 pStyleBox = m_pWestFontStyleLB;
858 pSizeBox = m_pWestFontSizeLB;
859 pLangBox = m_pWestFontLanguageLB;
860 nSlot = SID_ATTR_CHAR_FONT;
861 break;
863 case Asian :
864 pNameBox = m_pEastFontNameLB;
865 pStyleBox = m_pEastFontStyleLB;
866 pSizeBox = m_pEastFontSizeLB;
867 pLangBox = m_pEastFontLanguageLB;
868 nSlot = SID_ATTR_CHAR_CJK_FONT;
869 break;
871 case Ctl :
872 pNameBox = m_pCTLFontNameLB;
873 pStyleBox = m_pCTLFontStyleLB;
874 pSizeBox = m_pCTLFontSizeLB;
875 pLangBox = m_pCTLFontLanguageLB;
876 nSlot = SID_ATTR_CHAR_CTL_FONT;
877 break;
880 nWhich = GetWhich( nSlot );
881 const SfxPoolItem* pItem = NULL;
882 const SfxItemSet& rOldSet = GetItemSet();
883 const SfxPoolItem* pOld = NULL;
885 const SfxItemSet* pExampleSet = GetTabDialog() ? GetTabDialog()->GetExampleSet() : NULL;
887 bool bChanged = true;
888 const OUString& rFontName = pNameBox->GetText();
889 const FontList* pFontList = GetFontList();
890 OUString aStyleBoxText =pStyleBox->GetText();
891 sal_Int32 nEntryPos = pStyleBox->GetEntryPos( aStyleBoxText );
892 if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
893 aStyleBoxText = "";
894 vcl::FontInfo aInfo( pFontList->Get( rFontName, aStyleBoxText ) );
895 SvxFontItem aFontItem( aInfo.GetFamily(), aInfo.GetName(), aInfo.GetStyleName(),
896 aInfo.GetPitch(), aInfo.GetCharSet(), nWhich );
897 pOld = GetOldItem( rSet, nSlot );
899 if ( pOld )
901 const SvxFontItem& rItem = *( (const SvxFontItem*)pOld );
903 if ( rItem.GetFamilyName() == aFontItem.GetFamilyName() )
904 bChanged = false;
907 if ( !bChanged )
908 bChanged = pNameBox->GetSavedValue().isEmpty();
910 if ( !bChanged && pExampleSet &&
911 pExampleSet->GetItemState( nWhich, false, &pItem ) == SFX_ITEM_SET &&
912 ( (SvxFontItem*)pItem )->GetFamilyName() != aFontItem.GetFamilyName() )
913 bChanged = true;
915 if ( bChanged && !rFontName.isEmpty() )
917 rSet.Put( aFontItem );
918 bModified = true;
920 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
921 rSet.ClearItem( nWhich );
924 bChanged = true;
925 switch ( eLangGrp )
927 case Western : nSlot = SID_ATTR_CHAR_WEIGHT; break;
928 case Asian : nSlot = SID_ATTR_CHAR_CJK_WEIGHT; break;
929 case Ctl : nSlot = SID_ATTR_CHAR_CTL_WEIGHT; break;
931 nWhich = GetWhich( nSlot );
932 FontWeight eWeight = aInfo.GetWeight();
933 if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
934 eWeight = WEIGHT_NORMAL;
935 SvxWeightItem aWeightItem( eWeight, nWhich );
936 pOld = GetOldItem( rSet, nSlot );
938 if ( pOld )
940 const SvxWeightItem& rItem = *( (const SvxWeightItem*)pOld );
942 if ( rItem.GetValue() == aWeightItem.GetValue() )
943 bChanged = false;
946 if ( !bChanged )
948 bChanged = pStyleBox->GetSavedValue().isEmpty();
950 if ( m_pImpl->m_bInSearchMode && bChanged &&
951 aInfo.GetWeight() == WEIGHT_NORMAL && aInfo.GetItalic() != ITALIC_NONE )
952 bChanged = true;
955 if ( !bChanged && pExampleSet &&
956 pExampleSet->GetItemState( nWhich, false, &pItem ) == SFX_ITEM_SET &&
957 ( (SvxWeightItem*)pItem )->GetValue() != aWeightItem.GetValue() )
958 bChanged = true;
960 if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
961 bChanged = ( nEntryPos == m_pImpl->m_nExtraEntryPos );
963 OUString aText( pStyleBox->GetText() ); // Tristate, then text empty
965 if ( bChanged && !aText.isEmpty() )
967 rSet.Put( aWeightItem );
968 bModified = true;
970 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
971 CLEARTITEM;
973 bChanged = true;
974 switch ( eLangGrp )
976 case Western : nSlot = SID_ATTR_CHAR_POSTURE; break;
977 case Asian : nSlot = SID_ATTR_CHAR_CJK_POSTURE; break;
978 case Ctl : nSlot = SID_ATTR_CHAR_CTL_POSTURE; break;
980 nWhich = GetWhich( nSlot );
981 FontItalic eItalic = aInfo.GetItalic();
982 if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
983 eItalic = ITALIC_NONE;
984 SvxPostureItem aPostureItem( eItalic, nWhich );
985 pOld = GetOldItem( rSet, nSlot );
987 if ( pOld )
989 const SvxPostureItem& rItem = *( (const SvxPostureItem*)pOld );
991 if ( rItem.GetValue() == aPostureItem.GetValue() )
992 bChanged = false;
995 if ( !bChanged )
997 bChanged = pStyleBox->GetSavedValue().isEmpty();
999 if ( m_pImpl->m_bInSearchMode && bChanged &&
1000 aInfo.GetItalic() == ITALIC_NONE && aInfo.GetWeight() != WEIGHT_NORMAL )
1001 bChanged = false;
1004 if ( !bChanged && pExampleSet &&
1005 pExampleSet->GetItemState( nWhich, false, &pItem ) == SFX_ITEM_SET &&
1006 ( (SvxPostureItem*)pItem )->GetValue() != aPostureItem.GetValue() )
1007 bChanged = true;
1009 if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
1010 bChanged = ( nEntryPos == ( m_pImpl->m_nExtraEntryPos + 1 ) );
1012 if ( bChanged && !aText.isEmpty() )
1014 rSet.Put( aPostureItem );
1015 bModified = true;
1017 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
1018 CLEARTITEM;
1020 // FontSize
1021 long nSize = static_cast<long>(pSizeBox->GetValue());
1023 if ( pSizeBox->GetText().isEmpty() ) // GetValue() returns the min-value
1024 nSize = 0;
1025 long nSavedSize = pSizeBox->GetSavedValue().toInt32();
1026 bool bRel = true;
1028 if ( !pSizeBox->IsRelative() )
1030 nSavedSize *= 10;
1031 bRel = false;
1034 switch ( eLangGrp )
1036 case Western : nSlot = SID_ATTR_CHAR_FONTHEIGHT; break;
1037 case Asian : nSlot = SID_ATTR_CHAR_CJK_FONTHEIGHT; break;
1038 case Ctl : nSlot = SID_ATTR_CHAR_CTL_FONTHEIGHT; break;
1040 nWhich = GetWhich( nSlot );
1041 const SvxFontHeightItem* pOldHeight = (const SvxFontHeightItem*)GetOldItem( rSet, nSlot );
1042 bChanged = ( nSize != nSavedSize );
1044 if ( !bChanged && pExampleSet &&
1045 pExampleSet->GetItemState( nWhich, false, &pItem ) == SFX_ITEM_SET )
1047 float fSize = (float)nSize / 10;
1048 long nVal = CalcToUnit( fSize, rSet.GetPool()->GetMetric( nWhich ) );
1049 if ( ( (SvxFontHeightItem*)pItem )->GetHeight() != (sal_uInt32)nVal )
1050 bChanged = true;
1053 if ( bChanged || !pOldHeight ||
1054 bRel != ( SFX_MAPUNIT_RELATIVE != pOldHeight->GetPropUnit() || 100 != pOldHeight->GetProp() ) )
1056 SfxMapUnit eUnit = rSet.GetPool()->GetMetric( nWhich );
1057 if ( pSizeBox->IsRelative() )
1059 DBG_ASSERT( GetItemSet().GetParent(), "No parent set" );
1060 const SvxFontHeightItem& rOldItem =
1061 (const SvxFontHeightItem&)GetItemSet().GetParent()->Get( nWhich );
1063 SvxFontHeightItem aHeight( 240, 100, nWhich );
1064 if ( pSizeBox->IsPtRelative() )
1065 aHeight.SetHeight( rOldItem.GetHeight(), (sal_uInt16)( nSize / 10 ), SFX_MAPUNIT_POINT, eUnit );
1066 else
1067 aHeight.SetHeight( rOldItem.GetHeight(), (sal_uInt16)nSize, SFX_MAPUNIT_RELATIVE );
1068 rSet.Put( aHeight );
1070 else
1072 float fSize = (float)nSize / 10;
1073 rSet.Put( SvxFontHeightItem( CalcToUnit( fSize, eUnit ), 100, nWhich ) );
1075 bModified = true;
1077 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
1078 CLEARTITEM;
1080 bChanged = true;
1081 switch ( eLangGrp )
1083 case Western : nSlot = SID_ATTR_CHAR_LANGUAGE; break;
1084 case Asian : nSlot = SID_ATTR_CHAR_CJK_LANGUAGE; break;
1085 case Ctl : nSlot = SID_ATTR_CHAR_CTL_LANGUAGE; break;
1087 nWhich = GetWhich( nSlot );
1088 pOld = GetOldItem( rSet, nSlot );
1090 // For language list boxes acting as ComboBox, check for, add and select an
1091 // edited entry.
1092 SvxLanguageComboBox* pLangComboBox = dynamic_cast<SvxLanguageComboBox*>(pLangBox);
1093 if (pLangComboBox)
1095 switch (pLangComboBox->GetEditedAndValid())
1097 case SvxLanguageComboBox::EDITED_NO:
1098 ; // nothing to do
1099 break;
1100 case SvxLanguageComboBox::EDITED_VALID:
1102 const sal_Int32 nPos = pLangComboBox->SaveEditedAsEntry();
1103 if (nPos != COMBOBOX_ENTRY_NOTFOUND)
1104 pLangComboBox->SelectEntryPos( nPos);
1106 break;
1107 case SvxLanguageComboBox::EDITED_INVALID:
1108 pLangComboBox->SelectEntryPos( pLangComboBox->GetSavedValueLBB());
1109 break;
1113 sal_Int32 nLangPos = pLangBox->GetSelectEntryPosLBB();
1114 LanguageType eLangType = (LanguageType)(sal_uLong)pLangBox->GetEntryDataLBB( nLangPos );
1116 if ( pOld )
1118 const SvxLanguageItem& rItem = *( (const SvxLanguageItem*)pOld );
1120 if ( nLangPos == LISTBOX_ENTRY_NOTFOUND || eLangType == (LanguageType)rItem.GetValue() )
1121 bChanged = false;
1124 if ( !bChanged )
1125 bChanged = ( pLangBox->GetSavedValueLBB() == LISTBOX_ENTRY_NOTFOUND );
1127 if ( bChanged && nLangPos != LISTBOX_ENTRY_NOTFOUND )
1129 rSet.Put( SvxLanguageItem( eLangType, nWhich ) );
1130 bModified = true;
1132 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
1133 CLEARTITEM;
1135 return bModified;
1140 IMPL_LINK_NOARG(SvxCharNamePage, UpdateHdl_Impl)
1142 UpdatePreview_Impl();
1143 return 0;
1148 IMPL_LINK( SvxCharNamePage, FontModifyHdl_Impl, void*, pNameBox )
1150 m_pImpl->m_aUpdateTimer.Start();
1152 if ( m_pWestFontNameLB == pNameBox || m_pEastFontNameLB == pNameBox || m_pCTLFontNameLB == pNameBox )
1154 FillStyleBox_Impl( (FontNameBox*)pNameBox );
1155 FillSizeBox_Impl( (FontNameBox*)pNameBox );
1157 return 0;
1162 void SvxCharNamePage::ActivatePage( const SfxItemSet& rSet )
1164 SvxCharBasePage::ActivatePage( rSet );
1166 UpdatePreview_Impl(); // instead of asynchronous calling in ctor
1171 int SvxCharNamePage::DeactivatePage( SfxItemSet* _pSet )
1173 if ( _pSet )
1174 FillItemSet( *_pSet );
1175 return LEAVE_PAGE;
1180 SfxTabPage* SvxCharNamePage::Create( Window* pParent, const SfxItemSet& rSet )
1182 return new SvxCharNamePage( pParent, rSet );
1187 const sal_uInt16* SvxCharNamePage::GetRanges()
1189 return pNameRanges;
1194 void SvxCharNamePage::Reset( const SfxItemSet& rSet )
1196 Reset_Impl( rSet, Western );
1197 Reset_Impl( rSet, Asian );
1198 Reset_Impl( rSet, Ctl );
1200 SetPrevFontWidthScale( rSet );
1201 UpdatePreview_Impl();
1206 bool SvxCharNamePage::FillItemSet( SfxItemSet& rSet )
1208 bool bModified = FillItemSet_Impl( rSet, Western );
1209 bModified |= FillItemSet_Impl( rSet, Asian );
1210 bModified |= FillItemSet_Impl( rSet, Ctl );
1211 return bModified;
1216 void SvxCharNamePage::SetFontList( const SvxFontListItem& rItem )
1218 if ( m_pImpl->m_bMustDelete )
1220 delete m_pImpl->m_pFontList;
1222 m_pImpl->m_pFontList = rItem.GetFontList()->Clone();
1223 m_pImpl->m_bMustDelete = true;
1227 namespace
1229 void enableRelativeMode( SvxCharNamePage* _pPage, FontSizeBox* _pFontSizeLB, sal_uInt16 _nHeightWhich )
1231 _pFontSizeLB->EnableRelativeMode( 5, 995, 5 ); // min 5%, max 995%, step 5
1233 const SvxFontHeightItem& rHeightItem =
1234 (SvxFontHeightItem&)_pPage->GetItemSet().GetParent()->Get( _nHeightWhich );
1235 SfxMapUnit eUnit = _pPage->GetItemSet().GetPool()->GetMetric( _nHeightWhich );
1236 short nCurHeight =
1237 static_cast< short >( CalcToPoint( rHeightItem.GetHeight(), eUnit, 1 ) * 10 );
1239 // based on the current height:
1240 // - negative until minimum of 2 pt
1241 // - positive until maximum of 999 pt
1242 _pFontSizeLB->EnablePtRelativeMode( sal::static_int_cast< short >(-(nCurHeight - 20)), (9999 - nCurHeight), 10 );
1247 void SvxCharNamePage::EnableRelativeMode()
1249 DBG_ASSERT( GetItemSet().GetParent(), "RelativeMode, but no ParentSet!" );
1250 enableRelativeMode(this,m_pWestFontSizeLB,GetWhich( SID_ATTR_CHAR_FONTHEIGHT ));
1251 enableRelativeMode(this,m_pEastFontSizeLB,GetWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT ));
1252 enableRelativeMode(this,m_pCTLFontSizeLB,GetWhich( SID_ATTR_CHAR_CTL_FONTHEIGHT ));
1257 void SvxCharNamePage::EnableSearchMode()
1259 m_pImpl->m_bInSearchMode = true;
1262 void SvxCharNamePage::DisableControls( sal_uInt16 nDisable )
1264 if ( DISABLE_LANGUAGE & nDisable )
1266 if ( m_pWestFontLanguageFT ) m_pWestFontLanguageFT->Disable();
1267 if ( m_pWestFontLanguageLB ) m_pWestFontLanguageLB->Disable();
1268 if ( m_pEastFontLanguageFT ) m_pEastFontLanguageFT->Disable();
1269 if ( m_pEastFontLanguageLB ) m_pEastFontLanguageLB->Disable();
1270 if ( m_pCTLFontLanguageFT ) m_pCTLFontLanguageFT->Disable();
1271 if ( m_pCTLFontLanguageLB ) m_pCTLFontLanguageLB->Disable();
1274 if ( DISABLE_HIDE_LANGUAGE & nDisable )
1276 if ( m_pWestFontLanguageFT ) m_pWestFontLanguageFT->Hide();
1277 if ( m_pWestFontLanguageLB ) m_pWestFontLanguageLB->Hide();
1278 if ( m_pEastFontLanguageFT ) m_pEastFontLanguageFT->Hide();
1279 if ( m_pEastFontLanguageLB ) m_pEastFontLanguageLB->Hide();
1280 if ( m_pCTLFontLanguageFT ) m_pCTLFontLanguageFT->Hide();
1281 if ( m_pCTLFontLanguageLB ) m_pCTLFontLanguageLB->Hide();
1286 void SvxCharNamePage::SetPreviewBackgroundToCharacter()
1288 m_bPreviewBackgroundToCharacter = true;
1292 void SvxCharNamePage::PageCreated(const SfxAllItemSet& aSet)
1294 SFX_ITEMSET_ARG (&aSet,pFontListItem,SvxFontListItem,SID_ATTR_CHAR_FONTLIST,false);
1295 SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,false);
1296 SFX_ITEMSET_ARG (&aSet,pDisalbeItem,SfxUInt16Item,SID_DISABLE_CTL,false);
1297 if (pFontListItem)
1298 SetFontList(*pFontListItem);
1300 if (pFlagItem)
1302 sal_uInt32 nFlags=pFlagItem->GetValue();
1303 if ( ( nFlags & SVX_RELATIVE_MODE ) == SVX_RELATIVE_MODE )
1304 EnableRelativeMode();
1305 if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
1306 SetPreviewBackgroundToCharacter();
1308 if (pDisalbeItem)
1309 DisableControls(pDisalbeItem->GetValue());
1311 // class SvxCharEffectsPage ----------------------------------------------
1313 SvxCharEffectsPage::SvxCharEffectsPage( Window* pParent, const SfxItemSet& rInSet )
1314 : SvxCharBasePage(pParent, "EffectsPage", "cui/ui/effectspage.ui", rInSet)
1315 , m_aTransparentColorName(CUI_RES(RID_SVXSTR_CHARNAME_TRANSPARENT))
1317 get(m_pFontColorFT, "fontcolorft");
1318 get(m_pFontColorLB, "fontcolorlb");
1319 get(m_pEffectsFT, "effectsft");
1320 get(m_pEffectsLB, "effectslb");
1321 get(m_pReliefFT, "reliefft");
1322 get(m_pReliefLB, "relieflb");
1323 get(m_pOutlineBtn, "outlinecb");
1324 get(m_pShadowBtn, "shadowcb");
1325 get(m_pBlinkingBtn, "blinkingcb");
1326 get(m_pHiddenBtn, "hiddencb");
1327 get(m_pOverlineLB, "overlinelb");
1328 get(m_pOverlineColorFT, "overlinecolorft");
1329 get(m_pOverlineColorLB, "overlinecolorlb");
1330 get(m_pStrikeoutLB, "strikeoutlb");
1331 get(m_pUnderlineLB, "underlinelb");
1332 get(m_pUnderlineColorFT, "underlinecolorft");
1333 get(m_pUnderlineColorLB, "underlinecolorlb");
1334 get(m_pIndividualWordsBtn, "individualwordscb");
1335 get(m_pEmphasisFT, "emphasisft");
1336 get(m_pEmphasisLB, "emphasislb");
1337 get(m_pPositionFT, "positionft");
1338 get(m_pPositionLB, "positionlb");
1340 get(m_pPreviewWin, "preview");
1341 Initialize();
1346 void SvxCharEffectsPage::Initialize()
1348 // to handle the changes of the other pages
1349 SetExchangeSupport();
1351 // HTML-Mode
1352 const SfxPoolItem* pItem;
1353 SfxObjectShell* pShell;
1354 if ( SFX_ITEM_SET == GetItemSet().GetItemState( SID_HTML_MODE, false, &pItem ) ||
1355 ( NULL != ( pShell = SfxObjectShell::Current() ) &&
1356 NULL != ( pItem = pShell->GetItem( SID_HTML_MODE ) ) ) )
1358 m_nHtmlMode = ( (const SfxUInt16Item*)pItem )->GetValue();
1359 if ( ( m_nHtmlMode & HTMLMODE_ON ) == HTMLMODE_ON )
1361 //!!! hide some controls please
1365 // fill the color box
1366 SfxObjectShell* pDocSh = SfxObjectShell::Current();
1367 DBG_ASSERT( pDocSh, "DocShell not found!" );
1368 XColorListRef pColorTable;
1370 if ( pDocSh )
1372 pItem = pDocSh->GetItem( SID_COLOR_TABLE );
1373 if ( pItem != NULL )
1374 pColorTable = ( (SvxColorListItem*)pItem )->GetColorList();
1377 if ( !pColorTable.is() )
1378 pColorTable = XColorList::CreateStdColorList();
1380 m_pUnderlineColorLB->SetUpdateMode( false );
1381 m_pOverlineColorLB->SetUpdateMode( false );
1382 m_pFontColorLB->SetUpdateMode( false );
1385 SfxPoolItem* pDummy = NULL;
1386 SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocSh );
1387 if ( !pFrame ||
1388 SFX_ITEM_DEFAULT > pFrame->GetBindings().QueryState( SID_ATTR_AUTO_COLOR_INVALID, pDummy ) )
1390 m_pUnderlineColorLB->InsertAutomaticEntryColor( Color( COL_AUTO ) );
1391 m_pOverlineColorLB->InsertAutomaticEntryColor( Color( COL_AUTO ) );
1392 m_pFontColorLB->InsertAutomaticEntryColor( Color( COL_AUTO ) );
1394 delete pDummy;
1396 for ( long i = 0; i < pColorTable->Count(); i++ )
1398 XColorEntry* pEntry = pColorTable->GetColor(i);
1399 m_pUnderlineColorLB->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
1400 m_pOverlineColorLB->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
1401 m_pFontColorLB->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
1404 m_pUnderlineColorLB->SetUpdateMode( true );
1405 m_pOverlineColorLB->SetUpdateMode( true );
1406 m_pFontColorLB->SetUpdateMode( true );
1407 m_pFontColorLB->SetSelectHdl( LINK( this, SvxCharEffectsPage, ColorBoxSelectHdl_Impl ) );
1409 // handler
1410 Link aLink = LINK( this, SvxCharEffectsPage, SelectHdl_Impl );
1411 m_pUnderlineLB->SetSelectHdl( aLink );
1412 m_pUnderlineColorLB->SetSelectHdl( aLink );
1413 m_pOverlineLB->SetSelectHdl( aLink );
1414 m_pOverlineColorLB->SetSelectHdl( aLink );
1415 m_pStrikeoutLB->SetSelectHdl( aLink );
1416 m_pEmphasisLB->SetSelectHdl( aLink );
1417 m_pPositionLB->SetSelectHdl( aLink );
1418 m_pEffectsLB->SetSelectHdl( aLink );
1419 m_pReliefLB->SetSelectHdl( aLink );
1421 m_pUnderlineLB->SelectEntryPos( 0 );
1422 m_pUnderlineColorLB->SelectEntryPos( 0 );
1423 m_pOverlineLB->SelectEntryPos( 0 );
1424 m_pOverlineColorLB->SelectEntryPos( 0 );
1425 m_pStrikeoutLB->SelectEntryPos( 0 );
1426 m_pEmphasisLB->SelectEntryPos( 0 );
1427 m_pPositionLB->SelectEntryPos( 0 );
1428 SelectHdl_Impl( NULL );
1429 SelectHdl_Impl( m_pEmphasisLB );
1431 m_pEffectsLB->SelectEntryPos( 0 );
1433 m_pIndividualWordsBtn->SetClickHdl( LINK( this, SvxCharEffectsPage, CbClickHdl_Impl ) );
1434 aLink = LINK( this, SvxCharEffectsPage, TristClickHdl_Impl );
1435 m_pOutlineBtn->SetClickHdl( aLink );
1436 m_pShadowBtn->SetClickHdl( aLink );
1438 if ( !SvtLanguageOptions().IsAsianTypographyEnabled() )
1440 m_pEmphasisFT->Hide();
1441 m_pEmphasisLB->Hide();
1442 m_pPositionFT->Hide();
1443 m_pPositionLB->Hide();
1447 SvxCharEffectsPage::~SvxCharEffectsPage()
1453 void SvxCharEffectsPage::UpdatePreview_Impl()
1455 SvxFont& rFont = GetPreviewFont();
1456 SvxFont& rCJKFont = GetPreviewCJKFont();
1457 SvxFont& rCTLFont = GetPreviewCTLFont();
1459 sal_Int32 nPos = m_pUnderlineLB->GetSelectEntryPos();
1460 FontUnderline eUnderline = (FontUnderline)(sal_uLong)m_pUnderlineLB->GetEntryData( nPos );
1461 nPos = m_pOverlineLB->GetSelectEntryPos();
1462 FontUnderline eOverline = (FontUnderline)(sal_uLong)m_pOverlineLB->GetEntryData( nPos );
1463 nPos = m_pStrikeoutLB->GetSelectEntryPos();
1464 FontStrikeout eStrikeout = (FontStrikeout)(sal_uLong)m_pStrikeoutLB->GetEntryData( nPos );
1465 rFont.SetUnderline( eUnderline );
1466 rCJKFont.SetUnderline( eUnderline );
1467 rCTLFont.SetUnderline( eUnderline );
1468 m_pPreviewWin->SetTextLineColor( m_pUnderlineColorLB->GetSelectEntryColor() );
1469 rFont.SetOverline( eOverline );
1470 rCJKFont.SetOverline( eOverline );
1471 rCTLFont.SetOverline( eOverline );
1472 m_pPreviewWin->SetOverlineColor( m_pOverlineColorLB->GetSelectEntryColor() );
1473 rFont.SetStrikeout( eStrikeout );
1474 rCJKFont.SetStrikeout( eStrikeout );
1475 rCTLFont.SetStrikeout( eStrikeout );
1477 nPos = m_pPositionLB->GetSelectEntryPos();
1478 bool bUnder = ( CHRDLG_POSITION_UNDER == (sal_uLong)m_pPositionLB->GetEntryData( nPos ) );
1479 FontEmphasisMark eMark = (FontEmphasisMark)m_pEmphasisLB->GetSelectEntryPos();
1480 eMark |= bUnder ? EMPHASISMARK_POS_BELOW : EMPHASISMARK_POS_ABOVE;
1481 rFont.SetEmphasisMark( eMark );
1482 rCJKFont.SetEmphasisMark( eMark );
1483 rCTLFont.SetEmphasisMark( eMark );
1485 sal_Int32 nRelief = m_pReliefLB->GetSelectEntryPos();
1486 if(LISTBOX_ENTRY_NOTFOUND != nRelief)
1488 rFont.SetRelief( (FontRelief)nRelief );
1489 rCJKFont.SetRelief( (FontRelief)nRelief );
1490 rCTLFont.SetRelief( (FontRelief)nRelief );
1493 rFont.SetOutline( StateToAttr( m_pOutlineBtn->GetState() ) );
1494 rCJKFont.SetOutline( rFont.IsOutline() );
1495 rCTLFont.SetOutline( rFont.IsOutline() );
1497 rFont.SetShadow( StateToAttr( m_pShadowBtn->GetState() ) );
1498 rCJKFont.SetShadow( rFont.IsShadow() );
1499 rCTLFont.SetShadow( rFont.IsShadow() );
1501 sal_Int32 nCapsPos = m_pEffectsLB->GetSelectEntryPos();
1502 if ( nCapsPos != LISTBOX_ENTRY_NOTFOUND )
1504 rFont.SetCaseMap( (SvxCaseMap)nCapsPos );
1505 rCJKFont.SetCaseMap( (SvxCaseMap)nCapsPos );
1506 // #i78474# small caps do not exist in CTL fonts
1507 rCTLFont.SetCaseMap( static_cast<SvxCaseMap>( nCapsPos == SVX_CASEMAP_KAPITAELCHEN ? SVX_CASEMAP_NOT_MAPPED : (SvxCaseMap)nCapsPos) );
1510 bool bWordLine = m_pIndividualWordsBtn->IsChecked();
1511 rFont.SetWordLineMode( bWordLine );
1512 rCJKFont.SetWordLineMode( bWordLine );
1513 rCTLFont.SetWordLineMode( bWordLine );
1515 m_pPreviewWin->Invalidate();
1520 void SvxCharEffectsPage::SetCaseMap_Impl( SvxCaseMap eCaseMap )
1522 if ( SVX_CASEMAP_END > eCaseMap )
1523 m_pEffectsLB->SelectEntryPos(
1524 sal::static_int_cast< sal_Int32 >( eCaseMap ) );
1525 else
1527 m_pEffectsLB->SetNoSelection();
1528 eCaseMap = SVX_CASEMAP_NOT_MAPPED;
1531 UpdatePreview_Impl();
1536 void SvxCharEffectsPage::ResetColor_Impl( const SfxItemSet& rSet )
1538 sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_COLOR );
1539 SfxItemState eState = rSet.GetItemState( nWhich );
1541 switch ( eState )
1543 case SFX_ITEM_UNKNOWN:
1544 m_pFontColorFT->Hide();
1545 m_pFontColorLB->Hide();
1546 break;
1548 case SFX_ITEM_DISABLED:
1549 case SFX_ITEM_READONLY:
1550 m_pFontColorFT->Disable();
1551 m_pFontColorLB->Disable();
1552 break;
1554 case SFX_ITEM_DONTCARE:
1555 m_pFontColorLB->SetNoSelection();
1556 break;
1558 case SFX_ITEM_DEFAULT:
1559 case SFX_ITEM_SET:
1561 SvxFont& rFont = GetPreviewFont();
1562 SvxFont& rCJKFont = GetPreviewCJKFont();
1563 SvxFont& rCTLFont = GetPreviewCTLFont();
1565 const SvxColorItem& rItem = (SvxColorItem&)rSet.Get( nWhich );
1566 Color aColor = rItem.GetValue();
1567 rFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor );
1568 rCJKFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor );
1569 rCTLFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor );
1571 m_pPreviewWin->Invalidate();
1572 sal_Int32 nSelPos = m_pFontColorLB->GetEntryPos( aColor );
1573 if ( nSelPos == LISTBOX_ENTRY_NOTFOUND && aColor == Color( COL_TRANSPARENT ) )
1574 nSelPos = m_pFontColorLB->GetEntryPos( m_aTransparentColorName );
1576 if ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
1577 m_pFontColorLB->SelectEntryPos( nSelPos );
1578 else
1580 nSelPos = m_pFontColorLB->GetEntryPos( aColor );
1581 if ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
1582 m_pFontColorLB->SelectEntryPos( nSelPos );
1583 else
1584 m_pFontColorLB->SelectEntryPos(
1585 m_pFontColorLB->InsertEntry( aColor, OUString( SVX_RES( RID_SVXSTR_COLOR_USER ) ) ) );
1587 break;
1594 bool SvxCharEffectsPage::FillItemSetColor_Impl( SfxItemSet& rSet )
1596 sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_COLOR );
1597 const SvxColorItem* pOld = (const SvxColorItem*)GetOldItem( rSet, SID_ATTR_CHAR_COLOR );
1598 const SvxColorItem* pItem = NULL;
1599 bool bChanged = true;
1600 const SfxItemSet* pExampleSet = GetTabDialog() ? GetTabDialog()->GetExampleSet() : NULL;
1601 const SfxItemSet& rOldSet = GetItemSet();
1603 Color aSelectedColor;
1604 if ( m_pFontColorLB->GetSelectEntry() == m_aTransparentColorName )
1605 aSelectedColor = Color( COL_TRANSPARENT );
1606 else
1607 aSelectedColor = m_pFontColorLB->GetSelectEntryColor();
1609 if ( pOld && pOld->GetValue() == aSelectedColor )
1610 bChanged = false;
1612 if ( !bChanged )
1613 bChanged = ( m_pFontColorLB->GetSavedValue() == LISTBOX_ENTRY_NOTFOUND );
1615 if ( !bChanged && pExampleSet &&
1616 pExampleSet->GetItemState( nWhich, false, (const SfxPoolItem**)&pItem ) == SFX_ITEM_SET &&
1617 ( (SvxColorItem*)pItem )->GetValue() != aSelectedColor )
1618 bChanged = true;
1620 bool bModified = false;
1622 if ( bChanged && m_pFontColorLB->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
1624 rSet.Put( SvxColorItem( aSelectedColor, nWhich ) );
1625 bModified = true;
1627 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
1628 CLEARTITEM;
1630 return bModified;
1635 IMPL_LINK( SvxCharEffectsPage, SelectHdl_Impl, ListBox*, pBox )
1637 if ( m_pEmphasisLB == pBox )
1639 sal_Int32 nEPos = m_pEmphasisLB->GetSelectEntryPos();
1640 bool bEnable = ( nEPos > 0 && nEPos != LISTBOX_ENTRY_NOTFOUND );
1641 m_pPositionFT->Enable( bEnable );
1642 m_pPositionLB->Enable( bEnable );
1644 else if( m_pReliefLB == pBox)
1646 bool bEnable = ( pBox->GetSelectEntryPos() == 0 );
1647 m_pOutlineBtn->Enable( bEnable );
1648 m_pShadowBtn->Enable( bEnable );
1650 else if ( m_pPositionLB != pBox )
1652 sal_Int32 nUPos = m_pUnderlineLB->GetSelectEntryPos(),
1653 nOPos = m_pOverlineLB->GetSelectEntryPos(),
1654 nSPos = m_pStrikeoutLB->GetSelectEntryPos();
1655 bool bUEnable = ( nUPos > 0 && nUPos != LISTBOX_ENTRY_NOTFOUND );
1656 bool bOEnable = ( nOPos > 0 && nOPos != LISTBOX_ENTRY_NOTFOUND );
1657 m_pUnderlineColorFT->Enable( bUEnable );
1658 m_pUnderlineColorLB->Enable( bUEnable );
1659 m_pOverlineColorFT->Enable( bOEnable );
1660 m_pOverlineColorLB->Enable( bOEnable );
1661 m_pIndividualWordsBtn->Enable( bUEnable || bOEnable || ( nSPos > 0 && nSPos != LISTBOX_ENTRY_NOTFOUND ) );
1663 UpdatePreview_Impl();
1664 return 0;
1669 IMPL_LINK_NOARG(SvxCharEffectsPage, UpdatePreview_Impl)
1671 bool bEnable = ( ( m_pUnderlineLB->GetSelectEntryPos() > 0 ) ||
1672 ( m_pOverlineLB->GetSelectEntryPos() > 0 ) ||
1673 ( m_pStrikeoutLB->GetSelectEntryPos() > 0 ) );
1674 m_pIndividualWordsBtn->Enable( bEnable );
1676 UpdatePreview_Impl();
1677 return 0;
1682 IMPL_LINK_NOARG(SvxCharEffectsPage, CbClickHdl_Impl)
1684 UpdatePreview_Impl();
1685 return 0;
1690 IMPL_LINK_NOARG(SvxCharEffectsPage, TristClickHdl_Impl)
1692 UpdatePreview_Impl();
1693 return 0;
1698 IMPL_LINK( SvxCharEffectsPage, ColorBoxSelectHdl_Impl, ColorListBox*, pBox )
1700 SvxFont& rFont = GetPreviewFont();
1701 SvxFont& rCJKFont = GetPreviewCJKFont();
1702 SvxFont& rCTLFont = GetPreviewCTLFont();
1704 Color aSelectedColor;
1705 if ( pBox->GetSelectEntry() == m_aTransparentColorName )
1706 aSelectedColor = Color( COL_TRANSPARENT );
1707 else
1708 aSelectedColor = pBox->GetSelectEntryColor();
1709 rFont.SetColor( aSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aSelectedColor );
1710 rCJKFont.SetColor( aSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aSelectedColor );
1711 rCTLFont.SetColor( aSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aSelectedColor );
1713 m_pPreviewWin->Invalidate();
1714 return 0;
1718 int SvxCharEffectsPage::DeactivatePage( SfxItemSet* _pSet )
1720 if ( _pSet )
1721 FillItemSet( *_pSet );
1722 return LEAVE_PAGE;
1727 SfxTabPage* SvxCharEffectsPage::Create( Window* pParent, const SfxItemSet& rSet )
1729 return new SvxCharEffectsPage( pParent, rSet );
1734 const sal_uInt16* SvxCharEffectsPage::GetRanges()
1736 return pEffectsRanges;
1741 void SvxCharEffectsPage::Reset( const SfxItemSet& rSet )
1743 SvxFont& rFont = GetPreviewFont();
1744 SvxFont& rCJKFont = GetPreviewCJKFont();
1745 SvxFont& rCTLFont = GetPreviewCTLFont();
1747 bool bEnable = false;
1749 // Underline
1750 sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_UNDERLINE );
1751 rFont.SetUnderline( UNDERLINE_NONE );
1752 rCJKFont.SetUnderline( UNDERLINE_NONE );
1753 rCTLFont.SetUnderline( UNDERLINE_NONE );
1755 m_pUnderlineLB->SelectEntryPos( 0 );
1756 SfxItemState eState = rSet.GetItemState( nWhich );
1758 if ( eState >= SFX_ITEM_DONTCARE )
1760 if ( eState == SFX_ITEM_DONTCARE )
1761 m_pUnderlineLB->SetNoSelection();
1762 else
1764 const SvxUnderlineItem& rItem = (SvxUnderlineItem&)rSet.Get( nWhich );
1765 FontUnderline eUnderline = (FontUnderline)rItem.GetValue();
1766 rFont.SetUnderline( eUnderline );
1767 rCJKFont.SetUnderline( eUnderline );
1768 rCTLFont.SetUnderline( eUnderline );
1770 if ( eUnderline != UNDERLINE_NONE )
1772 for ( sal_Int32 i = 0; i < m_pUnderlineLB->GetEntryCount(); ++i )
1774 if ( (FontUnderline)(sal_uLong)m_pUnderlineLB->GetEntryData(i) == eUnderline )
1776 m_pUnderlineLB->SelectEntryPos(i);
1777 bEnable = true;
1778 break;
1782 Color aColor = rItem.GetColor();
1783 sal_Int32 nPos = m_pUnderlineColorLB->GetEntryPos( aColor );
1785 if ( LISTBOX_ENTRY_NOTFOUND != nPos )
1786 m_pUnderlineColorLB->SelectEntryPos( nPos );
1787 else
1789 nPos = m_pUnderlineColorLB->GetEntryPos( aColor );
1790 if ( LISTBOX_ENTRY_NOTFOUND != nPos )
1791 m_pUnderlineColorLB->SelectEntryPos( nPos );
1792 else
1793 m_pUnderlineColorLB->SelectEntryPos(
1794 m_pUnderlineColorLB->InsertEntry( aColor,
1795 OUString( SVX_RES( RID_SVXSTR_COLOR_USER ) ) ) );
1798 else
1800 m_pUnderlineColorLB->SelectEntry( Color( COL_AUTO ));
1801 m_pUnderlineColorLB->Disable();
1806 // Overline
1807 nWhich = GetWhich( SID_ATTR_CHAR_OVERLINE );
1808 rFont.SetOverline( UNDERLINE_NONE );
1809 rCJKFont.SetOverline( UNDERLINE_NONE );
1810 rCTLFont.SetOverline( UNDERLINE_NONE );
1812 m_pOverlineLB->SelectEntryPos( 0 );
1813 eState = rSet.GetItemState( nWhich );
1815 if ( eState >= SFX_ITEM_DONTCARE )
1817 if ( eState == SFX_ITEM_DONTCARE )
1818 m_pOverlineLB->SetNoSelection();
1819 else
1821 const SvxOverlineItem& rItem = (SvxOverlineItem&)rSet.Get( nWhich );
1822 FontUnderline eOverline = (FontUnderline)rItem.GetValue();
1823 rFont.SetOverline( eOverline );
1824 rCJKFont.SetOverline( eOverline );
1825 rCTLFont.SetOverline( eOverline );
1827 if ( eOverline != UNDERLINE_NONE )
1829 for ( sal_Int32 i = 0; i < m_pOverlineLB->GetEntryCount(); ++i )
1831 if ( (FontUnderline)(sal_uLong)m_pOverlineLB->GetEntryData(i) == eOverline )
1833 m_pOverlineLB->SelectEntryPos(i);
1834 bEnable = true;
1835 break;
1839 Color aColor = rItem.GetColor();
1840 sal_Int32 nPos = m_pOverlineColorLB->GetEntryPos( aColor );
1842 if ( LISTBOX_ENTRY_NOTFOUND != nPos )
1843 m_pOverlineColorLB->SelectEntryPos( nPos );
1844 else
1846 nPos = m_pOverlineColorLB->GetEntryPos( aColor );
1847 if ( LISTBOX_ENTRY_NOTFOUND != nPos )
1848 m_pOverlineColorLB->SelectEntryPos( nPos );
1849 else
1850 m_pOverlineColorLB->SelectEntryPos(
1851 m_pOverlineColorLB->InsertEntry( aColor,
1852 OUString( SVX_RES( RID_SVXSTR_COLOR_USER ) ) ) );
1855 else
1857 m_pOverlineColorLB->SelectEntry( Color( COL_AUTO ));
1858 m_pOverlineColorLB->Disable();
1863 // Strikeout
1864 nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT );
1865 rFont.SetStrikeout( STRIKEOUT_NONE );
1866 rCJKFont.SetStrikeout( STRIKEOUT_NONE );
1867 rCTLFont.SetStrikeout( STRIKEOUT_NONE );
1869 m_pStrikeoutLB->SelectEntryPos( 0 );
1870 eState = rSet.GetItemState( nWhich );
1872 if ( eState >= SFX_ITEM_DONTCARE )
1874 if ( eState == SFX_ITEM_DONTCARE )
1875 m_pStrikeoutLB->SetNoSelection();
1876 else
1878 const SvxCrossedOutItem& rItem = (SvxCrossedOutItem&)rSet.Get( nWhich );
1879 FontStrikeout eStrikeout = (FontStrikeout)rItem.GetValue();
1880 rFont.SetStrikeout( eStrikeout );
1881 rCJKFont.SetStrikeout( eStrikeout );
1882 rCTLFont.SetStrikeout( eStrikeout );
1884 if ( eStrikeout != STRIKEOUT_NONE )
1886 for ( sal_Int32 i = 0; i < m_pStrikeoutLB->GetEntryCount(); ++i )
1888 if ( (FontStrikeout)(sal_uLong)m_pStrikeoutLB->GetEntryData(i) == eStrikeout )
1890 m_pStrikeoutLB->SelectEntryPos(i);
1891 bEnable = true;
1892 break;
1899 // WordLineMode
1900 nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
1901 switch ( eState )
1903 case SFX_ITEM_UNKNOWN:
1904 m_pIndividualWordsBtn->Hide();
1905 break;
1907 case SFX_ITEM_DISABLED:
1908 case SFX_ITEM_READONLY:
1909 m_pIndividualWordsBtn->Disable();
1910 break;
1912 case SFX_ITEM_DONTCARE:
1913 m_pIndividualWordsBtn->SetState( TRISTATE_INDET );
1914 break;
1916 case SFX_ITEM_DEFAULT:
1917 case SFX_ITEM_SET:
1919 const SvxWordLineModeItem& rItem = (SvxWordLineModeItem&)rSet.Get( nWhich );
1920 rFont.SetWordLineMode( rItem.GetValue() );
1921 rCJKFont.SetWordLineMode( rItem.GetValue() );
1922 rCTLFont.SetWordLineMode( rItem.GetValue() );
1924 m_pIndividualWordsBtn->Check( rItem.GetValue() );
1925 m_pIndividualWordsBtn->Enable( bEnable );
1926 break;
1930 // Emphasis
1931 nWhich = GetWhich( SID_ATTR_CHAR_EMPHASISMARK );
1932 eState = rSet.GetItemState( nWhich );
1934 if ( eState >= SFX_ITEM_DEFAULT )
1936 const SvxEmphasisMarkItem& rItem = (SvxEmphasisMarkItem&)rSet.Get( nWhich );
1937 FontEmphasisMark eMark = rItem.GetEmphasisMark();
1938 rFont.SetEmphasisMark( eMark );
1939 rCJKFont.SetEmphasisMark( eMark );
1940 rCTLFont.SetEmphasisMark( eMark );
1942 m_pEmphasisLB->SelectEntryPos( (sal_Int32)( eMark & EMPHASISMARK_STYLE ) );
1943 eMark &= ~EMPHASISMARK_STYLE;
1944 sal_uLong nEntryData = ( eMark == EMPHASISMARK_POS_ABOVE )
1945 ? CHRDLG_POSITION_OVER
1946 : ( eMark == EMPHASISMARK_POS_BELOW ) ? CHRDLG_POSITION_UNDER : 0;
1948 for ( sal_Int32 i = 0; i < m_pPositionLB->GetEntryCount(); i++ )
1950 if ( nEntryData == (sal_uLong)m_pPositionLB->GetEntryData(i) )
1952 m_pPositionLB->SelectEntryPos(i);
1953 break;
1957 else if ( eState == SFX_ITEM_DONTCARE )
1958 m_pEmphasisLB->SetNoSelection( );
1959 else if ( eState == SFX_ITEM_UNKNOWN )
1961 m_pEmphasisFT->Hide();
1962 m_pEmphasisLB->Hide();
1964 else // SFX_ITEM_DISABLED or SFX_ITEM_READONLY
1966 m_pEmphasisFT->Disable();
1967 m_pEmphasisLB->Disable();
1970 // the select handler for the underline/overline/strikeout list boxes
1971 // SelectHdl_Impl( NULL );
1972 DBG_ASSERT(m_pUnderlineLB->GetSelectHdl() == m_pOverlineLB->GetSelectHdl(),
1973 "SvxCharEffectsPage::Reset: inconsistence (1)!");
1974 DBG_ASSERT(m_pUnderlineLB->GetSelectHdl() == m_pStrikeoutLB->GetSelectHdl(),
1975 "SvxCharEffectsPage::Reset: inconsistence (1)!");
1976 m_pUnderlineLB->GetSelectHdl().Call(NULL);
1977 // don't call SelectHdl_Impl directly!
1978 // in DisableControls, we may have re-reouted the select handler
1980 // the select handler for the emphasis listbox
1981 // SelectHdl_Impl( m_pEmphasisLB );
1982 DBG_ASSERT(m_pEmphasisLB->GetSelectHdl() == LINK(this, SvxCharEffectsPage, SelectHdl_Impl),
1983 "SvxCharEffectsPage::Reset: inconsistence (2)!");
1984 m_pEmphasisLB->GetSelectHdl().Call( m_pEmphasisLB );
1985 // this is for consistency only. Here it would be allowed to call SelectHdl_Impl directly ...
1987 // Effects
1988 SvxCaseMap eCaseMap = SVX_CASEMAP_END;
1989 nWhich = GetWhich( SID_ATTR_CHAR_CASEMAP );
1990 eState = rSet.GetItemState( nWhich );
1991 switch ( eState )
1993 case SFX_ITEM_UNKNOWN:
1994 m_pEffectsFT->Hide();
1995 m_pEffectsLB->Hide();
1996 break;
1998 case SFX_ITEM_DISABLED:
1999 case SFX_ITEM_READONLY:
2000 m_pEffectsFT->Disable();
2001 m_pEffectsLB->Disable();
2002 break;
2004 case SFX_ITEM_DONTCARE:
2005 m_pEffectsLB->SetNoSelection();
2006 break;
2008 case SFX_ITEM_DEFAULT:
2009 case SFX_ITEM_SET:
2011 const SvxCaseMapItem& rItem = (const SvxCaseMapItem&)rSet.Get( nWhich );
2012 eCaseMap = (SvxCaseMap)rItem.GetValue();
2013 break;
2016 SetCaseMap_Impl( eCaseMap );
2018 //Relief
2019 nWhich = GetWhich(SID_ATTR_CHAR_RELIEF);
2020 eState = rSet.GetItemState( nWhich );
2021 switch ( eState )
2023 case SFX_ITEM_UNKNOWN:
2024 m_pReliefFT->Hide();
2025 m_pReliefLB->Hide();
2026 break;
2028 case SFX_ITEM_DISABLED:
2029 case SFX_ITEM_READONLY:
2030 m_pReliefFT->Disable();
2031 m_pReliefLB->Disable();
2032 break;
2034 case SFX_ITEM_DONTCARE:
2035 m_pReliefLB->SetNoSelection();
2036 break;
2038 case SFX_ITEM_DEFAULT:
2039 case SFX_ITEM_SET:
2041 const SvxCharReliefItem& rItem = (const SvxCharReliefItem&)rSet.Get( nWhich );
2042 m_pReliefLB->SelectEntryPos(rItem.GetValue());
2043 SelectHdl_Impl(m_pReliefLB);
2044 break;
2048 // Outline
2049 nWhich = GetWhich( SID_ATTR_CHAR_CONTOUR );
2050 eState = rSet.GetItemState( nWhich );
2051 switch ( eState )
2053 case SFX_ITEM_UNKNOWN:
2054 m_pOutlineBtn->Hide();
2055 break;
2057 case SFX_ITEM_DISABLED:
2058 case SFX_ITEM_READONLY:
2059 m_pOutlineBtn->Disable();
2060 break;
2062 case SFX_ITEM_DONTCARE:
2063 m_pOutlineBtn->SetState( TRISTATE_INDET );
2064 break;
2066 case SFX_ITEM_DEFAULT:
2067 case SFX_ITEM_SET:
2069 const SvxContourItem& rItem = (SvxContourItem&)rSet.Get( nWhich );
2070 m_pOutlineBtn->SetState( (TriState)rItem.GetValue() );
2071 m_pOutlineBtn->EnableTriState( false );
2072 break;
2076 // Shadow
2077 nWhich = GetWhich( SID_ATTR_CHAR_SHADOWED );
2078 eState = rSet.GetItemState( nWhich );
2080 switch ( eState )
2082 case SFX_ITEM_UNKNOWN:
2083 m_pShadowBtn->Hide();
2084 break;
2086 case SFX_ITEM_DISABLED:
2087 case SFX_ITEM_READONLY:
2088 m_pShadowBtn->Disable();
2089 break;
2091 case SFX_ITEM_DONTCARE:
2092 m_pShadowBtn->SetState( TRISTATE_INDET );
2093 break;
2095 case SFX_ITEM_DEFAULT:
2096 case SFX_ITEM_SET:
2098 const SvxShadowedItem& rItem = (SvxShadowedItem&)rSet.Get( nWhich );
2099 m_pShadowBtn->SetState( (TriState)rItem.GetValue() );
2100 m_pShadowBtn->EnableTriState( false );
2101 break;
2105 // Blinking
2106 nWhich = GetWhich( SID_ATTR_FLASH );
2107 eState = rSet.GetItemState( nWhich );
2109 switch ( eState )
2111 case SFX_ITEM_UNKNOWN:
2112 m_pBlinkingBtn->Hide();
2113 break;
2115 case SFX_ITEM_DISABLED:
2116 case SFX_ITEM_READONLY:
2117 m_pBlinkingBtn->Disable();
2118 break;
2120 case SFX_ITEM_DONTCARE:
2121 m_pBlinkingBtn->SetState( TRISTATE_INDET );
2122 break;
2124 case SFX_ITEM_DEFAULT:
2125 case SFX_ITEM_SET:
2127 const SvxBlinkItem& rItem = (SvxBlinkItem&)rSet.Get( nWhich );
2128 m_pBlinkingBtn->SetState( (TriState)rItem.GetValue() );
2129 m_pBlinkingBtn->EnableTriState( false );
2130 break;
2133 // Hidden
2134 nWhich = GetWhich( SID_ATTR_CHAR_HIDDEN );
2135 eState = rSet.GetItemState( nWhich );
2137 switch ( eState )
2139 case SFX_ITEM_UNKNOWN:
2140 m_pHiddenBtn->Hide();
2141 break;
2143 case SFX_ITEM_DISABLED:
2144 case SFX_ITEM_READONLY:
2145 m_pHiddenBtn->Disable();
2146 break;
2148 case SFX_ITEM_DONTCARE:
2149 m_pHiddenBtn->SetState( TRISTATE_INDET );
2150 break;
2152 case SFX_ITEM_DEFAULT:
2153 case SFX_ITEM_SET:
2155 const SvxCharHiddenItem& rItem = (SvxCharHiddenItem&)rSet.Get( nWhich );
2156 m_pHiddenBtn->SetState( (TriState)rItem.GetValue() );
2157 m_pHiddenBtn->EnableTriState( false );
2158 break;
2162 SetPrevFontWidthScale( rSet );
2163 ResetColor_Impl( rSet );
2165 // preview update
2166 m_pPreviewWin->Invalidate();
2168 // save this settings
2169 m_pUnderlineLB->SaveValue();
2170 m_pUnderlineColorLB->SaveValue();
2171 m_pOverlineLB->SaveValue();
2172 m_pOverlineColorLB->SaveValue();
2173 m_pStrikeoutLB->SaveValue();
2174 m_pIndividualWordsBtn->SaveValue();
2175 m_pEmphasisLB->SaveValue();
2176 m_pPositionLB->SaveValue();
2177 m_pEffectsLB->SaveValue();
2178 m_pReliefLB->SaveValue();
2179 m_pOutlineBtn->SaveValue();
2180 m_pShadowBtn->SaveValue();
2181 m_pBlinkingBtn->SaveValue();
2182 m_pHiddenBtn->SaveValue();
2183 m_pFontColorLB->SaveValue();
2188 bool SvxCharEffectsPage::FillItemSet( SfxItemSet& rSet )
2190 const SfxPoolItem* pOld = 0;
2191 const SfxItemSet& rOldSet = GetItemSet();
2192 bool bModified = false;
2193 bool bChanged = true;
2195 // Underline
2196 sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_UNDERLINE );
2197 pOld = GetOldItem( rSet, SID_ATTR_CHAR_UNDERLINE );
2198 sal_Int32 nPos = m_pUnderlineLB->GetSelectEntryPos();
2199 FontUnderline eUnder = (FontUnderline)(sal_uLong)m_pUnderlineLB->GetEntryData( nPos );
2201 if ( pOld )
2203 //! if there are different underline styles in the selection the
2204 //! item-state in the 'rOldSet' will be invalid. In this case
2205 //! changing the underline style will be allowed if a style is
2206 //! selected in the listbox.
2207 bool bAllowChg = LISTBOX_ENTRY_NOTFOUND != nPos &&
2208 SFX_ITEM_DEFAULT > rOldSet.GetItemState( nWhich, true );
2210 const SvxUnderlineItem& rItem = *( (const SvxUnderlineItem*)pOld );
2211 if ( (FontUnderline)rItem.GetValue() == eUnder &&
2212 ( UNDERLINE_NONE == eUnder || rItem.GetColor() == m_pUnderlineColorLB->GetSelectEntryColor() ) &&
2213 ! bAllowChg )
2214 bChanged = false;
2217 if ( bChanged )
2219 SvxUnderlineItem aNewItem( eUnder, nWhich );
2220 aNewItem.SetColor( m_pUnderlineColorLB->GetSelectEntryColor() );
2221 rSet.Put( aNewItem );
2222 bModified = true;
2224 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2225 CLEARTITEM;
2227 bChanged = true;
2229 // Overline
2230 nWhich = GetWhich( SID_ATTR_CHAR_OVERLINE );
2231 pOld = GetOldItem( rSet, SID_ATTR_CHAR_OVERLINE );
2232 nPos = m_pOverlineLB->GetSelectEntryPos();
2233 FontUnderline eOver = (FontUnderline)(sal_uLong)m_pOverlineLB->GetEntryData( nPos );
2235 if ( pOld )
2237 //! if there are different underline styles in the selection the
2238 //! item-state in the 'rOldSet' will be invalid. In this case
2239 //! changing the underline style will be allowed if a style is
2240 //! selected in the listbox.
2241 bool bAllowChg = LISTBOX_ENTRY_NOTFOUND != nPos &&
2242 SFX_ITEM_DEFAULT > rOldSet.GetItemState( nWhich, true );
2244 const SvxOverlineItem& rItem = *( (const SvxOverlineItem*)pOld );
2245 if ( (FontUnderline)rItem.GetValue() == eOver &&
2246 ( UNDERLINE_NONE == eOver || rItem.GetColor() == m_pOverlineColorLB->GetSelectEntryColor() ) &&
2247 ! bAllowChg )
2248 bChanged = false;
2251 if ( bChanged )
2253 SvxOverlineItem aNewItem( eOver, nWhich );
2254 aNewItem.SetColor( m_pOverlineColorLB->GetSelectEntryColor() );
2255 rSet.Put( aNewItem );
2256 bModified = true;
2258 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2259 CLEARTITEM;
2261 bChanged = true;
2263 // Strikeout
2264 nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT );
2265 pOld = GetOldItem( rSet, SID_ATTR_CHAR_STRIKEOUT );
2266 nPos = m_pStrikeoutLB->GetSelectEntryPos();
2267 FontStrikeout eStrike = (FontStrikeout)(sal_uLong)m_pStrikeoutLB->GetEntryData( nPos );
2269 if ( pOld )
2271 //! if there are different strikeout styles in the selection the
2272 //! item-state in the 'rOldSet' will be invalid. In this case
2273 //! changing the strikeout style will be allowed if a style is
2274 //! selected in the listbox.
2275 bool bAllowChg = LISTBOX_ENTRY_NOTFOUND != nPos &&
2276 SFX_ITEM_DEFAULT > rOldSet.GetItemState( nWhich, true );
2278 const SvxCrossedOutItem& rItem = *( (const SvxCrossedOutItem*)pOld );
2279 if ( !m_pStrikeoutLB->IsEnabled()
2280 || ((FontStrikeout)rItem.GetValue() == eStrike && !bAllowChg) )
2281 bChanged = false;
2284 if ( bChanged )
2286 rSet.Put( SvxCrossedOutItem( eStrike, nWhich ) );
2287 bModified = true;
2289 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2290 CLEARTITEM;
2292 bChanged = true;
2294 // Individual words
2295 nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
2296 pOld = GetOldItem( rSet, SID_ATTR_CHAR_WORDLINEMODE );
2298 if ( pOld )
2300 const SvxWordLineModeItem& rItem = *( (const SvxWordLineModeItem*)pOld );
2301 if ( rItem.GetValue() == (bool) m_pIndividualWordsBtn->IsChecked() )
2302 bChanged = false;
2305 if ( rOldSet.GetItemState( nWhich ) == SFX_ITEM_DONTCARE &&
2306 ! m_pIndividualWordsBtn->IsValueChangedFromSaved() )
2307 bChanged = false;
2309 if ( bChanged )
2311 rSet.Put( SvxWordLineModeItem( m_pIndividualWordsBtn->IsChecked(), nWhich ) );
2312 bModified = true;
2314 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2315 CLEARTITEM;
2317 bChanged = true;
2319 // Emphasis
2320 nWhich = GetWhich( SID_ATTR_CHAR_EMPHASISMARK );
2321 pOld = GetOldItem( rSet, SID_ATTR_CHAR_EMPHASISMARK );
2322 sal_Int32 nMarkPos = m_pEmphasisLB->GetSelectEntryPos();
2323 sal_Int32 nPosPos = m_pPositionLB->GetSelectEntryPos();
2324 FontEmphasisMark eMark = (FontEmphasisMark)nMarkPos;
2325 if ( m_pPositionLB->IsEnabled() )
2327 eMark |= ( CHRDLG_POSITION_UNDER == (sal_uLong)m_pPositionLB->GetEntryData( nPosPos ) )
2328 ? EMPHASISMARK_POS_BELOW : EMPHASISMARK_POS_ABOVE;
2331 if ( pOld )
2333 if( rOldSet.GetItemState( nWhich ) != SFX_ITEM_DONTCARE )
2335 const SvxEmphasisMarkItem& rItem = *( (const SvxEmphasisMarkItem*)pOld );
2336 if ( rItem.GetEmphasisMark() == eMark )
2337 bChanged = false;
2341 if ( rOldSet.GetItemState( nWhich ) == SFX_ITEM_DONTCARE &&
2342 m_pEmphasisLB->GetSavedValue() == nMarkPos && m_pPositionLB->GetSavedValue() == nPosPos )
2343 bChanged = false;
2345 if ( bChanged )
2347 rSet.Put( SvxEmphasisMarkItem( eMark, nWhich ) );
2348 bModified = true;
2350 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2351 CLEARTITEM;
2353 bChanged = true;
2355 // Effects
2356 nWhich = GetWhich( SID_ATTR_CHAR_CASEMAP );
2357 pOld = GetOldItem( rSet, SID_ATTR_CHAR_CASEMAP );
2358 SvxCaseMap eCaseMap = SVX_CASEMAP_NOT_MAPPED;
2359 bool bChecked = false;
2360 sal_Int32 nCapsPos = m_pEffectsLB->GetSelectEntryPos();
2361 if ( nCapsPos != LISTBOX_ENTRY_NOTFOUND )
2363 eCaseMap = (SvxCaseMap)nCapsPos;
2364 bChecked = true;
2367 if ( pOld )
2369 //! if there are different effect styles in the selection the
2370 //! item-state in the 'rOldSet' will be invalid. In this case
2371 //! changing the effect style will be allowed if a style is
2372 //! selected in the listbox.
2373 bool bAllowChg = LISTBOX_ENTRY_NOTFOUND != nPos &&
2374 SFX_ITEM_DEFAULT > rOldSet.GetItemState( nWhich, true );
2376 const SvxCaseMapItem& rItem = *( (const SvxCaseMapItem*)pOld );
2377 if ( (SvxCaseMap)rItem.GetValue() == eCaseMap && !bAllowChg )
2378 bChanged = false;
2381 if ( bChanged && bChecked )
2383 rSet.Put( SvxCaseMapItem( eCaseMap, nWhich ) );
2384 bModified = true;
2386 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2387 CLEARTITEM;
2389 bChanged = true;
2391 //Relief
2392 nWhich = GetWhich(SID_ATTR_CHAR_RELIEF);
2393 if(m_pReliefLB->IsValueChangedFromSaved())
2395 m_pReliefLB->SaveValue();
2396 SvxCharReliefItem aRelief((FontRelief)m_pReliefLB->GetSelectEntryPos(), nWhich);
2397 rSet.Put(aRelief);
2400 // Outline
2401 const SfxItemSet* pExampleSet = GetTabDialog() ? GetTabDialog()->GetExampleSet() : NULL;
2402 nWhich = GetWhich( SID_ATTR_CHAR_CONTOUR );
2403 pOld = GetOldItem( rSet, SID_ATTR_CHAR_CONTOUR );
2404 TriState eState = m_pOutlineBtn->GetState();
2405 const SfxPoolItem* pItem;
2407 if ( pOld )
2409 const SvxContourItem& rItem = *( (const SvxContourItem*)pOld );
2410 if ( rItem.GetValue() == StateToAttr( eState ) && m_pOutlineBtn->GetSavedValue() == eState )
2411 bChanged = false;
2414 if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, false, &pItem ) == SFX_ITEM_SET &&
2415 !StateToAttr( eState ) && ( (SvxContourItem*)pItem )->GetValue() )
2416 bChanged = true;
2418 if ( bChanged && eState != TRISTATE_INDET )
2420 rSet.Put( SvxContourItem( StateToAttr( eState ), nWhich ) );
2421 bModified = true;
2423 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2424 CLEARTITEM;
2426 bChanged = true;
2428 // Shadow
2429 nWhich = GetWhich( SID_ATTR_CHAR_SHADOWED );
2430 pOld = GetOldItem( rSet, SID_ATTR_CHAR_SHADOWED );
2431 eState = m_pShadowBtn->GetState();
2433 if ( pOld )
2435 const SvxShadowedItem& rItem = *( (const SvxShadowedItem*)pOld );
2436 if ( rItem.GetValue() == StateToAttr( eState ) && m_pShadowBtn->GetSavedValue() == eState )
2437 bChanged = false;
2440 if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, false, &pItem ) == SFX_ITEM_SET &&
2441 !StateToAttr( eState ) && ( (SvxShadowedItem*)pItem )->GetValue() )
2442 bChanged = true;
2444 if ( bChanged && eState != TRISTATE_INDET )
2446 rSet.Put( SvxShadowedItem( StateToAttr( eState ), nWhich ) );
2447 bModified = true;
2449 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2450 CLEARTITEM;
2452 bChanged = true;
2454 // Blinking
2455 nWhich = GetWhich( SID_ATTR_FLASH );
2456 pOld = GetOldItem( rSet, SID_ATTR_FLASH );
2457 eState = m_pBlinkingBtn->GetState();
2459 if ( pOld )
2461 const SvxBlinkItem& rItem = *( (const SvxBlinkItem*)pOld );
2462 if ( rItem.GetValue() == StateToAttr( eState ) && m_pBlinkingBtn->GetSavedValue() == eState )
2463 bChanged = false;
2466 if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, false, &pItem ) == SFX_ITEM_SET &&
2467 !StateToAttr( eState ) && ( (SvxBlinkItem*)pItem )->GetValue() )
2468 bChanged = true;
2470 if ( bChanged && eState != TRISTATE_INDET )
2472 rSet.Put( SvxBlinkItem( StateToAttr( eState ), nWhich ) );
2473 bModified = true;
2475 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2476 CLEARTITEM;
2478 // Hidden
2479 nWhich = GetWhich( SID_ATTR_CHAR_HIDDEN );
2480 pOld = GetOldItem( rSet, SID_ATTR_CHAR_HIDDEN );
2481 eState = m_pHiddenBtn->GetState();
2482 bChanged = true;
2484 if ( pOld )
2486 const SvxCharHiddenItem& rItem = *( (const SvxCharHiddenItem*)pOld );
2487 if ( rItem.GetValue() == StateToAttr( eState ) && m_pHiddenBtn->GetSavedValue() == eState )
2488 bChanged = false;
2491 if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, false, &pItem ) == SFX_ITEM_SET &&
2492 !StateToAttr( eState ) && ( (SvxCharHiddenItem*)pItem )->GetValue() )
2493 bChanged = true;
2495 if ( bChanged && eState != TRISTATE_INDET )
2497 rSet.Put( SvxCharHiddenItem( StateToAttr( eState ), nWhich ) );
2498 bModified = true;
2500 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2501 CLEARTITEM;
2503 bModified |= FillItemSetColor_Impl( rSet );
2505 return bModified;
2508 void SvxCharEffectsPage::DisableControls( sal_uInt16 nDisable )
2510 if ( ( DISABLE_CASEMAP & nDisable ) == DISABLE_CASEMAP )
2512 m_pEffectsFT->Disable();
2513 m_pEffectsLB->Disable();
2516 if ( ( DISABLE_WORDLINE & nDisable ) == DISABLE_WORDLINE )
2517 m_pIndividualWordsBtn->Disable();
2519 if ( ( DISABLE_BLINK & nDisable ) == DISABLE_BLINK )
2520 m_pBlinkingBtn->Disable();
2522 if ( ( DISABLE_UNDERLINE_COLOR & nDisable ) == DISABLE_UNDERLINE_COLOR )
2524 // disable the controls
2525 m_pUnderlineColorFT->Disable( );
2526 m_pUnderlineColorLB->Disable( );
2527 // and reroute the selection handler of the controls which normally would affect the color box dis-/enabling
2528 m_pUnderlineLB->SetSelectHdl(LINK(this, SvxCharEffectsPage, UpdatePreview_Impl));
2529 m_pStrikeoutLB->SetSelectHdl(LINK(this, SvxCharEffectsPage, UpdatePreview_Impl));
2533 void SvxCharEffectsPage::EnableFlash()
2535 m_pBlinkingBtn->Show();
2539 void SvxCharEffectsPage::SetPreviewBackgroundToCharacter()
2541 m_bPreviewBackgroundToCharacter = true;
2545 void SvxCharEffectsPage::PageCreated(const SfxAllItemSet& aSet)
2547 SFX_ITEMSET_ARG (&aSet,pDisableCtlItem,SfxUInt16Item,SID_DISABLE_CTL,false);
2548 SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,false);
2549 if (pDisableCtlItem)
2550 DisableControls(pDisableCtlItem->GetValue());
2552 if (pFlagItem)
2554 sal_uInt32 nFlags=pFlagItem->GetValue();
2555 if ( ( nFlags & SVX_ENABLE_FLASH ) == SVX_ENABLE_FLASH )
2556 EnableFlash();
2557 if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
2558 SetPreviewBackgroundToCharacter();
2562 // class SvxCharPositionPage ---------------------------------------------
2564 SvxCharPositionPage::SvxCharPositionPage( Window* pParent, const SfxItemSet& rInSet )
2565 : SvxCharBasePage(pParent, "PositionPage", "cui/ui/positionpage.ui", rInSet)
2566 , m_nSuperEsc((short)DFLT_ESC_SUPER)
2567 , m_nSubEsc((short)DFLT_ESC_SUB)
2568 , m_nScaleWidthItemSetVal(100)
2569 , m_nScaleWidthInitialVal(100)
2570 , m_nSuperProp((sal_uInt8)DFLT_ESC_PROP)
2571 , m_nSubProp((sal_uInt8)DFLT_ESC_PROP)
2573 get(m_pHighPosBtn, "superscript");
2574 get(m_pNormalPosBtn, "normal");
2575 get(m_pLowPosBtn, "subscript");
2576 get(m_pHighLowFT, "raiselower");
2577 get(m_pHighLowMF, "raiselowersb");
2578 get(m_pHighLowRB, "automatic");
2579 get(m_pFontSizeFT, "relativefontsize");
2580 get(m_pFontSizeMF, "fontsizesb");
2581 get(m_pRotationContainer, "rotationcontainer");
2582 get(m_pScalingFT, "rotate");
2583 get(m_pScalingAndRotationFT, "rotateandscale");
2584 get(m_p0degRB, "0deg");
2585 get(m_p90degRB, "90deg");
2586 get(m_p270degRB, "270deg");
2587 get(m_pFitToLineCB, "fittoline");
2588 get(m_pScaleWidthMF, "scalewidthsb");
2589 get(m_pKerningLB, "kerninglb");
2590 get(m_pKerningFT, "kerningft");
2591 get(m_pKerningMF, "kerningsb");
2592 get(m_pPairKerningBtn, "pairkerning");
2594 get(m_pPreviewWin, "preview");
2596 Initialize();
2601 void SvxCharPositionPage::Initialize()
2603 // to handle the changes of the other pages
2604 SetExchangeSupport();
2606 GetPreviewFont().SetSize( Size( 0, 240 ) );
2607 GetPreviewCJKFont().SetSize( Size( 0, 240 ) );
2608 GetPreviewCTLFont().SetSize( Size( 0, 240 ) );
2610 m_pNormalPosBtn->Check();
2611 PositionHdl_Impl( m_pNormalPosBtn );
2612 m_pKerningLB->SelectEntryPos( 0 );
2613 KerningSelectHdl_Impl( NULL );
2615 Link aLink = LINK( this, SvxCharPositionPage, PositionHdl_Impl );
2616 m_pHighPosBtn->SetClickHdl( aLink );
2617 m_pNormalPosBtn->SetClickHdl( aLink );
2618 m_pLowPosBtn->SetClickHdl( aLink );
2620 aLink = LINK( this, SvxCharPositionPage, RotationHdl_Impl );
2621 m_p0degRB->SetClickHdl( aLink );
2622 m_p90degRB->SetClickHdl( aLink );
2623 m_p270degRB->SetClickHdl( aLink );
2625 aLink = LINK( this, SvxCharPositionPage, FontModifyHdl_Impl );
2626 m_pHighLowMF->SetModifyHdl( aLink );
2627 m_pFontSizeMF->SetModifyHdl( aLink );
2629 aLink = LINK( this, SvxCharPositionPage, LoseFocusHdl_Impl );
2630 m_pHighLowMF->SetLoseFocusHdl( aLink );
2631 m_pFontSizeMF->SetLoseFocusHdl( aLink );
2633 m_pHighLowRB->SetClickHdl( LINK( this, SvxCharPositionPage, AutoPositionHdl_Impl ) );
2634 m_pFitToLineCB->SetClickHdl( LINK( this, SvxCharPositionPage, FitToLineHdl_Impl ) );
2635 m_pKerningLB->SetSelectHdl( LINK( this, SvxCharPositionPage, KerningSelectHdl_Impl ) );
2636 m_pKerningMF->SetModifyHdl( LINK( this, SvxCharPositionPage, KerningModifyHdl_Impl ) );
2637 m_pPairKerningBtn->SetClickHdl( LINK( this, SvxCharPositionPage, PairKerningHdl_Impl ) );
2638 m_pScaleWidthMF->SetModifyHdl( LINK( this, SvxCharPositionPage, ScaleWidthModifyHdl_Impl ) );
2641 SvxCharPositionPage::~SvxCharPositionPage()
2647 void SvxCharPositionPage::UpdatePreview_Impl( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
2649 SetPrevFontEscapement( nProp, nEscProp, nEsc );
2654 void SvxCharPositionPage::SetEscapement_Impl( sal_uInt16 nEsc )
2656 SvxEscapementItem aEscItm( (SvxEscapement)nEsc, SID_ATTR_CHAR_ESCAPEMENT );
2658 if ( SVX_ESCAPEMENT_SUPERSCRIPT == nEsc )
2660 aEscItm.GetEsc() = m_nSuperEsc;
2661 aEscItm.GetProp() = m_nSuperProp;
2663 else if ( SVX_ESCAPEMENT_SUBSCRIPT == nEsc )
2665 aEscItm.GetEsc() = m_nSubEsc;
2666 aEscItm.GetProp() = m_nSubProp;
2669 short nFac = aEscItm.GetEsc() < 0 ? -1 : 1;
2671 m_pHighLowMF->SetValue( aEscItm.GetEsc() * nFac );
2672 m_pFontSizeMF->SetValue( aEscItm.GetProp() );
2674 if ( SVX_ESCAPEMENT_OFF == nEsc )
2676 m_pHighLowFT->Disable();
2677 m_pHighLowMF->Disable();
2678 m_pFontSizeFT->Disable();
2679 m_pFontSizeMF->Disable();
2680 m_pHighLowRB->Disable();
2682 else
2684 m_pFontSizeFT->Enable();
2685 m_pFontSizeMF->Enable();
2686 m_pHighLowRB->Enable();
2688 if ( !m_pHighLowRB->IsChecked() )
2690 m_pHighLowFT->Enable();
2691 m_pHighLowMF->Enable();
2693 else
2694 AutoPositionHdl_Impl( m_pHighLowRB );
2697 UpdatePreview_Impl( 100, aEscItm.GetProp(), aEscItm.GetEsc() );
2702 IMPL_LINK( SvxCharPositionPage, PositionHdl_Impl, RadioButton*, pBtn )
2704 sal_uInt16 nEsc = SVX_ESCAPEMENT_OFF; // also when pBtn == NULL
2706 if ( m_pHighPosBtn == pBtn )
2707 nEsc = SVX_ESCAPEMENT_SUPERSCRIPT;
2708 else if ( m_pLowPosBtn == pBtn )
2709 nEsc = SVX_ESCAPEMENT_SUBSCRIPT;
2711 SetEscapement_Impl( nEsc );
2712 return 0;
2717 IMPL_LINK( SvxCharPositionPage, RotationHdl_Impl, RadioButton*, pBtn )
2719 bool bEnable = false;
2720 if (m_p90degRB == pBtn || m_p270degRB == pBtn)
2721 bEnable = true;
2722 else
2723 OSL_ENSURE( m_p0degRB == pBtn, "unexpected button" );
2724 m_pFitToLineCB->Enable( bEnable );
2725 return 0;
2730 IMPL_LINK_NOARG(SvxCharPositionPage, FontModifyHdl_Impl)
2732 sal_uInt8 nEscProp = (sal_uInt8)m_pFontSizeMF->GetValue();
2733 short nEsc = (short)m_pHighLowMF->GetValue();
2734 nEsc *= m_pLowPosBtn->IsChecked() ? -1 : 1;
2735 UpdatePreview_Impl( 100, nEscProp, nEsc );
2736 return 0;
2741 IMPL_LINK( SvxCharPositionPage, AutoPositionHdl_Impl, CheckBox*, pBox )
2743 if ( pBox->IsChecked() )
2745 m_pHighLowFT->Disable();
2746 m_pHighLowMF->Disable();
2748 else
2749 PositionHdl_Impl( m_pHighPosBtn->IsChecked() ? m_pHighPosBtn
2750 : m_pLowPosBtn->IsChecked() ? m_pLowPosBtn
2751 : m_pNormalPosBtn );
2752 return 0;
2757 IMPL_LINK( SvxCharPositionPage, FitToLineHdl_Impl, CheckBox*, pBox )
2759 if (m_pFitToLineCB == pBox)
2761 sal_uInt16 nVal = m_nScaleWidthInitialVal;
2762 if (m_pFitToLineCB->IsChecked())
2763 nVal = m_nScaleWidthItemSetVal;
2764 m_pScaleWidthMF->SetValue( nVal );
2766 m_pPreviewWin->SetFontWidthScale( nVal );
2768 return 0;
2773 IMPL_LINK_NOARG(SvxCharPositionPage, KerningSelectHdl_Impl)
2775 if ( m_pKerningLB->GetSelectEntryPos() > LW_NORMAL )
2777 m_pKerningFT->Enable();
2778 m_pKerningMF->Enable();
2780 if ( m_pKerningLB->GetSelectEntryPos() == LW_CONDENSED )
2782 // Condensed -> max value == 1/6 of the current font height
2783 SvxFont& rFont = GetPreviewFont();
2784 long nMax = rFont.GetSize().Height() / 6;
2785 m_pKerningMF->SetMax( m_pKerningMF->Normalize( nMax ), FUNIT_TWIP );
2786 m_pKerningMF->SetLast( m_pKerningMF->GetMax( m_pKerningMF->GetUnit() ) );
2788 else
2790 m_pKerningMF->SetMax( 9999 );
2791 m_pKerningMF->SetLast( 9999 );
2794 else
2796 m_pKerningMF->SetValue( 0 );
2797 m_pKerningFT->Disable();
2798 m_pKerningMF->Disable();
2801 KerningModifyHdl_Impl( NULL );
2803 return 0;
2808 IMPL_LINK_NOARG(SvxCharPositionPage, KerningModifyHdl_Impl)
2810 long nVal = static_cast<long>(m_pKerningMF->GetValue());
2811 nVal = LogicToLogic( nVal, MAP_POINT, MAP_TWIP );
2812 long nKern = (short)m_pKerningMF->Denormalize( nVal );
2814 // Condensed? -> then negative
2815 if ( m_pKerningLB->GetSelectEntryPos() == LW_CONDENSED )
2816 nKern *= -1;
2818 SvxFont& rFont = GetPreviewFont();
2819 SvxFont& rCJKFont = GetPreviewCJKFont();
2820 SvxFont& rCTLFont = GetPreviewCTLFont();
2822 rFont.SetFixKerning( (short)nKern );
2823 rCJKFont.SetFixKerning( (short)nKern );
2824 rCTLFont.SetFixKerning( (short)nKern );
2825 m_pPreviewWin->Invalidate();
2826 return 0;
2831 IMPL_LINK_NOARG(SvxCharPositionPage, PairKerningHdl_Impl)
2833 return 0;
2838 IMPL_LINK( SvxCharPositionPage, LoseFocusHdl_Impl, MetricField*, pField )
2840 #ifdef DBG_UTIL
2841 bool bHigh = m_pHighPosBtn->IsChecked();
2842 #endif
2843 bool bLow = m_pLowPosBtn->IsChecked();
2844 DBG_ASSERT( bHigh || bLow, "normal position is not valid" );
2846 if ( m_pHighLowMF == pField )
2848 if ( bLow )
2849 m_nSubEsc = (short)m_pHighLowMF->GetValue() * -1;
2850 else
2851 m_nSuperEsc = (short)m_pHighLowMF->GetValue();
2853 else if ( m_pFontSizeMF == pField )
2855 if ( bLow )
2856 m_nSubProp = (sal_uInt8)m_pFontSizeMF->GetValue();
2857 else
2858 m_nSuperProp = (sal_uInt8)m_pFontSizeMF->GetValue();
2860 return 0;
2865 IMPL_LINK_NOARG(SvxCharPositionPage, ScaleWidthModifyHdl_Impl)
2867 m_pPreviewWin->SetFontWidthScale( sal_uInt16( m_pScaleWidthMF->GetValue() ) );
2869 return 0;
2872 void SvxCharPositionPage::ActivatePage( const SfxItemSet& rSet )
2874 //update the preview
2875 SvxCharBasePage::ActivatePage( rSet );
2877 //the only thing that has to be checked is the max. allowed value for the
2878 //condense edit field
2879 if ( m_pKerningLB->GetSelectEntryPos() == LW_CONDENSED )
2881 // Condensed -> max value == 1/6 of the current font height
2882 SvxFont& rFont = GetPreviewFont();
2883 long nMax = rFont.GetSize().Height() / 6;
2884 long nKern = (short)m_pKerningMF->Denormalize( LogicToLogic( static_cast<long>(m_pKerningMF->GetValue()), MAP_POINT, MAP_TWIP ) );
2885 m_pKerningMF->SetMax( m_pKerningMF->Normalize( nKern > nMax ? nKern : nMax ), FUNIT_TWIP );
2886 m_pKerningMF->SetLast( m_pKerningMF->GetMax( m_pKerningMF->GetUnit() ) );
2892 int SvxCharPositionPage::DeactivatePage( SfxItemSet* _pSet )
2894 if ( _pSet )
2895 FillItemSet( *_pSet );
2896 return LEAVE_PAGE;
2901 SfxTabPage* SvxCharPositionPage::Create( Window* pParent, const SfxItemSet& rSet )
2903 return new SvxCharPositionPage( pParent, rSet );
2908 const sal_uInt16* SvxCharPositionPage::GetRanges()
2910 return pPositionRanges;
2914 void SvxCharPositionPage::Reset( const SfxItemSet& rSet )
2916 OUString sUser = GetUserData();
2918 if ( !sUser.isEmpty() )
2920 m_nSuperEsc = (short)sUser.getToken( 0, ';' ).toInt32();
2921 m_nSubEsc = (short)sUser.getToken( 1, ';' ).toInt32();
2922 m_nSuperProp = (sal_uInt8)sUser.getToken( 2, ';' ).toInt32();
2923 m_nSubProp = (sal_uInt8)sUser.getToken( 3, ';' ).toInt32();
2925 //fdo#75307 validate all the entries and discard all of them if any are
2926 //out of range
2927 bool bValid = true;
2928 if (m_nSuperEsc < m_pHighLowMF->GetMin() || m_nSuperEsc > m_pHighLowMF->GetMax())
2929 bValid = false;
2930 if (m_nSubEsc*-1 < m_pHighLowMF->GetMin() || m_nSubEsc*-1 > m_pHighLowMF->GetMax())
2931 bValid = false;
2932 if (m_nSuperProp < m_pFontSizeMF->GetMin() || m_nSuperProp > m_pFontSizeMF->GetMax())
2933 bValid = false;
2934 if (m_nSubProp < m_pFontSizeMF->GetMin() || m_nSubProp > m_pFontSizeMF->GetMax())
2935 bValid = false;
2937 if (!bValid)
2939 m_nSuperEsc = DFLT_ESC_SUPER;
2940 m_nSubEsc = DFLT_ESC_SUB;
2941 m_nSuperProp = DFLT_ESC_PROP;
2942 m_nSubProp = DFLT_ESC_PROP;
2946 short nEsc = 0;
2947 sal_uInt8 nEscProp = 100;
2948 sal_uInt8 nProp = 100;
2950 m_pHighLowFT->Disable();
2951 m_pHighLowMF->Disable();
2952 m_pFontSizeFT->Disable();
2953 m_pFontSizeMF->Disable();
2955 SvxFont& rFont = GetPreviewFont();
2956 SvxFont& rCJKFont = GetPreviewCJKFont();
2957 SvxFont& rCTLFont = GetPreviewCTLFont();
2958 sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_ESCAPEMENT );
2960 if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT )
2962 const SvxEscapementItem& rItem = (SvxEscapementItem&)rSet.Get( nWhich );
2963 nEsc = rItem.GetEsc();
2964 nEscProp = rItem.GetProp();
2966 if ( nEsc != 0 )
2968 m_pHighLowFT->Enable();
2969 m_pHighLowMF->Enable();
2970 m_pFontSizeFT->Enable();
2971 m_pFontSizeMF->Enable();
2973 short nFac;
2974 bool bAutomatic(false);
2976 if ( nEsc > 0 )
2978 nFac = 1;
2979 m_pHighPosBtn->Check( true );
2980 if ( nEsc == DFLT_ESC_AUTO_SUPER )
2982 nEsc = DFLT_ESC_SUPER;
2983 bAutomatic = true;
2986 else
2988 nFac = -1;
2989 m_pLowPosBtn->Check( true );
2990 if ( nEsc == DFLT_ESC_AUTO_SUB )
2992 nEsc = DFLT_ESC_SUB;
2993 bAutomatic = true;
2996 if (!m_pHighLowRB->IsEnabled())
2998 m_pHighLowRB->Enable();
3000 m_pHighLowRB->Check(bAutomatic);
3002 if ( m_pHighLowRB->IsChecked() )
3004 m_pHighLowFT->Disable();
3005 m_pHighLowMF->Disable();
3007 m_pHighLowMF->SetValue( m_pHighLowMF->Normalize( nFac * nEsc ) );
3009 else
3011 m_pNormalPosBtn->Check( true );
3012 m_pHighLowRB->Check( true );
3013 PositionHdl_Impl( NULL );
3015 //the height has to be set after the handler is called to keep the value also if the escapement is zero
3016 m_pFontSizeMF->SetValue( m_pFontSizeMF->Normalize( nEscProp ) );
3018 else
3020 m_pHighPosBtn->Check( false );
3021 m_pNormalPosBtn->Check( false );
3022 m_pLowPosBtn->Check( false );
3025 // set BspFont
3026 SetPrevFontEscapement( nProp, nEscProp, nEsc );
3028 // Kerning
3029 nWhich = GetWhich( SID_ATTR_CHAR_KERNING );
3031 if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT )
3033 const SvxKerningItem& rItem = (SvxKerningItem&)rSet.Get( nWhich );
3034 SfxMapUnit eUnit = rSet.GetPool()->GetMetric( nWhich );
3035 MapUnit eOrgUnit = (MapUnit)eUnit;
3036 MapUnit ePntUnit( MAP_POINT );
3037 long nBig = static_cast<long>(m_pKerningMF->Normalize( static_cast<long>(rItem.GetValue()) ));
3038 long nKerning = LogicToLogic( nBig, eOrgUnit, ePntUnit );
3040 // set Kerning at the Font, convert into Twips before
3041 long nKern = LogicToLogic( rItem.GetValue(), (MapUnit)eUnit, MAP_TWIP );
3042 rFont.SetFixKerning( (short)nKern );
3043 rCJKFont.SetFixKerning( (short)nKern );
3044 rCTLFont.SetFixKerning( (short)nKern );
3046 if ( nKerning > 0 )
3048 m_pKerningLB->SelectEntryPos( LW_EXPANDED );
3050 else if ( nKerning < 0 )
3052 m_pKerningLB->SelectEntryPos( LW_CONDENSED );
3053 nKerning = -nKerning;
3055 else
3057 nKerning = 0;
3058 m_pKerningLB->SelectEntryPos( LW_NORMAL );
3060 //enable/disable and set min/max of the Edit
3061 KerningSelectHdl_Impl(m_pKerningLB);
3062 //the attribute value must be displayed also if it's above the maximum allowed value
3063 long nVal = static_cast<long>(m_pKerningMF->GetMax());
3064 if(nVal < nKerning)
3065 m_pKerningMF->SetMax( nKerning );
3066 m_pKerningMF->SetValue( nKerning );
3068 else
3069 m_pKerningMF->SetText( OUString() );
3071 // Pair kerning
3072 nWhich = GetWhich( SID_ATTR_CHAR_AUTOKERN );
3074 if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT )
3076 const SvxAutoKernItem& rItem = (SvxAutoKernItem&)rSet.Get( nWhich );
3077 m_pPairKerningBtn->Check( rItem.GetValue() );
3079 else
3080 m_pPairKerningBtn->Check( false );
3082 // Scale Width
3083 nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
3084 if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT )
3086 const SvxCharScaleWidthItem& rItem = ( SvxCharScaleWidthItem& ) rSet.Get( nWhich );
3087 m_nScaleWidthInitialVal = rItem.GetValue();
3088 m_pScaleWidthMF->SetValue( m_nScaleWidthInitialVal );
3090 else
3091 m_pScaleWidthMF->SetValue( 100 );
3093 nWhich = GetWhich( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE );
3094 if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT )
3095 m_nScaleWidthItemSetVal = ((SfxUInt16Item&) rSet.Get( nWhich )).GetValue();
3097 // Rotation
3098 nWhich = GetWhich( SID_ATTR_CHAR_ROTATED );
3099 SfxItemState eState = rSet.GetItemState( nWhich );
3100 if( SFX_ITEM_UNKNOWN == eState )
3102 m_pRotationContainer->Hide();
3103 m_pScalingAndRotationFT->Hide();
3104 m_pScalingFT->Show();
3106 else
3108 m_pRotationContainer->Show();
3109 m_pScalingAndRotationFT->Show();
3110 m_pScalingFT->Hide();
3112 Link aOldLink( m_pFitToLineCB->GetClickHdl() );
3113 m_pFitToLineCB->SetClickHdl( Link() );
3114 if( eState >= SFX_ITEM_DEFAULT )
3116 const SvxCharRotateItem& rItem =
3117 (SvxCharRotateItem&) rSet.Get( nWhich );
3118 if (rItem.IsBottomToTop())
3119 m_p90degRB->Check( true );
3120 else if (rItem.IsTopToBotton())
3121 m_p270degRB->Check( true );
3122 else
3124 DBG_ASSERT( 0 == rItem.GetValue(), "incorrect value" );
3125 m_p0degRB->Check( true );
3127 m_pFitToLineCB->Check( rItem.IsFitToLine() );
3129 else
3131 if( eState == SFX_ITEM_DONTCARE )
3133 m_p0degRB->Check( false );
3134 m_p90degRB->Check( false );
3135 m_p270degRB->Check( false );
3137 else
3138 m_p0degRB->Check( true );
3140 m_pFitToLineCB->Check( false );
3142 m_pFitToLineCB->SetClickHdl( aOldLink );
3143 m_pFitToLineCB->Enable( !m_p0degRB->IsChecked() );
3145 // is this value set?
3146 if( SFX_ITEM_UNKNOWN == rSet.GetItemState( GetWhich(
3147 SID_ATTR_CHAR_WIDTH_FIT_TO_LINE ) ))
3148 m_pFitToLineCB->Hide();
3151 m_pHighPosBtn->SaveValue();
3152 m_pNormalPosBtn->SaveValue();
3153 m_pLowPosBtn->SaveValue();
3154 m_p0degRB->SaveValue();
3155 m_p90degRB->SaveValue();
3156 m_p270degRB->SaveValue();
3157 m_pFitToLineCB->SaveValue();
3158 m_pScaleWidthMF->SaveValue();
3159 m_pKerningLB->SaveValue();
3160 m_pKerningMF->SaveValue();
3161 m_pPairKerningBtn->SaveValue();
3166 bool SvxCharPositionPage::FillItemSet( SfxItemSet& rSet )
3168 // Position (high, normal or low)
3169 const SfxItemSet& rOldSet = GetItemSet();
3170 bool bModified = false, bChanged = true;
3171 sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_ESCAPEMENT );
3172 const SfxPoolItem* pOld = GetOldItem( rSet, SID_ATTR_CHAR_ESCAPEMENT );
3173 const bool bHigh = m_pHighPosBtn->IsChecked();
3174 short nEsc;
3175 sal_uInt8 nEscProp;
3177 if ( bHigh || m_pLowPosBtn->IsChecked() )
3179 if ( m_pHighLowRB->IsChecked() )
3180 nEsc = bHigh ? DFLT_ESC_AUTO_SUPER : DFLT_ESC_AUTO_SUB;
3181 else
3183 nEsc = (short)m_pHighLowMF->Denormalize( m_pHighLowMF->GetValue() );
3184 nEsc *= (bHigh ? 1 : -1);
3186 nEscProp = (sal_uInt8)m_pFontSizeMF->Denormalize( m_pFontSizeMF->GetValue() );
3188 else
3190 nEsc = 0;
3191 nEscProp = 100;
3194 if ( pOld )
3196 const SvxEscapementItem& rItem = *( (const SvxEscapementItem*)pOld );
3197 if ( rItem.GetEsc() == nEsc && rItem.GetProp() == nEscProp )
3198 bChanged = false;
3201 if ( !bChanged && !m_pHighPosBtn->GetSavedValue() &&
3202 !m_pNormalPosBtn->GetSavedValue() && !m_pLowPosBtn->GetSavedValue() )
3203 bChanged = true;
3205 if ( bChanged &&
3206 ( m_pHighPosBtn->IsChecked() || m_pNormalPosBtn->IsChecked() || m_pLowPosBtn->IsChecked() ) )
3208 rSet.Put( SvxEscapementItem( nEsc, nEscProp, nWhich ) );
3209 bModified = true;
3211 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
3212 CLEARTITEM;
3214 bChanged = true;
3216 // Kerning
3217 nWhich = GetWhich( SID_ATTR_CHAR_KERNING );
3218 pOld = GetOldItem( rSet, SID_ATTR_CHAR_KERNING );
3219 sal_Int32 nPos = m_pKerningLB->GetSelectEntryPos();
3220 short nKerning = 0;
3221 SfxMapUnit eUnit = rSet.GetPool()->GetMetric( nWhich );
3223 if ( nPos == LW_EXPANDED || nPos == LW_CONDENSED )
3225 long nTmp = static_cast<long>(m_pKerningMF->GetValue());
3226 long nVal = LogicToLogic( nTmp, MAP_POINT, (MapUnit)eUnit );
3227 nKerning = (short)m_pKerningMF->Denormalize( nVal );
3229 if ( nPos == LW_CONDENSED )
3230 nKerning *= - 1;
3233 if ( pOld )
3235 const SvxKerningItem& rItem = *( (const SvxKerningItem*)pOld );
3236 if ( rItem.GetValue() == nKerning )
3237 bChanged = false;
3240 if ( !bChanged &&
3241 ( m_pKerningLB->GetSavedValue() == LISTBOX_ENTRY_NOTFOUND ||
3242 ( m_pKerningMF->GetSavedValue().isEmpty() && m_pKerningMF->IsEnabled() ) ) )
3243 bChanged = true;
3245 if ( bChanged && nPos != LISTBOX_ENTRY_NOTFOUND )
3247 rSet.Put( SvxKerningItem( nKerning, nWhich ) );
3248 bModified = true;
3250 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
3251 CLEARTITEM;
3253 bChanged = true;
3255 // Pair-Kerning
3256 nWhich = GetWhich( SID_ATTR_CHAR_AUTOKERN );
3258 if ( m_pPairKerningBtn->IsValueChangedFromSaved() )
3260 rSet.Put( SvxAutoKernItem( m_pPairKerningBtn->IsChecked(), nWhich ) );
3261 bModified = true;
3263 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
3264 CLEARTITEM;
3266 // Scale Width
3267 nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
3268 if ( m_pScaleWidthMF->IsValueChangedFromSaved() )
3270 rSet.Put( SvxCharScaleWidthItem( (sal_uInt16)m_pScaleWidthMF->GetValue(), nWhich ) );
3271 bModified = true;
3273 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
3274 CLEARTITEM;
3276 // Rotation
3277 nWhich = GetWhich( SID_ATTR_CHAR_ROTATED );
3278 if ( m_p0degRB->IsValueChangedFromSaved() ||
3279 m_p90degRB->IsValueChangedFromSaved() ||
3280 m_p270degRB->IsValueChangedFromSaved() ||
3281 m_pFitToLineCB->IsValueChangedFromSaved() )
3283 SvxCharRotateItem aItem( 0, m_pFitToLineCB->IsChecked(), nWhich );
3284 if (m_p90degRB->IsChecked())
3285 aItem.SetBottomToTop();
3286 else if (m_p270degRB->IsChecked())
3287 aItem.SetTopToBotton();
3288 rSet.Put( aItem );
3289 bModified = true;
3291 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
3292 CLEARTITEM;
3294 return bModified;
3299 void SvxCharPositionPage::FillUserData()
3301 const OUString cTok( ";" );
3303 OUString sUser = OUString::number( m_nSuperEsc ) + cTok +
3304 OUString::number( m_nSubEsc ) + cTok +
3305 OUString::number( m_nSuperProp ) + cTok +
3306 OUString::number( m_nSubProp );
3307 SetUserData( sUser );
3311 void SvxCharPositionPage::SetPreviewBackgroundToCharacter()
3313 m_bPreviewBackgroundToCharacter = true;
3316 void SvxCharPositionPage::PageCreated(const SfxAllItemSet& aSet)
3318 SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,false);
3319 if (pFlagItem)
3321 sal_uInt32 nFlags=pFlagItem->GetValue();
3322 if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
3323 SetPreviewBackgroundToCharacter();
3326 // class SvxCharTwoLinesPage ------------------------------------------------
3328 SvxCharTwoLinesPage::SvxCharTwoLinesPage(Window* pParent, const SfxItemSet& rInSet)
3329 : SvxCharBasePage(pParent, "TwoLinesPage", "cui/ui/twolinespage.ui", rInSet)
3330 , m_nStartBracketPosition( 0 )
3331 , m_nEndBracketPosition( 0 )
3333 get(m_pTwoLinesBtn, "twolines");
3334 get(m_pEnclosingFrame, "enclosing");
3335 get(m_pStartBracketLB, "startbracket");
3336 get(m_pEndBracketLB, "endbracket");
3338 get(m_pPreviewWin, "preview");
3340 Initialize();
3343 SvxCharTwoLinesPage::~SvxCharTwoLinesPage()
3349 void SvxCharTwoLinesPage::Initialize()
3351 m_pTwoLinesBtn->Check( false );
3352 TwoLinesHdl_Impl( NULL );
3354 m_pTwoLinesBtn->SetClickHdl( LINK( this, SvxCharTwoLinesPage, TwoLinesHdl_Impl ) );
3356 Link aLink = LINK( this, SvxCharTwoLinesPage, CharacterMapHdl_Impl );
3357 m_pStartBracketLB->SetSelectHdl( aLink );
3358 m_pEndBracketLB->SetSelectHdl( aLink );
3360 SvxFont& rFont = GetPreviewFont();
3361 SvxFont& rCJKFont = GetPreviewCJKFont();
3362 SvxFont& rCTLFont = GetPreviewCTLFont();
3363 rFont.SetSize( Size( 0, 220 ) );
3364 rCJKFont.SetSize( Size( 0, 220 ) );
3365 rCTLFont.SetSize( Size( 0, 220 ) );
3370 void SvxCharTwoLinesPage::SelectCharacter( ListBox* pBox )
3372 bool bStart = pBox == m_pStartBracketLB;
3373 SvxCharacterMap* aDlg = new SvxCharacterMap( this );
3374 aDlg->DisableFontSelection();
3376 if ( aDlg->Execute() == RET_OK )
3378 sal_Unicode cChar = (sal_Unicode) aDlg->GetChar();
3379 SetBracket( cChar, bStart );
3381 else
3383 pBox->SelectEntryPos( bStart ? m_nStartBracketPosition : m_nEndBracketPosition );
3385 delete aDlg;
3390 void SvxCharTwoLinesPage::SetBracket( sal_Unicode cBracket, bool bStart )
3392 sal_Int32 nEntryPos = 0;
3393 ListBox* pBox = bStart ? m_pStartBracketLB : m_pEndBracketLB;
3394 if ( 0 == cBracket )
3395 pBox->SelectEntryPos(0);
3396 else
3398 bool bFound = false;
3399 for ( sal_Int32 i = 1; i < pBox->GetEntryCount(); ++i )
3401 if ( (sal_uLong)pBox->GetEntryData(i) != CHRDLG_ENCLOSE_SPECIAL_CHAR )
3403 const sal_Unicode cChar = pBox->GetEntry(i)[0];
3404 if ( cChar == cBracket )
3406 pBox->SelectEntryPos(i);
3407 nEntryPos = i;
3408 bFound = true;
3409 break;
3414 if ( !bFound )
3416 nEntryPos = pBox->InsertEntry( OUString(cBracket) );
3417 pBox->SelectEntryPos( nEntryPos );
3420 if( bStart )
3421 m_nStartBracketPosition = nEntryPos;
3422 else
3423 m_nEndBracketPosition = nEntryPos;
3428 IMPL_LINK_NOARG(SvxCharTwoLinesPage, TwoLinesHdl_Impl)
3430 bool bChecked = m_pTwoLinesBtn->IsChecked();
3431 m_pEnclosingFrame->Enable( bChecked );
3433 UpdatePreview_Impl();
3434 return 0;
3439 IMPL_LINK( SvxCharTwoLinesPage, CharacterMapHdl_Impl, ListBox*, pBox )
3441 sal_Int32 nPos = pBox->GetSelectEntryPos();
3442 if ( CHRDLG_ENCLOSE_SPECIAL_CHAR == (sal_uLong)pBox->GetEntryData( nPos ) )
3443 SelectCharacter( pBox );
3444 else
3446 bool bStart = pBox == m_pStartBracketLB;
3447 if( bStart )
3448 m_nStartBracketPosition = nPos;
3449 else
3450 m_nEndBracketPosition = nPos;
3452 UpdatePreview_Impl();
3453 return 0;
3458 void SvxCharTwoLinesPage::ActivatePage( const SfxItemSet& rSet )
3460 SvxCharBasePage::ActivatePage( rSet );
3465 int SvxCharTwoLinesPage::DeactivatePage( SfxItemSet* _pSet )
3467 if ( _pSet )
3468 FillItemSet( *_pSet );
3469 return LEAVE_PAGE;
3474 SfxTabPage* SvxCharTwoLinesPage::Create( Window* pParent, const SfxItemSet& rSet )
3476 return new SvxCharTwoLinesPage( pParent, rSet );
3481 const sal_uInt16* SvxCharTwoLinesPage::GetRanges()
3483 return pTwoLinesRanges;
3488 void SvxCharTwoLinesPage::Reset( const SfxItemSet& rSet )
3490 m_pTwoLinesBtn->Check( false );
3491 sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_TWO_LINES );
3492 SfxItemState eState = rSet.GetItemState( nWhich );
3494 if ( eState >= SFX_ITEM_DONTCARE )
3496 const SvxTwoLinesItem& rItem = (SvxTwoLinesItem&)rSet.Get( nWhich );
3497 m_pTwoLinesBtn->Check( rItem.GetValue() );
3499 if ( rItem.GetValue() )
3501 SetBracket( rItem.GetStartBracket(), true );
3502 SetBracket( rItem.GetEndBracket(), false );
3505 TwoLinesHdl_Impl( NULL );
3507 SetPrevFontWidthScale( rSet );
3512 bool SvxCharTwoLinesPage::FillItemSet( SfxItemSet& rSet )
3514 const SfxItemSet& rOldSet = GetItemSet();
3515 bool bModified = false, bChanged = true;
3516 sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_TWO_LINES );
3517 const SfxPoolItem* pOld = GetOldItem( rSet, SID_ATTR_CHAR_TWO_LINES );
3518 bool bOn = m_pTwoLinesBtn->IsChecked();
3519 sal_Unicode cStart = ( bOn && m_pStartBracketLB->GetSelectEntryPos() > 0 )
3520 ? m_pStartBracketLB->GetSelectEntry()[0] : 0;
3521 sal_Unicode cEnd = ( bOn && m_pEndBracketLB->GetSelectEntryPos() > 0 )
3522 ? m_pEndBracketLB->GetSelectEntry()[0] : 0;
3524 if ( pOld )
3526 const SvxTwoLinesItem& rItem = *( (const SvxTwoLinesItem*)pOld );
3527 if ( rItem.GetValue() == bOn &&
3528 ( !bOn || ( rItem.GetStartBracket() == cStart && rItem.GetEndBracket() == cEnd ) ) )
3529 bChanged = false;
3532 if ( bChanged )
3534 rSet.Put( SvxTwoLinesItem( bOn, cStart, cEnd, nWhich ) );
3535 bModified = true;
3537 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, false ) )
3538 CLEARTITEM;
3540 return bModified;
3543 void SvxCharTwoLinesPage::UpdatePreview_Impl()
3545 sal_Unicode cStart = m_pStartBracketLB->GetSelectEntryPos() > 0
3546 ? m_pStartBracketLB->GetSelectEntry()[0] : 0;
3547 sal_Unicode cEnd = m_pEndBracketLB->GetSelectEntryPos() > 0
3548 ? m_pEndBracketLB->GetSelectEntry()[0] : 0;
3549 m_pPreviewWin->SetBrackets(cStart, cEnd);
3550 m_pPreviewWin->SetTwoLines(m_pTwoLinesBtn->IsChecked());
3551 m_pPreviewWin->Invalidate();
3554 void SvxCharTwoLinesPage::SetPreviewBackgroundToCharacter()
3556 m_bPreviewBackgroundToCharacter = true;
3560 void SvxCharTwoLinesPage::PageCreated(const SfxAllItemSet& aSet)
3562 SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,false);
3563 if (pFlagItem)
3565 sal_uInt32 nFlags=pFlagItem->GetValue();
3566 if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
3567 SetPreviewBackgroundToCharacter();
3571 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */