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