update dev300-m58
[ooovba.git] / sc / source / ui / view / cellsh3.cxx
blobc57a30768c0f9c323dd176002f526cf85cd5a168
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cellsh3.cxx,v $
10 * $Revision: 1.24.90.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 // INCLUDE ---------------------------------------------------------------
38 #include "scitems.hxx"
39 #include <sfx2/viewfrm.hxx>
40 #include <sfx2/bindings.hxx>
41 #include <sfx2/dispatch.hxx>
42 #include <sfx2/request.hxx>
43 #include <svtools/stritem.hxx>
44 #include <vcl/msgbox.hxx>
45 #include <sfx2/app.hxx>
46 #include "globstr.hrc"
47 #include "scmod.hxx"
48 #include "appoptio.hxx"
49 #include "tabvwsh.hxx"
50 #include "document.hxx"
51 #include "sc.hrc"
52 #include "docsh.hxx"
53 #include "reffact.hxx"
54 #include "uiitems.hxx"
55 //CHINA001 #include "scendlg.hxx"
56 //CHINA001 #include "mtrindlg.hxx"
57 #include "autoform.hxx"
58 #include "autofmt.hxx"
59 #include "cellsh.hxx"
60 #include "attrdlg.hrc" // TP_ALIGNMENT
61 #include "inputhdl.hxx"
62 #include "editable.hxx"
64 #include "scabstdlg.hxx" //CHINA001
66 #define IS_EDITMODE() GetViewData()->HasEditView( GetViewData()->GetActivePart() )
68 inline long TwipsToHMM(long nTwips) { return (nTwips * 127 + 36) / 72; }
69 inline long HMMToTwips(long nHMM) { return (nHMM * 72 + 63) / 127; }
70 inline long TwipsToEvenHMM(long nTwips) { return ( (nTwips * 127 + 72) / 144 ) * 2; }
72 //------------------------------------------------------------------
74 void ScCellShell::Execute( SfxRequest& rReq )
76 ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
77 SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings();
78 ScModule* pScMod = SC_MOD();
79 const SfxItemSet* pReqArgs = rReq.GetArgs();
80 USHORT nSlot = rReq.GetSlot();
82 if (nSlot != SID_CURRENTCELL) // der kommt beim MouseButtonUp
83 pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
85 if ( IS_EDITMODE() )
87 switch ( nSlot )
89 // beim Oeffnen eines Referenz-Dialogs darf die SubShell nicht umgeschaltet werden
90 // (beim Schliessen des Dialogs wird StopEditShell gerufen)
91 case SID_OPENDLG_FUNCTION:
92 // #53318# inplace macht die EditShell Aerger...
93 //! kann nicht immer umgeschaltet werden ????
94 if (!pTabViewShell->GetViewFrame()->GetFrame()->IsInPlace())
95 pTabViewShell->SetDontSwitch(TRUE); // EditShell nicht abschalten
96 // kein break
98 case FID_CELL_FORMAT:
99 case SID_ENABLE_HYPHENATION:
100 case SID_DATA_SELECT:
101 case SID_OPENDLG_CONSOLIDATE:
102 case SID_OPENDLG_SOLVE:
103 case SID_OPENDLG_OPTSOLVER:
105 pScMod->InputEnterHandler();
106 pTabViewShell->UpdateInputHandler();
108 pTabViewShell->SetDontSwitch(FALSE);
110 break;
112 default:
113 break;
117 switch ( nSlot )
122 case SID_ATTR_SIZE://XXX ???
123 break;
125 case SID_STATUS_SELMODE:
126 if ( pReqArgs )
128 /* 0: STD Click hebt Sel auf
129 * 1: ER Click erweitert Selektion
130 * 2: ERG Click definiert weitere Selektion
132 UINT16 nMode = ((const SfxUInt16Item&)pReqArgs->Get( nSlot )).GetValue();
134 switch ( nMode )
136 case 1: nMode = KEY_SHIFT; break;
137 case 2: nMode = KEY_MOD1; break; // Control-Taste
138 case 0:
139 default:
140 nMode = 0;
143 pTabViewShell->LockModifiers( nMode );
145 else
147 // no arguments (also executed by double click on the status bar controller):
148 // advance to next selection mode
150 USHORT nModifiers = pTabViewShell->GetLockedModifiers();
151 switch ( nModifiers )
153 case KEY_SHIFT: nModifiers = KEY_MOD1; break; // EXT -> ADD
154 case KEY_MOD1: nModifiers = 0; break; // ADD -> STD
155 default: nModifiers = KEY_SHIFT; break; // STD -> EXT
157 pTabViewShell->LockModifiers( nModifiers );
160 rBindings.Invalidate( SID_STATUS_SELMODE );
161 rReq.Done();
162 break;
164 // SID_STATUS_SELMODE_NORM wird nicht benutzt ???
166 case SID_STATUS_SELMODE_NORM:
167 pTabViewShell->LockModifiers( 0 );
168 rBindings.Invalidate( SID_STATUS_SELMODE );
169 break;
171 // SID_STATUS_SELMODE_ERG / SID_STATUS_SELMODE_ERW als Toggles:
173 case SID_STATUS_SELMODE_ERG:
174 if ( pTabViewShell->GetLockedModifiers() & KEY_MOD1 )
175 pTabViewShell->LockModifiers( 0 );
176 else
177 pTabViewShell->LockModifiers( KEY_MOD1 );
178 rBindings.Invalidate( SID_STATUS_SELMODE );
179 break;
181 case SID_STATUS_SELMODE_ERW:
182 if ( pTabViewShell->GetLockedModifiers() & KEY_SHIFT )
183 pTabViewShell->LockModifiers( 0 );
184 else
185 pTabViewShell->LockModifiers( KEY_SHIFT );
186 rBindings.Invalidate( SID_STATUS_SELMODE );
187 break;
189 case SID_ENTER_STRING:
191 if ( pReqArgs )
193 String aStr( ((const SfxStringItem&)pReqArgs->
194 Get( SID_ENTER_STRING )).GetValue() );
196 pTabViewShell->EnterData( GetViewData()->GetCurX(),
197 GetViewData()->GetCurY(),
198 GetViewData()->GetTabNo(),
199 aStr );
201 ScInputHandler* pHdl = SC_MOD()->GetInputHdl( pTabViewShell );
202 if ( !pHdl || !pHdl->IsInEnterHandler() )
204 // #101061# UpdateInputHandler is needed after the cell content
205 // has changed, but if called from EnterHandler, UpdateInputHandler
206 // will be called later when moving the cursor.
208 pTabViewShell->UpdateInputHandler();
211 rReq.Done();
213 // hier kein GrabFocus, weil sonst auf dem Mac die Tabelle vor die
214 // Seitenansicht springt, wenn die Eingabe nicht abgeschlossen war
215 // (GrabFocus passiert in KillEditView)
218 break;
220 case SID_INSERT_MATRIX:
222 if ( pReqArgs )
224 String aStr = ((const SfxStringItem&)pReqArgs->
225 Get( SID_INSERT_MATRIX )).GetValue();
226 pTabViewShell->EnterMatrix( aStr );
227 rReq.Done();
230 break;
232 case FID_INPUTLINE_ENTER:
233 case FID_INPUTLINE_BLOCK:
234 case FID_INPUTLINE_MATRIX:
236 if( pReqArgs == 0 ) //XXX vorlaufiger HACK um GPF zu vermeiden
237 break;
239 const ScInputStatusItem* pStatusItem
240 = (const ScInputStatusItem*)&pReqArgs->
241 Get( FID_INPUTLINE_STATUS );
243 ScAddress aCursorPos = pStatusItem->GetPos();
244 String aString = pStatusItem->GetString();
245 const EditTextObject* pData = pStatusItem->GetEditData();
246 if (pData)
248 if (nSlot == FID_INPUTLINE_BLOCK)
250 pTabViewShell->EnterBlock( String(), pData );
252 else if ( aString.Len() > 0 && ( aString.GetChar(0) == '=' || aString.GetChar(0) == '+' || aString.GetChar(0) == '-' ) )
254 pTabViewShell->EnterData( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(), aString, TRUE, pData );
256 else
258 pTabViewShell->EnterData( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(), pData );
261 else
263 if (nSlot == FID_INPUTLINE_ENTER)
265 if (
266 aCursorPos.Col() == GetViewData()->GetCurX() &&
267 aCursorPos.Row() == GetViewData()->GetCurY() &&
268 aCursorPos.Tab() == GetViewData()->GetTabNo()
271 SfxStringItem aItem( SID_ENTER_STRING, aString );
273 // SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings();
274 const SfxPoolItem* aArgs[2];
275 aArgs[0] = &aItem;
276 aArgs[1] = NULL;
277 rBindings.Execute( SID_ENTER_STRING, aArgs );
279 else
281 pTabViewShell->EnterData( aCursorPos.Col(),
282 aCursorPos.Row(),
283 aCursorPos.Tab(),
284 aString );
285 rReq.Done();
288 else if (nSlot == FID_INPUTLINE_BLOCK)
290 pTabViewShell->EnterBlock( aString, NULL );
291 rReq.Done();
293 else
295 pTabViewShell->EnterMatrix( aString );
296 rReq.Done();
301 // hier kein GrabFocus, weil sonst auf dem Mac die Tabelle vor die
302 // Seitenansicht springt, wenn die Eingabe nicht abgeschlossen war
303 // (GrabFocus passiert in KillEditView)
305 break;
307 case SID_OPENDLG_FUNCTION:
309 USHORT nId = SID_OPENDLG_FUNCTION;
310 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
311 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
313 pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
314 rReq.Ignore();
316 break;
318 case SID_OPENDLG_CONSOLIDATE:
320 USHORT nId = ScConsolidateDlgWrapper::GetChildWindowId();
321 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
322 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
324 pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
326 break;
328 case FID_CELL_FORMAT:
330 if ( pReqArgs != NULL )
332 //----------------------------------
333 // Zellattribute ohne Dialog setzen:
334 //----------------------------------
335 SfxItemSet* pEmptySet =
336 new SfxItemSet( *pReqArgs->GetPool(),
337 ATTR_PATTERN_START,
338 ATTR_PATTERN_END );
340 SfxItemSet* pNewSet =
341 new SfxItemSet( *pReqArgs->GetPool(),
342 ATTR_PATTERN_START,
343 ATTR_PATTERN_END );
345 const SfxPoolItem* pAttr = NULL;
346 USHORT nWhich = 0;
348 for ( nWhich=ATTR_PATTERN_START; nWhich<=ATTR_PATTERN_END; nWhich++ )
349 if ( pReqArgs->GetItemState( nWhich, TRUE, &pAttr ) == SFX_ITEM_SET )
350 pNewSet->Put( *pAttr );
352 pTabViewShell->ApplyAttributes( pNewSet, pEmptySet );
354 delete pNewSet;
355 delete pEmptySet;
357 rReq.Done();
359 else if ( pReqArgs == NULL )
361 pTabViewShell->ExecuteCellFormatDlg( rReq );
364 break;
366 case SID_ENABLE_HYPHENATION:
367 pTabViewShell->ExecuteCellFormatDlg( rReq, TP_ALIGNMENT );
368 break;
370 case SID_OPENDLG_SOLVE:
372 USHORT nId = ScSolverDlgWrapper::GetChildWindowId();
373 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
374 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
376 pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
378 break;
380 case SID_OPENDLG_OPTSOLVER:
382 USHORT nId = ScOptSolverDlgWrapper::GetChildWindowId();
383 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
384 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
386 pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
388 break;
390 case SID_OPENDLG_TABOP:
392 USHORT nId = ScTabOpDlgWrapper::GetChildWindowId();
393 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
394 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
396 pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
398 break;
400 case SID_SCENARIOS:
402 ScDocument* pDoc = GetViewData()->GetDocument();
403 ScMarkData& rMark = GetViewData()->GetMarkData();
404 SCTAB nTab = GetViewData()->GetTabNo();
406 if ( pDoc->IsScenario(nTab) )
408 rMark.MarkToMulti();
409 if ( rMark.IsMultiMarked() )
411 if ( rReq.IsAPI()
412 || RET_YES ==
413 QueryBox( pTabViewShell->GetDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
414 ScGlobal::GetRscString(STR_UPDATE_SCENARIO) ).
415 Execute() )
417 pTabViewShell->ExtendScenario();
418 rReq.Done();
421 else if( ! rReq.IsAPI() )
423 ErrorBox aErrorBox( pTabViewShell->GetDialogParent(), WinBits(WB_OK | WB_DEF_OK),
424 ScGlobal::GetRscString(STR_NOAREASELECTED) );
425 aErrorBox.Execute();
428 else
430 rMark.MarkToMulti();
431 if ( rMark.IsMultiMarked() )
433 SCTAB i=1;
434 String aBaseName;
435 String aName;
436 String aComment;
437 Color aColor;
438 USHORT nFlags;
440 pDoc->GetName( nTab, aBaseName );
441 aBaseName += '_';
442 aBaseName += ScGlobal::GetRscString(STR_SCENARIO);
443 aBaseName += '_';
445 // vorneweg testen, ob der Prefix als gueltig erkannt wird
446 // wenn nicht, nur doppelte vermeiden
447 BOOL bPrefix = pDoc->ValidTabName( aBaseName );
448 DBG_ASSERT(bPrefix, "ungueltiger Tabellenname");
450 while ( pDoc->IsScenario(nTab+i) )
451 i++;
453 BOOL bValid;
454 SCTAB nDummy;
457 aName = aBaseName;
458 aName += String::CreateFromInt32( i );
459 if (bPrefix)
460 bValid = pDoc->ValidNewTabName( aName );
461 else
462 bValid = !pDoc->GetTable( aName, nDummy );
463 ++i;
465 while ( !bValid && i <= 2*MAXTAB );
467 if ( pReqArgs != NULL )
469 String aArgName;
470 String aArgComment;
471 const SfxPoolItem* pItem;
472 if ( pReqArgs->GetItemState( SID_SCENARIOS, TRUE, &pItem ) == SFX_ITEM_SET )
473 aArgName = ((const SfxStringItem*)pItem)->GetValue();
474 if ( pReqArgs->GetItemState( SID_NEW_TABLENAME, TRUE, &pItem ) == SFX_ITEM_SET )
475 aArgComment = ((const SfxStringItem*)pItem)->GetValue();
477 aColor = Color( COL_LIGHTGRAY ); // Default
478 nFlags = 0; // nicht-TwoWay
480 pTabViewShell->MakeScenario( aArgName, aArgComment, aColor, nFlags );
481 if( ! rReq.IsAPI() )
482 rReq.Done();
484 else
486 BOOL bSheetProtected = pDoc->IsTabProtected(nTab);
487 //CHINA001 ScNewScenarioDlg* pNewDlg =
488 //CHINA001 new ScNewScenarioDlg( pTabViewShell->GetDialogParent(), aName, FALSE, bSheetProtected );
489 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
490 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
492 AbstractScNewScenarioDlg* pNewDlg = pFact->CreateScNewScenarioDlg( pTabViewShell->GetDialogParent(), aName, RID_SCDLG_NEWSCENARIO, FALSE,bSheetProtected);
493 DBG_ASSERT(pNewDlg, "Dialog create fail!");//CHINA001
494 if ( pNewDlg->Execute() == RET_OK )
496 pNewDlg->GetScenarioData( aName, aComment, aColor, nFlags );
497 pTabViewShell->MakeScenario( aName, aComment, aColor, nFlags );
499 rReq.AppendItem( SfxStringItem( SID_SCENARIOS, aName ) );
500 rReq.AppendItem( SfxStringItem( SID_NEW_TABLENAME, aComment ) );
501 rReq.Done();
503 delete pNewDlg;
506 else if( ! rReq.IsAPI() )
508 pTabViewShell->ErrorMessage(STR_ERR_NEWSCENARIO);
512 break;
515 case SID_SELECTALL:
517 pTabViewShell->SelectAll();
518 rReq.Done();
520 break;
522 //----------------------------------------------------------------
524 case FID_ROW_HEIGHT:
526 if ( pReqArgs )
528 const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_ROW_HEIGHT );
530 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
531 pTabViewShell->SetMarkedWidthOrHeight( FALSE, SC_SIZE_DIRECT,
532 sal::static_int_cast<USHORT>( HMMToTwips(rUInt16Item.GetValue()) ) );
533 if( ! rReq.IsAPI() )
534 rReq.Done();
536 else
538 ScViewData* pData = GetViewData();
539 FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric();
540 USHORT nCurHeight = pData->GetDocument()->
541 GetRowHeight( pData->GetCurY(),
542 pData->GetTabNo() );
543 //CHINA001 ScMetricInputDlg* pDlg =
544 //CHINA001 new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_MAN,
545 //CHINA001 nCurHeight,
546 //CHINA001 ScGlobal::nStdRowHeight,
547 //CHINA001 eMetric,
548 //CHINA001 2,
549 //CHINA001 MAX_COL_HEIGHT );
550 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
551 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
553 AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_MAN,
554 nCurHeight,
555 ScGlobal::nStdRowHeight,
556 RID_SCDLG_ROW_MAN,
557 eMetric,
559 MAX_COL_HEIGHT);
560 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
562 if ( pDlg->Execute() == RET_OK )
564 long nVal = pDlg->GetInputValue();
565 pTabViewShell->SetMarkedWidthOrHeight( FALSE, SC_SIZE_DIRECT, (USHORT)nVal );
567 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
568 rReq.AppendItem( SfxUInt16Item( FID_ROW_HEIGHT, (USHORT)TwipsToEvenHMM(nVal) ) );
569 rReq.Done();
572 delete pDlg;
575 break;
577 case FID_ROW_OPT_HEIGHT:
579 if ( pReqArgs )
581 const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_ROW_OPT_HEIGHT );
583 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
584 pTabViewShell->SetMarkedWidthOrHeight( FALSE, SC_SIZE_OPTIMAL,
585 sal::static_int_cast<USHORT>( HMMToTwips(rUInt16Item.GetValue()) ) );
586 ScGlobal::nLastRowHeightExtra = rUInt16Item.GetValue();
588 if( ! rReq.IsAPI() )
589 rReq.Done();
591 else
593 FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric();
595 //CHINA001 ScMetricInputDlg* pDlg =
596 //CHINA001 new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_OPT,
597 //CHINA001 ScGlobal::nLastRowHeightExtra,
598 //CHINA001 0,
599 //CHINA001 eMetric,
600 //CHINA001 1,
601 //CHINA001 MAX_EXTRA_HEIGHT );
602 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
603 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
605 AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_OPT,
606 ScGlobal::nLastRowHeightExtra,
608 RID_SCDLG_ROW_OPT,
609 eMetric,
611 MAX_EXTRA_HEIGHT);
612 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
614 if ( pDlg->Execute() == RET_OK )
616 long nVal = pDlg->GetInputValue();
617 pTabViewShell->SetMarkedWidthOrHeight( FALSE, SC_SIZE_OPTIMAL, (USHORT)nVal );
618 ScGlobal::nLastRowHeightExtra = nVal;
620 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
621 rReq.AppendItem( SfxUInt16Item( FID_ROW_OPT_HEIGHT, (USHORT)TwipsToEvenHMM(nVal) ) );
622 rReq.Done();
625 delete pDlg;
628 break;
630 case FID_COL_WIDTH:
632 if ( pReqArgs )
634 const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_COL_WIDTH );
636 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
637 pTabViewShell->SetMarkedWidthOrHeight( TRUE, SC_SIZE_DIRECT,
638 sal::static_int_cast<USHORT>( HMMToTwips(rUInt16Item.GetValue()) ) );
639 if( ! rReq.IsAPI() )
640 rReq.Done();
642 else
644 FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric();
645 ScViewData* pData = GetViewData();
646 USHORT nCurHeight = pData->GetDocument()->
647 GetColWidth( pData->GetCurX(),
648 pData->GetTabNo() );
649 //CHINA001 ScMetricInputDlg* pDlg =
650 //CHINA001 new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_MAN,
651 //CHINA001 nCurHeight,
652 //CHINA001 STD_COL_WIDTH,
653 //CHINA001 eMetric,
654 //CHINA001 2,
655 //CHINA001 MAX_COL_WIDTH );
656 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
657 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
659 AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_MAN,
660 nCurHeight,
661 STD_COL_WIDTH,
662 RID_SCDLG_COL_MAN,
663 eMetric,
665 MAX_COL_WIDTH);
666 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
668 if ( pDlg->Execute() == RET_OK )
670 long nVal = pDlg->GetInputValue();
671 pTabViewShell->SetMarkedWidthOrHeight( TRUE, SC_SIZE_DIRECT, (USHORT)nVal );
673 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
674 rReq.AppendItem( SfxUInt16Item( FID_COL_WIDTH, (USHORT)TwipsToEvenHMM(nVal)) );
675 rReq.Done();
678 delete pDlg;
681 break;
683 case FID_COL_OPT_WIDTH:
685 if ( pReqArgs )
687 const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_COL_OPT_WIDTH );
689 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
690 pTabViewShell->SetMarkedWidthOrHeight( TRUE, SC_SIZE_OPTIMAL,
691 sal::static_int_cast<USHORT>( HMMToTwips(rUInt16Item.GetValue()) ) );
692 ScGlobal::nLastColWidthExtra = rUInt16Item.GetValue();
694 if( ! rReq.IsAPI() )
695 rReq.Done();
697 else
699 FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric();
701 //CHINA001 ScMetricInputDlg* pDlg =
702 //CHINA001 new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_OPT,
703 //CHINA001 ScGlobal::nLastColWidthExtra,
704 //CHINA001 STD_EXTRA_WIDTH,
705 //CHINA001 eMetric,
706 //CHINA001 1,
707 //CHINA001 MAX_EXTRA_WIDTH );
709 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
710 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
712 AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_OPT,
713 ScGlobal::nLastColWidthExtra,
714 STD_EXTRA_WIDTH,
715 RID_SCDLG_COL_OPT,
716 eMetric,
718 MAX_EXTRA_WIDTH);
719 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
720 if ( pDlg->Execute() == RET_OK )
722 long nVal = pDlg->GetInputValue();
723 pTabViewShell->SetMarkedWidthOrHeight( TRUE, SC_SIZE_OPTIMAL, (USHORT)nVal );
724 ScGlobal::nLastColWidthExtra = nVal;
726 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
727 rReq.AppendItem( SfxUInt16Item( FID_COL_OPT_WIDTH, (USHORT)TwipsToEvenHMM(nVal) ) );
728 rReq.Done();
730 delete pDlg;
733 break;
735 case FID_COL_OPT_DIRECT:
736 pTabViewShell->SetMarkedWidthOrHeight( TRUE, SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH );
737 rReq.Done();
738 break;
740 case FID_ROW_HIDE:
741 pTabViewShell->SetMarkedWidthOrHeight( FALSE, SC_SIZE_DIRECT, 0 );
742 rReq.Done();
743 break;
744 case FID_ROW_SHOW:
745 pTabViewShell->SetMarkedWidthOrHeight( FALSE, SC_SIZE_SHOW, 0 );
746 rReq.Done();
747 break;
748 case FID_COL_HIDE:
749 pTabViewShell->SetMarkedWidthOrHeight( TRUE, SC_SIZE_DIRECT, 0 );
750 rReq.Done();
751 break;
752 case FID_COL_SHOW:
753 pTabViewShell->SetMarkedWidthOrHeight( TRUE, SC_SIZE_SHOW, 0 );
754 rReq.Done();
755 break;
757 //----------------------------------------------------------------
760 case SID_CELL_FORMAT_RESET:
762 pTabViewShell->DeleteContents( IDF_HARDATTR | IDF_EDITATTR );
763 rReq.Done();
765 break;
767 case FID_MERGE_ON:
768 case FID_MERGE_OFF:
769 case FID_MERGE_TOGGLE:
771 if ( !GetViewData()->GetDocument()->GetChangeTrack() )
773 // test whether to merge or to split
774 bool bMerge = false;
775 BOOL bCenter = FALSE;
776 switch( nSlot )
778 case FID_MERGE_ON:
779 bMerge = true;
780 break;
781 case FID_MERGE_OFF:
782 bMerge = false;
783 break;
784 case FID_MERGE_TOGGLE:
786 bCenter = TRUE;
787 SfxPoolItem* pItem = 0;
788 if( rBindings.QueryState( nSlot, pItem ) >= SFX_ITEM_DEFAULT )
789 bMerge = !static_cast< SfxBoolItem* >( pItem )->GetValue();
791 break;
794 if( bMerge )
796 // merge - check if to move contents of covered cells
797 BOOL bMoveContents = FALSE;
798 BOOL bApi = rReq.IsAPI();
799 const SfxPoolItem* pItem;
800 if ( pReqArgs &&
801 pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET )
803 DBG_ASSERT(pItem && pItem->ISA(SfxBoolItem), "falsches Item");
804 bMoveContents = ((const SfxBoolItem*)pItem)->GetValue();
807 if (pTabViewShell->MergeCells( bApi, bMoveContents, TRUE, bCenter ))
809 if (!bApi && bMoveContents) // "ja" im Dialog geklickt
810 rReq.AppendItem( SfxBoolItem( nSlot, bMoveContents ) );
811 rBindings.Invalidate( nSlot );
812 rReq.Done();
815 else
817 // split cells
818 if (pTabViewShell->RemoveMerge())
820 rBindings.Invalidate( nSlot );
821 rReq.Done();
824 break;
827 break;
829 case SID_AUTOFORMAT:
831 Window* pDlgParent = pTabViewShell->GetDialogParent();
832 SCCOL nStartCol;
833 SCROW nStartRow;
834 SCTAB nStartTab;
835 SCCOL nEndCol;
836 SCROW nEndRow;
837 SCTAB nEndTab;
839 const ScMarkData& rMark = GetViewData()->GetMarkData();
840 if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
841 pTabViewShell->MarkDataArea( TRUE );
843 GetViewData()->GetSimpleArea( nStartCol,nStartRow,nStartTab,
844 nEndCol,nEndRow,nEndTab );
846 if ( ( Abs((SCsCOL)nEndCol-(SCsCOL)nStartCol) > 1 )
847 && ( Abs((SCsROW)nEndRow-(SCsROW)nStartRow) > 1 ) )
849 if ( pReqArgs )
851 const SfxStringItem& rNameItem = (const SfxStringItem&)pReqArgs->Get( SID_AUTOFORMAT );
852 ScAutoFormat* pFormat = ScGlobal::GetAutoFormat();
853 USHORT nIndex = pFormat->FindIndexPerName( rNameItem.GetValue() );
855 pTabViewShell->AutoFormat( nIndex );
857 if( ! rReq.IsAPI() )
858 rReq.Done();
860 else
862 ScGlobal::ClearAutoFormat();
863 ScAutoFormatData* pNewEntry = pTabViewShell->CreateAutoFormatData();
864 //CHINA001 ScAutoFormatDlg* pDlg = new ScAutoFormatDlg(
865 //CHINA001 pDlgParent,
866 //CHINA001 ScGlobal::GetAutoFormat(),
867 //CHINA001 pNewEntry,
868 //CHINA001 GetViewData()->GetDocument() );
869 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
870 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
872 AbstractScAutoFormatDlg* pDlg = pFact->CreateScAutoFormatDlg( pDlgParent, ScGlobal::GetAutoFormat(), pNewEntry,GetViewData()->GetDocument(), RID_SCDLG_AUTOFORMAT );
873 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
875 if ( pDlg->Execute() == RET_OK )
877 ScEditableTester aTester( pTabViewShell );
878 if ( !aTester.IsEditable() )
880 pTabViewShell->ErrorMessage(aTester.GetMessageId());
882 else
884 pTabViewShell->AutoFormat( pDlg->GetIndex() );
886 rReq.AppendItem( SfxStringItem( SID_AUTOFORMAT, pDlg->GetCurrFormatName() ) );
887 rReq.Done();
890 delete pDlg;
891 delete pNewEntry;
894 else
895 ErrorBox( pDlgParent, WinBits( WB_OK | WB_DEF_OK ),
896 ScGlobal::GetRscString(STR_INVALID_AFAREA) ).Execute();
898 break;
900 case SID_CANCEL:
902 if (GetViewData()->HasEditView(GetViewData()->GetActivePart()))
903 pScMod->InputCancelHandler();
904 else if (pTabViewShell->HasPaintBrush())
905 pTabViewShell->ResetBrushDocument(); // abort format paint brush
906 else if (pTabViewShell->HasHintWindow())
907 pTabViewShell->RemoveHintWindow(); // Eingabemeldung abschalten
908 else if( ScViewUtil::IsFullScreen( *pTabViewShell ) )
909 ScViewUtil::SetFullScreen( *pTabViewShell, false );
910 else
912 // TODO/LATER: when is this code executed?
913 pTabViewShell->Escape();
914 //SfxObjectShell* pObjSh = GetViewData()->GetSfxDocShell();
915 //if (pObjSh->GetInPlaceObject() &&
916 // pObjSh->GetInPlaceObject()->GetIPClient())
918 // GetViewData()->GetDocShell()->
919 // DoInPlaceActivate(FALSE); // OLE beenden
923 // SetSumAssignMode(); //ScInputWindow
925 break;
927 case SID_DATA_SELECT:
928 pTabViewShell->StartDataSelect();
929 break;
931 case SID_DETECTIVE_FILLMODE:
933 BOOL bOldMode = pTabViewShell->IsAuditShell();
934 pTabViewShell->SetAuditShell( !bOldMode );
935 pTabViewShell->Invalidate( nSlot );
937 break;
939 case SID_OPENDLG_CONDFRMT:
941 USHORT nId = ScCondFormatDlgWrapper::GetChildWindowId();
942 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
943 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
945 pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
947 break;
949 // ----------------------------------------------------------------
951 case FID_INPUTLINE_STATUS:
952 DBG_ERROR("Execute von InputLine-Status");
953 break;
955 case SID_STATUS_DOCPOS:
956 // Launch navigator.
957 GetViewData()->GetDispatcher().Execute(
958 SID_NAVIGATOR, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
959 break;
961 case SID_MARKAREA:
962 // called from Basic at the hidden view to select a range in the visible view
963 DBG_ERROR("old slot SID_MARKAREA");
964 break;
966 default:
967 DBG_ERROR("Unbekannter Slot bei ScCellShell::Execute");
968 break;