LCOV - code coverage report
Current view: top level - sc/source/ui/view - cellsh3.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 386 0.3 %
Date: 2015-06-13 12:38:46 Functions: 2 3 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      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"
      29             : #include "scmod.hxx"
      30             : #include "appoptio.hxx"
      31             : #include "tabvwsh.hxx"
      32             : #include "document.hxx"
      33             : #include "sc.hrc"
      34             : #include "docsh.hxx"
      35             : #include "reffact.hxx"
      36             : #include "uiitems.hxx"
      37             : #include "autoform.hxx"
      38             : #include "autofmt.hxx"
      39             : #include "cellsh.hxx"
      40             : #include "inputhdl.hxx"
      41             : #include "editable.hxx"
      42             : #include "markdata.hxx"
      43             : #include "scabstdlg.hxx"
      44             : 
      45             : #include <config_telepathy.h>
      46             : 
      47             : #if ENABLE_TELEPATHY
      48             : #include "sccollaboration.hxx"
      49             : #endif
      50             : 
      51             : #include <boost/scoped_ptr.hpp>
      52             : 
      53             : #define IS_EDITMODE() GetViewData()->HasEditView( GetViewData()->GetActivePart() )
      54             : 
      55             : using sc::HMMToTwips;
      56             : using sc::TwipsToHMM;
      57             : using sc::TwipsToEvenHMM;
      58             : 
      59           0 : void ScCellShell::Execute( SfxRequest& rReq )
      60             : {
      61           0 :     ScTabViewShell* pTabViewShell   = GetViewData()->GetViewShell();
      62           0 :     SfxBindings&        rBindings   = pTabViewShell->GetViewFrame()->GetBindings();
      63           0 :     ScModule*           pScMod      = SC_MOD();
      64           0 :     const SfxItemSet*   pReqArgs    = rReq.GetArgs();
      65           0 :     sal_uInt16              nSlot       = rReq.GetSlot();
      66             : 
      67           0 :     if (nSlot != SID_CURRENTCELL)       // this comes with MouseButtonUp
      68           0 :         pTabViewShell->HideListBox();   // Autofilter-DropDown-Listbox
      69             : 
      70           0 :     if ( IS_EDITMODE() )
      71             :     {
      72           0 :         switch ( nSlot )
      73             :         {
      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           0 :                     if (!pTabViewShell->GetViewFrame()->GetFrame().IsInPlace())
      80           0 :                         pTabViewShell->SetDontSwitch(true);         // do not switch off EditShell
      81             :                     // no break
      82             : 
      83             :             case FID_CELL_FORMAT:
      84             :             case SID_ENABLE_HYPHENATION:
      85             :             case SID_DATA_SELECT:
      86             :             case SID_OPENDLG_CONSOLIDATE:
      87             :             case SID_OPENDLG_SOLVE:
      88             :             case SID_OPENDLG_OPTSOLVER:
      89             : 
      90           0 :                     pScMod->InputEnterHandler();
      91           0 :                     pTabViewShell->UpdateInputHandler();
      92             : 
      93           0 :                     pTabViewShell->SetDontSwitch(false);
      94             : 
      95           0 :                     break;
      96             : 
      97             :             default:
      98           0 :                     break;
      99             :         }
     100             :     }
     101             : 
     102           0 :     switch ( nSlot )
     103             :     {
     104             :         case SID_COLLABORATION:
     105             : #if ENABLE_TELEPATHY
     106             :             GetViewData()->GetDocShell()->GetCollaboration()->DisplayContacts();
     107             : #endif
     108           0 :             break;
     109             : 
     110             :         case SID_STATUS_SELMODE:
     111           0 :             if ( pReqArgs )
     112             :             {
     113             :                 /* 0: STD   Click cancels selection
     114             :                  * 1: ER    Click extends selection
     115             :                  * 2: ERG   Click defines further selection
     116             :                  */
     117           0 :                 sal_uInt16 nMode = static_cast<const SfxUInt16Item&>(pReqArgs->Get( nSlot )).GetValue();
     118             : 
     119           0 :                 switch ( nMode )
     120             :                 {
     121           0 :                     case 1: nMode = KEY_SHIFT;  break;
     122           0 :                     case 2: nMode = KEY_MOD1;   break; // control-key
     123             :                     case 0:
     124             :                     default:
     125           0 :                         nMode = 0;
     126             :                 }
     127             : 
     128           0 :                 pTabViewShell->LockModifiers( nMode );
     129             :             }
     130             :             else
     131             :             {
     132             :                 //  no arguments (also executed by double click on the status bar controller):
     133             :                 //  advance to next selection mode
     134             : 
     135           0 :                 sal_uInt16 nModifiers = pTabViewShell->GetLockedModifiers();
     136           0 :                 switch ( nModifiers )
     137             :                 {
     138           0 :                     case KEY_SHIFT: nModifiers = KEY_MOD1;  break;      // EXT -> ADD
     139           0 :                     case KEY_MOD1:  nModifiers = 0;         break;      // ADD -> STD
     140           0 :                     default:        nModifiers = KEY_SHIFT; break;      // STD -> EXT
     141             :                 }
     142           0 :                 pTabViewShell->LockModifiers( nModifiers );
     143             :             }
     144             : 
     145           0 :             rBindings.Invalidate( SID_STATUS_SELMODE );
     146           0 :             rReq.Done();
     147           0 :             break;
     148             : 
     149             :         //  SID_STATUS_SELMODE_NORM is not used ???
     150             : 
     151             :         case SID_STATUS_SELMODE_NORM:
     152           0 :             pTabViewShell->LockModifiers( 0 );
     153           0 :             rBindings.Invalidate( SID_STATUS_SELMODE );
     154           0 :             break;
     155             : 
     156             :         //  SID_STATUS_SELMODE_ERG / SID_STATUS_SELMODE_ERW as toggles:
     157             : 
     158             :         case SID_STATUS_SELMODE_ERG:
     159           0 :             if ( pTabViewShell->GetLockedModifiers() & KEY_MOD1 )
     160           0 :                 pTabViewShell->LockModifiers( 0 );
     161             :             else
     162           0 :                 pTabViewShell->LockModifiers( KEY_MOD1 );
     163           0 :             rBindings.Invalidate( SID_STATUS_SELMODE );
     164           0 :             break;
     165             : 
     166             :         case SID_STATUS_SELMODE_ERW:
     167           0 :             if ( pTabViewShell->GetLockedModifiers() & KEY_SHIFT )
     168           0 :                 pTabViewShell->LockModifiers( 0 );
     169             :             else
     170           0 :                 pTabViewShell->LockModifiers( KEY_SHIFT );
     171           0 :             rBindings.Invalidate( SID_STATUS_SELMODE );
     172           0 :             break;
     173             : 
     174             :         case SID_ENTER_STRING:
     175             :             {
     176           0 :                 if ( pReqArgs )
     177             :                 {
     178             :                     OUString aStr( static_cast<const SfxStringItem&>(pReqArgs->
     179           0 :                                     Get( SID_ENTER_STRING )).GetValue() );
     180             : 
     181           0 :                     pTabViewShell->EnterData( GetViewData()->GetCurX(),
     182             :                                                GetViewData()->GetCurY(),
     183           0 :                                                GetViewData()->GetTabNo(),
     184           0 :                                                aStr );
     185             : 
     186           0 :                     ScInputHandler* pHdl = SC_MOD()->GetInputHdl( pTabViewShell );
     187           0 :                     if ( !pHdl || !pHdl->IsInEnterHandler() )
     188             :                     {
     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.
     192             : 
     193           0 :                         pTabViewShell->UpdateInputHandler();
     194             :                     }
     195             : 
     196           0 :                     rReq.Done();
     197             : 
     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)
     201             :                 }
     202             :             }
     203           0 :             break;
     204             : 
     205             :         case SID_INSERT_MATRIX:
     206             :             {
     207           0 :                 if ( pReqArgs )
     208             :                 {
     209             :                     OUString aStr = static_cast<const SfxStringItem&>(pReqArgs->
     210           0 :                                     Get( SID_INSERT_MATRIX )).GetValue();
     211           0 :                     ScDocument* pDoc = GetViewData()->GetDocument();
     212           0 :                     pTabViewShell->EnterMatrix( aStr, pDoc->GetGrammar() );
     213           0 :                     rReq.Done();
     214             :                 }
     215             :             }
     216           0 :             break;
     217             : 
     218             :         case FID_INPUTLINE_ENTER:
     219             :         case FID_INPUTLINE_BLOCK:
     220             :         case FID_INPUTLINE_MATRIX:
     221             :             {
     222           0 :                 if( pReqArgs == 0 ) //XXX temporary HACK to avoid GPF
     223           0 :                     break;
     224             : 
     225             :                 const ScInputStatusItem* pStatusItem
     226             :                     = static_cast<const ScInputStatusItem*>(&pReqArgs->
     227           0 :                             Get( FID_INPUTLINE_STATUS ));
     228             : 
     229           0 :                 ScAddress aCursorPos = pStatusItem->GetPos();
     230           0 :                 OUString aString = pStatusItem->GetString();
     231           0 :                 const EditTextObject* pData = pStatusItem->GetEditData();
     232             : 
     233           0 :                 if (pData)
     234             :                 {
     235           0 :                     if (nSlot == FID_INPUTLINE_BLOCK)
     236             :                     {
     237           0 :                         pTabViewShell->EnterBlock( aString, pData );
     238             :                     }
     239           0 :                     else if ( !aString.isEmpty() && ( aString[0] == '=' || aString[0] == '+' || aString[0] == '-' ) )
     240             :                     {
     241           0 :                         pTabViewShell->EnterData( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(), aString, pData );
     242             :                     }
     243             :                     else
     244             :                     {
     245           0 :                         pTabViewShell->EnterData(aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(), *pData);
     246             :                     }
     247             :                 }
     248             :                 else
     249             :                 {
     250           0 :                     if (nSlot == FID_INPUTLINE_ENTER)
     251             :                     {
     252           0 :                         if (
     253           0 :                             aCursorPos.Col() == GetViewData()->GetCurX() &&
     254           0 :                             aCursorPos.Row() == GetViewData()->GetCurY() &&
     255           0 :                             aCursorPos.Tab() == GetViewData()->GetTabNo()
     256             :                             )
     257             :                         {
     258           0 :                             SfxStringItem   aItem( SID_ENTER_STRING, aString );
     259             : 
     260             :                             // SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings();
     261             :                             const SfxPoolItem* aArgs[2];
     262           0 :                             aArgs[0] = &aItem;
     263           0 :                             aArgs[1] = NULL;
     264           0 :                             rBindings.Execute( SID_ENTER_STRING, aArgs );
     265             :                         }
     266             :                         else
     267             :                         {
     268           0 :                             pTabViewShell->EnterData( aCursorPos.Col(),
     269             :                                                     aCursorPos.Row(),
     270           0 :                                                     aCursorPos.Tab(),
     271           0 :                                                     aString );
     272           0 :                             rReq.Done();
     273             :                         }
     274             :                     }
     275           0 :                     else if (nSlot == FID_INPUTLINE_BLOCK)
     276             :                     {
     277           0 :                         pTabViewShell->EnterBlock( aString, NULL );
     278           0 :                         rReq.Done();
     279             :                     }
     280             :                     else
     281             :                     {
     282           0 :                         ScDocument* pDoc = GetViewData()->GetDocument();
     283           0 :                         pTabViewShell->EnterMatrix( aString, pDoc->GetGrammar() );
     284           0 :                         rReq.Done();
     285             :                     }
     286             :                 }
     287             : 
     288             :                 pTabViewShell->SetAutoSpellData(
     289           0 :                     aCursorPos.Col(), aCursorPos.Row(), pStatusItem->GetMisspellRanges());
     290             : 
     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)
     294             :             }
     295           0 :             break;
     296             : 
     297             :         case SID_OPENDLG_FUNCTION:
     298             :             {
     299           0 :                 sal_uInt16 nId = SID_OPENDLG_FUNCTION;
     300           0 :                 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
     301           0 :                 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
     302             : 
     303           0 :                 pScMod->SetRefDialog( nId, pWnd == nullptr );
     304           0 :                 rReq.Ignore();
     305             :             }
     306           0 :             break;
     307             : 
     308             :         case SID_OPENDLG_CONSOLIDATE:
     309             :             {
     310           0 :                 sal_uInt16          nId  = ScConsolidateDlgWrapper::GetChildWindowId();
     311           0 :                 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
     312           0 :                 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
     313             : 
     314           0 :                 pScMod->SetRefDialog( nId, pWnd == nullptr );
     315             :             }
     316           0 :             break;
     317             : 
     318             :         case FID_CELL_FORMAT:
     319             :             {
     320           0 :                 if ( pReqArgs != NULL )
     321             :                 {
     322             : 
     323             :                     // set cell attribute without dialog:
     324             : 
     325             :                     boost::scoped_ptr<SfxItemSet> pEmptySet(
     326             :                                         new SfxItemSet( *pReqArgs->GetPool(),
     327             :                                                         ATTR_PATTERN_START,
     328           0 :                                                         ATTR_PATTERN_END ));
     329             : 
     330             :                     boost::scoped_ptr<SfxItemSet> pNewSet(
     331             :                                         new SfxItemSet( *pReqArgs->GetPool(),
     332             :                                                         ATTR_PATTERN_START,
     333           0 :                                                         ATTR_PATTERN_END ));
     334             : 
     335           0 :                     const SfxPoolItem*  pAttr = NULL;
     336           0 :                     sal_uInt16              nWhich = 0;
     337             : 
     338           0 :                     for ( nWhich=ATTR_PATTERN_START; nWhich<=ATTR_PATTERN_END; nWhich++ )
     339           0 :                         if ( pReqArgs->GetItemState( nWhich, true, &pAttr ) == SfxItemState::SET )
     340           0 :                             pNewSet->Put( *pAttr );
     341             : 
     342           0 :                     pTabViewShell->ApplyAttributes( pNewSet.get(), pEmptySet.get() );
     343             : 
     344           0 :                     pNewSet.reset();
     345           0 :                     pEmptySet.reset();
     346             : 
     347           0 :                     rReq.Done();
     348             :                 }
     349           0 :                 else if ( pReqArgs == NULL )
     350             :                 {
     351           0 :                     pTabViewShell->ExecuteCellFormatDlg( rReq );
     352             :                 }
     353             :             }
     354           0 :             break;
     355             : 
     356             :         case SID_ENABLE_HYPHENATION:
     357           0 :             pTabViewShell->ExecuteCellFormatDlg(rReq, "alignment");
     358           0 :             break;
     359             : 
     360             :         case SID_PROPERTY_PANEL_CELLTEXT_DLG:
     361           0 :             pTabViewShell->ExecuteCellFormatDlg( rReq, "font" );
     362           0 :             break;
     363             : 
     364             :         case SID_CELL_FORMAT_BORDER:
     365           0 :             pTabViewShell->ExecuteCellFormatDlg( rReq, "borders" );
     366           0 :             break;
     367             : 
     368             :         case SID_CHAR_DLG_EFFECT:
     369           0 :             pTabViewShell->ExecuteCellFormatDlg( rReq, "fonteffects" );
     370           0 :             break;
     371             : 
     372             :         case SID_OPENDLG_SOLVE:
     373             :             {
     374           0 :                 sal_uInt16          nId  = ScSolverDlgWrapper::GetChildWindowId();
     375           0 :                 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
     376           0 :                 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
     377             : 
     378           0 :                 pScMod->SetRefDialog( nId, pWnd == nullptr );
     379             :             }
     380           0 :             break;
     381             : 
     382             :         case SID_OPENDLG_OPTSOLVER:
     383             :             {
     384           0 :                 sal_uInt16 nId = ScOptSolverDlgWrapper::GetChildWindowId();
     385           0 :                 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
     386           0 :                 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
     387             : 
     388           0 :                 pScMod->SetRefDialog( nId, pWnd == nullptr );
     389             :             }
     390           0 :             break;
     391             : 
     392             :         case SID_OPENDLG_TABOP:
     393             :             {
     394           0 :                 sal_uInt16          nId  = ScTabOpDlgWrapper::GetChildWindowId();
     395           0 :                 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
     396           0 :                 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
     397             : 
     398           0 :                 pScMod->SetRefDialog( nId, pWnd == nullptr );
     399             :             }
     400           0 :             break;
     401             : 
     402             :         case SID_SCENARIOS:
     403             :             {
     404           0 :                 ScDocument* pDoc = GetViewData()->GetDocument();
     405           0 :                 ScMarkData& rMark = GetViewData()->GetMarkData();
     406           0 :                 SCTAB nTab = GetViewData()->GetTabNo();
     407             : 
     408           0 :                 if ( pDoc->IsScenario(nTab) )
     409             :                 {
     410           0 :                     rMark.MarkToMulti();
     411           0 :                     if ( rMark.IsMultiMarked() )
     412             :                     {
     413           0 :                         if (   rReq.IsAPI()
     414           0 :                             || RET_YES ==
     415           0 :                                ScopedVclPtr<QueryBox>::Create( pTabViewShell->GetDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
     416           0 :                                          ScGlobal::GetRscString(STR_UPDATE_SCENARIO) )->
     417           0 :                                         Execute() )
     418             :                         {
     419           0 :                             pTabViewShell->ExtendScenario();
     420           0 :                             rReq.Done();
     421             :                         }
     422             :                     }
     423           0 :                     else if( ! rReq.IsAPI() )
     424             :                     {
     425           0 :                         ScopedVclPtrInstance<MessageDialog> aErrorBox(pTabViewShell->GetDialogParent(),
     426           0 :                                             ScGlobal::GetRscString(STR_NOAREASELECTED));
     427           0 :                         aErrorBox->Execute();
     428             :                     }
     429             :                 }
     430             :                 else
     431             :                 {
     432           0 :                     rMark.MarkToMulti();
     433           0 :                     if ( rMark.IsMultiMarked() )
     434             :                     {
     435           0 :                         SCTAB i=1;
     436           0 :                         OUString aBaseName;
     437           0 :                         OUString aName;
     438           0 :                         OUString aComment;
     439           0 :                         Color  aColor;
     440             :                         sal_uInt16 nFlags;
     441             : 
     442           0 :                         OUString aTmp;
     443           0 :                         pDoc->GetName(nTab, aTmp);
     444           0 :                         aBaseName = aTmp;
     445           0 :                         aBaseName += "_";
     446           0 :                         aBaseName += ScGlobal::GetRscString(STR_SCENARIO);
     447           0 :                         aBaseName += "_";
     448             : 
     449             :                         //  first test, if the prefix is recognised as valid,
     450             :                         //  else avoid only doubles
     451           0 :                         bool bPrefix = ScDocument::ValidTabName( aBaseName );
     452             :                         OSL_ENSURE(bPrefix, "ungueltiger Tabellenname");
     453             : 
     454           0 :                         while ( pDoc->IsScenario(nTab+i) )
     455           0 :                             i++;
     456             : 
     457             :                         bool bValid;
     458             :                         SCTAB nDummy;
     459           0 :                         do
     460             :                         {
     461           0 :                             aName = aBaseName + OUString::number( i );
     462           0 :                             if (bPrefix)
     463           0 :                                 bValid = pDoc->ValidNewTabName( aName );
     464             :                             else
     465           0 :                                 bValid = !pDoc->GetTable( aName, nDummy );
     466           0 :                             ++i;
     467             :                         }
     468           0 :                         while ( !bValid && i <= MAXTAB + 2 );
     469             : 
     470           0 :                         if ( pReqArgs != NULL )
     471             :                         {
     472           0 :                             OUString aArgName;
     473           0 :                             OUString aArgComment;
     474             :                             const SfxPoolItem* pItem;
     475           0 :                             if ( pReqArgs->GetItemState( SID_SCENARIOS, true, &pItem ) == SfxItemState::SET )
     476           0 :                                 aArgName = static_cast<const SfxStringItem*>(pItem)->GetValue();
     477           0 :                             if ( pReqArgs->GetItemState( SID_NEW_TABLENAME, true, &pItem ) == SfxItemState::SET )
     478           0 :                                 aArgComment = static_cast<const SfxStringItem*>(pItem)->GetValue();
     479             : 
     480           0 :                             aColor = Color( COL_LIGHTGRAY );        // Default
     481           0 :                             nFlags = 0;                             // not-TwoWay
     482             : 
     483           0 :                             pTabViewShell->MakeScenario( aArgName, aArgComment, aColor, nFlags );
     484           0 :                             if( ! rReq.IsAPI() )
     485           0 :                                 rReq.Done();
     486             :                         }
     487             :                         else
     488             :                         {
     489           0 :                             bool bSheetProtected = pDoc->IsTabProtected(nTab);
     490           0 :                             ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     491             :                             OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
     492             : 
     493           0 :                             boost::scoped_ptr<AbstractScNewScenarioDlg> pNewDlg(pFact->CreateScNewScenarioDlg(pTabViewShell->GetDialogParent(), aName, false, bSheetProtected));
     494             :                             OSL_ENSURE(pNewDlg, "Dialog create fail!");
     495           0 :                             if ( pNewDlg->Execute() == RET_OK )
     496             :                             {
     497           0 :                                 pNewDlg->GetScenarioData( aName, aComment, aColor, nFlags );
     498           0 :                                 pTabViewShell->MakeScenario( aName, aComment, aColor, nFlags );
     499             : 
     500           0 :                                 rReq.AppendItem( SfxStringItem( SID_SCENARIOS, aName ) );
     501           0 :                                 rReq.AppendItem( SfxStringItem( SID_NEW_TABLENAME, aComment ) );
     502           0 :                                 rReq.Done();
     503           0 :                             }
     504           0 :                         }
     505             :                     }
     506           0 :                     else if( ! rReq.IsAPI() )
     507             :                     {
     508           0 :                         pTabViewShell->ErrorMessage(STR_ERR_NEWSCENARIO);
     509             :                     }
     510             :                 }
     511             :             }
     512           0 :             break;
     513             : 
     514             :         case SID_SELECTALL:
     515             :             {
     516           0 :                 pTabViewShell->SelectAll();
     517           0 :                 rReq.Done();
     518             :             }
     519           0 :             break;
     520             : 
     521             :         case FID_ROW_HEIGHT:
     522             :             {
     523           0 :                 if ( pReqArgs )
     524             :                 {
     525           0 :                     const SfxUInt16Item&  rUInt16Item = static_cast<const SfxUInt16Item&>(pReqArgs->Get( FID_ROW_HEIGHT ));
     526             : 
     527             :                     // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
     528             :                     pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT,
     529           0 :                                     sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) );
     530           0 :                     if( ! rReq.IsAPI() )
     531           0 :                         rReq.Done();
     532             :                 }
     533             :                 else
     534             :                 {
     535           0 :                     ScViewData* pData      = GetViewData();
     536           0 :                     FieldUnit   eMetric    = SC_MOD()->GetAppOptions().GetAppMetric();
     537             :                     sal_uInt16      nCurHeight = pData->GetDocument()->
     538             :                                                 GetRowHeight( pData->GetCurY(),
     539           0 :                                                               pData->GetTabNo() );
     540           0 :                     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     541             :                     assert(pFact); //ScAbstractFactory create fail!
     542             : 
     543             :                     boost::scoped_ptr<AbstractScMetricInputDlg> pDlg(pFact->CreateScMetricInputDlg(
     544             :                         pTabViewShell->GetDialogParent(), "RowHeightDialog",
     545             :                         nCurHeight, ScGlobal::nStdRowHeight,
     546           0 :                         eMetric, 2, MAX_ROW_HEIGHT));
     547             :                     assert(pDlg); //Dialog create fail
     548             : 
     549           0 :                     if ( pDlg->Execute() == RET_OK )
     550             :                     {
     551           0 :                         long nVal = pDlg->GetInputValue();
     552           0 :                         pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT, (sal_uInt16)nVal );
     553             : 
     554             :                         // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
     555           0 :                         rReq.AppendItem( SfxUInt16Item( FID_ROW_HEIGHT, (sal_uInt16)TwipsToEvenHMM(nVal) ) );
     556           0 :                         rReq.Done();
     557             : 
     558           0 :                     }
     559             :                 }
     560             :             }
     561           0 :             break;
     562             : 
     563             :         case FID_ROW_OPT_HEIGHT:
     564             :             {
     565           0 :                 if ( pReqArgs )
     566             :                 {
     567           0 :                     const SfxUInt16Item&  rUInt16Item = static_cast<const SfxUInt16Item&>(pReqArgs->Get( FID_ROW_OPT_HEIGHT ));
     568             : 
     569             :                     // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
     570             :                     pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_OPTIMAL,
     571           0 :                                     sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) );
     572           0 :                     ScGlobal::nLastRowHeightExtra = rUInt16Item.GetValue();
     573             : 
     574           0 :                     if( ! rReq.IsAPI() )
     575           0 :                         rReq.Done();
     576             :                 }
     577             :                 else
     578             :                 {
     579           0 :                     FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric();
     580             : 
     581           0 :                     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     582             :                     assert(pFact); //ScAbstractFactory create fail!
     583             : 
     584             :                     boost::scoped_ptr<AbstractScMetricInputDlg> pDlg(pFact->CreateScMetricInputDlg(
     585             :                         pTabViewShell->GetDialogParent(), "OptimalRowHeightDialog",
     586           0 :                         ScGlobal::nLastRowHeightExtra, 0, eMetric, 1, MAX_EXTRA_HEIGHT));
     587             :                     assert(pDlg); //Dialog create fail!
     588             : 
     589           0 :                     if ( pDlg->Execute() == RET_OK )
     590             :                     {
     591           0 :                         long nVal = pDlg->GetInputValue();
     592           0 :                         pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_OPTIMAL, (sal_uInt16)nVal );
     593           0 :                         ScGlobal::nLastRowHeightExtra = nVal;
     594             : 
     595             :                         // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
     596           0 :                         rReq.AppendItem( SfxUInt16Item( FID_ROW_OPT_HEIGHT, (sal_uInt16)TwipsToEvenHMM(nVal) ) );
     597           0 :                         rReq.Done();
     598             : 
     599           0 :                     }
     600             :                 }
     601             :             }
     602           0 :             break;
     603             : 
     604             :         case FID_COL_WIDTH:
     605             :             {
     606           0 :                 if ( pReqArgs )
     607             :                 {
     608           0 :                     const SfxUInt16Item&  rUInt16Item = static_cast<const SfxUInt16Item&>(pReqArgs->Get( FID_COL_WIDTH ));
     609             : 
     610             :                     // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
     611             :                     pTabViewShell->SetMarkedWidthOrHeight( true, SC_SIZE_DIRECT,
     612           0 :                                     sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) );
     613           0 :                     if( ! rReq.IsAPI() )
     614           0 :                         rReq.Done();
     615             :                 }
     616             :                 else
     617             :                 {
     618           0 :                     FieldUnit   eMetric    = SC_MOD()->GetAppOptions().GetAppMetric();
     619           0 :                     ScViewData* pData      = GetViewData();
     620             :                     sal_uInt16      nCurHeight = pData->GetDocument()->
     621           0 :                                                 GetColWidth( pData->GetCurX(),
     622           0 :                                                              pData->GetTabNo() );
     623           0 :                     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     624             :                     assert(pFact); //ScAbstractFactory create fail!
     625             : 
     626             :                     boost::scoped_ptr<AbstractScMetricInputDlg> pDlg(pFact->CreateScMetricInputDlg(
     627             :                         pTabViewShell->GetDialogParent(), "ColWidthDialog", nCurHeight,
     628           0 :                         STD_COL_WIDTH, eMetric, 2, MAX_COL_WIDTH));
     629             :                     assert(pDlg); //Dialog create fail!
     630             : 
     631           0 :                     if ( pDlg->Execute() == RET_OK )
     632             :                     {
     633           0 :                         long nVal = pDlg->GetInputValue();
     634           0 :                         pTabViewShell->SetMarkedWidthOrHeight( true, SC_SIZE_DIRECT, (sal_uInt16)nVal );
     635             : 
     636             :                         // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
     637           0 :                         rReq.AppendItem( SfxUInt16Item( FID_COL_WIDTH, (sal_uInt16)TwipsToEvenHMM(nVal)) );
     638           0 :                         rReq.Done();
     639             : 
     640           0 :                     }
     641             :                 }
     642             :             }
     643           0 :             break;
     644             : 
     645             :         case FID_COL_OPT_WIDTH:
     646             :             {
     647           0 :                 if ( pReqArgs )
     648             :                 {
     649           0 :                     const SfxUInt16Item&  rUInt16Item = static_cast<const SfxUInt16Item&>(pReqArgs->Get( FID_COL_OPT_WIDTH ));
     650             : 
     651             :                     // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
     652             :                     pTabViewShell->SetMarkedWidthOrHeight( true, SC_SIZE_OPTIMAL,
     653           0 :                                     sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) );
     654           0 :                     ScGlobal::nLastColWidthExtra = rUInt16Item.GetValue();
     655             : 
     656           0 :                     if( ! rReq.IsAPI() )
     657           0 :                         rReq.Done();
     658             :                 }
     659             :                 else
     660             :                 {
     661           0 :                     FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric();
     662             : 
     663           0 :                     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     664             :                     assert(pFact); //ScAbstractFactory create fail!
     665             : 
     666             :                     boost::scoped_ptr<AbstractScMetricInputDlg> pDlg(pFact->CreateScMetricInputDlg(
     667             :                         pTabViewShell->GetDialogParent(), "OptimalColWidthDialog",
     668           0 :                         ScGlobal::nLastColWidthExtra, STD_EXTRA_WIDTH, eMetric, 1, MAX_EXTRA_WIDTH));
     669             :                     assert(pDlg); //Dialog create fail!
     670           0 :                     if ( pDlg->Execute() == RET_OK )
     671             :                     {
     672           0 :                         long nVal = pDlg->GetInputValue();
     673           0 :                         pTabViewShell->SetMarkedWidthOrHeight( true, SC_SIZE_OPTIMAL, (sal_uInt16)nVal );
     674           0 :                         ScGlobal::nLastColWidthExtra = nVal;
     675             : 
     676             :                         // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
     677           0 :                         rReq.AppendItem( SfxUInt16Item( FID_COL_OPT_WIDTH, (sal_uInt16)TwipsToEvenHMM(nVal) ) );
     678           0 :                         rReq.Done();
     679           0 :                     }
     680             :                 }
     681             :             }
     682           0 :             break;
     683             : 
     684             :         case FID_COL_OPT_DIRECT:
     685           0 :             pTabViewShell->SetMarkedWidthOrHeight( true, SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH );
     686           0 :             rReq.Done();
     687           0 :             break;
     688             : 
     689             :         case FID_ROW_HIDE:
     690           0 :             pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT, 0 );
     691           0 :             rReq.Done();
     692           0 :             break;
     693             :         case FID_ROW_SHOW:
     694           0 :             pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_SHOW, 0 );
     695           0 :             rReq.Done();
     696           0 :             break;
     697             :         case FID_COL_HIDE:
     698           0 :             pTabViewShell->SetMarkedWidthOrHeight( true, SC_SIZE_DIRECT, 0 );
     699           0 :             rReq.Done();
     700           0 :             break;
     701             :         case FID_COL_SHOW:
     702           0 :             pTabViewShell->SetMarkedWidthOrHeight( true, SC_SIZE_SHOW, 0 );
     703           0 :             rReq.Done();
     704           0 :             break;
     705             : 
     706             :         case SID_CELL_FORMAT_RESET:
     707             :             {
     708           0 :                 pTabViewShell->DeleteContents( IDF_HARDATTR | IDF_EDITATTR );
     709           0 :                 rReq.Done();
     710             :             }
     711           0 :             break;
     712             : 
     713             :         case FID_MERGE_ON:
     714             :         case FID_MERGE_OFF:
     715             :         case FID_MERGE_TOGGLE:
     716             :         {
     717           0 :             if ( !GetViewData()->GetDocument()->GetChangeTrack() )
     718             :             {
     719             :                 // test whether to merge or to split
     720           0 :                 bool bMerge = false;
     721           0 :                 bool bCenter = false;
     722           0 :                 switch( nSlot )
     723             :                 {
     724             :                     case FID_MERGE_ON:
     725           0 :                         bMerge = true;
     726           0 :                     break;
     727             :                     case FID_MERGE_OFF:
     728           0 :                         bMerge = false;
     729           0 :                     break;
     730             :                     case FID_MERGE_TOGGLE:
     731             :                     {
     732           0 :                         bCenter = true;
     733           0 :                         SfxPoolItem* pItem = 0;
     734           0 :                         if( rBindings.QueryState( nSlot, pItem ) >= SfxItemState::DEFAULT )
     735           0 :                             bMerge = !static_cast< SfxBoolItem* >( pItem )->GetValue();
     736             : 
     737           0 :                         delete pItem;
     738             :                     }
     739           0 :                     break;
     740             :                 }
     741             : 
     742           0 :                 if( bMerge )
     743             :                 {
     744             :                     // merge - check if to move contents of covered cells
     745           0 :                     bool bMoveContents = false;
     746           0 :                     bool bApi = rReq.IsAPI();
     747             :                     const SfxPoolItem* pItem;
     748           0 :                     if ( pReqArgs &&
     749           0 :                         pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET )
     750             :                     {
     751             :                         OSL_ENSURE(pItem && pItem->ISA(SfxBoolItem), "falsches Item");
     752           0 :                         bMoveContents = static_cast<const SfxBoolItem*>(pItem)->GetValue();
     753             :                     }
     754             : 
     755           0 :                     if (pTabViewShell->MergeCells( bApi, bMoveContents, true, bCenter ))
     756             :                     {
     757           0 :                         if (!bApi && bMoveContents)             // "yes" clicked in dialog
     758           0 :                             rReq.AppendItem( SfxBoolItem( nSlot, bMoveContents ) );
     759           0 :                         rBindings.Invalidate( nSlot );
     760           0 :                         rReq.Done();
     761             :                     }
     762             :                 }
     763             :                 else
     764             :                 {
     765             :                     // split cells
     766           0 :                     if (pTabViewShell->RemoveMerge())
     767             :                     {
     768           0 :                         rBindings.Invalidate( nSlot );
     769           0 :                         rReq.Done();
     770             :                     }
     771             :                 }
     772           0 :                 break;
     773             :             }
     774             :         }
     775           0 :         break;
     776             : 
     777             :         case SID_AUTOFORMAT:
     778             :             {
     779           0 :                 vcl::Window* pDlgParent = pTabViewShell->GetDialogParent();
     780             :                 SCCOL nStartCol;
     781             :                 SCROW nStartRow;
     782             :                 SCTAB nStartTab;
     783             :                 SCCOL nEndCol;
     784             :                 SCROW nEndRow;
     785             :                 SCTAB nEndTab;
     786             : 
     787           0 :                 const ScMarkData& rMark = GetViewData()->GetMarkData();
     788           0 :                 if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
     789           0 :                     pTabViewShell->MarkDataArea( true );
     790             : 
     791             :                 GetViewData()->GetSimpleArea( nStartCol,nStartRow,nStartTab,
     792           0 :                                               nEndCol,nEndRow,nEndTab );
     793             : 
     794           0 :                 if (   ( std::abs((SCsCOL)nEndCol-(SCsCOL)nStartCol) > 1 )
     795           0 :                     && ( std::abs((SCsROW)nEndRow-(SCsROW)nStartRow) > 1 ) )
     796             :                 {
     797           0 :                     if ( pReqArgs )
     798             :                     {
     799           0 :                         const SfxStringItem& rNameItem = static_cast<const SfxStringItem&>(pReqArgs->Get( SID_AUTOFORMAT ));
     800           0 :                         ScAutoFormat* pFormat = ScGlobal::GetOrCreateAutoFormat();
     801           0 :                         ScAutoFormat::const_iterator it = pFormat->find(rNameItem.GetValue());
     802           0 :                         ScAutoFormat::const_iterator itBeg = pFormat->begin();
     803           0 :                         size_t nIndex = std::distance(itBeg, it);
     804             : 
     805           0 :                         pTabViewShell->AutoFormat( nIndex );
     806             : 
     807           0 :                         if( ! rReq.IsAPI() )
     808           0 :                             rReq.Done();
     809             :                     }
     810             :                     else
     811             :                     {
     812           0 :                         ScGlobal::ClearAutoFormat();
     813           0 :                         boost::scoped_ptr<ScAutoFormatData> pNewEntry(pTabViewShell->CreateAutoFormatData());
     814           0 :                         ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     815             :                         OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
     816             : 
     817           0 :                         boost::scoped_ptr<AbstractScAutoFormatDlg> pDlg(pFact->CreateScAutoFormatDlg(pDlgParent, ScGlobal::GetOrCreateAutoFormat(), pNewEntry.get(), GetViewData()));
     818             :                         OSL_ENSURE(pDlg, "Dialog create fail!");
     819             : 
     820           0 :                         if ( pDlg->Execute() == RET_OK )
     821             :                         {
     822           0 :                             ScEditableTester aTester( pTabViewShell );
     823           0 :                             if ( !aTester.IsEditable() )
     824             :                             {
     825           0 :                                 pTabViewShell->ErrorMessage(aTester.GetMessageId());
     826             :                             }
     827             :                             else
     828             :                             {
     829           0 :                                 pTabViewShell->AutoFormat( pDlg->GetIndex() );
     830             : 
     831           0 :                                 rReq.AppendItem( SfxStringItem( SID_AUTOFORMAT, pDlg->GetCurrFormatName() ) );
     832           0 :                                 rReq.Done();
     833             :                             }
     834           0 :                         }
     835           0 :                     }
     836             :                 }
     837             :                 else
     838             :                     ScopedVclPtrInstance<MessageDialog>(pDlgParent,
     839           0 :                               ScGlobal::GetRscString(STR_INVALID_AFAREA) )->Execute();
     840             :             }
     841           0 :             break;
     842             : 
     843             :         case SID_CANCEL:
     844             :             {
     845           0 :                 if (GetViewData()->HasEditView(GetViewData()->GetActivePart()))
     846           0 :                     pScMod->InputCancelHandler();
     847           0 :                 else if (pTabViewShell->HasPaintBrush())
     848           0 :                     pTabViewShell->ResetBrushDocument();            // abort format paint brush
     849           0 :                 else if (pTabViewShell->HasHintWindow())
     850           0 :                     pTabViewShell->RemoveHintWindow();
     851           0 :                 else if( ScViewUtil::IsFullScreen( *pTabViewShell ) )
     852           0 :                     ScViewUtil::SetFullScreen( *pTabViewShell, false );
     853             :                 else
     854             :                 {
     855             :                     // TODO/LATER: when is this code executed?
     856           0 :                     pTabViewShell->Escape();
     857             :                 }
     858             :             }
     859           0 :             break;
     860             : 
     861             :         case SID_DATA_SELECT:
     862           0 :             pTabViewShell->StartDataSelect();
     863           0 :             break;
     864             : 
     865             :         case SID_DETECTIVE_FILLMODE:
     866             :             {
     867           0 :                 bool bOldMode = pTabViewShell->IsAuditShell();
     868           0 :                 pTabViewShell->SetAuditShell( !bOldMode );
     869           0 :                 pTabViewShell->Invalidate( nSlot );
     870             :             }
     871           0 :             break;
     872             : 
     873             :         case FID_INPUTLINE_STATUS:
     874             :             OSL_FAIL("Execute von InputLine-Status");
     875           0 :             break;
     876             : 
     877             :         case SID_STATUS_DOCPOS:
     878             :             // Launch navigator.
     879           0 :             GetViewData()->GetDispatcher().Execute(
     880           0 :                 SID_NAVIGATOR, SfxCallMode::SYNCHRON|SfxCallMode::RECORD );
     881           0 :             break;
     882             : 
     883             :         case SID_MARKAREA:
     884             :             // called from Basic at the hidden view to select a range in the visible view
     885             :             OSL_FAIL("old slot SID_MARKAREA");
     886           0 :             break;
     887             : 
     888             :         default:
     889             :             OSL_FAIL("Unbekannter Slot bei ScCellShell::Execute");
     890           0 :             break;
     891             :     }
     892         156 : }
     893             : 
     894             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11