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