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