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
TwipsToHMM(long nTwips)61 inline long TwipsToHMM(long nTwips) { return (nTwips * 127 + 36) / 72; }
HMMToTwips(long nHMM)62 inline long HMMToTwips(long nHMM) { return (nHMM * 72 + 63) / 127; }
TwipsToEvenHMM(long nTwips)63 inline long TwipsToEvenHMM(long nTwips) { return ( (nTwips * 127 + 72) / 144 ) * 2; }
64
65 //------------------------------------------------------------------
66
Execute(SfxRequest & rReq)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_PROPERTY_PANEL_CELLTEXT_DLG:
364 pTabViewShell->ExecuteCellFormatDlg( rReq, TP_FONT );
365 break;
366
367 case SID_CELL_FORMAT_BORDER:
368 pTabViewShell->ExecuteCellFormatDlg( rReq, TP_BORDER );
369 break;
370
371 case SID_CHAR_DLG_EFFECT:
372 pTabViewShell->ExecuteCellFormatDlg( rReq, TP_FONTEFF );
373 break;
374
375 case SID_OPENDLG_SOLVE:
376 {
377 sal_uInt16 nId = ScSolverDlgWrapper::GetChildWindowId();
378 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
379 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
380
381 pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
382 }
383 break;
384
385 case SID_OPENDLG_OPTSOLVER:
386 {
387 sal_uInt16 nId = ScOptSolverDlgWrapper::GetChildWindowId();
388 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
389 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
390
391 pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
392 }
393 break;
394
395 case SID_OPENDLG_TABOP:
396 {
397 sal_uInt16 nId = ScTabOpDlgWrapper::GetChildWindowId();
398 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
399 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
400
401 pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
402 }
403 break;
404
405 case SID_SCENARIOS:
406 {
407 ScDocument* pDoc = GetViewData()->GetDocument();
408 ScMarkData& rMark = GetViewData()->GetMarkData();
409 SCTAB nTab = GetViewData()->GetTabNo();
410
411 if ( pDoc->IsScenario(nTab) )
412 {
413 rMark.MarkToMulti();
414 if ( rMark.IsMultiMarked() )
415 {
416 if ( rReq.IsAPI()
417 || RET_YES ==
418 QueryBox( pTabViewShell->GetDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
419 ScGlobal::GetRscString(STR_UPDATE_SCENARIO) ).
420 Execute() )
421 {
422 pTabViewShell->ExtendScenario();
423 rReq.Done();
424 }
425 }
426 else if( ! rReq.IsAPI() )
427 {
428 ErrorBox aErrorBox( pTabViewShell->GetDialogParent(), WinBits(WB_OK | WB_DEF_OK),
429 ScGlobal::GetRscString(STR_NOAREASELECTED) );
430 aErrorBox.Execute();
431 }
432 }
433 else
434 {
435 rMark.MarkToMulti();
436 if ( rMark.IsMultiMarked() )
437 {
438 SCTAB i=1;
439 String aBaseName;
440 String aName;
441 String aComment;
442 Color aColor;
443 sal_uInt16 nFlags;
444
445 pDoc->GetName( nTab, aBaseName );
446 aBaseName += '_';
447 aBaseName += ScGlobal::GetRscString(STR_SCENARIO);
448 aBaseName += '_';
449
450 // vorneweg testen, ob der Prefix als gueltig erkannt wird
451 // wenn nicht, nur doppelte vermeiden
452 sal_Bool bPrefix = pDoc->ValidTabName( aBaseName );
453 DBG_ASSERT(bPrefix, "ungueltiger Tabellenname");
454
455 while ( pDoc->IsScenario(nTab+i) )
456 i++;
457
458 sal_Bool bValid;
459 SCTAB nDummy;
460 do
461 {
462 aName = aBaseName;
463 aName += String::CreateFromInt32( i );
464 if (bPrefix)
465 bValid = pDoc->ValidNewTabName( aName );
466 else
467 bValid = !pDoc->GetTable( aName, nDummy );
468 ++i;
469 }
470 while ( !bValid && i <= 2*MAXTAB );
471
472 if ( pReqArgs != NULL )
473 {
474 String aArgName;
475 String aArgComment;
476 const SfxPoolItem* pItem;
477 if ( pReqArgs->GetItemState( SID_SCENARIOS, sal_True, &pItem ) == SFX_ITEM_SET )
478 aArgName = ((const SfxStringItem*)pItem)->GetValue();
479 if ( pReqArgs->GetItemState( SID_NEW_TABLENAME, sal_True, &pItem ) == SFX_ITEM_SET )
480 aArgComment = ((const SfxStringItem*)pItem)->GetValue();
481
482 aColor = Color( COL_LIGHTGRAY ); // Default
483 nFlags = 0; // nicht-TwoWay
484
485 pTabViewShell->MakeScenario( aArgName, aArgComment, aColor, nFlags );
486 if( ! rReq.IsAPI() )
487 rReq.Done();
488 }
489 else
490 {
491 sal_Bool bSheetProtected = pDoc->IsTabProtected(nTab);
492 //CHINA001 ScNewScenarioDlg* pNewDlg =
493 //CHINA001 new ScNewScenarioDlg( pTabViewShell->GetDialogParent(), aName, sal_False, bSheetProtected );
494 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
495 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
496
497 AbstractScNewScenarioDlg* pNewDlg = pFact->CreateScNewScenarioDlg( pTabViewShell->GetDialogParent(), aName, RID_SCDLG_NEWSCENARIO, sal_False,bSheetProtected);
498 DBG_ASSERT(pNewDlg, "Dialog create fail!");//CHINA001
499 if ( pNewDlg->Execute() == RET_OK )
500 {
501 pNewDlg->GetScenarioData( aName, aComment, aColor, nFlags );
502 pTabViewShell->MakeScenario( aName, aComment, aColor, nFlags );
503
504 rReq.AppendItem( SfxStringItem( SID_SCENARIOS, aName ) );
505 rReq.AppendItem( SfxStringItem( SID_NEW_TABLENAME, aComment ) );
506 rReq.Done();
507 }
508 delete pNewDlg;
509 }
510 }
511 else if( ! rReq.IsAPI() )
512 {
513 pTabViewShell->ErrorMessage(STR_ERR_NEWSCENARIO);
514 }
515 }
516 }
517 break;
518
519
520 case SID_SELECTALL:
521 {
522 pTabViewShell->SelectAll();
523 rReq.Done();
524 }
525 break;
526
527 //----------------------------------------------------------------
528
529 case FID_ROW_HEIGHT:
530 {
531 if ( pReqArgs )
532 {
533 const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_ROW_HEIGHT );
534
535 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
536 pTabViewShell->SetMarkedWidthOrHeight( sal_False, SC_SIZE_DIRECT,
537 sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) );
538 if( ! rReq.IsAPI() )
539 rReq.Done();
540 }
541 else
542 {
543 ScViewData* pData = GetViewData();
544 FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric();
545 sal_uInt16 nCurHeight = pData->GetDocument()->
546 GetRowHeight( pData->GetCurY(),
547 pData->GetTabNo() );
548 //CHINA001 ScMetricInputDlg* pDlg =
549 //CHINA001 new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_MAN,
550 //CHINA001 nCurHeight,
551 //CHINA001 ScGlobal::nStdRowHeight,
552 //CHINA001 eMetric,
553 //CHINA001 2,
554 //CHINA001 MAX_COL_HEIGHT );
555 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
556 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
557
558 AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_MAN,
559 nCurHeight,
560 ScGlobal::nStdRowHeight,
561 RID_SCDLG_ROW_MAN,
562 eMetric,
563 2,
564 MAX_COL_HEIGHT);
565 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
566
567 if ( pDlg->Execute() == RET_OK )
568 {
569 long nVal = pDlg->GetInputValue();
570 pTabViewShell->SetMarkedWidthOrHeight( sal_False, SC_SIZE_DIRECT, (sal_uInt16)nVal );
571
572 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
573 rReq.AppendItem( SfxUInt16Item( FID_ROW_HEIGHT, (sal_uInt16)TwipsToEvenHMM(nVal) ) );
574 rReq.Done();
575
576 }
577 delete pDlg;
578 }
579 }
580 break;
581
582 case FID_ROW_OPT_HEIGHT:
583 {
584 if ( pReqArgs )
585 {
586 const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_ROW_OPT_HEIGHT );
587
588 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
589 pTabViewShell->SetMarkedWidthOrHeight( sal_False, SC_SIZE_OPTIMAL,
590 sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) );
591 ScGlobal::nLastRowHeightExtra = rUInt16Item.GetValue();
592
593 if( ! rReq.IsAPI() )
594 rReq.Done();
595 }
596 else
597 {
598 FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric();
599
600 //CHINA001 ScMetricInputDlg* pDlg =
601 //CHINA001 new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_OPT,
602 //CHINA001 ScGlobal::nLastRowHeightExtra,
603 //CHINA001 0,
604 //CHINA001 eMetric,
605 //CHINA001 1,
606 //CHINA001 MAX_EXTRA_HEIGHT );
607 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
608 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
609
610 AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_OPT,
611 ScGlobal::nLastRowHeightExtra,
612 0,
613 RID_SCDLG_ROW_OPT,
614 eMetric,
615 1,
616 MAX_EXTRA_HEIGHT);
617 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
618
619 if ( pDlg->Execute() == RET_OK )
620 {
621 long nVal = pDlg->GetInputValue();
622 pTabViewShell->SetMarkedWidthOrHeight( sal_False, SC_SIZE_OPTIMAL, (sal_uInt16)nVal );
623 ScGlobal::nLastRowHeightExtra = nVal;
624
625 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
626 rReq.AppendItem( SfxUInt16Item( FID_ROW_OPT_HEIGHT, (sal_uInt16)TwipsToEvenHMM(nVal) ) );
627 rReq.Done();
628
629 }
630 delete pDlg;
631 }
632 }
633 break;
634
635 case FID_COL_WIDTH:
636 {
637 if ( pReqArgs )
638 {
639 const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_COL_WIDTH );
640
641 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
642 pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_DIRECT,
643 sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) );
644 if( ! rReq.IsAPI() )
645 rReq.Done();
646 }
647 else
648 {
649 FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric();
650 ScViewData* pData = GetViewData();
651 sal_uInt16 nCurHeight = pData->GetDocument()->
652 GetColWidth( pData->GetCurX(),
653 pData->GetTabNo() );
654 //CHINA001 ScMetricInputDlg* pDlg =
655 //CHINA001 new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_MAN,
656 //CHINA001 nCurHeight,
657 //CHINA001 STD_COL_WIDTH,
658 //CHINA001 eMetric,
659 //CHINA001 2,
660 //CHINA001 MAX_COL_WIDTH );
661 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
662 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
663
664 AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_MAN,
665 nCurHeight,
666 STD_COL_WIDTH,
667 RID_SCDLG_COL_MAN,
668 eMetric,
669 2,
670 MAX_COL_WIDTH);
671 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
672
673 if ( pDlg->Execute() == RET_OK )
674 {
675 long nVal = pDlg->GetInputValue();
676 pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_DIRECT, (sal_uInt16)nVal );
677
678 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
679 rReq.AppendItem( SfxUInt16Item( FID_COL_WIDTH, (sal_uInt16)TwipsToEvenHMM(nVal)) );
680 rReq.Done();
681
682 }
683 delete pDlg;
684 }
685 }
686 break;
687
688 case FID_COL_OPT_WIDTH:
689 {
690 if ( pReqArgs )
691 {
692 const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_COL_OPT_WIDTH );
693
694 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
695 pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_OPTIMAL,
696 sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) );
697 ScGlobal::nLastColWidthExtra = rUInt16Item.GetValue();
698
699 if( ! rReq.IsAPI() )
700 rReq.Done();
701 }
702 else
703 {
704 FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric();
705
706 //CHINA001 ScMetricInputDlg* pDlg =
707 //CHINA001 new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_OPT,
708 //CHINA001 ScGlobal::nLastColWidthExtra,
709 //CHINA001 STD_EXTRA_WIDTH,
710 //CHINA001 eMetric,
711 //CHINA001 1,
712 //CHINA001 MAX_EXTRA_WIDTH );
713
714 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
715 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
716
717 AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_OPT,
718 ScGlobal::nLastColWidthExtra,
719 STD_EXTRA_WIDTH,
720 RID_SCDLG_COL_OPT,
721 eMetric,
722 1,
723 MAX_EXTRA_WIDTH);
724 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
725 if ( pDlg->Execute() == RET_OK )
726 {
727 long nVal = pDlg->GetInputValue();
728 pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_OPTIMAL, (sal_uInt16)nVal );
729 ScGlobal::nLastColWidthExtra = nVal;
730
731 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
732 rReq.AppendItem( SfxUInt16Item( FID_COL_OPT_WIDTH, (sal_uInt16)TwipsToEvenHMM(nVal) ) );
733 rReq.Done();
734 }
735 delete pDlg;
736 }
737 }
738 break;
739
740 case FID_COL_OPT_DIRECT:
741 pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH );
742 rReq.Done();
743 break;
744
745 case FID_ROW_HIDE:
746 pTabViewShell->SetMarkedWidthOrHeight( sal_False, SC_SIZE_DIRECT, 0 );
747 rReq.Done();
748 break;
749 case FID_ROW_SHOW:
750 pTabViewShell->SetMarkedWidthOrHeight( sal_False, SC_SIZE_SHOW, 0 );
751 rReq.Done();
752 break;
753 case FID_COL_HIDE:
754 pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_DIRECT, 0 );
755 rReq.Done();
756 break;
757 case FID_COL_SHOW:
758 pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_SHOW, 0 );
759 rReq.Done();
760 break;
761
762 //----------------------------------------------------------------
763
764
765 case SID_CELL_FORMAT_RESET:
766 {
767 pTabViewShell->DeleteContents( IDF_HARDATTR | IDF_EDITATTR );
768 rReq.Done();
769 }
770 break;
771
772 case FID_MERGE_ON:
773 case FID_MERGE_OFF:
774 case FID_MERGE_TOGGLE:
775 {
776 if ( !GetViewData()->GetDocument()->GetChangeTrack() )
777 {
778 // test whether to merge or to split
779 bool bMerge = false;
780 switch( nSlot )
781 {
782 case FID_MERGE_ON:
783 bMerge = true;
784 break;
785 case FID_MERGE_OFF:
786 bMerge = false;
787 break;
788 case FID_MERGE_TOGGLE:
789 {
790 SfxPoolItem* pItem = 0;
791 if( rBindings.QueryState( nSlot, pItem ) >= SFX_ITEM_DEFAULT )
792 bMerge = !static_cast< SfxBoolItem* >( pItem )->GetValue();
793 }
794 break;
795 }
796
797 if( bMerge )
798 {
799 // merge - check if to move contents of covered cells
800 sal_Bool bMoveContents = sal_False;
801 sal_Bool bApi = rReq.IsAPI();
802 const SfxPoolItem* pItem;
803 if ( pReqArgs &&
804 pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET )
805 {
806 DBG_ASSERT(pItem && pItem->ISA(SfxBoolItem), "falsches Item");
807 bMoveContents = ((const SfxBoolItem*)pItem)->GetValue();
808 }
809
810 if (pTabViewShell->MergeCells( bApi, bMoveContents ))
811 {
812 if (!bApi && bMoveContents) // "ja" im Dialog geklickt
813 rReq.AppendItem( SfxBoolItem( nSlot, bMoveContents ) );
814 rBindings.Invalidate( nSlot );
815 rReq.Done();
816 }
817 }
818 else
819 {
820 // split cells
821 if (pTabViewShell->RemoveMerge())
822 {
823 rBindings.Invalidate( nSlot );
824 rReq.Done();
825 }
826 }
827 break;
828 }
829 }
830 break;
831
832 case SID_AUTOFORMAT:
833 {
834 Window* pDlgParent = pTabViewShell->GetDialogParent();
835 SCCOL nStartCol;
836 SCROW nStartRow;
837 SCTAB nStartTab;
838 SCCOL nEndCol;
839 SCROW nEndRow;
840 SCTAB nEndTab;
841
842 const ScMarkData& rMark = GetViewData()->GetMarkData();
843 if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
844 pTabViewShell->MarkDataArea( sal_True );
845
846 GetViewData()->GetSimpleArea( nStartCol,nStartRow,nStartTab,
847 nEndCol,nEndRow,nEndTab );
848
849 if ( ( Abs((SCsCOL)nEndCol-(SCsCOL)nStartCol) > 1 )
850 && ( Abs((SCsROW)nEndRow-(SCsROW)nStartRow) > 1 ) )
851 {
852 if ( pReqArgs )
853 {
854 const SfxStringItem& rNameItem = (const SfxStringItem&)pReqArgs->Get( SID_AUTOFORMAT );
855 ScAutoFormat* pFormat = ScGlobal::GetAutoFormat();
856 sal_uInt16 nIndex = pFormat->FindIndexPerName( rNameItem.GetValue() );
857
858 pTabViewShell->AutoFormat( nIndex );
859
860 if( ! rReq.IsAPI() )
861 rReq.Done();
862 }
863 else
864 {
865 ScGlobal::ClearAutoFormat();
866 ScAutoFormatData* pNewEntry = pTabViewShell->CreateAutoFormatData();
867 //CHINA001 ScAutoFormatDlg* pDlg = new ScAutoFormatDlg(
868 //CHINA001 pDlgParent,
869 //CHINA001 ScGlobal::GetAutoFormat(),
870 //CHINA001 pNewEntry,
871 //CHINA001 GetViewData()->GetDocument() );
872 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
873 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
874
875 AbstractScAutoFormatDlg* pDlg = pFact->CreateScAutoFormatDlg( pDlgParent, ScGlobal::GetAutoFormat(), pNewEntry,GetViewData()->GetDocument(), RID_SCDLG_AUTOFORMAT );
876 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
877
878 if ( pDlg->Execute() == RET_OK )
879 {
880 ScEditableTester aTester( pTabViewShell );
881 if ( !aTester.IsEditable() )
882 {
883 pTabViewShell->ErrorMessage(aTester.GetMessageId());
884 }
885 else
886 {
887 pTabViewShell->AutoFormat( pDlg->GetIndex() );
888
889 rReq.AppendItem( SfxStringItem( SID_AUTOFORMAT, pDlg->GetCurrFormatName() ) );
890 rReq.Done();
891 }
892 }
893 delete pDlg;
894 delete pNewEntry;
895 }
896 }
897 else
898 ErrorBox( pDlgParent, WinBits( WB_OK | WB_DEF_OK ),
899 ScGlobal::GetRscString(STR_INVALID_AFAREA) ).Execute();
900 }
901 break;
902
903 case SID_CANCEL:
904 {
905 if (GetViewData()->HasEditView(GetViewData()->GetActivePart()))
906 pScMod->InputCancelHandler();
907 else if (pTabViewShell->HasPaintBrush())
908 pTabViewShell->ResetBrushDocument(); // abort format paint brush
909 else if (pTabViewShell->HasHintWindow())
910 pTabViewShell->RemoveHintWindow(); // Eingabemeldung abschalten
911 else if( ScViewUtil::IsFullScreen( *pTabViewShell ) )
912 ScViewUtil::SetFullScreen( *pTabViewShell, false );
913 else
914 {
915 // TODO/LATER: when is this code executed?
916 pTabViewShell->Escape();
917 //SfxObjectShell* pObjSh = GetViewData()->GetSfxDocShell();
918 //if (pObjSh->GetInPlaceObject() &&
919 // pObjSh->GetInPlaceObject()->GetIPClient())
920 //{
921 // GetViewData()->GetDocShell()->
922 // DoInPlaceActivate(sal_False); // OLE beenden
923 //}
924 }
925
926 // SetSumAssignMode(); //ScInputWindow
927 }
928 break;
929
930 case SID_DATA_SELECT:
931 pTabViewShell->StartDataSelect();
932 break;
933
934 case SID_DETECTIVE_FILLMODE:
935 {
936 sal_Bool bOldMode = pTabViewShell->IsAuditShell();
937 pTabViewShell->SetAuditShell( !bOldMode );
938 pTabViewShell->Invalidate( nSlot );
939 }
940 break;
941
942 case SID_OPENDLG_CONDFRMT:
943 {
944 sal_uInt16 nId = ScCondFormatDlgWrapper::GetChildWindowId();
945 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
946 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
947
948 pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
949 }
950 break;
951
952 // ----------------------------------------------------------------
953
954 case FID_INPUTLINE_STATUS:
955 DBG_ERROR("Execute von InputLine-Status");
956 break;
957
958 case SID_STATUS_DOCPOS:
959 // Launch navigator.
960 GetViewData()->GetDispatcher().Execute(
961 SID_NAVIGATOR, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
962 break;
963
964 case SID_MARKAREA:
965 // called from Basic at the hidden view to select a range in the visible view
966 DBG_ERROR("old slot SID_MARKAREA");
967 break;
968
969 default:
970 DBG_ERROR("Unbekannter Slot bei ScCellShell::Execute");
971 break;
972 }
973 }
974
975