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_COLLABORATION
:
106 GetViewData()->GetDocShell()->GetCollaboration()->DisplayContacts();
110 case SID_STATUS_SELMODE
:
113 /* 0: STD Click cancels selection
114 * 1: ER Click extends selection
115 * 2: ERG Click defines further selection
117 sal_uInt16 nMode
= static_cast<const SfxUInt16Item
&>(pReqArgs
->Get( nSlot
)).GetValue();
121 case 1: nMode
= KEY_SHIFT
; break;
122 case 2: nMode
= KEY_MOD1
; break; // control-key
128 pTabViewShell
->LockModifiers( nMode
);
132 // no arguments (also executed by double click on the status bar controller):
133 // advance to next selection mode
135 sal_uInt16 nModifiers
= pTabViewShell
->GetLockedModifiers();
136 switch ( nModifiers
)
138 case KEY_SHIFT
: nModifiers
= KEY_MOD1
; break; // EXT -> ADD
139 case KEY_MOD1
: nModifiers
= 0; break; // ADD -> STD
140 default: nModifiers
= KEY_SHIFT
; break; // STD -> EXT
142 pTabViewShell
->LockModifiers( nModifiers
);
145 rBindings
.Invalidate( SID_STATUS_SELMODE
);
149 // SID_STATUS_SELMODE_NORM is not used ???
151 case SID_STATUS_SELMODE_NORM
:
152 pTabViewShell
->LockModifiers( 0 );
153 rBindings
.Invalidate( SID_STATUS_SELMODE
);
156 // SID_STATUS_SELMODE_ERG / SID_STATUS_SELMODE_ERW as toggles:
158 case SID_STATUS_SELMODE_ERG
:
159 if ( pTabViewShell
->GetLockedModifiers() & KEY_MOD1
)
160 pTabViewShell
->LockModifiers( 0 );
162 pTabViewShell
->LockModifiers( KEY_MOD1
);
163 rBindings
.Invalidate( SID_STATUS_SELMODE
);
166 case SID_STATUS_SELMODE_ERW
:
167 if ( pTabViewShell
->GetLockedModifiers() & KEY_SHIFT
)
168 pTabViewShell
->LockModifiers( 0 );
170 pTabViewShell
->LockModifiers( KEY_SHIFT
);
171 rBindings
.Invalidate( SID_STATUS_SELMODE
);
174 case SID_ENTER_STRING
:
178 OUString
aStr( static_cast<const SfxStringItem
&>(pReqArgs
->
179 Get( SID_ENTER_STRING
)).GetValue() );
181 pTabViewShell
->EnterData( GetViewData()->GetCurX(),
182 GetViewData()->GetCurY(),
183 GetViewData()->GetTabNo(),
186 ScInputHandler
* pHdl
= SC_MOD()->GetInputHdl( pTabViewShell
);
187 if ( !pHdl
|| !pHdl
->IsInEnterHandler() )
189 // UpdateInputHandler is needed after the cell content
190 // has changed, but if called from EnterHandler, UpdateInputHandler
191 // will be called later when moving the cursor.
193 pTabViewShell
->UpdateInputHandler();
198 // no GrabFocus here, as otherwise on a Mac the tab jumps before the
199 // sideview, when the input was not finished
200 // (GrabFocus is called in KillEditView)
205 case SID_INSERT_MATRIX
:
209 OUString aStr
= static_cast<const SfxStringItem
&>(pReqArgs
->
210 Get( SID_INSERT_MATRIX
)).GetValue();
211 ScDocument
* pDoc
= GetViewData()->GetDocument();
212 pTabViewShell
->EnterMatrix( aStr
, pDoc
->GetGrammar() );
218 case FID_INPUTLINE_ENTER
:
219 case FID_INPUTLINE_BLOCK
:
220 case FID_INPUTLINE_MATRIX
:
222 if( pReqArgs
== 0 ) //XXX temporary HACK to avoid GPF
225 const ScInputStatusItem
* pStatusItem
226 = static_cast<const ScInputStatusItem
*>(&pReqArgs
->
227 Get( FID_INPUTLINE_STATUS
));
229 ScAddress aCursorPos
= pStatusItem
->GetPos();
230 OUString aString
= pStatusItem
->GetString();
231 const EditTextObject
* pData
= pStatusItem
->GetEditData();
235 if (nSlot
== FID_INPUTLINE_BLOCK
)
237 pTabViewShell
->EnterBlock( aString
, pData
);
239 else if ( !aString
.isEmpty() && ( aString
[0] == '=' || aString
[0] == '+' || aString
[0] == '-' ) )
241 pTabViewShell
->EnterData( aCursorPos
.Col(), aCursorPos
.Row(), aCursorPos
.Tab(), aString
, pData
);
245 pTabViewShell
->EnterData(aCursorPos
.Col(), aCursorPos
.Row(), aCursorPos
.Tab(), *pData
);
250 if (nSlot
== FID_INPUTLINE_ENTER
)
253 aCursorPos
.Col() == GetViewData()->GetCurX() &&
254 aCursorPos
.Row() == GetViewData()->GetCurY() &&
255 aCursorPos
.Tab() == GetViewData()->GetTabNo()
258 SfxStringItem
aItem( SID_ENTER_STRING
, aString
);
260 // SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings();
261 const SfxPoolItem
* aArgs
[2];
264 rBindings
.Execute( SID_ENTER_STRING
, aArgs
);
268 pTabViewShell
->EnterData( aCursorPos
.Col(),
275 else if (nSlot
== FID_INPUTLINE_BLOCK
)
277 pTabViewShell
->EnterBlock( aString
, NULL
);
282 ScDocument
* pDoc
= GetViewData()->GetDocument();
283 pTabViewShell
->EnterMatrix( aString
, pDoc
->GetGrammar() );
288 pTabViewShell
->SetAutoSpellData(
289 aCursorPos
.Col(), aCursorPos
.Row(), pStatusItem
->GetMisspellRanges());
291 // no GrabFocus here, as otherwise on a Mac the tab jumps before the
292 // sideview, when the input was not finished
293 // (GrabFocus is called in KillEditView)
297 case SID_OPENDLG_FUNCTION
:
299 sal_uInt16 nId
= SID_OPENDLG_FUNCTION
;
300 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
301 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
303 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
308 case SID_OPENDLG_CONSOLIDATE
:
310 sal_uInt16 nId
= ScConsolidateDlgWrapper::GetChildWindowId();
311 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
312 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
314 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
318 case FID_CELL_FORMAT
:
320 if ( pReqArgs
!= NULL
)
323 // set cell attribute without dialog:
325 boost::scoped_ptr
<SfxItemSet
> pEmptySet(
326 new SfxItemSet( *pReqArgs
->GetPool(),
330 boost::scoped_ptr
<SfxItemSet
> pNewSet(
331 new SfxItemSet( *pReqArgs
->GetPool(),
335 const SfxPoolItem
* pAttr
= NULL
;
336 sal_uInt16 nWhich
= 0;
338 for ( nWhich
=ATTR_PATTERN_START
; nWhich
<=ATTR_PATTERN_END
; nWhich
++ )
339 if ( pReqArgs
->GetItemState( nWhich
, true, &pAttr
) == SfxItemState::SET
)
340 pNewSet
->Put( *pAttr
);
342 pTabViewShell
->ApplyAttributes( pNewSet
.get(), pEmptySet
.get() );
349 else if ( pReqArgs
== NULL
)
351 pTabViewShell
->ExecuteCellFormatDlg( rReq
);
356 case SID_ENABLE_HYPHENATION
:
357 pTabViewShell
->ExecuteCellFormatDlg(rReq
, "alignment");
360 case SID_PROPERTY_PANEL_CELLTEXT_DLG
:
361 pTabViewShell
->ExecuteCellFormatDlg( rReq
, "font" );
364 case SID_CELL_FORMAT_BORDER
:
365 pTabViewShell
->ExecuteCellFormatDlg( rReq
, "borders" );
368 case SID_CHAR_DLG_EFFECT
:
369 pTabViewShell
->ExecuteCellFormatDlg( rReq
, "fonteffects" );
372 case SID_OPENDLG_SOLVE
:
374 sal_uInt16 nId
= ScSolverDlgWrapper::GetChildWindowId();
375 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
376 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
378 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
382 case SID_OPENDLG_OPTSOLVER
:
384 sal_uInt16 nId
= ScOptSolverDlgWrapper::GetChildWindowId();
385 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
386 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
388 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
392 case SID_OPENDLG_TABOP
:
394 sal_uInt16 nId
= ScTabOpDlgWrapper::GetChildWindowId();
395 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
396 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
398 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
404 ScDocument
* pDoc
= GetViewData()->GetDocument();
405 ScMarkData
& rMark
= GetViewData()->GetMarkData();
406 SCTAB nTab
= GetViewData()->GetTabNo();
408 if ( pDoc
->IsScenario(nTab
) )
411 if ( rMark
.IsMultiMarked() )
415 ScopedVclPtr
<QueryBox
>::Create( pTabViewShell
->GetDialogParent(), WinBits(WB_YES_NO
| WB_DEF_YES
),
416 ScGlobal::GetRscString(STR_UPDATE_SCENARIO
) )->
419 pTabViewShell
->ExtendScenario();
423 else if( ! rReq
.IsAPI() )
425 ScopedVclPtrInstance
<MessageDialog
> aErrorBox(pTabViewShell
->GetDialogParent(),
426 ScGlobal::GetRscString(STR_NOAREASELECTED
));
427 aErrorBox
->Execute();
433 if ( rMark
.IsMultiMarked() )
443 pDoc
->GetName(nTab
, aTmp
);
446 aBaseName
+= ScGlobal::GetRscString(STR_SCENARIO
);
449 // first test, if the prefix is recognised as valid,
450 // else avoid only doubles
451 bool bPrefix
= ScDocument::ValidTabName( aBaseName
);
452 OSL_ENSURE(bPrefix
, "ungueltiger Tabellenname");
454 while ( pDoc
->IsScenario(nTab
+i
) )
461 aName
= aBaseName
+ OUString::number( i
);
463 bValid
= pDoc
->ValidNewTabName( aName
);
465 bValid
= !pDoc
->GetTable( aName
, nDummy
);
468 while ( !bValid
&& i
<= MAXTAB
+ 2 );
470 if ( pReqArgs
!= NULL
)
473 OUString aArgComment
;
474 const SfxPoolItem
* pItem
;
475 if ( pReqArgs
->GetItemState( SID_SCENARIOS
, true, &pItem
) == SfxItemState::SET
)
476 aArgName
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
477 if ( pReqArgs
->GetItemState( SID_NEW_TABLENAME
, true, &pItem
) == SfxItemState::SET
)
478 aArgComment
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
480 aColor
= Color( COL_LIGHTGRAY
); // Default
481 nFlags
= 0; // not-TwoWay
483 pTabViewShell
->MakeScenario( aArgName
, aArgComment
, aColor
, nFlags
);
489 bool bSheetProtected
= pDoc
->IsTabProtected(nTab
);
490 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
491 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
493 boost::scoped_ptr
<AbstractScNewScenarioDlg
> pNewDlg(pFact
->CreateScNewScenarioDlg(pTabViewShell
->GetDialogParent(), aName
, false, bSheetProtected
));
494 OSL_ENSURE(pNewDlg
, "Dialog create fail!");
495 if ( pNewDlg
->Execute() == RET_OK
)
497 pNewDlg
->GetScenarioData( aName
, aComment
, aColor
, nFlags
);
498 pTabViewShell
->MakeScenario( aName
, aComment
, aColor
, nFlags
);
500 rReq
.AppendItem( SfxStringItem( SID_SCENARIOS
, aName
) );
501 rReq
.AppendItem( SfxStringItem( SID_NEW_TABLENAME
, aComment
) );
506 else if( ! rReq
.IsAPI() )
508 pTabViewShell
->ErrorMessage(STR_ERR_NEWSCENARIO
);
516 pTabViewShell
->SelectAll();
525 const SfxUInt16Item
& rUInt16Item
= static_cast<const SfxUInt16Item
&>(pReqArgs
->Get( FID_ROW_HEIGHT
));
527 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
528 pTabViewShell
->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT
,
529 sal::static_int_cast
<sal_uInt16
>( HMMToTwips(rUInt16Item
.GetValue()) ) );
535 ScViewData
* pData
= GetViewData();
536 FieldUnit eMetric
= SC_MOD()->GetAppOptions().GetAppMetric();
537 sal_uInt16 nCurHeight
= pData
->GetDocument()->
538 GetRowHeight( pData
->GetCurY(),
540 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
541 assert(pFact
); //ScAbstractFactory create fail!
543 boost::scoped_ptr
<AbstractScMetricInputDlg
> pDlg(pFact
->CreateScMetricInputDlg(
544 pTabViewShell
->GetDialogParent(), "RowHeightDialog",
545 nCurHeight
, ScGlobal::nStdRowHeight
,
546 eMetric
, 2, MAX_ROW_HEIGHT
));
547 assert(pDlg
); //Dialog create fail
549 if ( pDlg
->Execute() == RET_OK
)
551 long nVal
= pDlg
->GetInputValue();
552 pTabViewShell
->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT
, (sal_uInt16
)nVal
);
554 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
555 rReq
.AppendItem( SfxUInt16Item( FID_ROW_HEIGHT
, (sal_uInt16
)TwipsToEvenHMM(nVal
) ) );
563 case FID_ROW_OPT_HEIGHT
:
567 const SfxUInt16Item
& rUInt16Item
= static_cast<const SfxUInt16Item
&>(pReqArgs
->Get( FID_ROW_OPT_HEIGHT
));
569 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
570 pTabViewShell
->SetMarkedWidthOrHeight( false, SC_SIZE_OPTIMAL
,
571 sal::static_int_cast
<sal_uInt16
>( HMMToTwips(rUInt16Item
.GetValue()) ) );
572 ScGlobal::nLastRowHeightExtra
= rUInt16Item
.GetValue();
579 FieldUnit eMetric
= SC_MOD()->GetAppOptions().GetAppMetric();
581 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
582 assert(pFact
); //ScAbstractFactory create fail!
584 boost::scoped_ptr
<AbstractScMetricInputDlg
> pDlg(pFact
->CreateScMetricInputDlg(
585 pTabViewShell
->GetDialogParent(), "OptimalRowHeightDialog",
586 ScGlobal::nLastRowHeightExtra
, 0, eMetric
, 1, MAX_EXTRA_HEIGHT
));
587 assert(pDlg
); //Dialog create fail!
589 if ( pDlg
->Execute() == RET_OK
)
591 long nVal
= pDlg
->GetInputValue();
592 pTabViewShell
->SetMarkedWidthOrHeight( false, SC_SIZE_OPTIMAL
, (sal_uInt16
)nVal
);
593 ScGlobal::nLastRowHeightExtra
= nVal
;
595 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
596 rReq
.AppendItem( SfxUInt16Item( FID_ROW_OPT_HEIGHT
, (sal_uInt16
)TwipsToEvenHMM(nVal
) ) );
608 const SfxUInt16Item
& rUInt16Item
= static_cast<const SfxUInt16Item
&>(pReqArgs
->Get( FID_COL_WIDTH
));
610 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
611 pTabViewShell
->SetMarkedWidthOrHeight( true, SC_SIZE_DIRECT
,
612 sal::static_int_cast
<sal_uInt16
>( HMMToTwips(rUInt16Item
.GetValue()) ) );
618 FieldUnit eMetric
= SC_MOD()->GetAppOptions().GetAppMetric();
619 ScViewData
* pData
= GetViewData();
620 sal_uInt16 nCurHeight
= pData
->GetDocument()->
621 GetColWidth( pData
->GetCurX(),
623 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
624 assert(pFact
); //ScAbstractFactory create fail!
626 boost::scoped_ptr
<AbstractScMetricInputDlg
> pDlg(pFact
->CreateScMetricInputDlg(
627 pTabViewShell
->GetDialogParent(), "ColWidthDialog", nCurHeight
,
628 STD_COL_WIDTH
, eMetric
, 2, MAX_COL_WIDTH
));
629 assert(pDlg
); //Dialog create fail!
631 if ( pDlg
->Execute() == RET_OK
)
633 long nVal
= pDlg
->GetInputValue();
634 pTabViewShell
->SetMarkedWidthOrHeight( true, SC_SIZE_DIRECT
, (sal_uInt16
)nVal
);
636 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
637 rReq
.AppendItem( SfxUInt16Item( FID_COL_WIDTH
, (sal_uInt16
)TwipsToEvenHMM(nVal
)) );
645 case FID_COL_OPT_WIDTH
:
649 const SfxUInt16Item
& rUInt16Item
= static_cast<const SfxUInt16Item
&>(pReqArgs
->Get( FID_COL_OPT_WIDTH
));
651 // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
652 pTabViewShell
->SetMarkedWidthOrHeight( true, SC_SIZE_OPTIMAL
,
653 sal::static_int_cast
<sal_uInt16
>( HMMToTwips(rUInt16Item
.GetValue()) ) );
654 ScGlobal::nLastColWidthExtra
= rUInt16Item
.GetValue();
661 FieldUnit eMetric
= SC_MOD()->GetAppOptions().GetAppMetric();
663 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
664 assert(pFact
); //ScAbstractFactory create fail!
666 boost::scoped_ptr
<AbstractScMetricInputDlg
> pDlg(pFact
->CreateScMetricInputDlg(
667 pTabViewShell
->GetDialogParent(), "OptimalColWidthDialog",
668 ScGlobal::nLastColWidthExtra
, STD_EXTRA_WIDTH
, eMetric
, 1, MAX_EXTRA_WIDTH
));
669 assert(pDlg
); //Dialog create fail!
670 if ( pDlg
->Execute() == RET_OK
)
672 long nVal
= pDlg
->GetInputValue();
673 pTabViewShell
->SetMarkedWidthOrHeight( true, SC_SIZE_OPTIMAL
, (sal_uInt16
)nVal
);
674 ScGlobal::nLastColWidthExtra
= nVal
;
676 // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
677 rReq
.AppendItem( SfxUInt16Item( FID_COL_OPT_WIDTH
, (sal_uInt16
)TwipsToEvenHMM(nVal
) ) );
684 case FID_COL_OPT_DIRECT
:
685 pTabViewShell
->SetMarkedWidthOrHeight( true, SC_SIZE_OPTIMAL
, STD_EXTRA_WIDTH
);
690 pTabViewShell
->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT
, 0 );
694 pTabViewShell
->SetMarkedWidthOrHeight( false, SC_SIZE_SHOW
, 0 );
698 pTabViewShell
->SetMarkedWidthOrHeight( true, SC_SIZE_DIRECT
, 0 );
702 pTabViewShell
->SetMarkedWidthOrHeight( true, SC_SIZE_SHOW
, 0 );
706 case SID_CELL_FORMAT_RESET
:
708 pTabViewShell
->DeleteContents( IDF_HARDATTR
| IDF_EDITATTR
);
715 case FID_MERGE_TOGGLE
:
717 if ( !GetViewData()->GetDocument()->GetChangeTrack() )
719 // test whether to merge or to split
721 bool bCenter
= false;
730 case FID_MERGE_TOGGLE
:
733 SfxPoolItem
* pItem
= 0;
734 if( rBindings
.QueryState( nSlot
, pItem
) >= SfxItemState::DEFAULT
)
735 bMerge
= !static_cast< SfxBoolItem
* >( pItem
)->GetValue();
744 // merge - check if to move contents of covered cells
745 bool bMoveContents
= false;
746 bool bApi
= rReq
.IsAPI();
747 const SfxPoolItem
* pItem
;
749 pReqArgs
->GetItemState(nSlot
, true, &pItem
) == SfxItemState::SET
)
751 OSL_ENSURE(pItem
&& pItem
->ISA(SfxBoolItem
), "falsches Item");
752 bMoveContents
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
755 if (pTabViewShell
->MergeCells( bApi
, bMoveContents
, true, bCenter
))
757 if (!bApi
&& bMoveContents
) // "yes" clicked in dialog
758 rReq
.AppendItem( SfxBoolItem( nSlot
, bMoveContents
) );
759 rBindings
.Invalidate( nSlot
);
766 if (pTabViewShell
->RemoveMerge())
768 rBindings
.Invalidate( nSlot
);
779 vcl::Window
* pDlgParent
= pTabViewShell
->GetDialogParent();
787 const ScMarkData
& rMark
= GetViewData()->GetMarkData();
788 if ( !rMark
.IsMarked() && !rMark
.IsMultiMarked() )
789 pTabViewShell
->MarkDataArea( true );
791 GetViewData()->GetSimpleArea( nStartCol
,nStartRow
,nStartTab
,
792 nEndCol
,nEndRow
,nEndTab
);
794 if ( ( std::abs((SCsCOL
)nEndCol
-(SCsCOL
)nStartCol
) > 1 )
795 && ( std::abs((SCsROW
)nEndRow
-(SCsROW
)nStartRow
) > 1 ) )
799 const SfxStringItem
& rNameItem
= static_cast<const SfxStringItem
&>(pReqArgs
->Get( SID_AUTOFORMAT
));
800 ScAutoFormat
* pFormat
= ScGlobal::GetOrCreateAutoFormat();
801 ScAutoFormat::const_iterator it
= pFormat
->find(rNameItem
.GetValue());
802 ScAutoFormat::const_iterator itBeg
= pFormat
->begin();
803 size_t nIndex
= std::distance(itBeg
, it
);
805 pTabViewShell
->AutoFormat( nIndex
);
812 ScGlobal::ClearAutoFormat();
813 boost::scoped_ptr
<ScAutoFormatData
> pNewEntry(pTabViewShell
->CreateAutoFormatData());
814 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
815 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
817 boost::scoped_ptr
<AbstractScAutoFormatDlg
> pDlg(pFact
->CreateScAutoFormatDlg(pDlgParent
, ScGlobal::GetOrCreateAutoFormat(), pNewEntry
.get(), GetViewData()));
818 OSL_ENSURE(pDlg
, "Dialog create fail!");
820 if ( pDlg
->Execute() == RET_OK
)
822 ScEditableTester
aTester( pTabViewShell
);
823 if ( !aTester
.IsEditable() )
825 pTabViewShell
->ErrorMessage(aTester
.GetMessageId());
829 pTabViewShell
->AutoFormat( pDlg
->GetIndex() );
831 rReq
.AppendItem( SfxStringItem( SID_AUTOFORMAT
, pDlg
->GetCurrFormatName() ) );
838 ScopedVclPtrInstance
<MessageDialog
>(pDlgParent
,
839 ScGlobal::GetRscString(STR_INVALID_AFAREA
) )->Execute();
845 if (GetViewData()->HasEditView(GetViewData()->GetActivePart()))
846 pScMod
->InputCancelHandler();
847 else if (pTabViewShell
->HasPaintBrush())
848 pTabViewShell
->ResetBrushDocument(); // abort format paint brush
849 else if (pTabViewShell
->HasHintWindow())
850 pTabViewShell
->RemoveHintWindow();
851 else if( ScViewUtil::IsFullScreen( *pTabViewShell
) )
852 ScViewUtil::SetFullScreen( *pTabViewShell
, false );
855 // TODO/LATER: when is this code executed?
856 pTabViewShell
->Escape();
861 case SID_DATA_SELECT
:
862 pTabViewShell
->StartDataSelect();
865 case SID_DETECTIVE_FILLMODE
:
867 bool bOldMode
= pTabViewShell
->IsAuditShell();
868 pTabViewShell
->SetAuditShell( !bOldMode
);
869 pTabViewShell
->Invalidate( nSlot
);
873 case FID_INPUTLINE_STATUS
:
874 OSL_FAIL("Execute von InputLine-Status");
877 case SID_STATUS_DOCPOS
:
879 GetViewData()->GetDispatcher().Execute(
880 SID_NAVIGATOR
, SfxCallMode::SYNCHRON
|SfxCallMode::RECORD
);
884 // called from Basic at the hidden view to select a range in the visible view
885 OSL_FAIL("old slot SID_MARKAREA");
889 OSL_FAIL("Unbekannter Slot bei ScCellShell::Execute");
894 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */