xref: /aoo41x/main/sc/source/ui/view/editsh.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sc.hxx"
30 
31 
32 
33 //------------------------------------------------------------------
34 
35 #include <com/sun/star/linguistic2/XThesaurus.hpp>
36 
37 #include "scitems.hxx"
38 #include <editeng/eeitem.hxx>
39 
40 #include <svx/clipfmtitem.hxx>
41 #include <svx/svxdlg.hxx>
42 #include <editeng/cntritem.hxx>
43 #include <editeng/outliner.hxx>
44 #include <editeng/unolingu.hxx>
45 #include <editeng/crsditem.hxx>
46 #include <editeng/editeng.hxx>
47 #include <editeng/editview.hxx>
48 #include <editeng/escpitem.hxx>
49 #include <editeng/flditem.hxx>
50 #include <editeng/fontitem.hxx>
51 #include <svx/hlnkitem.hxx>
52 #include <editeng/postitem.hxx>
53 #include <editeng/scripttypeitem.hxx>
54 #include <editeng/shdditem.hxx>
55 #include <svl/srchitem.hxx>
56 #include <editeng/udlnitem.hxx>
57 #include <editeng/wghtitem.hxx>
58 #include <sfx2/basedlgs.hxx>
59 #include <sfx2/bindings.hxx>
60 #include <sfx2/msg.hxx>
61 #include <sfx2/objface.hxx>
62 #include <sfx2/objsh.hxx>
63 #include <sfx2/request.hxx>
64 #include <sfx2/viewfrm.hxx>
65 #include <sot/exchange.hxx>
66 #include <svtools/cliplistener.hxx>
67 #include <svl/whiter.hxx>
68 #include <vcl/msgbox.hxx>
69 #include <vcl/sound.hxx>
70 #include <sot/formats.hxx>
71 #include <svtools/transfer.hxx>
72 #include <svl/stritem.hxx>
73 
74 #define _EDITSH_CXX
75 #include "editsh.hxx"
76 
77 #include "scresid.hxx"
78 #include "global.hxx"
79 #include "sc.hrc"
80 #include "scmod.hxx"
81 #include "inputhdl.hxx"
82 #include "viewutil.hxx"
83 #include "viewdata.hxx"
84 #include "document.hxx"
85 //CHINA001 #include "namepast.hxx"
86 #include "reffind.hxx"
87 #include "tabvwsh.hxx"
88 //CHINA001 #include "textdlgs.hxx"
89 #include "editutil.hxx"
90 #include "globstr.hrc"
91 
92 #define ScEditShell
93 #include "scslots.hxx"
94 
95 #include "scui_def.hxx" //CHINA001
96 #include "scabstdlg.hxx" //CHINA001
97 
98 
99 using namespace ::com::sun::star;
100 
101 
102 TYPEINIT1( ScEditShell, SfxShell );
103 
104 SFX_IMPL_INTERFACE(ScEditShell, SfxShell, ScResId(SCSTR_EDITSHELL))
105 {
106 	SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_EDIT) );
107 }
108 
109 
110 ScEditShell::ScEditShell(EditView* pView, ScViewData* pData) :
111 	pEditView		(pView),
112 	pViewData		(pData),
113 	pClipEvtLstnr	(NULL),
114 	bPastePossible	(sal_False),
115 	bIsInsertMode	(sal_True)
116 {
117 	SetPool( pEditView->GetEditEngine()->GetEmptyItemSet().GetPool() );
118 	SetUndoManager( &pEditView->GetEditEngine()->GetUndoManager() );
119 	SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("EditCell")));
120 }
121 
122 ScEditShell::~ScEditShell()
123 {
124 	if ( pClipEvtLstnr )
125 	{
126 		pClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), sal_False );
127 
128         //  #122057# The listener may just now be waiting for the SolarMutex and call the link
129         //  afterwards, in spite of RemoveListener. So the link has to be reset, too.
130         pClipEvtLstnr->ClearCallbackLink();
131 
132 		pClipEvtLstnr->release();
133 	}
134 }
135 
136 ScInputHandler* ScEditShell::GetMyInputHdl()
137 {
138 	return SC_MOD()->GetInputHdl( pViewData->GetViewShell() );
139 }
140 
141 void ScEditShell::SetEditView(EditView* pView)
142 {
143 	pEditView = pView;
144 	pEditView->SetInsertMode( bIsInsertMode );
145 	SetPool( pEditView->GetEditEngine()->GetEmptyItemSet().GetPool() );
146 	SetUndoManager( &pEditView->GetEditEngine()->GetUndoManager() );
147 }
148 
149 void lcl_RemoveAttribs( EditView& rEditView )
150 {
151 	ScEditEngineDefaulter* pEngine = static_cast<ScEditEngineDefaulter*>(rEditView.GetEditEngine());
152 
153 	sal_Bool bOld = pEngine->GetUpdateMode();
154 	pEngine->SetUpdateMode(sal_False);
155 
156 	String aName = ScGlobal::GetRscString( STR_UNDO_DELETECONTENTS );
157 	pEngine->GetUndoManager().EnterListAction( aName, aName );
158 
159 	rEditView.RemoveAttribs(sal_True);
160 	pEngine->RepeatDefaults();		// #97226# paragraph attributes from cell formats must be preserved
161 
162 	pEngine->GetUndoManager().LeaveListAction();
163 
164 	pEngine->SetUpdateMode(bOld);
165 }
166 
167 void lclInsertCharacter( EditView* pTableView, EditView* pTopView, sal_Unicode cChar )
168 {
169     String aString( cChar );
170     if( pTableView )
171         pTableView->InsertText( aString );
172     if( pTopView )
173         pTopView->InsertText( aString );
174 }
175 
176 void ScEditShell::Execute( SfxRequest& rReq )
177 {
178 	const SfxItemSet*	pReqArgs	= rReq.GetArgs();
179 	sal_uInt16				nSlot		= rReq.GetSlot();
180 	SfxBindings&		rBindings	= pViewData->GetBindings();
181 
182 	ScInputHandler* pHdl = GetMyInputHdl();
183 	DBG_ASSERT(pHdl,"kein ScInputHandler");
184 
185 	EditView* pTopView	 = pHdl->GetTopView();		// hat Eingabezeile den Focus?
186 	EditView* pTableView = pHdl->GetTableView();
187 
188 	DBG_ASSERT(pTableView,"no EditView :-(");
189     /* #i91683# No EditView if spell-check dialog is active and positioned on
190      * an error and user immediately (without double click or F2) selected a
191      * text portion of that cell with the mouse and wanted to modify it. */
192     /* FIXME: Bailing out only cures the symptom and prevents a crash, no edit
193      * action is possible. A real fix somehow would need to create a valid
194      * EditView from the spell-check view. */
195     if (!pTableView)
196         return;
197 
198 	EditEngine* pEngine = pTableView->GetEditEngine();
199 
200 	pHdl->DataChanging();
201 	sal_Bool bSetSelIsRef = sal_False;
202     sal_Bool bSetModified = sal_True;
203 
204 	switch ( nSlot )
205 	{
206 		case FID_INS_CELL_CONTENTS: // Insert-Taste, weil als Acc definiert
207 			bIsInsertMode = !pTableView->IsInsertMode();
208 			pTableView->SetInsertMode( bIsInsertMode );
209 			if (pTopView)
210 				pTopView->SetInsertMode( bIsInsertMode );
211 			rBindings.Invalidate( SID_ATTR_INSERT );
212 			break;
213 
214 		case SID_ATTR_INSERT:
215 			if ( pReqArgs )
216 			{
217 				bIsInsertMode = ((const SfxBoolItem&)pReqArgs->Get(nSlot)).GetValue();
218 				pTableView->SetInsertMode( bIsInsertMode );
219 				if (pTopView)
220 					pTopView->SetInsertMode( bIsInsertMode );
221 				rBindings.Invalidate( SID_ATTR_INSERT );
222 			}
223 			break;
224 
225         case SID_THES:
226             {
227                 String aReplaceText;
228                 SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES , sal_False );
229                 if (pItem2)
230                     aReplaceText = pItem2->GetValue();
231                 if (aReplaceText.Len() > 0)
232                     ReplaceTextWithSynonym( *pEditView, aReplaceText );
233             }
234             break;
235 
236 		case SID_COPY:
237 			pTableView->Copy();
238             bSetModified = sal_False;
239 			break;
240 
241 		case SID_CUT:
242 			pTableView->Cut();
243 			if (pTopView)
244 				pTopView->DeleteSelected();
245 			break;
246 
247 		case SID_PASTE:
248 			pTableView->PasteSpecial();
249 			if (pTopView)
250 				pTopView->Paste();
251 			break;
252 
253 		case SID_DELETE:
254 			pTableView->DeleteSelected();
255 			if (pTopView)
256 				pTopView->DeleteSelected();
257 			break;
258 
259 		case SID_CELL_FORMAT_RESET:					// "Standard"
260 			lcl_RemoveAttribs( *pTableView );
261 			if ( pTopView )
262 				lcl_RemoveAttribs( *pTopView );
263 			break;
264 
265 		case SID_CLIPBOARD_FORMAT_ITEMS:
266 			{
267 				sal_uLong nFormat = 0;
268 				const SfxPoolItem* pItem;
269 				if ( pReqArgs &&
270 					 pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET &&
271 					 pItem->ISA(SfxUInt32Item) )
272 				{
273 					nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
274 				}
275 
276 				if ( nFormat )
277 				{
278 					if (SOT_FORMAT_STRING == nFormat)
279 						pTableView->Paste();
280 					else
281 						pTableView->PasteSpecial();
282 
283 					if (pTopView)
284 						pTopView->Paste();
285 				}
286 			}
287 			break;
288 
289         case SID_PASTE_SPECIAL:
290 			{
291                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
292                 SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( pViewData->GetDialogParent() );
293                 sal_uLong nFormat = 0;
294                 if ( pDlg )
295                 {
296                     pDlg->Insert( SOT_FORMAT_STRING, EMPTY_STRING );
297                     pDlg->Insert( SOT_FORMAT_RTF,    EMPTY_STRING );
298 
299                     TransferableDataHelper aDataHelper(
300                         TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
301 
302                     nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() );
303                     DELETEZ(pDlg);
304                 }
305 
306 				// while the dialog was open, edit mode may have been stopped
307 				if (!SC_MOD()->IsInputMode())
308 				{
309 					Sound::Beep();
310 					return;
311 				}
312 
313 				if (nFormat > 0)
314 				{
315 					if (SOT_FORMAT_STRING == nFormat)
316 						pTableView->Paste();
317 					else
318 						pTableView->PasteSpecial();
319 
320 					if (pTopView)
321 						pTopView->Paste();
322 				}
323 
324 				if (pTopView)
325 					pTopView->GetWindow()->GrabFocus();
326 			}
327 			break;
328 
329 		case SID_SELECTALL:
330 			{
331 				sal_uInt16 nPar = pEngine->GetParagraphCount();
332 				if (nPar)
333 				{
334 					xub_StrLen nLen = pEngine->GetTextLen(nPar-1);
335 					pTableView->SetSelection(ESelection(0,0,nPar-1,nLen));
336 					if (pTopView)
337 						pTopView->SetSelection(ESelection(0,0,nPar-1,nLen));
338 				}
339                 bSetModified = sal_False;
340 			}
341 			break;
342 
343 		case SID_CHARMAP:
344 			{
345 				sal_uInt16 nScript = pTableView->GetSelectedScriptType();
346 				sal_uInt16 nFontWhich = ( nScript == SCRIPTTYPE_ASIAN ) ? EE_CHAR_FONTINFO_CJK :
347 								( ( nScript == SCRIPTTYPE_COMPLEX ) ? EE_CHAR_FONTINFO_CTL :
348 																		EE_CHAR_FONTINFO );
349 				const SvxFontItem& rItem = (const SvxFontItem&)
350 							pTableView->GetAttribs().Get(nFontWhich);
351 
352 				String aString;
353 				SvxFontItem aNewItem( EE_CHAR_FONTINFO );
354 
355 				const SfxItemSet *pArgs = rReq.GetArgs();
356 				const SfxPoolItem* pItem = 0;
357 				if( pArgs )
358 					pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), sal_False, &pItem);
359 
360 				if ( pItem )
361 				{
362 					aString = ((const SfxStringItem*)pItem)->GetValue();
363 					const SfxPoolItem* pFtItem = NULL;
364 					pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), sal_False, &pFtItem);
365 					const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
366 					if ( pFontItem )
367 					{
368 						String aFontName(pFontItem->GetValue());
369 					    Font aFont(aFontName, Size(1,1)); // Size nur wg. CTOR
370 						aNewItem = SvxFontItem( aFont.GetFamily(), aFont.GetName(),
371 									aFont.GetStyleName(), aFont.GetPitch(),
372                                     aFont.GetCharSet(), ATTR_FONT  );
373 					}
374 					else
375 						aNewItem = rItem;
376 				}
377 				else
378 				{
379                     ScViewUtil::ExecuteCharMap( rItem, *pViewData->GetViewShell()->GetViewFrame(), aNewItem, aString );
380 
381 					// while the dialog was open, edit mode may have been stopped
382 					if (!SC_MOD()->IsInputMode())
383 					{
384 						Sound::Beep();
385 						return;
386 					}
387 				}
388 
389 				if ( aString.Len() )
390 				{
391 					//	if string contains WEAK characters, set all fonts
392 					sal_uInt8 nSetScript;
393 					ScDocument* pDoc = pViewData->GetDocument();
394 					if ( pDoc->HasStringWeakCharacters( aString ) )
395 						nSetScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
396 					else
397 						nSetScript = pDoc->GetStringScriptType( aString );
398 
399 					SfxItemSet aSet( pTableView->GetEmptyItemSet() );
400 					SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, GetPool() );
401 					aSetItem.PutItemForScriptType( nSetScript, aNewItem );
402 					aSet.Put( aSetItem.GetItemSet(), sal_False );
403 
404 					//	SetAttribs an der View selektiert ein Wort, wenn nichts selektiert ist
405 					pTableView->GetEditEngine()->QuickSetAttribs( aSet, pTableView->GetSelection() );
406 					pTableView->InsertText(aString);
407 					if (pTopView)
408 						pTopView->InsertText(aString);
409 
410 					SfxStringItem aStringItem( SID_CHARMAP, aString );
411 					SfxStringItem aFontItem( SID_ATTR_SPECIALCHAR, aNewItem.GetFamilyName() );
412 					rReq.AppendItem( aFontItem );
413 					rReq.AppendItem( aStringItem );
414 					rReq.Done();
415 
416 
417 				}
418 
419 				if (pTopView)
420 					pTopView->GetWindow()->GrabFocus();
421 			}
422 			break;
423 
424 		case FID_INSERT_NAME:
425 			{
426 				ScDocument*		pDoc = pViewData->GetDocument();
427 				//CHINA001 ScNamePasteDlg* pDlg = new ScNamePasteDlg( pViewData->GetDialogParent(),
428 				//CHINA001 								pDoc->GetRangeName(), sal_False );
429 												// "Liste" disablen
430 				ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
431 				DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
432 
433 				AbstractScNamePasteDlg* pDlg = pFact->CreateScNamePasteDlg( pViewData->GetDialogParent(), pDoc->GetRangeName(), RID_SCDLG_NAMES_PASTE, sal_False );
434 				DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
435 				short nRet = pDlg->Execute();
436 				// pDlg is needed below
437 
438 				// while the dialog was open, edit mode may have been stopped
439 				if (!SC_MOD()->IsInputMode())
440 				{
441 					Sound::Beep();
442 					delete pDlg;
443 					return;
444 				}
445 
446 				if ( nRet == BTN_PASTE_NAME )
447 				{
448 					String aName = pDlg->GetSelectedName();
449 					pTableView->InsertText(aName);
450 					if (pTopView)
451 						pTopView->InsertText(aName);
452 				}
453 				delete pDlg;
454 
455 				if (pTopView)
456 					pTopView->GetWindow()->GrabFocus();
457 			}
458 			break;
459 
460 		case SID_CHAR_DLG:
461 			{
462 				SfxItemSet aAttrs( pTableView->GetAttribs() );
463 
464 				SfxObjectShell* pObjSh = pViewData->GetSfxDocShell();
465 
466 				//CHINA001 ScCharDlg* pDlg = new ScCharDlg( pViewData->GetDialogParent(), &aAttrs, pObjSh );
467 				ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
468 				DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
469 
470 				SfxAbstractTabDialog* pDlg = pFact->CreateScCharDlg( pViewData->GetDialogParent(), &aAttrs,
471 																	 pObjSh, RID_SCDLG_CHAR );
472 				DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
473 				short nRet = pDlg->Execute();
474 				// pDlg is needed below
475 
476 				// while the dialog was open, edit mode may have been stopped
477 				if (!SC_MOD()->IsInputMode())
478 				{
479 					Sound::Beep();
480 					delete pDlg;
481 					return;
482 				}
483 
484 				if ( nRet == RET_OK )
485 				{
486 					const SfxItemSet* pOut = pDlg->GetOutputItemSet();
487 					pTableView->SetAttribs( *pOut );
488 				}
489 				delete pDlg;
490 			}
491 			break;
492 
493 		case SID_TOGGLE_REL:
494 			{
495 				sal_Bool bOk = sal_False;
496 				if (pEngine->GetParagraphCount() == 1)
497 				{
498 					String aText = pEngine->GetText();
499 					ESelection aSel = pEditView->GetSelection();	// aktuelle View
500 
501 					ScRefFinder aFinder( aText, pViewData->GetDocument() );
502 					aFinder.ToggleRel( aSel.nStartPos, aSel.nEndPos );
503 					if (aFinder.GetFound())
504 					{
505 						String aNew = aFinder.GetText();
506 						ESelection aNewSel( 0,aFinder.GetSelStart(), 0,aFinder.GetSelEnd() );
507 						pEngine->SetText( aNew );
508 						pTableView->SetSelection( aNewSel );
509 						if ( pTopView )
510 						{
511 							pTopView->GetEditEngine()->SetText( aNew );
512 							pTopView->SetSelection( aNewSel );
513 						}
514 						bOk = sal_True;
515 
516 						//	Referenz wird selektiert -> beim Tippen nicht ueberschreiben
517 						bSetSelIsRef = sal_True;
518 					}
519 				}
520 				if (!bOk)
521                     Sound::Beep();              // keine Referenzen oder mehrere Absaetze
522 			}
523 			break;
524 
525 		case SID_HYPERLINK_SETLINK:
526 			if( pReqArgs )
527 			{
528 				const SfxPoolItem* pItem;
529 				if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, sal_True, &pItem ) == SFX_ITEM_SET )
530 				{
531 					const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem;
532 					const String& rName		= pHyper->GetName();
533 					const String& rURL		= pHyper->GetURL();
534 					const String& rTarget	= pHyper->GetTargetFrame();
535 					SvxLinkInsertMode eMode = pHyper->GetInsertMode();
536 
537 					sal_Bool bDone = sal_False;
538 					if ( eMode == HLINK_DEFAULT || eMode == HLINK_FIELD )
539 					{
540 						const SvxURLField* pURLField = GetURLField();
541 						if ( pURLField )
542 						{
543 							//	altes Feld selektieren
544 
545 							ESelection aSel = pTableView->GetSelection();
546 							aSel.Adjust();
547 							aSel.nEndPara = aSel.nStartPara;
548 							aSel.nEndPos = aSel.nStartPos + 1;
549 							pTableView->SetSelection( aSel );
550 
551 							//	neues Feld einfuegen
552 
553 							SvxURLField aURLField( rURL, rName, SVXURLFORMAT_REPR );
554 							aURLField.SetTargetFrame( rTarget );
555                             SvxFieldItem aURLItem( aURLField, EE_FEATURE_FIELD );
556 							pTableView->InsertField( aURLItem );
557 							pTableView->SetSelection( aSel );		// select inserted field
558 
559 							//	#57254# jetzt doch auch Felder in der Top-View
560 
561 							if ( pTopView )
562 							{
563 								aSel = pTopView->GetSelection();
564 								aSel.nEndPara = aSel.nStartPara;
565 								aSel.nEndPos = aSel.nStartPos + 1;
566 								pTopView->SetSelection( aSel );
567 								pTopView->InsertField( aURLItem );
568 								pTopView->SetSelection( aSel );		// select inserted field
569 							}
570 
571 							bDone = sal_True;
572 						}
573 					}
574 
575 					if (!bDone)
576 					{
577 						pViewData->GetViewShell()->
578 							InsertURL( rName, rURL, rTarget, (sal_uInt16) eMode );
579 
580 						//	InsertURL an der ViewShell schaltet bei "Button"
581 						//	die EditShell ab, darum sofort return
582 
583 						return;
584 					}
585 				}
586 			}
587 			break;
588 
589             case SID_OPEN_HYPERLINK:
590                 {
591                     const SvxURLField* pURLField = GetURLField();
592                     if ( pURLField )
593                         ScGlobal::OpenURL( pURLField->GetURL(), pURLField->GetTargetFrame() );
594                     return;
595                 }
596                 //break;
597 
598         case FN_INSERT_SOFT_HYPHEN:
599             lclInsertCharacter( pTableView, pTopView, CHAR_SHY );
600         break;
601         case FN_INSERT_HARDHYPHEN:
602             lclInsertCharacter( pTableView, pTopView, CHAR_NBHY );
603         break;
604         case FN_INSERT_HARD_SPACE:
605             lclInsertCharacter( pTableView, pTopView, CHAR_NBSP );
606         break;
607         case SID_INSERT_RLM:
608             lclInsertCharacter( pTableView, pTopView, CHAR_RLM );
609         break;
610         case SID_INSERT_LRM:
611             lclInsertCharacter( pTableView, pTopView, CHAR_LRM );
612         break;
613         case SID_INSERT_ZWSP:
614             lclInsertCharacter( pTableView, pTopView, CHAR_ZWSP );
615         break;
616         case SID_INSERT_ZWNBSP:
617             lclInsertCharacter( pTableView, pTopView, CHAR_ZWNBSP );
618         break;
619 	}
620 
621     pHdl->DataChanged(sal_False, bSetModified);
622 	if (bSetSelIsRef)
623 		pHdl->SetSelIsRef(sal_True);
624 }
625 
626 void lcl_DisableAll( SfxItemSet& rSet )    // disable all slots
627 {
628     SfxWhichIter aIter( rSet );
629     sal_uInt16 nWhich = aIter.FirstWhich();
630     while (nWhich)
631     {
632         rSet.DisableItem( nWhich );
633         nWhich = aIter.NextWhich();
634     }
635 }
636 
637 void __EXPORT ScEditShell::GetState( SfxItemSet& rSet )
638 {
639     // #125326# When deactivating the view, edit mode is stopped, but the EditShell is left active
640     // (a shell can't be removed from within Deactivate). In that state, the EditView isn't inserted
641     // into the EditEngine, so it can have an invalid selection and must not be used.
642     if ( !pViewData->HasEditView( pViewData->GetActivePart() ) )
643     {
644         lcl_DisableAll( rSet );
645         return;
646     }
647 
648 	ScInputHandler*	pHdl = GetMyInputHdl();
649 	EditView* pActiveView = pHdl ? pHdl->GetActiveView() : pEditView;
650 
651 	SfxWhichIter aIter( rSet );
652 	sal_uInt16 nWhich = aIter.FirstWhich();
653 	while (nWhich)
654 	{
655 		switch (nWhich)
656 		{
657 			case SID_ATTR_INSERT:	// Statuszeile
658 				{
659 					if ( pActiveView )
660 						rSet.Put( SfxBoolItem( nWhich, pActiveView->IsInsertMode() ) );
661 					else
662 						rSet.Put( SfxBoolItem( nWhich, 42 ) );
663 				}
664 				break;
665 
666 			case SID_HYPERLINK_GETLINK:
667 				{
668 					SvxHyperlinkItem aHLinkItem;
669 					const SvxURLField* pURLField = GetURLField();
670 					if ( pURLField )
671 					{
672 						aHLinkItem.SetName( pURLField->GetRepresentation() );
673 						aHLinkItem.SetURL( pURLField->GetURL() );
674 						aHLinkItem.SetTargetFrame( pURLField->GetTargetFrame() );
675 					}
676 					else if ( pActiveView )
677 					{
678 						// use selected text as name for urls
679 						String sReturn = pActiveView->GetSelected();
680 						sReturn.Erase(255);
681 						sReturn.EraseTrailingChars();
682 						aHLinkItem.SetName(sReturn);
683 					}
684 					rSet.Put(aHLinkItem);
685 				}
686 				break;
687 
688             case SID_OPEN_HYPERLINK:
689                 {
690                     if ( !GetURLField() )
691                         rSet.DisableItem( nWhich );
692                 }
693                 break;
694 
695 			case SID_TRANSLITERATE_HALFWIDTH:
696 			case SID_TRANSLITERATE_FULLWIDTH:
697 			case SID_TRANSLITERATE_HIRAGANA:
698 			case SID_TRANSLITERATE_KATAGANA:
699             case SID_INSERT_RLM:
700             case SID_INSERT_LRM:
701             case SID_INSERT_ZWNBSP:
702             case SID_INSERT_ZWSP:
703                 ScViewUtil::HideDisabledSlot( rSet, pViewData->GetBindings(), nWhich );
704             break;
705 
706             case SID_THES:
707                 {
708                     String          aStatusVal;
709                     LanguageType    nLang = LANGUAGE_NONE;
710                     bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, *pActiveView );
711                     rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
712 
713                     // disable thesaurus context menu entry if there is nothing to look up
714                     sal_Bool bCanDoThesaurus = ScModule::HasThesaurusLanguage( nLang );
715                     if (!bIsLookUpWord || !bCanDoThesaurus)
716                         rSet.DisableItem( SID_THES );
717                 }
718                 break;
719 
720 
721 		}
722 		nWhich = aIter.NextWhich();
723 	}
724 }
725 
726 const SvxURLField* ScEditShell::GetURLField()
727 {
728 	ScInputHandler*	pHdl = GetMyInputHdl();
729 	EditView* pActiveView = pHdl ? pHdl->GetActiveView() : pEditView;
730 	if ( pActiveView )
731 	{
732 		const SvxFieldItem*	pFieldItem = pActiveView->GetFieldAtSelection();
733 		if (pFieldItem)
734 		{
735 			const SvxFieldData* pField = pFieldItem->GetField();
736 			if ( pField && pField->ISA(SvxURLField) )
737 				return (const SvxURLField*)pField;
738 		}
739 	}
740 
741 	return NULL;
742 }
743 
744 IMPL_LINK( ScEditShell, ClipboardChanged, TransferableDataHelper*, pDataHelper )
745 {
746 	if ( pDataHelper )
747 	{
748 		bPastePossible = ( pDataHelper->HasFormat( SOT_FORMAT_STRING ) || pDataHelper->HasFormat( SOT_FORMAT_RTF ) );
749 
750 		SfxBindings& rBindings = pViewData->GetBindings();
751 		rBindings.Invalidate( SID_PASTE );
752         rBindings.Invalidate( SID_PASTE_SPECIAL );
753 		rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
754 	}
755 	return 0;
756 }
757 
758 void __EXPORT ScEditShell::GetClipState( SfxItemSet& rSet )
759 {
760 	if ( !pClipEvtLstnr )
761 	{
762 		// create listener
763 		pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScEditShell, ClipboardChanged ) );
764 		pClipEvtLstnr->acquire();
765 		Window* pWin = pViewData->GetActiveWin();
766 		pClipEvtLstnr->AddRemoveListener( pWin, sal_True );
767 
768 		// get initial state
769 		TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
770 		bPastePossible = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
771 	}
772 
773 	SfxWhichIter aIter( rSet );
774 	sal_uInt16 nWhich = aIter.FirstWhich();
775 	while (nWhich)
776 	{
777 		switch (nWhich)
778 		{
779 			case SID_PASTE:
780             case SID_PASTE_SPECIAL:
781 				if( !bPastePossible )
782 					rSet.DisableItem( nWhich );
783 				break;
784 			case SID_CLIPBOARD_FORMAT_ITEMS:
785 				if( bPastePossible )
786 				{
787 					SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
788 					TransferableDataHelper aDataHelper(
789 							TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
790 
791 					if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) )
792 						aFormats.AddClipbrdFormat( SOT_FORMAT_STRING );
793 					if ( aDataHelper.HasFormat( SOT_FORMAT_RTF ) )
794 						aFormats.AddClipbrdFormat( SOT_FORMAT_RTF );
795 
796 					rSet.Put( aFormats );
797 				}
798 				else
799 					rSet.DisableItem( nWhich );
800 				break;
801 		}
802 		nWhich = aIter.NextWhich();
803 	}
804 }
805 
806 void lcl_InvalidateUnder( SfxBindings& rBindings )
807 {
808 	rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
809 	rBindings.Invalidate( SID_ULINE_VAL_NONE );
810 	rBindings.Invalidate( SID_ULINE_VAL_SINGLE );
811 	rBindings.Invalidate( SID_ULINE_VAL_DOUBLE );
812 	rBindings.Invalidate( SID_ULINE_VAL_DOTTED );
813 }
814 
815 void ScEditShell::ExecuteAttr(SfxRequest& rReq)
816 {
817 	SfxItemSet			aSet( pEditView->GetEmptyItemSet() );
818 	SfxBindings&		rBindings	= pViewData->GetBindings();
819 	const SfxItemSet*	pArgs		= rReq.GetArgs();
820 	sal_uInt16				nSlot		= rReq.GetSlot();
821 
822 	switch ( nSlot )
823 	{
824 		case SID_ATTR_CHAR_FONTHEIGHT:
825 		case SID_ATTR_CHAR_FONT:
826 			{
827 				if (pArgs)
828 				{
829 					// #i78017 establish the same behaviour as in Writer
830 					sal_uInt16 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
831 					if (nSlot == SID_ATTR_CHAR_FONT)
832 					{
833 						nScript = pEditView->GetSelectedScriptType();
834 						if (nScript == 0) nScript = ScGlobal::GetDefaultScriptType();
835 					}
836 
837 					SfxItemPool& rPool = GetPool();
838 					SvxScriptSetItem aSetItem( nSlot, rPool );
839 					sal_uInt16 nWhich = rPool.GetWhich( nSlot );
840 					aSetItem.PutItemForScriptType( nScript, pArgs->Get( nWhich ) );
841 
842 					aSet.Put( aSetItem.GetItemSet(), sal_False );
843 				}
844 			}
845 			break;
846 
847 		case SID_ATTR_CHAR_COLOR:
848 			{
849 				if (pArgs)
850 				{
851 					aSet.Put( pArgs->Get( pArgs->GetPool()->GetWhich( nSlot ) ) );
852 					rBindings.Invalidate( nSlot );
853 				}
854 			}
855 			break;
856 
857 		//	Toggles
858 
859 		case SID_ATTR_CHAR_WEIGHT:
860 			{
861 				// #i78017 establish the same behaviour as in Writer
862 				sal_uInt16 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
863 
864 				SfxItemPool& rPool = GetPool();
865 
866 				sal_Bool bOld = sal_False;
867 				SvxScriptSetItem aOldSetItem( nSlot, rPool );
868 				aOldSetItem.GetItemSet().Put( pEditView->GetAttribs(), sal_False );
869 				const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
870 				if ( pCore && ((const SvxWeightItem*)pCore)->GetWeight() > WEIGHT_NORMAL )
871 					bOld = sal_True;
872 
873 				SvxScriptSetItem aSetItem( nSlot, rPool );
874 				aSetItem.PutItemForScriptType( nScript,
875 							SvxWeightItem( bOld ? WEIGHT_NORMAL : WEIGHT_BOLD, EE_CHAR_WEIGHT ) );
876 				aSet.Put( aSetItem.GetItemSet(), sal_False );
877 
878 				rBindings.Invalidate( nSlot );
879 			}
880 			break;
881 
882 		case SID_ATTR_CHAR_POSTURE:
883 			{
884 				// #i78017 establish the same behaviour as in Writer
885 				sal_uInt16 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
886 
887 				SfxItemPool& rPool = GetPool();
888 
889 				sal_Bool bOld = sal_False;
890 				SvxScriptSetItem aOldSetItem( nSlot, rPool );
891 				aOldSetItem.GetItemSet().Put( pEditView->GetAttribs(), sal_False );
892 				const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
893 				if ( pCore && ((const SvxPostureItem*)pCore)->GetValue() != ITALIC_NONE )
894 					bOld = sal_True;
895 
896 				SvxScriptSetItem aSetItem( nSlot, rPool );
897 				aSetItem.PutItemForScriptType( nScript,
898 							SvxPostureItem( bOld ? ITALIC_NONE : ITALIC_NORMAL, EE_CHAR_ITALIC ) );
899 				aSet.Put( aSetItem.GetItemSet(), sal_False );
900 
901 				rBindings.Invalidate( nSlot );
902 			}
903 			break;
904 
905 		case SID_ULINE_VAL_NONE:
906 			aSet.Put( SvxUnderlineItem( UNDERLINE_NONE, EE_CHAR_UNDERLINE ) );
907 			lcl_InvalidateUnder( rBindings );
908 			break;
909 
910 		case SID_ATTR_CHAR_UNDERLINE:	// Toggles
911 		case SID_ULINE_VAL_SINGLE:
912 		case SID_ULINE_VAL_DOUBLE:
913 		case SID_ULINE_VAL_DOTTED:
914 			{
915 				FontUnderline eOld = ((const SvxUnderlineItem&) pEditView->
916 									GetAttribs().Get(EE_CHAR_UNDERLINE)).GetLineStyle();
917 				FontUnderline eNew = eOld;
918 				switch (nSlot)
919 				{
920 					case SID_ATTR_CHAR_UNDERLINE:
921 						eNew = ( eOld != UNDERLINE_NONE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
922 						break;
923 					case SID_ULINE_VAL_SINGLE:
924 						eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
925 						break;
926 					case SID_ULINE_VAL_DOUBLE:
927 						eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE;
928 						break;
929 					case SID_ULINE_VAL_DOTTED:
930 						eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED;
931 						break;
932 				}
933 				aSet.Put( SvxUnderlineItem( eNew, EE_CHAR_UNDERLINE ) );
934 				lcl_InvalidateUnder( rBindings );
935 			}
936 			break;
937 
938 		case SID_ATTR_CHAR_OVERLINE:
939 			{
940 				FontUnderline eOld = ((const SvxOverlineItem&) pEditView->
941 									GetAttribs().Get(EE_CHAR_OVERLINE)).GetLineStyle();
942 				FontUnderline eNew = ( eOld != UNDERLINE_NONE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
943 				aSet.Put( SvxOverlineItem( eNew, EE_CHAR_OVERLINE ) );
944 				rBindings.Invalidate( nSlot );
945 			}
946 			break;
947 
948 		case SID_ATTR_CHAR_STRIKEOUT:
949 			{
950 				sal_Bool bOld = ((const SvxCrossedOutItem&)pEditView->GetAttribs().
951 								Get(EE_CHAR_STRIKEOUT)).GetValue() != STRIKEOUT_NONE;
952 				aSet.Put( SvxCrossedOutItem( bOld ? STRIKEOUT_NONE : STRIKEOUT_SINGLE, EE_CHAR_STRIKEOUT ) );
953 				rBindings.Invalidate( nSlot );
954 			}
955 			break;
956 
957 		case SID_ATTR_CHAR_SHADOWED:
958 			{
959 				sal_Bool bOld = ((const SvxShadowedItem&)pEditView->GetAttribs().
960 								Get(EE_CHAR_SHADOW)).GetValue();
961 				aSet.Put( SvxShadowedItem( !bOld, EE_CHAR_SHADOW ) );
962 				rBindings.Invalidate( nSlot );
963 			}
964 			break;
965 
966 		case SID_ATTR_CHAR_CONTOUR:
967 			{
968 				sal_Bool bOld = ((const SvxContourItem&)pEditView->GetAttribs().
969 								Get(EE_CHAR_OUTLINE)).GetValue();
970 				aSet.Put( SvxContourItem( !bOld, EE_CHAR_OUTLINE ) );
971 				rBindings.Invalidate( nSlot );
972 			}
973 			break;
974 
975 		case SID_SET_SUPER_SCRIPT:
976 			{
977 				SvxEscapement eOld = (SvxEscapement) ((const SvxEscapementItem&)
978 						pEditView->GetAttribs().Get(EE_CHAR_ESCAPEMENT)).GetEnumValue();
979 				SvxEscapement eNew = (eOld == SVX_ESCAPEMENT_SUPERSCRIPT) ?
980 										SVX_ESCAPEMENT_OFF : SVX_ESCAPEMENT_SUPERSCRIPT;
981 				aSet.Put( SvxEscapementItem( eNew, EE_CHAR_ESCAPEMENT ) );
982 				rBindings.Invalidate( nSlot );
983 			}
984 			break;
985 		case SID_SET_SUB_SCRIPT:
986 			{
987 				SvxEscapement eOld = (SvxEscapement) ((const SvxEscapementItem&)
988 						pEditView->GetAttribs().Get(EE_CHAR_ESCAPEMENT)).GetEnumValue();
989 				SvxEscapement eNew = (eOld == SVX_ESCAPEMENT_SUBSCRIPT) ?
990 										SVX_ESCAPEMENT_OFF : SVX_ESCAPEMENT_SUBSCRIPT;
991 				aSet.Put( SvxEscapementItem( eNew, EE_CHAR_ESCAPEMENT ) );
992 				rBindings.Invalidate( nSlot );
993 			}
994 			break;
995 	}
996 
997 	//
998 	//	anwenden
999 	//
1000 
1001 	EditEngine* pEngine = pEditView->GetEditEngine();
1002 	sal_Bool bOld = pEngine->GetUpdateMode();
1003 	pEngine->SetUpdateMode(sal_False);
1004 
1005 	pEditView->SetAttribs( aSet );
1006 
1007 	pEngine->SetUpdateMode(bOld);
1008 	pEditView->Invalidate();
1009 
1010 	ScInputHandler* pHdl = GetMyInputHdl();
1011 	pHdl->SetModified();
1012 
1013 	rReq.Done();
1014 }
1015 
1016 void ScEditShell::GetAttrState(SfxItemSet &rSet)
1017 {
1018     if ( !pViewData->HasEditView( pViewData->GetActivePart() ) )    // #125326#
1019     {
1020         lcl_DisableAll( rSet );
1021         return;
1022     }
1023 
1024 	SfxItemSet aAttribs = pEditView->GetAttribs();
1025 	rSet.Put( aAttribs );
1026 
1027 	//	choose font info according to selection script type
1028 
1029 	sal_uInt16 nScript = pEditView->GetSelectedScriptType();
1030 	if (nScript == 0) nScript = ScGlobal::GetDefaultScriptType();
1031 
1032     // #i55929# input-language-dependent script type (depends on input language if nothing selected)
1033     sal_uInt16 nInputScript = nScript;
1034     if ( !pEditView->GetSelection().HasRange() )
1035     {
1036         LanguageType nInputLang = pViewData->GetActiveWin()->GetInputLanguage();
1037         if (nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
1038             nInputScript = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
1039     }
1040 
1041     // #i55929# according to spec, nInputScript is used for font and font height only
1042 	if ( rSet.GetItemState( EE_CHAR_FONTINFO ) != SFX_ITEM_UNKNOWN )
1043 		ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_FONTINFO, nInputScript );
1044 	if ( rSet.GetItemState( EE_CHAR_FONTHEIGHT ) != SFX_ITEM_UNKNOWN )
1045 		ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_FONTHEIGHT, nInputScript );
1046 	if ( rSet.GetItemState( EE_CHAR_WEIGHT ) != SFX_ITEM_UNKNOWN )
1047 		ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_WEIGHT, nScript );
1048 	if ( rSet.GetItemState( EE_CHAR_ITALIC ) != SFX_ITEM_UNKNOWN )
1049 		ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_ITALIC, nScript );
1050 
1051 	//	Unterstreichung
1052 
1053 	SfxItemState eState = aAttribs.GetItemState( EE_CHAR_UNDERLINE, sal_True );
1054 	if ( eState == SFX_ITEM_DONTCARE )
1055 	{
1056 		rSet.InvalidateItem( SID_ULINE_VAL_NONE );
1057 		rSet.InvalidateItem( SID_ULINE_VAL_SINGLE );
1058 		rSet.InvalidateItem( SID_ULINE_VAL_DOUBLE );
1059 		rSet.InvalidateItem( SID_ULINE_VAL_DOTTED );
1060 	}
1061 	else
1062 	{
1063 		FontUnderline eUnderline = ((const SvxUnderlineItem&)
1064 					aAttribs.Get(EE_CHAR_UNDERLINE)).GetLineStyle();
1065 		sal_uInt16 nId = SID_ULINE_VAL_NONE;
1066 		switch (eUnderline)
1067 		{
1068 			case UNDERLINE_SINGLE:	nId = SID_ULINE_VAL_SINGLE;	break;
1069 			case UNDERLINE_DOUBLE:	nId = SID_ULINE_VAL_DOUBLE;	break;
1070 			case UNDERLINE_DOTTED:	nId = SID_ULINE_VAL_DOTTED;	break;
1071 			default:
1072 				break;
1073 		}
1074 		rSet.Put( SfxBoolItem( nId, sal_True ) );
1075 	}
1076 
1077 	//!	Testen, ob Klammer-Hervorhebung aktiv ist !!!!
1078 	ScInputHandler* pHdl = GetMyInputHdl();
1079 	if ( pHdl && pHdl->IsFormulaMode() )
1080 		rSet.ClearItem( EE_CHAR_WEIGHT );	// hervorgehobene Klammern hier nicht
1081 }
1082 
1083 String ScEditShell::GetSelectionText( sal_Bool bWholeWord )
1084 {
1085 	String aStrSelection;
1086 
1087     if ( pViewData->HasEditView( pViewData->GetActivePart() ) )    // #125326#
1088     {
1089         if ( bWholeWord )
1090         {
1091             EditEngine* pEngine = pEditView->GetEditEngine();
1092             ESelection  aSel = pEditView->GetSelection();
1093             String      aStrCurrentDelimiters = pEngine->GetWordDelimiters();
1094 
1095             pEngine->SetWordDelimiters( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(" .,;\"'")) );
1096             aStrSelection = pEngine->GetWord( aSel.nEndPara, aSel.nEndPos );
1097             pEngine->SetWordDelimiters( aStrCurrentDelimiters );
1098         }
1099         else
1100         {
1101             aStrSelection = pEditView->GetSelected();
1102         }
1103     }
1104 
1105 	return aStrSelection;
1106 }
1107 
1108 void ScEditShell::ExecuteUndo(SfxRequest& rReq)
1109 {
1110 	//	#81733# Undo must be handled here because it's called for both EditViews
1111 
1112 	ScInputHandler* pHdl = GetMyInputHdl();
1113 	DBG_ASSERT(pHdl,"no ScInputHandler");
1114 	EditView* pTopView	 = pHdl->GetTopView();
1115 	EditView* pTableView = pHdl->GetTableView();
1116 	DBG_ASSERT(pTableView,"no EditView");
1117 
1118 	pHdl->DataChanging();
1119 
1120 	const SfxItemSet* pReqArgs = rReq.GetArgs();
1121 	sal_uInt16 nSlot = rReq.GetSlot();
1122 	switch ( nSlot )
1123 	{
1124 		case SID_UNDO:
1125 		case SID_REDO:
1126 			{
1127 				sal_Bool bIsUndo = ( nSlot == SID_UNDO );
1128 
1129 				sal_uInt16 nCount = 1;
1130 				const SfxPoolItem* pItem;
1131 				if ( pReqArgs && pReqArgs->GetItemState( nSlot, sal_True, &pItem ) == SFX_ITEM_SET )
1132 					nCount = ((const SfxUInt16Item*)pItem)->GetValue();
1133 
1134 				for (sal_uInt16 i=0; i<nCount; i++)
1135 				{
1136 					if ( bIsUndo )
1137 					{
1138 						pTableView->Undo();
1139 						if (pTopView)
1140 							pTopView->Undo();
1141 					}
1142 					else
1143 					{
1144 						pTableView->Redo();
1145 						if (pTopView)
1146 							pTopView->Redo();
1147 					}
1148 				}
1149 			}
1150 			break;
1151 	}
1152 	pViewData->GetBindings().InvalidateAll(sal_False);
1153 
1154 	pHdl->DataChanged();
1155 }
1156 
1157 void ScEditShell::GetUndoState(SfxItemSet &rSet)
1158 {
1159 	//	Undo state is taken from normal ViewFrame state function
1160 
1161 	SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
1162 	if ( pViewFrm && GetUndoManager() )
1163 	{
1164 		SfxWhichIter aIter(rSet);
1165 		sal_uInt16 nWhich = aIter.FirstWhich();
1166 		while( nWhich )
1167 		{
1168 			pViewFrm->GetSlotState( nWhich, NULL, &rSet );
1169 			nWhich = aIter.NextWhich();
1170 		}
1171 	}
1172 
1173 	//	disable if no action in input line EditView
1174 
1175 	ScInputHandler* pHdl = GetMyInputHdl();
1176 	DBG_ASSERT(pHdl,"no ScInputHandler");
1177 	EditView* pTopView = pHdl->GetTopView();
1178 	if (pTopView)
1179 	{
1180 		::svl::IUndoManager& rTopMgr = pTopView->GetEditEngine()->GetUndoManager();
1181 		if ( rTopMgr.GetUndoActionCount() == 0 )
1182 			rSet.DisableItem( SID_UNDO );
1183 		if ( rTopMgr.GetRedoActionCount() == 0 )
1184 			rSet.DisableItem( SID_REDO );
1185 	}
1186 }
1187 
1188 void ScEditShell::ExecuteTrans( SfxRequest& rReq )
1189 {
1190 	sal_Int32 nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() );
1191 	if ( nType )
1192 	{
1193 		ScInputHandler* pHdl = GetMyInputHdl();
1194 		DBG_ASSERT( pHdl, "no ScInputHandler" );
1195 
1196 		EditView* pTopView	 = pHdl->GetTopView();
1197 		EditView* pTableView = pHdl->GetTableView();
1198 		DBG_ASSERT( pTableView, "no EditView" );
1199 
1200 		pHdl->DataChanging();
1201 
1202 		pTableView->TransliterateText( nType );
1203 		if (pTopView)
1204 			pTopView->TransliterateText( nType );
1205 
1206 		pHdl->DataChanged();
1207 	}
1208 }
1209 
1210