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"
48 #include "appoptio.hxx"
49 #include "tabvwsh.hxx"
50 #include "document.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"
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
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
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
);
122 case SID_ATTR_SIZE
://XXX ???
125 case SID_STATUS_SELMODE
:
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();
136 case 1: nMode
= KEY_SHIFT
; break;
137 case 2: nMode
= KEY_MOD1
; break; // Control-Taste
143 pTabViewShell
->LockModifiers( nMode
);
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
);
164 // SID_STATUS_SELMODE_NORM wird nicht benutzt ???
166 case SID_STATUS_SELMODE_NORM
:
167 pTabViewShell
->LockModifiers( 0 );
168 rBindings
.Invalidate( SID_STATUS_SELMODE
);
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 );
177 pTabViewShell
->LockModifiers( KEY_MOD1
);
178 rBindings
.Invalidate( SID_STATUS_SELMODE
);
181 case SID_STATUS_SELMODE_ERW
:
182 if ( pTabViewShell
->GetLockedModifiers() & KEY_SHIFT
)
183 pTabViewShell
->LockModifiers( 0 );
185 pTabViewShell
->LockModifiers( KEY_SHIFT
);
186 rBindings
.Invalidate( SID_STATUS_SELMODE
);
189 case SID_ENTER_STRING
:
193 String
aStr( ((const SfxStringItem
&)pReqArgs
->
194 Get( SID_ENTER_STRING
)).GetValue() );
196 pTabViewShell
->EnterData( GetViewData()->GetCurX(),
197 GetViewData()->GetCurY(),
198 GetViewData()->GetTabNo(),
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();
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)
220 case SID_INSERT_MATRIX
:
224 String aStr
= ((const SfxStringItem
&)pReqArgs
->
225 Get( SID_INSERT_MATRIX
)).GetValue();
226 pTabViewShell
->EnterMatrix( aStr
);
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
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();
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
);
258 pTabViewShell
->EnterData( aCursorPos
.Col(), aCursorPos
.Row(), aCursorPos
.Tab(), pData
);
263 if (nSlot
== FID_INPUTLINE_ENTER
)
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];
277 rBindings
.Execute( SID_ENTER_STRING
, aArgs
);
281 pTabViewShell
->EnterData( aCursorPos
.Col(),
288 else if (nSlot
== FID_INPUTLINE_BLOCK
)
290 pTabViewShell
->EnterBlock( aString
, NULL
);
295 pTabViewShell
->EnterMatrix( aString
);
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)
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
);
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
);
328 case FID_CELL_FORMAT
:
330 if ( pReqArgs
!= NULL
)
332 //----------------------------------
333 // Zellattribute ohne Dialog setzen:
334 //----------------------------------
335 SfxItemSet
* pEmptySet
=
336 new SfxItemSet( *pReqArgs
->GetPool(),
340 SfxItemSet
* pNewSet
=
341 new SfxItemSet( *pReqArgs
->GetPool(),
345 const SfxPoolItem
* pAttr
= NULL
;
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
);
359 else if ( pReqArgs
== NULL
)
361 pTabViewShell
->ExecuteCellFormatDlg( rReq
);
366 case SID_ENABLE_HYPHENATION
:
367 pTabViewShell
->ExecuteCellFormatDlg( rReq
, TP_ALIGNMENT
);
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
);
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
);
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
);
402 ScDocument
* pDoc
= GetViewData()->GetDocument();
403 ScMarkData
& rMark
= GetViewData()->GetMarkData();
404 SCTAB nTab
= GetViewData()->GetTabNo();
406 if ( pDoc
->IsScenario(nTab
) )
409 if ( rMark
.IsMultiMarked() )
413 QueryBox( pTabViewShell
->GetDialogParent(), WinBits(WB_YES_NO
| WB_DEF_YES
),
414 ScGlobal::GetRscString(STR_UPDATE_SCENARIO
) ).
417 pTabViewShell
->ExtendScenario();
421 else if( ! rReq
.IsAPI() )
423 ErrorBox
aErrorBox( pTabViewShell
->GetDialogParent(), WinBits(WB_OK
| WB_DEF_OK
),
424 ScGlobal::GetRscString(STR_NOAREASELECTED
) );
431 if ( rMark
.IsMultiMarked() )
440 pDoc
->GetName( nTab
, aBaseName
);
442 aBaseName
+= ScGlobal::GetRscString(STR_SCENARIO
);
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
) )
458 aName
+= String::CreateFromInt32( i
);
460 bValid
= pDoc
->ValidNewTabName( aName
);
462 bValid
= !pDoc
->GetTable( aName
, nDummy
);
465 while ( !bValid
&& i
<= 2*MAXTAB
);
467 if ( pReqArgs
!= NULL
)
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
);
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
) );
506 else if( ! rReq
.IsAPI() )
508 pTabViewShell
->ErrorMessage(STR_ERR_NEWSCENARIO
);
517 pTabViewShell
->SelectAll();
522 //----------------------------------------------------------------
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()) ) );
538 ScViewData
* pData
= GetViewData();
539 FieldUnit eMetric
= SC_MOD()->GetAppOptions().GetAppMetric();
540 USHORT nCurHeight
= pData
->GetDocument()->
541 GetRowHeight( pData
->GetCurY(),
543 //CHINA001 ScMetricInputDlg* pDlg =
544 //CHINA001 new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_MAN,
545 //CHINA001 nCurHeight,
546 //CHINA001 ScGlobal::nStdRowHeight,
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
,
555 ScGlobal::nStdRowHeight
,
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
) ) );
577 case FID_ROW_OPT_HEIGHT
:
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();
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,
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
,
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
) ) );
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()) ) );
644 FieldUnit eMetric
= SC_MOD()->GetAppOptions().GetAppMetric();
645 ScViewData
* pData
= GetViewData();
646 USHORT nCurHeight
= pData
->GetDocument()->
647 GetColWidth( pData
->GetCurX(),
649 //CHINA001 ScMetricInputDlg* pDlg =
650 //CHINA001 new ScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_MAN,
651 //CHINA001 nCurHeight,
652 //CHINA001 STD_COL_WIDTH,
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
,
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
)) );
683 case FID_COL_OPT_WIDTH
:
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();
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,
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
,
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
) ) );
735 case FID_COL_OPT_DIRECT
:
736 pTabViewShell
->SetMarkedWidthOrHeight( TRUE
, SC_SIZE_OPTIMAL
, STD_EXTRA_WIDTH
);
741 pTabViewShell
->SetMarkedWidthOrHeight( FALSE
, SC_SIZE_DIRECT
, 0 );
745 pTabViewShell
->SetMarkedWidthOrHeight( FALSE
, SC_SIZE_SHOW
, 0 );
749 pTabViewShell
->SetMarkedWidthOrHeight( TRUE
, SC_SIZE_DIRECT
, 0 );
753 pTabViewShell
->SetMarkedWidthOrHeight( TRUE
, SC_SIZE_SHOW
, 0 );
757 //----------------------------------------------------------------
760 case SID_CELL_FORMAT_RESET
:
762 pTabViewShell
->DeleteContents( IDF_HARDATTR
| IDF_EDITATTR
);
769 case FID_MERGE_TOGGLE
:
771 if ( !GetViewData()->GetDocument()->GetChangeTrack() )
773 // test whether to merge or to split
775 BOOL bCenter
= FALSE
;
784 case FID_MERGE_TOGGLE
:
787 SfxPoolItem
* pItem
= 0;
788 if( rBindings
.QueryState( nSlot
, pItem
) >= SFX_ITEM_DEFAULT
)
789 bMerge
= !static_cast< SfxBoolItem
* >( pItem
)->GetValue();
796 // merge - check if to move contents of covered cells
797 BOOL bMoveContents
= FALSE
;
798 BOOL bApi
= rReq
.IsAPI();
799 const SfxPoolItem
* pItem
;
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
);
818 if (pTabViewShell
->RemoveMerge())
820 rBindings
.Invalidate( nSlot
);
831 Window
* pDlgParent
= pTabViewShell
->GetDialogParent();
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 ) )
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
);
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());
884 pTabViewShell
->AutoFormat( pDlg
->GetIndex() );
886 rReq
.AppendItem( SfxStringItem( SID_AUTOFORMAT
, pDlg
->GetCurrFormatName() ) );
895 ErrorBox( pDlgParent
, WinBits( WB_OK
| WB_DEF_OK
),
896 ScGlobal::GetRscString(STR_INVALID_AFAREA
) ).Execute();
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 );
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
927 case SID_DATA_SELECT
:
928 pTabViewShell
->StartDataSelect();
931 case SID_DETECTIVE_FILLMODE
:
933 BOOL bOldMode
= pTabViewShell
->IsAuditShell();
934 pTabViewShell
->SetAuditShell( !bOldMode
);
935 pTabViewShell
->Invalidate( nSlot
);
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
);
949 // ----------------------------------------------------------------
951 case FID_INPUTLINE_STATUS
:
952 DBG_ERROR("Execute von InputLine-Status");
955 case SID_STATUS_DOCPOS
:
957 GetViewData()->GetDispatcher().Execute(
958 SID_NAVIGATOR
, SFX_CALLMODE_SYNCHRON
|SFX_CALLMODE_RECORD
);
962 // called from Basic at the hidden view to select a range in the visible view
963 DBG_ERROR("old slot SID_MARKAREA");
967 DBG_ERROR("Unbekannter Slot bei ScCellShell::Execute");