xref: /aoo41x/main/sc/source/ui/view/cellsh3.cxx (revision bb605c80)
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 // INCLUDE ---------------------------------------------------------------
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include "scitems.hxx"
32cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
33cdf0e10cSrcweir #include <sfx2/bindings.hxx>
34cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
35cdf0e10cSrcweir #include <sfx2/request.hxx>
36cdf0e10cSrcweir #include <svl/stritem.hxx>
37cdf0e10cSrcweir #include <vcl/msgbox.hxx>
38cdf0e10cSrcweir #include <sfx2/app.hxx>
39cdf0e10cSrcweir #include "globstr.hrc"
40cdf0e10cSrcweir #include "scmod.hxx"
41cdf0e10cSrcweir #include "appoptio.hxx"
42cdf0e10cSrcweir #include "tabvwsh.hxx"
43cdf0e10cSrcweir #include "document.hxx"
44cdf0e10cSrcweir #include "sc.hrc"
45cdf0e10cSrcweir #include "docsh.hxx"
46cdf0e10cSrcweir #include "reffact.hxx"
47cdf0e10cSrcweir #include "uiitems.hxx"
48cdf0e10cSrcweir //CHINA001 #include "scendlg.hxx"
49cdf0e10cSrcweir //CHINA001 #include "mtrindlg.hxx"
50cdf0e10cSrcweir #include "autoform.hxx"
51cdf0e10cSrcweir #include "autofmt.hxx"
52cdf0e10cSrcweir #include "cellsh.hxx"
53cdf0e10cSrcweir #include "attrdlg.hrc"		// TP_ALIGNMENT
54cdf0e10cSrcweir #include "inputhdl.hxx"
55cdf0e10cSrcweir #include "editable.hxx"
56cdf0e10cSrcweir 
57cdf0e10cSrcweir #include "scabstdlg.hxx" //CHINA001
58cdf0e10cSrcweir 
59cdf0e10cSrcweir #define IS_EDITMODE() GetViewData()->HasEditView( GetViewData()->GetActivePart() )
60cdf0e10cSrcweir 
TwipsToHMM(long nTwips)61cdf0e10cSrcweir inline long TwipsToHMM(long nTwips)	{ return (nTwips * 127 + 36) / 72; }
HMMToTwips(long nHMM)62cdf0e10cSrcweir inline long HMMToTwips(long nHMM)	{ return (nHMM * 72 + 63) / 127; }
TwipsToEvenHMM(long nTwips)63cdf0e10cSrcweir inline long TwipsToEvenHMM(long nTwips)	{ return ( (nTwips * 127 + 72) / 144 ) * 2; }
64cdf0e10cSrcweir 
65cdf0e10cSrcweir //------------------------------------------------------------------
66cdf0e10cSrcweir 
Execute(SfxRequest & rReq)67cdf0e10cSrcweir void ScCellShell::Execute( SfxRequest& rReq )
68cdf0e10cSrcweir {
69cdf0e10cSrcweir 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
70cdf0e10cSrcweir 	SfxBindings&		rBindings	= pTabViewShell->GetViewFrame()->GetBindings();
71cdf0e10cSrcweir 	ScModule*			pScMod		= SC_MOD();
72cdf0e10cSrcweir 	const SfxItemSet*	pReqArgs	= rReq.GetArgs();
73cdf0e10cSrcweir 	sal_uInt16				nSlot		= rReq.GetSlot();
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 	if (nSlot != SID_CURRENTCELL)		// der kommt beim MouseButtonUp
76cdf0e10cSrcweir 		pTabViewShell->HideListBox();	// Autofilter-DropDown-Listbox
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	if ( IS_EDITMODE() )
79cdf0e10cSrcweir 	{
80cdf0e10cSrcweir 		switch ( nSlot )
81cdf0e10cSrcweir 		{
82cdf0e10cSrcweir 			//	beim Oeffnen eines Referenz-Dialogs darf die SubShell nicht umgeschaltet werden
83cdf0e10cSrcweir 			//	(beim Schliessen des Dialogs wird StopEditShell gerufen)
84cdf0e10cSrcweir 			case SID_OPENDLG_FUNCTION:
85cdf0e10cSrcweir 					//	#53318# inplace macht die EditShell Aerger...
86cdf0e10cSrcweir 					//!	kann nicht immer umgeschaltet werden ????
87cdf0e10cSrcweir                     if (!pTabViewShell->GetViewFrame()->GetFrame().IsInPlace())
88cdf0e10cSrcweir 						pTabViewShell->SetDontSwitch(sal_True);			// EditShell nicht abschalten
89cdf0e10cSrcweir 					// kein break
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 			case FID_CELL_FORMAT:
92cdf0e10cSrcweir 			case SID_ENABLE_HYPHENATION:
93cdf0e10cSrcweir 			case SID_DATA_SELECT:
94cdf0e10cSrcweir 			case SID_OPENDLG_CONSOLIDATE:
95cdf0e10cSrcweir 			case SID_OPENDLG_SOLVE:
96cdf0e10cSrcweir             case SID_OPENDLG_OPTSOLVER:
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 					pScMod->InputEnterHandler();
99cdf0e10cSrcweir 					pTabViewShell->UpdateInputHandler();
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 					pTabViewShell->SetDontSwitch(sal_False);
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 					break;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 			default:
106cdf0e10cSrcweir 					break;
107cdf0e10cSrcweir 		}
108cdf0e10cSrcweir 	}
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 	switch ( nSlot )
111cdf0e10cSrcweir 	{
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 		case SID_ATTR_SIZE://XXX ???
116cdf0e10cSrcweir 			break;
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 		case SID_STATUS_SELMODE:
119cdf0e10cSrcweir 			if ( pReqArgs )
120cdf0e10cSrcweir 			{
121cdf0e10cSrcweir 				/* 0: STD	Click hebt Sel auf
122cdf0e10cSrcweir 				 * 1: ER	Click erweitert Selektion
123cdf0e10cSrcweir 				 * 2: ERG	Click definiert weitere Selektion
124cdf0e10cSrcweir 				 */
125cdf0e10cSrcweir 				sal_uInt16 nMode = ((const SfxUInt16Item&)pReqArgs->Get( nSlot )).GetValue();
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 				switch ( nMode )
128cdf0e10cSrcweir 				{
129cdf0e10cSrcweir 					case 1: nMode = KEY_SHIFT;	break;
130cdf0e10cSrcweir 					case 2: nMode = KEY_MOD1;	break; // Control-Taste
131cdf0e10cSrcweir 					case 0:
132cdf0e10cSrcweir 					default:
133cdf0e10cSrcweir 						nMode = 0;
134cdf0e10cSrcweir 				}
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 				pTabViewShell->LockModifiers( nMode );
137cdf0e10cSrcweir 			}
138cdf0e10cSrcweir 			else
139cdf0e10cSrcweir 			{
140cdf0e10cSrcweir 				//	no arguments (also executed by double click on the status bar controller):
141cdf0e10cSrcweir 				//	advance to next selection mode
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 				sal_uInt16 nModifiers = pTabViewShell->GetLockedModifiers();
144cdf0e10cSrcweir 				switch ( nModifiers )
145cdf0e10cSrcweir 				{
146cdf0e10cSrcweir 					case KEY_SHIFT:	nModifiers = KEY_MOD1;	break;		// EXT -> ADD
147cdf0e10cSrcweir 					case KEY_MOD1:	nModifiers = 0;			break;		// ADD -> STD
148cdf0e10cSrcweir 					default:		nModifiers = KEY_SHIFT;	break;		// STD -> EXT
149cdf0e10cSrcweir 				}
150cdf0e10cSrcweir 				pTabViewShell->LockModifiers( nModifiers );
151cdf0e10cSrcweir 			}
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 			rBindings.Invalidate( SID_STATUS_SELMODE );
154cdf0e10cSrcweir 			rReq.Done();
155cdf0e10cSrcweir 			break;
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 		//	SID_STATUS_SELMODE_NORM wird nicht benutzt ???
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 		case SID_STATUS_SELMODE_NORM:
160cdf0e10cSrcweir 			pTabViewShell->LockModifiers( 0 );
161cdf0e10cSrcweir 			rBindings.Invalidate( SID_STATUS_SELMODE );
162cdf0e10cSrcweir 			break;
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 		//	SID_STATUS_SELMODE_ERG / SID_STATUS_SELMODE_ERW als Toggles:
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 		case SID_STATUS_SELMODE_ERG:
167cdf0e10cSrcweir 			if ( pTabViewShell->GetLockedModifiers() & KEY_MOD1 )
168cdf0e10cSrcweir 				pTabViewShell->LockModifiers( 0 );
169cdf0e10cSrcweir 			else
170cdf0e10cSrcweir 				pTabViewShell->LockModifiers( KEY_MOD1 );
171cdf0e10cSrcweir 			rBindings.Invalidate( SID_STATUS_SELMODE );
172cdf0e10cSrcweir 			break;
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 		case SID_STATUS_SELMODE_ERW:
175cdf0e10cSrcweir 			if ( pTabViewShell->GetLockedModifiers() & KEY_SHIFT )
176cdf0e10cSrcweir 				pTabViewShell->LockModifiers( 0 );
177cdf0e10cSrcweir 			else
178cdf0e10cSrcweir 				pTabViewShell->LockModifiers( KEY_SHIFT );
179cdf0e10cSrcweir 			rBindings.Invalidate( SID_STATUS_SELMODE );
180cdf0e10cSrcweir 			break;
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 		case SID_ENTER_STRING:
183cdf0e10cSrcweir 			{
184cdf0e10cSrcweir 				if ( pReqArgs )
185cdf0e10cSrcweir 				{
186cdf0e10cSrcweir 					String aStr( ((const SfxStringItem&)pReqArgs->
187cdf0e10cSrcweir 									Get( SID_ENTER_STRING )).GetValue() );
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 					pTabViewShell->EnterData( GetViewData()->GetCurX(),
190cdf0e10cSrcweir 											   GetViewData()->GetCurY(),
191cdf0e10cSrcweir 											   GetViewData()->GetTabNo(),
192cdf0e10cSrcweir 											   aStr );
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 					ScInputHandler* pHdl = SC_MOD()->GetInputHdl( pTabViewShell );
195cdf0e10cSrcweir 					if ( !pHdl || !pHdl->IsInEnterHandler() )
196cdf0e10cSrcweir 					{
197cdf0e10cSrcweir 						//	#101061# UpdateInputHandler is needed after the cell content
198cdf0e10cSrcweir 						//	has changed, but if called from EnterHandler, UpdateInputHandler
199cdf0e10cSrcweir 						//	will be called later when moving the cursor.
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 						pTabViewShell->UpdateInputHandler();
202cdf0e10cSrcweir 					}
203cdf0e10cSrcweir 
204cdf0e10cSrcweir 					rReq.Done();
205cdf0e10cSrcweir 
206cdf0e10cSrcweir 					//	hier kein GrabFocus, weil sonst auf dem Mac die Tabelle vor die
207cdf0e10cSrcweir 					//	Seitenansicht springt, wenn die Eingabe nicht abgeschlossen war
208cdf0e10cSrcweir 					//	(GrabFocus passiert in KillEditView)
209cdf0e10cSrcweir 				}
210cdf0e10cSrcweir 			}
211cdf0e10cSrcweir 			break;
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 		case SID_INSERT_MATRIX:
214cdf0e10cSrcweir 			{
215cdf0e10cSrcweir 				if ( pReqArgs )
216cdf0e10cSrcweir 				{
217cdf0e10cSrcweir 					String aStr = ((const SfxStringItem&)pReqArgs->
218cdf0e10cSrcweir 									Get( SID_INSERT_MATRIX )).GetValue();
219cdf0e10cSrcweir 					pTabViewShell->EnterMatrix( aStr );
220cdf0e10cSrcweir 					rReq.Done();
221cdf0e10cSrcweir 				}
222cdf0e10cSrcweir 			}
223cdf0e10cSrcweir 			break;
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 		case FID_INPUTLINE_ENTER:
226cdf0e10cSrcweir 		case FID_INPUTLINE_BLOCK:
227cdf0e10cSrcweir 		case FID_INPUTLINE_MATRIX:
228cdf0e10cSrcweir 			{
229cdf0e10cSrcweir 				if( pReqArgs == 0 ) //XXX vorlaufiger HACK um GPF zu vermeiden
230cdf0e10cSrcweir 					break;
231cdf0e10cSrcweir 
232cdf0e10cSrcweir 				const ScInputStatusItem* pStatusItem
233cdf0e10cSrcweir 					= (const ScInputStatusItem*)&pReqArgs->
234cdf0e10cSrcweir 							Get( FID_INPUTLINE_STATUS );
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 				ScAddress aCursorPos = pStatusItem->GetPos();
237cdf0e10cSrcweir                 String aString = pStatusItem->GetString();
238cdf0e10cSrcweir 				const EditTextObject* pData = pStatusItem->GetEditData();
239cdf0e10cSrcweir 				if (pData)
240cdf0e10cSrcweir 				{
241cdf0e10cSrcweir 					if (nSlot == FID_INPUTLINE_BLOCK)
242cdf0e10cSrcweir                     {
243cdf0e10cSrcweir 						pTabViewShell->EnterBlock( aString, pData );
244cdf0e10cSrcweir                     }
245cdf0e10cSrcweir                     else if ( aString.Len() > 0 && ( aString.GetChar(0) == '=' || aString.GetChar(0) == '+' || aString.GetChar(0) == '-' ) )
246cdf0e10cSrcweir                     {
247cdf0e10cSrcweir                         pTabViewShell->EnterData( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(), aString, sal_True, pData );
248cdf0e10cSrcweir                     }
249cdf0e10cSrcweir 					else
250cdf0e10cSrcweir                     {
251cdf0e10cSrcweir 						pTabViewShell->EnterData( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(), pData );
252cdf0e10cSrcweir                     }
253cdf0e10cSrcweir 				}
254cdf0e10cSrcweir 				else
255cdf0e10cSrcweir 				{
256cdf0e10cSrcweir 					if (nSlot == FID_INPUTLINE_ENTER)
257cdf0e10cSrcweir 					{
258cdf0e10cSrcweir 						if (
259cdf0e10cSrcweir 							aCursorPos.Col() == GetViewData()->GetCurX() &&
260cdf0e10cSrcweir 							aCursorPos.Row() == GetViewData()->GetCurY() &&
261cdf0e10cSrcweir 							aCursorPos.Tab() == GetViewData()->GetTabNo()
262cdf0e10cSrcweir 							)
263cdf0e10cSrcweir 						{
264cdf0e10cSrcweir 							SfxStringItem	aItem( SID_ENTER_STRING, aString );
265cdf0e10cSrcweir 
266cdf0e10cSrcweir                             // SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings();
267cdf0e10cSrcweir 							const SfxPoolItem* aArgs[2];
268cdf0e10cSrcweir 							aArgs[0] = &aItem;
269cdf0e10cSrcweir 							aArgs[1] = NULL;
270cdf0e10cSrcweir 							rBindings.Execute( SID_ENTER_STRING, aArgs );
271cdf0e10cSrcweir 						}
272cdf0e10cSrcweir 						else
273cdf0e10cSrcweir 						{
274cdf0e10cSrcweir 							pTabViewShell->EnterData( aCursorPos.Col(),
275cdf0e10cSrcweir 													aCursorPos.Row(),
276cdf0e10cSrcweir 													aCursorPos.Tab(),
277cdf0e10cSrcweir 													aString );
278cdf0e10cSrcweir 							rReq.Done();
279cdf0e10cSrcweir 						}
280cdf0e10cSrcweir 					}
281cdf0e10cSrcweir 					else if (nSlot == FID_INPUTLINE_BLOCK)
282cdf0e10cSrcweir 					{
283cdf0e10cSrcweir 						pTabViewShell->EnterBlock( aString, NULL );
284cdf0e10cSrcweir 						rReq.Done();
285cdf0e10cSrcweir 					}
286cdf0e10cSrcweir 					else
287cdf0e10cSrcweir 					{
288cdf0e10cSrcweir 						pTabViewShell->EnterMatrix( aString );
289cdf0e10cSrcweir 						rReq.Done();
290cdf0e10cSrcweir 					}
291cdf0e10cSrcweir 
292cdf0e10cSrcweir 				}
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 				//	hier kein GrabFocus, weil sonst auf dem Mac die Tabelle vor die
295cdf0e10cSrcweir 				//	Seitenansicht springt, wenn die Eingabe nicht abgeschlossen war
296cdf0e10cSrcweir 				//	(GrabFocus passiert in KillEditView)
297cdf0e10cSrcweir 			}
298cdf0e10cSrcweir 			break;
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 		case SID_OPENDLG_FUNCTION:
301cdf0e10cSrcweir 			{
302cdf0e10cSrcweir 				sal_uInt16 nId = SID_OPENDLG_FUNCTION;
303cdf0e10cSrcweir 				SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
304cdf0e10cSrcweir 				SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 				pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
307cdf0e10cSrcweir                 rReq.Ignore();
308cdf0e10cSrcweir 			}
309cdf0e10cSrcweir 			break;
310cdf0e10cSrcweir 
311cdf0e10cSrcweir 		case SID_OPENDLG_CONSOLIDATE:
312cdf0e10cSrcweir 			{
313cdf0e10cSrcweir 				sal_uInt16			nId  = ScConsolidateDlgWrapper::GetChildWindowId();
314cdf0e10cSrcweir 				SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
315cdf0e10cSrcweir 				SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
316cdf0e10cSrcweir 
317cdf0e10cSrcweir 				pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
318cdf0e10cSrcweir 			}
319cdf0e10cSrcweir 			break;
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 		case FID_CELL_FORMAT:
322cdf0e10cSrcweir 			{
323cdf0e10cSrcweir 				if ( pReqArgs != NULL )
324cdf0e10cSrcweir 				{
325cdf0e10cSrcweir 					//----------------------------------
326cdf0e10cSrcweir 					// Zellattribute ohne Dialog setzen:
327cdf0e10cSrcweir 					//----------------------------------
328cdf0e10cSrcweir 					SfxItemSet* 	pEmptySet =
329cdf0e10cSrcweir 										new SfxItemSet( *pReqArgs->GetPool(),
330cdf0e10cSrcweir 														ATTR_PATTERN_START,
331cdf0e10cSrcweir 														ATTR_PATTERN_END );
332cdf0e10cSrcweir 
333cdf0e10cSrcweir 					SfxItemSet* 	pNewSet =
334cdf0e10cSrcweir 										new SfxItemSet( *pReqArgs->GetPool(),
335cdf0e10cSrcweir 														ATTR_PATTERN_START,
336cdf0e10cSrcweir 														ATTR_PATTERN_END );
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 					const SfxPoolItem*	pAttr = NULL;
339cdf0e10cSrcweir 					sal_uInt16				nWhich = 0;
340cdf0e10cSrcweir 
341cdf0e10cSrcweir 					for ( nWhich=ATTR_PATTERN_START; nWhich<=ATTR_PATTERN_END; nWhich++ )
342cdf0e10cSrcweir 						if ( pReqArgs->GetItemState( nWhich, sal_True, &pAttr ) == SFX_ITEM_SET )
343cdf0e10cSrcweir 							pNewSet->Put( *pAttr );
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 					pTabViewShell->ApplyAttributes( pNewSet, pEmptySet );
346cdf0e10cSrcweir 
347cdf0e10cSrcweir 					delete pNewSet;
348cdf0e10cSrcweir 					delete pEmptySet;
349cdf0e10cSrcweir 
350cdf0e10cSrcweir 					rReq.Done();
351cdf0e10cSrcweir 				}
352cdf0e10cSrcweir 				else if ( pReqArgs == NULL )
353cdf0e10cSrcweir 				{
354cdf0e10cSrcweir 					pTabViewShell->ExecuteCellFormatDlg( rReq );
355cdf0e10cSrcweir 				}
356cdf0e10cSrcweir 			}
357cdf0e10cSrcweir 			break;
358cdf0e10cSrcweir 
359cdf0e10cSrcweir 		case SID_ENABLE_HYPHENATION:
360cdf0e10cSrcweir 			pTabViewShell->ExecuteCellFormatDlg( rReq, TP_ALIGNMENT );
361cdf0e10cSrcweir 			break;
362cdf0e10cSrcweir 
363*bb605c80SOliver-Rainer Wittmann         case SID_PROPERTY_PANEL_CELLTEXT_DLG:
364*bb605c80SOliver-Rainer Wittmann             pTabViewShell->ExecuteCellFormatDlg( rReq, TP_FONT );
365*bb605c80SOliver-Rainer Wittmann             break;
366*bb605c80SOliver-Rainer Wittmann 
367facb16e7SArmin Le Grand 		case SID_CELL_FORMAT_BORDER:
368facb16e7SArmin Le Grand 			pTabViewShell->ExecuteCellFormatDlg( rReq, TP_BORDER );
369facb16e7SArmin Le Grand 			break;
370facb16e7SArmin Le Grand 
371d9a8b508SZheng Fan 		case SID_CHAR_DLG_EFFECT:
372d9a8b508SZheng Fan 			pTabViewShell->ExecuteCellFormatDlg( rReq, TP_FONTEFF );
373d9a8b508SZheng Fan 			break;
374d9a8b508SZheng Fan 
375cdf0e10cSrcweir 		case SID_OPENDLG_SOLVE:
376cdf0e10cSrcweir 			{
377cdf0e10cSrcweir 				sal_uInt16			nId  = ScSolverDlgWrapper::GetChildWindowId();
378cdf0e10cSrcweir 				SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
379cdf0e10cSrcweir 				SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 				pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
382cdf0e10cSrcweir 			}
383cdf0e10cSrcweir 			break;
384cdf0e10cSrcweir 
385cdf0e10cSrcweir         case SID_OPENDLG_OPTSOLVER:
386cdf0e10cSrcweir             {
387cdf0e10cSrcweir                 sal_uInt16 nId = ScOptSolverDlgWrapper::GetChildWindowId();
388cdf0e10cSrcweir                 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
389cdf0e10cSrcweir                 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
390cdf0e10cSrcweir 
391cdf0e10cSrcweir                 pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
392cdf0e10cSrcweir             }
393cdf0e10cSrcweir             break;
394cdf0e10cSrcweir 
395cdf0e10cSrcweir 		case SID_OPENDLG_TABOP:
396cdf0e10cSrcweir 			{
397cdf0e10cSrcweir 				sal_uInt16			nId  = ScTabOpDlgWrapper::GetChildWindowId();
398cdf0e10cSrcweir 				SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
399cdf0e10cSrcweir 				SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 				pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
402cdf0e10cSrcweir 			}
403cdf0e10cSrcweir 			break;
404cdf0e10cSrcweir 
405cdf0e10cSrcweir 		case SID_SCENARIOS:
406cdf0e10cSrcweir 			{
407cdf0e10cSrcweir 				ScDocument* pDoc = GetViewData()->GetDocument();
408cdf0e10cSrcweir 				ScMarkData& rMark = GetViewData()->GetMarkData();
409cdf0e10cSrcweir 				SCTAB nTab = GetViewData()->GetTabNo();
410cdf0e10cSrcweir 
411cdf0e10cSrcweir 				if ( pDoc->IsScenario(nTab) )
412cdf0e10cSrcweir 				{
413cdf0e10cSrcweir 					rMark.MarkToMulti();
414cdf0e10cSrcweir 					if ( rMark.IsMultiMarked() )
415cdf0e10cSrcweir 					{
416cdf0e10cSrcweir 						if (   rReq.IsAPI()
417cdf0e10cSrcweir 							|| RET_YES ==
418cdf0e10cSrcweir 							   QueryBox( pTabViewShell->GetDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
419cdf0e10cSrcweir 										 ScGlobal::GetRscString(STR_UPDATE_SCENARIO) ).
420cdf0e10cSrcweir 										Execute() )
421cdf0e10cSrcweir 						{
422cdf0e10cSrcweir 							pTabViewShell->ExtendScenario();
423cdf0e10cSrcweir 							rReq.Done();
424cdf0e10cSrcweir 						}
425cdf0e10cSrcweir 					}
426cdf0e10cSrcweir 					else if( ! rReq.IsAPI() )
427cdf0e10cSrcweir 					{
428cdf0e10cSrcweir 						ErrorBox aErrorBox( pTabViewShell->GetDialogParent(), WinBits(WB_OK | WB_DEF_OK),
429cdf0e10cSrcweir 											ScGlobal::GetRscString(STR_NOAREASELECTED) );
430cdf0e10cSrcweir 						aErrorBox.Execute();
431cdf0e10cSrcweir 					}
432cdf0e10cSrcweir 				}
433cdf0e10cSrcweir 				else
434cdf0e10cSrcweir 				{
435cdf0e10cSrcweir 					rMark.MarkToMulti();
436cdf0e10cSrcweir 					if ( rMark.IsMultiMarked() )
437cdf0e10cSrcweir 					{
438cdf0e10cSrcweir 						SCTAB i=1;
439cdf0e10cSrcweir 						String aBaseName;
440cdf0e10cSrcweir 						String aName;
441cdf0e10cSrcweir 						String aComment;
442cdf0e10cSrcweir 						Color  aColor;
443cdf0e10cSrcweir 						sal_uInt16 nFlags;
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 						pDoc->GetName( nTab, aBaseName );
446cdf0e10cSrcweir 						aBaseName += '_';
447cdf0e10cSrcweir 						aBaseName += ScGlobal::GetRscString(STR_SCENARIO);
448cdf0e10cSrcweir 						aBaseName += '_';
449cdf0e10cSrcweir 
450cdf0e10cSrcweir 						//	vorneweg testen, ob der Prefix als gueltig erkannt wird
451cdf0e10cSrcweir 						//	wenn nicht, nur doppelte vermeiden
452cdf0e10cSrcweir 						sal_Bool bPrefix = pDoc->ValidTabName( aBaseName );
453cdf0e10cSrcweir 						DBG_ASSERT(bPrefix, "ungueltiger Tabellenname");
454cdf0e10cSrcweir 
455cdf0e10cSrcweir 						while ( pDoc->IsScenario(nTab+i) )
456cdf0e10cSrcweir 							i++;
457cdf0e10cSrcweir 
458cdf0e10cSrcweir 						sal_Bool bValid;
459cdf0e10cSrcweir 						SCTAB nDummy;
460cdf0e10cSrcweir 						do
461cdf0e10cSrcweir 						{
462cdf0e10cSrcweir 							aName = aBaseName;
463cdf0e10cSrcweir 							aName += String::CreateFromInt32( i );
464cdf0e10cSrcweir 							if (bPrefix)
465cdf0e10cSrcweir 								bValid = pDoc->ValidNewTabName( aName );
466cdf0e10cSrcweir 							else
467cdf0e10cSrcweir 								bValid = !pDoc->GetTable( aName, nDummy );
468cdf0e10cSrcweir 							++i;
469cdf0e10cSrcweir 						}
470cdf0e10cSrcweir 						while ( !bValid && i <= 2*MAXTAB );
471cdf0e10cSrcweir 
472cdf0e10cSrcweir 						if ( pReqArgs != NULL )
473cdf0e10cSrcweir 						{
474cdf0e10cSrcweir 							String aArgName;
475cdf0e10cSrcweir 							String aArgComment;
476cdf0e10cSrcweir 							const SfxPoolItem* pItem;
477cdf0e10cSrcweir 							if ( pReqArgs->GetItemState( SID_SCENARIOS, sal_True, &pItem ) == SFX_ITEM_SET )
478cdf0e10cSrcweir 								aArgName = ((const SfxStringItem*)pItem)->GetValue();
479cdf0e10cSrcweir 							if ( pReqArgs->GetItemState( SID_NEW_TABLENAME, sal_True, &pItem ) == SFX_ITEM_SET )
480cdf0e10cSrcweir 								aArgComment = ((const SfxStringItem*)pItem)->GetValue();
481cdf0e10cSrcweir 
482cdf0e10cSrcweir 							aColor = Color( COL_LIGHTGRAY );		// Default
483cdf0e10cSrcweir 							nFlags = 0;								// nicht-TwoWay
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 							pTabViewShell->MakeScenario( aArgName, aArgComment, aColor, nFlags );
486cdf0e10cSrcweir 							if( ! rReq.IsAPI() )
487cdf0e10cSrcweir 								rReq.Done();
488cdf0e10cSrcweir 						}
489cdf0e10cSrcweir 						else
490cdf0e10cSrcweir 						{
491cdf0e10cSrcweir 							sal_Bool bSheetProtected = pDoc->IsTabProtected(nTab);
492cdf0e10cSrcweir 							//CHINA001 ScNewScenarioDlg* pNewDlg =
493cdf0e10cSrcweir 							//CHINA001 	new ScNewScenarioDlg( pTabViewShell->GetDialogParent(), aName, sal_False, bSheetProtected );
494cdf0e10cSrcweir 							ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
495cdf0e10cSrcweir 							DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
496cdf0e10cSrcweir 
497cdf0e10cSrcweir 							AbstractScNewScenarioDlg* pNewDlg = pFact->CreateScNewScenarioDlg( pTabViewShell->GetDialogParent(), aName, RID_SCDLG_NEWSCENARIO, sal_False,bSheetProtected);
498cdf0e10cSrcweir 							DBG_ASSERT(pNewDlg, "Dialog create fail!");//CHINA001
499cdf0e10cSrcweir 							if ( pNewDlg->Execute() == RET_OK )
500cdf0e10cSrcweir 							{
501cdf0e10cSrcweir 								pNewDlg->GetScenarioData( aName, aComment, aColor, nFlags );
502cdf0e10cSrcweir 								pTabViewShell->MakeScenario( aName, aComment, aColor, nFlags );
503cdf0e10cSrcweir 
504cdf0e10cSrcweir 								rReq.AppendItem( SfxStringItem( SID_SCENARIOS, aName ) );
505cdf0e10cSrcweir 								rReq.AppendItem( SfxStringItem( SID_NEW_TABLENAME, aComment ) );
506cdf0e10cSrcweir 								rReq.Done();
507cdf0e10cSrcweir 							}
508cdf0e10cSrcweir 							delete pNewDlg;
509cdf0e10cSrcweir 						}
510cdf0e10cSrcweir 					}
511cdf0e10cSrcweir 					else if( ! rReq.IsAPI() )
512cdf0e10cSrcweir 					{
513cdf0e10cSrcweir 						pTabViewShell->ErrorMessage(STR_ERR_NEWSCENARIO);
514cdf0e10cSrcweir 					}
515cdf0e10cSrcweir 				}
516cdf0e10cSrcweir 			}
517cdf0e10cSrcweir 			break;
518cdf0e10cSrcweir 
519cdf0e10cSrcweir 
520cdf0e10cSrcweir 		case SID_SELECTALL:
521cdf0e10cSrcweir 			{
522cdf0e10cSrcweir 				pTabViewShell->SelectAll();
523cdf0e10cSrcweir 				rReq.Done();
524cdf0e10cSrcweir 			}
525cdf0e10cSrcweir 			break;
526cdf0e10cSrcweir 
527cdf0e10cSrcweir 		//----------------------------------------------------------------
528cdf0e10cSrcweir 
529cdf0e10cSrcweir 		case FID_ROW_HEIGHT:
530cdf0e10cSrcweir 			{
531cdf0e10cSrcweir 				if ( pReqArgs )
532cdf0e10cSrcweir 				{
533cdf0e10cSrcweir 					const SfxUInt16Item&  rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_ROW_HEIGHT );
534cdf0e10cSrcweir 
535cdf0e10cSrcweir                     // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
536cdf0e10cSrcweir                     pTabViewShell->SetMarkedWidthOrHeight( sal_False, SC_SIZE_DIRECT,
537cdf0e10cSrcweir                                     sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) );
538cdf0e10cSrcweir 					if( ! rReq.IsAPI() )
539cdf0e10cSrcweir 						rReq.Done();
540cdf0e10cSrcweir 				}
541cdf0e10cSrcweir 				else
542cdf0e10cSrcweir 				{
543cdf0e10cSrcweir 					ScViewData* pData      = GetViewData();
544cdf0e10cSrcweir 					FieldUnit	eMetric    = SC_MOD()->GetAppOptions().GetAppMetric();
545cdf0e10cSrcweir 					sal_uInt16		nCurHeight = pData->GetDocument()->
546cdf0e10cSrcweir 												GetRowHeight( pData->GetCurY(),
547cdf0e10cSrcweir 															  pData->GetTabNo() );
548cdf0e10cSrcweir //CHINA001					ScMetricInputDlg* pDlg =
549cdf0e10cSrcweir //CHINA001					new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_MAN,
550cdf0e10cSrcweir //CHINA001					nCurHeight,
551cdf0e10cSrcweir //CHINA001					ScGlobal::nStdRowHeight,
552cdf0e10cSrcweir //CHINA001					eMetric,
553cdf0e10cSrcweir //CHINA001					2,
554cdf0e10cSrcweir //CHINA001					MAX_COL_HEIGHT );
555cdf0e10cSrcweir 					ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
556cdf0e10cSrcweir 					DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
557cdf0e10cSrcweir 
558cdf0e10cSrcweir 					AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_MAN,
559cdf0e10cSrcweir 																					nCurHeight,
560cdf0e10cSrcweir 																					ScGlobal::nStdRowHeight,
561cdf0e10cSrcweir 																					RID_SCDLG_ROW_MAN,
562cdf0e10cSrcweir 																					eMetric,
563cdf0e10cSrcweir 																					2,
564cdf0e10cSrcweir 																					MAX_COL_HEIGHT);
565cdf0e10cSrcweir 					DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
566cdf0e10cSrcweir 
567cdf0e10cSrcweir 					if ( pDlg->Execute() == RET_OK )
568cdf0e10cSrcweir 					{
569cdf0e10cSrcweir 						long nVal = pDlg->GetInputValue();
570cdf0e10cSrcweir 						pTabViewShell->SetMarkedWidthOrHeight( sal_False, SC_SIZE_DIRECT, (sal_uInt16)nVal );
571cdf0e10cSrcweir 
572cdf0e10cSrcweir                         // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
573cdf0e10cSrcweir 						rReq.AppendItem( SfxUInt16Item( FID_ROW_HEIGHT, (sal_uInt16)TwipsToEvenHMM(nVal) ) );
574cdf0e10cSrcweir 						rReq.Done();
575cdf0e10cSrcweir 
576cdf0e10cSrcweir 					}
577cdf0e10cSrcweir 					delete pDlg;
578cdf0e10cSrcweir 				}
579cdf0e10cSrcweir 			}
580cdf0e10cSrcweir 			break;
581cdf0e10cSrcweir 
582cdf0e10cSrcweir 		case FID_ROW_OPT_HEIGHT:
583cdf0e10cSrcweir 			{
584cdf0e10cSrcweir 				if ( pReqArgs )
585cdf0e10cSrcweir 				{
586cdf0e10cSrcweir 					const SfxUInt16Item&  rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_ROW_OPT_HEIGHT );
587cdf0e10cSrcweir 
588cdf0e10cSrcweir                     // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
589cdf0e10cSrcweir                     pTabViewShell->SetMarkedWidthOrHeight( sal_False, SC_SIZE_OPTIMAL,
590cdf0e10cSrcweir                                     sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) );
591cdf0e10cSrcweir 					ScGlobal::nLastRowHeightExtra = rUInt16Item.GetValue();
592cdf0e10cSrcweir 
593cdf0e10cSrcweir 					if( ! rReq.IsAPI() )
594cdf0e10cSrcweir 						rReq.Done();
595cdf0e10cSrcweir 				}
596cdf0e10cSrcweir 				else
597cdf0e10cSrcweir 				{
598cdf0e10cSrcweir 					FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric();
599cdf0e10cSrcweir 
600cdf0e10cSrcweir //CHINA001					ScMetricInputDlg* pDlg =
601cdf0e10cSrcweir //CHINA001					new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_OPT,
602cdf0e10cSrcweir //CHINA001					ScGlobal::nLastRowHeightExtra,
603cdf0e10cSrcweir //CHINA001					0,
604cdf0e10cSrcweir //CHINA001					eMetric,
605cdf0e10cSrcweir //CHINA001					1,
606cdf0e10cSrcweir //CHINA001					MAX_EXTRA_HEIGHT );
607cdf0e10cSrcweir 					ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
608cdf0e10cSrcweir 					DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
609cdf0e10cSrcweir 
610cdf0e10cSrcweir 					AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_OPT,
611cdf0e10cSrcweir 																					ScGlobal::nLastRowHeightExtra,
612cdf0e10cSrcweir 																					0,
613cdf0e10cSrcweir 																					RID_SCDLG_ROW_OPT,
614cdf0e10cSrcweir 																					eMetric,
615cdf0e10cSrcweir 																					1,
616cdf0e10cSrcweir 																					MAX_EXTRA_HEIGHT);
617cdf0e10cSrcweir 					DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
618cdf0e10cSrcweir 
619cdf0e10cSrcweir 					if ( pDlg->Execute() == RET_OK )
620cdf0e10cSrcweir 					{
621cdf0e10cSrcweir 						long nVal = pDlg->GetInputValue();
622cdf0e10cSrcweir 						pTabViewShell->SetMarkedWidthOrHeight( sal_False, SC_SIZE_OPTIMAL, (sal_uInt16)nVal );
623cdf0e10cSrcweir 						ScGlobal::nLastRowHeightExtra = nVal;
624cdf0e10cSrcweir 
625cdf0e10cSrcweir                         // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
626cdf0e10cSrcweir 						rReq.AppendItem( SfxUInt16Item( FID_ROW_OPT_HEIGHT, (sal_uInt16)TwipsToEvenHMM(nVal) ) );
627cdf0e10cSrcweir 						rReq.Done();
628cdf0e10cSrcweir 
629cdf0e10cSrcweir 					}
630cdf0e10cSrcweir 					delete pDlg;
631cdf0e10cSrcweir 				}
632cdf0e10cSrcweir 			}
633cdf0e10cSrcweir 			break;
634cdf0e10cSrcweir 
635cdf0e10cSrcweir 		case FID_COL_WIDTH:
636cdf0e10cSrcweir 			{
637cdf0e10cSrcweir 				if ( pReqArgs )
638cdf0e10cSrcweir 				{
639cdf0e10cSrcweir 					const SfxUInt16Item&  rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_COL_WIDTH );
640cdf0e10cSrcweir 
641cdf0e10cSrcweir                     // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
642cdf0e10cSrcweir                     pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_DIRECT,
643cdf0e10cSrcweir                                     sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) );
644cdf0e10cSrcweir 					if( ! rReq.IsAPI() )
645cdf0e10cSrcweir 						rReq.Done();
646cdf0e10cSrcweir 				}
647cdf0e10cSrcweir 				else
648cdf0e10cSrcweir 				{
649cdf0e10cSrcweir 					FieldUnit   eMetric	   = SC_MOD()->GetAppOptions().GetAppMetric();
650cdf0e10cSrcweir 					ScViewData* pData      = GetViewData();
651cdf0e10cSrcweir 					sal_uInt16		nCurHeight = pData->GetDocument()->
652cdf0e10cSrcweir 												GetColWidth( pData->GetCurX(),
653cdf0e10cSrcweir 															 pData->GetTabNo() );
654cdf0e10cSrcweir //CHINA001					ScMetricInputDlg* pDlg =
655cdf0e10cSrcweir //CHINA001					new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_MAN,
656cdf0e10cSrcweir //CHINA001					nCurHeight,
657cdf0e10cSrcweir //CHINA001					STD_COL_WIDTH,
658cdf0e10cSrcweir //CHINA001					eMetric,
659cdf0e10cSrcweir //CHINA001					2,
660cdf0e10cSrcweir //CHINA001					MAX_COL_WIDTH );
661cdf0e10cSrcweir 					ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
662cdf0e10cSrcweir 					DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
663cdf0e10cSrcweir 
664cdf0e10cSrcweir 					AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_MAN,
665cdf0e10cSrcweir 																					nCurHeight,
666cdf0e10cSrcweir 																					STD_COL_WIDTH,
667cdf0e10cSrcweir 																					RID_SCDLG_COL_MAN,
668cdf0e10cSrcweir 																					eMetric,
669cdf0e10cSrcweir 																					2,
670cdf0e10cSrcweir 																					MAX_COL_WIDTH);
671cdf0e10cSrcweir 					DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
672cdf0e10cSrcweir 
673cdf0e10cSrcweir 					if ( pDlg->Execute() == RET_OK )
674cdf0e10cSrcweir 					{
675cdf0e10cSrcweir 						long nVal = pDlg->GetInputValue();
676cdf0e10cSrcweir 						pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_DIRECT, (sal_uInt16)nVal );
677cdf0e10cSrcweir 
678cdf0e10cSrcweir                         // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
679cdf0e10cSrcweir 						rReq.AppendItem( SfxUInt16Item( FID_COL_WIDTH, (sal_uInt16)TwipsToEvenHMM(nVal)) );
680cdf0e10cSrcweir 						rReq.Done();
681cdf0e10cSrcweir 
682cdf0e10cSrcweir 					}
683cdf0e10cSrcweir 					delete pDlg;
684cdf0e10cSrcweir 				}
685cdf0e10cSrcweir 			}
686cdf0e10cSrcweir 			break;
687cdf0e10cSrcweir 
688cdf0e10cSrcweir 		case FID_COL_OPT_WIDTH:
689cdf0e10cSrcweir 			{
690cdf0e10cSrcweir 				if ( pReqArgs )
691cdf0e10cSrcweir 				{
692cdf0e10cSrcweir 					const SfxUInt16Item&  rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_COL_OPT_WIDTH );
693cdf0e10cSrcweir 
694cdf0e10cSrcweir                     // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
695cdf0e10cSrcweir                     pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_OPTIMAL,
696cdf0e10cSrcweir                                     sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) );
697cdf0e10cSrcweir 					ScGlobal::nLastColWidthExtra = rUInt16Item.GetValue();
698cdf0e10cSrcweir 
699cdf0e10cSrcweir 					if( ! rReq.IsAPI() )
700cdf0e10cSrcweir 						rReq.Done();
701cdf0e10cSrcweir 				}
702cdf0e10cSrcweir 				else
703cdf0e10cSrcweir 				{
704cdf0e10cSrcweir 					FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric();
705cdf0e10cSrcweir 
706cdf0e10cSrcweir //CHINA001					ScMetricInputDlg* pDlg =
707cdf0e10cSrcweir //CHINA001					new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_OPT,
708cdf0e10cSrcweir //CHINA001					ScGlobal::nLastColWidthExtra,
709cdf0e10cSrcweir //CHINA001					STD_EXTRA_WIDTH,
710cdf0e10cSrcweir //CHINA001					eMetric,
711cdf0e10cSrcweir //CHINA001					1,
712cdf0e10cSrcweir //CHINA001					MAX_EXTRA_WIDTH );
713cdf0e10cSrcweir 
714cdf0e10cSrcweir 					ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
715cdf0e10cSrcweir 					DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
716cdf0e10cSrcweir 
717cdf0e10cSrcweir 					AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_OPT,
718cdf0e10cSrcweir 																					ScGlobal::nLastColWidthExtra,
719cdf0e10cSrcweir 																					STD_EXTRA_WIDTH,
720cdf0e10cSrcweir 																					RID_SCDLG_COL_OPT,
721cdf0e10cSrcweir 																					eMetric,
722cdf0e10cSrcweir 																					1,
723cdf0e10cSrcweir 																					MAX_EXTRA_WIDTH);
724cdf0e10cSrcweir 					DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
725cdf0e10cSrcweir 					if ( pDlg->Execute() == RET_OK )
726cdf0e10cSrcweir 					{
727cdf0e10cSrcweir 						long nVal = pDlg->GetInputValue();
728cdf0e10cSrcweir 						pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_OPTIMAL, (sal_uInt16)nVal );
729cdf0e10cSrcweir 						ScGlobal::nLastColWidthExtra = nVal;
730cdf0e10cSrcweir 
731cdf0e10cSrcweir                         // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
732cdf0e10cSrcweir 						rReq.AppendItem( SfxUInt16Item( FID_COL_OPT_WIDTH, (sal_uInt16)TwipsToEvenHMM(nVal) ) );
733cdf0e10cSrcweir 						rReq.Done();
734cdf0e10cSrcweir 					}
735cdf0e10cSrcweir 					delete pDlg;
736cdf0e10cSrcweir 				}
737cdf0e10cSrcweir 			}
738cdf0e10cSrcweir 			break;
739cdf0e10cSrcweir 
740cdf0e10cSrcweir 		case FID_COL_OPT_DIRECT:
741cdf0e10cSrcweir 			pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH );
742cdf0e10cSrcweir 			rReq.Done();
743cdf0e10cSrcweir 			break;
744cdf0e10cSrcweir 
745cdf0e10cSrcweir 		case FID_ROW_HIDE:
746cdf0e10cSrcweir 			pTabViewShell->SetMarkedWidthOrHeight( sal_False, SC_SIZE_DIRECT, 0 );
747cdf0e10cSrcweir 			rReq.Done();
748cdf0e10cSrcweir 			break;
749cdf0e10cSrcweir 		case FID_ROW_SHOW:
750cdf0e10cSrcweir 			pTabViewShell->SetMarkedWidthOrHeight( sal_False, SC_SIZE_SHOW, 0 );
751cdf0e10cSrcweir 			rReq.Done();
752cdf0e10cSrcweir 			break;
753cdf0e10cSrcweir 		case FID_COL_HIDE:
754cdf0e10cSrcweir 			pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_DIRECT, 0 );
755cdf0e10cSrcweir 			rReq.Done();
756cdf0e10cSrcweir 			break;
757cdf0e10cSrcweir 		case FID_COL_SHOW:
758cdf0e10cSrcweir 			pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_SHOW, 0 );
759cdf0e10cSrcweir 			rReq.Done();
760cdf0e10cSrcweir 			break;
761cdf0e10cSrcweir 
762cdf0e10cSrcweir 		//----------------------------------------------------------------
763cdf0e10cSrcweir 
764cdf0e10cSrcweir 
765cdf0e10cSrcweir 		case SID_CELL_FORMAT_RESET:
766cdf0e10cSrcweir 			{
767cdf0e10cSrcweir 				pTabViewShell->DeleteContents( IDF_HARDATTR | IDF_EDITATTR );
768cdf0e10cSrcweir 				rReq.Done();
769cdf0e10cSrcweir 			}
770cdf0e10cSrcweir 			break;
771cdf0e10cSrcweir 
772cdf0e10cSrcweir 		case FID_MERGE_ON:
773cdf0e10cSrcweir         case FID_MERGE_OFF:
774cdf0e10cSrcweir         case FID_MERGE_TOGGLE:
775cdf0e10cSrcweir         {
776cdf0e10cSrcweir             if ( !GetViewData()->GetDocument()->GetChangeTrack() )
777cdf0e10cSrcweir             {
778cdf0e10cSrcweir                 // test whether to merge or to split
779cdf0e10cSrcweir                 bool bMerge = false;
780cdf0e10cSrcweir                 switch( nSlot )
781cdf0e10cSrcweir                 {
782cdf0e10cSrcweir                     case FID_MERGE_ON:
783cdf0e10cSrcweir                         bMerge = true;
784cdf0e10cSrcweir                     break;
785cdf0e10cSrcweir                     case FID_MERGE_OFF:
786cdf0e10cSrcweir                         bMerge = false;
787cdf0e10cSrcweir                     break;
788cdf0e10cSrcweir                     case FID_MERGE_TOGGLE:
789cdf0e10cSrcweir                     {
790cdf0e10cSrcweir                         SfxPoolItem* pItem = 0;
791cdf0e10cSrcweir                         if( rBindings.QueryState( nSlot, pItem ) >= SFX_ITEM_DEFAULT )
792cdf0e10cSrcweir                             bMerge = !static_cast< SfxBoolItem* >( pItem )->GetValue();
793cdf0e10cSrcweir                     }
794cdf0e10cSrcweir                     break;
795cdf0e10cSrcweir                 }
796cdf0e10cSrcweir 
797cdf0e10cSrcweir                 if( bMerge )
798cdf0e10cSrcweir                 {
799cdf0e10cSrcweir                     // merge - check if to move contents of covered cells
800cdf0e10cSrcweir                     sal_Bool bMoveContents = sal_False;
801cdf0e10cSrcweir                     sal_Bool bApi = rReq.IsAPI();
802cdf0e10cSrcweir                     const SfxPoolItem* pItem;
803cdf0e10cSrcweir                     if ( pReqArgs &&
804cdf0e10cSrcweir                         pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET )
805cdf0e10cSrcweir                     {
806cdf0e10cSrcweir                         DBG_ASSERT(pItem && pItem->ISA(SfxBoolItem), "falsches Item");
807cdf0e10cSrcweir                         bMoveContents = ((const SfxBoolItem*)pItem)->GetValue();
808cdf0e10cSrcweir                     }
809cdf0e10cSrcweir 
810cdf0e10cSrcweir                     if (pTabViewShell->MergeCells( bApi, bMoveContents ))
811cdf0e10cSrcweir                     {
812cdf0e10cSrcweir                         if (!bApi && bMoveContents)             // "ja" im Dialog geklickt
813cdf0e10cSrcweir                             rReq.AppendItem( SfxBoolItem( nSlot, bMoveContents ) );
814cdf0e10cSrcweir                         rBindings.Invalidate( nSlot );
815cdf0e10cSrcweir                         rReq.Done();
816cdf0e10cSrcweir                     }
817cdf0e10cSrcweir                 }
818cdf0e10cSrcweir                 else
819cdf0e10cSrcweir                 {
820cdf0e10cSrcweir                     // split cells
821cdf0e10cSrcweir                     if (pTabViewShell->RemoveMerge())
822cdf0e10cSrcweir                     {
823cdf0e10cSrcweir                         rBindings.Invalidate( nSlot );
824cdf0e10cSrcweir                         rReq.Done();
825cdf0e10cSrcweir                     }
826cdf0e10cSrcweir                 }
827cdf0e10cSrcweir                 break;
828cdf0e10cSrcweir             }
829cdf0e10cSrcweir         }
830cdf0e10cSrcweir         break;
831cdf0e10cSrcweir 
832cdf0e10cSrcweir 		case SID_AUTOFORMAT:
833cdf0e10cSrcweir 			{
834cdf0e10cSrcweir 				Window* pDlgParent = pTabViewShell->GetDialogParent();
835cdf0e10cSrcweir 				SCCOL nStartCol;
836cdf0e10cSrcweir 				SCROW nStartRow;
837cdf0e10cSrcweir 				SCTAB nStartTab;
838cdf0e10cSrcweir 				SCCOL nEndCol;
839cdf0e10cSrcweir 				SCROW nEndRow;
840cdf0e10cSrcweir 				SCTAB nEndTab;
841cdf0e10cSrcweir 
842cdf0e10cSrcweir 				const ScMarkData& rMark = GetViewData()->GetMarkData();
843cdf0e10cSrcweir 				if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
844cdf0e10cSrcweir 					pTabViewShell->MarkDataArea( sal_True );
845cdf0e10cSrcweir 
846cdf0e10cSrcweir 				GetViewData()->GetSimpleArea( nStartCol,nStartRow,nStartTab,
847cdf0e10cSrcweir 											  nEndCol,nEndRow,nEndTab );
848cdf0e10cSrcweir 
849cdf0e10cSrcweir 				if (   ( Abs((SCsCOL)nEndCol-(SCsCOL)nStartCol) > 1 )
850cdf0e10cSrcweir 					&& ( Abs((SCsROW)nEndRow-(SCsROW)nStartRow) > 1 ) )
851cdf0e10cSrcweir 				{
852cdf0e10cSrcweir 					if ( pReqArgs )
853cdf0e10cSrcweir 					{
854cdf0e10cSrcweir 						const SfxStringItem& rNameItem = (const SfxStringItem&)pReqArgs->Get( SID_AUTOFORMAT );
855cdf0e10cSrcweir 						ScAutoFormat* pFormat = ScGlobal::GetAutoFormat();
856cdf0e10cSrcweir 						sal_uInt16 nIndex = pFormat->FindIndexPerName( rNameItem.GetValue() );
857cdf0e10cSrcweir 
858cdf0e10cSrcweir 						pTabViewShell->AutoFormat( nIndex );
859cdf0e10cSrcweir 
860cdf0e10cSrcweir 						if( ! rReq.IsAPI() )
861cdf0e10cSrcweir 							rReq.Done();
862cdf0e10cSrcweir 					}
863cdf0e10cSrcweir 					else
864cdf0e10cSrcweir 					{
865cdf0e10cSrcweir 						ScGlobal::ClearAutoFormat();
866cdf0e10cSrcweir 						ScAutoFormatData* pNewEntry = pTabViewShell->CreateAutoFormatData();
867cdf0e10cSrcweir //CHINA001						ScAutoFormatDlg*  pDlg		= new ScAutoFormatDlg(
868cdf0e10cSrcweir //CHINA001						pDlgParent,
869cdf0e10cSrcweir //CHINA001						ScGlobal::GetAutoFormat(),
870cdf0e10cSrcweir //CHINA001						pNewEntry,
871cdf0e10cSrcweir //CHINA001						GetViewData()->GetDocument() );
872cdf0e10cSrcweir 						ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
873cdf0e10cSrcweir 						DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
874cdf0e10cSrcweir 
875cdf0e10cSrcweir 						AbstractScAutoFormatDlg* pDlg = pFact->CreateScAutoFormatDlg( pDlgParent, ScGlobal::GetAutoFormat(), pNewEntry,GetViewData()->GetDocument(), RID_SCDLG_AUTOFORMAT );
876cdf0e10cSrcweir 						DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
877cdf0e10cSrcweir 
878cdf0e10cSrcweir 						if ( pDlg->Execute() == RET_OK )
879cdf0e10cSrcweir 						{
880cdf0e10cSrcweir 							ScEditableTester aTester( pTabViewShell );
881cdf0e10cSrcweir 							if ( !aTester.IsEditable() )
882cdf0e10cSrcweir 							{
883cdf0e10cSrcweir 								pTabViewShell->ErrorMessage(aTester.GetMessageId());
884cdf0e10cSrcweir 							}
885cdf0e10cSrcweir 							else
886cdf0e10cSrcweir 							{
887cdf0e10cSrcweir 								pTabViewShell->AutoFormat( pDlg->GetIndex() );
888cdf0e10cSrcweir 
889cdf0e10cSrcweir 								rReq.AppendItem( SfxStringItem( SID_AUTOFORMAT, pDlg->GetCurrFormatName() ) );
890cdf0e10cSrcweir 								rReq.Done();
891cdf0e10cSrcweir 							}
892cdf0e10cSrcweir 						}
893cdf0e10cSrcweir 						delete pDlg;
894cdf0e10cSrcweir 						delete pNewEntry;
895cdf0e10cSrcweir 					}
896cdf0e10cSrcweir 				}
897cdf0e10cSrcweir 				else
898cdf0e10cSrcweir 					ErrorBox( pDlgParent, WinBits( WB_OK | WB_DEF_OK ),
899cdf0e10cSrcweir 							  ScGlobal::GetRscString(STR_INVALID_AFAREA) ).Execute();
900cdf0e10cSrcweir 			}
901cdf0e10cSrcweir 			break;
902cdf0e10cSrcweir 
903cdf0e10cSrcweir 		case SID_CANCEL:
904cdf0e10cSrcweir 			{
905cdf0e10cSrcweir 				if (GetViewData()->HasEditView(GetViewData()->GetActivePart()))
906cdf0e10cSrcweir 					pScMod->InputCancelHandler();
907cdf0e10cSrcweir                 else if (pTabViewShell->HasPaintBrush())
908cdf0e10cSrcweir                     pTabViewShell->ResetBrushDocument();            // abort format paint brush
909cdf0e10cSrcweir 				else if (pTabViewShell->HasHintWindow())
910cdf0e10cSrcweir 					pTabViewShell->RemoveHintWindow();				// Eingabemeldung abschalten
911cdf0e10cSrcweir                 else if( ScViewUtil::IsFullScreen( *pTabViewShell ) )
912cdf0e10cSrcweir                     ScViewUtil::SetFullScreen( *pTabViewShell, false );
913cdf0e10cSrcweir 				else
914cdf0e10cSrcweir 				{
915cdf0e10cSrcweir                     // TODO/LATER: when is this code executed?
916cdf0e10cSrcweir                     pTabViewShell->Escape();
917cdf0e10cSrcweir                     //SfxObjectShell* pObjSh = GetViewData()->GetSfxDocShell();
918cdf0e10cSrcweir                     //if (pObjSh->GetInPlaceObject() &&
919cdf0e10cSrcweir                     //    pObjSh->GetInPlaceObject()->GetIPClient())
920cdf0e10cSrcweir                     //{
921cdf0e10cSrcweir                     //    GetViewData()->GetDocShell()->
922cdf0e10cSrcweir                     //        DoInPlaceActivate(sal_False);       // OLE beenden
923cdf0e10cSrcweir                     //}
924cdf0e10cSrcweir 				}
925cdf0e10cSrcweir 
926cdf0e10cSrcweir //				SetSumAssignMode(); //ScInputWindow
927cdf0e10cSrcweir 			}
928cdf0e10cSrcweir 			break;
929cdf0e10cSrcweir 
930cdf0e10cSrcweir 		case SID_DATA_SELECT:
931cdf0e10cSrcweir 			pTabViewShell->StartDataSelect();
932cdf0e10cSrcweir 			break;
933cdf0e10cSrcweir 
934cdf0e10cSrcweir 		case SID_DETECTIVE_FILLMODE:
935cdf0e10cSrcweir 			{
936cdf0e10cSrcweir 				sal_Bool bOldMode = pTabViewShell->IsAuditShell();
937cdf0e10cSrcweir 				pTabViewShell->SetAuditShell( !bOldMode );
938cdf0e10cSrcweir 				pTabViewShell->Invalidate( nSlot );
939cdf0e10cSrcweir 			}
940cdf0e10cSrcweir 			break;
941cdf0e10cSrcweir 
942cdf0e10cSrcweir 		case SID_OPENDLG_CONDFRMT:
943cdf0e10cSrcweir 			{
944cdf0e10cSrcweir 				sal_uInt16			nId  = ScCondFormatDlgWrapper::GetChildWindowId();
945cdf0e10cSrcweir 				SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
946cdf0e10cSrcweir 				SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
947cdf0e10cSrcweir 
948cdf0e10cSrcweir 				pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
949cdf0e10cSrcweir 			}
950cdf0e10cSrcweir 			break;
951cdf0e10cSrcweir 
952cdf0e10cSrcweir 		//	----------------------------------------------------------------
953cdf0e10cSrcweir 
954cdf0e10cSrcweir 		case FID_INPUTLINE_STATUS:
955cdf0e10cSrcweir 			DBG_ERROR("Execute von InputLine-Status");
956cdf0e10cSrcweir 			break;
957cdf0e10cSrcweir 
958cdf0e10cSrcweir         case SID_STATUS_DOCPOS:
959cdf0e10cSrcweir             // Launch navigator.
960cdf0e10cSrcweir             GetViewData()->GetDispatcher().Execute(
961cdf0e10cSrcweir                 SID_NAVIGATOR, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
962cdf0e10cSrcweir             break;
963cdf0e10cSrcweir 
964cdf0e10cSrcweir 		case SID_MARKAREA:
965cdf0e10cSrcweir 			// called from Basic at the hidden view to select a range in the visible view
966cdf0e10cSrcweir 			DBG_ERROR("old slot SID_MARKAREA");
967cdf0e10cSrcweir 			break;
968cdf0e10cSrcweir 
969cdf0e10cSrcweir 		default:
970cdf0e10cSrcweir 			DBG_ERROR("Unbekannter Slot bei ScCellShell::Execute");
971cdf0e10cSrcweir 			break;
972cdf0e10cSrcweir 	}
973cdf0e10cSrcweir }
974cdf0e10cSrcweir 
975