1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "scitems.hxx"
21 #include <sfx2/viewfrm.hxx>
22 #include <sfx2/bindings.hxx>
23 #include <sfx2/dispatch.hxx>
24 #include <sfx2/request.hxx>
25 #include <svl/stritem.hxx>
26 #include <vcl/msgbox.hxx>
27 #include <sfx2/app.hxx>
28 #include "globstr.hrc"
30 #include "appoptio.hxx"
31 #include "tabvwsh.hxx"
32 #include "document.hxx"
35 #include "reffact.hxx"
36 #include "uiitems.hxx"
37 #include "autoform.hxx"
38 #include "autofmt.hxx"
40 #include "inputhdl.hxx"
41 #include "editable.hxx"
42 #include "markdata.hxx"
43 #include "scabstdlg.hxx"
45 #include <config_telepathy.h>
48 #include "sccollaboration.hxx"
51 #define IS_EDITMODE() GetViewData()->HasEditView( GetViewData()->GetActivePart() )
55 using sc::TwipsToEvenHMM
;
57 //------------------------------------------------------------------
59 void ScCellShell::Execute( SfxRequest
& rReq
)
61 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
62 SfxBindings
& rBindings
= pTabViewShell
->GetViewFrame()->GetBindings();
63 ScModule
* pScMod
= SC_MOD();
64 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
65 sal_uInt16 nSlot
= rReq
.GetSlot();
67 if (nSlot
!= SID_CURRENTCELL
) // this comes with MouseButtonUp
68 pTabViewShell
->HideListBox(); // Autofilter-DropDown-Listbox
74 // when opening a reference-dialog the subshell may not be switched
75 // (on closing the dialog StopEditShell is called)
76 case SID_OPENDLG_FUNCTION
:
77 // inplace leads to trouble with EditShell ...
78 //! cannot always be switched werden ????
79 if (!pTabViewShell
->GetViewFrame()->GetFrame().IsInPlace())
80 pTabViewShell
->SetDontSwitch(sal_True
); // do not switch off EditShell
84 case SID_ENABLE_HYPHENATION
:
86 case SID_OPENDLG_CONSOLIDATE
:
87 case SID_OPENDLG_SOLVE
:
88 case SID_OPENDLG_OPTSOLVER
:
90 pScMod
->InputEnterHandler();
91 pTabViewShell
->UpdateInputHandler();
93 pTabViewShell
->SetDontSwitch(false);
104 case SID_ATTR_SIZE
://XXX ???
107 case SID_COLLABORATION
:
109 GetViewData()->GetDocShell()->GetCollaboration()->DisplayContacts();
113 case SID_STATUS_SELMODE
:
116 /* 0: STD Click cancels selection
117 * 1: ER Click extends selection
118 * 2: ERG Click defines further selection
120 sal_uInt16 nMode
= ((const SfxUInt16Item
&)pReqArgs
->Get( nSlot
)).GetValue();
124 case 1: nMode
= KEY_SHIFT
; break;
125 case 2: nMode
= KEY_MOD1
; break; // control-key
131 pTabViewShell
->LockModifiers( nMode
);
135 // no arguments (also executed by double click on the status bar controller):
136 // advance to next selection mode
138 sal_uInt16 nModifiers
= pTabViewShell
->GetLockedModifiers();
139 switch ( nModifiers
)
141 case KEY_SHIFT
: nModifiers
= KEY_MOD1
; break; // EXT -> ADD
142 case KEY_MOD1
: nModifiers
= 0; break; // ADD -> STD
143 default: nModifiers
= KEY_SHIFT
; break; // STD -> EXT
145 pTabViewShell
->LockModifiers( nModifiers
);
148 rBindings
.Invalidate( SID_STATUS_SELMODE
);
152 // SID_STATUS_SELMODE_NORM is not used ???
154 case SID_STATUS_SELMODE_NORM
:
155 pTabViewShell
->LockModifiers( 0 );
156 rBindings
.Invalidate( SID_STATUS_SELMODE
);
159 // SID_STATUS_SELMODE_ERG / SID_STATUS_SELMODE_ERW as toggles:
161 case SID_STATUS_SELMODE_ERG
:
162 if ( pTabViewShell
->GetLockedModifiers() & KEY_MOD1
)
163 pTabViewShell
->LockModifiers( 0 );
165 pTabViewShell
->LockModifiers( KEY_MOD1
);
166 rBindings
.Invalidate( SID_STATUS_SELMODE
);
169 case SID_STATUS_SELMODE_ERW
:
170 if ( pTabViewShell
->GetLockedModifiers() & KEY_SHIFT
)
171 pTabViewShell
->LockModifiers( 0 );
173 pTabViewShell
->LockModifiers( KEY_SHIFT
);
174 rBindings
.Invalidate( SID_STATUS_SELMODE
);
177 case SID_ENTER_STRING
:
181 OUString
aStr( ((const SfxStringItem
&)pReqArgs
->
182 Get( SID_ENTER_STRING
)).GetValue() );
184 pTabViewShell
->EnterData( GetViewData()->GetCurX(),
185 GetViewData()->GetCurY(),
186 GetViewData()->GetTabNo(),
189 ScInputHandler
* pHdl
= SC_MOD()->GetInputHdl( pTabViewShell
);
190 if ( !pHdl
|| !pHdl
->IsInEnterHandler() )
192 // UpdateInputHandler is needed after the cell content
193 // has changed, but if called from EnterHandler, UpdateInputHandler
194 // will be called later when moving the cursor.
196 pTabViewShell
->UpdateInputHandler();
201 // no GrabFocus here, as otherwise on a Mac the tab jumps before the
202 // sideview, when the input was not finished
203 // (GrabFocus is called in KillEditView)
208 case SID_INSERT_MATRIX
:
212 OUString aStr
= ((const SfxStringItem
&)pReqArgs
->
213 Get( SID_INSERT_MATRIX
)).GetValue();
214 ScDocument
* pDoc
= GetViewData()->GetDocument();
215 pTabViewShell
->EnterMatrix( aStr
, pDoc
->GetGrammar() );
221 case FID_INPUTLINE_ENTER
:
222 case FID_INPUTLINE_BLOCK
:
223 case FID_INPUTLINE_MATRIX
:
225 if( pReqArgs
== 0 ) //XXX temporary HACK to avoid GPF
228 const ScInputStatusItem
* pStatusItem
229 = (const ScInputStatusItem
*)&pReqArgs
->
230 Get( FID_INPUTLINE_STATUS
);
232 ScAddress aCursorPos
= pStatusItem
->GetPos();
233 OUString aString
= pStatusItem
->GetString();
234 const EditTextObject
* pData
= pStatusItem
->GetEditData();
238 if (nSlot
== FID_INPUTLINE_BLOCK
)
240 pTabViewShell
->EnterBlock( aString
, pData
);
242 else if ( !aString
.isEmpty() && ( aString
[0] == '=' || aString
[0] == '+' || aString
[0] == '-' ) )
244 pTabViewShell
->EnterData( aCursorPos
.Col(), aCursorPos
.Row(), aCursorPos
.Tab(), aString
, pData
);
248 pTabViewShell
->EnterData(aCursorPos
.Col(), aCursorPos
.Row(), aCursorPos
.Tab(), *pData
);
253 if (nSlot
== FID_INPUTLINE_ENTER
)
256 aCursorPos
.Col() == GetViewData()->GetCurX() &&
257 aCursorPos
.Row() == GetViewData()->GetCurY() &&
258 aCursorPos
.Tab() == GetViewData()->GetTabNo()
261 SfxStringItem
aItem( SID_ENTER_STRING
, aString
);
263 // SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings();
264 const SfxPoolItem
* aArgs
[2];
267 rBindings
.Execute( SID_ENTER_STRING
, aArgs
);
271 pTabViewShell
->EnterData( aCursorPos
.Col(),
278 else if (nSlot
== FID_INPUTLINE_BLOCK
)
280 pTabViewShell
->EnterBlock( aString
, NULL
);
285 ScDocument
* pDoc
= GetViewData()->GetDocument();
286 pTabViewShell
->EnterMatrix( aString
, pDoc
->GetGrammar() );
291 pTabViewShell
->SetAutoSpellData(
292 aCursorPos
.Col(), aCursorPos
.Row(), pStatusItem
->GetMisspellRanges());
294 // no GrabFocus here, as otherwise on a Mac the tab jumps before the
295 // sideview, when the input was not finished
296 // (GrabFocus is called in KillEditView)
300 case SID_OPENDLG_FUNCTION
:
302 sal_uInt16 nId
= SID_OPENDLG_FUNCTION
;
303 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
304 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
306 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
311 case SID_OPENDLG_CONSOLIDATE
:
313 sal_uInt16 nId
= ScConsolidateDlgWrapper::GetChildWindowId();
314 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
315 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
317 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
321 case FID_CELL_FORMAT
:
323 if ( pReqArgs
!= NULL
)
325 //----------------------------------
326 // set cell attribute without dialog:
327 //----------------------------------
328 SfxItemSet
* pEmptySet
=
329 new SfxItemSet( *pReqArgs
->GetPool(),
333 SfxItemSet
* pNewSet
=
334 new SfxItemSet( *pReqArgs
->GetPool(),
338 const SfxPoolItem
* pAttr
= NULL
;
339 sal_uInt16 nWhich
= 0;
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
);
345 pTabViewShell
->ApplyAttributes( pNewSet
, pEmptySet
);
352 else if ( pReqArgs
== NULL
)
354 pTabViewShell
->ExecuteCellFormatDlg( rReq
);
359 case SID_ENABLE_HYPHENATION
:
360 pTabViewShell
->ExecuteCellFormatDlg(rReq
, "alignment");
363 case SID_PROPERTY_PANEL_CELLTEXT_DLG
:
364 pTabViewShell
->ExecuteCellFormatDlg( rReq
, "font" );
367 case SID_CELL_FORMAT_BORDER
:
368 pTabViewShell
->ExecuteCellFormatDlg( rReq
, "borders" );
371 case SID_CHAR_DLG_EFFECT
:
372 pTabViewShell
->ExecuteCellFormatDlg( rReq
, "fonteffects" );
375 case SID_OPENDLG_SOLVE
:
377 sal_uInt16 nId
= ScSolverDlgWrapper::GetChildWindowId();
378 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
379 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
381 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
385 case SID_OPENDLG_OPTSOLVER
:
387 sal_uInt16 nId
= ScOptSolverDlgWrapper::GetChildWindowId();
388 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
389 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
391 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
395 case SID_OPENDLG_TABOP
:
397 sal_uInt16 nId
= ScTabOpDlgWrapper::GetChildWindowId();
398 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
399 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
401 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
407 ScDocument
* pDoc
= GetViewData()->GetDocument();
408 ScMarkData
& rMark
= GetViewData()->GetMarkData();
409 SCTAB nTab
= GetViewData()->GetTabNo();
411 if ( pDoc
->IsScenario(nTab
) )
414 if ( rMark
.IsMultiMarked() )
418 QueryBox( pTabViewShell
->GetDialogParent(), WinBits(WB_YES_NO
| WB_DEF_YES
),
419 ScGlobal::GetRscString(STR_UPDATE_SCENARIO
) ).
422 pTabViewShell
->ExtendScenario();
426 else if( ! rReq
.IsAPI() )
428 ErrorBox
aErrorBox( pTabViewShell
->GetDialogParent(), WinBits(WB_OK
| WB_DEF_OK
),
429 ScGlobal::GetRscString(STR_NOAREASELECTED
) );
436 if ( rMark
.IsMultiMarked() )
446 pDoc
->GetName(nTab
, aTmp
);
449 aBaseName
+= ScGlobal::GetRscString(STR_SCENARIO
);
452 // first test, if the prefix is recognised as valid,
453 // else avoid only doubles
454 sal_Bool bPrefix
= pDoc
->ValidTabName( aBaseName
);
455 OSL_ENSURE(bPrefix
, "ungueltiger Tabellenname");
457 while ( pDoc
->IsScenario(nTab
+i
) )
464 aName
= aBaseName
+ OUString::number( i
);
466 bValid
= pDoc
->ValidNewTabName( aName
);
468 bValid
= !pDoc
->GetTable( aName
, nDummy
);
471 while ( !bValid
&& i
<= MAXTAB
+ 2 );
473 if ( pReqArgs
!= NULL
)
476 OUString aArgComment
;
477 const SfxPoolItem
* pItem
;
478 if ( pReqArgs
->GetItemState( SID_SCENARIOS
, sal_True
, &pItem
) == SFX_ITEM_SET
)
479 aArgName
= ((const SfxStringItem
*)pItem
)->GetValue();
480 if ( pReqArgs
->GetItemState( SID_NEW_TABLENAME
, sal_True
, &pItem
) == SFX_ITEM_SET
)
481 aArgComment
= ((const SfxStringItem
*)pItem
)->GetValue();
483 aColor
= Color( COL_LIGHTGRAY
); // Default
484 nFlags
= 0; // not-TwoWay
486 pTabViewShell
->MakeScenario( aArgName
, aArgComment
, aColor
, nFlags
);
492 sal_Bool bSheetProtected
= pDoc
->IsTabProtected(nTab
);
493 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
494 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
496 AbstractScNewScenarioDlg
* pNewDlg
= pFact
->CreateScNewScenarioDlg( pTabViewShell
->GetDialogParent(), aName
, RID_SCDLG_NEWSCENARIO
, false,bSheetProtected
);
497 OSL_ENSURE(pNewDlg
, "Dialog create fail!");
498 if ( pNewDlg
->Execute() == RET_OK
)
500 pNewDlg
->GetScenarioData( aName
, aComment
, aColor
, nFlags
);
501 pTabViewShell
->MakeScenario( aName
, aComment
, aColor
, nFlags
);
503 rReq
.AppendItem( SfxStringItem( SID_SCENARIOS
, aName
) );
504 rReq
.AppendItem( SfxStringItem( SID_NEW_TABLENAME
, aComment
) );
510 else if( ! rReq
.IsAPI() )
512 pTabViewShell
->ErrorMessage(STR_ERR_NEWSCENARIO
);
521 pTabViewShell
->SelectAll();
526 //----------------------------------------------------------------
532 const SfxUInt16Item
& rUInt16Item
= (const SfxUInt16Item
&)pReqArgs
->Get( FID_ROW_HEIGHT
);
534 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
535 pTabViewShell
->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT
,
536 sal::static_int_cast
<sal_uInt16
>( HMMToTwips(rUInt16Item
.GetValue()) ) );
542 ScViewData
* pData
= GetViewData();
543 FieldUnit eMetric
= SC_MOD()->GetAppOptions().GetAppMetric();
544 sal_uInt16 nCurHeight
= pData
->GetDocument()->
545 GetRowHeight( pData
->GetCurY(),
547 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
548 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
550 AbstractScMetricInputDlg
* pDlg
= pFact
->CreateScMetricInputDlg( pTabViewShell
->GetDialogParent(), RID_SCDLG_ROW_MAN
,
552 ScGlobal::nStdRowHeight
,
557 OSL_ENSURE(pDlg
, "Dialog create fail!");
559 if ( pDlg
->Execute() == RET_OK
)
561 long nVal
= pDlg
->GetInputValue();
562 pTabViewShell
->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT
, (sal_uInt16
)nVal
);
564 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
565 rReq
.AppendItem( SfxUInt16Item( FID_ROW_HEIGHT
, (sal_uInt16
)TwipsToEvenHMM(nVal
) ) );
574 case FID_ROW_OPT_HEIGHT
:
578 const SfxUInt16Item
& rUInt16Item
= (const SfxUInt16Item
&)pReqArgs
->Get( FID_ROW_OPT_HEIGHT
);
580 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
581 pTabViewShell
->SetMarkedWidthOrHeight( false, SC_SIZE_OPTIMAL
,
582 sal::static_int_cast
<sal_uInt16
>( HMMToTwips(rUInt16Item
.GetValue()) ) );
583 ScGlobal::nLastRowHeightExtra
= rUInt16Item
.GetValue();
590 FieldUnit eMetric
= SC_MOD()->GetAppOptions().GetAppMetric();
592 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
593 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
595 AbstractScMetricInputDlg
* pDlg
= pFact
->CreateScMetricInputDlg( pTabViewShell
->GetDialogParent(), RID_SCDLG_ROW_OPT
,
596 ScGlobal::nLastRowHeightExtra
,
602 OSL_ENSURE(pDlg
, "Dialog create fail!");
604 if ( pDlg
->Execute() == RET_OK
)
606 long nVal
= pDlg
->GetInputValue();
607 pTabViewShell
->SetMarkedWidthOrHeight( false, SC_SIZE_OPTIMAL
, (sal_uInt16
)nVal
);
608 ScGlobal::nLastRowHeightExtra
= nVal
;
610 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
611 rReq
.AppendItem( SfxUInt16Item( FID_ROW_OPT_HEIGHT
, (sal_uInt16
)TwipsToEvenHMM(nVal
) ) );
624 const SfxUInt16Item
& rUInt16Item
= (const SfxUInt16Item
&)pReqArgs
->Get( FID_COL_WIDTH
);
626 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
627 pTabViewShell
->SetMarkedWidthOrHeight( sal_True
, SC_SIZE_DIRECT
,
628 sal::static_int_cast
<sal_uInt16
>( HMMToTwips(rUInt16Item
.GetValue()) ) );
634 FieldUnit eMetric
= SC_MOD()->GetAppOptions().GetAppMetric();
635 ScViewData
* pData
= GetViewData();
636 sal_uInt16 nCurHeight
= pData
->GetDocument()->
637 GetColWidth( pData
->GetCurX(),
639 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
640 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
642 AbstractScMetricInputDlg
* pDlg
= pFact
->CreateScMetricInputDlg( pTabViewShell
->GetDialogParent(), RID_SCDLG_COL_MAN
,
649 OSL_ENSURE(pDlg
, "Dialog create fail!");
651 if ( pDlg
->Execute() == RET_OK
)
653 long nVal
= pDlg
->GetInputValue();
654 pTabViewShell
->SetMarkedWidthOrHeight( sal_True
, SC_SIZE_DIRECT
, (sal_uInt16
)nVal
);
656 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
657 rReq
.AppendItem( SfxUInt16Item( FID_COL_WIDTH
, (sal_uInt16
)TwipsToEvenHMM(nVal
)) );
666 case FID_COL_OPT_WIDTH
:
670 const SfxUInt16Item
& rUInt16Item
= (const SfxUInt16Item
&)pReqArgs
->Get( FID_COL_OPT_WIDTH
);
672 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
673 pTabViewShell
->SetMarkedWidthOrHeight( sal_True
, SC_SIZE_OPTIMAL
,
674 sal::static_int_cast
<sal_uInt16
>( HMMToTwips(rUInt16Item
.GetValue()) ) );
675 ScGlobal::nLastColWidthExtra
= rUInt16Item
.GetValue();
682 FieldUnit eMetric
= SC_MOD()->GetAppOptions().GetAppMetric();
684 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
685 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
687 AbstractScMetricInputDlg
* pDlg
= pFact
->CreateScMetricInputDlg( pTabViewShell
->GetDialogParent(), RID_SCDLG_COL_OPT
,
688 ScGlobal::nLastColWidthExtra
,
694 OSL_ENSURE(pDlg
, "Dialog create fail!");
695 if ( pDlg
->Execute() == RET_OK
)
697 long nVal
= pDlg
->GetInputValue();
698 pTabViewShell
->SetMarkedWidthOrHeight( sal_True
, SC_SIZE_OPTIMAL
, (sal_uInt16
)nVal
);
699 ScGlobal::nLastColWidthExtra
= nVal
;
701 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
702 rReq
.AppendItem( SfxUInt16Item( FID_COL_OPT_WIDTH
, (sal_uInt16
)TwipsToEvenHMM(nVal
) ) );
710 case FID_COL_OPT_DIRECT
:
711 pTabViewShell
->SetMarkedWidthOrHeight( sal_True
, SC_SIZE_OPTIMAL
, STD_EXTRA_WIDTH
);
716 pTabViewShell
->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT
, 0 );
720 pTabViewShell
->SetMarkedWidthOrHeight( false, SC_SIZE_SHOW
, 0 );
724 pTabViewShell
->SetMarkedWidthOrHeight( sal_True
, SC_SIZE_DIRECT
, 0 );
728 pTabViewShell
->SetMarkedWidthOrHeight( sal_True
, SC_SIZE_SHOW
, 0 );
732 //----------------------------------------------------------------
735 case SID_CELL_FORMAT_RESET
:
737 pTabViewShell
->DeleteContents( IDF_HARDATTR
| IDF_EDITATTR
);
744 case FID_MERGE_TOGGLE
:
746 if ( !GetViewData()->GetDocument()->GetChangeTrack() )
748 // test whether to merge or to split
750 sal_Bool bCenter
= false;
759 case FID_MERGE_TOGGLE
:
762 SfxPoolItem
* pItem
= 0;
763 if( rBindings
.QueryState( nSlot
, pItem
) >= SFX_ITEM_DEFAULT
)
764 bMerge
= !static_cast< SfxBoolItem
* >( pItem
)->GetValue();
773 // merge - check if to move contents of covered cells
774 sal_Bool bMoveContents
= false;
775 sal_Bool bApi
= rReq
.IsAPI();
776 const SfxPoolItem
* pItem
;
778 pReqArgs
->GetItemState(nSlot
, sal_True
, &pItem
) == SFX_ITEM_SET
)
780 OSL_ENSURE(pItem
&& pItem
->ISA(SfxBoolItem
), "falsches Item");
781 bMoveContents
= ((const SfxBoolItem
*)pItem
)->GetValue();
784 if (pTabViewShell
->MergeCells( bApi
, bMoveContents
, true, bCenter
))
786 if (!bApi
&& bMoveContents
) // "yes" clicked in dialog
787 rReq
.AppendItem( SfxBoolItem( nSlot
, bMoveContents
) );
788 rBindings
.Invalidate( nSlot
);
795 if (pTabViewShell
->RemoveMerge())
797 rBindings
.Invalidate( nSlot
);
808 Window
* pDlgParent
= pTabViewShell
->GetDialogParent();
816 const ScMarkData
& rMark
= GetViewData()->GetMarkData();
817 if ( !rMark
.IsMarked() && !rMark
.IsMultiMarked() )
818 pTabViewShell
->MarkDataArea( sal_True
);
820 GetViewData()->GetSimpleArea( nStartCol
,nStartRow
,nStartTab
,
821 nEndCol
,nEndRow
,nEndTab
);
823 if ( ( std::abs((SCsCOL
)nEndCol
-(SCsCOL
)nStartCol
) > 1 )
824 && ( std::abs((SCsROW
)nEndRow
-(SCsROW
)nStartRow
) > 1 ) )
828 const SfxStringItem
& rNameItem
= (const SfxStringItem
&)pReqArgs
->Get( SID_AUTOFORMAT
);
829 ScAutoFormat
* pFormat
= ScGlobal::GetOrCreateAutoFormat();
830 ScAutoFormat::const_iterator it
= pFormat
->find(rNameItem
.GetValue());
831 ScAutoFormat::const_iterator itBeg
= pFormat
->begin();
832 size_t nIndex
= std::distance(itBeg
, it
);
834 pTabViewShell
->AutoFormat( nIndex
);
841 ScGlobal::ClearAutoFormat();
842 ScAutoFormatData
* pNewEntry
= pTabViewShell
->CreateAutoFormatData();
843 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
844 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
846 AbstractScAutoFormatDlg
* pDlg
= pFact
->CreateScAutoFormatDlg( pDlgParent
, ScGlobal::GetOrCreateAutoFormat(), pNewEntry
,GetViewData()->GetDocument(), RID_SCDLG_AUTOFORMAT
);
847 OSL_ENSURE(pDlg
, "Dialog create fail!");
849 if ( pDlg
->Execute() == RET_OK
)
851 ScEditableTester
aTester( pTabViewShell
);
852 if ( !aTester
.IsEditable() )
854 pTabViewShell
->ErrorMessage(aTester
.GetMessageId());
858 pTabViewShell
->AutoFormat( pDlg
->GetIndex() );
860 rReq
.AppendItem( SfxStringItem( SID_AUTOFORMAT
, pDlg
->GetCurrFormatName() ) );
869 ErrorBox( pDlgParent
, WinBits( WB_OK
| WB_DEF_OK
),
870 ScGlobal::GetRscString(STR_INVALID_AFAREA
) ).Execute();
876 if (GetViewData()->HasEditView(GetViewData()->GetActivePart()))
877 pScMod
->InputCancelHandler();
878 else if (pTabViewShell
->HasPaintBrush())
879 pTabViewShell
->ResetBrushDocument(); // abort format paint brush
880 else if (pTabViewShell
->HasHintWindow())
881 pTabViewShell
->RemoveHintWindow();
882 else if( ScViewUtil::IsFullScreen( *pTabViewShell
) )
883 ScViewUtil::SetFullScreen( *pTabViewShell
, false );
886 // TODO/LATER: when is this code executed?
887 pTabViewShell
->Escape();
892 case SID_DATA_SELECT
:
893 pTabViewShell
->StartDataSelect();
896 case SID_DETECTIVE_FILLMODE
:
898 sal_Bool bOldMode
= pTabViewShell
->IsAuditShell();
899 pTabViewShell
->SetAuditShell( !bOldMode
);
900 pTabViewShell
->Invalidate( nSlot
);
904 // ----------------------------------------------------------------
906 case FID_INPUTLINE_STATUS
:
907 OSL_FAIL("Execute von InputLine-Status");
910 case SID_STATUS_DOCPOS
:
912 GetViewData()->GetDispatcher().Execute(
913 SID_NAVIGATOR
, SFX_CALLMODE_SYNCHRON
|SFX_CALLMODE_RECORD
);
917 // called from Basic at the hidden view to select a range in the visible view
918 OSL_FAIL("old slot SID_MARKAREA");
922 OSL_FAIL("Unbekannter Slot bei ScCellShell::Execute");
927 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */