1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_cui.hxx" 26 27 // include --------------------------------------------------------------- 28 #include <editeng/unolingu.hxx> 29 #include <vcl/svapp.hxx> 30 #include <unotools/pathoptions.hxx> 31 #include <svtools/ctrltool.hxx> 32 #include <svl/sfontitm.hxx> 33 #include <sfx2/printer.hxx> 34 #include <sfx2/objsh.hxx> 35 #include <sfx2/viewsh.hxx> 36 #include <sfx2/bindings.hxx> 37 #include <sfx2/viewfrm.hxx> 38 #include <vcl/msgbox.hxx> 39 #include <svx/dialmgr.hxx> 40 #include <svx/dialogs.hrc> 41 #include <svtools/unitconv.hxx> 42 43 #define _SVX_CHARDLG_CXX 44 #include <svl/languageoptions.hxx> 45 46 #include <cuires.hrc> 47 #include "chardlg.hrc" 48 49 #include <svx/xtable.hxx> // XColorList 50 #include "chardlg.hxx" 51 #include "editeng/fontitem.hxx" 52 #include <editeng/postitem.hxx> 53 #include <editeng/udlnitem.hxx> 54 #include <editeng/crsditem.hxx> 55 #include <editeng/cntritem.hxx> 56 #include <editeng/langitem.hxx> 57 #include <editeng/wghtitem.hxx> 58 #include <editeng/fhgtitem.hxx> 59 #include <editeng/shdditem.hxx> 60 #include <editeng/escpitem.hxx> 61 #include <editeng/prszitem.hxx> 62 #include <editeng/wrlmitem.hxx> 63 #include <editeng/cmapitem.hxx> 64 #include <editeng/kernitem.hxx> 65 #include <editeng/blnkitem.hxx> 66 #include "editeng/flstitem.hxx" 67 #include <editeng/akrnitem.hxx> 68 #include <editeng/brshitem.hxx> 69 #include <editeng/colritem.hxx> 70 #include "svx/drawitem.hxx" 71 #include "svx/dlgutil.hxx" 72 #include <dialmgr.hxx> 73 #include "svx/htmlmode.hxx" 74 #include "cuicharmap.hxx" 75 #include "chardlg.h" 76 #include <editeng/emphitem.hxx> 77 #include <editeng/charreliefitem.hxx> 78 #include <editeng/twolinesitem.hxx> 79 #include <editeng/charhiddenitem.hxx> 80 #include <svl/stritem.hxx> 81 #include <editeng/charscaleitem.hxx> 82 #include <editeng/charrotateitem.hxx> 83 #include <svx/svxdlg.hxx> //CHINA001 84 #include <cuires.hrc> //CHINA001 85 #include <svl/intitem.hxx> //CHINA001 86 #include <sfx2/request.hxx> //CHINA001 87 #include "svx/flagsdef.hxx" //CHINA001 88 89 using namespace ::com::sun::star; 90 91 // define ---------------------------------------------------------------- 92 93 #define ISITEMSET rSet.GetItemState(nWhich)>=SFX_ITEM_DEFAULT 94 95 #define CLEARTITEM rSet.InvalidateItem(nWhich) 96 97 #define LW_NORMAL 0 98 #define LW_GESPERRT 1 99 #define LW_SCHMAL 2 100 101 // static ---------------------------------------------------------------- 102 103 static sal_uInt16 pNameRanges[] = 104 { 105 SID_ATTR_CHAR_FONT, 106 SID_ATTR_CHAR_WEIGHT, 107 SID_ATTR_CHAR_FONTHEIGHT, 108 SID_ATTR_CHAR_FONTHEIGHT, 109 SID_ATTR_CHAR_COLOR, 110 SID_ATTR_CHAR_COLOR, 111 SID_ATTR_CHAR_LANGUAGE, 112 SID_ATTR_CHAR_LANGUAGE, 113 SID_ATTR_CHAR_CJK_FONT, 114 SID_ATTR_CHAR_CJK_WEIGHT, 115 SID_ATTR_CHAR_CTL_FONT, 116 SID_ATTR_CHAR_CTL_WEIGHT, 117 0 118 }; 119 120 static sal_uInt16 pEffectsRanges[] = 121 { 122 SID_ATTR_CHAR_SHADOWED, 123 SID_ATTR_CHAR_UNDERLINE, 124 SID_ATTR_CHAR_COLOR, 125 SID_ATTR_CHAR_COLOR, 126 SID_ATTR_CHAR_CASEMAP, 127 SID_ATTR_CHAR_CASEMAP, 128 SID_ATTR_FLASH, 129 SID_ATTR_FLASH, 130 SID_ATTR_CHAR_EMPHASISMARK, 131 SID_ATTR_CHAR_EMPHASISMARK, 132 SID_ATTR_CHAR_RELIEF, 133 SID_ATTR_CHAR_RELIEF, 134 SID_ATTR_CHAR_HIDDEN, 135 SID_ATTR_CHAR_HIDDEN, 136 SID_ATTR_CHAR_OVERLINE, 137 SID_ATTR_CHAR_OVERLINE, 138 0 139 }; 140 141 static sal_uInt16 pPositionRanges[] = 142 { 143 SID_ATTR_CHAR_KERNING, 144 SID_ATTR_CHAR_KERNING, 145 SID_ATTR_CHAR_ESCAPEMENT, 146 SID_ATTR_CHAR_ESCAPEMENT, 147 SID_ATTR_CHAR_AUTOKERN, 148 SID_ATTR_CHAR_AUTOKERN, 149 SID_ATTR_CHAR_ROTATED, 150 SID_ATTR_CHAR_SCALEWIDTH, 151 SID_ATTR_CHAR_WIDTH_FIT_TO_LINE, 152 SID_ATTR_CHAR_WIDTH_FIT_TO_LINE, 153 0 154 }; 155 156 static sal_uInt16 pTwoLinesRanges[] = 157 { 158 SID_ATTR_CHAR_TWO_LINES, 159 SID_ATTR_CHAR_TWO_LINES, 160 0 161 }; 162 163 // C-Funktion ------------------------------------------------------------ 164 165 inline sal_Bool StateToAttr( TriState aState ) 166 { 167 return ( STATE_CHECK == aState ); 168 } 169 170 // class SvxCharBasePage ------------------------------------------------- 171 172 inline SvxFont& SvxCharBasePage::GetPreviewFont() 173 { 174 return m_aPreviewWin.GetFont(); 175 } 176 177 // ----------------------------------------------------------------------- 178 179 inline SvxFont& SvxCharBasePage::GetPreviewCJKFont() 180 { 181 return m_aPreviewWin.GetCJKFont(); 182 } 183 // ----------------------------------------------------------------------- 184 185 inline SvxFont& SvxCharBasePage::GetPreviewCTLFont() 186 { 187 return m_aPreviewWin.GetCTLFont(); 188 } 189 190 // ----------------------------------------------------------------------- 191 192 SvxCharBasePage::SvxCharBasePage( Window* pParent, const ResId& rResId, const SfxItemSet& rItemset, 193 sal_uInt16 nResIdPrewievWin, sal_uInt16 nResIdFontTypeFT ): 194 SfxTabPage( pParent, rResId, rItemset ), 195 m_aPreviewWin( this, ResId( nResIdPrewievWin, *rResId.GetResMgr() ) ), 196 m_aFontTypeFT( this, ResId( nResIdFontTypeFT, *rResId.GetResMgr() ) ), 197 m_bPreviewBackgroundToCharacter( sal_False ) 198 { 199 } 200 201 // ----------------------------------------------------------------------- 202 203 SvxCharBasePage::~SvxCharBasePage() 204 { 205 } 206 207 // ----------------------------------------------------------------------- 208 209 //void SvxCharBasePage::SetPrevFontAttributes( const SfxItemSet& rSet ) 210 void SvxCharBasePage::ActivatePage( const SfxItemSet& rSet ) 211 { 212 SvxFont& rFont = GetPreviewFont(); 213 SvxFont& rCJKFont = GetPreviewCJKFont(); 214 SvxFont& rCTLFont = GetPreviewCTLFont(); 215 sal_uInt16 nWhich; 216 217 nWhich = GetWhich( SID_CHAR_DLG_PREVIEW_STRING ); 218 if( ISITEMSET ) 219 { 220 const SfxStringItem& rItem = ( SfxStringItem& ) rSet.Get( nWhich ); 221 ::rtl::OUString aString = rItem.GetValue(); 222 if( aString.getLength() != 0 ) 223 m_aPreviewWin.SetPreviewText( aString ); 224 else 225 m_aPreviewWin.SetFontNameAsPreviewText(); 226 } 227 228 // Underline 229 FontUnderline eUnderline; 230 nWhich = GetWhich( SID_ATTR_CHAR_UNDERLINE ); 231 if( ISITEMSET ) 232 { 233 const SvxUnderlineItem& rItem = ( SvxUnderlineItem& ) rSet.Get( nWhich ); 234 eUnderline = ( FontUnderline ) rItem.GetValue(); 235 m_aPreviewWin.SetTextLineColor( rItem.GetColor() ); 236 } 237 else 238 eUnderline = UNDERLINE_NONE; 239 240 rFont.SetUnderline( eUnderline ); 241 rCJKFont.SetUnderline( eUnderline ); 242 rCTLFont.SetUnderline( eUnderline ); 243 244 // Overline 245 FontUnderline eOverline; 246 nWhich = GetWhich( SID_ATTR_CHAR_OVERLINE ); 247 if( ISITEMSET ) 248 { 249 const SvxOverlineItem& rItem = ( SvxOverlineItem& ) rSet.Get( nWhich ); 250 eOverline = ( FontUnderline ) rItem.GetValue(); 251 m_aPreviewWin.SetOverlineColor( rItem.GetColor() ); 252 } 253 else 254 eOverline = UNDERLINE_NONE; 255 256 rFont.SetOverline( eOverline ); 257 rCJKFont.SetOverline( eOverline ); 258 rCTLFont.SetOverline( eOverline ); 259 260 // Strikeout 261 FontStrikeout eStrikeout; 262 nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT ); 263 if( ISITEMSET ) 264 { 265 const SvxCrossedOutItem& rItem = ( SvxCrossedOutItem& ) rSet.Get( nWhich ); 266 eStrikeout = ( FontStrikeout ) rItem.GetValue(); 267 } 268 else 269 eStrikeout = STRIKEOUT_NONE; 270 271 rFont.SetStrikeout( eStrikeout ); 272 rCJKFont.SetStrikeout( eStrikeout ); 273 rCTLFont.SetStrikeout( eStrikeout ); 274 275 // WordLineMode 276 nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE ); 277 if( ISITEMSET ) 278 { 279 const SvxWordLineModeItem& rItem = ( SvxWordLineModeItem& ) rSet.Get( nWhich ); 280 rFont.SetWordLineMode( rItem.GetValue() ); 281 rCJKFont.SetWordLineMode( rItem.GetValue() ); 282 rCTLFont.SetWordLineMode( rItem.GetValue() ); 283 } 284 285 // Emphasis 286 nWhich = GetWhich( SID_ATTR_CHAR_EMPHASISMARK ); 287 if( ISITEMSET ) 288 { 289 const SvxEmphasisMarkItem& rItem = ( SvxEmphasisMarkItem& ) rSet.Get( nWhich ); 290 FontEmphasisMark eMark = rItem.GetEmphasisMark(); 291 rFont.SetEmphasisMark( eMark ); 292 rCJKFont.SetEmphasisMark( eMark ); 293 rCTLFont.SetEmphasisMark( eMark ); 294 } 295 296 // Relief 297 nWhich = GetWhich( SID_ATTR_CHAR_RELIEF ); 298 if( ISITEMSET ) 299 { 300 const SvxCharReliefItem& rItem = ( SvxCharReliefItem& ) rSet.Get( nWhich ); 301 FontRelief eFontRelief = ( FontRelief ) rItem.GetValue(); 302 rFont.SetRelief( eFontRelief ); 303 rCJKFont.SetRelief( eFontRelief ); 304 rCTLFont.SetRelief( eFontRelief ); 305 } 306 307 // Effects 308 nWhich = GetWhich( SID_ATTR_CHAR_CASEMAP ); 309 if( ISITEMSET ) 310 { 311 const SvxCaseMapItem& rItem = ( SvxCaseMapItem& ) rSet.Get( nWhich ); 312 SvxCaseMap eCaseMap = ( SvxCaseMap ) rItem.GetValue(); 313 rFont.SetCaseMap( eCaseMap ); 314 rCJKFont.SetCaseMap( eCaseMap ); 315 // #i78474# small caps do not exist in CTL fonts 316 rCTLFont.SetCaseMap( eCaseMap == SVX_CASEMAP_KAPITAELCHEN ? SVX_CASEMAP_NOT_MAPPED : eCaseMap ); 317 } 318 319 // Outline 320 nWhich = GetWhich( SID_ATTR_CHAR_CONTOUR ); 321 if( ISITEMSET ) 322 { 323 const SvxContourItem& rItem = ( SvxContourItem& ) rSet.Get( nWhich ); 324 sal_Bool bOutline = rItem.GetValue(); 325 rFont.SetOutline( bOutline ); 326 rCJKFont.SetOutline( bOutline ); 327 rCTLFont.SetOutline( bOutline ); 328 } 329 330 // Shadow 331 nWhich = GetWhich( SID_ATTR_CHAR_SHADOWED ); 332 if( ISITEMSET ) 333 { 334 const SvxShadowedItem& rItem = ( SvxShadowedItem& ) rSet.Get( nWhich ); 335 sal_Bool bShadow = rItem.GetValue(); 336 rFont.SetShadow( bShadow ); 337 rCJKFont.SetShadow( bShadow ); 338 rCTLFont.SetShadow( bShadow ); 339 } 340 341 // Background 342 sal_Bool bTransparent; 343 nWhich = GetWhich( m_bPreviewBackgroundToCharacter ? SID_ATTR_BRUSH : SID_ATTR_BRUSH_CHAR ); 344 if( ISITEMSET ) 345 { 346 const SvxBrushItem& rBrush = ( SvxBrushItem& ) rSet.Get( nWhich ); 347 const Color& rColor = rBrush.GetColor(); 348 bTransparent = rColor.GetTransparency() > 0; 349 rFont.SetFillColor( rColor ); 350 rCJKFont.SetFillColor( rColor ); 351 rCTLFont.SetFillColor( rColor ); 352 } 353 else 354 bTransparent = sal_True; 355 356 rFont.SetTransparent( bTransparent ); 357 rCJKFont.SetTransparent( bTransparent ); 358 rCTLFont.SetTransparent( bTransparent ); 359 360 Color aBackCol( COL_TRANSPARENT ); 361 if( !m_bPreviewBackgroundToCharacter ) 362 { 363 nWhich = GetWhich( SID_ATTR_BRUSH ); 364 if( ISITEMSET ) 365 { 366 const SvxBrushItem& rBrush = ( SvxBrushItem& ) rSet.Get( nWhich ); 367 if( GPOS_NONE == rBrush.GetGraphicPos() ) 368 aBackCol = rBrush.GetColor(); 369 } 370 } 371 m_aPreviewWin.SetBackColor( aBackCol ); 372 373 // Font 374 SetPrevFont( rSet, SID_ATTR_CHAR_FONT, rFont ); 375 SetPrevFont( rSet, SID_ATTR_CHAR_CJK_FONT, rCJKFont ); 376 SetPrevFont( rSet, SID_ATTR_CHAR_CTL_FONT, rCTLFont ); 377 378 // Style 379 SetPrevFontStyle( rSet, SID_ATTR_CHAR_POSTURE, SID_ATTR_CHAR_WEIGHT, rFont ); 380 SetPrevFontStyle( rSet, SID_ATTR_CHAR_CJK_POSTURE, SID_ATTR_CHAR_CJK_WEIGHT, rCJKFont ); 381 SetPrevFontStyle( rSet, SID_ATTR_CHAR_CTL_POSTURE, SID_ATTR_CHAR_CTL_WEIGHT, rCTLFont ); 382 383 // Size 384 SetPrevFontSize( rSet, SID_ATTR_CHAR_FONTHEIGHT, rFont ); 385 SetPrevFontSize( rSet, SID_ATTR_CHAR_CJK_FONTHEIGHT, rCJKFont ); 386 SetPrevFontSize( rSet, SID_ATTR_CHAR_CTL_FONTHEIGHT, rCTLFont ); 387 388 // Color 389 nWhich = GetWhich( SID_ATTR_CHAR_COLOR ); 390 if( ISITEMSET ) 391 { 392 const SvxColorItem& rItem = ( SvxColorItem& ) rSet.Get( nWhich ); 393 Color aCol( rItem.GetValue() ); 394 rFont.SetColor( aCol ); 395 rCJKFont.SetColor( aCol ); 396 rCTLFont.SetColor( aCol ); 397 398 m_aPreviewWin.AutoCorrectFontColor(); // handle color COL_AUTO 399 } 400 401 // Kerning 402 nWhich = GetWhich( SID_ATTR_CHAR_KERNING ); 403 if( ISITEMSET ) 404 { 405 const SvxKerningItem& rItem = ( SvxKerningItem& ) rSet.Get( nWhich ); 406 short nKern = ( short ) 407 LogicToLogic( rItem.GetValue(), ( MapUnit ) rSet.GetPool()->GetMetric( nWhich ), MAP_TWIP ); 408 rFont.SetFixKerning( nKern ); 409 rCJKFont.SetFixKerning( nKern ); 410 rCTLFont.SetFixKerning( nKern ); 411 } 412 413 // Escapement 414 nWhich = GetWhich( SID_ATTR_CHAR_ESCAPEMENT ); 415 const sal_uInt8 nProp = 100; 416 short nEsc; 417 sal_uInt8 nEscProp; 418 if( ISITEMSET ) 419 { 420 const SvxEscapementItem& rItem = ( SvxEscapementItem& ) rSet.Get( nWhich ); 421 nEsc = rItem.GetEsc(); 422 nEscProp = rItem.GetProp(); 423 424 if( nEsc == DFLT_ESC_AUTO_SUPER ) 425 nEsc = DFLT_ESC_SUPER; 426 else if( nEsc == DFLT_ESC_AUTO_SUB ) 427 nEsc = DFLT_ESC_SUB; 428 } 429 else 430 { 431 nEsc = 0; 432 nEscProp = 100; 433 } 434 435 SetPrevFontEscapement( nProp, nEscProp, nEsc ); 436 437 // Font width scale 438 SetPrevFontWidthScale( rSet ); 439 440 m_aPreviewWin.Invalidate(); 441 } 442 443 // ----------------------------------------------------------------------- 444 445 void SvxCharBasePage::SetPrevFontSize( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont ) 446 { 447 sal_uInt16 nWhich = GetWhich( nSlot ); 448 long nH; 449 if( rSet.GetItemState( nWhich ) >= SFX_ITEM_SET ) 450 { 451 nH = LogicToLogic( ( ( SvxFontHeightItem& ) rSet.Get( nWhich ) ).GetHeight(), 452 ( MapUnit ) rSet.GetPool()->GetMetric( nWhich ), 453 MAP_TWIP ); 454 } 455 else 456 nH = 240; // as default 12pt 457 458 rFont.SetSize( Size( 0, nH ) ); 459 } 460 461 // ----------------------------------------------------------------------- 462 463 void SvxCharBasePage::SetPrevFont( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont ) 464 { 465 sal_uInt16 nWhich = GetWhich( nSlot ); 466 if( ISITEMSET ) 467 { 468 const SvxFontItem& rFontItem = ( SvxFontItem& ) rSet.Get( nWhich ); 469 rFont.SetFamily( rFontItem.GetFamily() ); 470 rFont.SetName( rFontItem.GetFamilyName() ); 471 rFont.SetPitch( rFontItem.GetPitch() ); 472 rFont.SetCharSet( rFontItem.GetCharSet() ); 473 rFont.SetStyleName( rFontItem.GetStyleName() ); 474 } 475 } 476 477 // ----------------------------------------------------------------------- 478 479 void SvxCharBasePage::SetPrevFontStyle( const SfxItemSet& rSet, sal_uInt16 nPosture, sal_uInt16 nWeight, SvxFont& rFont ) 480 { 481 sal_uInt16 nWhich = GetWhich( nPosture ); 482 if( ISITEMSET ) 483 { 484 const SvxPostureItem& rItem = ( SvxPostureItem& ) rSet.Get( nWhich ); 485 rFont.SetItalic( ( FontItalic ) rItem.GetValue() != ITALIC_NONE ? ITALIC_NORMAL : ITALIC_NONE ); 486 } 487 488 nWhich = GetWhich( nWeight ); 489 if( ISITEMSET ) 490 { 491 SvxWeightItem& rItem = ( SvxWeightItem& ) rSet.Get( nWhich ); 492 rFont.SetWeight( ( FontWeight ) rItem.GetValue() != WEIGHT_NORMAL ? WEIGHT_BOLD : WEIGHT_NORMAL ); 493 } 494 } 495 496 // ----------------------------------------------------------------------- 497 498 void SvxCharBasePage::SetPrevFontWidthScale( const SfxItemSet& rSet ) 499 { 500 sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH ); 501 if( ISITEMSET ) 502 { 503 const SvxCharScaleWidthItem& rItem = ( SvxCharScaleWidthItem& ) rSet.Get( nWhich ); 504 505 m_aPreviewWin.SetFontWidthScale( rItem.GetValue() ); 506 } 507 } 508 509 // ----------------------------------------------------------------------- 510 namespace 511 { 512 // ----------------------------------------------------------------------- 513 void setPrevFontEscapement(SvxFont& _rFont,sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc ) 514 { 515 _rFont.SetPropr( nProp ); 516 _rFont.SetProprRel( nEscProp ); 517 _rFont.SetEscapement( nEsc ); 518 } 519 // ----------------------------------------------------------------------- 520 // ----------------------------------------------------------------------- 521 } 522 // ----------------------------------------------------------------------- 523 524 void SvxCharBasePage::SetPrevFontEscapement( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc ) 525 { 526 setPrevFontEscapement(GetPreviewFont(),nProp,nEscProp,nEsc); 527 setPrevFontEscapement(GetPreviewCJKFont(),nProp,nEscProp,nEsc); 528 setPrevFontEscapement(GetPreviewCTLFont(),nProp,nEscProp,nEsc); 529 m_aPreviewWin.Invalidate(); 530 } 531 532 // SvxCharNamePage_Impl -------------------------------------------------- 533 534 struct SvxCharNamePage_Impl 535 { 536 Timer m_aUpdateTimer; 537 String m_aNoStyleText; 538 String m_aTransparentText; 539 const FontList* m_pFontList; 540 sal_uInt16 m_nExtraEntryPos; 541 sal_Bool m_bMustDelete; 542 sal_Bool m_bInSearchMode; 543 544 SvxCharNamePage_Impl() : 545 546 m_pFontList ( NULL ), 547 m_nExtraEntryPos( LISTBOX_ENTRY_NOTFOUND ), 548 m_bMustDelete ( sal_False ), 549 m_bInSearchMode ( sal_False ) 550 551 { 552 m_aUpdateTimer.SetTimeout( 350 ); 553 } 554 555 ~SvxCharNamePage_Impl() 556 { 557 if ( m_bMustDelete ) 558 delete m_pFontList; 559 } 560 }; 561 562 // class SvxCharNamePage ------------------------------------------------- 563 564 SvxCharNamePage::SvxCharNamePage( Window* pParent, const SfxItemSet& rInSet ) : 565 566 SvxCharBasePage( pParent, CUI_RES( RID_SVXPAGE_CHAR_NAME ), rInSet, WIN_CHAR_PREVIEW, FT_CHAR_FONTTYPE ), 567 m_pImpl ( new SvxCharNamePage_Impl ) 568 { 569 m_pImpl->m_aNoStyleText = String( CUI_RES( STR_CHARNAME_NOSTYLE ) ); 570 m_pImpl->m_aTransparentText = String( CUI_RES( STR_CHARNAME_TRANSPARENT ) ); 571 572 SvtLanguageOptions aLanguageOptions; 573 sal_Bool bCJK = ( aLanguageOptions.IsCJKFontEnabled() || aLanguageOptions.IsCTLFontEnabled() ); 574 575 m_pWestLine = new FixedLine( this, CUI_RES( FL_WEST ) ); 576 m_pWestFontNameFT = new FixedText( this, CUI_RES( bCJK ? FT_WEST_NAME : FT_WEST_NAME_NOCJK ) ); 577 m_pWestFontNameLB = new FontNameBox( this, CUI_RES( bCJK ? LB_WEST_NAME : LB_WEST_NAME_NOCJK ) ); 578 m_pWestFontStyleFT = new FixedText( this, CUI_RES( bCJK ? FT_WEST_STYLE : FT_WEST_STYLE_NOCJK ) ); 579 m_pWestFontStyleLB = new FontStyleBox( this, CUI_RES( bCJK ? LB_WEST_STYLE : LB_WEST_STYLE_NOCJK ) ); 580 m_pWestFontSizeFT = new FixedText( this, CUI_RES( bCJK ? FT_WEST_SIZE : FT_WEST_SIZE_NOCJK ) ); 581 m_pWestFontSizeLB = new FontSizeBox( this, CUI_RES( bCJK ? LB_WEST_SIZE : LB_WEST_SIZE_NOCJK ) ); 582 583 if( !bCJK ) 584 { 585 m_pColorFL = new FixedLine( this, CUI_RES( FL_COLOR2 ) ); 586 m_pColorFT = new FixedText( this, CUI_RES( FT_COLOR2 ) ); 587 m_pColorLB = new ColorListBox( this, CUI_RES( LB_COLOR2 ) ); 588 } 589 590 m_pWestFontLanguageFT = new FixedText( this, CUI_RES( bCJK ? FT_WEST_LANG : FT_WEST_LANG_NOCJK ) ); 591 m_pWestFontLanguageLB = new SvxLanguageBox( this, CUI_RES( bCJK ? LB_WEST_LANG : LB_WEST_LANG_NOCJK ) ); 592 593 m_pEastLine = new FixedLine( this, CUI_RES( FL_EAST ) ); 594 m_pEastFontNameFT = new FixedText( this, CUI_RES( FT_EAST_NAME ) ); 595 m_pEastFontNameLB = new FontNameBox( this, CUI_RES( LB_EAST_NAME ) ); 596 m_pEastFontStyleFT = new FixedText( this, CUI_RES( FT_EAST_STYLE ) ); 597 m_pEastFontStyleLB = new FontStyleBox( this, CUI_RES( LB_EAST_STYLE ) ); 598 m_pEastFontSizeFT = new FixedText( this, CUI_RES( FT_EAST_SIZE ) ); 599 m_pEastFontSizeLB = new FontSizeBox( this, CUI_RES( LB_EAST_SIZE ) ); 600 m_pEastFontLanguageFT = new FixedText( this, CUI_RES( FT_EAST_LANG ) ); 601 m_pEastFontLanguageLB = new SvxLanguageBox( this, CUI_RES( LB_EAST_LANG ) ); 602 603 m_pCTLLine = new FixedLine( this, CUI_RES( FL_CTL ) ); 604 m_pCTLFontNameFT = new FixedText( this, CUI_RES( FT_CTL_NAME ) ); 605 m_pCTLFontNameLB = new FontNameBox( this, CUI_RES( LB_CTL_NAME ) ); 606 m_pCTLFontStyleFT = new FixedText( this, CUI_RES( FT_CTL_STYLE ) ); 607 m_pCTLFontStyleLB = new FontStyleBox( this, CUI_RES( LB_CTL_STYLE ) ); 608 m_pCTLFontSizeFT = new FixedText( this, CUI_RES( FT_CTL_SIZE ) ); 609 m_pCTLFontSizeLB = new FontSizeBox( this, CUI_RES( LB_CTL_SIZE ) ); 610 m_pCTLFontLanguageFT = new FixedText( this, CUI_RES( FT_CTL_LANG ) ); 611 m_pCTLFontLanguageLB = new SvxLanguageBox( this, CUI_RES( LB_CTL_LANG ) ); 612 613 if( bCJK ) 614 { 615 m_pColorFL = new FixedLine( this, CUI_RES( FL_COLOR2 ) ); 616 m_pColorFT = new FixedText( this, CUI_RES( FT_COLOR2 ) ); 617 m_pColorLB = new ColorListBox( this, CUI_RES( LB_COLOR2 ) ); 618 } 619 620 m_pWestLine ->Show( bCJK ); 621 m_pColorFL ->Show( bCJK ); 622 623 bCJK = aLanguageOptions.IsCJKFontEnabled(); 624 m_pEastLine ->Show( bCJK ); 625 m_pEastFontNameFT ->Show( bCJK ); 626 m_pEastFontNameLB ->Show( bCJK ); 627 m_pEastFontStyleFT ->Show( bCJK ); 628 m_pEastFontStyleLB ->Show( bCJK ); 629 m_pEastFontSizeFT ->Show( bCJK ); 630 m_pEastFontSizeLB ->Show( bCJK ); 631 m_pEastFontLanguageFT ->Show( bCJK ); 632 m_pEastFontLanguageLB ->Show( bCJK ); 633 634 sal_Bool bShowCTL = aLanguageOptions.IsCTLFontEnabled(); 635 if ( bShowCTL && !bCJK ) 636 { 637 // move CTL controls to the places of the CJK controls, if these controls aren't visible 638 m_pCTLLine ->SetPosPixel( m_pEastLine->GetPosPixel() ); 639 m_pCTLFontNameFT ->SetPosPixel( m_pEastFontNameFT->GetPosPixel() ); 640 m_pCTLFontNameLB ->SetPosPixel( m_pEastFontNameLB->GetPosPixel() ); 641 m_pCTLFontStyleFT ->SetPosPixel( m_pEastFontStyleFT->GetPosPixel() ); 642 m_pCTLFontStyleLB ->SetPosPixel( m_pEastFontStyleLB->GetPosPixel() ); 643 m_pCTLFontSizeFT ->SetPosPixel( m_pEastFontSizeFT->GetPosPixel() ); 644 m_pCTLFontSizeLB ->SetPosPixel( m_pEastFontSizeLB->GetPosPixel() ); 645 m_pCTLFontLanguageFT ->SetPosPixel( m_pEastFontLanguageFT->GetPosPixel() ); 646 m_pCTLFontLanguageLB ->SetPosPixel( m_pEastFontLanguageLB->GetPosPixel() ); 647 } 648 m_pCTLLine ->Show( bShowCTL ); 649 m_pCTLFontNameFT ->Show( bShowCTL ); 650 m_pCTLFontNameLB ->Show( bShowCTL ); 651 m_pCTLFontStyleFT ->Show( bShowCTL ); 652 m_pCTLFontStyleLB ->Show( bShowCTL ); 653 m_pCTLFontSizeFT ->Show( bShowCTL ); 654 m_pCTLFontSizeLB ->Show( bShowCTL ); 655 m_pCTLFontLanguageFT ->Show( bShowCTL ); 656 m_pCTLFontLanguageLB ->Show( bShowCTL ); 657 658 FreeResource(); 659 660 m_pWestFontLanguageLB->SetLanguageList( LANG_LIST_WESTERN, sal_True, sal_False, sal_True ); 661 m_pEastFontLanguageLB->SetLanguageList( LANG_LIST_CJK, sal_True, sal_False, sal_True ); 662 m_pCTLFontLanguageLB->SetLanguageList( LANG_LIST_CTL, sal_True, sal_False, sal_True ); 663 664 Initialize(); 665 } 666 667 // ----------------------------------------------------------------------- 668 669 SvxCharNamePage::~SvxCharNamePage() 670 { 671 delete m_pImpl; 672 673 delete m_pWestLine; 674 delete m_pWestFontNameFT; 675 delete m_pWestFontNameLB; 676 delete m_pWestFontStyleFT; 677 delete m_pWestFontStyleLB; 678 delete m_pWestFontSizeFT; 679 delete m_pWestFontSizeLB; 680 delete m_pWestFontLanguageFT; 681 delete m_pWestFontLanguageLB; 682 683 delete m_pEastLine; 684 delete m_pEastFontNameFT; 685 delete m_pEastFontNameLB; 686 delete m_pEastFontStyleFT; 687 delete m_pEastFontStyleLB; 688 delete m_pEastFontSizeFT; 689 delete m_pEastFontSizeLB; 690 delete m_pEastFontLanguageFT; 691 delete m_pEastFontLanguageLB; 692 693 delete m_pCTLLine; 694 delete m_pCTLFontNameFT; 695 delete m_pCTLFontNameLB; 696 delete m_pCTLFontStyleFT; 697 delete m_pCTLFontStyleLB; 698 delete m_pCTLFontSizeFT; 699 delete m_pCTLFontSizeLB; 700 delete m_pCTLFontLanguageFT; 701 delete m_pCTLFontLanguageLB; 702 703 delete m_pColorFL; 704 delete m_pColorFT; 705 delete m_pColorLB; 706 } 707 708 // ----------------------------------------------------------------------- 709 710 void SvxCharNamePage::Initialize() 711 { 712 // to handle the changes of the other pages 713 SetExchangeSupport(); 714 715 // fill the color box 716 SfxObjectShell* pDocSh = SfxObjectShell::Current(); 717 //DBG_ASSERT( pDocSh, "DocShell not found!" ); 718 XColorList* pColorTable = NULL; 719 FASTBOOL bKillTable = sal_False; 720 const SfxPoolItem* pItem = NULL; 721 722 if ( pDocSh ) 723 { 724 pItem = pDocSh->GetItem( SID_COLOR_TABLE ); 725 if ( pItem != NULL ) 726 pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable(); 727 } 728 729 if ( !pColorTable ) 730 { 731 pColorTable = new XColorList( SvtPathOptions().GetPalettePath() ); 732 bKillTable = sal_True; 733 } 734 735 m_pColorLB->SetUpdateMode( sal_False ); 736 737 { 738 SfxPoolItem* pDummy; 739 SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocSh ); 740 if( !pFrame || SFX_ITEM_DEFAULT > pFrame->GetBindings().QueryState( 741 SID_ATTR_AUTO_COLOR_INVALID, pDummy )) 742 m_pColorLB->InsertEntry( Color( COL_AUTO ), 743 SVX_RESSTR( RID_SVXSTR_AUTOMATIC )); 744 } 745 for ( long i = 0; i < pColorTable->Count(); i++ ) 746 { 747 XColorEntry* pEntry = pColorTable->GetColor(i); 748 m_pColorLB->InsertEntry( pEntry->GetColor(), pEntry->GetName() ); 749 } 750 751 m_pColorLB->SetUpdateMode( sal_True ); 752 753 if ( bKillTable ) 754 delete pColorTable; 755 756 m_pColorLB->SetSelectHdl( LINK( this, SvxCharNamePage, ColorBoxSelectHdl_Impl ) ); 757 758 Link aLink = LINK( this, SvxCharNamePage, FontModifyHdl_Impl ); 759 m_pWestFontNameLB->SetModifyHdl( aLink ); 760 m_pWestFontStyleLB->SetModifyHdl( aLink ); 761 m_pWestFontSizeLB->SetModifyHdl( aLink ); 762 m_pEastFontNameLB->SetModifyHdl( aLink ); 763 m_pEastFontStyleLB->SetModifyHdl( aLink ); 764 m_pEastFontSizeLB->SetModifyHdl( aLink ); 765 m_pCTLFontNameLB->SetModifyHdl( aLink ); 766 m_pCTLFontStyleLB->SetModifyHdl( aLink ); 767 m_pCTLFontSizeLB->SetModifyHdl( aLink ); 768 769 m_pImpl->m_aUpdateTimer.SetTimeoutHdl( LINK( this, SvxCharNamePage, UpdateHdl_Impl ) ); 770 771 m_pColorFL->Hide(); 772 m_pColorFT->Hide(); 773 m_pColorLB->Hide(); 774 } 775 776 // ----------------------------------------------------------------------- 777 778 const FontList* SvxCharNamePage::GetFontList() const 779 { 780 if ( !m_pImpl->m_pFontList ) 781 { 782 SfxObjectShell* pDocSh = SfxObjectShell::Current(); 783 const SfxPoolItem* pItem; 784 785 /* #110771# SvxFontListItem::GetFontList can return NULL */ 786 if ( pDocSh ) 787 { 788 pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST ); 789 if ( pItem != NULL ) 790 { 791 DBG_ASSERT(NULL != ( (SvxFontListItem*)pItem )->GetFontList(), 792 "Where is the font list?"); 793 m_pImpl->m_pFontList = static_cast<const SvxFontListItem*>(pItem )->GetFontList()->Clone(); 794 m_pImpl->m_bMustDelete = sal_True; 795 } 796 } 797 if(!m_pImpl->m_pFontList) 798 { 799 m_pImpl->m_pFontList = 800 new FontList( Application::GetDefaultDevice() ); 801 m_pImpl->m_bMustDelete = sal_True; 802 } 803 } 804 805 return m_pImpl->m_pFontList; 806 } 807 808 // ----------------------------------------------------------------------------- 809 namespace 810 { 811 FontInfo calcFontInfo( SvxFont& _rFont, 812 SvxCharNamePage* _pPage, 813 const FontNameBox* _pFontNameLB, 814 const FontStyleBox* _pFontStyleLB, 815 const FontSizeBox* _pFontSizeLB, 816 const FontList* _pFontList, 817 sal_uInt16 _nFontWhich, 818 sal_uInt16 _nFontHeightWhich) 819 { 820 Size aSize = _rFont.GetSize(); 821 aSize.Width() = 0; 822 FontInfo aFontInfo; 823 String sFontName(_pFontNameLB->GetText()); 824 sal_Bool bFontAvailable = _pFontList->IsAvailable( sFontName ); 825 if(bFontAvailable || _pFontNameLB->GetSavedValue() != sFontName) 826 aFontInfo = _pFontList->Get( sFontName, _pFontStyleLB->GetText() ); 827 else 828 { 829 //get the font from itemset 830 SfxItemState eState = _pPage->GetItemSet().GetItemState( _nFontWhich ); 831 if ( eState >= SFX_ITEM_DEFAULT ) 832 { 833 const SvxFontItem* pFontItem = (const SvxFontItem*)&( _pPage->GetItemSet().Get( _nFontWhich ) ); 834 aFontInfo.SetName(pFontItem->GetFamilyName()); 835 aFontInfo.SetStyleName(pFontItem->GetStyleName()); 836 aFontInfo.SetFamily(pFontItem->GetFamily()); 837 aFontInfo.SetPitch(pFontItem->GetPitch()); 838 aFontInfo.SetCharSet(pFontItem->GetCharSet()); 839 } 840 } 841 if ( _pFontSizeLB->IsRelative() ) 842 { 843 DBG_ASSERT( _pPage->GetItemSet().GetParent(), "No parent set" ); 844 const SvxFontHeightItem& rOldItem = (SvxFontHeightItem&)_pPage->GetItemSet().GetParent()->Get( _nFontHeightWhich ); 845 846 // alter Wert, skaliert 847 long nHeight; 848 if ( _pFontSizeLB->IsPtRelative() ) 849 nHeight = rOldItem.GetHeight() + PointToTwips( static_cast<long>(_pFontSizeLB->GetValue() / 10) ); 850 else 851 nHeight = static_cast<long>(rOldItem.GetHeight() * _pFontSizeLB->GetValue() / 100); 852 853 // Umrechnung in twips fuer das Beispiel-Window 854 aSize.Height() = 855 ItemToControl( nHeight, _pPage->GetItemSet().GetPool()->GetMetric( _nFontHeightWhich ), SFX_FUNIT_TWIP ); 856 } 857 else if ( _pFontSizeLB->GetText().Len() ) 858 aSize.Height() = PointToTwips( static_cast<long>(_pFontSizeLB->GetValue() / 10) ); 859 else 860 aSize.Height() = 200; // default 10pt 861 aFontInfo.SetSize( aSize ); 862 863 _rFont.SetFamily( aFontInfo.GetFamily() ); 864 _rFont.SetName( aFontInfo.GetName() ); 865 _rFont.SetStyleName( aFontInfo.GetStyleName() ); 866 _rFont.SetPitch( aFontInfo.GetPitch() ); 867 _rFont.SetCharSet( aFontInfo.GetCharSet() ); 868 _rFont.SetWeight( aFontInfo.GetWeight() ); 869 _rFont.SetItalic( aFontInfo.GetItalic() ); 870 _rFont.SetSize( aFontInfo.GetSize() ); 871 872 return aFontInfo; 873 } 874 } 875 876 // ----------------------------------------------------------------------- 877 878 void SvxCharNamePage::UpdatePreview_Impl() 879 { 880 SvxFont& rFont = GetPreviewFont(); 881 SvxFont& rCJKFont = GetPreviewCJKFont(); 882 SvxFont& rCTLFont = GetPreviewCTLFont(); 883 // Size 884 Size aSize = rFont.GetSize(); 885 aSize.Width() = 0; 886 Size aCJKSize = rCJKFont.GetSize(); 887 aCJKSize.Width() = 0; 888 Size aCTLSize = rCTLFont.GetSize(); 889 aCTLSize.Width() = 0; 890 // Font 891 const FontList* pFontList = GetFontList(); 892 FontInfo aFontInfo = 893 calcFontInfo(rFont,this,m_pWestFontNameLB,m_pWestFontStyleLB,m_pWestFontSizeLB,pFontList,GetWhich( SID_ATTR_CHAR_FONT ),GetWhich( SID_ATTR_CHAR_FONTHEIGHT )); 894 895 calcFontInfo(rCJKFont,this,m_pEastFontNameLB,m_pEastFontStyleLB,m_pEastFontSizeLB,pFontList,GetWhich( SID_ATTR_CHAR_CJK_FONT ),GetWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT )); 896 897 calcFontInfo(rCTLFont,this,m_pCTLFontNameLB,m_pCTLFontStyleLB,m_pCTLFontSizeLB,pFontList,GetWhich( SID_ATTR_CHAR_CTL_FONT ),GetWhich( SID_ATTR_CHAR_CTL_FONTHEIGHT )); 898 899 m_aPreviewWin.Invalidate(); 900 m_aFontTypeFT.SetText( pFontList->GetFontMapText( aFontInfo ) ); 901 } 902 903 // ----------------------------------------------------------------------- 904 905 void SvxCharNamePage::FillStyleBox_Impl( const FontNameBox* pNameBox ) 906 { 907 const FontList* pFontList = GetFontList(); 908 DBG_ASSERT( pFontList, "no fontlist" ); 909 910 FontStyleBox* pStyleBox = NULL; 911 912 if ( m_pWestFontNameLB == pNameBox ) 913 pStyleBox = m_pWestFontStyleLB; 914 else if ( m_pEastFontNameLB == pNameBox ) 915 pStyleBox = m_pEastFontStyleLB; 916 else if ( m_pCTLFontNameLB == pNameBox ) 917 pStyleBox = m_pCTLFontStyleLB; 918 else 919 { 920 DBG_ERRORFILE( "invalid font name box" ); 921 } 922 923 pStyleBox->Fill( pNameBox->GetText(), pFontList ); 924 925 if ( m_pImpl->m_bInSearchMode ) 926 { 927 // Bei der Suche zus"atzliche Eintr"age: 928 // "Nicht Fett" und "Nicht Kursiv" 929 String aEntry = m_pImpl->m_aNoStyleText; 930 const sal_Char sS[] = "%1"; 931 aEntry.SearchAndReplaceAscii( sS, pFontList->GetBoldStr() ); 932 m_pImpl->m_nExtraEntryPos = pStyleBox->InsertEntry( aEntry ); 933 aEntry = m_pImpl->m_aNoStyleText; 934 aEntry.SearchAndReplaceAscii( sS, pFontList->GetItalicStr() ); 935 pStyleBox->InsertEntry( aEntry ); 936 } 937 } 938 939 // ----------------------------------------------------------------------- 940 941 void SvxCharNamePage::FillSizeBox_Impl( const FontNameBox* pNameBox ) 942 { 943 const FontList* pFontList = GetFontList(); 944 DBG_ASSERT( pFontList, "no fontlist" ); 945 946 FontStyleBox* pStyleBox = NULL; 947 FontSizeBox* pSizeBox = NULL; 948 949 if ( m_pWestFontNameLB == pNameBox ) 950 { 951 pStyleBox = m_pWestFontStyleLB; 952 pSizeBox = m_pWestFontSizeLB; 953 } 954 else if ( m_pEastFontNameLB == pNameBox ) 955 { 956 pStyleBox = m_pEastFontStyleLB; 957 pSizeBox = m_pEastFontSizeLB; 958 } 959 else if ( m_pCTLFontNameLB == pNameBox ) 960 { 961 pStyleBox = m_pCTLFontStyleLB; 962 pSizeBox = m_pCTLFontSizeLB; 963 } 964 else 965 { 966 DBG_ERRORFILE( "invalid font name box" ); 967 } 968 969 FontInfo _aFontInfo( pFontList->Get( pNameBox->GetText(), pStyleBox->GetText() ) ); 970 pSizeBox->Fill( &_aFontInfo, pFontList ); 971 } 972 973 // ----------------------------------------------------------------------- 974 975 void SvxCharNamePage::Reset_Impl( const SfxItemSet& rSet, LanguageGroup eLangGrp ) 976 { 977 FixedText* pNameLabel = NULL; 978 FontNameBox* pNameBox = NULL; 979 FixedText* pStyleLabel = NULL; 980 FontStyleBox* pStyleBox = NULL; 981 FixedText* pSizeLabel = NULL; 982 FontSizeBox* pSizeBox = NULL; 983 FixedText* pLangFT = NULL; 984 SvxLanguageBox* pLangBox = NULL; 985 sal_uInt16 nWhich = 0; 986 987 switch ( eLangGrp ) 988 { 989 case Western : 990 pNameLabel = m_pWestFontNameFT; 991 pNameBox = m_pWestFontNameLB; 992 pStyleLabel = m_pWestFontStyleFT; 993 pStyleBox = m_pWestFontStyleLB; 994 pSizeLabel = m_pWestFontSizeFT; 995 pSizeBox = m_pWestFontSizeLB; 996 pLangFT = m_pWestFontLanguageFT; 997 pLangBox = m_pWestFontLanguageLB; 998 nWhich = GetWhich( SID_ATTR_CHAR_FONT ); 999 break; 1000 1001 case Asian : 1002 pNameLabel = m_pEastFontNameFT; 1003 pNameBox = m_pEastFontNameLB; 1004 pStyleLabel = m_pEastFontStyleFT; 1005 pStyleBox = m_pEastFontStyleLB; 1006 pSizeLabel = m_pEastFontSizeFT; 1007 pSizeBox = m_pEastFontSizeLB; 1008 pLangFT = m_pEastFontLanguageFT; 1009 pLangBox = m_pEastFontLanguageLB; 1010 nWhich = GetWhich( SID_ATTR_CHAR_CJK_FONT ); 1011 break; 1012 1013 case Ctl : 1014 pNameLabel = m_pCTLFontNameFT; 1015 pNameBox = m_pCTLFontNameLB; 1016 pStyleLabel = m_pCTLFontStyleFT; 1017 pStyleBox = m_pCTLFontStyleLB; 1018 pSizeLabel = m_pCTLFontSizeFT; 1019 pSizeBox = m_pCTLFontSizeLB; 1020 pLangFT = m_pCTLFontLanguageFT; 1021 pLangBox = m_pCTLFontLanguageLB; 1022 nWhich = GetWhich( SID_ATTR_CHAR_CTL_FONT ); 1023 break; 1024 } 1025 1026 // die FontListBox fuellen 1027 const FontList* pFontList = GetFontList(); 1028 pNameBox->Fill( pFontList ); 1029 1030 // Font ermitteln 1031 const SvxFontItem* pFontItem = NULL; 1032 SfxItemState eState = rSet.GetItemState( nWhich ); 1033 1034 if ( eState >= SFX_ITEM_DEFAULT ) 1035 { 1036 pFontItem = (const SvxFontItem*)&( rSet.Get( nWhich ) ); 1037 pNameBox->SetText( pFontItem->GetFamilyName() ); 1038 } 1039 else 1040 { 1041 pNameBox->SetText( String() ); 1042 } 1043 1044 FillStyleBox_Impl( pNameBox ); 1045 1046 FASTBOOL bStyle = sal_False; 1047 FASTBOOL bStyleAvailable = sal_True; 1048 FontItalic eItalic = ITALIC_NONE; 1049 FontWeight eWeight = WEIGHT_NORMAL; 1050 switch ( eLangGrp ) 1051 { 1052 case Western : nWhich = GetWhich( SID_ATTR_CHAR_POSTURE ); break; 1053 case Asian : nWhich = GetWhich( SID_ATTR_CHAR_CJK_POSTURE ); break; 1054 case Ctl : nWhich = GetWhich( SID_ATTR_CHAR_CTL_POSTURE ); break; 1055 } 1056 eState = rSet.GetItemState( nWhich ); 1057 1058 if ( eState >= SFX_ITEM_DEFAULT ) 1059 { 1060 const SvxPostureItem& rItem = (SvxPostureItem&)rSet.Get( nWhich ); 1061 eItalic = (FontItalic)rItem.GetValue(); 1062 bStyle = sal_True; 1063 } 1064 bStyleAvailable = bStyleAvailable && (eState >= SFX_ITEM_DONTCARE); 1065 1066 switch ( eLangGrp ) 1067 { 1068 case Western : nWhich = GetWhich( SID_ATTR_CHAR_WEIGHT ); break; 1069 case Asian : nWhich = GetWhich( SID_ATTR_CHAR_CJK_WEIGHT ); break; 1070 case Ctl : nWhich = GetWhich( SID_ATTR_CHAR_CTL_WEIGHT ); break; 1071 } 1072 eState = rSet.GetItemState( nWhich ); 1073 1074 if ( eState >= SFX_ITEM_DEFAULT ) 1075 { 1076 SvxWeightItem& rItem = (SvxWeightItem&)rSet.Get( nWhich ); 1077 eWeight = (FontWeight)rItem.GetValue(); 1078 } 1079 else 1080 bStyle = sal_False; 1081 bStyleAvailable = bStyleAvailable && (eState >= SFX_ITEM_DONTCARE); 1082 1083 // Aktuell eingestellter Font 1084 if ( bStyle && pFontItem ) 1085 { 1086 FontInfo aInfo = pFontList->Get( pFontItem->GetFamilyName(), eWeight, eItalic ); 1087 pStyleBox->SetText( pFontList->GetStyleName( aInfo ) ); 1088 } 1089 else if ( !m_pImpl->m_bInSearchMode || !bStyle ) 1090 { 1091 pStyleBox->SetText( String() ); 1092 } 1093 else if ( bStyle ) 1094 { 1095 FontInfo aInfo = pFontList->Get( String(), eWeight, eItalic ); 1096 pStyleBox->SetText( pFontList->GetStyleName( aInfo ) ); 1097 } 1098 if (!bStyleAvailable) 1099 { 1100 pStyleBox->Disable( ); 1101 pStyleLabel->Disable( ); 1102 } 1103 1104 // SizeBox fuellen 1105 FillSizeBox_Impl( pNameBox ); 1106 switch ( eLangGrp ) 1107 { 1108 case Western : nWhich = GetWhich( SID_ATTR_CHAR_FONTHEIGHT ); break; 1109 case Asian : nWhich = GetWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT ); break; 1110 case Ctl : nWhich = GetWhich( SID_ATTR_CHAR_CTL_FONTHEIGHT ); break; 1111 } 1112 eState = rSet.GetItemState( nWhich ); 1113 1114 if ( pSizeBox->IsRelativeMode() ) 1115 { 1116 SfxMapUnit eUnit = rSet.GetPool()->GetMetric( nWhich ); 1117 const SvxFontHeightItem& rItem = (SvxFontHeightItem&)rSet.Get( nWhich ); 1118 1119 if( rItem.GetProp() != 100 || SFX_MAPUNIT_RELATIVE != rItem.GetPropUnit() ) 1120 { 1121 sal_Bool bPtRel = SFX_MAPUNIT_POINT == rItem.GetPropUnit(); 1122 pSizeBox->SetPtRelative( bPtRel ); 1123 pSizeBox->SetValue( bPtRel ? ((short)rItem.GetProp()) * 10 : rItem.GetProp() ); 1124 } 1125 else 1126 { 1127 pSizeBox->SetRelative(); 1128 pSizeBox->SetValue( (long)CalcToPoint( rItem.GetHeight(), eUnit, 10 ) ); 1129 } 1130 } 1131 else if ( eState >= SFX_ITEM_DEFAULT ) 1132 { 1133 SfxMapUnit eUnit = rSet.GetPool()->GetMetric( nWhich ); 1134 const SvxFontHeightItem& rItem = (SvxFontHeightItem&)rSet.Get( nWhich ); 1135 pSizeBox->SetValue( (long)CalcToPoint( rItem.GetHeight(), eUnit, 10 ) ); 1136 } 1137 else 1138 { 1139 pSizeBox->SetText( String() ); 1140 if ( eState <= SFX_ITEM_READONLY ) 1141 { 1142 pSizeBox->Disable( ); 1143 pSizeLabel->Disable( ); 1144 } 1145 } 1146 1147 switch ( eLangGrp ) 1148 { 1149 case Western : nWhich = GetWhich( SID_ATTR_CHAR_LANGUAGE ); break; 1150 case Asian : nWhich = GetWhich( SID_ATTR_CHAR_CJK_LANGUAGE ); break; 1151 case Ctl : nWhich = GetWhich( SID_ATTR_CHAR_CTL_LANGUAGE ); break; 1152 } 1153 pLangBox->SetNoSelection(); 1154 eState = rSet.GetItemState( nWhich ); 1155 1156 switch ( eState ) 1157 { 1158 case SFX_ITEM_UNKNOWN: 1159 pLangFT->Hide(); 1160 pLangBox->Hide(); 1161 break; 1162 1163 case SFX_ITEM_DISABLED: 1164 case SFX_ITEM_READONLY: 1165 pLangFT->Disable(); 1166 pLangBox->Disable(); 1167 break; 1168 1169 case SFX_ITEM_DEFAULT: 1170 case SFX_ITEM_SET: 1171 { 1172 const SvxLanguageItem& rItem = (SvxLanguageItem&)rSet.Get( nWhich ); 1173 LanguageType eLangType = (LanguageType)rItem.GetValue(); 1174 DBG_ASSERT( eLangType != LANGUAGE_SYSTEM, "LANGUAGE_SYSTEM not allowed" ); 1175 if ( eLangType != LANGUAGE_DONTKNOW ) 1176 pLangBox->SelectLanguage( eLangType ); 1177 break; 1178 } 1179 } 1180 1181 if ( Western == eLangGrp ) 1182 m_aFontTypeFT.SetText( pFontList->GetFontMapText( 1183 pFontList->Get( pNameBox->GetText(), pStyleBox->GetText() ) ) ); 1184 1185 // save these settings 1186 pNameBox->SaveValue(); 1187 pStyleBox->SaveValue(); 1188 pSizeBox->SaveValue(); 1189 pLangBox->SaveValue(); 1190 } 1191 1192 // ----------------------------------------------------------------------- 1193 1194 sal_Bool SvxCharNamePage::FillItemSet_Impl( SfxItemSet& rSet, LanguageGroup eLangGrp ) 1195 { 1196 sal_Bool bModified = sal_False; 1197 1198 FontNameBox* pNameBox = NULL; 1199 FontStyleBox* pStyleBox = NULL; 1200 FontSizeBox* pSizeBox = NULL; 1201 SvxLanguageBox* pLangBox = NULL; 1202 sal_uInt16 nWhich = 0; 1203 sal_uInt16 nSlot = 0; 1204 1205 switch ( eLangGrp ) 1206 { 1207 case Western : 1208 pNameBox = m_pWestFontNameLB; 1209 pStyleBox = m_pWestFontStyleLB; 1210 pSizeBox = m_pWestFontSizeLB; 1211 pLangBox = m_pWestFontLanguageLB; 1212 nSlot = SID_ATTR_CHAR_FONT; 1213 break; 1214 1215 case Asian : 1216 pNameBox = m_pEastFontNameLB; 1217 pStyleBox = m_pEastFontStyleLB; 1218 pSizeBox = m_pEastFontSizeLB; 1219 pLangBox = m_pEastFontLanguageLB; 1220 nSlot = SID_ATTR_CHAR_CJK_FONT; 1221 break; 1222 1223 case Ctl : 1224 pNameBox = m_pCTLFontNameLB; 1225 pStyleBox = m_pCTLFontStyleLB; 1226 pSizeBox = m_pCTLFontSizeLB; 1227 pLangBox = m_pCTLFontLanguageLB; 1228 nSlot = SID_ATTR_CHAR_CTL_FONT; 1229 break; 1230 } 1231 1232 nWhich = GetWhich( nSlot ); 1233 const SfxPoolItem* pItem = NULL; 1234 const SfxItemSet& rOldSet = GetItemSet(); 1235 const SfxPoolItem* pOld = NULL; 1236 1237 const SfxItemSet* pExampleSet = GetTabDialog() ? GetTabDialog()->GetExampleSet() : NULL; 1238 1239 FASTBOOL bChanged = sal_True; 1240 const String& rFontName = pNameBox->GetText(); 1241 const FontList* pFontList = GetFontList(); 1242 String aStyleBoxText =pStyleBox->GetText(); 1243 sal_uInt16 nEntryPos = pStyleBox->GetEntryPos( aStyleBoxText ); 1244 if ( nEntryPos >= m_pImpl->m_nExtraEntryPos ) 1245 aStyleBoxText.Erase(); 1246 FontInfo aInfo( pFontList->Get( rFontName, aStyleBoxText ) ); 1247 SvxFontItem aFontItem( aInfo.GetFamily(), aInfo.GetName(), aInfo.GetStyleName(), 1248 aInfo.GetPitch(), aInfo.GetCharSet(), nWhich ); 1249 pOld = GetOldItem( rSet, nSlot ); 1250 1251 if ( pOld ) 1252 { 1253 const SvxFontItem& rItem = *( (const SvxFontItem*)pOld ); 1254 1255 if ( rItem.GetFamilyName() == aFontItem.GetFamilyName() ) 1256 bChanged = sal_False; 1257 } 1258 1259 if ( !bChanged ) 1260 bChanged = !pNameBox->GetSavedValue().Len(); 1261 1262 if ( !bChanged && pExampleSet && 1263 pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET && 1264 ( (SvxFontItem*)pItem )->GetFamilyName() != aFontItem.GetFamilyName() ) 1265 bChanged = sal_True; 1266 1267 if ( bChanged && rFontName.Len() ) 1268 { 1269 rSet.Put( aFontItem ); 1270 bModified |= sal_True; 1271 } 1272 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 1273 rSet.ClearItem( nWhich ); 1274 1275 1276 bChanged = sal_True; 1277 switch ( eLangGrp ) 1278 { 1279 case Western : nSlot = SID_ATTR_CHAR_WEIGHT; break; 1280 case Asian : nSlot = SID_ATTR_CHAR_CJK_WEIGHT; break; 1281 case Ctl : nSlot = SID_ATTR_CHAR_CTL_WEIGHT; break; 1282 } 1283 nWhich = GetWhich( nSlot ); 1284 FontWeight eWeight = aInfo.GetWeight(); 1285 if ( nEntryPos >= m_pImpl->m_nExtraEntryPos ) 1286 eWeight = WEIGHT_NORMAL; 1287 SvxWeightItem aWeightItem( eWeight, nWhich ); 1288 pOld = GetOldItem( rSet, nSlot ); 1289 1290 if ( pOld ) 1291 { 1292 const SvxWeightItem& rItem = *( (const SvxWeightItem*)pOld ); 1293 1294 if ( rItem.GetValue() == aWeightItem.GetValue() ) 1295 bChanged = sal_False; 1296 } 1297 1298 if ( !bChanged ) 1299 { 1300 bChanged = !pStyleBox->GetSavedValue().Len(); 1301 1302 if ( m_pImpl->m_bInSearchMode && bChanged && 1303 aInfo.GetWeight() == WEIGHT_NORMAL && aInfo.GetItalic() != ITALIC_NONE ) 1304 bChanged = sal_False; 1305 } 1306 1307 if ( !bChanged && pExampleSet && 1308 pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET && 1309 ( (SvxWeightItem*)pItem )->GetValue() != aWeightItem.GetValue() ) 1310 bChanged = sal_True; 1311 1312 if ( nEntryPos >= m_pImpl->m_nExtraEntryPos ) 1313 bChanged = ( nEntryPos == m_pImpl->m_nExtraEntryPos ); 1314 1315 String aText( pStyleBox->GetText() ); // Tristate, dann Text leer 1316 1317 if ( bChanged && aText.Len() ) 1318 { 1319 rSet.Put( aWeightItem ); 1320 bModified |= sal_True; 1321 } 1322 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 1323 CLEARTITEM; 1324 1325 bChanged = sal_True; 1326 switch ( eLangGrp ) 1327 { 1328 case Western : nSlot = SID_ATTR_CHAR_POSTURE; break; 1329 case Asian : nSlot = SID_ATTR_CHAR_CJK_POSTURE; break; 1330 case Ctl : nSlot = SID_ATTR_CHAR_CTL_POSTURE; break; 1331 } 1332 nWhich = GetWhich( nSlot ); 1333 FontItalic eItalic = aInfo.GetItalic(); 1334 if ( nEntryPos >= m_pImpl->m_nExtraEntryPos ) 1335 eItalic = ITALIC_NONE; 1336 SvxPostureItem aPostureItem( eItalic, nWhich ); 1337 pOld = GetOldItem( rSet, nSlot ); 1338 1339 if ( pOld ) 1340 { 1341 const SvxPostureItem& rItem = *( (const SvxPostureItem*)pOld ); 1342 1343 if ( rItem.GetValue() == aPostureItem.GetValue() ) 1344 bChanged = sal_False; 1345 } 1346 1347 if ( !bChanged ) 1348 { 1349 bChanged = !pStyleBox->GetSavedValue().Len(); 1350 1351 if ( m_pImpl->m_bInSearchMode && bChanged && 1352 aInfo.GetItalic() == ITALIC_NONE && aInfo.GetWeight() != WEIGHT_NORMAL ) 1353 bChanged = sal_False; 1354 } 1355 1356 if ( !bChanged && pExampleSet && 1357 pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET && 1358 ( (SvxPostureItem*)pItem )->GetValue() != aPostureItem.GetValue() ) 1359 bChanged = sal_True; 1360 1361 if ( nEntryPos >= m_pImpl->m_nExtraEntryPos ) 1362 bChanged = ( nEntryPos == ( m_pImpl->m_nExtraEntryPos + 1 ) ); 1363 1364 if ( bChanged && aText.Len() ) 1365 { 1366 rSet.Put( aPostureItem ); 1367 bModified |= sal_True; 1368 } 1369 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 1370 CLEARTITEM; 1371 1372 // FontSize 1373 long nSize = static_cast<long>(pSizeBox->GetValue()); 1374 1375 if ( !pSizeBox->GetText().Len() ) // GetValue() gibt dann Min-Wert zurueck 1376 nSize = 0; 1377 long nSavedSize = pSizeBox->GetSavedValue().ToInt32(); 1378 FASTBOOL bRel = sal_True; 1379 1380 if ( !pSizeBox->IsRelative() ) 1381 { 1382 nSavedSize *= 10; 1383 bRel = sal_False; 1384 } 1385 1386 switch ( eLangGrp ) 1387 { 1388 case Western : nSlot = SID_ATTR_CHAR_FONTHEIGHT; break; 1389 case Asian : nSlot = SID_ATTR_CHAR_CJK_FONTHEIGHT; break; 1390 case Ctl : nSlot = SID_ATTR_CHAR_CTL_FONTHEIGHT; break; 1391 } 1392 nWhich = GetWhich( nSlot ); 1393 const SvxFontHeightItem* pOldHeight = (const SvxFontHeightItem*)GetOldItem( rSet, nSlot ); 1394 bChanged = ( nSize != nSavedSize ); 1395 1396 if ( !bChanged && pExampleSet && 1397 pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET ) 1398 { 1399 float fSize = (float)nSize / 10; 1400 long nVal = CalcToUnit( fSize, rSet.GetPool()->GetMetric( nWhich ) ); 1401 if ( ( (SvxFontHeightItem*)pItem )->GetHeight() != (sal_uInt32)nVal ) 1402 bChanged = sal_True; 1403 } 1404 1405 if ( bChanged || !pOldHeight || 1406 bRel != ( SFX_MAPUNIT_RELATIVE != pOldHeight->GetPropUnit() || 100 != pOldHeight->GetProp() ) ) 1407 { 1408 SfxMapUnit eUnit = rSet.GetPool()->GetMetric( nWhich ); 1409 if ( pSizeBox->IsRelative() ) 1410 { 1411 DBG_ASSERT( GetItemSet().GetParent(), "No parent set" ); 1412 const SvxFontHeightItem& rOldItem = 1413 (const SvxFontHeightItem&)GetItemSet().GetParent()->Get( nWhich ); 1414 1415 SvxFontHeightItem aHeight( 240, 100, nWhich ); 1416 if ( pSizeBox->IsPtRelative() ) 1417 aHeight.SetHeight( rOldItem.GetHeight(), (sal_uInt16)( nSize / 10 ), SFX_MAPUNIT_POINT, eUnit ); 1418 else 1419 aHeight.SetHeight( rOldItem.GetHeight(), (sal_uInt16)nSize, SFX_MAPUNIT_RELATIVE ); 1420 rSet.Put( aHeight ); 1421 } 1422 else 1423 { 1424 float fSize = (float)nSize / 10; 1425 rSet.Put( SvxFontHeightItem( CalcToUnit( fSize, eUnit ), 100, nWhich ) ); 1426 } 1427 bModified |= sal_True; 1428 } 1429 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 1430 CLEARTITEM; 1431 1432 bChanged = sal_True; 1433 switch ( eLangGrp ) 1434 { 1435 case Western : nSlot = SID_ATTR_CHAR_LANGUAGE; break; 1436 case Asian : nSlot = SID_ATTR_CHAR_CJK_LANGUAGE; break; 1437 case Ctl : nSlot = SID_ATTR_CHAR_CTL_LANGUAGE; break; 1438 } 1439 nWhich = GetWhich( nSlot ); 1440 pOld = GetOldItem( rSet, nSlot ); 1441 sal_uInt16 nLangPos = pLangBox->GetSelectEntryPos(); 1442 LanguageType eLangType = (LanguageType)(sal_uLong)pLangBox->GetEntryData( nLangPos ); 1443 1444 if ( pOld ) 1445 { 1446 const SvxLanguageItem& rItem = *( (const SvxLanguageItem*)pOld ); 1447 1448 if ( nLangPos == LISTBOX_ENTRY_NOTFOUND || eLangType == (LanguageType)rItem.GetValue() ) 1449 bChanged = sal_False; 1450 } 1451 1452 if ( !bChanged ) 1453 bChanged = ( pLangBox->GetSavedValue() == LISTBOX_ENTRY_NOTFOUND ); 1454 1455 if ( bChanged && nLangPos != LISTBOX_ENTRY_NOTFOUND ) 1456 { 1457 rSet.Put( SvxLanguageItem( eLangType, nWhich ) ); 1458 bModified |= sal_True; 1459 } 1460 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 1461 CLEARTITEM; 1462 1463 return bModified; 1464 } 1465 1466 // ----------------------------------------------------------------------- 1467 1468 void SvxCharNamePage::ResetColor_Impl( const SfxItemSet& rSet ) 1469 { 1470 sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_COLOR ); 1471 SfxItemState eState = rSet.GetItemState( nWhich ); 1472 1473 switch ( eState ) 1474 { 1475 case SFX_ITEM_UNKNOWN: 1476 m_pColorLB->Hide(); 1477 break; 1478 1479 case SFX_ITEM_DISABLED: 1480 case SFX_ITEM_READONLY: 1481 m_pColorLB->Disable(); 1482 break; 1483 1484 case SFX_ITEM_DONTCARE: 1485 m_pColorLB->SetNoSelection(); 1486 break; 1487 1488 case SFX_ITEM_DEFAULT: 1489 case SFX_ITEM_SET: 1490 { 1491 SvxFont& rFont = GetPreviewFont(); 1492 SvxFont& rCJKFont = GetPreviewCJKFont(); 1493 SvxFont& rCTLFont = GetPreviewCTLFont(); 1494 const SvxColorItem& rItem = (SvxColorItem&)rSet.Get( nWhich ); 1495 Color aColor = rItem.GetValue(); 1496 rFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor ); 1497 rCJKFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor ); 1498 rCTLFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor ); 1499 m_aPreviewWin.Invalidate(); 1500 sal_uInt16 nSelPos = m_pColorLB->GetEntryPos( aColor ); 1501 if ( nSelPos == LISTBOX_ENTRY_NOTFOUND && aColor == Color( COL_TRANSPARENT ) ) 1502 nSelPos = m_pColorLB->GetEntryPos( m_pImpl->m_aTransparentText ); 1503 1504 if ( LISTBOX_ENTRY_NOTFOUND != nSelPos ) 1505 m_pColorLB->SelectEntryPos( nSelPos ); 1506 else 1507 { 1508 nSelPos = m_pColorLB->GetEntryPos( aColor ); 1509 if ( LISTBOX_ENTRY_NOTFOUND != nSelPos ) 1510 m_pColorLB->SelectEntryPos( nSelPos ); 1511 else 1512 m_pColorLB->SelectEntryPos( 1513 m_pColorLB->InsertEntry( aColor, String( SVX_RES( RID_SVXSTR_COLOR_USER ) ) ) ); 1514 } 1515 break; 1516 } 1517 } 1518 } 1519 1520 // ----------------------------------------------------------------------- 1521 1522 IMPL_LINK( SvxCharNamePage, UpdateHdl_Impl, Timer*, EMPTYARG ) 1523 { 1524 UpdatePreview_Impl(); 1525 return 0; 1526 } 1527 1528 // ----------------------------------------------------------------------- 1529 1530 IMPL_LINK( SvxCharNamePage, FontModifyHdl_Impl, void*, pNameBox ) 1531 { 1532 m_pImpl->m_aUpdateTimer.Start(); 1533 1534 if ( m_pWestFontNameLB == pNameBox || m_pEastFontNameLB == pNameBox || m_pCTLFontNameLB == pNameBox ) 1535 { 1536 FillStyleBox_Impl( (FontNameBox*)pNameBox ); 1537 FillSizeBox_Impl( (FontNameBox*)pNameBox ); 1538 } 1539 return 0; 1540 } 1541 1542 // ----------------------------------------------------------------------- 1543 1544 IMPL_LINK( SvxCharNamePage, ColorBoxSelectHdl_Impl, ColorListBox*, pBox ) 1545 { 1546 SvxFont& rFont = GetPreviewFont(); 1547 SvxFont& rCJKFont = GetPreviewCJKFont(); 1548 SvxFont& rCTLFont = GetPreviewCTLFont(); 1549 Color aSelectedColor; 1550 if ( pBox->GetSelectEntry() == m_pImpl->m_aTransparentText ) 1551 aSelectedColor = Color( COL_TRANSPARENT ); 1552 else 1553 aSelectedColor = pBox->GetSelectEntryColor(); 1554 rFont.SetColor( aSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aSelectedColor ); 1555 rCJKFont.SetColor( aSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aSelectedColor ); 1556 rCTLFont.SetColor( aSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aSelectedColor ); 1557 m_aPreviewWin.Invalidate(); 1558 return 0; 1559 } 1560 1561 // ----------------------------------------------------------------------- 1562 1563 void SvxCharNamePage::ActivatePage( const SfxItemSet& rSet ) 1564 { 1565 SvxCharBasePage::ActivatePage( rSet ); 1566 1567 UpdatePreview_Impl(); // instead of asynchronous calling in ctor 1568 } 1569 1570 // ----------------------------------------------------------------------- 1571 1572 int SvxCharNamePage::DeactivatePage( SfxItemSet* _pSet ) 1573 { 1574 if ( _pSet ) 1575 FillItemSet( *_pSet ); 1576 return LEAVE_PAGE; 1577 } 1578 1579 // ----------------------------------------------------------------------- 1580 1581 SfxTabPage* SvxCharNamePage::Create( Window* pParent, const SfxItemSet& rSet ) 1582 { 1583 return new SvxCharNamePage( pParent, rSet ); 1584 } 1585 1586 // ----------------------------------------------------------------------- 1587 1588 sal_uInt16* SvxCharNamePage::GetRanges() 1589 { 1590 return pNameRanges; 1591 } 1592 1593 // ----------------------------------------------------------------------- 1594 1595 void SvxCharNamePage::Reset( const SfxItemSet& rSet ) 1596 { 1597 Reset_Impl( rSet, Western ); 1598 Reset_Impl( rSet, Asian ); 1599 Reset_Impl( rSet, Ctl ); 1600 ResetColor_Impl( rSet ); 1601 m_pColorLB->SaveValue(); 1602 1603 SetPrevFontWidthScale( rSet ); 1604 UpdatePreview_Impl(); 1605 } 1606 1607 // ----------------------------------------------------------------------- 1608 1609 sal_Bool SvxCharNamePage::FillItemSet( SfxItemSet& rSet ) 1610 { 1611 sal_Bool bModified = FillItemSet_Impl( rSet, Western ); 1612 bModified |= FillItemSet_Impl( rSet, Asian ); 1613 bModified |= FillItemSet_Impl( rSet, Ctl ); 1614 return bModified; 1615 } 1616 1617 // ----------------------------------------------------------------------- 1618 1619 void SvxCharNamePage::SetFontList( const SvxFontListItem& rItem ) 1620 { 1621 if ( m_pImpl->m_bMustDelete ) 1622 { 1623 delete m_pImpl->m_pFontList; 1624 } 1625 m_pImpl->m_pFontList = rItem.GetFontList()->Clone(); 1626 m_pImpl->m_bMustDelete = sal_True; 1627 } 1628 1629 // ----------------------------------------------------------------------- 1630 namespace 1631 { 1632 void enableRelativeMode( SvxCharNamePage* _pPage, FontSizeBox* _pFontSizeLB, sal_uInt16 _nHeightWhich ) 1633 { 1634 _pFontSizeLB->EnableRelativeMode( 5, 995, 5 ); // min 5%, max 995%, step 5 1635 1636 const SvxFontHeightItem& rHeightItem = 1637 (SvxFontHeightItem&)_pPage->GetItemSet().GetParent()->Get( _nHeightWhich ); 1638 SfxMapUnit eUnit = _pPage->GetItemSet().GetPool()->GetMetric( _nHeightWhich ); 1639 short nCurHeight = 1640 static_cast< short >( CalcToPoint( rHeightItem.GetHeight(), eUnit, 1 ) * 10 ); 1641 1642 // ausgehend von der akt. Hoehe: 1643 // - negativ bis minimal 2 pt 1644 // - positiv bis maximal 999 pt 1645 _pFontSizeLB->EnablePtRelativeMode( sal::static_int_cast< short >(-(nCurHeight - 20)), (9999 - nCurHeight), 10 ); 1646 } 1647 } 1648 // ----------------------------------------------------------------------------- 1649 1650 void SvxCharNamePage::EnableRelativeMode() 1651 { 1652 DBG_ASSERT( GetItemSet().GetParent(), "RelativeMode, but no ParentSet!" ); 1653 enableRelativeMode(this,m_pWestFontSizeLB,GetWhich( SID_ATTR_CHAR_FONTHEIGHT )); 1654 enableRelativeMode(this,m_pEastFontSizeLB,GetWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT )); 1655 enableRelativeMode(this,m_pCTLFontSizeLB,GetWhich( SID_ATTR_CHAR_CTL_FONTHEIGHT )); 1656 } 1657 1658 // ----------------------------------------------------------------------- 1659 1660 void SvxCharNamePage::EnableSearchMode() 1661 { 1662 m_pImpl->m_bInSearchMode = sal_True; 1663 } 1664 // ----------------------------------------------------------------------- 1665 void SvxCharNamePage::DisableControls( sal_uInt16 nDisable ) 1666 { 1667 if ( DISABLE_LANGUAGE & nDisable ) 1668 { 1669 if ( m_pWestFontLanguageFT ) m_pWestFontLanguageFT->Disable(); 1670 if ( m_pWestFontLanguageLB ) m_pWestFontLanguageLB->Disable(); 1671 if ( m_pEastFontLanguageFT ) m_pEastFontLanguageFT->Disable(); 1672 if ( m_pEastFontLanguageLB ) m_pEastFontLanguageLB->Disable(); 1673 if ( m_pCTLFontLanguageFT ) m_pCTLFontLanguageFT->Disable(); 1674 if ( m_pCTLFontLanguageLB ) m_pCTLFontLanguageLB->Disable(); 1675 } 1676 1677 if ( DISABLE_HIDE_LANGUAGE & nDisable ) 1678 { 1679 if ( m_pWestFontLanguageFT ) m_pWestFontLanguageFT->Hide(); 1680 if ( m_pWestFontLanguageLB ) m_pWestFontLanguageLB->Hide(); 1681 if ( m_pEastFontLanguageFT ) m_pEastFontLanguageFT->Hide(); 1682 if ( m_pEastFontLanguageLB ) m_pEastFontLanguageLB->Hide(); 1683 if ( m_pCTLFontLanguageFT ) m_pCTLFontLanguageFT->Hide(); 1684 if ( m_pCTLFontLanguageLB ) m_pCTLFontLanguageLB->Hide(); 1685 } 1686 } 1687 1688 // ----------------------------------------------------------------------- 1689 void SvxCharNamePage::SetPreviewBackgroundToCharacter() 1690 { 1691 m_bPreviewBackgroundToCharacter = sal_True; 1692 } 1693 1694 // ----------------------------------------------------------------------- 1695 void SvxCharNamePage::PageCreated (SfxAllItemSet aSet) //add CHINA001 1696 { 1697 SFX_ITEMSET_ARG (&aSet,pFontListItem,SvxFontListItem,SID_ATTR_CHAR_FONTLIST,sal_False); 1698 SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,sal_False); 1699 SFX_ITEMSET_ARG (&aSet,pDisalbeItem,SfxUInt16Item,SID_DISABLE_CTL,sal_False); 1700 if (pFontListItem) 1701 SetFontList(*pFontListItem); 1702 //CHINA001 SetFontList(pFontListItem->GetFontList()); 1703 1704 if (pFlagItem) 1705 { 1706 sal_uInt32 nFlags=pFlagItem->GetValue(); 1707 if ( ( nFlags & SVX_RELATIVE_MODE ) == SVX_RELATIVE_MODE ) 1708 EnableRelativeMode(); 1709 if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER ) 1710 SetPreviewBackgroundToCharacter(); 1711 } 1712 if (pDisalbeItem) 1713 DisableControls(pDisalbeItem->GetValue()); 1714 } 1715 // class SvxCharEffectsPage ---------------------------------------------- 1716 1717 SvxCharEffectsPage::SvxCharEffectsPage( Window* pParent, const SfxItemSet& rInSet ) : 1718 1719 SvxCharBasePage( pParent, CUI_RES( RID_SVXPAGE_CHAR_EFFECTS ), rInSet, WIN_EFFECTS_PREVIEW, FT_EFFECTS_FONTTYPE ), 1720 1721 m_aFontColorFT ( this, CUI_RES( FT_FONTCOLOR ) ), 1722 m_aFontColorLB ( this, CUI_RES( LB_FONTCOLOR ) ), 1723 1724 m_aEffectsFT ( this, CUI_RES( FT_EFFECTS ) ), 1725 m_aEffectsLB ( this, 0 ), 1726 1727 m_aEffects2LB ( this, CUI_RES( LB_EFFECTS2 ) ), 1728 1729 m_aReliefFT ( this, CUI_RES( FT_RELIEF ) ), 1730 m_aReliefLB ( this, CUI_RES( LB_RELIEF ) ), 1731 1732 m_aOutlineBtn ( this, CUI_RES( CB_OUTLINE ) ), 1733 m_aShadowBtn ( this, CUI_RES( CB_SHADOW ) ), 1734 m_aBlinkingBtn ( this, CUI_RES( CB_BLINKING ) ), 1735 m_aHiddenBtn ( this, CUI_RES( CB_CHARHIDDEN ) ), 1736 1737 m_aVerticalLine ( this, CUI_RES( FL_EFFECTS_VERTICAL ) ), 1738 1739 m_aOverlineFT ( this, CUI_RES( FT_OVERLINE ) ), 1740 m_aOverlineLB ( this, CUI_RES( LB_OVERLINE ) ), 1741 m_aOverlineColorFT ( this, CUI_RES( FT_OVERLINE_COLOR ) ), 1742 m_aOverlineColorLB ( this, CUI_RES( LB_OVERLINE_COLOR ) ), 1743 m_aStrikeoutFT ( this, CUI_RES( FT_STRIKEOUT ) ), 1744 m_aStrikeoutLB ( this, CUI_RES( LB_STRIKEOUT ) ), 1745 m_aUnderlineFT ( this, CUI_RES( FT_UNDERLINE ) ), 1746 m_aUnderlineLB ( this, CUI_RES( LB_UNDERLINE ) ), 1747 m_aUnderlineColorFT ( this, CUI_RES( FT_UNDERLINE_COLOR ) ), 1748 m_aUnderlineColorLB ( this, CUI_RES( LB_UNDERLINE_COLOR ) ), 1749 m_aIndividualWordsBtn ( this, CUI_RES( CB_INDIVIDUALWORDS ) ), 1750 1751 m_aAsianLine ( this, CUI_RES( FL_EFFECTS_ASIAN ) ), 1752 1753 m_aEmphasisFT ( this, CUI_RES( FT_EMPHASIS ) ), 1754 m_aEmphasisLB ( this, CUI_RES( LB_EMPHASIS ) ), 1755 m_aPositionFT ( this, CUI_RES( FT_POSITION ) ), 1756 m_aPositionLB ( this, CUI_RES( LB_POSITION ) ), 1757 1758 m_aTransparentColorName ( CUI_RES( STR_CHARNAME_TRANSPARENT ) ) 1759 1760 { 1761 m_aEffectsLB.Hide(); 1762 FreeResource(); 1763 Initialize(); 1764 } 1765 1766 // ----------------------------------------------------------------------- 1767 1768 void SvxCharEffectsPage::Initialize() 1769 { 1770 // to handle the changes of the other pages 1771 SetExchangeSupport(); 1772 1773 // HTML-Mode 1774 const SfxPoolItem* pItem; 1775 SfxObjectShell* pShell; 1776 if ( SFX_ITEM_SET == GetItemSet().GetItemState( SID_HTML_MODE, sal_False, &pItem ) || 1777 ( NULL != ( pShell = SfxObjectShell::Current() ) && 1778 NULL != ( pItem = pShell->GetItem( SID_HTML_MODE ) ) ) ) 1779 { 1780 m_nHtmlMode = ( (const SfxUInt16Item*)pItem )->GetValue(); 1781 if ( ( m_nHtmlMode & HTMLMODE_ON ) == HTMLMODE_ON ) 1782 { 1783 //!!! hide some controls please 1784 } 1785 } 1786 1787 // fill the color box 1788 SfxObjectShell* pDocSh = SfxObjectShell::Current(); 1789 DBG_ASSERT( pDocSh, "DocShell not found!" ); 1790 XColorList* pColorTable = NULL; 1791 FASTBOOL bKillTable = sal_False; 1792 1793 if ( pDocSh ) 1794 { 1795 pItem = pDocSh->GetItem( SID_COLOR_TABLE ); 1796 if ( pItem != NULL ) 1797 pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable(); 1798 } 1799 1800 if ( !pColorTable ) 1801 { 1802 pColorTable = new XColorList( SvtPathOptions().GetPalettePath() ); 1803 bKillTable = sal_True; 1804 } 1805 1806 m_aUnderlineColorLB.SetUpdateMode( sal_False ); 1807 m_aOverlineColorLB.SetUpdateMode( sal_False ); 1808 m_aFontColorLB.SetUpdateMode( sal_False ); 1809 1810 { 1811 SfxPoolItem* pDummy; 1812 SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocSh ); 1813 if ( !pFrame || 1814 SFX_ITEM_DEFAULT > pFrame->GetBindings().QueryState( SID_ATTR_AUTO_COLOR_INVALID, pDummy ) ) 1815 { 1816 m_aUnderlineColorLB.InsertAutomaticEntry(); 1817 m_aOverlineColorLB.InsertAutomaticEntry(); 1818 m_aFontColorLB.InsertAutomaticEntry(); 1819 } 1820 } 1821 for ( long i = 0; i < pColorTable->Count(); i++ ) 1822 { 1823 XColorEntry* pEntry = pColorTable->GetColor(i); 1824 m_aUnderlineColorLB.InsertEntry( pEntry->GetColor(), pEntry->GetName() ); 1825 m_aOverlineColorLB.InsertEntry( pEntry->GetColor(), pEntry->GetName() ); 1826 m_aFontColorLB.InsertEntry( pEntry->GetColor(), pEntry->GetName() ); 1827 } 1828 1829 m_aUnderlineColorLB.SetUpdateMode( sal_True ); 1830 m_aOverlineColorLB.SetUpdateMode( sal_True ); 1831 m_aFontColorLB.SetUpdateMode( sal_True ); 1832 m_aFontColorLB.SetSelectHdl( LINK( this, SvxCharEffectsPage, ColorBoxSelectHdl_Impl ) ); 1833 1834 if ( bKillTable ) 1835 delete pColorTable; 1836 1837 // handler 1838 Link aLink = LINK( this, SvxCharEffectsPage, SelectHdl_Impl ); 1839 m_aUnderlineLB.SetSelectHdl( aLink ); 1840 m_aUnderlineColorLB.SetSelectHdl( aLink ); 1841 m_aOverlineLB.SetSelectHdl( aLink ); 1842 m_aOverlineColorLB.SetSelectHdl( aLink ); 1843 m_aStrikeoutLB.SetSelectHdl( aLink ); 1844 m_aEmphasisLB.SetSelectHdl( aLink ); 1845 m_aPositionLB.SetSelectHdl( aLink ); 1846 m_aEffects2LB.SetSelectHdl( aLink ); 1847 m_aReliefLB.SetSelectHdl( aLink ); 1848 1849 m_aUnderlineLB.SelectEntryPos( 0 ); 1850 m_aUnderlineColorLB.SelectEntryPos( 0 ); 1851 m_aOverlineLB.SelectEntryPos( 0 ); 1852 m_aOverlineColorLB.SelectEntryPos( 0 ); 1853 m_aStrikeoutLB.SelectEntryPos( 0 ); 1854 m_aEmphasisLB.SelectEntryPos( 0 ); 1855 m_aPositionLB.SelectEntryPos( 0 ); 1856 SelectHdl_Impl( NULL ); 1857 SelectHdl_Impl( &m_aEmphasisLB ); 1858 1859 m_aEffects2LB.SelectEntryPos( 0 ); 1860 1861 m_aIndividualWordsBtn.SetClickHdl( LINK( this, SvxCharEffectsPage, CbClickHdl_Impl ) ); 1862 aLink = LINK( this, SvxCharEffectsPage, TristClickHdl_Impl ); 1863 m_aOutlineBtn.SetClickHdl( aLink ); 1864 m_aShadowBtn.SetClickHdl( aLink ); 1865 1866 if ( !SvtLanguageOptions().IsAsianTypographyEnabled() ) 1867 { 1868 m_aAsianLine.Hide(); 1869 m_aEmphasisFT.Hide(); 1870 m_aEmphasisLB.Hide(); 1871 m_aPositionFT.Hide(); 1872 m_aPositionLB.Hide(); 1873 } 1874 } 1875 // ----------------------------------------------------------------------- 1876 1877 void SvxCharEffectsPage::UpdatePreview_Impl() 1878 { 1879 SvxFont& rFont = GetPreviewFont(); 1880 SvxFont& rCJKFont = GetPreviewCJKFont(); 1881 SvxFont& rCTLFont = GetPreviewCTLFont(); 1882 1883 sal_uInt16 nPos = m_aUnderlineLB.GetSelectEntryPos(); 1884 FontUnderline eUnderline = (FontUnderline)(sal_uLong)m_aUnderlineLB.GetEntryData( nPos ); 1885 nPos = m_aOverlineLB.GetSelectEntryPos(); 1886 FontUnderline eOverline = (FontUnderline)(sal_uLong)m_aOverlineLB.GetEntryData( nPos ); 1887 nPos = m_aStrikeoutLB.GetSelectEntryPos(); 1888 FontStrikeout eStrikeout = (FontStrikeout)(sal_uLong)m_aStrikeoutLB.GetEntryData( nPos ); 1889 rFont.SetUnderline( eUnderline ); 1890 rCJKFont.SetUnderline( eUnderline ); 1891 rCTLFont.SetUnderline( eUnderline ); 1892 m_aPreviewWin.SetTextLineColor( m_aUnderlineColorLB.GetSelectEntryColor() ); 1893 rFont.SetOverline( eOverline ); 1894 rCJKFont.SetOverline( eOverline ); 1895 rCTLFont.SetOverline( eOverline ); 1896 m_aPreviewWin.SetOverlineColor( m_aOverlineColorLB.GetSelectEntryColor() ); 1897 rFont.SetStrikeout( eStrikeout ); 1898 rCJKFont.SetStrikeout( eStrikeout ); 1899 rCTLFont.SetStrikeout( eStrikeout ); 1900 1901 nPos = m_aPositionLB.GetSelectEntryPos(); 1902 sal_Bool bUnder = ( CHRDLG_POSITION_UNDER == (sal_uLong)m_aPositionLB.GetEntryData( nPos ) ); 1903 FontEmphasisMark eMark = (FontEmphasisMark)m_aEmphasisLB.GetSelectEntryPos(); 1904 eMark |= bUnder ? EMPHASISMARK_POS_BELOW : EMPHASISMARK_POS_ABOVE; 1905 rFont.SetEmphasisMark( eMark ); 1906 rCJKFont.SetEmphasisMark( eMark ); 1907 rCTLFont.SetEmphasisMark( eMark ); 1908 1909 sal_uInt16 nRelief = m_aReliefLB.GetSelectEntryPos(); 1910 if(LISTBOX_ENTRY_NOTFOUND != nRelief) 1911 { 1912 rFont.SetRelief( (FontRelief)nRelief ); 1913 rCJKFont.SetRelief( (FontRelief)nRelief ); 1914 rCTLFont.SetRelief( (FontRelief)nRelief ); 1915 } 1916 1917 rFont.SetOutline( StateToAttr( m_aOutlineBtn.GetState() ) ); 1918 rCJKFont.SetOutline( rFont.IsOutline() ); 1919 rCTLFont.SetOutline( rFont.IsOutline() ); 1920 1921 rFont.SetShadow( StateToAttr( m_aShadowBtn.GetState() ) ); 1922 rCJKFont.SetShadow( rFont.IsShadow() ); 1923 rCTLFont.SetShadow( rFont.IsShadow() ); 1924 1925 sal_uInt16 nCapsPos = m_aEffects2LB.GetSelectEntryPos(); 1926 if ( nCapsPos != LISTBOX_ENTRY_NOTFOUND ) 1927 { 1928 rFont.SetCaseMap( (SvxCaseMap)nCapsPos ); 1929 rCJKFont.SetCaseMap( (SvxCaseMap)nCapsPos ); 1930 // #i78474# small caps do not exist in CTL fonts 1931 rCTLFont.SetCaseMap( static_cast<SvxCaseMap>( nCapsPos == SVX_CASEMAP_KAPITAELCHEN ? SVX_CASEMAP_NOT_MAPPED : (SvxCaseMap)nCapsPos) ); 1932 } 1933 1934 sal_Bool bWordLine = m_aIndividualWordsBtn.IsChecked(); 1935 rFont.SetWordLineMode( bWordLine ); 1936 rCJKFont.SetWordLineMode( bWordLine ); 1937 rCTLFont.SetWordLineMode( bWordLine ); 1938 1939 m_aPreviewWin.Invalidate(); 1940 } 1941 1942 // ----------------------------------------------------------------------- 1943 1944 void SvxCharEffectsPage::SetCaseMap_Impl( SvxCaseMap eCaseMap ) 1945 { 1946 if ( SVX_CASEMAP_END > eCaseMap ) 1947 m_aEffects2LB.SelectEntryPos( 1948 sal::static_int_cast< sal_uInt16 >( eCaseMap ) ); 1949 else 1950 { 1951 m_aEffects2LB.SetNoSelection(); 1952 eCaseMap = SVX_CASEMAP_NOT_MAPPED; 1953 } 1954 1955 UpdatePreview_Impl(); 1956 } 1957 1958 // ----------------------------------------------------------------------- 1959 1960 void SvxCharEffectsPage::ResetColor_Impl( const SfxItemSet& rSet ) 1961 { 1962 sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_COLOR ); 1963 SfxItemState eState = rSet.GetItemState( nWhich ); 1964 1965 switch ( eState ) 1966 { 1967 case SFX_ITEM_UNKNOWN: 1968 m_aFontColorFT.Hide(); 1969 m_aFontColorLB.Hide(); 1970 break; 1971 1972 case SFX_ITEM_DISABLED: 1973 case SFX_ITEM_READONLY: 1974 m_aFontColorFT.Disable(); 1975 m_aFontColorLB.Disable(); 1976 break; 1977 1978 case SFX_ITEM_DONTCARE: 1979 m_aFontColorLB.SetNoSelection(); 1980 break; 1981 1982 case SFX_ITEM_DEFAULT: 1983 case SFX_ITEM_SET: 1984 { 1985 SvxFont& rFont = GetPreviewFont(); 1986 SvxFont& rCJKFont = GetPreviewCJKFont(); 1987 SvxFont& rCTLFont = GetPreviewCTLFont(); 1988 1989 const SvxColorItem& rItem = (SvxColorItem&)rSet.Get( nWhich ); 1990 Color aColor = rItem.GetValue(); 1991 rFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor ); 1992 rCJKFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor ); 1993 rCTLFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor ); 1994 1995 m_aPreviewWin.Invalidate(); 1996 sal_uInt16 nSelPos = m_aFontColorLB.GetEntryPos( aColor ); 1997 if ( nSelPos == LISTBOX_ENTRY_NOTFOUND && aColor == Color( COL_TRANSPARENT ) ) 1998 nSelPos = m_aFontColorLB.GetEntryPos( m_aTransparentColorName ); 1999 2000 if ( LISTBOX_ENTRY_NOTFOUND != nSelPos ) 2001 m_aFontColorLB.SelectEntryPos( nSelPos ); 2002 else 2003 { 2004 nSelPos = m_aFontColorLB.GetEntryPos( aColor ); 2005 if ( LISTBOX_ENTRY_NOTFOUND != nSelPos ) 2006 m_aFontColorLB.SelectEntryPos( nSelPos ); 2007 else 2008 m_aFontColorLB.SelectEntryPos( 2009 m_aFontColorLB.InsertEntry( aColor, String( SVX_RES( RID_SVXSTR_COLOR_USER ) ) ) ); 2010 } 2011 break; 2012 } 2013 } 2014 } 2015 2016 // ----------------------------------------------------------------------- 2017 2018 sal_Bool SvxCharEffectsPage::FillItemSetColor_Impl( SfxItemSet& rSet ) 2019 { 2020 sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_COLOR ); 2021 const SvxColorItem* pOld = (const SvxColorItem*)GetOldItem( rSet, SID_ATTR_CHAR_COLOR ); 2022 const SvxColorItem* pItem = NULL; 2023 sal_Bool bChanged = sal_True; 2024 const SfxItemSet* pExampleSet = GetTabDialog() ? GetTabDialog()->GetExampleSet() : NULL; 2025 const SfxItemSet& rOldSet = GetItemSet(); 2026 2027 Color aSelectedColor; 2028 if ( m_aFontColorLB.GetSelectEntry() == m_aTransparentColorName ) 2029 aSelectedColor = Color( COL_TRANSPARENT ); 2030 else 2031 aSelectedColor = m_aFontColorLB.GetSelectEntryColor(); 2032 2033 if ( pOld && pOld->GetValue() == aSelectedColor ) 2034 bChanged = sal_False; 2035 2036 if ( !bChanged ) 2037 bChanged = ( m_aFontColorLB.GetSavedValue() == LISTBOX_ENTRY_NOTFOUND ); 2038 2039 if ( !bChanged && pExampleSet && 2040 pExampleSet->GetItemState( nWhich, sal_False, (const SfxPoolItem**)&pItem ) == SFX_ITEM_SET && 2041 ( (SvxColorItem*)pItem )->GetValue() != aSelectedColor ) 2042 bChanged = sal_True; 2043 2044 sal_Bool bModified = sal_False; 2045 2046 if ( bChanged && m_aFontColorLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND ) 2047 { 2048 rSet.Put( SvxColorItem( aSelectedColor, nWhich ) ); 2049 bModified = sal_True; 2050 } 2051 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 2052 CLEARTITEM; 2053 2054 return bModified; 2055 } 2056 2057 // ----------------------------------------------------------------------- 2058 2059 IMPL_LINK( SvxCharEffectsPage, SelectHdl_Impl, ListBox*, pBox ) 2060 { 2061 if ( &m_aEmphasisLB == pBox ) 2062 { 2063 sal_uInt16 nEPos = m_aEmphasisLB.GetSelectEntryPos(); 2064 sal_Bool bEnable = ( nEPos > 0 && nEPos != LISTBOX_ENTRY_NOTFOUND ); 2065 m_aPositionFT.Enable( bEnable ); 2066 m_aPositionLB.Enable( bEnable ); 2067 } 2068 else if( &m_aReliefLB == pBox) 2069 { 2070 sal_Bool bEnable = ( pBox->GetSelectEntryPos() == 0 ); 2071 m_aOutlineBtn.Enable( bEnable ); 2072 m_aShadowBtn.Enable( bEnable ); 2073 } 2074 else if ( &m_aPositionLB != pBox ) 2075 { 2076 sal_uInt16 nUPos = m_aUnderlineLB.GetSelectEntryPos(), 2077 nOPos = m_aOverlineLB.GetSelectEntryPos(), 2078 nSPos = m_aStrikeoutLB.GetSelectEntryPos(); 2079 sal_Bool bUEnable = ( nUPos > 0 && nUPos != LISTBOX_ENTRY_NOTFOUND ); 2080 sal_Bool bOEnable = ( nOPos > 0 && nOPos != LISTBOX_ENTRY_NOTFOUND ); 2081 m_aUnderlineColorFT.Enable( bUEnable ); 2082 m_aUnderlineColorLB.Enable( bUEnable ); 2083 m_aOverlineColorFT.Enable( bOEnable ); 2084 m_aOverlineColorLB.Enable( bOEnable ); 2085 m_aIndividualWordsBtn.Enable( bUEnable || bOEnable || ( nSPos > 0 && nSPos != LISTBOX_ENTRY_NOTFOUND ) ); 2086 } 2087 UpdatePreview_Impl(); 2088 return 0; 2089 } 2090 2091 // ----------------------------------------------------------------------- 2092 2093 IMPL_LINK( SvxCharEffectsPage, UpdatePreview_Impl, ListBox*, EMPTYARG ) 2094 { 2095 bool bEnable = ( ( m_aUnderlineLB.GetSelectEntryPos() > 0 ) || 2096 ( m_aOverlineLB.GetSelectEntryPos() > 0 ) || 2097 ( m_aStrikeoutLB.GetSelectEntryPos() > 0 ) ); 2098 m_aIndividualWordsBtn.Enable( bEnable ); 2099 2100 UpdatePreview_Impl(); 2101 return 0; 2102 } 2103 2104 // ----------------------------------------------------------------------- 2105 2106 IMPL_LINK( SvxCharEffectsPage, CbClickHdl_Impl, CheckBox*, EMPTYARG ) 2107 { 2108 UpdatePreview_Impl(); 2109 return 0; 2110 } 2111 2112 // ----------------------------------------------------------------------- 2113 2114 IMPL_LINK( SvxCharEffectsPage, TristClickHdl_Impl, TriStateBox*, EMPTYARG ) 2115 { 2116 UpdatePreview_Impl(); 2117 return 0; 2118 } 2119 2120 // ----------------------------------------------------------------------- 2121 2122 IMPL_LINK( SvxCharEffectsPage, ColorBoxSelectHdl_Impl, ColorListBox*, pBox ) 2123 { 2124 SvxFont& rFont = GetPreviewFont(); 2125 SvxFont& rCJKFont = GetPreviewCJKFont(); 2126 SvxFont& rCTLFont = GetPreviewCTLFont(); 2127 2128 Color aSelectedColor; 2129 if ( pBox->GetSelectEntry() == m_aTransparentColorName ) 2130 aSelectedColor = Color( COL_TRANSPARENT ); 2131 else 2132 aSelectedColor = pBox->GetSelectEntryColor(); 2133 rFont.SetColor( aSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aSelectedColor ); 2134 rCJKFont.SetColor( aSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aSelectedColor ); 2135 rCTLFont.SetColor( aSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aSelectedColor ); 2136 2137 m_aPreviewWin.Invalidate(); 2138 return 0; 2139 } 2140 // ----------------------------------------------------------------------- 2141 2142 int SvxCharEffectsPage::DeactivatePage( SfxItemSet* _pSet ) 2143 { 2144 if ( _pSet ) 2145 FillItemSet( *_pSet ); 2146 return LEAVE_PAGE; 2147 } 2148 2149 // ----------------------------------------------------------------------- 2150 2151 SfxTabPage* SvxCharEffectsPage::Create( Window* pParent, const SfxItemSet& rSet ) 2152 { 2153 return new SvxCharEffectsPage( pParent, rSet ); 2154 } 2155 2156 // ----------------------------------------------------------------------- 2157 2158 sal_uInt16* SvxCharEffectsPage::GetRanges() 2159 { 2160 return pEffectsRanges; 2161 } 2162 2163 // ----------------------------------------------------------------------- 2164 2165 void SvxCharEffectsPage::Reset( const SfxItemSet& rSet ) 2166 { 2167 SvxFont& rFont = GetPreviewFont(); 2168 SvxFont& rCJKFont = GetPreviewCJKFont(); 2169 SvxFont& rCTLFont = GetPreviewCTLFont(); 2170 2171 sal_Bool bEnable = sal_False; 2172 2173 // Underline 2174 sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_UNDERLINE ); 2175 rFont.SetUnderline( UNDERLINE_NONE ); 2176 rCJKFont.SetUnderline( UNDERLINE_NONE ); 2177 rCTLFont.SetUnderline( UNDERLINE_NONE ); 2178 2179 m_aUnderlineLB.SelectEntryPos( 0 ); 2180 SfxItemState eState = rSet.GetItemState( nWhich ); 2181 2182 if ( eState >= SFX_ITEM_DONTCARE ) 2183 { 2184 if ( eState == SFX_ITEM_DONTCARE ) 2185 m_aUnderlineLB.SetNoSelection(); 2186 else 2187 { 2188 const SvxUnderlineItem& rItem = (SvxUnderlineItem&)rSet.Get( nWhich ); 2189 FontUnderline eUnderline = (FontUnderline)rItem.GetValue(); 2190 rFont.SetUnderline( eUnderline ); 2191 rCJKFont.SetUnderline( eUnderline ); 2192 rCTLFont.SetUnderline( eUnderline ); 2193 2194 if ( eUnderline != UNDERLINE_NONE ) 2195 { 2196 for ( sal_uInt16 i = 0; i < m_aUnderlineLB.GetEntryCount(); ++i ) 2197 { 2198 if ( (FontUnderline)(sal_uLong)m_aUnderlineLB.GetEntryData(i) == eUnderline ) 2199 { 2200 m_aUnderlineLB.SelectEntryPos(i); 2201 bEnable |= sal_True; 2202 break; 2203 } 2204 } 2205 2206 Color aColor = rItem.GetColor(); 2207 sal_uInt16 nPos = m_aUnderlineColorLB.GetEntryPos( aColor ); 2208 2209 if ( LISTBOX_ENTRY_NOTFOUND != nPos ) 2210 m_aUnderlineColorLB.SelectEntryPos( nPos ); 2211 else 2212 { 2213 nPos = m_aUnderlineColorLB.GetEntryPos( aColor ); 2214 if ( LISTBOX_ENTRY_NOTFOUND != nPos ) 2215 m_aUnderlineColorLB.SelectEntryPos( nPos ); 2216 else 2217 m_aUnderlineColorLB.SelectEntryPos( 2218 m_aUnderlineColorLB.InsertEntry( aColor, 2219 String( SVX_RES( RID_SVXSTR_COLOR_USER ) ) ) ); 2220 } 2221 } 2222 else 2223 { 2224 m_aUnderlineColorLB.SelectEntry( Color( COL_AUTO )); 2225 m_aUnderlineColorLB.Disable(); 2226 } 2227 } 2228 } 2229 2230 // Overline 2231 nWhich = GetWhich( SID_ATTR_CHAR_OVERLINE ); 2232 rFont.SetOverline( UNDERLINE_NONE ); 2233 rCJKFont.SetOverline( UNDERLINE_NONE ); 2234 rCTLFont.SetOverline( UNDERLINE_NONE ); 2235 2236 m_aOverlineLB.SelectEntryPos( 0 ); 2237 eState = rSet.GetItemState( nWhich ); 2238 2239 if ( eState >= SFX_ITEM_DONTCARE ) 2240 { 2241 if ( eState == SFX_ITEM_DONTCARE ) 2242 m_aOverlineLB.SetNoSelection(); 2243 else 2244 { 2245 const SvxOverlineItem& rItem = (SvxOverlineItem&)rSet.Get( nWhich ); 2246 FontUnderline eOverline = (FontUnderline)rItem.GetValue(); 2247 rFont.SetOverline( eOverline ); 2248 rCJKFont.SetOverline( eOverline ); 2249 rCTLFont.SetOverline( eOverline ); 2250 2251 if ( eOverline != UNDERLINE_NONE ) 2252 { 2253 for ( sal_uInt16 i = 0; i < m_aOverlineLB.GetEntryCount(); ++i ) 2254 { 2255 if ( (FontUnderline)(sal_uLong)m_aOverlineLB.GetEntryData(i) == eOverline ) 2256 { 2257 m_aOverlineLB.SelectEntryPos(i); 2258 bEnable |= sal_True; 2259 break; 2260 } 2261 } 2262 2263 Color aColor = rItem.GetColor(); 2264 sal_uInt16 nPos = m_aOverlineColorLB.GetEntryPos( aColor ); 2265 2266 if ( LISTBOX_ENTRY_NOTFOUND != nPos ) 2267 m_aOverlineColorLB.SelectEntryPos( nPos ); 2268 else 2269 { 2270 nPos = m_aOverlineColorLB.GetEntryPos( aColor ); 2271 if ( LISTBOX_ENTRY_NOTFOUND != nPos ) 2272 m_aOverlineColorLB.SelectEntryPos( nPos ); 2273 else 2274 m_aOverlineColorLB.SelectEntryPos( 2275 m_aOverlineColorLB.InsertEntry( aColor, 2276 String( SVX_RES( RID_SVXSTR_COLOR_USER ) ) ) ); 2277 } 2278 } 2279 else 2280 { 2281 m_aOverlineColorLB.SelectEntry( Color( COL_AUTO )); 2282 m_aOverlineColorLB.Disable(); 2283 } 2284 } 2285 } 2286 2287 // Strikeout 2288 nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT ); 2289 rFont.SetStrikeout( STRIKEOUT_NONE ); 2290 rCJKFont.SetStrikeout( STRIKEOUT_NONE ); 2291 rCTLFont.SetStrikeout( STRIKEOUT_NONE ); 2292 2293 m_aStrikeoutLB.SelectEntryPos( 0 ); 2294 eState = rSet.GetItemState( nWhich ); 2295 2296 if ( eState >= SFX_ITEM_DONTCARE ) 2297 { 2298 if ( eState == SFX_ITEM_DONTCARE ) 2299 m_aStrikeoutLB.SetNoSelection(); 2300 else 2301 { 2302 const SvxCrossedOutItem& rItem = (SvxCrossedOutItem&)rSet.Get( nWhich ); 2303 FontStrikeout eStrikeout = (FontStrikeout)rItem.GetValue(); 2304 rFont.SetStrikeout( eStrikeout ); 2305 rCJKFont.SetStrikeout( eStrikeout ); 2306 rCTLFont.SetStrikeout( eStrikeout ); 2307 2308 if ( eStrikeout != STRIKEOUT_NONE ) 2309 { 2310 for ( sal_uInt16 i = 0; i < m_aStrikeoutLB.GetEntryCount(); ++i ) 2311 { 2312 if ( (FontStrikeout)(sal_uLong)m_aStrikeoutLB.GetEntryData(i) == eStrikeout ) 2313 { 2314 m_aStrikeoutLB.SelectEntryPos(i); 2315 bEnable |= sal_True; 2316 break; 2317 } 2318 } 2319 } 2320 } 2321 } 2322 2323 // WordLineMode 2324 nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE ); 2325 switch ( eState ) 2326 { 2327 case SFX_ITEM_UNKNOWN: 2328 m_aIndividualWordsBtn.Hide(); 2329 break; 2330 2331 case SFX_ITEM_DISABLED: 2332 case SFX_ITEM_READONLY: 2333 m_aIndividualWordsBtn.Disable(); 2334 break; 2335 2336 case SFX_ITEM_DONTCARE: 2337 m_aIndividualWordsBtn.SetState( STATE_DONTKNOW ); 2338 break; 2339 2340 case SFX_ITEM_DEFAULT: 2341 case SFX_ITEM_SET: 2342 { 2343 const SvxWordLineModeItem& rItem = (SvxWordLineModeItem&)rSet.Get( nWhich ); 2344 rFont.SetWordLineMode( rItem.GetValue() ); 2345 rCJKFont.SetWordLineMode( rItem.GetValue() ); 2346 rCTLFont.SetWordLineMode( rItem.GetValue() ); 2347 2348 m_aIndividualWordsBtn.Check( rItem.GetValue() ); 2349 m_aIndividualWordsBtn.Enable( bEnable ); 2350 break; 2351 } 2352 } 2353 2354 // Emphasis 2355 nWhich = GetWhich( SID_ATTR_CHAR_EMPHASISMARK ); 2356 eState = rSet.GetItemState( nWhich ); 2357 2358 if ( eState >= SFX_ITEM_DEFAULT ) 2359 { 2360 const SvxEmphasisMarkItem& rItem = (SvxEmphasisMarkItem&)rSet.Get( nWhich ); 2361 FontEmphasisMark eMark = rItem.GetEmphasisMark(); 2362 rFont.SetEmphasisMark( eMark ); 2363 rCJKFont.SetEmphasisMark( eMark ); 2364 rCTLFont.SetEmphasisMark( eMark ); 2365 2366 m_aEmphasisLB.SelectEntryPos( (sal_uInt16)( eMark & EMPHASISMARK_STYLE ) ); 2367 eMark &= ~EMPHASISMARK_STYLE; 2368 sal_uLong nEntryData = ( eMark == EMPHASISMARK_POS_ABOVE ) 2369 ? CHRDLG_POSITION_OVER 2370 : ( eMark == EMPHASISMARK_POS_BELOW ) ? CHRDLG_POSITION_UNDER : 0; 2371 2372 for ( sal_uInt16 i = 0; i < m_aPositionLB.GetEntryCount(); i++ ) 2373 { 2374 if ( nEntryData == (sal_uLong)m_aPositionLB.GetEntryData(i) ) 2375 { 2376 m_aPositionLB.SelectEntryPos(i); 2377 break; 2378 } 2379 } 2380 } 2381 else if ( eState == SFX_ITEM_DONTCARE ) 2382 m_aEmphasisLB.SetNoSelection( ); 2383 else if ( eState == SFX_ITEM_UNKNOWN ) 2384 { 2385 m_aEmphasisFT.Hide(); 2386 m_aEmphasisLB.Hide(); 2387 } 2388 else // SFX_ITEM_DISABLED or SFX_ITEM_READONLY 2389 { 2390 m_aEmphasisFT.Disable(); 2391 m_aEmphasisLB.Disable(); 2392 } 2393 2394 // the select handler for the underline/overline/strikeout list boxes 2395 // SelectHdl_Impl( NULL ); 2396 DBG_ASSERT(m_aUnderlineLB.GetSelectHdl() == m_aOverlineLB.GetSelectHdl(), 2397 "SvxCharEffectsPage::Reset: inconsistence (1)!"); 2398 DBG_ASSERT(m_aUnderlineLB.GetSelectHdl() == m_aStrikeoutLB.GetSelectHdl(), 2399 "SvxCharEffectsPage::Reset: inconsistence (1)!"); 2400 m_aUnderlineLB.GetSelectHdl().Call(NULL); 2401 // don't call SelectHdl_Impl directly! 2402 // in DisableControls, we may have re-reouted the select handler 2403 // 30.05.2001 - 86262 - frank.schoenheit@germany.sun.com 2404 2405 // the select handler for the emphasis listbox 2406 // SelectHdl_Impl( &m_aEmphasisLB ); 2407 DBG_ASSERT(m_aEmphasisLB.GetSelectHdl() == LINK(this, SvxCharEffectsPage, SelectHdl_Impl), 2408 "SvxCharEffectsPage::Reset: inconsistence (2)!"); 2409 m_aEmphasisLB.GetSelectHdl().Call( &m_aEmphasisLB ); 2410 // this is for consistency only. Here it would be allowed to call SelectHdl_Impl directly ... 2411 2412 // Effects 2413 SvxCaseMap eCaseMap = SVX_CASEMAP_END; 2414 nWhich = GetWhich( SID_ATTR_CHAR_CASEMAP ); 2415 eState = rSet.GetItemState( nWhich ); 2416 switch ( eState ) 2417 { 2418 case SFX_ITEM_UNKNOWN: 2419 m_aEffectsFT.Hide(); 2420 m_aEffects2LB.Hide(); 2421 break; 2422 2423 case SFX_ITEM_DISABLED: 2424 case SFX_ITEM_READONLY: 2425 m_aEffectsFT.Disable(); 2426 m_aEffects2LB.Disable(); 2427 break; 2428 2429 case SFX_ITEM_DONTCARE: 2430 m_aEffects2LB.SetNoSelection(); 2431 break; 2432 2433 case SFX_ITEM_DEFAULT: 2434 case SFX_ITEM_SET: 2435 { 2436 const SvxCaseMapItem& rItem = (const SvxCaseMapItem&)rSet.Get( nWhich ); 2437 eCaseMap = (SvxCaseMap)rItem.GetValue(); 2438 break; 2439 } 2440 } 2441 SetCaseMap_Impl( eCaseMap ); 2442 2443 //Relief 2444 nWhich = GetWhich(SID_ATTR_CHAR_RELIEF); 2445 eState = rSet.GetItemState( nWhich ); 2446 switch ( eState ) 2447 { 2448 case SFX_ITEM_UNKNOWN: 2449 m_aReliefFT.Hide(); 2450 m_aReliefLB.Hide(); 2451 break; 2452 2453 case SFX_ITEM_DISABLED: 2454 case SFX_ITEM_READONLY: 2455 m_aReliefFT.Disable(); 2456 m_aReliefLB.Disable(); 2457 break; 2458 2459 case SFX_ITEM_DONTCARE: 2460 m_aReliefLB.SetNoSelection(); 2461 break; 2462 2463 case SFX_ITEM_DEFAULT: 2464 case SFX_ITEM_SET: 2465 { 2466 const SvxCharReliefItem& rItem = (const SvxCharReliefItem&)rSet.Get( nWhich ); 2467 m_aReliefLB.SelectEntryPos(rItem.GetValue()); 2468 SelectHdl_Impl(&m_aReliefLB); 2469 break; 2470 } 2471 } 2472 2473 // Outline 2474 nWhich = GetWhich( SID_ATTR_CHAR_CONTOUR ); 2475 eState = rSet.GetItemState( nWhich ); 2476 switch ( eState ) 2477 { 2478 case SFX_ITEM_UNKNOWN: 2479 m_aOutlineBtn.Hide(); 2480 break; 2481 2482 case SFX_ITEM_DISABLED: 2483 case SFX_ITEM_READONLY: 2484 m_aOutlineBtn.Disable(); 2485 break; 2486 2487 case SFX_ITEM_DONTCARE: 2488 m_aOutlineBtn.SetState( STATE_DONTKNOW ); 2489 break; 2490 2491 case SFX_ITEM_DEFAULT: 2492 case SFX_ITEM_SET: 2493 { 2494 const SvxContourItem& rItem = (SvxContourItem&)rSet.Get( nWhich ); 2495 m_aOutlineBtn.SetState( (TriState)rItem.GetValue() ); 2496 m_aOutlineBtn.EnableTriState( sal_False ); 2497 break; 2498 } 2499 } 2500 2501 // Shadow 2502 nWhich = GetWhich( SID_ATTR_CHAR_SHADOWED ); 2503 eState = rSet.GetItemState( nWhich ); 2504 2505 switch ( eState ) 2506 { 2507 case SFX_ITEM_UNKNOWN: 2508 m_aShadowBtn.Hide(); 2509 break; 2510 2511 case SFX_ITEM_DISABLED: 2512 case SFX_ITEM_READONLY: 2513 m_aShadowBtn.Disable(); 2514 break; 2515 2516 case SFX_ITEM_DONTCARE: 2517 m_aShadowBtn.SetState( STATE_DONTKNOW ); 2518 break; 2519 2520 case SFX_ITEM_DEFAULT: 2521 case SFX_ITEM_SET: 2522 { 2523 const SvxShadowedItem& rItem = (SvxShadowedItem&)rSet.Get( nWhich ); 2524 m_aShadowBtn.SetState( (TriState)rItem.GetValue() ); 2525 m_aShadowBtn.EnableTriState( sal_False ); 2526 break; 2527 } 2528 } 2529 2530 // Blinking 2531 nWhich = GetWhich( SID_ATTR_FLASH ); 2532 eState = rSet.GetItemState( nWhich ); 2533 2534 switch ( eState ) 2535 { 2536 case SFX_ITEM_UNKNOWN: 2537 m_aBlinkingBtn.Hide(); 2538 break; 2539 2540 case SFX_ITEM_DISABLED: 2541 case SFX_ITEM_READONLY: 2542 m_aBlinkingBtn.Disable(); 2543 break; 2544 2545 case SFX_ITEM_DONTCARE: 2546 m_aBlinkingBtn.SetState( STATE_DONTKNOW ); 2547 break; 2548 2549 case SFX_ITEM_DEFAULT: 2550 case SFX_ITEM_SET: 2551 { 2552 const SvxBlinkItem& rItem = (SvxBlinkItem&)rSet.Get( nWhich ); 2553 m_aBlinkingBtn.SetState( (TriState)rItem.GetValue() ); 2554 m_aBlinkingBtn.EnableTriState( sal_False ); 2555 break; 2556 } 2557 } 2558 // Hidden 2559 nWhich = GetWhich( SID_ATTR_CHAR_HIDDEN ); 2560 eState = rSet.GetItemState( nWhich ); 2561 2562 switch ( eState ) 2563 { 2564 case SFX_ITEM_UNKNOWN: 2565 m_aHiddenBtn.Hide(); 2566 break; 2567 2568 case SFX_ITEM_DISABLED: 2569 case SFX_ITEM_READONLY: 2570 m_aHiddenBtn.Disable(); 2571 break; 2572 2573 case SFX_ITEM_DONTCARE: 2574 m_aHiddenBtn.SetState( STATE_DONTKNOW ); 2575 break; 2576 2577 case SFX_ITEM_DEFAULT: 2578 case SFX_ITEM_SET: 2579 { 2580 const SvxCharHiddenItem& rItem = (SvxCharHiddenItem&)rSet.Get( nWhich ); 2581 m_aHiddenBtn.SetState( (TriState)rItem.GetValue() ); 2582 m_aHiddenBtn.EnableTriState( sal_False ); 2583 break; 2584 } 2585 } 2586 2587 SetPrevFontWidthScale( rSet ); 2588 ResetColor_Impl( rSet ); 2589 2590 // preview update 2591 m_aPreviewWin.Invalidate(); 2592 2593 // save this settings 2594 m_aUnderlineLB.SaveValue(); 2595 m_aUnderlineColorLB.SaveValue(); 2596 m_aOverlineLB.SaveValue(); 2597 m_aOverlineColorLB.SaveValue(); 2598 m_aStrikeoutLB.SaveValue(); 2599 m_aIndividualWordsBtn.SaveValue(); 2600 m_aEmphasisLB.SaveValue(); 2601 m_aPositionLB.SaveValue(); 2602 m_aEffects2LB.SaveValue(); 2603 m_aReliefLB.SaveValue(); 2604 m_aOutlineBtn.SaveValue(); 2605 m_aShadowBtn.SaveValue(); 2606 m_aBlinkingBtn.SaveValue(); 2607 m_aHiddenBtn.SaveValue(); 2608 m_aFontColorLB.SaveValue(); 2609 } 2610 2611 // ----------------------------------------------------------------------- 2612 2613 sal_Bool SvxCharEffectsPage::FillItemSet( SfxItemSet& rSet ) 2614 { 2615 const SfxPoolItem* pOld = 0; 2616 const SfxItemSet& rOldSet = GetItemSet(); 2617 sal_Bool bModified = sal_False; 2618 FASTBOOL bChanged = sal_True; 2619 2620 // Underline 2621 sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_UNDERLINE ); 2622 pOld = GetOldItem( rSet, SID_ATTR_CHAR_UNDERLINE ); 2623 sal_uInt16 nPos = m_aUnderlineLB.GetSelectEntryPos(); 2624 FontUnderline eUnder = (FontUnderline)(sal_uLong)m_aUnderlineLB.GetEntryData( nPos ); 2625 2626 if ( pOld ) 2627 { 2628 //! if there are different underline styles in the selection the 2629 //! item-state in the 'rOldSet' will be invalid. In this case 2630 //! changing the underline style will be allowed if a style is 2631 //! selected in the listbox. 2632 sal_Bool bAllowChg = LISTBOX_ENTRY_NOTFOUND != nPos && 2633 SFX_ITEM_DEFAULT > rOldSet.GetItemState( nWhich, sal_True ); 2634 2635 const SvxUnderlineItem& rItem = *( (const SvxUnderlineItem*)pOld ); 2636 if ( (FontUnderline)rItem.GetValue() == eUnder && 2637 ( UNDERLINE_NONE == eUnder || rItem.GetColor() == m_aUnderlineColorLB.GetSelectEntryColor() ) && 2638 ! bAllowChg ) 2639 bChanged = sal_False; 2640 } 2641 2642 if ( bChanged ) 2643 { 2644 SvxUnderlineItem aNewItem( eUnder, nWhich ); 2645 aNewItem.SetColor( m_aUnderlineColorLB.GetSelectEntryColor() ); 2646 rSet.Put( aNewItem ); 2647 bModified |= sal_True; 2648 } 2649 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 2650 CLEARTITEM; 2651 2652 bChanged = sal_True; 2653 2654 // Overline 2655 nWhich = GetWhich( SID_ATTR_CHAR_OVERLINE ); 2656 pOld = GetOldItem( rSet, SID_ATTR_CHAR_OVERLINE ); 2657 nPos = m_aOverlineLB.GetSelectEntryPos(); 2658 FontUnderline eOver = (FontUnderline)(sal_uLong)m_aOverlineLB.GetEntryData( nPos ); 2659 2660 if ( pOld ) 2661 { 2662 //! if there are different underline styles in the selection the 2663 //! item-state in the 'rOldSet' will be invalid. In this case 2664 //! changing the underline style will be allowed if a style is 2665 //! selected in the listbox. 2666 sal_Bool bAllowChg = LISTBOX_ENTRY_NOTFOUND != nPos && 2667 SFX_ITEM_DEFAULT > rOldSet.GetItemState( nWhich, sal_True ); 2668 2669 const SvxOverlineItem& rItem = *( (const SvxOverlineItem*)pOld ); 2670 if ( (FontUnderline)rItem.GetValue() == eOver && 2671 ( UNDERLINE_NONE == eOver || rItem.GetColor() == m_aOverlineColorLB.GetSelectEntryColor() ) && 2672 ! bAllowChg ) 2673 bChanged = sal_False; 2674 } 2675 2676 if ( bChanged ) 2677 { 2678 SvxOverlineItem aNewItem( eOver, nWhich ); 2679 aNewItem.SetColor( m_aOverlineColorLB.GetSelectEntryColor() ); 2680 rSet.Put( aNewItem ); 2681 bModified |= sal_True; 2682 } 2683 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 2684 CLEARTITEM; 2685 2686 bChanged = sal_True; 2687 2688 // Strikeout 2689 nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT ); 2690 pOld = GetOldItem( rSet, SID_ATTR_CHAR_STRIKEOUT ); 2691 nPos = m_aStrikeoutLB.GetSelectEntryPos(); 2692 FontStrikeout eStrike = (FontStrikeout)(sal_uLong)m_aStrikeoutLB.GetEntryData( nPos ); 2693 2694 if ( pOld ) 2695 { 2696 //! if there are different strikeout styles in the selection the 2697 //! item-state in the 'rOldSet' will be invalid. In this case 2698 //! changing the strikeout style will be allowed if a style is 2699 //! selected in the listbox. 2700 sal_Bool bAllowChg = LISTBOX_ENTRY_NOTFOUND != nPos && 2701 SFX_ITEM_DEFAULT > rOldSet.GetItemState( nWhich, sal_True ); 2702 2703 const SvxCrossedOutItem& rItem = *( (const SvxCrossedOutItem*)pOld ); 2704 if ( !m_aStrikeoutLB.IsEnabled() 2705 || ((FontStrikeout)rItem.GetValue() == eStrike && !bAllowChg) ) 2706 bChanged = sal_False; 2707 } 2708 2709 if ( bChanged ) 2710 { 2711 rSet.Put( SvxCrossedOutItem( eStrike, nWhich ) ); 2712 bModified |= sal_True; 2713 } 2714 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 2715 CLEARTITEM; 2716 2717 bChanged = sal_True; 2718 2719 // Individual words 2720 nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE ); 2721 pOld = GetOldItem( rSet, SID_ATTR_CHAR_WORDLINEMODE ); 2722 2723 if ( pOld ) 2724 { 2725 const SvxWordLineModeItem& rItem = *( (const SvxWordLineModeItem*)pOld ); 2726 if ( rItem.GetValue() == m_aIndividualWordsBtn.IsChecked() ) 2727 bChanged = sal_False; 2728 } 2729 2730 if ( rOldSet.GetItemState( nWhich ) == SFX_ITEM_DONTCARE && 2731 m_aIndividualWordsBtn.IsChecked() == m_aIndividualWordsBtn.GetSavedValue() ) 2732 bChanged = sal_False; 2733 2734 if ( bChanged ) 2735 { 2736 rSet.Put( SvxWordLineModeItem( m_aIndividualWordsBtn.IsChecked(), nWhich ) ); 2737 bModified |= sal_True; 2738 } 2739 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 2740 CLEARTITEM; 2741 2742 bChanged = sal_True; 2743 2744 // Emphasis 2745 nWhich = GetWhich( SID_ATTR_CHAR_EMPHASISMARK ); 2746 pOld = GetOldItem( rSet, SID_ATTR_CHAR_EMPHASISMARK ); 2747 sal_uInt16 nMarkPos = m_aEmphasisLB.GetSelectEntryPos(); 2748 sal_uInt16 nPosPos = m_aPositionLB.GetSelectEntryPos(); 2749 FontEmphasisMark eMark = (FontEmphasisMark)nMarkPos; 2750 if ( m_aPositionLB.IsEnabled() ) 2751 { 2752 eMark |= ( CHRDLG_POSITION_UNDER == (sal_uLong)m_aPositionLB.GetEntryData( nPosPos ) ) 2753 ? EMPHASISMARK_POS_BELOW : EMPHASISMARK_POS_ABOVE; 2754 } 2755 2756 if ( pOld ) 2757 { 2758 if( rOldSet.GetItemState( nWhich ) != SFX_ITEM_DONTCARE ) 2759 { 2760 const SvxEmphasisMarkItem& rItem = *( (const SvxEmphasisMarkItem*)pOld ); 2761 if ( rItem.GetEmphasisMark() == eMark ) 2762 bChanged = sal_False; 2763 } 2764 } 2765 2766 if ( rOldSet.GetItemState( nWhich ) == SFX_ITEM_DONTCARE && 2767 m_aEmphasisLB.GetSavedValue() == nMarkPos && m_aPositionLB.GetSavedValue() == nPosPos ) 2768 bChanged = sal_False; 2769 2770 if ( bChanged ) 2771 { 2772 rSet.Put( SvxEmphasisMarkItem( eMark, nWhich ) ); 2773 bModified |= sal_True; 2774 } 2775 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 2776 CLEARTITEM; 2777 2778 bChanged = sal_True; 2779 2780 // Effects 2781 nWhich = GetWhich( SID_ATTR_CHAR_CASEMAP ); 2782 pOld = GetOldItem( rSet, SID_ATTR_CHAR_CASEMAP ); 2783 SvxCaseMap eCaseMap = SVX_CASEMAP_NOT_MAPPED; 2784 FASTBOOL bChecked = sal_False; 2785 sal_uInt16 nCapsPos = m_aEffects2LB.GetSelectEntryPos(); 2786 if ( nCapsPos != LISTBOX_ENTRY_NOTFOUND ) 2787 { 2788 eCaseMap = (SvxCaseMap)nCapsPos; 2789 bChecked = sal_True; 2790 } 2791 2792 if ( pOld ) 2793 { 2794 //! if there are different effect styles in the selection the 2795 //! item-state in the 'rOldSet' will be invalid. In this case 2796 //! changing the effect style will be allowed if a style is 2797 //! selected in the listbox. 2798 sal_Bool bAllowChg = LISTBOX_ENTRY_NOTFOUND != nPos && 2799 SFX_ITEM_DEFAULT > rOldSet.GetItemState( nWhich, sal_True ); 2800 2801 const SvxCaseMapItem& rItem = *( (const SvxCaseMapItem*)pOld ); 2802 if ( (SvxCaseMap)rItem.GetValue() == eCaseMap && !bAllowChg ) 2803 bChanged = sal_False; 2804 } 2805 2806 if ( bChanged && bChecked ) 2807 { 2808 rSet.Put( SvxCaseMapItem( eCaseMap, nWhich ) ); 2809 bModified |= sal_True; 2810 } 2811 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 2812 CLEARTITEM; 2813 2814 bChanged = sal_True; 2815 2816 //Relief 2817 nWhich = GetWhich(SID_ATTR_CHAR_RELIEF); 2818 if(m_aReliefLB.GetSelectEntryPos() != m_aReliefLB.GetSavedValue()) 2819 { 2820 m_aReliefLB.SaveValue(); 2821 SvxCharReliefItem aRelief((FontRelief)m_aReliefLB.GetSelectEntryPos(), nWhich); 2822 rSet.Put(aRelief); 2823 } 2824 2825 // Outline 2826 const SfxItemSet* pExampleSet = GetTabDialog() ? GetTabDialog()->GetExampleSet() : NULL; 2827 nWhich = GetWhich( SID_ATTR_CHAR_CONTOUR ); 2828 pOld = GetOldItem( rSet, SID_ATTR_CHAR_CONTOUR ); 2829 TriState eState = m_aOutlineBtn.GetState(); 2830 const SfxPoolItem* pItem; 2831 2832 if ( pOld ) 2833 { 2834 const SvxContourItem& rItem = *( (const SvxContourItem*)pOld ); 2835 if ( rItem.GetValue() == StateToAttr( eState ) && m_aOutlineBtn.GetSavedValue() == eState ) 2836 bChanged = sal_False; 2837 } 2838 2839 if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET && 2840 !StateToAttr( eState ) && ( (SvxContourItem*)pItem )->GetValue() ) 2841 bChanged = sal_True; 2842 2843 if ( bChanged && eState != STATE_DONTKNOW ) 2844 { 2845 rSet.Put( SvxContourItem( StateToAttr( eState ), nWhich ) ); 2846 bModified |= sal_True; 2847 } 2848 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 2849 CLEARTITEM; 2850 2851 bChanged = sal_True; 2852 2853 // Shadow 2854 nWhich = GetWhich( SID_ATTR_CHAR_SHADOWED ); 2855 pOld = GetOldItem( rSet, SID_ATTR_CHAR_SHADOWED ); 2856 eState = m_aShadowBtn.GetState(); 2857 2858 if ( pOld ) 2859 { 2860 const SvxShadowedItem& rItem = *( (const SvxShadowedItem*)pOld ); 2861 if ( rItem.GetValue() == StateToAttr( eState ) && m_aShadowBtn.GetSavedValue() == eState ) 2862 bChanged = sal_False; 2863 } 2864 2865 if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET && 2866 !StateToAttr( eState ) && ( (SvxShadowedItem*)pItem )->GetValue() ) 2867 bChanged = sal_True; 2868 2869 if ( bChanged && eState != STATE_DONTKNOW ) 2870 { 2871 rSet.Put( SvxShadowedItem( StateToAttr( eState ), nWhich ) ); 2872 bModified = sal_True; 2873 } 2874 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 2875 CLEARTITEM; 2876 2877 bChanged = sal_True; 2878 2879 // Blinking 2880 nWhich = GetWhich( SID_ATTR_FLASH ); 2881 pOld = GetOldItem( rSet, SID_ATTR_FLASH ); 2882 eState = m_aBlinkingBtn.GetState(); 2883 2884 if ( pOld ) 2885 { 2886 const SvxBlinkItem& rItem = *( (const SvxBlinkItem*)pOld ); 2887 if ( rItem.GetValue() == StateToAttr( eState ) && m_aBlinkingBtn.GetSavedValue() == eState ) 2888 bChanged = sal_False; 2889 } 2890 2891 if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET && 2892 !StateToAttr( eState ) && ( (SvxBlinkItem*)pItem )->GetValue() ) 2893 bChanged = sal_True; 2894 2895 if ( bChanged && eState != STATE_DONTKNOW ) 2896 { 2897 rSet.Put( SvxBlinkItem( StateToAttr( eState ), nWhich ) ); 2898 bModified = sal_True; 2899 } 2900 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 2901 CLEARTITEM; 2902 2903 // Hidden 2904 nWhich = GetWhich( SID_ATTR_CHAR_HIDDEN ); 2905 pOld = GetOldItem( rSet, SID_ATTR_CHAR_HIDDEN ); 2906 eState = m_aHiddenBtn.GetState(); 2907 bChanged = sal_True; 2908 2909 if ( pOld ) 2910 { 2911 const SvxCharHiddenItem& rItem = *( (const SvxCharHiddenItem*)pOld ); 2912 if ( rItem.GetValue() == StateToAttr( eState ) && m_aHiddenBtn.GetSavedValue() == eState ) 2913 bChanged = sal_False; 2914 } 2915 2916 if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, sal_False, &pItem ) == SFX_ITEM_SET && 2917 !StateToAttr( eState ) && ( (SvxCharHiddenItem*)pItem )->GetValue() ) 2918 bChanged = sal_True; 2919 2920 if ( bChanged && eState != STATE_DONTKNOW ) 2921 { 2922 rSet.Put( SvxCharHiddenItem( StateToAttr( eState ), nWhich ) ); 2923 bModified = sal_True; 2924 } 2925 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 2926 CLEARTITEM; 2927 2928 bModified |= FillItemSetColor_Impl( rSet ); 2929 2930 return bModified; 2931 } 2932 2933 void SvxCharEffectsPage::DisableControls( sal_uInt16 nDisable ) 2934 { 2935 if ( ( DISABLE_CASEMAP & nDisable ) == DISABLE_CASEMAP ) 2936 { 2937 m_aEffectsFT.Disable(); 2938 m_aEffects2LB.Disable(); 2939 } 2940 2941 if ( ( DISABLE_WORDLINE & nDisable ) == DISABLE_WORDLINE ) 2942 m_aIndividualWordsBtn.Disable(); 2943 2944 if ( ( DISABLE_BLINK & nDisable ) == DISABLE_BLINK ) 2945 m_aBlinkingBtn.Disable(); 2946 2947 if ( ( DISABLE_UNDERLINE_COLOR & nDisable ) == DISABLE_UNDERLINE_COLOR ) 2948 { 2949 // disable the controls 2950 m_aUnderlineColorFT.Disable( ); 2951 m_aUnderlineColorLB.Disable( ); 2952 // and reroute the selection handler of the controls which normally would affect the color box dis-/enabling 2953 m_aUnderlineLB.SetSelectHdl(LINK(this, SvxCharEffectsPage, UpdatePreview_Impl)); 2954 m_aStrikeoutLB.SetSelectHdl(LINK(this, SvxCharEffectsPage, UpdatePreview_Impl)); 2955 } 2956 } 2957 2958 void SvxCharEffectsPage::EnableFlash() 2959 { 2960 if ( !( ( m_nHtmlMode & HTMLMODE_ON ) && !( m_nHtmlMode & HTMLMODE_BLINK ) ) ) 2961 m_aBlinkingBtn.Show(); 2962 } 2963 2964 // ----------------------------------------------------------------------- 2965 void SvxCharEffectsPage::SetPreviewBackgroundToCharacter() 2966 { 2967 m_bPreviewBackgroundToCharacter = sal_True; 2968 } 2969 2970 // ----------------------------------------------------------------------- 2971 void SvxCharEffectsPage::PageCreated (SfxAllItemSet aSet) //add CHINA001 2972 { 2973 SFX_ITEMSET_ARG (&aSet,pDisableCtlItem,SfxUInt16Item,SID_DISABLE_CTL,sal_False); 2974 SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,sal_False); 2975 if (pDisableCtlItem) 2976 DisableControls(pDisableCtlItem->GetValue()); 2977 2978 if (pFlagItem) 2979 { 2980 sal_uInt32 nFlags=pFlagItem->GetValue(); 2981 if ( ( nFlags & SVX_ENABLE_FLASH ) == SVX_ENABLE_FLASH ) 2982 EnableFlash(); 2983 if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER ) 2984 SetPreviewBackgroundToCharacter(); 2985 } 2986 } 2987 2988 // class SvxCharPositionPage --------------------------------------------- 2989 2990 SvxCharPositionPage::SvxCharPositionPage( Window* pParent, const SfxItemSet& rInSet ) : 2991 2992 SvxCharBasePage( pParent, CUI_RES( RID_SVXPAGE_CHAR_POSITION ), rInSet, WIN_POS_PREVIEW, FT_POS_FONTTYPE ), 2993 2994 m_aPositionLine ( this, CUI_RES( FL_POSITION ) ), 2995 m_aHighPosBtn ( this, CUI_RES( RB_HIGHPOS ) ), 2996 m_aNormalPosBtn ( this, CUI_RES( RB_NORMALPOS ) ), 2997 m_aLowPosBtn ( this, CUI_RES( RB_LOWPOS ) ), 2998 m_aHighLowFT ( this, CUI_RES( FT_HIGHLOW ) ), 2999 m_aHighLowEdit ( this, CUI_RES( ED_HIGHLOW ) ), 3000 m_aHighLowRB ( this, CUI_RES( CB_HIGHLOW ) ), 3001 m_aFontSizeFT ( this, CUI_RES( FT_FONTSIZE ) ), 3002 m_aFontSizeEdit ( this, CUI_RES( ED_FONTSIZE ) ), 3003 m_aRotationScalingFL( this, CUI_RES( FL_ROTATION_SCALING ) ), 3004 m_aScalingFL ( this, CUI_RES( FL_SCALING ) ), 3005 m_a0degRB ( this, CUI_RES( RB_0_DEG ) ), 3006 m_a90degRB ( this, CUI_RES( RB_90_DEG ) ), 3007 m_a270degRB ( this, CUI_RES( RB_270_DEG ) ), 3008 m_aFitToLineCB ( this, CUI_RES( CB_FIT_TO_LINE ) ), 3009 m_aScaleWidthFT ( this, CUI_RES( FT_SCALE_WIDTH ) ), 3010 m_aScaleWidthMF ( this, CUI_RES( MF_SCALE_WIDTH ) ), 3011 3012 m_aKerningLine ( this, CUI_RES( FL_KERNING2 ) ), 3013 m_aKerningLB ( this, CUI_RES( LB_KERNING2 ) ), 3014 m_aKerningFT ( this, CUI_RES( FT_KERNING2 ) ), 3015 m_aKerningEdit ( this, CUI_RES( ED_KERNING2 ) ), 3016 m_aPairKerningBtn ( this, CUI_RES( CB_PAIRKERNING ) ), 3017 3018 m_nSuperEsc ( (short)DFLT_ESC_SUPER ), 3019 m_nSubEsc ( (short)DFLT_ESC_SUB ), 3020 m_nScaleWidthItemSetVal ( 100 ), 3021 m_nScaleWidthInitialVal ( 100 ), 3022 m_nSuperProp ( (sal_uInt8)DFLT_ESC_PROP ), 3023 m_nSubProp ( (sal_uInt8)DFLT_ESC_PROP ) 3024 { 3025 FreeResource(); 3026 Initialize(); 3027 } 3028 3029 // ----------------------------------------------------------------------- 3030 3031 void SvxCharPositionPage::Initialize() 3032 { 3033 // to handle the changes of the other pages 3034 SetExchangeSupport(); 3035 3036 GetPreviewFont().SetSize( Size( 0, 240 ) ); 3037 GetPreviewCJKFont().SetSize( Size( 0, 240 ) ); 3038 GetPreviewCTLFont().SetSize( Size( 0, 240 ) ); 3039 3040 m_aNormalPosBtn.Check(); 3041 PositionHdl_Impl( &m_aNormalPosBtn ); 3042 m_aKerningLB.SelectEntryPos( 0 ); 3043 KerningSelectHdl_Impl( NULL ); 3044 3045 Link aLink = LINK( this, SvxCharPositionPage, PositionHdl_Impl ); 3046 m_aHighPosBtn.SetClickHdl( aLink ); 3047 m_aNormalPosBtn.SetClickHdl( aLink ); 3048 m_aLowPosBtn.SetClickHdl( aLink ); 3049 3050 aLink = LINK( this, SvxCharPositionPage, RotationHdl_Impl ); 3051 m_a0degRB .SetClickHdl( aLink ); 3052 m_a90degRB .SetClickHdl( aLink ); 3053 m_a270degRB.SetClickHdl( aLink ); 3054 3055 aLink = LINK( this, SvxCharPositionPage, FontModifyHdl_Impl ); 3056 m_aHighLowEdit.SetModifyHdl( aLink ); 3057 m_aFontSizeEdit.SetModifyHdl( aLink ); 3058 3059 aLink = LINK( this, SvxCharPositionPage, LoseFocusHdl_Impl ); 3060 m_aHighLowEdit.SetLoseFocusHdl( aLink ); 3061 m_aFontSizeEdit.SetLoseFocusHdl( aLink ); 3062 3063 m_aHighLowRB.SetClickHdl( LINK( this, SvxCharPositionPage, AutoPositionHdl_Impl ) ); 3064 m_aFitToLineCB.SetClickHdl( LINK( this, SvxCharPositionPage, FitToLineHdl_Impl ) ); 3065 m_aKerningLB.SetSelectHdl( LINK( this, SvxCharPositionPage, KerningSelectHdl_Impl ) ); 3066 m_aKerningEdit.SetModifyHdl( LINK( this, SvxCharPositionPage, KerningModifyHdl_Impl ) ); 3067 m_aPairKerningBtn.SetClickHdl( LINK( this, SvxCharPositionPage, PairKerningHdl_Impl ) ); 3068 m_aScaleWidthMF.SetModifyHdl( LINK( this, SvxCharPositionPage, ScaleWidthModifyHdl_Impl ) ); 3069 } 3070 3071 // ----------------------------------------------------------------------- 3072 3073 void SvxCharPositionPage::UpdatePreview_Impl( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc ) 3074 { 3075 SetPrevFontEscapement( nProp, nEscProp, nEsc ); 3076 } 3077 3078 // ----------------------------------------------------------------------- 3079 3080 void SvxCharPositionPage::SetEscapement_Impl( sal_uInt16 nEsc ) 3081 { 3082 SvxEscapementItem aEscItm( (SvxEscapement)nEsc, SID_ATTR_CHAR_ESCAPEMENT ); 3083 3084 if ( SVX_ESCAPEMENT_SUPERSCRIPT == nEsc ) 3085 { 3086 aEscItm.GetEsc() = m_nSuperEsc; 3087 aEscItm.GetProp() = m_nSuperProp; 3088 } 3089 else if ( SVX_ESCAPEMENT_SUBSCRIPT == nEsc ) 3090 { 3091 aEscItm.GetEsc() = m_nSubEsc; 3092 aEscItm.GetProp() = m_nSubProp; 3093 } 3094 3095 short nFac = aEscItm.GetEsc() < 0 ? -1 : 1; 3096 3097 m_aHighLowEdit.SetValue( aEscItm.GetEsc() * nFac ); 3098 m_aFontSizeEdit.SetValue( aEscItm.GetProp() ); 3099 3100 if ( SVX_ESCAPEMENT_OFF == nEsc ) 3101 { 3102 m_aHighLowFT.Disable(); 3103 m_aHighLowEdit.Disable(); 3104 m_aFontSizeFT.Disable(); 3105 m_aFontSizeEdit.Disable(); 3106 m_aHighLowRB.Disable(); 3107 } 3108 else 3109 { 3110 m_aFontSizeFT.Enable(); 3111 m_aFontSizeEdit.Enable(); 3112 m_aHighLowRB.Enable(); 3113 3114 if ( !m_aHighLowRB.IsChecked() ) 3115 { 3116 m_aHighLowFT.Enable(); 3117 m_aHighLowEdit.Enable(); 3118 } 3119 else 3120 AutoPositionHdl_Impl( &m_aHighLowRB ); 3121 } 3122 3123 UpdatePreview_Impl( 100, aEscItm.GetProp(), aEscItm.GetEsc() ); 3124 } 3125 3126 // ----------------------------------------------------------------------- 3127 3128 IMPL_LINK( SvxCharPositionPage, PositionHdl_Impl, RadioButton*, pBtn ) 3129 { 3130 sal_uInt16 nEsc = SVX_ESCAPEMENT_OFF; // also when pBtn == NULL 3131 3132 if ( &m_aHighPosBtn == pBtn ) 3133 nEsc = SVX_ESCAPEMENT_SUPERSCRIPT; 3134 else if ( &m_aLowPosBtn == pBtn ) 3135 nEsc = SVX_ESCAPEMENT_SUBSCRIPT; 3136 3137 SetEscapement_Impl( nEsc ); 3138 return 0; 3139 } 3140 3141 // ----------------------------------------------------------------------- 3142 3143 IMPL_LINK( SvxCharPositionPage, RotationHdl_Impl, RadioButton*, pBtn ) 3144 { 3145 sal_Bool bEnable = sal_False; 3146 if (&m_a90degRB == pBtn || &m_a270degRB == pBtn) 3147 bEnable = sal_True; 3148 else 3149 OSL_ENSURE( &m_a0degRB == pBtn, "unexpected button" ); 3150 m_aFitToLineCB.Enable( bEnable ); 3151 return 0; 3152 } 3153 3154 // ----------------------------------------------------------------------- 3155 3156 IMPL_LINK( SvxCharPositionPage, FontModifyHdl_Impl, MetricField*, EMPTYARG ) 3157 { 3158 sal_uInt8 nEscProp = (sal_uInt8)m_aFontSizeEdit.GetValue(); 3159 short nEsc = (short)m_aHighLowEdit.GetValue(); 3160 nEsc *= m_aLowPosBtn.IsChecked() ? -1 : 1; 3161 UpdatePreview_Impl( 100, nEscProp, nEsc ); 3162 return 0; 3163 } 3164 3165 // ----------------------------------------------------------------------- 3166 3167 IMPL_LINK( SvxCharPositionPage, AutoPositionHdl_Impl, CheckBox*, pBox ) 3168 { 3169 if ( pBox->IsChecked() ) 3170 { 3171 m_aHighLowFT.Disable(); 3172 m_aHighLowEdit.Disable(); 3173 } 3174 else 3175 PositionHdl_Impl( m_aHighPosBtn.IsChecked() ? &m_aHighPosBtn 3176 : m_aLowPosBtn.IsChecked() ? &m_aLowPosBtn 3177 : &m_aNormalPosBtn ); 3178 return 0; 3179 } 3180 3181 // ----------------------------------------------------------------------- 3182 3183 IMPL_LINK( SvxCharPositionPage, FitToLineHdl_Impl, CheckBox*, pBox ) 3184 { 3185 if ( &m_aFitToLineCB == pBox) 3186 { 3187 sal_uInt16 nVal = m_nScaleWidthInitialVal; 3188 if (m_aFitToLineCB.IsChecked()) 3189 nVal = m_nScaleWidthItemSetVal; 3190 m_aScaleWidthMF.SetValue( nVal ); 3191 3192 m_aPreviewWin.SetFontWidthScale( nVal ); 3193 } 3194 return 0; 3195 } 3196 3197 // ----------------------------------------------------------------------- 3198 3199 IMPL_LINK( SvxCharPositionPage, KerningSelectHdl_Impl, ListBox*, EMPTYARG ) 3200 { 3201 if ( m_aKerningLB.GetSelectEntryPos() > 0 ) 3202 { 3203 m_aKerningFT.Enable(); 3204 m_aKerningEdit.Enable(); 3205 3206 if ( m_aKerningLB.GetSelectEntryPos() == 2 ) 3207 { 3208 // Condensed -> max value == 1/6 of the current font height 3209 SvxFont& rFont = GetPreviewFont(); 3210 long nMax = rFont.GetSize().Height() / 6; 3211 m_aKerningEdit.SetMax( m_aKerningEdit.Normalize( nMax ), FUNIT_TWIP ); 3212 m_aKerningEdit.SetLast( m_aKerningEdit.GetMax( m_aKerningEdit.GetUnit() ) ); 3213 } 3214 else 3215 { 3216 m_aKerningEdit.SetMax( 9999 ); 3217 m_aKerningEdit.SetLast( 9999 ); 3218 } 3219 } 3220 else 3221 { 3222 m_aKerningEdit.SetValue( 0 ); 3223 m_aKerningFT.Disable(); 3224 m_aKerningEdit.Disable(); 3225 } 3226 3227 KerningModifyHdl_Impl( NULL ); 3228 3229 return 0; 3230 } 3231 3232 // ----------------------------------------------------------------------- 3233 3234 IMPL_LINK( SvxCharPositionPage, KerningModifyHdl_Impl, MetricField*, EMPTYARG ) 3235 { 3236 long nVal = static_cast<long>(m_aKerningEdit.GetValue()); 3237 nVal = LogicToLogic( nVal, MAP_POINT, MAP_TWIP ); 3238 long nKern = (short)m_aKerningEdit.Denormalize( nVal ); 3239 3240 // Condensed? -> then negative 3241 if ( m_aKerningLB.GetSelectEntryPos() == 2 ) 3242 nKern *= -1; 3243 3244 SvxFont& rFont = GetPreviewFont(); 3245 SvxFont& rCJKFont = GetPreviewCJKFont(); 3246 SvxFont& rCTLFont = GetPreviewCTLFont(); 3247 3248 rFont.SetFixKerning( (short)nKern ); 3249 rCJKFont.SetFixKerning( (short)nKern ); 3250 rCTLFont.SetFixKerning( (short)nKern ); 3251 m_aPreviewWin.Invalidate(); 3252 return 0; 3253 } 3254 3255 // ----------------------------------------------------------------------- 3256 3257 IMPL_LINK( SvxCharPositionPage, PairKerningHdl_Impl, CheckBox*, EMPTYARG ) 3258 { 3259 return 0; 3260 } 3261 3262 // ----------------------------------------------------------------------- 3263 3264 IMPL_LINK( SvxCharPositionPage, LoseFocusHdl_Impl, MetricField*, pField ) 3265 { 3266 #ifdef DBG_UTIL 3267 sal_Bool bHigh = m_aHighPosBtn.IsChecked(); 3268 #endif 3269 sal_Bool bLow = m_aLowPosBtn.IsChecked(); 3270 DBG_ASSERT( bHigh || bLow, "normal position is not valid" ); 3271 3272 if ( &m_aHighLowEdit == pField ) 3273 { 3274 if ( bLow ) 3275 m_nSubEsc = (short)m_aHighLowEdit.GetValue() * -1; 3276 else 3277 m_nSuperEsc = (short)m_aHighLowEdit.GetValue(); 3278 } 3279 else if ( &m_aFontSizeEdit == pField ) 3280 { 3281 if ( bLow ) 3282 m_nSubProp = (sal_uInt8)m_aFontSizeEdit.GetValue(); 3283 else 3284 m_nSuperProp = (sal_uInt8)m_aFontSizeEdit.GetValue(); 3285 } 3286 return 0; 3287 } 3288 3289 // ----------------------------------------------------------------------- 3290 3291 IMPL_LINK( SvxCharPositionPage, ScaleWidthModifyHdl_Impl, MetricField*, EMPTYARG ) 3292 { 3293 m_aPreviewWin.SetFontWidthScale( sal_uInt16( m_aScaleWidthMF.GetValue() ) ); 3294 3295 return 0; 3296 } 3297 3298 /* -----------------28.08.2003 12:12----------------- 3299 3300 --------------------------------------------------*/ 3301 void SvxCharPositionPage::ActivatePage( const SfxItemSet& rSet ) 3302 { 3303 //update the preview 3304 SvxCharBasePage::ActivatePage( rSet ); 3305 3306 //the only thing that has to be checked is the max. allowed value for the 3307 //condense edit field 3308 if ( m_aKerningLB.GetSelectEntryPos() == 2 ) 3309 { 3310 // Condensed -> max value == 1/6 of the current font height 3311 SvxFont& rFont = GetPreviewFont(); 3312 long nMax = rFont.GetSize().Height() / 6; 3313 long nKern = (short)m_aKerningEdit.Denormalize( LogicToLogic( static_cast<long>(m_aKerningEdit.GetValue()), MAP_POINT, MAP_TWIP ) ); 3314 m_aKerningEdit.SetMax( m_aKerningEdit.Normalize( nKern > nMax ? nKern : nMax ), FUNIT_TWIP ); 3315 m_aKerningEdit.SetLast( m_aKerningEdit.GetMax( m_aKerningEdit.GetUnit() ) ); 3316 } 3317 } 3318 3319 // ----------------------------------------------------------------------- 3320 3321 int SvxCharPositionPage::DeactivatePage( SfxItemSet* _pSet ) 3322 { 3323 if ( _pSet ) 3324 FillItemSet( *_pSet ); 3325 return LEAVE_PAGE; 3326 } 3327 3328 // ----------------------------------------------------------------------- 3329 3330 SfxTabPage* SvxCharPositionPage::Create( Window* pParent, const SfxItemSet& rSet ) 3331 { 3332 return new SvxCharPositionPage( pParent, rSet ); 3333 } 3334 3335 // ----------------------------------------------------------------------- 3336 3337 sal_uInt16* SvxCharPositionPage::GetRanges() 3338 { 3339 return pPositionRanges; 3340 } 3341 3342 // ----------------------------------------------------------------------- 3343 void SvxCharPositionPage::Reset( const SfxItemSet& rSet ) 3344 { 3345 String sUser = GetUserData(); 3346 3347 if ( sUser.Len() ) 3348 { 3349 m_nSuperEsc = (short)sUser.GetToken( 0 ).ToInt32(); 3350 m_nSubEsc = (short)sUser.GetToken( 1 ).ToInt32(); 3351 m_nSuperProp = (sal_uInt8)sUser.GetToken( 2 ).ToInt32(); 3352 m_nSubProp = (sal_uInt8)sUser.GetToken( 3 ).ToInt32(); 3353 } 3354 3355 short nEsc = 0; 3356 sal_uInt8 nEscProp = 100; 3357 sal_uInt8 nProp = 100; 3358 3359 m_aHighLowFT.Disable(); 3360 m_aHighLowEdit.Disable(); 3361 m_aFontSizeFT.Disable(); 3362 m_aFontSizeEdit.Disable(); 3363 3364 SvxFont& rFont = GetPreviewFont(); 3365 SvxFont& rCJKFont = GetPreviewCJKFont(); 3366 SvxFont& rCTLFont = GetPreviewCTLFont(); 3367 sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_ESCAPEMENT ); 3368 3369 if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT ) 3370 { 3371 const SvxEscapementItem& rItem = (SvxEscapementItem&)rSet.Get( nWhich ); 3372 nEsc = rItem.GetEsc(); 3373 nEscProp = rItem.GetProp(); 3374 3375 if ( nEsc != 0 ) 3376 { 3377 m_aHighLowFT.Enable(); 3378 m_aHighLowEdit.Enable(); 3379 m_aFontSizeFT.Enable(); 3380 m_aFontSizeEdit.Enable(); 3381 3382 short nFac; 3383 sal_Bool bAutomatic(sal_False); 3384 3385 if ( nEsc > 0 ) 3386 { 3387 nFac = 1; 3388 m_aHighPosBtn.Check( sal_True ); 3389 if ( nEsc == DFLT_ESC_AUTO_SUPER ) 3390 { 3391 nEsc = DFLT_ESC_SUPER; 3392 bAutomatic = sal_True; 3393 } 3394 } 3395 else 3396 { 3397 nFac = -1; 3398 m_aLowPosBtn.Check( sal_True ); 3399 if ( nEsc == DFLT_ESC_AUTO_SUB ) 3400 { 3401 nEsc = DFLT_ESC_SUB; 3402 bAutomatic = sal_True; 3403 } 3404 } 3405 if (!m_aHighLowRB.IsEnabled()) 3406 { 3407 m_aHighLowRB.Enable(); 3408 } 3409 m_aHighLowRB.Check(bAutomatic); 3410 3411 if ( m_aHighLowRB.IsChecked() ) 3412 { 3413 m_aHighLowFT.Disable(); 3414 m_aHighLowEdit.Disable(); 3415 } 3416 m_aHighLowEdit.SetValue( m_aHighLowEdit.Normalize( nFac * nEsc ) ); 3417 } 3418 else 3419 { 3420 m_aNormalPosBtn.Check( sal_True ); 3421 m_aHighLowRB.Check( sal_True ); 3422 PositionHdl_Impl( NULL ); 3423 } 3424 //the height has to be set after the handler is called to keep the value also if the escapement is zero 3425 m_aFontSizeEdit.SetValue( m_aFontSizeEdit.Normalize( nEscProp ) ); 3426 } 3427 else 3428 { 3429 m_aHighPosBtn.Check( sal_False ); 3430 m_aNormalPosBtn.Check( sal_False ); 3431 m_aLowPosBtn.Check( sal_False ); 3432 } 3433 3434 // BspFont setzen 3435 SetPrevFontEscapement( nProp, nEscProp, nEsc ); 3436 3437 // Kerning 3438 nWhich = GetWhich( SID_ATTR_CHAR_KERNING ); 3439 3440 if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT ) 3441 { 3442 const SvxKerningItem& rItem = (SvxKerningItem&)rSet.Get( nWhich ); 3443 SfxMapUnit eUnit = rSet.GetPool()->GetMetric( nWhich ); 3444 MapUnit eOrgUnit = (MapUnit)eUnit; 3445 MapUnit ePntUnit( MAP_POINT ); 3446 long nBig = static_cast<long>(m_aKerningEdit.Normalize( static_cast<long>(rItem.GetValue()) )); 3447 long nKerning = LogicToLogic( nBig, eOrgUnit, ePntUnit ); 3448 3449 // Kerning am Font setzen, vorher in Twips umrechnen 3450 long nKern = LogicToLogic( rItem.GetValue(), (MapUnit)eUnit, MAP_TWIP ); 3451 rFont.SetFixKerning( (short)nKern ); 3452 rCJKFont.SetFixKerning( (short)nKern ); 3453 rCTLFont.SetFixKerning( (short)nKern ); 3454 3455 if ( nKerning > 0 ) 3456 { 3457 m_aKerningLB.SelectEntryPos( LW_GESPERRT ); 3458 } 3459 else if ( nKerning < 0 ) 3460 { 3461 m_aKerningLB.SelectEntryPos( LW_SCHMAL ); 3462 nKerning = -nKerning; 3463 } 3464 else 3465 { 3466 nKerning = 0; 3467 m_aKerningLB.SelectEntryPos( LW_NORMAL ); 3468 } 3469 //enable/disable and set min/max of the Edit 3470 KerningSelectHdl_Impl(&m_aKerningLB); 3471 //the attribute value must be displayed also if it's above the maximum allowed value 3472 long nVal = static_cast<long>(m_aKerningEdit.GetMax()); 3473 if(nVal < nKerning) 3474 m_aKerningEdit.SetMax( nKerning ); 3475 m_aKerningEdit.SetValue( nKerning ); 3476 } 3477 else 3478 m_aKerningEdit.SetText( String() ); 3479 3480 // Pair kerning 3481 nWhich = GetWhich( SID_ATTR_CHAR_AUTOKERN ); 3482 3483 if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT ) 3484 { 3485 const SvxAutoKernItem& rItem = (SvxAutoKernItem&)rSet.Get( nWhich ); 3486 m_aPairKerningBtn.Check( rItem.GetValue() ); 3487 } 3488 else 3489 m_aPairKerningBtn.Check( sal_False ); 3490 3491 // Scale Width 3492 nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH ); 3493 if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT ) 3494 { 3495 const SvxCharScaleWidthItem& rItem = ( SvxCharScaleWidthItem& ) rSet.Get( nWhich ); 3496 m_nScaleWidthInitialVal = rItem.GetValue(); 3497 m_aScaleWidthMF.SetValue( m_nScaleWidthInitialVal ); 3498 } 3499 else 3500 m_aScaleWidthMF.SetValue( 100 ); 3501 3502 nWhich = GetWhich( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE ); 3503 if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_DEFAULT ) 3504 m_nScaleWidthItemSetVal = ((SfxUInt16Item&) rSet.Get( nWhich )).GetValue(); 3505 3506 // Rotation 3507 nWhich = GetWhich( SID_ATTR_CHAR_ROTATED ); 3508 SfxItemState eState = rSet.GetItemState( nWhich ); 3509 if( SFX_ITEM_UNKNOWN == eState ) 3510 { 3511 m_aRotationScalingFL.Hide(); 3512 m_aScalingFL.Show(); 3513 m_a0degRB.Hide(); 3514 m_a90degRB.Hide(); 3515 m_a270degRB.Hide(); 3516 m_aFitToLineCB.Hide(); 3517 m_aFitToLineCB .Hide(); 3518 3519 3520 // move the following controls upwards 3521 Window* aCntrlArr[] = { 3522 &m_aScaleWidthFT, &m_aScaleWidthMF, &m_aKerningLine, 3523 &m_aKerningLB, &m_aKerningFT, &m_aKerningEdit, &m_aPairKerningBtn, 3524 0 }; 3525 3526 long nDiff = m_aScaleWidthMF.GetPosPixel().Y() - 3527 m_a0degRB.GetPosPixel().Y(); 3528 3529 for( Window** ppW = aCntrlArr; *ppW; ++ppW ) 3530 { 3531 Point aPnt( (*ppW)->GetPosPixel() ); 3532 aPnt.Y() -= nDiff; 3533 (*ppW)->SetPosPixel( aPnt ); 3534 } 3535 } 3536 else 3537 { 3538 m_aScalingFL.Hide(); 3539 3540 Link aOldLink( m_aFitToLineCB.GetClickHdl() ); 3541 m_aFitToLineCB.SetClickHdl( Link() ); 3542 if( eState >= SFX_ITEM_DEFAULT ) 3543 { 3544 const SvxCharRotateItem& rItem = 3545 (SvxCharRotateItem&) rSet.Get( nWhich ); 3546 if (rItem.IsBottomToTop()) 3547 m_a90degRB.Check( sal_True ); 3548 else if (rItem.IsTopToBotton()) 3549 m_a270degRB.Check( sal_True ); 3550 else 3551 { 3552 DBG_ASSERT( 0 == rItem.GetValue(), "incorrect value" ); 3553 m_a0degRB.Check( sal_True ); 3554 } 3555 m_aFitToLineCB.Check( rItem.IsFitToLine() ); 3556 } 3557 else 3558 { 3559 if( eState == SFX_ITEM_DONTCARE ) 3560 { 3561 m_a0degRB.Check( sal_False ); 3562 m_a90degRB.Check( sal_False ); 3563 m_a270degRB.Check( sal_False ); 3564 } 3565 else 3566 m_a0degRB.Check( sal_True ); 3567 3568 m_aFitToLineCB.Check( sal_False ); 3569 } 3570 m_aFitToLineCB.SetClickHdl( aOldLink ); 3571 m_aFitToLineCB.Enable( !m_a0degRB.IsChecked() ); 3572 3573 // is this value set? 3574 if( SFX_ITEM_UNKNOWN == rSet.GetItemState( GetWhich( 3575 SID_ATTR_CHAR_WIDTH_FIT_TO_LINE ) )) 3576 m_aFitToLineCB.Hide(); 3577 } 3578 3579 m_aHighPosBtn.SaveValue(); 3580 m_aNormalPosBtn.SaveValue(); 3581 m_aLowPosBtn.SaveValue(); 3582 m_a0degRB.SaveValue(); 3583 m_a90degRB.SaveValue(); 3584 m_a270degRB.SaveValue(); 3585 m_aFitToLineCB.SaveValue(); 3586 m_aScaleWidthMF.SaveValue(); 3587 m_aKerningLB.SaveValue(); 3588 m_aKerningEdit.SaveValue(); 3589 m_aPairKerningBtn.SaveValue(); 3590 } 3591 3592 // ----------------------------------------------------------------------- 3593 3594 sal_Bool SvxCharPositionPage::FillItemSet( SfxItemSet& rSet ) 3595 { 3596 // Position (hoch, normal oder tief) 3597 const SfxItemSet& rOldSet = GetItemSet(); 3598 sal_Bool bModified = sal_False, bChanged = sal_True; 3599 sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_ESCAPEMENT ); 3600 const SfxPoolItem* pOld = GetOldItem( rSet, SID_ATTR_CHAR_ESCAPEMENT ); 3601 const FASTBOOL bHigh = m_aHighPosBtn.IsChecked(); 3602 short nEsc; 3603 sal_uInt8 nEscProp; 3604 3605 if ( bHigh || m_aLowPosBtn.IsChecked() ) 3606 { 3607 if ( m_aHighLowRB.IsChecked() ) 3608 nEsc = bHigh ? DFLT_ESC_AUTO_SUPER : DFLT_ESC_AUTO_SUB; 3609 else 3610 { 3611 nEsc = (short)m_aHighLowEdit.Denormalize( m_aHighLowEdit.GetValue() ); 3612 nEsc *= bHigh ? 1 : -1; 3613 } 3614 nEscProp = (sal_uInt8)m_aFontSizeEdit.Denormalize( m_aFontSizeEdit.GetValue() ); 3615 } 3616 else 3617 { 3618 nEsc = 0; 3619 nEscProp = 100; 3620 } 3621 3622 if ( pOld ) 3623 { 3624 const SvxEscapementItem& rItem = *( (const SvxEscapementItem*)pOld ); 3625 if ( rItem.GetEsc() == nEsc && rItem.GetProp() == nEscProp ) 3626 bChanged = sal_False; 3627 } 3628 3629 if ( !bChanged && !m_aHighPosBtn.GetSavedValue() && 3630 !m_aNormalPosBtn.GetSavedValue() && !m_aLowPosBtn.GetSavedValue() ) 3631 bChanged = sal_True; 3632 3633 if ( bChanged && 3634 ( m_aHighPosBtn.IsChecked() || m_aNormalPosBtn.IsChecked() || m_aLowPosBtn.IsChecked() ) ) 3635 { 3636 rSet.Put( SvxEscapementItem( nEsc, nEscProp, nWhich ) ); 3637 bModified = sal_True; 3638 } 3639 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 3640 CLEARTITEM; 3641 3642 bChanged = sal_True; 3643 3644 // Kerning 3645 nWhich = GetWhich( SID_ATTR_CHAR_KERNING ); 3646 pOld = GetOldItem( rSet, SID_ATTR_CHAR_KERNING ); 3647 sal_uInt16 nPos = m_aKerningLB.GetSelectEntryPos(); 3648 short nKerning = 0; 3649 SfxMapUnit eUnit = rSet.GetPool()->GetMetric( nWhich ); 3650 3651 if ( nPos == LW_GESPERRT || nPos == LW_SCHMAL ) 3652 { 3653 long nTmp = static_cast<long>(m_aKerningEdit.GetValue()); 3654 long nVal = LogicToLogic( nTmp, MAP_POINT, (MapUnit)eUnit ); 3655 nKerning = (short)m_aKerningEdit.Denormalize( nVal ); 3656 3657 if ( nPos == LW_SCHMAL ) 3658 nKerning *= - 1; 3659 } 3660 3661 if ( pOld ) 3662 { 3663 const SvxKerningItem& rItem = *( (const SvxKerningItem*)pOld ); 3664 if ( rItem.GetValue() == nKerning ) 3665 bChanged = sal_False; 3666 } 3667 3668 if ( !bChanged && 3669 ( m_aKerningLB.GetSavedValue() == LISTBOX_ENTRY_NOTFOUND || 3670 ( !m_aKerningEdit.GetSavedValue().Len() && m_aKerningEdit.IsEnabled() ) ) ) 3671 bChanged = sal_True; 3672 3673 if ( bChanged && nPos != LISTBOX_ENTRY_NOTFOUND ) 3674 { 3675 rSet.Put( SvxKerningItem( nKerning, nWhich ) ); 3676 bModified |= sal_True; 3677 } 3678 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 3679 CLEARTITEM; 3680 3681 bChanged = sal_True; 3682 3683 // Pair-Kerning 3684 nWhich = GetWhich( SID_ATTR_CHAR_AUTOKERN ); 3685 3686 if ( m_aPairKerningBtn.IsChecked() != m_aPairKerningBtn.GetSavedValue() ) 3687 { 3688 rSet.Put( SvxAutoKernItem( m_aPairKerningBtn.IsChecked(), nWhich ) ); 3689 bModified |= sal_True; 3690 } 3691 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 3692 CLEARTITEM; 3693 3694 // Scale Width 3695 nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH ); 3696 if ( m_aScaleWidthMF.GetText() != m_aScaleWidthMF.GetSavedValue() ) 3697 { 3698 rSet.Put( SvxCharScaleWidthItem( (sal_uInt16)m_aScaleWidthMF.GetValue(), nWhich ) ); 3699 bModified |= sal_True; 3700 } 3701 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 3702 CLEARTITEM; 3703 3704 // Rotation 3705 nWhich = GetWhich( SID_ATTR_CHAR_ROTATED ); 3706 if ( m_a0degRB .IsChecked() != m_a0degRB .GetSavedValue() || 3707 m_a90degRB .IsChecked() != m_a90degRB .GetSavedValue() || 3708 m_a270degRB .IsChecked() != m_a270degRB .GetSavedValue() || 3709 m_aFitToLineCB.IsChecked() != m_aFitToLineCB.GetSavedValue() ) 3710 { 3711 SvxCharRotateItem aItem( 0, m_aFitToLineCB.IsChecked(), nWhich ); 3712 if (m_a90degRB.IsChecked()) 3713 aItem.SetBottomToTop(); 3714 else if (m_a270degRB.IsChecked()) 3715 aItem.SetTopToBotton(); 3716 rSet.Put( aItem ); 3717 bModified |= sal_True; 3718 } 3719 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 3720 CLEARTITEM; 3721 3722 return bModified; 3723 } 3724 3725 // ----------------------------------------------------------------------- 3726 3727 void SvxCharPositionPage::FillUserData() 3728 { 3729 const sal_Unicode cTok = ';'; 3730 3731 String sUser( UniString::CreateFromInt32( m_nSuperEsc ) ); 3732 sUser.Append( cTok ); 3733 sUser.Append( UniString::CreateFromInt32( m_nSubEsc ) ); 3734 sUser.Append( cTok ); 3735 sUser.Append( UniString::CreateFromInt32( m_nSuperProp ) ); 3736 sUser.Append( cTok ); 3737 sUser.Append( UniString::CreateFromInt32( m_nSubProp ) ); 3738 SetUserData( sUser ); 3739 } 3740 3741 // ----------------------------------------------------------------------- 3742 void SvxCharPositionPage::SetPreviewBackgroundToCharacter() 3743 { 3744 m_bPreviewBackgroundToCharacter = sal_True; 3745 } 3746 // ----------------------------------------------------------------------- 3747 void SvxCharPositionPage::PageCreated (SfxAllItemSet aSet) //add CHINA001 3748 { 3749 SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,sal_False); 3750 if (pFlagItem) 3751 { 3752 sal_uInt32 nFlags=pFlagItem->GetValue(); 3753 if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER ) 3754 SetPreviewBackgroundToCharacter(); 3755 } 3756 } 3757 // class SvxCharTwoLinesPage ------------------------------------------------ 3758 3759 SvxCharTwoLinesPage::SvxCharTwoLinesPage( Window* pParent, const SfxItemSet& rInSet ) : 3760 3761 SvxCharBasePage( pParent, CUI_RES( RID_SVXPAGE_CHAR_TWOLINES ), rInSet, WIN_TWOLINES_PREVIEW, FT_TWOLINES_FONTTYPE ), 3762 3763 m_aSwitchOnLine ( this, CUI_RES( FL_SWITCHON ) ), 3764 m_aTwoLinesBtn ( this, CUI_RES( CB_TWOLINES ) ), 3765 3766 m_aEncloseLine ( this, CUI_RES( FL_ENCLOSE ) ), 3767 m_aStartBracketFT ( this, CUI_RES( FT_STARTBRACKET ) ), 3768 m_aStartBracketLB ( this, CUI_RES( ED_STARTBRACKET ) ), 3769 m_aEndBracketFT ( this, CUI_RES( FT_ENDBRACKET ) ), 3770 m_aEndBracketLB ( this, CUI_RES( ED_ENDBRACKET ) ), 3771 m_nStartBracketPosition( 0 ), 3772 m_nEndBracketPosition( 0 ) 3773 { 3774 FreeResource(); 3775 Initialize(); 3776 } 3777 3778 // ----------------------------------------------------------------------- 3779 3780 void SvxCharTwoLinesPage::Initialize() 3781 { 3782 Size aSize = m_aStartBracketLB.GetSizePixel(); 3783 aSize.Height() = m_aStartBracketLB.CalcSize( 1, 6 ).Height(); 3784 m_aStartBracketLB.SetSizePixel( aSize ); 3785 aSize = m_aEndBracketLB.GetSizePixel(); 3786 aSize.Height() = m_aEndBracketLB.CalcSize( 1, 6 ).Height(); 3787 m_aEndBracketLB.SetSizePixel( aSize ); 3788 3789 m_aTwoLinesBtn.Check( sal_False ); 3790 TwoLinesHdl_Impl( NULL ); 3791 3792 m_aTwoLinesBtn.SetClickHdl( LINK( this, SvxCharTwoLinesPage, TwoLinesHdl_Impl ) ); 3793 3794 Link aLink = LINK( this, SvxCharTwoLinesPage, CharacterMapHdl_Impl ); 3795 m_aStartBracketLB.SetSelectHdl( aLink ); 3796 m_aEndBracketLB.SetSelectHdl( aLink ); 3797 3798 SvxFont& rFont = GetPreviewFont(); 3799 SvxFont& rCJKFont = GetPreviewCJKFont(); 3800 SvxFont& rCTLFont = GetPreviewCTLFont(); 3801 rFont.SetSize( Size( 0, 220 ) ); 3802 rCJKFont.SetSize( Size( 0, 220 ) ); 3803 rCTLFont.SetSize( Size( 0, 220 ) ); 3804 } 3805 3806 // ----------------------------------------------------------------------- 3807 3808 void SvxCharTwoLinesPage::SelectCharacter( ListBox* pBox ) 3809 { 3810 //CHINA001 SvxCharacterMap aDlg( this ); 3811 bool bStart = pBox == &m_aStartBracketLB; 3812 //SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 3813 //if(pFact) 3814 { 3815 //AbstractSvxCharacterMap* aDlg = pFact->CreateSvxCharacterMap( this, RID_SVXDLG_CHARMAP ); 3816 SvxCharacterMap* aDlg = new SvxCharacterMap( this ); 3817 aDlg->DisableFontSelection();//CHINA001 aDlg.DisableFontSelection(); 3818 3819 if ( aDlg->Execute() == RET_OK )//CHINA001 ( aDlg.Execute() == RET_OK ) 3820 { 3821 sal_Unicode cChar = (sal_Unicode) aDlg->GetChar();//CHINA001 aDlg.GetChar(); 3822 SetBracket( cChar, bStart ); 3823 } 3824 else 3825 { 3826 pBox->SelectEntryPos( bStart ? m_nStartBracketPosition : m_nEndBracketPosition ); 3827 } 3828 delete aDlg; //add CHINA001 3829 } 3830 } 3831 3832 // ----------------------------------------------------------------------- 3833 3834 void SvxCharTwoLinesPage::SetBracket( sal_Unicode cBracket, sal_Bool bStart ) 3835 { 3836 sal_uInt16 nEntryPos = 0; 3837 ListBox* pBox = bStart ? &m_aStartBracketLB : &m_aEndBracketLB; 3838 if ( 0 == cBracket ) 3839 pBox->SelectEntryPos(0); 3840 else 3841 { 3842 FASTBOOL bFound = sal_False; 3843 for ( sal_uInt16 i = 1; i < pBox->GetEntryCount(); ++i ) 3844 { 3845 if ( (sal_uLong)pBox->GetEntryData(i) != CHRDLG_ENCLOSE_SPECIAL_CHAR ) 3846 { 3847 const sal_Unicode cChar = pBox->GetEntry(i).GetChar(0); 3848 if ( cChar == cBracket ) 3849 { 3850 pBox->SelectEntryPos(i); 3851 nEntryPos = i; 3852 bFound = sal_True; 3853 break; 3854 } 3855 } 3856 } 3857 3858 if ( !bFound ) 3859 { 3860 nEntryPos = pBox->InsertEntry( String( cBracket ) ); 3861 pBox->SelectEntryPos( nEntryPos ); 3862 } 3863 } 3864 if( bStart ) 3865 m_nStartBracketPosition = nEntryPos; 3866 else 3867 m_nEndBracketPosition = nEntryPos; 3868 } 3869 3870 // ----------------------------------------------------------------------- 3871 3872 IMPL_LINK( SvxCharTwoLinesPage, TwoLinesHdl_Impl, CheckBox*, EMPTYARG ) 3873 { 3874 sal_Bool bChecked = m_aTwoLinesBtn.IsChecked(); 3875 m_aStartBracketFT.Enable( bChecked ); 3876 m_aStartBracketLB.Enable( bChecked ); 3877 m_aEndBracketFT.Enable( bChecked ); 3878 m_aEndBracketLB.Enable( bChecked ); 3879 3880 UpdatePreview_Impl(); 3881 return 0; 3882 } 3883 3884 // ----------------------------------------------------------------------- 3885 3886 IMPL_LINK( SvxCharTwoLinesPage, CharacterMapHdl_Impl, ListBox*, pBox ) 3887 { 3888 sal_uInt16 nPos = pBox->GetSelectEntryPos(); 3889 if ( CHRDLG_ENCLOSE_SPECIAL_CHAR == (sal_uLong)pBox->GetEntryData( nPos ) ) 3890 SelectCharacter( pBox ); 3891 else 3892 { 3893 bool bStart = pBox == &m_aStartBracketLB; 3894 if( bStart ) 3895 m_nStartBracketPosition = nPos; 3896 else 3897 m_nEndBracketPosition = nPos; 3898 } 3899 UpdatePreview_Impl(); 3900 return 0; 3901 } 3902 3903 // ----------------------------------------------------------------------- 3904 3905 void SvxCharTwoLinesPage::ActivatePage( const SfxItemSet& rSet ) 3906 { 3907 SvxCharBasePage::ActivatePage( rSet ); 3908 } 3909 3910 // ----------------------------------------------------------------------- 3911 3912 int SvxCharTwoLinesPage::DeactivatePage( SfxItemSet* _pSet ) 3913 { 3914 if ( _pSet ) 3915 FillItemSet( *_pSet ); 3916 return LEAVE_PAGE; 3917 } 3918 3919 // ----------------------------------------------------------------------- 3920 3921 SfxTabPage* SvxCharTwoLinesPage::Create( Window* pParent, const SfxItemSet& rSet ) 3922 { 3923 return new SvxCharTwoLinesPage( pParent, rSet ); 3924 } 3925 3926 // ----------------------------------------------------------------------- 3927 3928 sal_uInt16* SvxCharTwoLinesPage::GetRanges() 3929 { 3930 return pTwoLinesRanges; 3931 } 3932 3933 // ----------------------------------------------------------------------- 3934 3935 void SvxCharTwoLinesPage::Reset( const SfxItemSet& rSet ) 3936 { 3937 m_aTwoLinesBtn.Check( sal_False ); 3938 sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_TWO_LINES ); 3939 SfxItemState eState = rSet.GetItemState( nWhich ); 3940 3941 if ( eState >= SFX_ITEM_DONTCARE ) 3942 { 3943 const SvxTwoLinesItem& rItem = (SvxTwoLinesItem&)rSet.Get( nWhich ); 3944 m_aTwoLinesBtn.Check( rItem.GetValue() ); 3945 3946 if ( rItem.GetValue() ) 3947 { 3948 SetBracket( rItem.GetStartBracket(), sal_True ); 3949 SetBracket( rItem.GetEndBracket(), sal_False ); 3950 } 3951 } 3952 TwoLinesHdl_Impl( NULL ); 3953 3954 SetPrevFontWidthScale( rSet ); 3955 } 3956 3957 // ----------------------------------------------------------------------- 3958 3959 sal_Bool SvxCharTwoLinesPage::FillItemSet( SfxItemSet& rSet ) 3960 { 3961 const SfxItemSet& rOldSet = GetItemSet(); 3962 sal_Bool bModified = sal_False, bChanged = sal_True; 3963 sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_TWO_LINES ); 3964 const SfxPoolItem* pOld = GetOldItem( rSet, SID_ATTR_CHAR_TWO_LINES ); 3965 sal_Bool bOn = m_aTwoLinesBtn.IsChecked(); 3966 sal_Unicode cStart = ( bOn && m_aStartBracketLB.GetSelectEntryPos() > 0 ) 3967 ? m_aStartBracketLB.GetSelectEntry().GetChar(0) : 0; 3968 sal_Unicode cEnd = ( bOn && m_aEndBracketLB.GetSelectEntryPos() > 0 ) 3969 ? m_aEndBracketLB.GetSelectEntry().GetChar(0) : 0; 3970 3971 if ( pOld ) 3972 { 3973 const SvxTwoLinesItem& rItem = *( (const SvxTwoLinesItem*)pOld ); 3974 if ( rItem.GetValue() == bOn && 3975 ( !bOn || ( rItem.GetStartBracket() == cStart && rItem.GetEndBracket() == cEnd ) ) ) 3976 bChanged = sal_False; 3977 } 3978 3979 if ( bChanged ) 3980 { 3981 rSet.Put( SvxTwoLinesItem( bOn, cStart, cEnd, nWhich ) ); 3982 bModified |= sal_True; 3983 } 3984 else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich, sal_False ) ) 3985 CLEARTITEM; 3986 3987 return bModified; 3988 } 3989 /* -----------------------------04.12.00 09:48-------------------------------- 3990 3991 ---------------------------------------------------------------------------*/ 3992 void SvxCharTwoLinesPage::UpdatePreview_Impl() 3993 { 3994 sal_Unicode cStart = m_aStartBracketLB.GetSelectEntryPos() > 0 3995 ? m_aStartBracketLB.GetSelectEntry().GetChar(0) : 0; 3996 sal_Unicode cEnd = m_aEndBracketLB.GetSelectEntryPos() > 0 3997 ? m_aEndBracketLB.GetSelectEntry().GetChar(0) : 0; 3998 m_aPreviewWin.SetBrackets(cStart, cEnd); 3999 m_aPreviewWin.SetTwoLines(m_aTwoLinesBtn.IsChecked()); 4000 m_aPreviewWin.Invalidate(); 4001 } 4002 // ----------------------------------------------------------------------- 4003 void SvxCharTwoLinesPage::SetPreviewBackgroundToCharacter() 4004 { 4005 m_bPreviewBackgroundToCharacter = sal_True; 4006 } 4007 4008 // ----------------------------------------------------------------------- 4009 void SvxCharTwoLinesPage::PageCreated (SfxAllItemSet aSet) //add CHINA001 4010 { 4011 SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,sal_False); 4012 if (pFlagItem) 4013 { 4014 sal_uInt32 nFlags=pFlagItem->GetValue(); 4015 if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER ) 4016 SetPreviewBackgroundToCharacter(); 4017 } 4018 } 4019