update dev300-m58
[ooovba.git] / sw / source / ui / shells / drwtxtsh.cxx
blob9098c55dcf5156a2807357b94415f02896361146
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drwtxtsh.cxx,v $
10 * $Revision: 1.42.190.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #include <hintids.hxx>
34 #include <i18npool/lang.h>
35 #include <svtools/slstitm.hxx>
36 #include <svtools/cjkoptions.hxx>
37 #include <svx/fontitem.hxx>
38 #include <svx/langitem.hxx>
39 #include <svx/svdview.hxx>
40 #include <vcl/msgbox.hxx>
41 #include <sfx2/viewfrm.hxx>
42 #include <sfx2/objface.hxx>
43 #include <svx/svdotext.hxx>
44 #include <svx/xftsfit.hxx>
45 #include <svx/editeng.hxx>
46 #include <svx/editview.hxx>
47 #include <svx/eeitem.hxx>
48 #include <svx/scripttypeitem.hxx>
49 #include <sfx2/bindings.hxx>
50 #include <svx/fontwork.hxx>
51 #include <sfx2/request.hxx>
52 #include <svtools/whiter.hxx>
53 #include <svx/outliner.hxx>
54 #include <svx/editstat.hxx>
55 #include <svx/svdoutl.hxx>
56 #include <unoobj.hxx>
57 #include <com/sun/star/i18n/TransliterationModules.hpp>
58 #include <com/sun/star/i18n/TextConversionOption.hpp>
59 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
60 #include <com/sun/star/lang/XInitialization.hpp>
61 #include <swtypes.hxx>
62 #include <view.hxx>
63 #include <wrtsh.hxx>
64 #include <viewopt.hxx>
65 #include <initui.hxx> // fuer SpellPointer
66 #include <drwtxtsh.hxx>
67 #include <swundo.hxx>
68 #include <breakit.hxx>
70 #ifndef _CMDID_H
71 #include <cmdid.h>
72 #endif
73 #ifndef _HELPID_H
74 #include <helpid.h>
75 #endif
76 #ifndef _GLOBALS_HRC
77 #include <globals.hrc>
78 #endif
79 #ifndef _SHELLS_HRC
80 #include <shells.hrc>
81 #endif
83 #define SwDrawTextShell
84 #include <sfx2/msg.hxx>
85 #include <swslots.hxx>
86 #ifndef _POPUP_HRC
87 #include <popup.hrc>
88 #endif
89 #include <uitool.hxx>
90 #include <wview.hxx>
91 #include <swmodule.hxx>
93 #include <svx/xtable.hxx>
94 #include <svx/svxdlg.hxx>
95 #include <svx/dialogs.hrc>
97 #include <svx/svxdlg.hxx>
98 #include <svx/dialogs.hrc>
100 #include <cppuhelper/bootstrap.hxx>
102 #include "swabstdlg.hxx" //CHINA001
103 #include "misc.hrc"
105 using namespace ::com::sun::star;
106 using namespace ::com::sun::star::uno;
107 using namespace ::com::sun::star::beans;
108 using namespace ::com::sun::star::i18n;
112 SFX_IMPL_INTERFACE(SwDrawTextShell, SfxShell, SW_RES(STR_SHELLNAME_DRAW_TEXT))
114 SFX_POPUPMENU_REGISTRATION(SW_RES(MN_DRWTXT_POPUPMENU));
115 SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_DRAW_TEXT_TOOLBOX));
116 SFX_CHILDWINDOW_REGISTRATION(SvxFontWorkChildWindow::GetChildWindowId());
119 TYPEINIT1(SwDrawTextShell,SfxShell)
121 /*--------------------------------------------------------------------
122 Beschreibung:
123 --------------------------------------------------------------------*/
127 void SwDrawTextShell::Init()
129 SwWrtShell &rSh = GetShell();
130 pSdrView = rSh.GetDrawView();
131 SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
132 //#97471# mouse click _and_ key input at the same time
133 if( !pOutliner )
134 return ;
135 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
136 ULONG nCtrl = pOutliner->GetControlWord();
137 nCtrl |= EE_CNTRL_AUTOCORRECT;
139 SetUndoManager(&pOutliner->GetUndoManager());
141 // jetzt versuchen wir mal ein AutoSpell
143 const SwViewOption* pVOpt = rSh.GetViewOptions();
144 if(pVOpt->IsOnlineSpell())
146 nCtrl |= EE_CNTRL_ONLINESPELLING|EE_CNTRL_ALLOWBIGOBJS;
148 else
149 nCtrl &= ~(EE_CNTRL_ONLINESPELLING);
151 pOutliner->SetControlWord(nCtrl);
152 pOLV->ShowCursor();
155 /*--------------------------------------------------------------------
156 Beschreibung:
157 --------------------------------------------------------------------*/
160 SwDrawTextShell::SwDrawTextShell(SwView &rV) :
161 SfxShell(&rV),
162 rView(rV)
164 SwWrtShell &rSh = GetShell();
165 SetPool(rSh.GetAttrPool().GetSecondaryPool());
167 Init();
169 rSh.NoEdit(TRUE);
170 SetName(String::CreateFromAscii("ObjectText"));
171 SetHelpId(SW_DRWTXTSHELL);
174 /*--------------------------------------------------------------------
175 Beschreibung:
176 --------------------------------------------------------------------*/
180 __EXPORT SwDrawTextShell::~SwDrawTextShell()
182 if ( GetView().GetCurShell() == this )
183 rView.ResetSubShell();
185 //MA 13. Nov. 96: Das kommt durchaus vor #33141#:
186 //(doppel-)Klick von einem Texteditmode in ein anderes Objekt, zwischendurch
187 //wird eine andere (Draw-)Shell gepusht, die alte aber noch nicht deletet.
188 //Dann wird vor dem Flush wieder ein DrawTextShell gepusht und der Mode ist
189 //eingeschaltet. In diesem Moment wird der Dispatcher geflusht und die alte
190 //DrawTextShell zerstoert.
191 // ASSERT( !pSdrView->IsTextEdit(), "TextEdit in DTor DrwTxtSh?" );
192 // if (pSdrView->IsTextEdit())
193 // GetShell().EndTextEdit(); // Danebengeklickt, Ende mit Edit
195 // GetShell().Edit();
198 SwWrtShell& SwDrawTextShell::GetShell()
200 return rView.GetWrtShell();
204 /*--------------------------------------------------------------------
205 Beschreibung: Slots mit dieser Statusmethode disablen
206 --------------------------------------------------------------------*/
208 void SwDrawTextShell::StateDisableItems( SfxItemSet &rSet )
210 SfxWhichIter aIter(rSet);
211 USHORT nWhich = aIter.FirstWhich();
213 while (nWhich)
215 rSet.DisableItem( nWhich );
216 nWhich = aIter.NextWhich();
221 /*************************************************************************
223 |* Attribute setzen
225 \************************************************************************/
229 void SwDrawTextShell::SetAttrToMarked(const SfxItemSet& rAttr)
231 Rectangle aNullRect;
232 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
233 Rectangle aOutRect = pOLV->GetOutputArea();
235 if (aNullRect != aOutRect)
237 GetShell().GetDrawView()->SetAttributes(rAttr);
238 // Init();
242 /*--------------------------------------------------------------------
243 Beschreibung:
244 --------------------------------------------------------------------*/
248 BOOL SwDrawTextShell::IsTextEdit()
250 return pSdrView->IsTextEdit();
253 /*--------------------------------------------------------------------
254 Beschreibung:
255 --------------------------------------------------------------------*/
259 void SwDrawTextShell::ExecFontWork(SfxRequest& rReq)
261 SwWrtShell &rSh = GetShell();
262 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rSh.GetView()));
263 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< UINT16 >(eMetric)) );
264 SfxViewFrame* pVFrame = GetView().GetViewFrame();
265 if ( rReq.GetArgs() )
267 pVFrame->SetChildWindow(SvxFontWorkChildWindow::GetChildWindowId(),
268 ((const SfxBoolItem&) (rReq.GetArgs()->
269 Get(SID_FONTWORK))).GetValue());
271 else
272 pVFrame->ToggleChildWindow(SvxFontWorkChildWindow::GetChildWindowId());
274 pVFrame->GetBindings().Invalidate(SID_FONTWORK);
277 /*--------------------------------------------------------------------
278 Beschreibung:
279 --------------------------------------------------------------------*/
283 void SwDrawTextShell::StateFontWork(SfxItemSet& rSet)
285 const USHORT nId = SvxFontWorkChildWindow::GetChildWindowId();
286 rSet.Put(SfxBoolItem(SID_FONTWORK, GetView().GetViewFrame()->HasChildWindow(nId)));
289 /*************************************************************************
291 |* SfxRequests fuer FontWork bearbeiten
293 \************************************************************************/
297 void SwDrawTextShell::ExecFormText(SfxRequest& rReq)
299 SwWrtShell &rSh = GetShell();
300 SdrView* pDrView = rSh.GetDrawView();
302 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
304 if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
306 const SfxItemSet& rSet = *rReq.GetArgs();
307 const SfxPoolItem* pItem;
309 //ask for the ViewFrame here - "this" may not be valid any longer!
310 SfxViewFrame* pVFrame = GetView().GetViewFrame();
311 if ( pDrView->IsTextEdit() )
313 //#111733# Sometimes SdrEndTextEdit() initiates the change in selection and
314 // 'this' is not valid anymore
315 SwView& rTempView = GetView();
316 pDrView->SdrEndTextEdit(sal_True);
317 //this removes the current shell from the dispatcher stack!!
318 rTempView.AttrChangedNotify(&rSh);
321 if ( rSet.GetItemState(XATTR_FORMTXTSTDFORM, TRUE, &pItem) ==
322 SFX_ITEM_SET &&
323 ((const XFormTextStdFormItem*) pItem)->GetValue() != XFTFORM_NONE )
326 const USHORT nId = SvxFontWorkChildWindow::GetChildWindowId();
327 SvxFontWorkDialog* pDlg = (SvxFontWorkDialog*)(
328 pVFrame->GetChildWindow(nId)->GetWindow());
330 pDlg->CreateStdFormObj(*pDrView, *pDrView->GetSdrPageView(),
331 rSet, *rMarkList.GetMark(0)->GetMarkedSdrObj(),
332 ((const XFormTextStdFormItem*) pItem)->
333 GetValue());
335 else
336 pDrView->SetAttributes(rSet);
341 /*************************************************************************
343 |* Statuswerte fuer FontWork zurueckgeben
345 \************************************************************************/
349 void SwDrawTextShell::GetFormTextState(SfxItemSet& rSet)
351 SwWrtShell &rSh = GetShell();
352 SdrView* pDrView = rSh.GetDrawView();
353 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
354 const SdrObject* pObj = NULL;
355 SvxFontWorkDialog* pDlg = NULL;
357 const USHORT nId = SvxFontWorkChildWindow::GetChildWindowId();
359 SfxViewFrame* pVFrame = GetView().GetViewFrame();
360 if ( pVFrame->HasChildWindow(nId) )
361 pDlg = (SvxFontWorkDialog*)(pVFrame->GetChildWindow(nId)->GetWindow());
363 if ( rMarkList.GetMarkCount() == 1 )
364 pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
366 if ( pObj == NULL || !pObj->ISA(SdrTextObj) ||
367 !((SdrTextObj*) pObj)->HasText() )
369 #define XATTR_ANZ 12
370 static const USHORT nXAttr[ XATTR_ANZ ] =
371 { XATTR_FORMTXTSTYLE, XATTR_FORMTXTADJUST, XATTR_FORMTXTDISTANCE,
372 XATTR_FORMTXTSTART, XATTR_FORMTXTMIRROR, XATTR_FORMTXTSTDFORM,
373 XATTR_FORMTXTHIDEFORM, XATTR_FORMTXTOUTLINE, XATTR_FORMTXTSHADOW,
374 XATTR_FORMTXTSHDWCOLOR, XATTR_FORMTXTSHDWXVAL, XATTR_FORMTXTSHDWYVAL
376 for( USHORT i = 0; i < XATTR_ANZ; )
377 rSet.DisableItem( nXAttr[ i++ ] );
379 else
381 if ( pDlg )
382 pDlg->SetColorTable(XColorTable::GetStdColorTable());
384 pDrView->GetAttributes( rSet );
388 /*--------------------------------------------------------------------
389 Beschreibung:
390 --------------------------------------------------------------------*/
394 void SwDrawTextShell::ExecDrawLingu(SfxRequest &rReq)
396 SwWrtShell &rSh = GetShell();
397 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
398 if( rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() )
400 switch(rReq.GetSlot())
402 case FN_THESAURUS_DLG:
403 pOLV->StartThesaurus();
404 break;
406 case SID_HANGUL_HANJA_CONVERSION:
407 pOLV->StartTextConversion( LANGUAGE_KOREAN, LANGUAGE_KOREAN, NULL,
408 i18n::TextConversionOption::CHARACTER_BY_CHARACTER, sal_True, sal_False );
409 break;
411 case SID_CHINESE_CONVERSION:
413 //open ChineseTranslationDialog
414 Reference< XComponentContext > xContext(
415 ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
416 if(xContext.is())
418 Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
419 if(xMCF.is())
421 Reference< ui::dialogs::XExecutableDialog > xDialog(
422 xMCF->createInstanceWithContext(
423 rtl::OUString::createFromAscii("com.sun.star.linguistic2.ChineseTranslationDialog")
424 , xContext), UNO_QUERY);
425 Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY );
426 if( xInit.is() )
428 // initialize dialog
429 Reference< awt::XWindow > xDialogParentWindow(0);
430 Sequence<Any> aSeq(1);
431 Any* pArray = aSeq.getArray();
432 PropertyValue aParam;
433 aParam.Name = rtl::OUString::createFromAscii("ParentWindow");
434 aParam.Value <<= makeAny(xDialogParentWindow);
435 pArray[0] <<= makeAny(aParam);
436 xInit->initialize( aSeq );
438 //execute dialog
439 sal_Int16 nDialogRet = xDialog->execute();
440 if( RET_OK == nDialogRet )
442 //get some parameters from the dialog
443 sal_Bool bToSimplified = sal_True;
444 sal_Bool bUseVariants = sal_True;
445 sal_Bool bCommonTerms = sal_True;
446 Reference< beans::XPropertySet > xProp( xDialog, UNO_QUERY );
447 if( xProp.is() )
451 xProp->getPropertyValue( C2U("IsDirectionToSimplified") ) >>= bToSimplified;
452 xProp->getPropertyValue( C2U("IsUseCharacterVariants") ) >>= bUseVariants;
453 xProp->getPropertyValue( C2U("IsTranslateCommonTerms") ) >>= bCommonTerms;
455 catch( Exception& )
460 //execute translation
461 sal_Int16 nSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
462 sal_Int16 nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
463 sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
464 if( !bCommonTerms )
465 nOptions = nOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
467 Font aTargetFont = pOLV->GetWindow()->GetDefaultFont( DEFAULTFONT_CJK_TEXT,
468 nTargetLang, DEFAULTFONT_FLAGS_ONLYONE );
470 pOLV->StartTextConversion( nSourceLang, nTargetLang, &aTargetFont, nOptions, sal_False, sal_False );
473 Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY );
474 if( xComponent.is() )
475 xComponent->dispose();
479 break;
481 default:
482 ASSERT(!this, "unexpected slot-id");
487 /*--------------------------------------------------------------------
488 Beschreibung:
489 --------------------------------------------------------------------*/
490 void SwDrawTextShell::ExecDraw(SfxRequest &rReq)
492 SwWrtShell &rSh = GetShell();
493 pSdrView = rSh.GetDrawView();
494 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
496 switch (rReq.GetSlot())
498 case FN_INSERT_SOFT_HYPHEN:
499 case FN_INSERT_HARDHYPHEN:
500 case FN_INSERT_HARD_SPACE:
501 case SID_INSERT_RLM :
502 case SID_INSERT_LRM :
503 case SID_INSERT_ZWNBSP :
504 case SID_INSERT_ZWSP:
506 sal_Unicode cIns = 0;
507 switch(rReq.GetSlot())
509 case FN_INSERT_SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break;
510 case FN_INSERT_HARDHYPHEN: cIns = CHAR_HARDHYPHEN; break;
511 case FN_INSERT_HARD_SPACE: cIns = CHAR_HARDBLANK; break;
512 case SID_INSERT_RLM : cIns = CHAR_RLM ; break;
513 case SID_INSERT_LRM : cIns = CHAR_LRM ; break;
514 case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break;
515 case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break;
517 pOLV->InsertText( String(cIns), TRUE );
518 rReq.Done();
520 break;
521 case SID_CHARMAP:
522 { // Sonderzeichen einfuegen
523 InsertSymbol(rReq);
524 break;
526 case FN_INSERT_STRING:
528 const SfxItemSet *pNewAttrs = rReq.GetArgs();
529 sal_uInt16 nSlot = rReq.GetSlot();
530 const SfxPoolItem* pItem = 0;
531 if(pNewAttrs)
533 pNewAttrs->GetItemState(nSlot, FALSE, &pItem );
534 pOLV->InsertText(((const SfxStringItem *)pItem)->GetValue());
536 break;
539 case SID_SELECTALL:
541 SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
542 if(pOutliner)
544 ULONG nParaCount = pOutliner->GetParagraphCount();
545 if (nParaCount > 0)
546 pOLV->SelectRange(0L, USHORT(nParaCount) );
549 break;
551 case FN_FORMAT_RESET: // delete hard text attributes
553 pOLV->RemoveAttribsKeepLanguages( true );
554 pOLV->GetEditView().GetEditEngine()->RemoveFields(TRUE);
555 rReq.Done();
557 break;
559 case FN_ESCAPE:
560 if (pSdrView->IsTextEdit())
562 // Shellwechsel!
563 rSh.EndTextEdit();
564 SwView& rTempView = rSh.GetView();
565 rTempView.ExitDraw();
566 rSh.Edit();
567 rTempView.AttrChangedNotify(&rSh);
568 return;
570 break;
571 case FN_DRAWTEXT_ATTR_DLG:
573 SfxItemSet aNewAttr( pSdrView->GetModel()->GetItemPool() );
574 pSdrView->GetAttributes( aNewAttr );
575 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
576 if ( pFact )
578 SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog(
579 &(GetView().GetViewFrame()->GetWindow()),
580 &aNewAttr, RID_SVXDLG_TEXT, pSdrView );
581 USHORT nResult = pDlg->Execute();
583 if (nResult == RET_OK)
585 if (pSdrView->AreObjectsMarked())
587 pSdrView->SetAttributes(*pDlg->GetOutputItemSet());
588 rReq.Done(*(pDlg->GetOutputItemSet()));
592 delete( pDlg );
595 break;
597 default:
598 ASSERT(!this, "unexpected slot-id");
599 return;
602 GetView().GetViewFrame()->GetBindings().InvalidateAll(FALSE);
604 if (IsTextEdit() && pOLV->GetOutliner()->IsModified())
605 rSh.SetModified();
608 /*--------------------------------------------------------------------
609 Beschreibung: Undo ausfuehren
610 --------------------------------------------------------------------*/
614 void SwDrawTextShell::ExecUndo(SfxRequest &rReq)
616 if( IsTextEdit() )
618 BOOL bCallBase = TRUE;
619 const SfxItemSet* pArgs = rReq.GetArgs();
620 if( pArgs )
622 USHORT nId = rReq.GetSlot(), nCnt = 1;
623 const SfxPoolItem* pItem;
624 switch( nId )
626 case SID_UNDO:
627 case SID_REDO:
628 if( SFX_ITEM_SET == pArgs->GetItemState( nId, FALSE, &pItem ) &&
629 1 < (nCnt = ((SfxUInt16Item*)pItem)->GetValue()) )
631 // then we make by ourself.
632 SfxUndoManager* pUndoManager = GetUndoManager();
633 if( pUndoManager )
635 if( SID_UNDO == nId )
636 while( nCnt-- )
637 pUndoManager->Undo(0);
638 else
639 while( nCnt-- )
640 pUndoManager->Redo(0);
642 bCallBase = FALSE;
644 break;
647 if( bCallBase )
649 SfxViewFrame *pSfxViewFrame = GetView().GetViewFrame();
650 pSfxViewFrame->ExecuteSlot(rReq, pSfxViewFrame->GetInterface());
655 /*--------------------------------------------------------------------
656 Beschreibung: Zustand Undo
657 --------------------------------------------------------------------*/
661 void SwDrawTextShell::StateUndo(SfxItemSet &rSet)
663 if ( !IsTextEdit() )
664 return;
666 SfxViewFrame *pSfxViewFrame = GetView().GetViewFrame();
667 SfxWhichIter aIter(rSet);
668 USHORT nWhich = aIter.FirstWhich();
669 while( nWhich )
671 switch ( nWhich )
673 case SID_GETUNDOSTRINGS:
674 case SID_GETREDOSTRINGS:
676 SfxUndoManager* pUndoManager = GetUndoManager();
677 if( pUndoManager )
679 UniString (SfxUndoManager:: *fnGetComment)( USHORT ) const;
681 sal_uInt16 nCount;
682 if( SID_GETUNDOSTRINGS == nWhich )
684 nCount = pUndoManager->GetUndoActionCount();
685 fnGetComment = &SfxUndoManager::GetUndoActionComment;
687 else
689 nCount = pUndoManager->GetRedoActionCount();
690 fnGetComment = &SfxUndoManager::GetRedoActionComment;
692 if( nCount )
694 String sList;
695 for( sal_uInt16 n = 0; n < nCount; ++n )
696 ( sList += (pUndoManager->*fnGetComment)( n ) )
697 += '\n';
699 SfxStringListItem aItem( nWhich );
700 aItem.SetString( sList );
701 rSet.Put( aItem );
704 else
705 rSet.DisableItem( nWhich );
707 break;
709 default:
710 pSfxViewFrame->GetSlotState( nWhich,
711 pSfxViewFrame->GetInterface(), &rSet );
714 nWhich = aIter.NextWhich();
718 void SwDrawTextShell::ExecTransliteration( SfxRequest & rReq )
720 using namespace i18n;
722 sal_uInt32 nMode = 0;
724 switch( rReq.GetSlot() )
726 case SID_TRANSLITERATE_UPPER:
727 nMode = TransliterationModules_LOWERCASE_UPPERCASE;
728 break;
729 case SID_TRANSLITERATE_LOWER:
730 nMode = TransliterationModules_UPPERCASE_LOWERCASE;
731 break;
733 case SID_TRANSLITERATE_HALFWIDTH:
734 nMode = TransliterationModules_FULLWIDTH_HALFWIDTH;
735 break;
736 case SID_TRANSLITERATE_FULLWIDTH:
737 nMode = TransliterationModules_HALFWIDTH_FULLWIDTH;
738 break;
740 case SID_TRANSLITERATE_HIRAGANA:
741 nMode = TransliterationModules_KATAKANA_HIRAGANA;
742 break;
743 case SID_TRANSLITERATE_KATAGANA:
744 nMode = TransliterationModules_HIRAGANA_KATAKANA;
745 break;
747 default:
748 ASSERT(!this, "falscher Dispatcher");
751 if( nMode )
753 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
754 pOLV->TransliterateText( nMode );
759 /*--------------------------------------------------------------------
760 Beschreibung: Sonderzeichen einfuegen (siehe SDraw: FUBULLET.CXX)
761 --------------------------------------------------------------------*/
763 void SwDrawTextShell::InsertSymbol(SfxRequest& rReq)
765 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
766 if(!pOLV)
767 return;
768 const SfxItemSet *pArgs = rReq.GetArgs();
769 const SfxPoolItem* pItem = 0;
770 if( pArgs )
771 pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), FALSE, &pItem);
773 String sSym;
774 String sFontName;
775 if ( pItem )
777 sSym = ((const SfxStringItem*)pItem)->GetValue();
778 const SfxPoolItem* pFtItem = NULL;
779 pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), FALSE, &pFtItem);
780 const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
781 if ( pFontItem )
782 sFontName = pFontItem->GetValue();
785 SfxItemSet aSet(pOLV->GetAttribs());
786 USHORT nScript = pOLV->GetSelectedScriptType();
787 SvxFontItem aSetDlgFont( RES_CHRATR_FONT );
789 SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() );
790 aSetItem.GetItemSet().Put( aSet, FALSE );
791 const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript );
792 if( pI )
793 aSetDlgFont = *(SvxFontItem*)pI;
794 else
795 aSetDlgFont = (SvxFontItem&)aSet.Get( GetWhichOfScript(
796 SID_ATTR_CHAR_FONT,
797 GetI18NScriptTypeOfLanguage( (USHORT)GetAppLanguage() ) ));
798 if (!sFontName.Len())
799 sFontName = aSetDlgFont.GetFamilyName();
802 Font aFont(sFontName, Size(1,1));
803 if(!sSym.Len())
805 SfxAllItemSet aAllSet( GetPool() );
806 aAllSet.Put( SfxBoolItem( FN_PARAM_1, FALSE ) );
808 SwViewOption aOpt(*rView.GetWrtShell().GetViewOptions());
809 String sSymbolFont = aOpt.GetSymbolFont();
810 if( sSymbolFont.Len() )
811 aAllSet.Put( SfxStringItem( SID_FONT_NAME, sSymbolFont ) );
812 else
813 aAllSet.Put( SfxStringItem( SID_FONT_NAME, aSetDlgFont.GetFamilyName() ) );
815 // Wenn Zeichen selektiert ist kann es angezeigt werden
816 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
817 SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( rView.GetWindow(), aAllSet,
818 rView.GetViewFrame()->GetFrame()->GetFrameInterface(), RID_SVXDLG_CHARMAP );
819 USHORT nResult = pDlg->Execute();
820 if( nResult == RET_OK )
822 SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pCItem, SfxStringItem, SID_CHARMAP, FALSE );
823 SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, FALSE );
824 if ( pFontItem )
826 aFont.SetName( pFontItem->GetFamilyName() );
827 aFont.SetStyleName( pFontItem->GetStyleName() );
828 aFont.SetCharSet( pFontItem->GetCharSet() );
829 aFont.SetPitch( pFontItem->GetPitch() );
832 if ( pCItem )
834 sSym = pCItem->GetValue();
835 aOpt.SetSymbolFont(aFont.GetName());
836 SW_MOD()->ApplyUsrPref(aOpt, &rView);
840 delete( pDlg );
843 if( sSym.Len() )
845 // nicht flackern
846 pOLV->HideCursor();
847 SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
848 pOutliner->SetUpdateMode(FALSE);
850 SfxItemSet aOldSet( pOLV->GetAttribs() );
851 SfxItemSet aFontSet( *aOldSet.GetPool(),
852 EE_CHAR_FONTINFO, EE_CHAR_FONTINFO,
853 EE_CHAR_FONTINFO_CJK, EE_CHAR_FONTINFO_CJK,
854 EE_CHAR_FONTINFO_CTL, EE_CHAR_FONTINFO_CTL,
855 0 );
856 aFontSet.Set( aOldSet );
858 // String einfuegen
859 pOLV->InsertText( sSym, TRUE );
861 // attributieren (Font setzen)
862 SfxItemSet aFontAttribSet( *aFontSet.GetPool(), aFontSet.GetRanges() );
863 SvxFontItem aFontItem (aFont.GetFamily(), aFont.GetName(),
864 aFont.GetStyleName(), aFont.GetPitch(),
865 aFont.GetCharSet(),
866 EE_CHAR_FONTINFO );
867 nScript = pBreakIt->GetAllScriptsOfText( sSym );
868 if( SCRIPTTYPE_LATIN & nScript )
869 aFontAttribSet.Put( aFontItem, EE_CHAR_FONTINFO );
870 if( SCRIPTTYPE_ASIAN & nScript )
871 aFontAttribSet.Put( aFontItem, EE_CHAR_FONTINFO_CJK );
872 if( SCRIPTTYPE_COMPLEX & nScript )
873 aFontAttribSet.Put( aFontItem, EE_CHAR_FONTINFO_CTL );
874 pOLV->SetAttribs(aFontAttribSet);
876 // Selektion loeschen
877 ESelection aSel(pOLV->GetSelection());
878 aSel.nStartPara = aSel.nEndPara;
879 aSel.nStartPos = aSel.nEndPos;
880 pOLV->SetSelection(aSel);
882 // Alten Font restaurieren
883 pOLV->SetAttribs( aFontSet );
885 // ab jetzt wieder anzeigen
886 pOutliner->SetUpdateMode(TRUE);
887 pOLV->ShowCursor();
889 rReq.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP), sSym ) );
890 if(aFont.GetName().Len())
891 rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR, aFont.GetName() ) );
892 rReq.Done();
895 /*-- 22.10.2003 14:26:32---------------------------------------------------
897 -----------------------------------------------------------------------*/
898 SfxUndoManager* SwDrawTextShell::GetUndoManager()
900 SwWrtShell &rSh = GetShell();
901 pSdrView = rSh.GetDrawView();
902 SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
903 pOutliner = pSdrView->GetTextEditOutliner();
904 return &pOutliner->GetUndoManager();