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