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 #include <com/sun/star/i18n/WordType.hpp> 28 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> 29 30 #include <comphelper/processfactory.hxx> 31 #include <svx/dialogs.hrc> 32 #include <hintids.hxx> 33 #include <cmdid.h> 34 #include <helpid.h> 35 36 #include <i18npool/mslangid.hxx> 37 #include <svl/languageoptions.hxx> 38 #include <editeng/langitem.hxx> 39 #include <svtools/langtab.hxx> 40 #include <svl/slstitm.hxx> 41 #include <string.h> 42 #include <svl/stritem.hxx> 43 #include <svx/htmlmode.hxx> 44 #include <svl/whiter.hxx> 45 #include <sfx2/bindings.hxx> 46 #include <sfx2/dispatch.hxx> 47 #include <sfx2/objitem.hxx> 48 #include <vcl/msgbox.hxx> 49 #include <vcl/unohelp2.hxx> 50 #include <sfx2/request.hxx> 51 #include <svl/eitem.hxx> 52 #include <svl/macitem.hxx> 53 #include <editeng/lrspitem.hxx> 54 #include <editeng/ulspitem.hxx> 55 #include <editeng/colritem.hxx> 56 #include <editeng/tstpitem.hxx> 57 #include <editeng/brshitem.hxx> 58 #include <editeng/svxacorr.hxx> 59 #include <svl/cjkoptions.hxx> 60 #include <svl/ctloptions.hxx> 61 #include <IDocumentSettingAccess.hxx> 62 #include <charfmt.hxx> 63 #include <editeng/fontitem.hxx> 64 #include <svx/SmartTagItem.hxx> 65 #include <svx/dialmgr.hxx> 66 #include <fmtinfmt.hxx> 67 #include <swwait.hxx> 68 #include <wrtsh.hxx> 69 #include <wview.hxx> 70 #include <swmodule.hxx> 71 #include <viewopt.hxx> 72 #include <uitool.hxx> 73 #include <swevent.hxx> 74 #include <fmthdft.hxx> 75 #include <pagedesc.hxx> 76 #include <textsh.hxx> 77 #include <IMark.hxx> 78 #include <swdtflvr.hxx> 79 #include <docstat.hxx> 80 #include <outline.hxx> 81 #include <tablemgr.hxx> 82 #include <swundo.hxx> // fuer Undo-IDs 83 #include <reffld.hxx> 84 #include <docsh.hxx> 85 #include <mdiexp.hxx> 86 #include <inputwin.hxx> 87 #include <pardlg.hxx> 88 #include <frmatr.hxx> 89 #include <fmtcol.hxx> 90 #include <cellatr.hxx> 91 #include <edtwin.hxx> 92 #include <redlndlg.hxx> 93 #include "fldmgr.hxx" 94 95 #include <globals.hrc> 96 #include <shells.hrc> 97 #include <app.hrc> 98 #include <web.hrc> 99 #include "paratr.hxx" 100 #include <crsskip.hxx> 101 #include <docstat.hxx> 102 #include <vcl/svapp.hxx> 103 #include <sfx2/app.hxx> 104 #include <breakit.hxx> 105 106 #include <SwSmartTagMgr.hxx> 107 108 #include <editeng/acorrcfg.hxx> 109 #include "swabstdlg.hxx" 110 #include "misc.hrc" 111 #include "chrdlg.hrc" 112 #include <IDocumentStatistics.hxx> 113 114 #include <sfx2/sfxdlg.hxx> 115 #include <svl/languageoptions.hxx> 116 #include <unotools/lingucfg.hxx> 117 #include <com/sun/star/beans/XPropertySet.hpp> 118 #include <com/sun/star/util/XChangesBatch.hpp> 119 #include <com/sun/star/uno/Any.hxx> 120 #include <editeng/unolingu.hxx> 121 #include <unotools/syslocaleoptions.hxx> 122 #include <doc.hxx> 123 #include <view.hxx> 124 #include <ndtxt.hxx> 125 #include <pam.hxx> 126 #include <sfx2/objface.hxx> 127 #include <langhelper.hxx> 128 129 #ifndef _NBDTMGFACT_HXX 130 #include <svx/nbdtmgfact.hxx> 131 #endif 132 #ifndef _NBDTMG_HXX 133 #include <svx/nbdtmg.hxx> 134 #endif 135 136 //UUUU 137 #include <svx/svdmodel.hxx> 138 #include <svx/drawitem.hxx> 139 140 #include <numrule.hxx> 141 142 143 using namespace ::com::sun::star; 144 using namespace svx::sidebar; 145 146 147 void lcl_CharDialog( SwWrtShell &rWrtSh, sal_Bool bUseDialog, sal_uInt16 nSlot,const SfxItemSet *pArgs, SfxRequest *pReq ) 148 { 149 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rWrtSh.GetView())); 150 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric))); 151 SfxItemSet aCoreSet( rWrtSh.GetView().GetPool(), 152 RES_CHRATR_BEGIN, RES_CHRATR_END-1, 153 RES_TXTATR_INETFMT, RES_TXTATR_INETFMT, 154 RES_BACKGROUND, RES_BACKGROUND, 155 FN_PARAM_SELECTION, FN_PARAM_SELECTION, 156 SID_HTML_MODE, SID_HTML_MODE, 157 SID_ATTR_CHAR_WIDTH_FIT_TO_LINE, SID_ATTR_CHAR_WIDTH_FIT_TO_LINE, 158 0 ); 159 rWrtSh.GetCurAttr( aCoreSet ); 160 sal_Bool bSel = rWrtSh.HasSelection(); 161 sal_Bool bSelectionPut = sal_False; 162 if(bSel || rWrtSh.IsInWord()) 163 { 164 if(!bSel) 165 { 166 rWrtSh.StartAction(); 167 rWrtSh.Push(); 168 if(!rWrtSh.SelectTxtAttr( RES_TXTATR_INETFMT )) 169 rWrtSh.SelWrd(); 170 } 171 aCoreSet.Put(SfxStringItem(FN_PARAM_SELECTION, rWrtSh.GetSelTxt())); 172 bSelectionPut = sal_True; 173 if(!bSel) 174 { 175 rWrtSh.Pop(sal_False); 176 rWrtSh.EndAction(); 177 } 178 } 179 aCoreSet.Put( SfxUInt16Item( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE, 180 rWrtSh.GetScalingOfSelectedText() ) ); 181 // Das CHRATR_BACKGROUND-Attribut wird fuer den Dialog in 182 // ein RES_BACKGROUND verwandelt und wieder zurueck ... 183 const SfxPoolItem *pTmpBrush; 184 if( SFX_ITEM_SET == aCoreSet.GetItemState( RES_CHRATR_BACKGROUND, sal_True, &pTmpBrush ) ) 185 { 186 SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) ); 187 aTmpBrush.SetWhich( RES_BACKGROUND ); 188 aCoreSet.Put( aTmpBrush ); 189 } 190 191 aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(rWrtSh.GetView().GetDocShell()))); 192 SfxAbstractTabDialog* pDlg = NULL; 193 if ( bUseDialog && GetActiveView() ) 194 { 195 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 196 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 197 198 pDlg = pFact->CreateSwCharDlg( rWrtSh.GetView().GetWindow(), rWrtSh.GetView(), aCoreSet, DLG_CHAR ); 199 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 200 if( FN_INSERT_HYPERLINK == nSlot ) 201 pDlg->SetCurPageId(TP_CHAR_URL); 202 } 203 if (nSlot == SID_CHAR_DLG_EFFECT) 204 { 205 pDlg->SetCurPageId(TP_CHAR_EXT); 206 } 207 208 const SfxItemSet* pSet = NULL; 209 if ( !bUseDialog ) 210 pSet = pArgs; 211 else if ( NULL != pDlg && pDlg->Execute() == RET_OK ) /* #110771# pDlg can be NULL */ 212 { 213 pSet = pDlg->GetOutputItemSet(); 214 } 215 216 if ( pSet) 217 { 218 SfxItemSet aTmpSet( *pSet ); 219 if( SFX_ITEM_SET == aTmpSet.GetItemState( RES_BACKGROUND, sal_False, &pTmpBrush ) ) 220 { 221 SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) ); 222 aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND ); 223 aTmpSet.Put( aTmpBrush ); 224 } 225 226 aTmpSet.ClearItem( RES_BACKGROUND ); 227 228 const SfxPoolItem* pSelectionItem; 229 sal_Bool bInsert = sal_False; 230 xub_StrLen nInsert = 0; 231 232 // aus ungeklaerter Ursache ist das alte Item wieder im Set 233 if( !bSelectionPut && SFX_ITEM_SET == aTmpSet.GetItemState(FN_PARAM_SELECTION, sal_False, &pSelectionItem) ) 234 { 235 String sInsert = ((const SfxStringItem*)pSelectionItem)->GetValue(); 236 bInsert = sInsert.Len() != 0; 237 if(bInsert) 238 { 239 nInsert = sInsert.Len(); 240 rWrtSh.StartAction(); 241 rWrtSh.Insert( sInsert ); 242 rWrtSh.SetMark(); 243 rWrtSh.ExtendSelection(sal_False, sInsert.Len()); 244 SfxRequest aReq( rWrtSh.GetView().GetViewFrame(), FN_INSERT_STRING ); 245 aReq.AppendItem( SfxStringItem( FN_INSERT_STRING, sInsert ) ); 246 aReq.Done(); 247 SfxRequest aReq1( rWrtSh.GetView().GetViewFrame(), FN_CHAR_LEFT ); 248 aReq1.AppendItem( SfxInt16Item(FN_PARAM_MOVE_COUNT, nInsert) ); 249 aReq1.AppendItem( SfxBoolItem(FN_PARAM_MOVE_SELECTION, sal_True) ); 250 aReq1.Done(); 251 } 252 } 253 aTmpSet.ClearItem(FN_PARAM_SELECTION); 254 255 SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl(); 256 if(bSel && rWrtSh.IsSelFullPara() && pColl && pColl->IsAutoUpdateFmt()) 257 { 258 rWrtSh.AutoUpdatePara(pColl, aTmpSet); 259 } 260 else 261 rWrtSh.SetAttrSet( aTmpSet ); 262 if (pReq) 263 pReq->Done(aTmpSet); 264 if(bInsert) 265 { 266 SfxRequest aReq1( rWrtSh.GetView().GetViewFrame(), FN_CHAR_RIGHT ); 267 aReq1.AppendItem( SfxInt16Item(FN_PARAM_MOVE_COUNT, nInsert) ); 268 aReq1.AppendItem( SfxBoolItem(FN_PARAM_MOVE_SELECTION, sal_False) ); 269 aReq1.Done(); 270 rWrtSh.SwapPam(); 271 rWrtSh.ClearMark(); 272 rWrtSh.DontExpandFmt(); 273 rWrtSh.EndAction(); 274 } 275 } 276 277 delete pDlg; 278 } 279 280 /*-------------------------------------------------------------------- 281 Beschreibung: 282 --------------------------------------------------------------------*/ 283 284 short lcl_AskRedlineMode(Window *pWin) 285 { 286 MessBox aQBox( pWin, 0, 287 String( SW_RES( STR_REDLINE_TITLE ) ), 288 String( SW_RES( STR_REDLINE_MSG ) ) ); 289 aQBox.SetImage( QueryBox::GetStandardImage() ); 290 sal_uInt16 nBtnFlags = BUTTONDIALOG_DEFBUTTON | 291 BUTTONDIALOG_OKBUTTON | 292 BUTTONDIALOG_FOCUSBUTTON; 293 294 aQBox.AddButton(String(SW_RES(STR_REDLINE_ACCEPT_ALL)), RET_OK, nBtnFlags); 295 aQBox.GetPushButton( RET_OK )->SetHelpId(HID_AUTOFORMAT_ACCEPT); 296 aQBox.AddButton(String(SW_RES(STR_REDLINE_REJECT_ALL)), RET_CANCEL, BUTTONDIALOG_CANCELBUTTON); 297 aQBox.GetPushButton( RET_CANCEL )->SetHelpId(HID_AUTOFORMAT_REJECT ); 298 aQBox.AddButton(String(SW_RES(STR_REDLINE_EDIT)), 2, 0); 299 aQBox.GetPushButton( 2 )->SetHelpId(HID_AUTOFORMAT_EDIT_CHG); 300 aQBox.SetButtonHelpText( RET_OK, aEmptyStr ); 301 302 return aQBox.Execute(); 303 } 304 305 void SwTextShell::Execute(SfxRequest &rReq) 306 { 307 sal_Bool bUseDialog = sal_True; 308 const SfxItemSet *pArgs = rReq.GetArgs(); 309 SwWrtShell& rWrtSh = GetShell(); 310 const SfxPoolItem* pItem = 0; 311 sal_uInt16 nSlot = rReq.GetSlot(); 312 if(pArgs) 313 pArgs->GetItemState(GetPool().GetWhich(nSlot), sal_False, &pItem); 314 switch( nSlot ) 315 { 316 case SID_LANGUAGE_STATUS: 317 { 318 // get the language 319 String aNewLangTxt; 320 SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_LANGUAGE_STATUS , sal_False ); 321 if (pItem2) 322 aNewLangTxt = pItem2->GetValue(); 323 324 //!! Remember the view frame right now... 325 //!! (call to GetView().GetViewFrame() will break if the 326 //!! SwTextShell got destroyed meanwhile.) 327 SfxViewFrame *pViewFrame = GetView().GetViewFrame(); 328 329 if (aNewLangTxt.EqualsAscii( "*" )) 330 { 331 // open the dialog "Tools/Options/Language Settings - Language" 332 // to set the documents default language 333 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); 334 if (pFact) 335 { 336 VclAbstractDialog* pDlg = pFact->CreateVclDialog( GetView().GetWindow(), SID_LANGUAGE_OPTIONS ); 337 pDlg->Execute(); 338 delete pDlg; 339 } 340 } 341 else 342 { 343 //!! We have to use StartAction / EndAction bracketing in 344 //!! order to prevent possible destruction of the SwTextShell 345 //!! due to the selection changes coming below. 346 rWrtSh.StartAction(); 347 // prevent view from jumping because of (temporary) selection changes 348 rWrtSh.LockView( sal_True ); 349 350 // save selection for later restoration 351 rWrtSh.Push(); 352 353 // setting the new language... 354 if (aNewLangTxt.Len() > 0) 355 { 356 const String aSelectionLangPrefix( String::CreateFromAscii("Current_") ); 357 const String aParagraphLangPrefix( String::CreateFromAscii("Paragraph_") ); 358 const String aDocumentLangPrefix( String::CreateFromAscii("Default_") ); 359 const String aStrNone( String::CreateFromAscii("LANGUAGE_NONE") ); 360 const String aStrResetLangs( String::CreateFromAscii("RESET_LANGUAGES") ); 361 362 SfxItemSet aCoreSet( GetPool(), 363 RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE, 364 RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, 365 RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE, 366 0 ); 367 368 xub_StrLen nPos = 0; 369 bool bForSelection = true; 370 bool bForParagraph = false; 371 if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aSelectionLangPrefix, 0 ))) 372 { 373 // ... for the current selection 374 aNewLangTxt = aNewLangTxt.Erase( nPos, aSelectionLangPrefix.Len() ); 375 bForSelection = true; 376 } 377 else if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aParagraphLangPrefix , 0 ))) 378 { 379 // ... for the current paragraph language 380 aNewLangTxt = aNewLangTxt.Erase( nPos, aParagraphLangPrefix.Len() ); 381 bForSelection = true; 382 bForParagraph = true; 383 } 384 else if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aDocumentLangPrefix , 0 ))) 385 { 386 // ... as default document language 387 aNewLangTxt = aNewLangTxt.Erase( nPos, aDocumentLangPrefix.Len() ); 388 bForSelection = false; 389 } 390 391 if (bForParagraph) 392 SwLangHelper::SelectCurrentPara( rWrtSh ); 393 394 if (!bForSelection) // document language to be changed... 395 { 396 rWrtSh.SelAll(); 397 rWrtSh.ExtendedSelectAll(); 398 } 399 400 rWrtSh.StartUndo( ( !bForParagraph && !bForSelection ) ? UNDO_SETDEFTATTR : UNDO_EMPTY ); 401 if (aNewLangTxt == aStrNone) 402 SwLangHelper::SetLanguage_None( rWrtSh, bForSelection, aCoreSet ); 403 else if (aNewLangTxt == aStrResetLangs) 404 SwLangHelper::ResetLanguages( rWrtSh, bForSelection ); 405 else 406 SwLangHelper::SetLanguage( rWrtSh, aNewLangTxt, bForSelection, aCoreSet ); 407 rWrtSh.EndUndo(); 408 409 } 410 411 // restore selection... 412 rWrtSh.Pop( sal_False ); 413 414 rWrtSh.LockView( sal_False ); 415 rWrtSh.EndAction(); 416 } 417 418 // invalidate slot to get the new language displayed 419 pViewFrame->GetBindings().Invalidate( nSlot ); 420 421 rReq.Done(); 422 break; 423 } 424 425 case SID_THES: 426 { 427 // replace word/selection with text from selected sub menu entry 428 String aReplaceText; 429 SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES , sal_False ); 430 if (pItem2) 431 aReplaceText = pItem2->GetValue(); 432 if (aReplaceText.Len() > 0) 433 { 434 SwView &rView2 = rWrtSh.GetView(); 435 const bool bSelection = rWrtSh.HasSelection(); 436 const String aLookUpText = rView2.GetThesaurusLookUpText( bSelection ); 437 rView2.InsertThesaurusSynonym( aReplaceText, aLookUpText, bSelection ); 438 } 439 } 440 break; 441 442 case SID_CHARMAP: 443 { 444 InsertSymbol( rReq ); 445 } 446 break; 447 case FN_INSERT_FOOTNOTE: 448 case FN_INSERT_ENDNOTE: 449 { 450 String aStr; 451 SFX_REQUEST_ARG( rReq, pFont, SfxStringItem, FN_PARAM_1 , sal_False ); 452 // SFX_REQUEST_ARG( rReq, pCharset, SfxInt16Item, FN_PARAM_2 , sal_False ); 453 SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, nSlot , sal_False ); 454 if ( pNameItem ) 455 aStr = pNameItem->GetValue(); 456 sal_Bool bFont = pFont && pFont->GetValue().Len(); 457 rWrtSh.StartUndo( UNDO_UI_INSERT_FOOTNOTE ); 458 rWrtSh.InsertFootnote( aStr, nSlot == FN_INSERT_ENDNOTE, !bFont ); 459 if ( bFont ) 460 { 461 rWrtSh.Left( CRSR_SKIP_CHARS, sal_True, 1, sal_False ); 462 SfxItemSet aSet( rWrtSh.GetAttrPool(), RES_CHRATR_FONT, RES_CHRATR_FONT ); 463 rWrtSh.GetCurAttr( aSet ); 464 SvxFontItem &rFont = (SvxFontItem &) aSet.Get( RES_CHRATR_FONT ); 465 SvxFontItem aFont( rFont.GetFamily(), pFont->GetValue(), 466 rFont.GetStyleName(), rFont.GetPitch(), RTL_TEXTENCODING_DONTKNOW, RES_CHRATR_FONT ); 467 //pCharset ? (CharSet) pCharset->GetValue() : RTL_TEXTENCODING_DONTKNOW ); 468 rWrtSh.SetAttrSet( aSet, nsSetAttrMode::SETATTR_DONTEXPAND ); 469 rWrtSh.ResetSelect(0, sal_False); 470 rWrtSh.EndSelect(); 471 rWrtSh.GotoFtnTxt(); 472 } 473 rWrtSh.EndUndo( UNDO_UI_INSERT_FOOTNOTE ); 474 rReq.Done(); 475 } 476 break; 477 case FN_INSERT_FOOTNOTE_DLG: 478 { 479 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 480 DBG_ASSERT(pFact, "Dialogdiet fail!"); 481 AbstractInsFootNoteDlg* pDlg = pFact->CreateInsFootNoteDlg( DLG_INS_FOOTNOTE, 482 GetView().GetWindow(), rWrtSh, sal_False ); 483 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 484 pDlg->SetHelpId(GetStaticInterface()->GetSlot(nSlot)->GetCommand()); 485 if ( pDlg->Execute() == RET_OK ) 486 { 487 sal_uInt16 nId = pDlg->IsEndNote() ? FN_INSERT_ENDNOTE : FN_INSERT_FOOTNOTE; 488 SfxRequest aReq( GetView().GetViewFrame(), nId ); 489 if ( pDlg->GetStr().Len() ) 490 aReq.AppendItem( SfxStringItem( nId, pDlg->GetStr() ) ); 491 if ( pDlg->GetFontName().Len() ) 492 aReq.AppendItem( SfxStringItem( FN_PARAM_1, pDlg->GetFontName() ) ); 493 //aReq.AppendItem( SfxStringItem( FN_PARAM_2, pDlg->GetCharSet() ) ); 494 ExecuteSlot( aReq ); 495 } 496 497 rReq.Ignore(); 498 delete pDlg; 499 } 500 break; 501 case FN_FORMAT_FOOTNOTE_DLG: 502 { 503 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 504 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 505 506 VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( GetView().GetWindow(), rWrtSh, DLG_DOC_FOOTNOTE ); 507 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 508 pDlg->Execute(); 509 delete pDlg; 510 break; 511 } 512 case SID_INSERTDOC: 513 { 514 GetView().ExecuteInsertDoc( rReq, pItem ); 515 break; 516 } 517 case FN_FORMAT_RESET: 518 { 519 // #i78856, reset all attributes but not the language attributes 520 // (for this build an array of all relevant attributes and 521 // remove the languages from that) 522 SvUShortsSort aAttribs; 523 524 sal_uInt16 __FAR_DATA aResetableSetRange[] = { 525 RES_FRMATR_BEGIN, RES_FRMATR_END-1, 526 RES_CHRATR_BEGIN, RES_CHRATR_LANGUAGE - 1, 527 RES_CHRATR_LANGUAGE + 1, RES_CHRATR_CJK_LANGUAGE - 1, 528 RES_CHRATR_CJK_LANGUAGE + 1, RES_CHRATR_CTL_LANGUAGE - 1, 529 RES_CHRATR_CTL_LANGUAGE + 1, RES_CHRATR_END-1, 530 RES_PARATR_BEGIN, RES_PARATR_END-1, 531 RES_TXTATR_INETFMT, RES_TXTATR_INETFMT, 532 RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT, 533 RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY, 534 RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, 535 RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, 536 0 537 }; 538 sal_uInt16 __FAR_DATA *pUShorts = aResetableSetRange; 539 while (*pUShorts) 540 { 541 sal_uInt16 nL = pUShorts[1] - pUShorts[0] + 1; 542 sal_uInt16 nE = pUShorts[0]; 543 for (sal_uInt16 i = 0; i < nL; ++i) 544 aAttribs.Insert( nE++ ); 545 pUShorts += 2; 546 } 547 548 rWrtSh.ResetAttr( &aAttribs ); 549 rReq.Done(); 550 break; 551 } 552 case FN_INSERT_BREAK_DLG: 553 { 554 sal_uInt16 nKind=0, nPageNumber=0; 555 String aTemplateName; 556 if ( pItem ) 557 { 558 nKind = ((SfxInt16Item*)pItem)->GetValue(); 559 SFX_REQUEST_ARG( rReq, pTemplate, SfxStringItem, FN_PARAM_1 , sal_False ); 560 SFX_REQUEST_ARG( rReq, pNumber, SfxUInt16Item, FN_PARAM_2 , sal_False ); 561 if ( pTemplate ) 562 aTemplateName = pTemplate->GetValue(); 563 if ( pNumber ) 564 nPageNumber = pNumber->GetValue(); 565 } 566 else 567 { 568 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 569 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 570 571 AbstractSwBreakDlg* pDlg = pFact->CreateSwBreakDlg( GetView().GetWindow(), rWrtSh, DLG_BREAK ); 572 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 573 if ( pDlg->Execute() == RET_OK ) 574 { 575 nKind = pDlg->GetKind(); 576 aTemplateName = pDlg->GetTemplateName(); 577 nPageNumber = pDlg->GetPageNumber(); 578 rReq.AppendItem( SfxInt16Item( FN_INSERT_BREAK_DLG, nKind ) ); 579 rReq.AppendItem( SfxUInt16Item( FN_PARAM_2, nPageNumber ) ); 580 rReq.AppendItem( SfxStringItem( FN_PARAM_1, aTemplateName ) ); 581 rReq.Done(); 582 } 583 else 584 rReq.Ignore(); 585 delete pDlg; 586 } 587 588 switch ( nKind ) 589 { 590 case 1 : 591 rWrtSh.InsertLineBreak(); break; 592 case 2 : 593 rWrtSh.InsertColumnBreak(); break; 594 case 3 : 595 { 596 rWrtSh.StartAllAction(); 597 if( aTemplateName.Len() ) 598 rWrtSh.InsertPageBreak( &aTemplateName, nPageNumber ); 599 else 600 rWrtSh.InsertPageBreak(); 601 rWrtSh.EndAllAction(); 602 } 603 } 604 605 break; 606 } 607 case FN_INSERT_BOOKMARK: 608 { 609 if ( pItem ) 610 { 611 ::rtl::OUString sName = ((SfxStringItem*)pItem)->GetValue(); 612 rWrtSh.SetBookmark( KeyCode(), sName, aEmptyStr ); 613 } 614 else 615 { 616 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 617 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 618 619 VclAbstractDialog* pDlg = pFact->CreateSwInsertBookmarkDlg( GetView().GetWindow(), rWrtSh, rReq, DLG_INSERT_BOOKMARK ); 620 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 621 pDlg->Execute(); 622 delete pDlg; 623 } 624 625 break; 626 } 627 case FN_DELETE_BOOKMARK: 628 { 629 if ( pItem ) 630 { 631 IDocumentMarkAccess* const pMarkAccess = rWrtSh.getIDocumentMarkAccess(); 632 pMarkAccess->deleteMark( pMarkAccess->findMark(((SfxStringItem*)pItem)->GetValue()) ); 633 } 634 break; 635 } 636 case FN_AUTOFORMAT_REDLINE_APPLY: 637 { 638 SvxSwAutoFmtFlags aFlags(SvxAutoCorrCfg::Get()->GetAutoCorrect()->GetSwFlags()); 639 // das muss fuer die Nachbearbeitung immer sal_False sein 640 aFlags.bAFmtByInput = sal_False; 641 aFlags.bWithRedlining = sal_True; 642 rWrtSh.AutoFormat( &aFlags ); 643 aFlags.bWithRedlining = sal_False; 644 645 SfxViewFrame* pVFrame = GetView().GetViewFrame(); 646 if (pVFrame->HasChildWindow(FN_REDLINE_ACCEPT)) 647 pVFrame->ToggleChildWindow(FN_REDLINE_ACCEPT); 648 649 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 650 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 651 652 AbstractSwModalRedlineAcceptDlg* pDlg = pFact->CreateSwModalRedlineAcceptDlg( &GetView().GetEditWin(), DLG_MOD_REDLINE_ACCEPT ); 653 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 654 655 switch (lcl_AskRedlineMode(&GetView().GetEditWin())) 656 { 657 case RET_OK: 658 { 659 pDlg->AcceptAll(sal_True); 660 SfxRequest aReq( pVFrame, FN_AUTOFORMAT_APPLY ); 661 aReq.Done(); 662 rReq.Ignore(); 663 break; 664 } 665 666 case RET_CANCEL: 667 pDlg->AcceptAll(sal_False); 668 rReq.Ignore(); 669 break; 670 671 case 2: 672 pDlg->Execute(); 673 rReq.Done(); 674 break; 675 } 676 delete pDlg; 677 } 678 break; 679 680 case FN_AUTOFORMAT_APPLY: 681 { 682 SvxSwAutoFmtFlags aFlags(SvxAutoCorrCfg::Get()->GetAutoCorrect()->GetSwFlags()); 683 // das muss fuer die Nachbearbeitung immer sal_False sein 684 aFlags.bAFmtByInput = sal_False; 685 rWrtSh.AutoFormat( &aFlags ); 686 rReq.Done(); 687 } 688 break; 689 case FN_AUTOFORMAT_AUTO: 690 { 691 SvxAutoCorrCfg* pACfg = SvxAutoCorrCfg::Get(); 692 sal_Bool bSet = pItem ? ((const SfxBoolItem*)pItem)->GetValue() : !pACfg->IsAutoFmtByInput(); 693 if( bSet != pACfg->IsAutoFmtByInput() ) 694 { 695 pACfg->SetAutoFmtByInput( bSet ); 696 GetView().GetViewFrame()->GetBindings().Invalidate( nSlot ); 697 if ( !pItem ) 698 rReq.AppendItem( SfxBoolItem( GetPool().GetWhich(nSlot), bSet ) ); 699 rReq.Done(); 700 } 701 } 702 break; 703 case FN_AUTO_CORRECT: 704 { 705 // erstmal auf Blank defaulten 706 sal_Unicode cChar = ' '; 707 rWrtSh.AutoCorrect( *SvxAutoCorrCfg::Get()->GetAutoCorrect(), cChar ); 708 rReq.Done(); 709 } 710 break; 711 case FN_TABLE_SORT_DIALOG: 712 case FN_SORTING_DLG: 713 { 714 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 715 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 716 717 VclAbstractDialog* pDlg = pFact->CreateVclAbstractDialog( GetView().GetWindow(), rWrtSh, DLG_SORTING ); 718 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 719 pDlg->Execute(); 720 delete pDlg; 721 rReq.Done(); 722 } 723 break; 724 case FN_NUMBERING_OUTLINE_DLG: 725 { 726 SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1); 727 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 728 DBG_ASSERT(pFact, "Dialogdiet fail!"); 729 SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE, 730 GetView().GetWindow(), &aTmp, rWrtSh); 731 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 732 pDlg->Execute(); 733 delete pDlg; 734 rReq.Done(); 735 } 736 break; 737 case FN_CALCULATE: 738 { 739 SwTransferable* pTransfer = new SwTransferable( rWrtSh ); 740 /*??*/ uno::Reference< 741 datatransfer::XTransferable > xRef( 742 pTransfer ); 743 pTransfer->CalculateAndCopy(); 744 rReq.Done(); 745 } 746 break; 747 case FN_GOTO_REFERENCE: 748 { 749 SwField *pFld = rWrtSh.GetCurFld(); 750 if(pFld && pFld->GetTypeId() == TYP_GETREFFLD) 751 { 752 rWrtSh.StartAllAction(); 753 rWrtSh.SwCrsrShell::GotoRefMark( ((SwGetRefField*)pFld)->GetSetRefName(), 754 ((SwGetRefField*)pFld)->GetSubType(), 755 ((SwGetRefField*)pFld)->GetSeqNo() ); 756 rWrtSh.EndAllAction(); 757 rReq.Done(); 758 } 759 } 760 break; 761 case FN_EDIT_FORMULA: 762 { 763 const sal_uInt16 nId = SwInputChild::GetChildWindowId(); 764 SfxViewFrame* pVFrame = GetView().GetViewFrame(); 765 if(pItem) 766 { 767 //if the ChildWindow is active it has to be removed 768 if( pVFrame->HasChildWindow( nId ) ) 769 { 770 pVFrame->ToggleChildWindow( nId ); 771 pVFrame->GetBindings().InvalidateAll( sal_True ); 772 } 773 774 String sFormula(((const SfxStringItem*)pItem)->GetValue()); 775 SwFldMgr aFldMgr; 776 rWrtSh.StartAllAction(); 777 sal_Bool bDelSel; 778 if( 0 != (bDelSel = rWrtSh.HasSelection()) ) 779 { 780 rWrtSh.StartUndo( UNDO_START ); 781 rWrtSh.DelRight(); 782 } 783 else 784 { 785 rWrtSh.EnterStdMode(); 786 } 787 788 if( !bDelSel && aFldMgr.GetCurFld() && TYP_FORMELFLD == aFldMgr.GetCurTypeId() ) 789 aFldMgr.UpdateCurFld( aFldMgr.GetCurFld()->GetFormat(), aEmptyStr, sFormula ); 790 else if( sFormula.Len() ) 791 { 792 if( rWrtSh.IsCrsrInTbl() ) 793 { 794 SfxItemSet aSet( rWrtSh.GetAttrPool(), RES_BOXATR_FORMULA, RES_BOXATR_FORMULA ); 795 aSet.Put( SwTblBoxFormula( sFormula )); 796 rWrtSh.SetTblBoxFormulaAttrs( aSet ); 797 rWrtSh.UpdateTable(); 798 } 799 else 800 { 801 SvNumberFormatter* pFormatter = rWrtSh.GetNumberFormatter(); 802 sal_uLong nSysNumFmt = pFormatter->GetFormatIndex( NF_NUMBER_STANDARD, LANGUAGE_SYSTEM); 803 SwInsertFld_Data aData(TYP_FORMELFLD, nsSwGetSetExpType::GSE_FORMULA, aEmptyStr, sFormula, nSysNumFmt); 804 aFldMgr.InsertFld(aData); 805 } 806 } 807 808 if( bDelSel ) 809 rWrtSh.EndUndo( UNDO_END ); 810 rWrtSh.EndAllAction(); 811 rReq.Done(); 812 } 813 else 814 { 815 rWrtSh.EndAllTblBoxEdit(); 816 pVFrame->ToggleChildWindow( nId ); 817 if( !pVFrame->HasChildWindow( nId ) ) 818 pVFrame->GetBindings().InvalidateAll( sal_True ); 819 rReq.Ignore(); 820 } 821 } 822 823 break; 824 case FN_TABLE_UNSET_READ_ONLY: 825 { 826 rWrtSh.UnProtectTbls(); 827 } 828 break; 829 case FN_EDIT_HYPERLINK: 830 GetView().GetViewFrame()->ToggleChildWindow(SID_HYPERLINK_DIALOG); 831 break; 832 case FN_REMOVE_HYPERLINK: 833 { 834 sal_Bool bSel = rWrtSh.HasSelection(); 835 if(!bSel) 836 { 837 rWrtSh.StartAction(); 838 rWrtSh.Push(); 839 if(!rWrtSh.SelectTxtAttr( RES_TXTATR_INETFMT )) 840 rWrtSh.SelWrd(); 841 } 842 //now remove the attribute 843 SvUShortsSort aAttribs; 844 aAttribs.Insert( RES_TXTATR_INETFMT ); 845 rWrtSh.ResetAttr( &aAttribs ); 846 if(!bSel) 847 { 848 rWrtSh.Pop(sal_False); 849 rWrtSh.EndAction(); 850 } 851 } 852 break; 853 case SID_ATTR_BRUSH_CHAR : 854 case SID_ATTR_CHAR_SCALEWIDTH : 855 case SID_ATTR_CHAR_ROTATED : 856 case FN_TXTATR_INET : 857 case FN_INSERT_HYPERLINK: 858 { 859 sal_uInt16 nWhich = GetPool().GetWhich( nSlot ); 860 if ( pArgs && pArgs->GetItemState( nWhich ) == SFX_ITEM_SET ) 861 bUseDialog = sal_False; 862 // intentionally no break 863 } 864 case SID_CHAR_DLG: 865 case SID_CHAR_DLG_EFFECT: 866 { 867 lcl_CharDialog( rWrtSh, bUseDialog, nSlot, pArgs, &rReq ); 868 } 869 break; 870 case SID_CHAR_DLG_FOR_PARAGRAPH: 871 { 872 rWrtSh.Push(); //save current cursor 873 SwLangHelper::SelectCurrentPara( rWrtSh ); 874 lcl_CharDialog( rWrtSh, bUseDialog, nSlot, pArgs, &rReq ); 875 rWrtSh.Pop( sal_False ); //restore old cursor 876 } 877 break; 878 case SID_ATTR_LRSPACE : 879 case SID_ATTR_ULSPACE : 880 case SID_ATTR_BRUSH : 881 case SID_PARA_VERTALIGN : 882 case SID_ATTR_PARA_NUMRULE : 883 case SID_ATTR_PARA_REGISTER : 884 case SID_ATTR_PARA_PAGENUM : 885 case FN_FORMAT_LINENUMBER : 886 case FN_NUMBER_NEWSTART : 887 case FN_NUMBER_NEWSTART_AT : 888 case FN_FORMAT_DROPCAPS : 889 case FN_DROP_TEXT: 890 case SID_ATTR_PARA_LRSPACE: 891 { 892 sal_uInt16 nWhich = GetPool().GetWhich( nSlot ); 893 if ( pArgs && pArgs->GetItemState( nWhich ) == SFX_ITEM_SET ) 894 bUseDialog = sal_False; 895 // intentionally no break 896 897 } 898 case SID_PARA_DLG: 899 { 900 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &GetView())); 901 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric))); 902 SfxItemSet aCoreSet( GetPool(), //UUUU sorted by indices, one group of three concatenated 903 RES_PARATR_BEGIN, RES_PARATR_END - 1, // [60 904 RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END - 1, // [77 905 RES_FRMATR_BEGIN, RES_FRMATR_END - 1, // [82 906 907 //UUUU FillAttribute support 908 XATTR_FILL_FIRST, XATTR_FILL_LAST, // [1014 909 910 // includes SID_ATTR_TABSTOP_POS 911 SID_ATTR_TABSTOP_DEFAULTS, SID_ATTR_TABSTOP_OFFSET, // [10003 .. 10005 912 913 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, // [10023 914 SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP, // [10065 915 916 //UUUU items to hand over XPropertyList things like 917 // XColorList, XHatchList, XGradientList and XBitmapList 918 // to the Area TabPage 919 SID_COLOR_TABLE, SID_BITMAP_LIST, // [10179 920 921 SID_HTML_MODE, SID_HTML_MODE, // [10414 922 SID_ATTR_PARA_PAGENUM, SID_ATTR_PARA_PAGENUM, // [10457 923 FN_PARAM_1, FN_PARAM_1, // [21160 924 FN_NUMBER_NEWSTART, FN_NUMBER_NEWSTART_AT, // [21738 925 FN_DROP_TEXT, FN_DROP_CHAR_STYLE_NAME, // [22418 926 0); 927 928 // get also the list level indent values merged as LR-SPACE item, if needed. 929 rWrtSh.GetCurAttr( aCoreSet, true ); 930 931 //UUUU create needed items for XPropertyList entries from the DrawModel so that 932 // the Area TabPage can access them 933 // Do this after GetCurAttr, this resets the ItemSet content again 934 const SdrModel* pDrawModel = GetView().GetDocShell()->GetDoc()->GetDrawModel(); 935 936 aCoreSet.Put(SvxColorTableItem(pDrawModel->GetColorTableFromSdrModel(), SID_COLOR_TABLE)); 937 aCoreSet.Put(SvxGradientListItem(pDrawModel->GetGradientListFromSdrModel(), SID_GRADIENT_LIST)); 938 aCoreSet.Put(SvxHatchListItem(pDrawModel->GetHatchListFromSdrModel(), SID_HATCH_LIST)); 939 aCoreSet.Put(SvxBitmapListItem(pDrawModel->GetBitmapListFromSdrModel(), SID_BITMAP_LIST)); 940 941 aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE, 942 ::GetHtmlMode(GetView().GetDocShell()))); 943 944 // Tabulatoren, DefaultTabs ins ItemSet Stecken 945 const SvxTabStopItem& rDefTabs = (const SvxTabStopItem&) 946 GetPool().GetDefaultItem(RES_PARATR_TABSTOP); 947 948 sal_uInt16 nDefDist = ::GetTabDist( rDefTabs ); 949 SfxUInt16Item aDefDistItem( SID_ATTR_TABSTOP_DEFAULTS, nDefDist ); 950 aCoreSet.Put( aDefDistItem ); 951 952 // Aktueller Tab 953 SfxUInt16Item aTabPos( SID_ATTR_TABSTOP_POS, 0 ); 954 aCoreSet.Put( aTabPos ); 955 956 // linker Rand als Offset 957 //#i24363# tab stops relative to indent 958 const long nOff = rWrtSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT) ? 959 ((SvxLRSpaceItem&)aCoreSet.Get( RES_LR_SPACE )).GetTxtLeft() : 0; 960 SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff ); 961 aCoreSet.Put( aOff ); 962 963 // BoxInfo setzen 964 ::PrepareBoxInfo( aCoreSet, rWrtSh ); 965 966 //aktuelles Seitenformat 967 ::SwToSfxPageDescAttr( aCoreSet ); 968 969 sal_uInt16 nDefPage = 0; 970 if( pItem ) 971 nDefPage = ((SfxUInt16Item *)pItem)->GetValue(); 972 973 // Numerierungseigenschaften 974 if(rWrtSh.GetNumRuleAtCurrCrsrPos()) 975 { 976 SfxBoolItem aStart( FN_NUMBER_NEWSTART, rWrtSh.IsNumRuleStart() ); 977 aCoreSet.Put(aStart); 978 // --> OD 2008-02-29 #refactorlists# 979 // SfxUInt16Item aStartAt(FN_NUMBER_NEWSTART_AT, 980 // rWrtSh.IsNodeNumStart()); 981 SfxUInt16Item aStartAt( FN_NUMBER_NEWSTART_AT, 982 rWrtSh.GetNodeNumStart() ); 983 // <-- 984 aCoreSet.Put(aStartAt); 985 } 986 SfxAbstractTabDialog* pDlg = NULL; 987 988 if ( bUseDialog && GetActiveView() ) 989 { 990 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 991 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 992 993 pDlg = pFact->CreateSwParaDlg( GetView().GetWindow(),GetView(), aCoreSet,DLG_STD, DLG_PARA,NULL, sal_False, nDefPage ); 994 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 995 } 996 SfxItemSet* pSet = NULL; 997 if ( !bUseDialog ) 998 { 999 if ( nSlot == SID_ATTR_PARA_LRSPACE) 1000 { 1001 SvxLRSpaceItem aParaMargin((const SvxLRSpaceItem&)pArgs->Get(nSlot)); 1002 aParaMargin.SetWhich( RES_LR_SPACE); 1003 aCoreSet.Put(aParaMargin); 1004 pSet = &aCoreSet; 1005 1006 } else 1007 pSet = (SfxItemSet*) pArgs; 1008 1009 } 1010 else if ( NULL != pDlg && pDlg->Execute() == RET_OK ) 1011 { 1012 // Defaults evtl umsetzen 1013 pSet = (SfxItemSet*)pDlg->GetOutputItemSet(); 1014 sal_uInt16 nNewDist; 1015 if( SFX_ITEM_SET == pSet->GetItemState( SID_ATTR_TABSTOP_DEFAULTS, sal_False, &pItem ) && 1016 nDefDist != (nNewDist = ((SfxUInt16Item*)pItem)->GetValue()) ) 1017 { 1018 SvxTabStopItem aDefTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP ); 1019 MakeDefTabs( nNewDist, aDefTabs ); 1020 rWrtSh.SetDefault( aDefTabs ); 1021 pSet->ClearItem( SID_ATTR_TABSTOP_DEFAULTS ); 1022 } 1023 1024 if ( SFX_ITEM_SET == pSet->GetItemState(FN_PARAM_1,sal_False,&pItem) ) 1025 { 1026 pSet->Put(SfxStringItem(FN_DROP_TEXT, ((const SfxStringItem*)pItem)->GetValue())); 1027 pSet->ClearItem(FN_PARAM_1); 1028 } 1029 1030 if( SFX_ITEM_SET == pSet->GetItemState( RES_PARATR_DROP, sal_False, &pItem )) 1031 { 1032 String sCharStyleName; 1033 if(((const SwFmtDrop*)pItem)->GetCharFmt()) 1034 sCharStyleName = ((const SwFmtDrop*)pItem)->GetCharFmt()->GetName(); 1035 pSet->Put(SfxStringItem(FN_DROP_CHAR_STYLE_NAME, sCharStyleName)); 1036 } 1037 } 1038 1039 if ( pSet ) 1040 { 1041 rReq.Done( *pSet ); 1042 ::SfxToSwPageDescAttr( rWrtSh, *pSet ); 1043 // --> OD 2006-12-06 #i56253# 1044 // enclose all undos. 1045 // Thus, check conditions, if actions will be performed. 1046 const bool bUndoNeeded( pSet->Count() || 1047 SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART) || 1048 SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) ); 1049 if ( bUndoNeeded ) 1050 { 1051 rWrtSh.StartUndo( UNDO_INSATTR ); 1052 } 1053 // <-- 1054 if( pSet->Count() ) 1055 { 1056 rWrtSh.StartAction(); 1057 // rWrtSh.StartUndo( UNDO_START ); 1058 if ( SFX_ITEM_SET == pSet->GetItemState(FN_DROP_TEXT, sal_False, &pItem) ) 1059 { 1060 if ( ((SfxStringItem*)pItem)->GetValue().Len() ) 1061 rWrtSh.ReplaceDropTxt(((SfxStringItem*)pItem)->GetValue()); 1062 } 1063 rWrtSh.SetAttrSet( *pSet ); 1064 // rWrtSh.EndUndo( UNDO_END ); 1065 rWrtSh.EndAction(); 1066 SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl(); 1067 if(pColl && pColl->IsAutoUpdateFmt()) 1068 { 1069 rWrtSh.AutoUpdatePara(pColl, *pSet); 1070 } 1071 } 1072 1073 if( SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART) ) 1074 { 1075 //SetNumRuleStart(sal_True) restarts the numbering at the value 1076 //that is defined at the starting point of the numbering level 1077 //otherwise the SetNodeNumStart() value determines the start 1078 //if it's set to something different than (sal_uInt16)0xFFFF 1079 1080 sal_Bool bStart = ((SfxBoolItem&)pSet->Get(FN_NUMBER_NEWSTART)).GetValue(); 1081 // --> OD 2007-06-11 #b6560525# 1082 // Default value for restart value has to be (sal_uInt16)0xFFFF 1083 // in order to indicate that the restart value of the list 1084 // style has to be used on restart. 1085 sal_uInt16 nNumStart = (sal_uInt16)0xFFFF; 1086 // <-- 1087 if( SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) ) 1088 { 1089 nNumStart = ((SfxUInt16Item&)pSet->Get(FN_NUMBER_NEWSTART_AT)).GetValue(); 1090 } 1091 rWrtSh.SetNumRuleStart(bStart); 1092 rWrtSh.SetNodeNumStart(nNumStart); 1093 } 1094 else if( SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) ) 1095 { 1096 sal_uInt16 nNumStart = ((SfxUInt16Item&)pSet->Get(FN_NUMBER_NEWSTART_AT)).GetValue(); 1097 rWrtSh.SetNodeNumStart(nNumStart); 1098 rWrtSh.SetNumRuleStart(sal_False); 1099 } 1100 // --> OD 2006-12-06 #i56253# 1101 if ( bUndoNeeded ) 1102 { 1103 rWrtSh.EndUndo( UNDO_INSATTR ); 1104 } 1105 // <-- 1106 } 1107 1108 delete pDlg; 1109 } 1110 break; 1111 case FN_NUM_CONTINUE: 1112 { 1113 // --> OD 2008-03-18 #refactorlists# 1114 String sContinuedListId; 1115 const SwNumRule* pRule = 1116 rWrtSh.SearchNumRule( false, true, false, -1, sContinuedListId ); 1117 // --> OD 2009-08-26 #i86492# 1118 // Search also for bullet list 1119 if ( !pRule ) 1120 { 1121 pRule = rWrtSh.SearchNumRule( false, false, false, -1, sContinuedListId ); 1122 } 1123 // <-- 1124 if ( pRule ) 1125 { 1126 rWrtSh.SetCurNumRule( *pRule, false, sContinuedListId ); 1127 } 1128 // <-- 1129 } 1130 break; 1131 1132 case FN_SELECT_PARA: 1133 { 1134 if ( !rWrtSh.IsSttOfPara() ) 1135 rWrtSh.SttPara( sal_False ); 1136 else 1137 rWrtSh.EnterStdMode(); 1138 rWrtSh.EndPara( sal_True ); 1139 } 1140 break; 1141 1142 case SID_DEC_INDENT: 1143 case SID_INC_INDENT: 1144 //According to the requirement, modified the behavior when user 1145 //using the indent button on the toolbar. Now if we increase/decrease indent for a 1146 //paragraph which has bullet style it will increase/decrease the bullet level. 1147 { 1148 //If the current paragraph has bullet call the function to 1149 //increase or decrease the bullet level. 1150 //Why could I know wheter a paragraph has bullet or not by checking the below conditions? 1151 //Please refer to the "case KEY_TAB:" section in SwEditWin::KeyInput(..) : 1152 // if( rSh.GetCurNumRule() && rSh.IsSttOfPara() && 1153 // !rSh.HasReadonlySel() ) 1154 // eKeyState = KS_NumDown; 1155 //Above code demonstrates that when the cursor is at the start of a paragraph which has bullet, 1156 //press TAB will increase the bullet level. 1157 //So I copied from that ^^ 1158 if ( rWrtSh.GetNumRuleAtCurrCrsrPos() && !rWrtSh.HasReadonlySel() ) 1159 { 1160 rWrtSh.NumUpDown( SID_INC_INDENT == nSlot ); 1161 } 1162 else //execute the original processing functions 1163 { 1164 //below is copied of the old codes 1165 rWrtSh.MoveLeftMargin( SID_INC_INDENT == nSlot, rReq.GetModifier() != KEY_MOD1 ); 1166 } 1167 } 1168 rReq.Done(); 1169 break; 1170 1171 case FN_DEC_INDENT_OFFSET: 1172 case FN_INC_INDENT_OFFSET: 1173 rWrtSh.MoveLeftMargin( FN_INC_INDENT_OFFSET == nSlot, rReq.GetModifier() == KEY_MOD1 ); 1174 rReq.Done(); 1175 break; 1176 1177 case SID_ATTR_CHAR_COLOR2: 1178 { 1179 if(pItem) 1180 { 1181 Color aSet = ((const SvxColorItem*)pItem)->GetValue(); 1182 SwEditWin& rEditWin = GetView().GetEditWin(); 1183 rEditWin.SetTextColor(aSet); 1184 SwApplyTemplate* pApply = rEditWin.GetApplyTemplate(); 1185 SvxColorItem aItem(aSet, RES_CHRATR_COLOR); 1186 1187 // besteht eine Selektion, wird sie gleich gefaerbt 1188 if(!pApply && rWrtSh.HasSelection()) 1189 { 1190 rWrtSh.SetAttrItem(SvxColorItem (aSet, RES_CHRATR_COLOR)); 1191 } 1192 else if(!pApply || pApply->nColor != SID_ATTR_CHAR_COLOR_EXT) 1193 { 1194 GetView().GetViewFrame()->GetDispatcher()->Execute(SID_ATTR_CHAR_COLOR_EXT); 1195 } 1196 1197 rReq.Done(); 1198 } 1199 } 1200 break; 1201 case SID_ATTR_CHAR_COLOR_BACKGROUND: 1202 { 1203 SwEditWin& rEdtWin = GetView().GetEditWin(); 1204 SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate(); 1205 rEdtWin.SetTextBackColorTransparent(0 == pItem); 1206 Color aSet; 1207 if(pItem) 1208 { 1209 aSet = ((const SvxColorItem*)pItem)->GetValue(); 1210 rEdtWin.SetTextBackColor(aSet); 1211 } 1212 if(!pApply && (rWrtSh.HasSelection() || rReq.IsAPI())) 1213 { 1214 SvxBrushItem aBrushItem(RES_CHRATR_BACKGROUND); 1215 if(pItem) 1216 aBrushItem.SetColor(aSet); 1217 else 1218 aBrushItem.SetColor(Color(COL_TRANSPARENT)); 1219 rWrtSh.SetAttrItem( aBrushItem ); 1220 } 1221 else if(!pApply || pApply->nColor != SID_ATTR_CHAR_COLOR_BACKGROUND_EXT) 1222 { 1223 GetView().GetViewFrame()->GetDispatcher()->Execute(SID_ATTR_CHAR_COLOR_BACKGROUND_EXT); 1224 } 1225 1226 rReq.Done(); 1227 1228 } 1229 break; 1230 case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT: 1231 case SID_ATTR_CHAR_COLOR_EXT: 1232 { 1233 SwEditWin& rEdtWin = GetView().GetEditWin(); 1234 SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate(); 1235 SwApplyTemplate aTempl; 1236 sal_Bool bSelection = rWrtSh.HasSelection(); 1237 if(bSelection) 1238 { 1239 1240 if(nSlot == SID_ATTR_CHAR_COLOR_BACKGROUND_EXT) 1241 { 1242 rWrtSh.SetAttrItem( 1243 SvxBrushItem( rEdtWin.GetTextBackColor(), RES_CHRATR_BACKGROUND) ); 1244 } 1245 else 1246 rWrtSh.SetAttrItem( 1247 SvxColorItem( rEdtWin.GetTextColor(), RES_CHRATR_COLOR) ); 1248 } 1249 else 1250 { 1251 if(!pApply || pApply->nColor != nSlot) 1252 aTempl.nColor = nSlot; 1253 rEdtWin.SetApplyTemplate(aTempl); 1254 } 1255 1256 rReq.Done(); 1257 } 1258 break; 1259 1260 case FN_NUM_BULLET_MOVEDOWN: 1261 if (!rWrtSh.IsAddMode()) 1262 rWrtSh.MoveParagraph(1); 1263 rReq.Done(); 1264 break; 1265 1266 case FN_NUM_BULLET_MOVEUP: 1267 if (!rWrtSh.IsAddMode()) 1268 rWrtSh.MoveParagraph(-1); 1269 rReq.Done(); 1270 break; 1271 case SID_RUBY_DIALOG: 1272 case SID_HYPERLINK_DIALOG: 1273 { 1274 SfxRequest aReq(nSlot, SFX_CALLMODE_SLOT, SFX_APP()->GetPool()); 1275 GetView().GetViewFrame()->ExecuteSlot( aReq); 1276 rReq.Ignore(); 1277 } 1278 break; 1279 case FN_INSERT_PAGEHEADER: 1280 case FN_INSERT_PAGEFOOTER: 1281 if(pArgs && pArgs->Count()) 1282 { 1283 String sStyleName; 1284 if(pItem) 1285 sStyleName = ((const SfxStringItem*)pItem)->GetValue(); 1286 sal_Bool bOn = sal_True; 1287 if( SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_1, sal_False, &pItem)) 1288 bOn = ((const SfxBoolItem*)pItem)->GetValue(); 1289 ChangeHeaderOrFooter(sStyleName, FN_INSERT_PAGEHEADER == nSlot, bOn, !rReq.IsAPI()); 1290 rReq.Done(); 1291 } 1292 break; 1293 case FN_READONLY_SELECTION_MODE : 1294 if(GetView().GetDocShell()->IsReadOnly()) 1295 { 1296 rWrtSh.SetReadonlySelectionOption( 1297 !rWrtSh.GetViewOptions()->IsSelectionInReadonly()); 1298 rWrtSh.ShowCrsr(); 1299 } 1300 break; 1301 case FN_SELECTION_MODE_DEFAULT: 1302 case FN_SELECTION_MODE_BLOCK : 1303 { 1304 bool bSetBlockMode = !rWrtSh.IsBlockMode(); 1305 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(nSlot, sal_False, &pItem)) 1306 bSetBlockMode = ((const SfxBoolItem*)pItem)->GetValue(); 1307 if( ( nSlot == FN_SELECTION_MODE_DEFAULT ) ^ bSetBlockMode ) 1308 rWrtSh.EnterBlockMode(); 1309 else 1310 rWrtSh.EnterStdMode(); 1311 SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings(); 1312 rBnd.Invalidate(FN_STAT_SELMODE); 1313 rBnd.Update(FN_STAT_SELMODE); 1314 } 1315 break; 1316 case SID_OPEN_HYPERLINK: 1317 case FN_COPY_HYPERLINK_LOCATION: 1318 { 1319 SfxItemSet aSet(GetPool(), 1320 RES_TXTATR_INETFMT, 1321 RES_TXTATR_INETFMT); 1322 rWrtSh.GetCurAttr(aSet); 1323 if(SFX_ITEM_SET <= aSet.GetItemState( RES_TXTATR_INETFMT, sal_True )) 1324 { 1325 const SwFmtINetFmt& rINetFmt = dynamic_cast<const SwFmtINetFmt&>( aSet.Get(RES_TXTATR_INETFMT, sal_True) ); 1326 if( nSlot == FN_COPY_HYPERLINK_LOCATION ) 1327 { 1328 ::uno::Reference< datatransfer::clipboard::XClipboard > xClipboard = GetView().GetEditWin().GetClipboard(); 1329 vcl::unohelper::TextDataObject::CopyStringTo( 1330 rINetFmt.GetValue(), 1331 xClipboard ); 1332 } 1333 else 1334 rWrtSh.ClickToINetAttr(rINetFmt, URLLOAD_NOFILTER); 1335 } 1336 } 1337 break; 1338 case SID_OPEN_XML_FILTERSETTINGS: 1339 { 1340 try 1341 { 1342 uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY); 1343 if( xDialog.is() ) 1344 { 1345 xDialog->execute(); 1346 } 1347 } 1348 catch( uno::Exception& ) 1349 { 1350 } 1351 rReq.Ignore (); 1352 } 1353 break; 1354 case FN_FORMAT_APPLY_HEAD1: 1355 { 1356 } 1357 break; 1358 case FN_FORMAT_APPLY_HEAD2: 1359 { 1360 } 1361 break; 1362 case FN_FORMAT_APPLY_HEAD3: 1363 { 1364 } 1365 break; 1366 case FN_FORMAT_APPLY_DEFAULT: 1367 { 1368 } 1369 break; 1370 case FN_FORMAT_APPLY_TEXTBODY: 1371 { 1372 } 1373 break; 1374 case FN_WORDCOUNT_DIALOG: 1375 { 1376 SwWrtShell &rSh = GetShell(); 1377 SwDocStat aCurr; 1378 SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() ); 1379 { 1380 SwWait aWait( *GetView().GetDocShell(), true ); 1381 rSh.StartAction(); 1382 rSh.CountWords( aCurr ); 1383 rSh.UpdateDocStat( aDocStat ); 1384 rSh.EndAction(); 1385 } 1386 1387 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 1388 DBG_ASSERT(pFact, "Dialogdiet fail!"); 1389 AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() ); 1390 pDialog->SetValues(aCurr, aDocStat ); 1391 pDialog->Execute(); 1392 delete pDialog; 1393 } 1394 break; 1395 default: 1396 ASSERT(!this, falscher Dispatcher); 1397 return; 1398 } 1399 } 1400 1401 1402 /*-------------------------------------------------------------------- 1403 Beschreibung: 1404 --------------------------------------------------------------------*/ 1405 1406 1407 void SwTextShell::GetState( SfxItemSet &rSet ) 1408 { 1409 SwWrtShell &rSh = GetShell(); 1410 SfxWhichIter aIter( rSet ); 1411 sal_uInt16 nWhich = aIter.FirstWhich(); 1412 while ( nWhich ) 1413 { 1414 switch ( nWhich ) 1415 { 1416 case SID_LANGUAGE_STATUS: 1417 { 1418 // the value of used script types 1419 String aScriptTypesInUse( String::CreateFromInt32( rSh.GetScriptType() ) ); 1420 1421 SvtLanguageTable aLangTable; 1422 1423 // get keyboard language 1424 String aKeyboardLang; 1425 LanguageType nLang = LANGUAGE_DONTKNOW; 1426 SwEditWin& rEditWin = GetView().GetEditWin(); 1427 nLang = rEditWin.GetInputLanguage(); 1428 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) 1429 aKeyboardLang = aLangTable.GetString( nLang ); 1430 1431 // get the language that is in use 1432 const String aMultipleLanguages = String::CreateFromAscii("*"); 1433 String aCurrentLang = aMultipleLanguages; 1434 nLang = SwLangHelper::GetCurrentLanguage( rSh ); 1435 if (nLang != LANGUAGE_DONTKNOW) 1436 aCurrentLang = aLangTable.GetString( nLang ); 1437 1438 // build sequence for status value 1439 uno::Sequence< ::rtl::OUString > aSeq( 4 ); 1440 aSeq[0] = aCurrentLang; 1441 aSeq[1] = aScriptTypesInUse; 1442 aSeq[2] = aKeyboardLang; 1443 aSeq[3] = SwLangHelper::GetTextForLanguageGuessing( rSh ); 1444 1445 // set sequence as status value 1446 SfxStringListItem aItem( SID_LANGUAGE_STATUS ); 1447 aItem.SetStringList( aSeq ); 1448 rSet.Put( aItem, SID_LANGUAGE_STATUS ); 1449 } 1450 break; 1451 1452 case SID_THES: 1453 { 1454 // is there a valid selection to get text from? 1455 String aText; 1456 sal_Bool bValid = !rSh.HasSelection() || 1457 (rSh.IsSelOnePara() && !rSh.IsMultiSelection()); 1458 // prevent context menu from showing when cursor is not in or at the end of a word 1459 // (GetCurWord will return the next word if there is none at the current position...) 1460 const sal_Int16 nWordType = ::i18n::WordType::DICTIONARY_WORD; 1461 bool bWord = rSh.IsInWord( nWordType ) || rSh.IsStartWord( nWordType ) || rSh.IsEndWord( nWordType ); 1462 if (bValid && bWord) 1463 aText = rSh.HasSelection()? rSh.GetSelTxt() : rSh.GetCurWord(); 1464 1465 LanguageType nLang = rSh.GetCurLang(); 1466 lang::Locale aLocale = SvxCreateLocale( nLang ); 1467 String aLangText( MsLangId::convertLanguageToIsoString( nLang ) ); 1468 1469 // set word and locale to look up as status value 1470 String aStatusVal( aText ); 1471 aStatusVal.AppendAscii( "#" ); 1472 aStatusVal += aLangText; 1473 1474 rSet.Put( SfxStringItem( SID_THES, aStatusVal ) ); 1475 1476 // disable "Thesaurus" context menu entry if there is nothing to look up 1477 uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() ); 1478 if (aText.Len() == 0 || 1479 !xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( aLocale )) 1480 rSet.DisableItem( SID_THES ); 1481 } 1482 break; 1483 1484 case FN_NUMBER_NEWSTART : 1485 if(!rSh.GetNumRuleAtCurrCrsrPos()) 1486 rSet.DisableItem(nWhich); 1487 else 1488 rSet.Put(SfxBoolItem(FN_NUMBER_NEWSTART, 1489 rSh.IsNumRuleStart())); 1490 break; 1491 1492 case FN_EDIT_FORMULA: 1493 case SID_CHARMAP: 1494 { 1495 const int nType = rSh.GetSelectionType(); 1496 if (!(nType & nsSelectionType::SEL_TXT) && 1497 !(nType & nsSelectionType::SEL_TBL) && 1498 !(nType & nsSelectionType::SEL_NUM)) 1499 { 1500 rSet.DisableItem(nWhich); 1501 } 1502 else if ( nWhich == FN_EDIT_FORMULA 1503 && rSh.CrsrInsideInputFld() ) 1504 { 1505 rSet.DisableItem( nWhich ); 1506 } 1507 } 1508 break; 1509 1510 case FN_INSERT_ENDNOTE: 1511 case FN_INSERT_FOOTNOTE: 1512 case FN_INSERT_FOOTNOTE_DLG: 1513 { 1514 const sal_uInt16 nNoType = 1515 FRMTYPE_FLY_ANY | FRMTYPE_HEADER | FRMTYPE_FOOTER | FRMTYPE_FOOTNOTE; 1516 if ( (rSh.GetFrmType(0,sal_True) & nNoType) ) 1517 rSet.DisableItem(nWhich); 1518 1519 if ( rSh.CrsrInsideInputFld() ) 1520 { 1521 rSet.DisableItem( nWhich ); 1522 } 1523 } 1524 break; 1525 1526 case FN_INSERT_HYPERLINK: 1527 case SID_INSERTDOC: 1528 case FN_INSERT_GLOSSARY: 1529 case FN_EXPAND_GLOSSARY: 1530 if ( rSh.CrsrInsideInputFld() ) 1531 { 1532 rSet.DisableItem( nWhich ); 1533 } 1534 break; 1535 1536 case FN_INSERT_TABLE: 1537 if ( rSh.CrsrInsideInputFld() 1538 || rSh.GetTableFmt() 1539 || (rSh.GetFrmType(0,sal_True) & FRMTYPE_FOOTNOTE) ) 1540 { 1541 rSet.DisableItem( nWhich ); 1542 } 1543 break; 1544 1545 case FN_CALCULATE: 1546 if ( !rSh.IsSelection() ) 1547 rSet.DisableItem(nWhich); 1548 break; 1549 case FN_GOTO_REFERENCE: 1550 { 1551 SwField *pFld = rSh.GetCurFld(); 1552 if ( !pFld || (pFld && pFld->GetTypeId() != TYP_GETREFFLD) ) 1553 rSet.DisableItem(nWhich); 1554 } 1555 break; 1556 case FN_AUTOFORMAT_AUTO: 1557 { 1558 rSet.Put( SfxBoolItem( nWhich, SvxAutoCorrCfg::Get()->IsAutoFmtByInput() )); 1559 } 1560 break; 1561 1562 case FN_GLOSSARY_DLG: 1563 { 1564 if ( rSh.CrsrInsideInputFld() ) 1565 { 1566 rSet.DisableItem( nWhich ); 1567 } 1568 else 1569 { 1570 rSet.Put(SfxBoolItem(nWhich), sal_True); 1571 } 1572 } 1573 break; 1574 1575 case SID_DEC_INDENT: 1576 case SID_INC_INDENT: 1577 { 1578 //if the paragrah has bullet we'll do the following things: 1579 //1: if the bullet level is the first level, disable the decrease-indent button 1580 //2: if the bullet level is the last level, disable the increase-indent button 1581 if ( rSh.GetNumRuleAtCurrCrsrPos() && !rSh.HasReadonlySel() ) 1582 { 1583 const sal_uInt8 nLevel = rSh.GetNumLevel(); 1584 if ( ( nLevel == ( MAXLEVEL - 1 ) && nWhich == SID_INC_INDENT ) 1585 || ( nLevel == 0 && nWhich == SID_DEC_INDENT ) ) 1586 { 1587 rSet.DisableItem( nWhich ); 1588 } 1589 } 1590 else 1591 { 1592 sal_uInt16 nHtmlMode = ::GetHtmlMode( GetView().GetDocShell() ); 1593 nHtmlMode &= HTMLMODE_ON | HTMLMODE_SOME_STYLES; 1594 if ( ( nHtmlMode == HTMLMODE_ON ) 1595 || !rSh.IsMoveLeftMargin( SID_INC_INDENT == nWhich, sal_True ) ) 1596 { 1597 rSet.DisableItem( nWhich ); 1598 } 1599 } 1600 } 1601 break; 1602 1603 case FN_DEC_INDENT_OFFSET: 1604 case FN_INC_INDENT_OFFSET: 1605 { 1606 sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell()); 1607 nHtmlMode &= HTMLMODE_ON|HTMLMODE_SOME_STYLES; 1608 if( (nHtmlMode == HTMLMODE_ON) || 1609 !rSh.IsMoveLeftMargin( FN_INC_INDENT_OFFSET == nWhich, 1610 sal_False )) 1611 rSet.DisableItem( nWhich ); 1612 } 1613 break; 1614 1615 case SID_ATTR_CHAR_COLOR2: 1616 { 1617 rSet.Put(SvxColorItem(GetView().GetEditWin().GetTextColor(), SID_ATTR_CHAR_COLOR2)); 1618 } 1619 break; 1620 case SID_ATTR_CHAR_COLOR_BACKGROUND: 1621 { 1622 if(GetView().GetEditWin().IsTextBackColorTransparent()) 1623 rSet.Put(SvxColorItem(Color(COL_TRANSPARENT), SID_ATTR_CHAR_COLOR_BACKGROUND)); 1624 else 1625 rSet.Put(SvxColorItem(GetView().GetEditWin().GetTextBackColor(), SID_ATTR_CHAR_COLOR_BACKGROUND)); 1626 } 1627 break; 1628 case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT: 1629 case SID_ATTR_CHAR_COLOR_EXT: 1630 { 1631 SwEditWin& rEdtWin = GetView().GetEditWin(); 1632 SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate(); 1633 rSet.Put(SfxBoolItem(nWhich, pApply && pApply->nColor == nWhich)); 1634 } 1635 break; 1636 1637 case FN_INSERT_BOOKMARK: 1638 if( rSh.IsTableMode() 1639 || rSh.CrsrInsideInputFld() ) 1640 { 1641 rSet.DisableItem( nWhich ); 1642 } 1643 break; 1644 1645 1646 case FN_INSERT_BREAK: 1647 if ( rSh.HasReadonlySel() 1648 && !rSh.CrsrInsideInputFld() ) 1649 { 1650 rSet.DisableItem( nWhich ); 1651 } 1652 break; 1653 1654 1655 case FN_INSERT_BREAK_DLG: 1656 case FN_INSERT_COLUMN_BREAK: 1657 case FN_INSERT_PAGEBREAK: 1658 if( rSh.CrsrInsideInputFld() ) 1659 { 1660 rSet.DisableItem( nWhich ); 1661 } 1662 break; 1663 1664 case FN_INSERT_PAGEHEADER: 1665 case FN_INSERT_PAGEFOOTER: 1666 { 1667 #ifndef CHECK_MENU 1668 rSet.Put( SfxObjectShellItem( nWhich, GetView().GetDocShell() )); 1669 #else 1670 // Seitenvorlagen besorgen 1671 sal_Bool bFound = sal_False; 1672 sal_uInt16 n, nCnt = rSh.GetPageDescCnt(); 1673 for( n = 0; n < nCnt; ++n ) 1674 { 1675 const SwPageDesc& rDesc = rSh.GetPageDesc( n ); 1676 if( FN_INSERT_PAGEHEADER == nWhich 1677 ? !rDesc.GetMaster().GetHeader().IsActive() 1678 : !rDesc.GetMaster().GetFooter().IsActive() ) 1679 { 1680 bFound = sal_True; 1681 break; 1682 } 1683 } 1684 1685 if( bFound ) 1686 rSet.Put( SfxObjectShellItem( nWhich, GetView().GetDocShell() )); 1687 else 1688 rSet.DisableItem( nWhich ); 1689 #endif 1690 } 1691 break; 1692 case FN_TABLE_SORT_DIALOG: 1693 case FN_SORTING_DLG: 1694 if(!rSh.HasSelection() || 1695 (FN_TABLE_SORT_DIALOG == nWhich && !rSh.GetTableFmt())) 1696 rSet.DisableItem( nWhich ); 1697 break; 1698 1699 case SID_RUBY_DIALOG: 1700 { 1701 SvtCJKOptions aCJKOptions; 1702 if( !aCJKOptions.IsRubyEnabled() 1703 || rSh.CrsrInsideInputFld() ) 1704 { 1705 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False ); 1706 rSet.DisableItem(nWhich); 1707 } 1708 else 1709 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True ); 1710 } 1711 break; 1712 1713 case SID_HYPERLINK_DIALOG: 1714 if( GetView().GetDocShell()->IsReadOnly() 1715 || ( !GetView().GetViewFrame()->HasChildWindow(nWhich) 1716 && rSh.HasReadonlySel() ) 1717 || rSh.CrsrInsideInputFld() ) 1718 { 1719 rSet.DisableItem(nWhich); 1720 } 1721 else 1722 { 1723 rSet.Put(SfxBoolItem( nWhich, 0 != GetView().GetViewFrame()->GetChildWindow( nWhich ) )); 1724 } 1725 break; 1726 1727 case FN_EDIT_HYPERLINK: 1728 case FN_REMOVE_HYPERLINK: 1729 case FN_COPY_HYPERLINK_LOCATION: 1730 { 1731 SfxItemSet aSet(GetPool(), 1732 RES_TXTATR_INETFMT, 1733 RES_TXTATR_INETFMT); 1734 rSh.GetCurAttr(aSet); 1735 if(SFX_ITEM_SET > aSet.GetItemState( RES_TXTATR_INETFMT, sal_True ) || rSh.HasReadonlySel()) 1736 { 1737 rSet.DisableItem(nWhich); 1738 } 1739 } 1740 break; 1741 1742 case SID_TRANSLITERATE_HALFWIDTH: 1743 case SID_TRANSLITERATE_FULLWIDTH: 1744 case SID_TRANSLITERATE_HIRAGANA: 1745 case SID_TRANSLITERATE_KATAGANA: 1746 { 1747 SvtCJKOptions aCJKOptions; 1748 if(!aCJKOptions.IsChangeCaseMapEnabled()) 1749 { 1750 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False ); 1751 rSet.DisableItem(nWhich); 1752 } 1753 else 1754 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True ); 1755 } 1756 break; 1757 case FN_READONLY_SELECTION_MODE : 1758 if(!GetView().GetDocShell()->IsReadOnly()) 1759 rSet.DisableItem( nWhich ); 1760 else 1761 { 1762 rSet.Put(SfxBoolItem(nWhich, rSh.GetViewOptions()->IsSelectionInReadonly())); 1763 } 1764 break; 1765 case FN_SELECTION_MODE_DEFAULT: 1766 case FN_SELECTION_MODE_BLOCK : 1767 rSet.Put(SfxBoolItem(nWhich, (nWhich == FN_SELECTION_MODE_DEFAULT) != rSh.IsBlockMode())); 1768 break; 1769 case SID_OPEN_HYPERLINK: 1770 { 1771 SfxItemSet aSet(GetPool(), 1772 RES_TXTATR_INETFMT, 1773 RES_TXTATR_INETFMT); 1774 rSh.GetCurAttr(aSet); 1775 if(SFX_ITEM_SET > aSet.GetItemState( RES_TXTATR_INETFMT, sal_False )) 1776 rSet.DisableItem(nWhich); 1777 } 1778 break; 1779 case SID_OPEN_SMARTTAGMENU: 1780 { 1781 uno::Sequence< rtl::OUString > aSmartTagTypes; 1782 uno::Sequence< uno::Reference< container::XStringKeyMap > > aStringKeyMaps; 1783 uno::Reference<text::XTextRange> xRange; 1784 1785 rSh.GetSmartTagTerm( aSmartTagTypes, aStringKeyMaps, xRange ); 1786 1787 if ( xRange.is() && aSmartTagTypes.getLength() ) 1788 { 1789 uno::Sequence < uno::Sequence< uno::Reference< smarttags::XSmartTagAction > > > aActionComponentsSequence; 1790 uno::Sequence < uno::Sequence< sal_Int32 > > aActionIndicesSequence; 1791 1792 const SmartTagMgr& rSmartTagMgr = SwSmartTagMgr::Get(); 1793 rSmartTagMgr.GetActionSequences( aSmartTagTypes, 1794 aActionComponentsSequence, 1795 aActionIndicesSequence ); 1796 1797 uno::Reference <frame::XController> xController = GetView().GetController(); 1798 const lang::Locale aLocale( SW_BREAKITER()->GetLocale( (LanguageType)GetAppLanguage() ) ); 1799 const rtl::OUString aApplicationName( rSmartTagMgr.GetApplicationName() ); 1800 const rtl::OUString aRangeText = xRange->getString(); 1801 1802 const SvxSmartTagItem aItem( nWhich, 1803 aActionComponentsSequence, 1804 aActionIndicesSequence, 1805 aStringKeyMaps, 1806 xRange, 1807 xController, 1808 aLocale, 1809 aApplicationName, 1810 aRangeText ); 1811 1812 rSet.Put( aItem ); 1813 } 1814 else 1815 rSet.DisableItem(nWhich); 1816 } 1817 break; 1818 1819 case FN_NUM_NUMBERING_ON: 1820 rSet.Put(SfxBoolItem(FN_NUM_NUMBERING_ON,rSh.SelectionHasNumber())); 1821 break; 1822 1823 case FN_NUM_BULLET_ON: 1824 rSet.Put(SfxBoolItem(FN_NUM_BULLET_ON,rSh.SelectionHasBullet())); 1825 break; 1826 1827 case FN_BUL_NUM_RULE_INDEX: 1828 case FN_NUM_NUM_RULE_INDEX: 1829 { 1830 SwNumRule* pCurRule = (SwNumRule*)(GetShell().GetNumRuleAtCurrCrsrPos()); 1831 sal_uInt16 nActNumLvl = (sal_uInt16)0xFFFF; 1832 rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,DEFAULT_NONE)); 1833 rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,DEFAULT_NONE)); 1834 if( pCurRule ) 1835 { 1836 nActNumLvl = GetShell().GetNumLevel(); 1837 if( nActNumLvl < MAXLEVEL ) 1838 { 1839 nActNumLvl = 1<<nActNumLvl; 1840 } 1841 SvxNumRule aSvxRule = pCurRule->MakeSvxNumRule(); 1842 if ( GetShell().HasBullet()) 1843 { 1844 rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,(sal_uInt16)0xFFFF)); 1845 rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,(sal_uInt16)0xFFFF)); 1846 NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(eNBOType::MIXBULLETS); 1847 if ( pBullets ) 1848 { 1849 sal_uInt16 nBulIndex = pBullets->GetNBOIndexForNumRule(aSvxRule,nActNumLvl); 1850 rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,nBulIndex)); 1851 } 1852 }else if ( GetShell().HasNumber() ) 1853 { 1854 rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,(sal_uInt16)0xFFFF)); 1855 rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,(sal_uInt16)0xFFFF)); 1856 NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING); 1857 if ( pNumbering ) 1858 { 1859 sal_uInt16 nBulIndex = pNumbering->GetNBOIndexForNumRule(aSvxRule,nActNumLvl); 1860 rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,nBulIndex)); 1861 } 1862 } 1863 } 1864 } 1865 break; 1866 case FN_NUM_CONTINUE: 1867 { 1868 { 1869 // --> OD 2009-08-26 #i86492# 1870 // Search also for bullet list 1871 String aDummy; 1872 const SwNumRule* pRule = 1873 rSh.SearchNumRule( false, true, false, -1, aDummy ); 1874 if ( !pRule ) 1875 { 1876 pRule = rSh.SearchNumRule( false, false, false, -1, aDummy ); 1877 } 1878 // <-- 1879 if ( !pRule ) 1880 rSet.DisableItem(nWhich); 1881 } 1882 } 1883 break; 1884 case SID_INSERT_RLM : 1885 case SID_INSERT_LRM : 1886 case SID_INSERT_ZWNBSP : 1887 case SID_INSERT_ZWSP: 1888 { 1889 SvtCTLOptions aCTLOptions; 1890 sal_Bool bEnabled = aCTLOptions.IsCTLFontEnabled(); 1891 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, bEnabled ); 1892 if(!bEnabled) 1893 rSet.DisableItem(nWhich); 1894 } 1895 break; 1896 } 1897 nWhich = aIter.NextWhich(); 1898 } 1899 } 1900 /* -----------------------------2002/07/05 10:31------------------------------ 1901 Switch on/off header of footer of a page style - if an empty name is 1902 given all styles are changed 1903 ---------------------------------------------------------------------------*/ 1904 void SwTextShell::ChangeHeaderOrFooter( 1905 const String& rStyleName, sal_Bool bHeader, sal_Bool bOn, sal_Bool bShowWarning) 1906 { 1907 SwWrtShell& rSh = GetShell(); 1908 rSh.StartAllAction(); 1909 rSh.StartUndo( UNDO_HEADER_FOOTER ); // #i7983# 1910 sal_Bool bExecute = sal_True; 1911 sal_Bool bCrsrSet = sal_False; 1912 for( sal_uInt16 nFrom = 0, nTo = rSh.GetPageDescCnt(); 1913 nFrom < nTo; ++nFrom ) 1914 { 1915 int bChgd = sal_False; 1916 SwPageDesc aDesc( rSh.GetPageDesc( nFrom )); 1917 String sTmp(aDesc.GetName()); 1918 if( !rStyleName.Len() || rStyleName == sTmp ) 1919 { 1920 if( bShowWarning && !bOn && GetActiveView() && GetActiveView() == &GetView() && 1921 ((bHeader && aDesc.GetMaster().GetHeader().IsActive()) || 1922 (!bHeader && aDesc.GetMaster().GetFooter().IsActive()))) 1923 { 1924 bShowWarning = sal_False; 1925 //Actions have to be closed while the dialog is showing 1926 rSh.EndAllAction(); 1927 1928 Window* pParent = &GetView().GetViewFrame()->GetWindow(); 1929 sal_Bool bRet = RET_YES == QueryBox( pParent, ResId( RID_SVXQBX_DELETE_HEADFOOT, 1930 DIALOG_MGR() ) ).Execute(); 1931 bExecute = bRet; 1932 rSh.StartAllAction(); 1933 } 1934 if( bExecute ) 1935 { 1936 bChgd = sal_True; 1937 SwFrmFmt &rMaster = aDesc.GetMaster(); 1938 if(bHeader) 1939 rMaster.SetFmtAttr( SwFmtHeader( bOn )); 1940 else 1941 rMaster.SetFmtAttr( SwFmtFooter( bOn )); 1942 if( bOn ) 1943 { 1944 SvxULSpaceItem aUL(bHeader ? 0 : MM50, bHeader ? MM50 : 0, RES_UL_SPACE ); 1945 SwFrmFmt* pFmt = bHeader ? 1946 (SwFrmFmt*)rMaster.GetHeader().GetHeaderFmt() : 1947 (SwFrmFmt*)rMaster.GetFooter().GetFooterFmt(); 1948 pFmt->SetFmtAttr( aUL ); 1949 } 1950 } 1951 if( bChgd ) 1952 { 1953 rSh.ChgPageDesc( nFrom, aDesc ); 1954 1955 if( !bCrsrSet && bOn ) 1956 bCrsrSet = rSh.SetCrsrInHdFt( 1957 !rStyleName.Len() ? (sal_uInt16)0xFFFF : nFrom, 1958 bHeader ); 1959 } 1960 } 1961 } 1962 rSh.EndUndo( UNDO_HEADER_FOOTER ); // #i7983# 1963 rSh.EndAllAction(); 1964 } 1965 1966