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