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