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