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