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_sw.hxx" 26 27 28 #include <hintids.hxx> 29 30 #ifndef _MSGBOX_HXX //autogen 31 #include <vcl/msgbox.hxx> 32 #endif 33 #include <svl/whiter.hxx> 34 #include <svl/stritem.hxx> 35 #include <svl/itemiter.hxx> 36 #include <svl/ctloptions.hxx> 37 #include <swmodule.hxx> 38 #include <sfx2/bindings.hxx> 39 #include <sfx2/request.hxx> 40 #include <editeng/fhgtitem.hxx> 41 #include <editeng/adjitem.hxx> 42 #include <editeng/lspcitem.hxx> 43 #include <editeng/udlnitem.hxx> 44 #include <editeng/escpitem.hxx> 45 #include <svx/htmlmode.hxx> 46 #include <editeng/scripttypeitem.hxx> 47 #include <editeng/frmdiritem.hxx> 48 #include "paratr.hxx" 49 50 #include <fmtinfmt.hxx> 51 #ifndef _DOCSH_HXX 52 #include <docsh.hxx> 53 #endif 54 #include <wrtsh.hxx> 55 #ifndef _VIEW_HXX 56 #include <view.hxx> 57 #endif 58 #include <viewopt.hxx> 59 #include <uitool.hxx> 60 #ifndef _TEXTSH_HXX 61 #include <textsh.hxx> 62 #endif 63 #include <num.hxx> 64 #include <swundo.hxx> 65 #include <fmtcol.hxx> 66 67 #ifndef _CMDID_H 68 #include <cmdid.h> 69 #endif 70 #include <globals.h> 71 #ifndef _SHELLS_HRC 72 #include <shells.hrc> 73 #endif 74 #include <SwStyleNameMapper.hxx> 75 #include "swabstdlg.hxx" 76 #include "chrdlg.hrc" 77 const SwTwips lFontInc = 2 * 20; // ==> PointToTwips(2) 78 const SwTwips lFontMaxSz = 72 * 20; // ==> PointToTwips(72) 79 80 81 82 83 void SwTextShell::ExecCharAttr(SfxRequest &rReq) 84 { 85 SwWrtShell &rSh = GetShell(); 86 const SfxItemSet *pArgs = rReq.GetArgs(); 87 int eState = STATE_TOGGLE; 88 sal_uInt16 nWhich = rReq.GetSlot(); 89 90 if(pArgs ) 91 { 92 const SfxPoolItem* pItem; 93 pArgs->GetItemState(nWhich, sal_False, &pItem); 94 eState = ((const SfxBoolItem &) pArgs-> 95 Get( nWhich )).GetValue() ? STATE_ON : STATE_OFF; 96 } 97 98 99 SfxItemSet aSet( GetPool(), RES_CHRATR_BEGIN, RES_CHRATR_END-1 ); 100 if (STATE_TOGGLE == eState) 101 rSh.GetCurAttr( aSet ); 102 103 switch ( nWhich ) 104 { 105 case FN_SET_SUB_SCRIPT: 106 case FN_SET_SUPER_SCRIPT: 107 { 108 SvxEscapement eEscape = SVX_ESCAPEMENT_SUBSCRIPT; 109 switch (eState) 110 { 111 case STATE_TOGGLE: 112 { 113 short nTmpEsc = ((const SvxEscapementItem&) 114 aSet.Get( RES_CHRATR_ESCAPEMENT )).GetEsc(); 115 eEscape = nWhich == FN_SET_SUPER_SCRIPT ? 116 SVX_ESCAPEMENT_SUPERSCRIPT: 117 SVX_ESCAPEMENT_SUBSCRIPT; 118 if( (nWhich == FN_SET_SUB_SCRIPT && nTmpEsc < 0) || 119 (nWhich == FN_SET_SUPER_SCRIPT && nTmpEsc > 0) ) 120 eEscape = SVX_ESCAPEMENT_OFF; 121 122 SfxBindings& rBind = GetView().GetViewFrame()->GetBindings(); 123 if( nWhich == FN_SET_SUB_SCRIPT ) 124 rBind.SetState( SfxBoolItem( FN_SET_SUPER_SCRIPT, 125 sal_False ) ); 126 else 127 rBind.SetState( SfxBoolItem( FN_SET_SUB_SCRIPT, 128 sal_False ) ); 129 130 } 131 break; 132 case STATE_ON: 133 eEscape = nWhich == FN_SET_SUPER_SCRIPT ? 134 SVX_ESCAPEMENT_SUPERSCRIPT: 135 SVX_ESCAPEMENT_SUBSCRIPT; 136 break; 137 case STATE_OFF: 138 eEscape = SVX_ESCAPEMENT_OFF; 139 break; 140 } 141 SvxEscapementItem aEscape( eEscape, RES_CHRATR_ESCAPEMENT ); 142 if(eEscape == SVX_ESCAPEMENT_SUPERSCRIPT) 143 aEscape.GetEsc() = DFLT_ESC_AUTO_SUPER; 144 else if(eEscape == SVX_ESCAPEMENT_SUBSCRIPT) 145 aEscape.GetEsc() = DFLT_ESC_AUTO_SUB; 146 if(eState != STATE_OFF ) 147 { 148 if(eEscape == FN_SET_SUPER_SCRIPT) 149 aEscape.GetEsc() *= -1; 150 } 151 rSh.SetAttr( aEscape ); 152 rReq.AppendItem( aEscape ); 153 rReq.Done(); 154 } 155 break; 156 157 case FN_UPDATE_STYLE_BY_EXAMPLE: 158 rSh.QuickUpdateStyle(); 159 rReq.Done(); 160 break; 161 case FN_UNDERLINE_DOUBLE: 162 { 163 FontUnderline eUnderline = ((const SvxUnderlineItem&) 164 aSet.Get(RES_CHRATR_UNDERLINE)).GetLineStyle(); 165 switch( eState ) 166 { 167 case STATE_TOGGLE: 168 eUnderline = eUnderline == UNDERLINE_DOUBLE ? 169 UNDERLINE_NONE : 170 UNDERLINE_DOUBLE; 171 break; 172 case STATE_ON: 173 eUnderline = UNDERLINE_DOUBLE; 174 break; 175 case STATE_OFF: 176 eUnderline = UNDERLINE_NONE; 177 break; 178 } 179 SvxUnderlineItem aUnderline(eUnderline, RES_CHRATR_UNDERLINE ); 180 rSh.SetAttr( aUnderline ); 181 rReq.AppendItem( aUnderline ); 182 rReq.Done(); 183 } 184 break; 185 case FN_REMOVE_DIRECT_CHAR_FORMATS: 186 if( !rSh.HasReadonlySel() && rSh.IsEndPara()) 187 rSh.DontExpandFmt(); 188 break; 189 default: 190 ASSERT(sal_False, falscher Dispatcher); 191 return; 192 } 193 } 194 195 196 void SwTextShell::ExecCharAttrArgs(SfxRequest &rReq) 197 { 198 sal_uInt16 nSlot = rReq.GetSlot(); 199 const SfxItemSet* pArgs = rReq.GetArgs(); 200 sal_Bool bArgs = pArgs != 0 && pArgs->Count() > 0; 201 int bGrow = sal_False; 202 SwWrtShell& rWrtSh = GetShell(); 203 SwTxtFmtColl* pColl = 0; 204 205 // nur gesetzt, wenn gesamter Absatz selektiert ist und AutoUpdateFmt gesetzt ist 206 if( rWrtSh.HasSelection() && rWrtSh.IsSelFullPara() ) 207 { 208 pColl = rWrtSh.GetCurTxtFmtColl(); 209 if(pColl && !pColl->IsAutoUpdateFmt()) 210 pColl = 0; 211 } 212 SfxItemPool& rPool = GetPool(); 213 sal_uInt16 nWhich = rPool.GetWhich(nSlot); 214 switch ( nSlot ) 215 { 216 case FN_TXTATR_INET: 217 // Sonderbehandlung der PoolId des SwFmtInetFmt 218 if(bArgs) 219 { 220 const SfxPoolItem& rItem = pArgs->Get(nWhich ); 221 222 SwFmtINetFmt aINetFmt((const SwFmtINetFmt&)rItem); 223 if( USHRT_MAX == aINetFmt.GetVisitedFmtId() ) 224 { 225 aINetFmt.SetVisitedFmtId( 226 SwStyleNameMapper::GetPoolIdFromUIName( aINetFmt.GetVisitedFmt(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT)); 227 } 228 if( USHRT_MAX == aINetFmt.GetINetFmtId() ) 229 { 230 aINetFmt.SetINetFmtId( 231 SwStyleNameMapper::GetPoolIdFromUIName( aINetFmt.GetINetFmt(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT)); 232 } 233 234 if ( pColl ) 235 pColl->SetFmtAttr( aINetFmt ); 236 else rWrtSh.SetAttr( aINetFmt ); 237 rReq.Done(); 238 } 239 break; 240 241 case FN_GROW_FONT_SIZE: 242 bGrow = sal_True; 243 // kein break !! 244 case FN_SHRINK_FONT_SIZE: 245 { 246 SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT, rPool ); 247 rWrtSh.GetCurAttr( aSetItem.GetItemSet() ); 248 SfxItemSet aAttrSet( rPool, aSetItem.GetItemSet().GetRanges() ); 249 250 const SfxPoolItem* pI; 251 static const sal_uInt16 aScrTypes[] = { 252 SCRIPTTYPE_LATIN, SCRIPTTYPE_ASIAN, SCRIPTTYPE_COMPLEX, 0 }; 253 sal_uInt16 nScriptType = rWrtSh.GetScriptType(); 254 for( const sal_uInt16* pScrpTyp = aScrTypes; *pScrpTyp; ++pScrpTyp ) 255 if( ( nScriptType & *pScrpTyp ) && 256 0 != ( pI = aSetItem.GetItemOfScript( *pScrpTyp ))) 257 { 258 SvxFontHeightItem aSize( *(const SvxFontHeightItem*)pI ); 259 SwTwips lSize = (SwTwips) aSize.GetHeight(); 260 261 if (bGrow) 262 { 263 if( lSize == lFontMaxSz ) 264 break; // das wars, hoeher gehts nicht 265 if( ( lSize += lFontInc ) > lFontMaxSz ) 266 lSize = lFontMaxSz; 267 } 268 else 269 { 270 if( 4 == lSize ) 271 break; 272 if( ( lSize -= lFontInc ) < 4 ) 273 lSize = 4; 274 } 275 aSize.SetHeight( lSize ); 276 aAttrSet.Put( aSize ); 277 } 278 if( aAttrSet.Count() ) 279 { 280 if( pColl ) 281 pColl->SetFmtAttr( aAttrSet ); 282 else 283 rWrtSh.SetAttr( aAttrSet ); 284 } 285 rReq.Done(); 286 } 287 break; 288 289 default: 290 ASSERT(sal_False, falscher Dispatcher); 291 return; 292 } 293 } 294 295 296 297 #ifdef CFRONT 298 299 void lcl_SetAdjust(SvxAdjust eAdjst, SfxItemSet& rSet) 300 { 301 rSet.Put(SvxAdjustItem(eAdjst,RES_PARATR_ADJUST )); 302 } 303 304 305 306 void lcl_SetLineSpace(sal_uInt8 ePropL,SfxItemSet& rSet) 307 { 308 SvxLineSpacingItem aLineSpacing(ePropL, RES_PARATR_LINESPACING ); 309 aLineSpacing.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 310 if( 100 == ePropL ) 311 aLineSpacing.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF; 312 else 313 aLineSpacing.SetPropLineSpace(ePropL); 314 rSet.Put( aLineSpacing ); 315 } 316 317 318 319 void SwTextShell::ExecParaAttr(SfxRequest &rReq) 320 { 321 // gleiche beide Attribute holen, ist nicht teuerer !! 322 SfxItemSet aSet( GetPool(), RES_PARATR_LINESPACING, RES_PARATR_ADJUST ); 323 324 switch (rReq.GetSlot()) 325 { 326 case FN_SET_LEFT_PARA: lcl_SetAdjust(ADJLEFT,aSet); break; 327 case FN_SET_RIGHT_PARA: lcl_SetAdjust(ADJRIGHT,aSet); break; 328 case FN_SET_CENTER_PARA: lcl_SetAdjust(ADJCENTER,aSet); break; 329 case SID_ATTR_PARA_ADJUST_BLOCK:lcl_SetAdjust(ADJBLOCK,aSet); break; 330 331 case FN_SET_LINE_SPACE_1: lcl_SetLineSpace(100,aSet); break; 332 case FN_SET_LINE_SPACE_15: lcl_SetLineSpace(150,aSet); break; 333 case FN_SET_LINE_SPACE_2: lcl_SetLineSpace(200,aSet); break; 334 335 default: 336 DBG_ERROR("SwTextShell::ExecParaAttr falscher Dispatcher"); 337 return; 338 } 339 SwWrtShell& rWrtSh = GetShell(); 340 SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl(); 341 if(pColl && pColl->IsAutoUpdateFmt()) 342 { 343 rWrtSh.AutoUpdatePara(pColl, *pSet); 344 } 345 else 346 { 347 rWrtSh.SetAttr( aSet ); 348 rReq.Done( aSet ); 349 } 350 } 351 352 #else 353 354 355 356 void SwTextShell::ExecParaAttr(SfxRequest &rReq) 357 { 358 SvxAdjust eAdjst; 359 sal_uInt8 ePropL; 360 const SfxItemSet* pArgs = rReq.GetArgs(); 361 362 // gleich beide Attribute holen, ist nicht teuerer !! 363 SfxItemSet aSet( GetPool(), 364 RES_PARATR_LINESPACING, RES_PARATR_ADJUST, 365 RES_FRAMEDIR, RES_FRAMEDIR, 366 0 ); 367 368 sal_uInt16 nSlot = rReq.GetSlot(); 369 switch (nSlot) 370 { 371 case SID_ATTR_PARA_ADJUST: 372 { 373 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_PARATR_ADJUST) ) 374 { 375 const SvxAdjustItem& rAdj = (const SvxAdjustItem&) pArgs->Get(RES_PARATR_ADJUST); 376 SvxAdjustItem aAdj( rAdj.GetAdjust(), RES_PARATR_ADJUST ); 377 if ( rAdj.GetAdjust() == SVX_ADJUST_BLOCK ) 378 { 379 aAdj.SetLastBlock( rAdj.GetLastBlock() ); 380 aAdj.SetOneWord( rAdj.GetOneWord() ); 381 } 382 383 aSet.Put(aAdj); 384 } 385 } 386 break; 387 case SID_ATTR_PARA_ADJUST_LEFT: eAdjst = SVX_ADJUST_LEFT; goto SET_ADJUST; 388 case SID_ATTR_PARA_ADJUST_RIGHT: eAdjst = SVX_ADJUST_RIGHT; goto SET_ADJUST; 389 case SID_ATTR_PARA_ADJUST_CENTER: eAdjst = SVX_ADJUST_CENTER; goto SET_ADJUST; 390 case SID_ATTR_PARA_ADJUST_BLOCK: eAdjst = SVX_ADJUST_BLOCK; goto SET_ADJUST; 391 SET_ADJUST: 392 { 393 aSet.Put(SvxAdjustItem(eAdjst,RES_PARATR_ADJUST)); 394 rReq.AppendItem( SfxBoolItem( GetPool().GetWhich(nSlot), sal_True ) ); 395 } 396 break; 397 398 case SID_ATTR_PARA_LINESPACE: 399 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState( GetPool().GetWhich(nSlot) )) 400 { 401 SvxLineSpacingItem aLineSpace = (const SvxLineSpacingItem&)pArgs->Get( 402 GetPool().GetWhich(nSlot)); 403 aSet.Put( aLineSpace ); 404 } 405 break; 406 case SID_ATTR_PARA_LINESPACE_10: ePropL = 100; goto SET_LINESPACE; 407 case SID_ATTR_PARA_LINESPACE_15: ePropL = 150; goto SET_LINESPACE; 408 case SID_ATTR_PARA_LINESPACE_20: ePropL = 200; goto SET_LINESPACE; 409 410 SET_LINESPACE: 411 { 412 413 SvxLineSpacingItem aLineSpacing(ePropL, RES_PARATR_LINESPACING ); 414 aLineSpacing.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; 415 if( 100 == ePropL ) 416 aLineSpacing.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF; 417 else 418 aLineSpacing.SetPropLineSpace(ePropL); 419 aSet.Put( aLineSpacing ); 420 } 421 break; 422 423 case SID_ATTR_PARA_LEFT_TO_RIGHT : 424 case SID_ATTR_PARA_RIGHT_TO_LEFT : 425 { 426 sal_Bool bSet = sal_True; 427 int eState = pArgs ? pArgs->GetItemState(nSlot) : SFX_ITEM_DISABLED; 428 if (pArgs && SFX_ITEM_SET == eState) 429 bSet = ((const SfxBoolItem&)pArgs->Get(nSlot)).GetValue(); 430 /* 431 // toggling of the slots not used anymore 432 433 if(!bSet) 434 nSlot = SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot ? 435 SID_ATTR_PARA_RIGHT_TO_LEFT : 436 SID_ATTR_PARA_LEFT_TO_RIGHT; 437 */ 438 SfxItemSet aAdjustSet( GetPool(), 439 RES_PARATR_ADJUST, RES_PARATR_ADJUST ); 440 GetShell().GetCurAttr(aAdjustSet); 441 sal_Bool bChgAdjust = sal_False; 442 SfxItemState eAdjustState = aAdjustSet.GetItemState(RES_PARATR_ADJUST, sal_False); 443 if(eAdjustState >= SFX_ITEM_DEFAULT) 444 { 445 int eAdjust = (int)(( const SvxAdjustItem& ) 446 aAdjustSet.Get(RES_PARATR_ADJUST)).GetAdjust(); 447 // bChgAdjust = SVX_ADJUST_CENTER != eAdjust && SVX_ADJUST_BLOCK != eAdjust; 448 bChgAdjust = (SVX_ADJUST_LEFT == eAdjust && SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot) || 449 (SVX_ADJUST_RIGHT == eAdjust && SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot); 450 } 451 else 452 bChgAdjust = sal_True; 453 454 SvxFrameDirection eFrmDirection = 455 (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ? 456 FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP; 457 aSet.Put( SvxFrameDirectionItem( eFrmDirection, RES_FRAMEDIR ) ); 458 459 if (bChgAdjust) 460 { 461 SvxAdjust eAdjust = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ? 462 SVX_ADJUST_LEFT : SVX_ADJUST_RIGHT; 463 SvxAdjustItem aAdjust( eAdjust, RES_PARATR_ADJUST ); 464 aSet.Put( aAdjust ); 465 aAdjust.SetWhich(SID_ATTR_PARA_ADJUST); 466 GetView().GetViewFrame()->GetBindings().SetState( aAdjust ); 467 // Toggle numbering alignment 468 const SwNumRule* pCurRule = GetShell().GetCurNumRule(); 469 if( pCurRule ) 470 { 471 SvxNumRule aRule = pCurRule->MakeSvxNumRule(); 472 473 for(sal_uInt16 i = 0; i < aRule.GetLevelCount(); i++) 474 { 475 SvxNumberFormat aFmt(aRule.GetLevel(i)); 476 if(SVX_ADJUST_LEFT == aFmt.GetNumAdjust()) 477 aFmt.SetNumAdjust( SVX_ADJUST_RIGHT ); 478 479 else if(SVX_ADJUST_RIGHT == aFmt.GetNumAdjust()) 480 aFmt.SetNumAdjust( SVX_ADJUST_LEFT ); 481 482 aRule.SetLevel(i, aFmt, aRule.Get(i) != 0); 483 } 484 // --> OD 2008-02-11 #newlistlevelattrs# 485 SwNumRule aSetRule( pCurRule->GetName(), 486 pCurRule->Get( 0 ).GetPositionAndSpaceMode() ); 487 // <-- 488 aSetRule.SetSvxRule( aRule, GetShell().GetDoc()); 489 aSetRule.SetAutoRule( sal_True ); 490 // --> OD 2008-03-17 #refactorlists# 491 // no start or continuation of a list - list style is only changed 492 GetShell().SetCurNumRule( aSetRule, false ); 493 // <-- 494 } 495 } 496 } 497 break; 498 499 default: 500 ASSERT(sal_False, falscher Dispatcher); 501 return; 502 } 503 SwWrtShell& rWrtSh = GetShell(); 504 SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl(); 505 if(pColl && pColl->IsAutoUpdateFmt()) 506 { 507 rWrtSh.AutoUpdatePara(pColl, aSet); 508 } 509 else 510 rWrtSh.SetAttr( aSet ); 511 rReq.Done(); 512 } 513 514 #endif 515 516 517 518 void SwTextShell::ExecParaAttrArgs(SfxRequest &rReq) 519 { 520 SwWrtShell &rSh = GetShell(); 521 const SfxItemSet *pArgs = rReq.GetArgs(); 522 const SfxPoolItem *pItem = 0; 523 524 sal_uInt16 nSlot = rReq.GetSlot(); 525 if(pArgs) 526 pArgs->GetItemState(GetPool().GetWhich(nSlot), sal_False, &pItem); 527 switch ( nSlot ) 528 { 529 case FN_DROP_CHAR_STYLE_NAME: 530 if( pItem ) 531 { 532 String sCharStyleName = ((const SfxStringItem*)pItem)->GetValue(); 533 SfxItemSet aSet(GetPool(), RES_PARATR_DROP, RES_PARATR_DROP, 0L); 534 rSh.GetCurAttr(aSet); 535 SwFmtDrop aDropItem((const SwFmtDrop&)aSet.Get(RES_PARATR_DROP)); 536 SwCharFmt* pFmt = 0; 537 if(sCharStyleName.Len()) 538 pFmt = rSh.FindCharFmtByName( sCharStyleName ); 539 aDropItem.SetCharFmt( pFmt ); 540 aSet.Put(aDropItem); 541 rSh.SetAttr(aSet); 542 } 543 break; 544 case FN_FORMAT_DROPCAPS: 545 { 546 if(pItem) 547 { 548 rSh.SetAttr(*pItem); 549 rReq.Done(); 550 } 551 else 552 { 553 SfxItemSet aSet(GetPool(), RES_PARATR_DROP, RES_PARATR_DROP, 554 HINT_END, HINT_END, 0); 555 rSh.GetCurAttr(aSet); 556 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 557 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 558 559 SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( GetView().GetWindow(), aSet, 560 rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface(), DLG_SWDROPCAPS ); 561 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 562 if (pDlg->Execute() == RET_OK) 563 { 564 rSh.StartAction(); 565 rSh.StartUndo( UNDO_START ); 566 if ( SFX_ITEM_SET == aSet.GetItemState(HINT_END,sal_False,&pItem) ) 567 { 568 if ( ((SfxStringItem*)pItem)->GetValue().Len() ) 569 rSh.ReplaceDropTxt(((SfxStringItem*)pItem)->GetValue()); 570 } 571 rSh.SetAttr(*pDlg->GetOutputItemSet()); 572 rSh.StartUndo( UNDO_END ); 573 rSh.EndAction(); 574 rReq.Done(*pDlg->GetOutputItemSet()); 575 } 576 delete pDlg; 577 } 578 } 579 break; 580 case SID_ATTR_PARA_PAGEBREAK: 581 if(pItem) 582 { 583 rSh.SetAttr( *pItem ); 584 rReq.Done(); 585 } 586 break; 587 case SID_ATTR_PARA_MODEL: 588 { 589 if(pItem) 590 { 591 SfxItemSet aCoreSet( GetPool(), 592 RES_PAGEDESC, RES_PAGEDESC, 593 SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL, 0); 594 aCoreSet.Put(*pItem); 595 SfxToSwPageDescAttr( rSh, aCoreSet); 596 rSh.SetAttr(aCoreSet); 597 rReq.Done(); 598 } 599 } 600 break; 601 602 default: 603 ASSERT(sal_False, falscher Dispatcher); 604 return; 605 } 606 } 607 608 609 610 void SwTextShell::GetAttrState(SfxItemSet &rSet) 611 { 612 SwWrtShell &rSh = GetShell(); 613 SfxItemPool& rPool = GetPool(); 614 SfxItemSet aCoreSet(rPool, aTxtFmtCollSetRange); 615 rSh.GetCurAttr(aCoreSet); // *alle* Textattribute von der Core erfragen 616 617 SfxWhichIter aIter(rSet); 618 sal_uInt16 nSlot = aIter.FirstWhich(); 619 sal_Bool bFlag = sal_False; 620 SfxBoolItem aFlagItem; 621 const SfxPoolItem* pItem = 0; 622 int eAdjust = -1; // Illegaler Wert, um DONTCARE zu erkennen 623 SfxItemState eState = aCoreSet.GetItemState(RES_PARATR_ADJUST, sal_False, &pItem); 624 625 if( SFX_ITEM_DEFAULT == eState ) 626 pItem = &rPool.GetDefaultItem(RES_PARATR_ADJUST); 627 if( SFX_ITEM_DEFAULT <= eState ) 628 eAdjust = (int)(( SvxAdjustItem* ) pItem)->GetAdjust(); 629 630 short nEsc = 0; 631 eState = aCoreSet.GetItemState(RES_CHRATR_ESCAPEMENT, sal_False, &pItem); 632 if( SFX_ITEM_DEFAULT == eState ) 633 pItem = &rPool.GetDefaultItem(RES_CHRATR_ESCAPEMENT); 634 if( eState >= SFX_ITEM_DEFAULT ) 635 nEsc = ((SvxEscapementItem* )pItem)->GetEsc(); 636 637 sal_uInt16 nLineSpace = 0; 638 eState = aCoreSet.GetItemState(RES_PARATR_LINESPACING, sal_False, &pItem); 639 if( SFX_ITEM_DEFAULT == eState ) 640 pItem = &rPool.GetDefaultItem(RES_PARATR_LINESPACING); 641 if( SFX_ITEM_DEFAULT <= eState && 642 ((SvxLineSpacingItem* )pItem)->GetLineSpaceRule() == SVX_LINE_SPACE_AUTO ) 643 { 644 if(SVX_INTER_LINE_SPACE_OFF == 645 ((SvxLineSpacingItem* )pItem)->GetInterLineSpaceRule()) 646 nLineSpace = 100; 647 else 648 nLineSpace = ((SvxLineSpacingItem* )pItem)->GetPropLineSpace(); 649 } 650 651 while (nSlot) 652 { 653 switch(nSlot) 654 { 655 case FN_SET_SUPER_SCRIPT: 656 bFlag = 0 < nEsc; 657 break; 658 case FN_SET_SUB_SCRIPT: 659 bFlag = 0 > nEsc; 660 break; 661 case SID_ATTR_PARA_ADJUST_LEFT: 662 if (eAdjust == -1) 663 { 664 rSet.InvalidateItem( nSlot ); 665 nSlot = 0; 666 } 667 else 668 bFlag = SVX_ADJUST_LEFT == eAdjust; 669 break; 670 case SID_ATTR_PARA_ADJUST_RIGHT: 671 if (eAdjust == -1) 672 { 673 rSet.InvalidateItem( nSlot ); 674 nSlot = 0; 675 } 676 else 677 bFlag = SVX_ADJUST_RIGHT == eAdjust; 678 break; 679 case SID_ATTR_PARA_ADJUST_CENTER: 680 if (eAdjust == -1) 681 { 682 rSet.InvalidateItem( nSlot ); 683 nSlot = 0; 684 } 685 else 686 bFlag = SVX_ADJUST_CENTER == eAdjust; 687 break; 688 case SID_ATTR_PARA_ADJUST_BLOCK: 689 { 690 if (eAdjust == -1) 691 { 692 rSet.InvalidateItem( nSlot ); 693 nSlot = 0; 694 } 695 else 696 { 697 bFlag = SVX_ADJUST_BLOCK == eAdjust; 698 sal_uInt16 nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell()); 699 if((nHtmlMode & HTMLMODE_ON) && !(nHtmlMode & (HTMLMODE_FULL_STYLES|HTMLMODE_FIRSTLINE) )) 700 { 701 rSet.DisableItem( nSlot ); 702 nSlot = 0; 703 } 704 } 705 } 706 break; 707 case SID_ATTR_PARA_LINESPACE_10: 708 bFlag = nLineSpace == 100; 709 break; 710 case SID_ATTR_PARA_LINESPACE_15: 711 bFlag = nLineSpace == 150; 712 break; 713 case SID_ATTR_PARA_LINESPACE_20: 714 bFlag = nLineSpace == 200; 715 break; 716 case FN_GROW_FONT_SIZE: 717 case FN_SHRINK_FONT_SIZE: 718 { 719 SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT, 720 *rSet.GetPool() ); 721 aSetItem.GetItemSet().Put( aCoreSet, sal_False ); 722 if( !aSetItem.GetItemOfScript( rSh.GetScriptType() )) 723 rSet.DisableItem( nSlot ); 724 nSlot = 0; 725 } 726 break; 727 case FN_UNDERLINE_DOUBLE: 728 { 729 eState = aCoreSet.GetItemState(RES_CHRATR_UNDERLINE); 730 if( eState >= SFX_ITEM_DEFAULT ) 731 { 732 FontUnderline eUnderline = ((const SvxUnderlineItem&) 733 aCoreSet.Get(RES_CHRATR_UNDERLINE)).GetLineStyle(); 734 rSet.Put(SfxBoolItem(nSlot, eUnderline == UNDERLINE_DOUBLE)); 735 } 736 else 737 rSet.InvalidateItem(nSlot); 738 nSlot = 0; 739 } 740 break; 741 case SID_ATTR_PARA_ADJUST: 742 if (eAdjust == -1) 743 rSet.InvalidateItem( nSlot ); 744 else 745 rSet.Put(SvxAdjustItem((SvxAdjust)eAdjust, SID_ATTR_PARA_ADJUST )); 746 nSlot = 0; 747 break; 748 749 case SID_ATTR_PARA_LEFT_TO_RIGHT : 750 case SID_ATTR_PARA_RIGHT_TO_LEFT : 751 { 752 if ( !SW_MOD()->GetCTLOptions().IsCTLFontEnabled() ) 753 { 754 rSet.DisableItem( nSlot ); 755 nSlot = 0; 756 } 757 else 758 { 759 // is the item set? 760 sal_uInt16 nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell()); 761 if((!(nHtmlMode & HTMLMODE_ON) || (0 != (nHtmlMode & HTMLMODE_SOME_STYLES))) && 762 aCoreSet.GetItemState( RES_FRAMEDIR, sal_False ) >= SFX_ITEM_DEFAULT) 763 { 764 SvxFrameDirection eFrmDir = (SvxFrameDirection) 765 ((const SvxFrameDirectionItem& )aCoreSet.Get(RES_FRAMEDIR)).GetValue(); 766 if (FRMDIR_ENVIRONMENT == eFrmDir) 767 { 768 eFrmDir = rSh.IsInRightToLeftText() ? 769 FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP; 770 } 771 bFlag = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot && 772 FRMDIR_HORI_LEFT_TOP == eFrmDir) || 773 (SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot && 774 FRMDIR_HORI_RIGHT_TOP == eFrmDir); 775 } 776 else 777 { 778 rSet.InvalidateItem(nSlot); 779 nSlot = 0; 780 } 781 } 782 } 783 break; 784 785 case SID_ATTR_CHAR_LANGUAGE: 786 case SID_ATTR_CHAR_KERNING: 787 case RES_PARATR_DROP: 788 { 789 #if OSL_DEBUG_LEVEL > 1 790 const SfxPoolItem& rItem = aCoreSet.Get(GetPool().GetWhich(nSlot), sal_True); 791 rSet.Put(rItem); 792 #else 793 rSet.Put(aCoreSet.Get( GetPool().GetWhich(nSlot), sal_True)); 794 #endif 795 nSlot = 0; 796 } 797 break; 798 case SID_ATTR_PARA_MODEL: 799 { 800 SfxItemSet aTemp(GetPool(), 801 RES_PAGEDESC,RES_PAGEDESC, 802 SID_ATTR_PARA_MODEL,SID_ATTR_PARA_MODEL, 803 0L); 804 aTemp.Put(aCoreSet); 805 ::SwToSfxPageDescAttr(aTemp); 806 rSet.Put(aTemp.Get(SID_ATTR_PARA_MODEL)); 807 nSlot = 0; 808 } 809 break; 810 case RES_TXTATR_INETFMT: 811 { 812 SfxItemSet aSet(GetPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT); 813 rSh.GetCurAttr(aSet); 814 #if OSL_DEBUG_LEVEL > 1 815 const SfxPoolItem& rItem = aSet.Get(RES_TXTATR_INETFMT, sal_True); 816 rSet.Put(rItem); 817 #else 818 rSet.Put(aSet.Get( RES_TXTATR_INETFMT, sal_True)); 819 #endif 820 nSlot = 0; 821 } 822 break; 823 824 default: 825 // Nichts tun 826 nSlot = 0; 827 break; 828 829 } 830 if( nSlot ) 831 { 832 aFlagItem.SetWhich( nSlot ); 833 aFlagItem.SetValue( bFlag ); 834 rSet.Put( aFlagItem ); 835 } 836 nSlot = aIter.NextWhich(); 837 } 838 839 rSet.Put(aCoreSet,sal_False); 840 } 841 842 843 844