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 #include <boost/scoped_ptr.hpp>
53 #define IS_EDITMODE() GetViewData()->HasEditView( GetViewData()->GetActivePart() )
57 using sc::TwipsToEvenHMM
;
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(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
)
326 // set cell attribute without dialog:
328 boost::scoped_ptr
<SfxItemSet
> pEmptySet(
329 new SfxItemSet( *pReqArgs
->GetPool(),
333 boost::scoped_ptr
<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
, true, &pAttr
) == SFX_ITEM_SET
)
343 pNewSet
->Put( *pAttr
);
345 pTabViewShell
->ApplyAttributes( pNewSet
.get(), pEmptySet
.get() );
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 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
, true, &pItem
) == SFX_ITEM_SET
)
479 aArgName
= ((const SfxStringItem
*)pItem
)->GetValue();
480 if ( pReqArgs
->GetItemState( SID_NEW_TABLENAME
, 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 bool bSheetProtected
= pDoc
->IsTabProtected(nTab
);
493 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
494 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
496 boost::scoped_ptr
<AbstractScNewScenarioDlg
> pNewDlg(pFact
->CreateScNewScenarioDlg(pTabViewShell
->GetDialogParent(), aName
, 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
) );
509 else if( ! rReq
.IsAPI() )
511 pTabViewShell
->ErrorMessage(STR_ERR_NEWSCENARIO
);
520 pTabViewShell
->SelectAll();
529 const SfxUInt16Item
& rUInt16Item
= (const SfxUInt16Item
&)pReqArgs
->Get( FID_ROW_HEIGHT
);
531 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
532 pTabViewShell
->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT
,
533 sal::static_int_cast
<sal_uInt16
>( HMMToTwips(rUInt16Item
.GetValue()) ) );
539 ScViewData
* pData
= GetViewData();
540 FieldUnit eMetric
= SC_MOD()->GetAppOptions().GetAppMetric();
541 sal_uInt16 nCurHeight
= pData
->GetDocument()->
542 GetRowHeight( pData
->GetCurY(),
544 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
545 assert(pFact
); //ScAbstractFactory create fail!
547 boost::scoped_ptr
<AbstractScMetricInputDlg
> pDlg(pFact
->CreateScMetricInputDlg(
548 pTabViewShell
->GetDialogParent(), "RowHeightDialog",
549 nCurHeight
, ScGlobal::nStdRowHeight
,
550 eMetric
, 2, MAX_ROW_HEIGHT
));
551 assert(pDlg
); //Dialog create fail
553 if ( pDlg
->Execute() == RET_OK
)
555 long nVal
= pDlg
->GetInputValue();
556 pTabViewShell
->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT
, (sal_uInt16
)nVal
);
558 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
559 rReq
.AppendItem( SfxUInt16Item( FID_ROW_HEIGHT
, (sal_uInt16
)TwipsToEvenHMM(nVal
) ) );
567 case FID_ROW_OPT_HEIGHT
:
571 const SfxUInt16Item
& rUInt16Item
= (const SfxUInt16Item
&)pReqArgs
->Get( FID_ROW_OPT_HEIGHT
);
573 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
574 pTabViewShell
->SetMarkedWidthOrHeight( false, SC_SIZE_OPTIMAL
,
575 sal::static_int_cast
<sal_uInt16
>( HMMToTwips(rUInt16Item
.GetValue()) ) );
576 ScGlobal::nLastRowHeightExtra
= rUInt16Item
.GetValue();
583 FieldUnit eMetric
= SC_MOD()->GetAppOptions().GetAppMetric();
585 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
586 assert(pFact
); //ScAbstractFactory create fail!
588 boost::scoped_ptr
<AbstractScMetricInputDlg
> pDlg(pFact
->CreateScMetricInputDlg(
589 pTabViewShell
->GetDialogParent(), "OptimalRowHeightDialog",
590 ScGlobal::nLastRowHeightExtra
, 0, eMetric
, 1, MAX_EXTRA_HEIGHT
));
591 assert(pDlg
); //Dialog create fail!
593 if ( pDlg
->Execute() == RET_OK
)
595 long nVal
= pDlg
->GetInputValue();
596 pTabViewShell
->SetMarkedWidthOrHeight( false, SC_SIZE_OPTIMAL
, (sal_uInt16
)nVal
);
597 ScGlobal::nLastRowHeightExtra
= nVal
;
599 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
600 rReq
.AppendItem( SfxUInt16Item( FID_ROW_OPT_HEIGHT
, (sal_uInt16
)TwipsToEvenHMM(nVal
) ) );
612 const SfxUInt16Item
& rUInt16Item
= (const SfxUInt16Item
&)pReqArgs
->Get( FID_COL_WIDTH
);
614 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
615 pTabViewShell
->SetMarkedWidthOrHeight( true, SC_SIZE_DIRECT
,
616 sal::static_int_cast
<sal_uInt16
>( HMMToTwips(rUInt16Item
.GetValue()) ) );
622 FieldUnit eMetric
= SC_MOD()->GetAppOptions().GetAppMetric();
623 ScViewData
* pData
= GetViewData();
624 sal_uInt16 nCurHeight
= pData
->GetDocument()->
625 GetColWidth( pData
->GetCurX(),
627 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
628 assert(pFact
); //ScAbstractFactory create fail!
630 boost::scoped_ptr
<AbstractScMetricInputDlg
> pDlg(pFact
->CreateScMetricInputDlg(
631 pTabViewShell
->GetDialogParent(), "ColWidthDialog", nCurHeight
,
632 STD_COL_WIDTH
, eMetric
, 2, MAX_COL_WIDTH
));
633 assert(pDlg
); //Dialog create fail!
635 if ( pDlg
->Execute() == RET_OK
)
637 long nVal
= pDlg
->GetInputValue();
638 pTabViewShell
->SetMarkedWidthOrHeight( true, SC_SIZE_DIRECT
, (sal_uInt16
)nVal
);
640 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
641 rReq
.AppendItem( SfxUInt16Item( FID_COL_WIDTH
, (sal_uInt16
)TwipsToEvenHMM(nVal
)) );
649 case FID_COL_OPT_WIDTH
:
653 const SfxUInt16Item
& rUInt16Item
= (const SfxUInt16Item
&)pReqArgs
->Get( FID_COL_OPT_WIDTH
);
655 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
656 pTabViewShell
->SetMarkedWidthOrHeight( true, SC_SIZE_OPTIMAL
,
657 sal::static_int_cast
<sal_uInt16
>( HMMToTwips(rUInt16Item
.GetValue()) ) );
658 ScGlobal::nLastColWidthExtra
= rUInt16Item
.GetValue();
665 FieldUnit eMetric
= SC_MOD()->GetAppOptions().GetAppMetric();
667 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
668 assert(pFact
); //ScAbstractFactory create fail!
670 boost::scoped_ptr
<AbstractScMetricInputDlg
> pDlg(pFact
->CreateScMetricInputDlg(
671 pTabViewShell
->GetDialogParent(), "OptimalColWidthDialog",
672 ScGlobal::nLastColWidthExtra
, STD_EXTRA_WIDTH
, eMetric
, 1, MAX_EXTRA_WIDTH
));
673 assert(pDlg
); //Dialog create fail!
674 if ( pDlg
->Execute() == RET_OK
)
676 long nVal
= pDlg
->GetInputValue();
677 pTabViewShell
->SetMarkedWidthOrHeight( true, SC_SIZE_OPTIMAL
, (sal_uInt16
)nVal
);
678 ScGlobal::nLastColWidthExtra
= nVal
;
680 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
681 rReq
.AppendItem( SfxUInt16Item( FID_COL_OPT_WIDTH
, (sal_uInt16
)TwipsToEvenHMM(nVal
) ) );
688 case FID_COL_OPT_DIRECT
:
689 pTabViewShell
->SetMarkedWidthOrHeight( true, SC_SIZE_OPTIMAL
, STD_EXTRA_WIDTH
);
694 pTabViewShell
->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT
, 0 );
698 pTabViewShell
->SetMarkedWidthOrHeight( false, SC_SIZE_SHOW
, 0 );
702 pTabViewShell
->SetMarkedWidthOrHeight( true, SC_SIZE_DIRECT
, 0 );
706 pTabViewShell
->SetMarkedWidthOrHeight( true, SC_SIZE_SHOW
, 0 );
711 case SID_CELL_FORMAT_RESET
:
713 pTabViewShell
->DeleteContents( IDF_HARDATTR
| IDF_EDITATTR
);
720 case FID_MERGE_TOGGLE
:
722 if ( !GetViewData()->GetDocument()->GetChangeTrack() )
724 // test whether to merge or to split
726 bool bCenter
= false;
735 case FID_MERGE_TOGGLE
:
738 SfxPoolItem
* pItem
= 0;
739 if( rBindings
.QueryState( nSlot
, pItem
) >= SFX_ITEM_DEFAULT
)
740 bMerge
= !static_cast< SfxBoolItem
* >( pItem
)->GetValue();
749 // merge - check if to move contents of covered cells
750 bool bMoveContents
= false;
751 bool bApi
= rReq
.IsAPI();
752 const SfxPoolItem
* pItem
;
754 pReqArgs
->GetItemState(nSlot
, true, &pItem
) == SFX_ITEM_SET
)
756 OSL_ENSURE(pItem
&& pItem
->ISA(SfxBoolItem
), "falsches Item");
757 bMoveContents
= ((const SfxBoolItem
*)pItem
)->GetValue();
760 if (pTabViewShell
->MergeCells( bApi
, bMoveContents
, true, bCenter
))
762 if (!bApi
&& bMoveContents
) // "yes" clicked in dialog
763 rReq
.AppendItem( SfxBoolItem( nSlot
, bMoveContents
) );
764 rBindings
.Invalidate( nSlot
);
771 if (pTabViewShell
->RemoveMerge())
773 rBindings
.Invalidate( nSlot
);
784 Window
* pDlgParent
= pTabViewShell
->GetDialogParent();
792 const ScMarkData
& rMark
= GetViewData()->GetMarkData();
793 if ( !rMark
.IsMarked() && !rMark
.IsMultiMarked() )
794 pTabViewShell
->MarkDataArea( true );
796 GetViewData()->GetSimpleArea( nStartCol
,nStartRow
,nStartTab
,
797 nEndCol
,nEndRow
,nEndTab
);
799 if ( ( std::abs((SCsCOL
)nEndCol
-(SCsCOL
)nStartCol
) > 1 )
800 && ( std::abs((SCsROW
)nEndRow
-(SCsROW
)nStartRow
) > 1 ) )
804 const SfxStringItem
& rNameItem
= (const SfxStringItem
&)pReqArgs
->Get( SID_AUTOFORMAT
);
805 ScAutoFormat
* pFormat
= ScGlobal::GetOrCreateAutoFormat();
806 ScAutoFormat::const_iterator it
= pFormat
->find(rNameItem
.GetValue());
807 ScAutoFormat::const_iterator itBeg
= pFormat
->begin();
808 size_t nIndex
= std::distance(itBeg
, it
);
810 pTabViewShell
->AutoFormat( nIndex
);
817 ScGlobal::ClearAutoFormat();
818 boost::scoped_ptr
<ScAutoFormatData
> pNewEntry(pTabViewShell
->CreateAutoFormatData());
819 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
820 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
822 boost::scoped_ptr
<AbstractScAutoFormatDlg
> pDlg(pFact
->CreateScAutoFormatDlg(pDlgParent
, ScGlobal::GetOrCreateAutoFormat(), pNewEntry
.get(), GetViewData()));
823 OSL_ENSURE(pDlg
, "Dialog create fail!");
825 if ( pDlg
->Execute() == RET_OK
)
827 ScEditableTester
aTester( pTabViewShell
);
828 if ( !aTester
.IsEditable() )
830 pTabViewShell
->ErrorMessage(aTester
.GetMessageId());
834 pTabViewShell
->AutoFormat( pDlg
->GetIndex() );
836 rReq
.AppendItem( SfxStringItem( SID_AUTOFORMAT
, pDlg
->GetCurrFormatName() ) );
843 ErrorBox( pDlgParent
, WinBits( WB_OK
| WB_DEF_OK
),
844 ScGlobal::GetRscString(STR_INVALID_AFAREA
) ).Execute();
850 if (GetViewData()->HasEditView(GetViewData()->GetActivePart()))
851 pScMod
->InputCancelHandler();
852 else if (pTabViewShell
->HasPaintBrush())
853 pTabViewShell
->ResetBrushDocument(); // abort format paint brush
854 else if (pTabViewShell
->HasHintWindow())
855 pTabViewShell
->RemoveHintWindow();
856 else if( ScViewUtil::IsFullScreen( *pTabViewShell
) )
857 ScViewUtil::SetFullScreen( *pTabViewShell
, false );
860 // TODO/LATER: when is this code executed?
861 pTabViewShell
->Escape();
866 case SID_DATA_SELECT
:
867 pTabViewShell
->StartDataSelect();
870 case SID_DETECTIVE_FILLMODE
:
872 bool bOldMode
= pTabViewShell
->IsAuditShell();
873 pTabViewShell
->SetAuditShell( !bOldMode
);
874 pTabViewShell
->Invalidate( nSlot
);
878 case FID_INPUTLINE_STATUS
:
879 OSL_FAIL("Execute von InputLine-Status");
882 case SID_STATUS_DOCPOS
:
884 GetViewData()->GetDispatcher().Execute(
885 SID_NAVIGATOR
, SFX_CALLMODE_SYNCHRON
|SFX_CALLMODE_RECORD
);
889 // called from Basic at the hidden view to select a range in the visible view
890 OSL_FAIL("old slot SID_MARKAREA");
894 OSL_FAIL("Unbekannter Slot bei ScCellShell::Execute");
899 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */