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