1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sw.hxx" 26 27 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> 28 29 #include <comphelper/processfactory.hxx> 30 #include <i18npool/mslangid.hxx> 31 #include <sfx2/bindings.hxx> 32 #include <sfx2/dispatch.hxx> 33 #include <sfx2/request.hxx> 34 #include <tools/shl.hxx> 35 #include <svx/svdview.hxx> 36 #include <editeng/spltitem.hxx> 37 #include <editeng/orphitem.hxx> 38 #include <editeng/brkitem.hxx> 39 #include <editeng/widwitem.hxx> 40 #include <editeng/kernitem.hxx> 41 #include <editeng/escpitem.hxx> 42 #include <editeng/lspcitem.hxx> 43 #include <editeng/adjitem.hxx> 44 #include <editeng/crsditem.hxx> 45 #include <editeng/shdditem.hxx> 46 #include <editeng/hyznitem.hxx> 47 #include <editeng/udlnitem.hxx> 48 #include <editeng/fontitem.hxx> 49 #include <editeng/fhgtitem.hxx> 50 #include <editeng/colritem.hxx> 51 #include <editeng/wghtitem.hxx> 52 #include <editeng/cntritem.hxx> 53 #include <editeng/postitem.hxx> 54 #include <editeng/frmdiritem.hxx> 55 #include <svx/svdoutl.hxx> 56 #include <sfx2/viewfrm.hxx> 57 #include <svl/whiter.hxx> 58 #include <svl/cjkoptions.hxx> 59 #include <svl/ctloptions.hxx> 60 #include <svtools/langtab.hxx> 61 #include <svl/languageoptions.hxx> 62 #include <sfx2/bindings.hxx> 63 #include <vcl/msgbox.hxx> 64 #include <sfx2/dispatch.hxx> 65 #include <sfx2/request.hxx> 66 #include <editeng/flditem.hxx> 67 #include <editeng/editstat.hxx> 68 #include <svx/hlnkitem.hxx> 69 #include <svx/htmlmode.hxx> 70 #include <svl/languageoptions.hxx> 71 #include <svl/slstitm.hxx> 72 #include <editeng/langitem.hxx> 73 #include <svtools/langtab.hxx> 74 #include <editeng/unolingu.hxx> 75 #include <editeng/scripttypeitem.hxx> 76 #include <editeng/writingmodeitem.hxx> 77 #include <editeng/eeitem.hxx> 78 #include <editeng/editeng.hxx> 79 #include <editeng/editdata.hxx> 80 #include <editeng/outliner.hxx> 81 #include <vcl/window.hxx> 82 #include <editeng/editview.hxx> 83 #include <vcl/outdev.hxx> 84 #include <editeng/hyznitem.hxx> 85 #include <editeng/kernitem.hxx> 86 #include <editeng/langitem.hxx> 87 #include <editeng/lspcitem.hxx> 88 #include <editeng/orphitem.hxx> 89 #include <editeng/outliner.hxx> 90 #include <editeng/postitem.hxx> 91 #include <editeng/scripttypeitem.hxx> 92 #include <editeng/shdditem.hxx> 93 #include <editeng/spltitem.hxx> 94 #include <svx/svdoutl.hxx> 95 #include <svx/svdview.hxx> 96 #include <editeng/udlnitem.hxx> 97 #include <editeng/unolingu.hxx> 98 #include <editeng/wghtitem.hxx> 99 #include <editeng/widwitem.hxx> 100 #include <editeng/writingmodeitem.hxx> 101 #include <tools/shl.hxx> 102 #include <vcl/msgbox.hxx> 103 #include <vcl/outdev.hxx> 104 #include <vcl/window.hxx> 105 106 #include <cmdid.h> 107 #include <doc.hxx> 108 #include <docstat.hxx> 109 #include <drwtxtsh.hxx> 110 #include <edtwin.hxx> 111 #include <globals.hrc> 112 #include <hintids.hxx> 113 #include <initui.hxx> // fuer SpellPointer 114 #include <langhelper.hxx> 115 #include <pardlg.hxx> 116 #include <shells.hrc> 117 #include <string.h> 118 #include <swdtflvr.hxx> 119 #include <swmodule.hxx> 120 #include <swwait.hxx> 121 #include <uitool.hxx> 122 #include <viewopt.hxx> 123 #include <wrtsh.hxx> 124 #include <wview.hxx> 125 126 #include "swabstdlg.hxx" 127 #include "chrdlg.hrc" 128 #include "misc.hrc" 129 130 131 #include <langhelper.hxx> 132 133 using namespace ::com::sun::star; 134 135 /*-------------------------------------------------------------------- 136 Beschreibung: 137 --------------------------------------------------------------------*/ 138 139 void SwDrawTextShell::Execute( SfxRequest &rReq ) 140 { 141 SwWrtShell &rSh = GetShell(); 142 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); 143 SfxItemSet aEditAttr(pOLV->GetAttribs()); 144 SfxItemSet aNewAttr(*aEditAttr.GetPool(), aEditAttr.GetRanges()); 145 146 sal_uInt16 nSlot = rReq.GetSlot(); 147 148 sal_uInt16 nWhich = GetPool().GetWhich(nSlot); 149 const SfxItemSet *pNewAttrs = rReq.GetArgs(); 150 151 bool bRestoreSelection = false; 152 ESelection aOldSelection; 153 154 sal_uInt16 nEEWhich = 0; 155 switch (nSlot) 156 { 157 case SID_LANGUAGE_STATUS: 158 { 159 aOldSelection = pOLV->GetSelection(); 160 if (!pOLV->GetEditView().HasSelection()) 161 { 162 bRestoreSelection = true; 163 pOLV->GetEditView().SelectCurrentWord(); 164 } 165 166 bRestoreSelection = SwLangHelper::SetLanguageStatus(pOLV,rReq,GetView(),rSh); 167 break; 168 } 169 170 case SID_THES: 171 { 172 String aReplaceText; 173 SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES, sal_False ); 174 if (pItem2) 175 aReplaceText = pItem2->GetValue(); 176 if (aReplaceText.Len() > 0) 177 ReplaceTextWithSynonym( pOLV->GetEditView(), aReplaceText ); 178 break; 179 } 180 181 case SID_ATTR_CHAR_FONT: 182 case SID_ATTR_CHAR_FONTHEIGHT: 183 case SID_ATTR_CHAR_WEIGHT: 184 case SID_ATTR_CHAR_POSTURE: 185 { 186 SfxItemPool* pPool2 = aEditAttr.GetPool()->GetSecondaryPool(); 187 if( !pPool2 ) 188 pPool2 = aEditAttr.GetPool(); 189 SvxScriptSetItem aSetItem( nSlot, *pPool2 ); 190 191 // #i78017 establish the same behaviour as in Writer 192 sal_uInt16 nScriptTypes = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX; 193 if (nSlot == SID_ATTR_CHAR_FONT) 194 nScriptTypes = pOLV->GetSelectedScriptType(); 195 196 aSetItem.PutItemForScriptType( nScriptTypes, pNewAttrs->Get( nWhich ) ); 197 aNewAttr.Put( aSetItem.GetItemSet() ); 198 } 199 break; 200 201 case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break; 202 203 case SID_ATTR_CHAR_UNDERLINE: 204 { 205 FontUnderline eFU = ((const SvxUnderlineItem&)aEditAttr.Get(EE_CHAR_UNDERLINE)).GetLineStyle(); 206 aNewAttr.Put(SvxUnderlineItem(eFU == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_UNDERLINE)); 207 } 208 break; 209 210 case SID_ATTR_CHAR_OVERLINE: 211 { 212 FontUnderline eFO = ((const SvxOverlineItem&)aEditAttr.Get(EE_CHAR_OVERLINE)).GetLineStyle(); 213 aNewAttr.Put(SvxOverlineItem(eFO == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_OVERLINE)); 214 } 215 break; 216 217 case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break; 218 case SID_ATTR_CHAR_SHADOWED: nEEWhich = EE_CHAR_SHADOW; break; 219 case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT; break; 220 case SID_ATTR_CHAR_WORDLINEMODE: nEEWhich = EE_CHAR_WLM; break; 221 case SID_ATTR_CHAR_RELIEF : nEEWhich = EE_CHAR_RELIEF; break; 222 case SID_ATTR_CHAR_LANGUAGE : nEEWhich = EE_CHAR_LANGUAGE;break; 223 case SID_ATTR_CHAR_KERNING : nEEWhich = EE_CHAR_KERNING; break; 224 case SID_ATTR_CHAR_SCALEWIDTH: nEEWhich = EE_CHAR_FONTWIDTH; break; 225 case SID_ATTR_CHAR_AUTOKERN : nEEWhich = EE_CHAR_PAIRKERNING; break; 226 case SID_ATTR_CHAR_ESCAPEMENT: nEEWhich = EE_CHAR_ESCAPEMENT; break; 227 case SID_ATTR_PARA_ADJUST_LEFT: 228 aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_LEFT, EE_PARA_JUST)); 229 break; 230 case SID_ATTR_PARA_ADJUST_CENTER: 231 aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST)); 232 break; 233 case SID_ATTR_PARA_ADJUST_RIGHT: 234 aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_RIGHT, EE_PARA_JUST)); 235 break; 236 case SID_ATTR_PARA_ADJUST_BLOCK: 237 aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_BLOCK, EE_PARA_JUST)); 238 break; 239 240 case SID_ATTR_PARA_LINESPACE_10: 241 { 242 SvxLineSpacingItem aItem(SVX_LINESPACE_ONE_LINE, EE_PARA_SBL); 243 aItem.SetPropLineSpace(100); 244 aNewAttr.Put(aItem); 245 } 246 break; 247 case SID_ATTR_PARA_LINESPACE_15: 248 { 249 SvxLineSpacingItem aItem(SVX_LINESPACE_ONE_POINT_FIVE_LINES, EE_PARA_SBL); 250 aItem.SetPropLineSpace(150); 251 aNewAttr.Put(aItem); 252 } 253 break; 254 case SID_ATTR_PARA_LINESPACE_20: 255 { 256 SvxLineSpacingItem aItem(SVX_LINESPACE_TWO_LINES, EE_PARA_SBL); 257 aItem.SetPropLineSpace(200); 258 aNewAttr.Put(aItem); 259 } 260 break; 261 262 case FN_SET_SUPER_SCRIPT: 263 { 264 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); 265 SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&) 266 aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue(); 267 268 if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT ) 269 aItem.SetEscapement( SVX_ESCAPEMENT_OFF ); 270 else 271 aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT ); 272 aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT ); 273 } 274 break; 275 case FN_SET_SUB_SCRIPT: 276 { 277 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); 278 SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&) 279 aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue(); 280 281 if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT ) 282 aItem.SetEscapement( SVX_ESCAPEMENT_OFF ); 283 else 284 aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT ); 285 aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT ); 286 } 287 break; 288 289 case SID_CHAR_DLG_EFFECT: 290 case SID_CHAR_DLG: 291 case SID_CHAR_DLG_FOR_PARAGRAPH: 292 { 293 const SfxItemSet* pArgs = rReq.GetArgs(); 294 295 if( !pArgs ) 296 { 297 aOldSelection = pOLV->GetSelection(); 298 if (nSlot == SID_CHAR_DLG_FOR_PARAGRAPH) 299 { 300 // select current paragraph (and restore selection later on...) 301 EditView & rEditView = pOLV->GetEditView(); 302 SwLangHelper::SelectPara( rEditView, rEditView.GetSelection() ); 303 bRestoreSelection = true; 304 } 305 306 SwView* pView = &GetView(); 307 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView)); 308 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) ); 309 SfxItemSet aDlgAttr(GetPool(), EE_ITEMS_START, EE_ITEMS_END); 310 311 // util::Language gibts an der EditEngine nicht! Daher nicht im Set. 312 313 aDlgAttr.Put( aEditAttr ); 314 aDlgAttr.Put( SvxKerningItem(0, RES_CHRATR_KERNING) ); 315 316 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 317 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 318 319 SfxAbstractTabDialog* pDlg = pFact->CreateSwCharDlg( pView->GetWindow(), *pView, aDlgAttr, DLG_CHAR,0, sal_True ); 320 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 321 if (nSlot == SID_CHAR_DLG_EFFECT) 322 { 323 pDlg->SetCurPageId(TP_CHAR_EXT); 324 } 325 sal_uInt16 nRet = pDlg->Execute(); 326 if(RET_OK == nRet ) 327 { 328 rReq.Done( *( pDlg->GetOutputItemSet() ) ); 329 aNewAttr.Put(*pDlg->GetOutputItemSet()); 330 } 331 delete( pDlg ); 332 if(RET_OK != nRet) 333 return ; 334 } 335 else 336 aNewAttr.Put(*pArgs); 337 } 338 break; 339 case FN_FORMAT_FOOTNOTE_DLG: 340 { 341 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 342 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 343 344 VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( GetView().GetWindow(), rView.GetWrtShell(), DLG_DOC_FOOTNOTE ); 345 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 346 pDlg->Execute(); 347 delete pDlg; 348 break; 349 } 350 case FN_NUMBERING_OUTLINE_DLG: 351 { 352 SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1); 353 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 354 DBG_ASSERT(pFact, "Dialogdiet fail!"); 355 SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE, 356 GetView().GetWindow(), &aTmp, GetView().GetWrtShell()); 357 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 358 pDlg->Execute(); 359 delete pDlg; 360 rReq.Done(); 361 } 362 break; 363 case SID_OPEN_XML_FILTERSETTINGS: 364 { 365 try 366 { 367 uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY); 368 if( xDialog.is() ) 369 { 370 xDialog->execute(); 371 } 372 } 373 catch( uno::Exception& ) 374 { 375 } 376 rReq.Ignore (); 377 } 378 break; 379 case FN_WORDCOUNT_DIALOG: 380 { 381 SwDocStat aCurr; 382 SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() ); 383 { 384 SwWait aWait( *GetView().GetDocShell(), sal_True ); 385 rSh.StartAction(); 386 rSh.CountWords( aCurr ); 387 rSh.UpdateDocStat( aDocStat ); 388 rSh.EndAction(); 389 } 390 391 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 392 DBG_ASSERT(pFact, "Dialogdiet fail!"); 393 AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() ); 394 pDialog->SetValues(aCurr, aDocStat ); 395 pDialog->Execute(); 396 delete pDialog; 397 } 398 break; 399 case SID_PARA_DLG: 400 { 401 const SfxItemSet* pArgs = rReq.GetArgs(); 402 403 if (!pArgs) 404 { 405 SwView* pView = &GetView(); 406 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView)); 407 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) ); 408 SfxItemSet aDlgAttr(GetPool(), 409 EE_ITEMS_START, EE_ITEMS_END, 410 SID_ATTR_PARA_HYPHENZONE, SID_ATTR_PARA_HYPHENZONE, 411 SID_ATTR_PARA_SPLIT, SID_ATTR_PARA_SPLIT, 412 SID_ATTR_PARA_WIDOWS, SID_ATTR_PARA_WIDOWS, 413 SID_ATTR_PARA_ORPHANS, SID_ATTR_PARA_ORPHANS, 414 0); 415 416 aDlgAttr.Put(aEditAttr); 417 418 // Die Werte sind erst einmal uebernommen worden, um den Dialog anzuzeigen. 419 // Muss natuerlich noch geaendert werden 420 // aDlgAttr.Put( SvxParaDlgLimitsItem( 567 * 50, 5670) ); 421 422 aDlgAttr.Put( SvxHyphenZoneItem( sal_False, RES_PARATR_HYPHENZONE) ); 423 aDlgAttr.Put( SvxFmtBreakItem( SVX_BREAK_NONE, RES_BREAK ) ); 424 aDlgAttr.Put( SvxFmtSplitItem( sal_True, RES_PARATR_SPLIT ) ); 425 aDlgAttr.Put( SvxWidowsItem( 0, RES_PARATR_WIDOWS ) ); 426 aDlgAttr.Put( SvxOrphansItem( 0, RES_PARATR_ORPHANS ) ); 427 428 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 429 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 430 431 SfxAbstractTabDialog* pDlg = pFact->CreateSwParaDlg( GetView().GetWindow(), GetView(), aDlgAttr,DLG_STD, DLG_PARA, 0, sal_True ); 432 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 433 sal_uInt16 nRet = pDlg->Execute(); 434 if(RET_OK == nRet) 435 { 436 rReq.Done( *( pDlg->GetOutputItemSet() ) ); 437 aNewAttr.Put(*pDlg->GetOutputItemSet()); 438 } 439 delete( pDlg ); 440 if(RET_OK != nRet) 441 return; 442 } 443 else 444 aNewAttr.Put(*pArgs); 445 } 446 break; 447 case SID_AUTOSPELL_CHECK: 448 { 449 //!! JP 16.03.2001: why?? pSdrView = rSh.GetDrawView(); 450 //!! JP 16.03.2001: why?? pOutliner = pSdrView->GetTextEditOutliner(); 451 SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner(); 452 sal_uInt32 nCtrl = pOutliner->GetControlWord(); 453 454 sal_Bool bSet = ((const SfxBoolItem&)rReq.GetArgs()->Get( 455 nSlot)).GetValue(); 456 if(bSet) 457 nCtrl |= EE_CNTRL_ONLINESPELLING|EE_CNTRL_ALLOWBIGOBJS; 458 else 459 nCtrl &= ~EE_CNTRL_ONLINESPELLING; 460 pOutliner->SetControlWord(nCtrl); 461 462 rView.ExecuteSlot(rReq); 463 } 464 break; 465 case SID_HYPERLINK_SETLINK: 466 { 467 const SfxPoolItem* pItem = 0; 468 if(pNewAttrs) 469 pNewAttrs->GetItemState(nSlot, sal_False, &pItem); 470 471 if(pItem) 472 { 473 const SvxHyperlinkItem& rHLinkItem = *(const SvxHyperlinkItem *)pItem; 474 SvxURLField aFld(rHLinkItem.GetURL(), rHLinkItem.GetName(), SVXURLFORMAT_APPDEFAULT); 475 aFld.SetTargetFrame(rHLinkItem.GetTargetFrame()); 476 477 const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection(); 478 479 if (pFieldItem && pFieldItem->GetField()->ISA(SvxURLField)) 480 { 481 // Feld selektieren, so dass es beim Insert geloescht wird 482 ESelection aSel = pOLV->GetSelection(); 483 aSel.nEndPos++; 484 pOLV->SetSelection(aSel); 485 } 486 pOLV->InsertField(SvxFieldItem(aFld, EE_FEATURE_FIELD)); 487 } 488 } 489 break; 490 491 case SID_TEXTDIRECTION_LEFT_TO_RIGHT: 492 case SID_TEXTDIRECTION_TOP_TO_BOTTOM: 493 // Shellwechsel! 494 { 495 SdrObject* pTmpObj = pSdrView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(); 496 SdrPageView* pTmpPV = pSdrView->GetSdrPageView(); 497 SdrView* pTmpView = pSdrView; 498 499 pSdrView->SdrEndTextEdit(sal_True); 500 501 SfxItemSet aAttr( *aNewAttr.GetPool(), 502 SDRATTR_TEXTDIRECTION, 503 SDRATTR_TEXTDIRECTION ); 504 505 aAttr.Put( SvxWritingModeItem( 506 nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ? 507 text::WritingMode_LR_TB 508 : text::WritingMode_TB_RL, SDRATTR_TEXTDIRECTION ) ); 509 pTmpView->SetAttributes( aAttr ); 510 511 rSh.GetView().BeginTextEdit( pTmpObj, pTmpPV, &rSh.GetView().GetEditWin(), sal_False); 512 rSh.GetView().AttrChangedNotify( &rSh ); 513 } 514 return; 515 516 case SID_ATTR_PARA_LEFT_TO_RIGHT: 517 case SID_ATTR_PARA_RIGHT_TO_LEFT: 518 { 519 SdrObject* pTmpObj = pSdrView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(); 520 SdrPageView* pTmpPV = pSdrView->GetSdrPageView(); 521 SdrView* pTmpView = pSdrView; 522 523 pSdrView->SdrEndTextEdit(sal_True); 524 sal_Bool bLeftToRight = nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT; 525 526 const SfxPoolItem* pPoolItem; 527 if( pNewAttrs && SFX_ITEM_SET == pNewAttrs->GetItemState( nSlot, sal_True, &pPoolItem ) ) 528 { 529 if( !( (SfxBoolItem*)pPoolItem)->GetValue() ) 530 bLeftToRight = !bLeftToRight; 531 } 532 SfxItemSet aAttr( *aNewAttr.GetPool(), 533 EE_PARA_JUST, EE_PARA_JUST, 534 EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR, 535 0 ); 536 537 sal_uInt16 nAdjust = SVX_ADJUST_LEFT; 538 if( SFX_ITEM_ON == aEditAttr.GetItemState(EE_PARA_JUST, sal_True, &pPoolItem ) ) 539 nAdjust = ( (SvxAdjustItem*)pPoolItem)->GetEnumValue(); 540 541 if( bLeftToRight ) 542 { 543 aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ) ); 544 if( nAdjust == SVX_ADJUST_RIGHT ) 545 aAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) ); 546 } 547 else 548 { 549 aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP, EE_PARA_WRITINGDIR ) ); 550 if( nAdjust == SVX_ADJUST_LEFT ) 551 aAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) ); 552 } 553 pTmpView->SetAttributes( aAttr ); 554 rSh.GetView().BeginTextEdit( pTmpObj, pTmpPV, &rSh.GetView().GetEditWin(), sal_False ); 555 rSh.GetView().AttrChangedNotify( &rSh ); 556 } 557 return; 558 default: 559 ASSERT(!this, falscher Dispatcher); 560 return; 561 } 562 if(nEEWhich && pNewAttrs) 563 aNewAttr.Put(pNewAttrs->Get(nWhich), nEEWhich); 564 565 SetAttrToMarked(aNewAttr); 566 567 GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False); 568 569 if (IsTextEdit() && pOLV->GetOutliner()->IsModified()) 570 rSh.SetModified(); 571 572 if (bRestoreSelection) 573 { 574 // restore selection 575 pOLV->GetEditView().SetSelection( aOldSelection ); 576 } 577 } 578 579 /*-------------------------------------------------------------------- 580 Beschreibung: 581 --------------------------------------------------------------------*/ 582 583 void SwDrawTextShell::GetState(SfxItemSet& rSet) 584 { 585 if (!IsTextEdit()) // Sonst manchmal Absturz! 586 return; 587 588 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); 589 SfxWhichIter aIter(rSet); 590 sal_uInt16 nWhich = aIter.FirstWhich(); 591 592 SfxItemSet aEditAttr( pOLV->GetAttribs() ); 593 const SfxPoolItem *pAdjust = 0, *pLSpace = 0, *pEscItem = 0; 594 int eAdjust, nLSpace, nEsc; 595 596 while(nWhich) 597 { 598 sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich ); 599 sal_Bool bFlag = sal_False; 600 switch( nSlotId ) 601 { 602 case SID_LANGUAGE_STATUS://20412: 603 { 604 nSlotId = SwLangHelper::GetLanguageStatus(pOLV,rSet);; 605 break; 606 } 607 608 case SID_THES: 609 { 610 String aStatusVal; 611 LanguageType nLang = LANGUAGE_NONE; 612 bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, pOLV->GetEditView() ); 613 rSet.Put( SfxStringItem( SID_THES, aStatusVal ) ); 614 615 // disable "Thesaurus" context menu entry if there is nothing to look up 616 uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() ); 617 lang::Locale aLocale( SvxCreateLocale( nLang ) ); 618 if (!bIsLookUpWord || 619 !xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( aLocale )) 620 rSet.DisableItem( SID_THES ); 621 622 //! avoid puting the same item as SfxBoolItem at the end of this function 623 nSlotId = 0; 624 break; 625 } 626 627 case SID_ATTR_PARA_ADJUST_LEFT: eAdjust = SVX_ADJUST_LEFT; goto ASK_ADJUST; 628 case SID_ATTR_PARA_ADJUST_RIGHT: eAdjust = SVX_ADJUST_RIGHT; goto ASK_ADJUST; 629 case SID_ATTR_PARA_ADJUST_CENTER: eAdjust = SVX_ADJUST_CENTER; goto ASK_ADJUST; 630 case SID_ATTR_PARA_ADJUST_BLOCK: eAdjust = SVX_ADJUST_BLOCK; goto ASK_ADJUST; 631 ASK_ADJUST: 632 { 633 if( !pAdjust ) 634 aEditAttr.GetItemState( EE_PARA_JUST, sal_False, &pAdjust); 635 636 if( !pAdjust || IsInvalidItem( pAdjust )) 637 rSet.InvalidateItem( nSlotId ), nSlotId = 0; 638 else 639 bFlag = eAdjust == ((SvxAdjustItem*)pAdjust)->GetAdjust(); 640 } 641 break; 642 643 case SID_ATTR_PARA_LINESPACE_10: nLSpace = 100; goto ASK_LINESPACE; 644 case SID_ATTR_PARA_LINESPACE_15: nLSpace = 150; goto ASK_LINESPACE; 645 case SID_ATTR_PARA_LINESPACE_20: nLSpace = 200; goto ASK_LINESPACE; 646 ASK_LINESPACE: 647 { 648 if( !pLSpace ) 649 aEditAttr.GetItemState( EE_PARA_SBL, sal_False, &pLSpace ); 650 651 if( !pLSpace || IsInvalidItem( pLSpace )) 652 rSet.InvalidateItem( nSlotId ), nSlotId = 0; 653 else if( nLSpace == ((const SvxLineSpacingItem*)pLSpace)-> 654 GetPropLineSpace() ) 655 bFlag = sal_True; 656 else 657 nSlotId = 0; 658 } 659 break; 660 661 case FN_SET_SUPER_SCRIPT: nEsc = SVX_ESCAPEMENT_SUPERSCRIPT; 662 goto ASK_ESCAPE; 663 case FN_SET_SUB_SCRIPT: nEsc = SVX_ESCAPEMENT_SUBSCRIPT; 664 goto ASK_ESCAPE; 665 ASK_ESCAPE: 666 { 667 if( !pEscItem ) 668 pEscItem = &aEditAttr.Get( EE_CHAR_ESCAPEMENT ); 669 670 if( nEsc == ((const SvxEscapementItem*) 671 pEscItem)->GetEnumValue() ) 672 bFlag = sal_True; 673 else 674 nSlotId = 0; 675 } 676 break; 677 678 case SID_THESAURUS: 679 { 680 // disable "Thesaurus" if the language is not supported 681 const SfxPoolItem &rItem = GetShell().GetDoc()->GetDefault( 682 GetWhichOfScript( RES_CHRATR_LANGUAGE, 683 GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage())) ); 684 LanguageType nLang = ((const SvxLanguageItem &) rItem).GetLanguage(); 685 686 uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() ); 687 if (!xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( SvxCreateLocale( nLang ) )) 688 rSet.DisableItem( SID_THESAURUS ); 689 nSlotId = 0; 690 } 691 break; 692 case SID_HANGUL_HANJA_CONVERSION: 693 case SID_CHINESE_CONVERSION: 694 { 695 if (!SvtCJKOptions().IsAnyEnabled()) 696 { 697 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False ); 698 rSet.DisableItem(nWhich); 699 } 700 else 701 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True ); 702 } 703 break; 704 705 case SID_TEXTDIRECTION_LEFT_TO_RIGHT: 706 case SID_TEXTDIRECTION_TOP_TO_BOTTOM: 707 if ( !SvtLanguageOptions().IsVerticalTextEnabled() ) 708 { 709 rSet.DisableItem( nSlotId ); 710 nSlotId = 0; 711 } 712 else 713 { 714 SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner(); 715 if( pOutliner ) 716 bFlag = pOutliner->IsVertical() == 717 (SID_TEXTDIRECTION_TOP_TO_BOTTOM == nSlotId); 718 else 719 { 720 text::WritingMode eMode = (text::WritingMode) 721 ( (const SvxWritingModeItem&) aEditAttr.Get( SDRATTR_TEXTDIRECTION ) ).GetValue(); 722 723 if( nSlotId == SID_TEXTDIRECTION_LEFT_TO_RIGHT ) 724 { 725 bFlag = eMode == text::WritingMode_LR_TB; 726 } 727 else 728 { 729 bFlag = eMode != text::WritingMode_TB_RL; 730 } 731 } 732 } 733 break; 734 case SID_ATTR_PARA_LEFT_TO_RIGHT: 735 case SID_ATTR_PARA_RIGHT_TO_LEFT: 736 { 737 if ( !SvtLanguageOptions().IsCTLFontEnabled() ) 738 { 739 rSet.DisableItem( nWhich ); 740 nSlotId = 0; 741 } 742 else 743 { 744 SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner(); 745 if(pOutliner && pOutliner->IsVertical()) 746 { 747 rSet.DisableItem( nWhich ); 748 nSlotId = 0; 749 } 750 else 751 { 752 switch( ( ( (SvxFrameDirectionItem&) aEditAttr.Get( EE_PARA_WRITINGDIR ) ) ).GetValue() ) 753 { 754 case FRMDIR_HORI_LEFT_TOP: 755 bFlag = nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT; 756 break; 757 758 case FRMDIR_HORI_RIGHT_TOP: 759 bFlag = nWhich != SID_ATTR_PARA_LEFT_TO_RIGHT; 760 break; 761 } 762 } 763 } 764 } 765 break; 766 case SID_TRANSLITERATE_HALFWIDTH: 767 case SID_TRANSLITERATE_FULLWIDTH: 768 case SID_TRANSLITERATE_HIRAGANA: 769 case SID_TRANSLITERATE_KATAGANA: 770 { 771 SvtCJKOptions aCJKOptions; 772 if(!aCJKOptions.IsChangeCaseMapEnabled()) 773 { 774 rSet.DisableItem(nWhich); 775 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False ); 776 } 777 else 778 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True ); 779 } 780 break; 781 case SID_INSERT_RLM : 782 case SID_INSERT_LRM : 783 case SID_INSERT_ZWNBSP : 784 case SID_INSERT_ZWSP: 785 { 786 SvtCTLOptions aCTLOptions; 787 sal_Bool bEnabled = aCTLOptions.IsCTLFontEnabled(); 788 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, bEnabled ); 789 if(!bEnabled) 790 rSet.DisableItem(nWhich); 791 } 792 break; 793 default: 794 nSlotId = 0; // don't know this slot 795 break; 796 } 797 798 if( nSlotId ) 799 rSet.Put( SfxBoolItem( nWhich, bFlag )); 800 801 nWhich = aIter.NextWhich(); 802 } 803 } 804 805 /*-------------------------------------------------------------------- 806 Beschreibung: 807 --------------------------------------------------------------------*/ 808 void SwDrawTextShell::GetDrawTxtCtrlState(SfxItemSet& rSet) 809 { 810 if (!IsTextEdit()) // Sonst Absturz! 811 return; 812 813 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); 814 SfxItemSet aEditAttr(pOLV->GetAttribs()); 815 816 SfxWhichIter aIter(rSet); 817 sal_uInt16 nWhich = aIter.FirstWhich(); 818 sal_uInt16 nScriptType = pOLV->GetSelectedScriptType(); 819 while(nWhich) 820 { 821 sal_uInt16 nEEWhich = 0; 822 sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich ); 823 switch( nSlotId ) 824 { 825 case SID_ATTR_CHAR_FONT: 826 case SID_ATTR_CHAR_FONTHEIGHT: 827 case SID_ATTR_CHAR_WEIGHT: 828 case SID_ATTR_CHAR_POSTURE: 829 { 830 SfxItemPool* pEditPool = aEditAttr.GetPool()->GetSecondaryPool(); 831 if( !pEditPool ) 832 pEditPool = aEditAttr.GetPool(); 833 SvxScriptSetItem aSetItem( nSlotId, *pEditPool ); 834 aSetItem.GetItemSet().Put( aEditAttr, sal_False ); 835 const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType ); 836 if( pI ) 837 rSet.Put( *pI, nWhich ); 838 else 839 rSet.InvalidateItem( nWhich ); 840 } 841 break; 842 case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break; 843 case SID_ATTR_CHAR_UNDERLINE: nEEWhich = EE_CHAR_UNDERLINE;break; 844 case SID_ATTR_CHAR_OVERLINE: nEEWhich = EE_CHAR_OVERLINE;break; 845 case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break; 846 case SID_ATTR_CHAR_SHADOWED: nEEWhich = EE_CHAR_SHADOW;break; 847 case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT;break; 848 case SID_AUTOSPELL_CHECK: 849 { 850 const SfxPoolItem* pState = rView.GetSlotState(nWhich); 851 if (pState) 852 rSet.Put(SfxBoolItem(nWhich, ((const SfxBoolItem*)pState)->GetValue())); 853 else 854 rSet.DisableItem( nWhich ); 855 break; 856 } 857 case SID_ATTR_CHAR_WORDLINEMODE: nEEWhich = EE_CHAR_WLM; break; 858 case SID_ATTR_CHAR_RELIEF : nEEWhich = EE_CHAR_RELIEF; break; 859 case SID_ATTR_CHAR_LANGUAGE : nEEWhich = EE_CHAR_LANGUAGE;break; 860 case SID_ATTR_CHAR_KERNING : nEEWhich = EE_CHAR_KERNING; break; 861 case SID_ATTR_CHAR_SCALEWIDTH: nEEWhich = EE_CHAR_FONTWIDTH;break; 862 case SID_ATTR_CHAR_AUTOKERN : nEEWhich = EE_CHAR_PAIRKERNING; break; 863 case SID_ATTR_CHAR_ESCAPEMENT: nEEWhich = EE_CHAR_ESCAPEMENT; break; 864 } 865 if(nEEWhich) 866 rSet.Put(aEditAttr.Get(nEEWhich, sal_True), nWhich); 867 868 nWhich = aIter.NextWhich(); 869 } 870 } 871 872 /*-------------------------------------------------------------------- 873 Beschreibung: 874 --------------------------------------------------------------------*/ 875 void SwDrawTextShell::ExecClpbrd(SfxRequest &rReq) 876 { 877 if (!IsTextEdit()) // Sonst Absturz! 878 return; 879 880 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); 881 882 ESelection aSel(pOLV->GetSelection()); 883 const sal_Bool bCopy = (aSel.nStartPara != aSel.nEndPara) || (aSel.nStartPos != aSel.nEndPos); 884 sal_uInt16 nId = rReq.GetSlot(); 885 switch( nId ) 886 { 887 case SID_CUT: 888 if (bCopy) 889 pOLV->Cut(); 890 return; 891 892 case SID_COPY: 893 if (bCopy) 894 pOLV->Copy(); 895 return; 896 897 case SID_PASTE: 898 pOLV->PasteSpecial(); 899 break; 900 901 default: 902 DBG_ERROR("falscher Dispatcher"); 903 return; 904 } 905 } 906 907 /*-------------------------------------------------------------------- 908 Beschreibung: ClipBoard-Status 909 --------------------------------------------------------------------*/ 910 void SwDrawTextShell::StateClpbrd(SfxItemSet &rSet) 911 { 912 if (!IsTextEdit()) // Sonst Absturz! 913 return; 914 915 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); 916 ESelection aSel(pOLV->GetSelection()); 917 const sal_Bool bCopy = (aSel.nStartPara != aSel.nEndPara) || 918 (aSel.nStartPos != aSel.nEndPos); 919 920 921 SfxWhichIter aIter(rSet); 922 sal_uInt16 nWhich = aIter.FirstWhich(); 923 924 while(nWhich) 925 { 926 switch(nWhich) 927 { 928 case SID_CUT: 929 case SID_COPY: 930 if( !bCopy ) 931 rSet.DisableItem( nWhich ); 932 break; 933 934 case SID_PASTE: 935 { 936 TransferableDataHelper aDataHelper( 937 TransferableDataHelper::CreateFromSystemClipboard( 938 &GetView().GetEditWin() ) ); 939 940 if( !aDataHelper.GetXTransferable().is() || 941 !SwTransferable::IsPaste( GetShell(), aDataHelper )) 942 rSet.DisableItem( SID_PASTE ); 943 } 944 break; 945 946 case SID_PASTE_SPECIAL: 947 rSet.DisableItem( SID_PASTE_SPECIAL ); 948 break; 949 // --> OD 2008-06-20 #151110# 950 case SID_CLIPBOARD_FORMAT_ITEMS: 951 rSet.DisableItem( SID_CLIPBOARD_FORMAT_ITEMS ); 952 break; 953 // <-- 954 } 955 nWhich = aIter.NextWhich(); 956 } 957 } 958 959 /*-------------------------------------------------------------------- 960 Beschreibung: Hyperlink-Status 961 --------------------------------------------------------------------*/ 962 963 void SwDrawTextShell::StateInsert(SfxItemSet &rSet) 964 { 965 if (!IsTextEdit()) // Sonst Absturz! 966 return; 967 968 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); 969 SfxWhichIter aIter(rSet); 970 sal_uInt16 nWhich = aIter.FirstWhich(); 971 972 while(nWhich) 973 { 974 switch(nWhich) 975 { 976 case SID_HYPERLINK_GETLINK: 977 { 978 SvxHyperlinkItem aHLinkItem; 979 aHLinkItem.SetInsertMode(HLINK_FIELD); 980 981 const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection(); 982 983 if (pFieldItem) 984 { 985 const SvxFieldData* pField = pFieldItem->GetField(); 986 987 if (pField->ISA(SvxURLField)) 988 { 989 aHLinkItem.SetName(((const SvxURLField*) pField)->GetRepresentation()); 990 aHLinkItem.SetURL(((const SvxURLField*) pField)->GetURL()); 991 aHLinkItem.SetTargetFrame(((const SvxURLField*) pField)->GetTargetFrame()); 992 } 993 } 994 else 995 { 996 String sSel(pOLV->GetSelected()); 997 sSel.Erase(255); 998 sSel.EraseTrailingChars(); 999 aHLinkItem.SetName(sSel); 1000 } 1001 1002 sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell()); 1003 aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() | 1004 ((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0))); 1005 1006 rSet.Put(aHLinkItem); 1007 } 1008 break; 1009 } 1010 nWhich = aIter.NextWhich(); 1011 } 1012 } 1013 1014