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