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 <hintids.hxx> 28 #include <i18npool/lang.h> 29 #include <svl/slstitm.hxx> 30 #include <svl/cjkoptions.hxx> 31 #include <editeng/fontitem.hxx> 32 #include <editeng/langitem.hxx> 33 #include <svx/svdview.hxx> 34 #include <vcl/msgbox.hxx> 35 #include <sfx2/viewfrm.hxx> 36 #include <sfx2/objface.hxx> 37 #include <svx/svdotext.hxx> 38 #include <editeng/editeng.hxx> 39 #include <editeng/editview.hxx> 40 #include <editeng/eeitem.hxx> 41 #include <editeng/scripttypeitem.hxx> 42 #include <sfx2/bindings.hxx> 43 #include <svx/fontwork.hxx> 44 #include <sfx2/request.hxx> 45 #include <sfx2/sidebar/EnumContext.hxx> 46 #include <svl/whiter.hxx> 47 #include <editeng/outliner.hxx> 48 #include <editeng/editstat.hxx> 49 #include <svx/svdoutl.hxx> 50 #include <com/sun/star/i18n/TransliterationModules.hpp> 51 #include <com/sun/star/i18n/TransliterationModulesExtra.hpp> 52 #include <com/sun/star/i18n/TextConversionOption.hpp> 53 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> 54 #include <com/sun/star/lang/XInitialization.hpp> 55 #include <swtypes.hxx> 56 #include <view.hxx> 57 #include <wrtsh.hxx> 58 #include <viewopt.hxx> 59 #include <initui.hxx> // fuer SpellPointer 60 #include <drwtxtsh.hxx> 61 #include <swundo.hxx> 62 #include <breakit.hxx> 63 64 #include <cmdid.h> 65 #include <helpid.h> 66 #ifndef _GLOBALS_HRC 67 #include <globals.hrc> 68 #endif 69 #ifndef _SHELLS_HRC 70 #include <shells.hrc> 71 #endif 72 73 #define SwDrawTextShell 74 #include <sfx2/msg.hxx> 75 #include <swslots.hxx> 76 #ifndef _POPUP_HRC 77 #include <popup.hrc> 78 #endif 79 #include <uitool.hxx> 80 #include <wview.hxx> 81 #include <swmodule.hxx> 82 #include <svx/xtable.hxx> 83 #include <svx/svxdlg.hxx> 84 #include <svx/dialogs.hrc> 85 #include <svx/svxdlg.hxx> 86 #include <svx/dialogs.hrc> 87 #include <svx/svdoashp.hxx> 88 #include <cppuhelper/bootstrap.hxx> 89 #include "swabstdlg.hxx" //CHINA001 90 #include "misc.hrc" 91 92 using namespace ::com::sun::star; 93 using namespace ::com::sun::star::uno; 94 using namespace ::com::sun::star::beans; 95 using namespace ::com::sun::star::i18n; 96 97 98 99 SFX_IMPL_INTERFACE(SwDrawTextShell, SfxShell, SW_RES(STR_SHELLNAME_DRAW_TEXT)) 100 { 101 SFX_POPUPMENU_REGISTRATION(SW_RES(MN_DRWTXT_POPUPMENU)); 102 SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_DRAW_TEXT_TOOLBOX)); 103 SFX_CHILDWINDOW_REGISTRATION(SvxFontWorkChildWindow::GetChildWindowId()); 104 } 105 106 TYPEINIT1(SwDrawTextShell,SfxShell) 107 108 /*-------------------------------------------------------------------- 109 Beschreibung: 110 --------------------------------------------------------------------*/ 111 112 113 114 void SwDrawTextShell::Init() 115 { 116 SwWrtShell &rSh = GetShell(); 117 pSdrView = rSh.GetDrawView(); 118 SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner(); 119 //#97471# mouse click _and_ key input at the same time 120 if( !pOutliner ) 121 return ; 122 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); 123 sal_uLong nCtrl = pOutliner->GetControlWord(); 124 nCtrl |= EE_CNTRL_AUTOCORRECT; 125 126 SetUndoManager(&pOutliner->GetUndoManager()); 127 128 // jetzt versuchen wir mal ein AutoSpell 129 130 const SwViewOption* pVOpt = rSh.GetViewOptions(); 131 if(pVOpt->IsOnlineSpell()) 132 { 133 nCtrl |= EE_CNTRL_ONLINESPELLING|EE_CNTRL_ALLOWBIGOBJS; 134 } 135 else 136 nCtrl &= ~(EE_CNTRL_ONLINESPELLING); 137 138 pOutliner->SetControlWord(nCtrl); 139 pOLV->ShowCursor(); 140 } 141 142 /*-------------------------------------------------------------------- 143 Beschreibung: 144 --------------------------------------------------------------------*/ 145 146 147 SwDrawTextShell::SwDrawTextShell(SwView &rV) : 148 SfxShell(&rV), 149 rView(rV) 150 { 151 SwWrtShell &rSh = GetShell(); 152 SetPool(rSh.GetAttrPool().GetSecondaryPool()); 153 154 Init(); 155 156 rSh.NoEdit(sal_True); 157 SetName(String::CreateFromAscii("ObjectText")); 158 SetHelpId(SW_DRWTXTSHELL); 159 SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_DrawText)); 160 } 161 162 /*-------------------------------------------------------------------- 163 Beschreibung: 164 --------------------------------------------------------------------*/ 165 166 167 168 __EXPORT SwDrawTextShell::~SwDrawTextShell() 169 { 170 if ( GetView().GetCurShell() == this ) 171 rView.ResetSubShell(); 172 173 //MA 13. Nov. 96: Das kommt durchaus vor #33141#: 174 //(doppel-)Klick von einem Texteditmode in ein anderes Objekt, zwischendurch 175 //wird eine andere (Draw-)Shell gepusht, die alte aber noch nicht deletet. 176 //Dann wird vor dem Flush wieder ein DrawTextShell gepusht und der Mode ist 177 //eingeschaltet. In diesem Moment wird der Dispatcher geflusht und die alte 178 //DrawTextShell zerstoert. 179 // ASSERT( !pSdrView->IsTextEdit(), "TextEdit in DTor DrwTxtSh?" ); 180 // if (pSdrView->IsTextEdit()) 181 // GetShell().EndTextEdit(); // Danebengeklickt, Ende mit Edit 182 183 // GetShell().Edit(); 184 } 185 186 SwWrtShell& SwDrawTextShell::GetShell() 187 { 188 return rView.GetWrtShell(); 189 } 190 191 192 /*-------------------------------------------------------------------- 193 Beschreibung: Slots mit dieser Statusmethode disablen 194 --------------------------------------------------------------------*/ 195 196 void SwDrawTextShell::StateDisableItems( SfxItemSet &rSet ) 197 { 198 SfxWhichIter aIter(rSet); 199 sal_uInt16 nWhich = aIter.FirstWhich(); 200 201 while (nWhich) 202 { 203 rSet.DisableItem( nWhich ); 204 nWhich = aIter.NextWhich(); 205 } 206 } 207 208 209 /************************************************************************* 210 |* 211 |* Attribute setzen 212 |* 213 \************************************************************************/ 214 215 216 217 void SwDrawTextShell::SetAttrToMarked(const SfxItemSet& rAttr) 218 { 219 Rectangle aNullRect; 220 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); 221 Rectangle aOutRect = pOLV->GetOutputArea(); 222 223 if (aNullRect != aOutRect) 224 { 225 GetShell().GetDrawView()->SetAttributes(rAttr); 226 // Init(); 227 } 228 } 229 230 /*-------------------------------------------------------------------- 231 Beschreibung: 232 --------------------------------------------------------------------*/ 233 234 235 236 sal_Bool SwDrawTextShell::IsTextEdit() 237 { 238 return pSdrView->IsTextEdit(); 239 } 240 241 /*-------------------------------------------------------------------- 242 Beschreibung: 243 --------------------------------------------------------------------*/ 244 245 246 247 void SwDrawTextShell::ExecFontWork(SfxRequest& rReq) 248 { 249 SwWrtShell &rSh = GetShell(); 250 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rSh.GetView())); 251 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) ); 252 SfxViewFrame* pVFrame = GetView().GetViewFrame(); 253 if ( rReq.GetArgs() ) 254 { 255 pVFrame->SetChildWindow(SvxFontWorkChildWindow::GetChildWindowId(), 256 ((const SfxBoolItem&) (rReq.GetArgs()-> 257 Get(SID_FONTWORK))).GetValue()); 258 } 259 else 260 pVFrame->ToggleChildWindow(SvxFontWorkChildWindow::GetChildWindowId()); 261 262 pVFrame->GetBindings().Invalidate(SID_FONTWORK); 263 } 264 265 /*-------------------------------------------------------------------- 266 Beschreibung: 267 --------------------------------------------------------------------*/ 268 269 270 271 void SwDrawTextShell::StateFontWork(SfxItemSet& rSet) 272 { 273 const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId(); 274 rSet.Put(SfxBoolItem(SID_FONTWORK, GetView().GetViewFrame()->HasChildWindow(nId))); 275 } 276 277 /************************************************************************* 278 |* 279 |* SfxRequests fuer FontWork bearbeiten 280 |* 281 \************************************************************************/ 282 283 284 285 void SwDrawTextShell::ExecFormText(SfxRequest& rReq) 286 { 287 SwWrtShell &rSh = GetShell(); 288 SdrView* pDrView = rSh.GetDrawView(); 289 290 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); 291 292 if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() ) 293 { 294 const SfxItemSet& rSet = *rReq.GetArgs(); 295 296 //ask for the ViewFrame here - "this" may not be valid any longer! 297 // SfxViewFrame* pVFrame = GetView().GetViewFrame(); 298 if ( pDrView->IsTextEdit() ) 299 { 300 //#111733# Sometimes SdrEndTextEdit() initiates the change in selection and 301 // 'this' is not valid anymore 302 SwView& rTempView = GetView(); 303 pDrView->SdrEndTextEdit(sal_True); 304 //this removes the current shell from the dispatcher stack!! 305 rTempView.AttrChangedNotify(&rSh); 306 } 307 308 pDrView->SetAttributes(rSet); 309 } 310 311 } 312 313 /************************************************************************* 314 |* 315 |* Statuswerte fuer FontWork zurueckgeben 316 |* 317 \************************************************************************/ 318 319 320 321 void SwDrawTextShell::GetFormTextState(SfxItemSet& rSet) 322 { 323 SwWrtShell &rSh = GetShell(); 324 SdrView* pDrView = rSh.GetDrawView(); 325 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); 326 const SdrObject* pObj = NULL; 327 SvxFontWorkDialog* pDlg = NULL; 328 329 const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId(); 330 331 SfxViewFrame* pVFrame = GetView().GetViewFrame(); 332 if ( pVFrame->HasChildWindow(nId) ) 333 pDlg = (SvxFontWorkDialog*)(pVFrame->GetChildWindow(nId)->GetWindow()); 334 335 if ( rMarkList.GetMarkCount() == 1 ) 336 pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); 337 338 const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(pObj); 339 const bool bDeactivate( 340 !pObj || 341 !pTextObj || 342 !pTextObj->HasText() || 343 dynamic_cast< const SdrObjCustomShape* >(pObj)); // #121538# no FontWork for CustomShapes 344 345 if (bDeactivate) 346 { 347 rSet.DisableItem(XATTR_FORMTXTSTYLE); 348 rSet.DisableItem(XATTR_FORMTXTADJUST); 349 rSet.DisableItem(XATTR_FORMTXTDISTANCE); 350 rSet.DisableItem(XATTR_FORMTXTSTART); 351 rSet.DisableItem(XATTR_FORMTXTMIRROR); 352 rSet.DisableItem(XATTR_FORMTXTHIDEFORM); 353 rSet.DisableItem(XATTR_FORMTXTOUTLINE); 354 rSet.DisableItem(XATTR_FORMTXTSHADOW); 355 rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR); 356 rSet.DisableItem(XATTR_FORMTXTSHDWXVAL); 357 rSet.DisableItem(XATTR_FORMTXTSHDWYVAL); 358 } 359 else 360 { 361 if ( pDlg ) 362 pDlg->SetColorTable(XColorList::GetStdColorList()); 363 364 pDrView->GetAttributes( rSet ); 365 } 366 } 367 368 /*-------------------------------------------------------------------- 369 Beschreibung: 370 --------------------------------------------------------------------*/ 371 372 373 374 void SwDrawTextShell::ExecDrawLingu(SfxRequest &rReq) 375 { 376 SwWrtShell &rSh = GetShell(); 377 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); 378 if( rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() ) 379 { 380 switch(rReq.GetSlot()) 381 { 382 case SID_THESAURUS: 383 pOLV->StartThesaurus(); 384 break; 385 386 case SID_HANGUL_HANJA_CONVERSION: 387 pOLV->StartTextConversion( LANGUAGE_KOREAN, LANGUAGE_KOREAN, NULL, 388 i18n::TextConversionOption::CHARACTER_BY_CHARACTER, sal_True, sal_False ); 389 break; 390 391 case SID_CHINESE_CONVERSION: 392 { 393 //open ChineseTranslationDialog 394 Reference< XComponentContext > xContext( 395 ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one 396 if(xContext.is()) 397 { 398 Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() ); 399 if(xMCF.is()) 400 { 401 Reference< ui::dialogs::XExecutableDialog > xDialog( 402 xMCF->createInstanceWithContext( 403 rtl::OUString::createFromAscii("com.sun.star.linguistic2.ChineseTranslationDialog") 404 , xContext), UNO_QUERY); 405 Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY ); 406 if( xInit.is() ) 407 { 408 // initialize dialog 409 Reference< awt::XWindow > xDialogParentWindow(0); 410 Sequence<Any> aSeq(1); 411 Any* pArray = aSeq.getArray(); 412 PropertyValue aParam; 413 aParam.Name = rtl::OUString::createFromAscii("ParentWindow"); 414 aParam.Value <<= makeAny(xDialogParentWindow); 415 pArray[0] <<= makeAny(aParam); 416 xInit->initialize( aSeq ); 417 418 //execute dialog 419 sal_Int16 nDialogRet = xDialog->execute(); 420 if( RET_OK == nDialogRet ) 421 { 422 //get some parameters from the dialog 423 sal_Bool bToSimplified = sal_True; 424 sal_Bool bUseVariants = sal_True; 425 sal_Bool bCommonTerms = sal_True; 426 Reference< beans::XPropertySet > xProp( xDialog, UNO_QUERY ); 427 if( xProp.is() ) 428 { 429 try 430 { 431 xProp->getPropertyValue( C2U("IsDirectionToSimplified") ) >>= bToSimplified; 432 xProp->getPropertyValue( C2U("IsUseCharacterVariants") ) >>= bUseVariants; 433 xProp->getPropertyValue( C2U("IsTranslateCommonTerms") ) >>= bCommonTerms; 434 } 435 catch( Exception& ) 436 { 437 } 438 } 439 440 //execute translation 441 sal_Int16 nSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED; 442 sal_Int16 nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL; 443 sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0; 444 if( !bCommonTerms ) 445 nOptions = nOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER; 446 447 Font aTargetFont = pOLV->GetWindow()->GetDefaultFont( DEFAULTFONT_CJK_TEXT, 448 nTargetLang, DEFAULTFONT_FLAGS_ONLYONE ); 449 450 pOLV->StartTextConversion( nSourceLang, nTargetLang, &aTargetFont, nOptions, sal_False, sal_False ); 451 } 452 } 453 Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY ); 454 if( xComponent.is() ) 455 xComponent->dispose(); 456 } 457 } 458 } 459 break; 460 461 default: 462 ASSERT(!this, "unexpected slot-id"); 463 } 464 } 465 } 466 467 /*-------------------------------------------------------------------- 468 Beschreibung: 469 --------------------------------------------------------------------*/ 470 void SwDrawTextShell::ExecDraw(SfxRequest &rReq) 471 { 472 SwWrtShell &rSh = GetShell(); 473 pSdrView = rSh.GetDrawView(); 474 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); 475 476 switch (rReq.GetSlot()) 477 { 478 case FN_INSERT_SOFT_HYPHEN: 479 case FN_INSERT_HARDHYPHEN: 480 case FN_INSERT_HARD_SPACE: 481 case SID_INSERT_RLM : 482 case SID_INSERT_LRM : 483 case SID_INSERT_ZWNBSP : 484 case SID_INSERT_ZWSP: 485 { 486 sal_Unicode cIns = 0; 487 switch(rReq.GetSlot()) 488 { 489 case FN_INSERT_SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break; 490 case FN_INSERT_HARDHYPHEN: cIns = CHAR_HARDHYPHEN; break; 491 case FN_INSERT_HARD_SPACE: cIns = CHAR_HARDBLANK; break; 492 case SID_INSERT_RLM : cIns = CHAR_RLM ; break; 493 case SID_INSERT_LRM : cIns = CHAR_LRM ; break; 494 case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break; 495 case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break; 496 } 497 pOLV->InsertText( String(cIns)); 498 rReq.Done(); 499 } 500 break; 501 case SID_CHARMAP: 502 { // Sonderzeichen einfuegen 503 InsertSymbol(rReq); 504 break; 505 } 506 case FN_INSERT_STRING: 507 { 508 const SfxItemSet *pNewAttrs = rReq.GetArgs(); 509 sal_uInt16 nSlot = rReq.GetSlot(); 510 const SfxPoolItem* pItem = 0; 511 if(pNewAttrs) 512 { 513 pNewAttrs->GetItemState(nSlot, sal_False, &pItem ); 514 pOLV->InsertText(((const SfxStringItem *)pItem)->GetValue()); 515 } 516 break; 517 } 518 519 case SID_SELECTALL: 520 { 521 SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner(); 522 if(pOutliner) 523 { 524 sal_uLong nParaCount = pOutliner->GetParagraphCount(); 525 if (nParaCount > 0) 526 pOLV->SelectRange(0L, sal_uInt16(nParaCount) ); 527 } 528 } 529 break; 530 531 case FN_FORMAT_RESET: // delete hard text attributes 532 { 533 pOLV->RemoveAttribsKeepLanguages( true ); 534 pOLV->GetEditView().GetEditEngine()->RemoveFields(sal_True); 535 rReq.Done(); 536 } 537 break; 538 539 case FN_ESCAPE: 540 if (pSdrView->IsTextEdit()) 541 { 542 // Shellwechsel! 543 rSh.EndTextEdit(); 544 SwView& rTempView = rSh.GetView(); 545 rTempView.ExitDraw(); 546 rSh.Edit(); 547 rTempView.AttrChangedNotify(&rSh); 548 return; 549 } 550 break; 551 case FN_DRAWTEXT_ATTR_DLG: 552 { 553 SfxItemSet aNewAttr( pSdrView->GetModel()->GetItemPool() ); 554 pSdrView->GetAttributes( aNewAttr ); 555 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 556 if ( pFact ) 557 { 558 SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( 559 &(GetView().GetViewFrame()->GetWindow()), 560 &aNewAttr, pSdrView ); 561 sal_uInt16 nResult = pDlg->Execute(); 562 563 if (nResult == RET_OK) 564 { 565 if (pSdrView->AreObjectsMarked()) 566 { 567 pSdrView->SetAttributes(*pDlg->GetOutputItemSet()); 568 rReq.Done(*(pDlg->GetOutputItemSet())); 569 } 570 } 571 572 delete( pDlg ); 573 } 574 } 575 break; 576 case SID_TABLE_VERT_NONE: 577 case SID_TABLE_VERT_CENTER: 578 case SID_TABLE_VERT_BOTTOM: 579 { 580 sal_uInt16 nSId = rReq.GetSlot(); 581 if (pSdrView->AreObjectsMarked()) 582 { 583 SdrTextVertAdjust eTVA = SDRTEXTVERTADJUST_TOP; 584 if (nSId == SID_TABLE_VERT_CENTER) 585 eTVA = SDRTEXTVERTADJUST_CENTER; 586 else if (nSId == SID_TABLE_VERT_BOTTOM) 587 eTVA = SDRTEXTVERTADJUST_BOTTOM; 588 589 SfxItemSet aNewAttr( pSdrView->GetModel()->GetItemPool() ); 590 pSdrView->GetAttributes( aNewAttr ); 591 aNewAttr.Put(SdrTextVertAdjustItem(eTVA)); 592 pSdrView->SetAttributes(aNewAttr); 593 rReq.Done(); 594 } 595 596 } 597 break; 598 599 default: 600 ASSERT(!this, "unexpected slot-id"); 601 return; 602 } 603 604 GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False); 605 606 if (IsTextEdit() && pOLV->GetOutliner()->IsModified()) 607 rSh.SetModified(); 608 } 609 610 /*-------------------------------------------------------------------- 611 Beschreibung: Undo ausfuehren 612 --------------------------------------------------------------------*/ 613 614 615 616 void SwDrawTextShell::ExecUndo(SfxRequest &rReq) 617 { 618 if( IsTextEdit() ) 619 { 620 sal_Bool bCallBase = sal_True; 621 const SfxItemSet* pArgs = rReq.GetArgs(); 622 if( pArgs ) 623 { 624 sal_uInt16 nId = rReq.GetSlot(), nCnt = 1; 625 const SfxPoolItem* pItem; 626 switch( nId ) 627 { 628 case SID_UNDO: 629 case SID_REDO: 630 if( SFX_ITEM_SET == pArgs->GetItemState( nId, sal_False, &pItem ) && 631 1 < (nCnt = ((SfxUInt16Item*)pItem)->GetValue()) ) 632 { 633 // then we make by ourself. 634 ::svl::IUndoManager* pUndoManager = GetUndoManager(); 635 if( pUndoManager ) 636 { 637 if( SID_UNDO == nId ) 638 while( nCnt-- ) 639 pUndoManager->Undo(); 640 else 641 while( nCnt-- ) 642 pUndoManager->Redo(); 643 } 644 bCallBase = sal_False; 645 GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False); 646 } 647 break; 648 } 649 } 650 if( bCallBase ) 651 { 652 SfxViewFrame *pSfxViewFrame = GetView().GetViewFrame(); 653 pSfxViewFrame->ExecuteSlot(rReq, pSfxViewFrame->GetInterface()); 654 } 655 } 656 } 657 658 /*-------------------------------------------------------------------- 659 Beschreibung: Zustand Undo 660 --------------------------------------------------------------------*/ 661 662 663 664 void SwDrawTextShell::StateUndo(SfxItemSet &rSet) 665 { 666 if ( !IsTextEdit() ) 667 return; 668 669 SfxViewFrame *pSfxViewFrame = GetView().GetViewFrame(); 670 SfxWhichIter aIter(rSet); 671 sal_uInt16 nWhich = aIter.FirstWhich(); 672 while( nWhich ) 673 { 674 switch ( nWhich ) 675 { 676 case SID_GETUNDOSTRINGS: 677 case SID_GETREDOSTRINGS: 678 { 679 ::svl::IUndoManager* pUndoManager = GetUndoManager(); 680 if( pUndoManager ) 681 { 682 UniString (::svl::IUndoManager:: *fnGetComment)( size_t, bool const ) const; 683 684 sal_uInt16 nCount; 685 if( SID_GETUNDOSTRINGS == nWhich ) 686 { 687 nCount = pUndoManager->GetUndoActionCount(); 688 fnGetComment = &::svl::IUndoManager::GetUndoActionComment; 689 } 690 else 691 { 692 nCount = pUndoManager->GetRedoActionCount(); 693 fnGetComment = &::svl::IUndoManager::GetRedoActionComment; 694 } 695 if( nCount ) 696 { 697 String sList; 698 for( sal_uInt16 n = 0; n < nCount; ++n ) 699 ( sList += (pUndoManager->*fnGetComment)( n, ::svl::IUndoManager::TopLevel ) ) 700 += '\n'; 701 702 SfxStringListItem aItem( nWhich ); 703 aItem.SetString( sList ); 704 rSet.Put( aItem ); 705 } 706 } 707 else 708 rSet.DisableItem( nWhich ); 709 } 710 break; 711 712 default: 713 pSfxViewFrame->GetSlotState( nWhich, 714 pSfxViewFrame->GetInterface(), &rSet ); 715 } 716 717 nWhich = aIter.NextWhich(); 718 } 719 } 720 721 void SwDrawTextShell::ExecTransliteration( SfxRequest & rReq ) 722 { 723 using namespace i18n; 724 { 725 sal_uInt32 nMode = 0; 726 727 switch( rReq.GetSlot() ) 728 { 729 case SID_TRANSLITERATE_SENTENCE_CASE: 730 nMode = TransliterationModulesExtra::SENTENCE_CASE; 731 break; 732 case SID_TRANSLITERATE_TITLE_CASE: 733 nMode = TransliterationModulesExtra::TITLE_CASE; 734 break; 735 case SID_TRANSLITERATE_TOGGLE_CASE: 736 nMode = TransliterationModulesExtra::TOGGLE_CASE; 737 break; 738 case SID_TRANSLITERATE_UPPER: 739 nMode = TransliterationModules_LOWERCASE_UPPERCASE; 740 break; 741 case SID_TRANSLITERATE_LOWER: 742 nMode = TransliterationModules_UPPERCASE_LOWERCASE; 743 break; 744 745 case SID_TRANSLITERATE_HALFWIDTH: 746 nMode = TransliterationModules_FULLWIDTH_HALFWIDTH; 747 break; 748 case SID_TRANSLITERATE_FULLWIDTH: 749 nMode = TransliterationModules_HALFWIDTH_FULLWIDTH; 750 break; 751 752 case SID_TRANSLITERATE_HIRAGANA: 753 nMode = TransliterationModules_KATAKANA_HIRAGANA; 754 break; 755 case SID_TRANSLITERATE_KATAGANA: 756 nMode = TransliterationModules_HIRAGANA_KATAKANA; 757 break; 758 759 default: 760 ASSERT(!this, "falscher Dispatcher"); 761 } 762 763 if( nMode ) 764 { 765 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); 766 pOLV->TransliterateText( nMode ); 767 } 768 } 769 } 770 771 /*-------------------------------------------------------------------- 772 Beschreibung: Sonderzeichen einfuegen (siehe SDraw: FUBULLET.CXX) 773 --------------------------------------------------------------------*/ 774 775 void SwDrawTextShell::InsertSymbol(SfxRequest& rReq) 776 { 777 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); 778 if(!pOLV) 779 return; 780 const SfxItemSet *pArgs = rReq.GetArgs(); 781 const SfxPoolItem* pItem = 0; 782 if( pArgs ) 783 pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), sal_False, &pItem); 784 785 String sSym; 786 String sFontName; 787 if ( pItem ) 788 { 789 sSym = ((const SfxStringItem*)pItem)->GetValue(); 790 const SfxPoolItem* pFtItem = NULL; 791 pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), sal_False, &pFtItem); 792 const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem ); 793 if ( pFontItem ) 794 sFontName = pFontItem->GetValue(); 795 } 796 797 SfxItemSet aSet(pOLV->GetAttribs()); 798 sal_uInt16 nScript = pOLV->GetSelectedScriptType(); 799 SvxFontItem aSetDlgFont( RES_CHRATR_FONT ); 800 { 801 SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() ); 802 aSetItem.GetItemSet().Put( aSet, sal_False ); 803 const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript ); 804 if( pI ) 805 aSetDlgFont = *(SvxFontItem*)pI; 806 else 807 aSetDlgFont = (SvxFontItem&)aSet.Get( GetWhichOfScript( 808 SID_ATTR_CHAR_FONT, 809 GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() ) )); 810 if (!sFontName.Len()) 811 sFontName = aSetDlgFont.GetFamilyName(); 812 } 813 814 Font aFont(sFontName, Size(1,1)); 815 if(!sSym.Len()) 816 { 817 SfxAllItemSet aAllSet( GetPool() ); 818 aAllSet.Put( SfxBoolItem( FN_PARAM_1, sal_False ) ); 819 820 SwViewOption aOpt(*rView.GetWrtShell().GetViewOptions()); 821 String sSymbolFont = aOpt.GetSymbolFont(); 822 if( sSymbolFont.Len() ) 823 aAllSet.Put( SfxStringItem( SID_FONT_NAME, sSymbolFont ) ); 824 else 825 aAllSet.Put( SfxStringItem( SID_FONT_NAME, aSetDlgFont.GetFamilyName() ) ); 826 827 // Wenn Zeichen selektiert ist kann es angezeigt werden 828 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 829 SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( rView.GetWindow(), aAllSet, 830 rView.GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP ); 831 sal_uInt16 nResult = pDlg->Execute(); 832 if( nResult == RET_OK ) 833 { 834 SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pCItem, SfxStringItem, SID_CHARMAP, sal_False ); 835 SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, sal_False ); 836 if ( pFontItem ) 837 { 838 aFont.SetName( pFontItem->GetFamilyName() ); 839 aFont.SetStyleName( pFontItem->GetStyleName() ); 840 aFont.SetCharSet( pFontItem->GetCharSet() ); 841 aFont.SetPitch( pFontItem->GetPitch() ); 842 } 843 844 if ( pCItem ) 845 { 846 sSym = pCItem->GetValue(); 847 aOpt.SetSymbolFont(aFont.GetName()); 848 SW_MOD()->ApplyUsrPref(aOpt, &rView); 849 } 850 } 851 852 delete( pDlg ); 853 } 854 855 if( sSym.Len() ) 856 { 857 // nicht flackern 858 pOLV->HideCursor(); 859 SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner(); 860 pOutliner->SetUpdateMode(sal_False); 861 862 SfxItemSet aOldSet( pOLV->GetAttribs() ); 863 SfxItemSet aFontSet( *aOldSet.GetPool(), 864 EE_CHAR_FONTINFO, EE_CHAR_FONTINFO, 865 EE_CHAR_FONTINFO_CJK, EE_CHAR_FONTINFO_CJK, 866 EE_CHAR_FONTINFO_CTL, EE_CHAR_FONTINFO_CTL, 867 0 ); 868 aFontSet.Set( aOldSet ); 869 870 // String einfuegen 871 pOLV->InsertText( sSym ); 872 873 // attributieren (Font setzen) 874 SfxItemSet aFontAttribSet( *aFontSet.GetPool(), aFontSet.GetRanges() ); 875 SvxFontItem aFontItem (aFont.GetFamily(), aFont.GetName(), 876 aFont.GetStyleName(), aFont.GetPitch(), 877 aFont.GetCharSet(), 878 EE_CHAR_FONTINFO ); 879 nScript = pBreakIt->GetAllScriptsOfText( sSym ); 880 if( SCRIPTTYPE_LATIN & nScript ) 881 aFontAttribSet.Put( aFontItem, EE_CHAR_FONTINFO ); 882 if( SCRIPTTYPE_ASIAN & nScript ) 883 aFontAttribSet.Put( aFontItem, EE_CHAR_FONTINFO_CJK ); 884 if( SCRIPTTYPE_COMPLEX & nScript ) 885 aFontAttribSet.Put( aFontItem, EE_CHAR_FONTINFO_CTL ); 886 pOLV->SetAttribs(aFontAttribSet); 887 888 // Selektion loeschen 889 ESelection aSel(pOLV->GetSelection()); 890 aSel.nStartPara = aSel.nEndPara; 891 aSel.nStartPos = aSel.nEndPos; 892 pOLV->SetSelection(aSel); 893 894 // Alten Font restaurieren 895 pOLV->SetAttribs( aFontSet ); 896 897 // ab jetzt wieder anzeigen 898 pOutliner->SetUpdateMode(sal_True); 899 pOLV->ShowCursor(); 900 901 rReq.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP), sSym ) ); 902 if(aFont.GetName().Len()) 903 rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR, aFont.GetName() ) ); 904 rReq.Done(); 905 } 906 } 907 /*-- 22.10.2003 14:26:32--------------------------------------------------- 908 909 -----------------------------------------------------------------------*/ 910 ::svl::IUndoManager* SwDrawTextShell::GetUndoManager() 911 { 912 SwWrtShell &rSh = GetShell(); 913 pSdrView = rSh.GetDrawView(); 914 SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner(); 915 pOutliner = pSdrView->GetTextEditOutliner(); 916 return &pOutliner->GetUndoManager(); 917 } 918 919 void SwDrawTextShell::GetStatePropPanelAttr(SfxItemSet &rSet) 920 { 921 SfxWhichIter aIter( rSet ); 922 sal_uInt16 nWhich = aIter.FirstWhich(); 923 924 SwWrtShell &rSh = GetShell(); 925 pSdrView = rSh.GetDrawView(); 926 927 SfxItemSet aAttrs( pSdrView->GetModel()->GetItemPool() ); 928 pSdrView->GetAttributes( aAttrs ); 929 930 while ( nWhich ) 931 { 932 sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich) 933 ? GetPool().GetSlotId(nWhich) 934 : nWhich; 935 switch ( nSlotId ) 936 { 937 case SID_TABLE_VERT_NONE: 938 case SID_TABLE_VERT_CENTER: 939 case SID_TABLE_VERT_BOTTOM: 940 sal_Bool bContour = sal_False; 941 SfxItemState eConState = aAttrs.GetItemState( SDRATTR_TEXT_CONTOURFRAME ); 942 if( eConState != SFX_ITEM_DONTCARE ) 943 { 944 bContour = ( ( const SdrTextContourFrameItem& )aAttrs.Get( SDRATTR_TEXT_CONTOURFRAME ) ).GetValue(); 945 } 946 if (bContour) break; 947 948 SfxItemState eVState = aAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ); 949 //SfxItemState eHState = aAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ); 950 951 //if(SFX_ITEM_DONTCARE != eVState && SFX_ITEM_DONTCARE != eHState) 952 if(SFX_ITEM_DONTCARE != eVState) 953 { 954 SdrTextVertAdjust eTVA = (SdrTextVertAdjust)((const SdrTextVertAdjustItem&)aAttrs.Get(SDRATTR_TEXT_VERTADJUST)).GetValue(); 955 sal_Bool bSet = nSlotId == SID_TABLE_VERT_NONE && eTVA == SDRTEXTVERTADJUST_TOP|| 956 nSlotId == SID_TABLE_VERT_CENTER && eTVA == SDRTEXTVERTADJUST_CENTER || 957 nSlotId == SID_TABLE_VERT_BOTTOM && eTVA == SDRTEXTVERTADJUST_BOTTOM; 958 rSet.Put(SfxBoolItem(nSlotId, bSet)); 959 } 960 else 961 { 962 rSet.Put(SfxBoolItem(nSlotId, sal_False)); 963 } 964 break; 965 } 966 nWhich = aIter.NextWhich(); 967 } 968 } 969