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