LCOV - code coverage report
Current view: top level - sc/source/ui/view - tabvwshf.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 17 457 3.7 %
Date: 2012-08-25 Functions: 1 2 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 14 1050 1.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <boost/scoped_ptr.hpp>
      31                 :            : 
      32                 :            : #include "scitems.hxx"
      33                 :            : #include <sfx2/request.hxx>
      34                 :            : #include <sfx2/bindings.hxx>
      35                 :            : #include <sfx2/viewfrm.hxx>
      36                 :            : #include <basic/sbstar.hxx>
      37                 :            : #include <svl/languageoptions.hxx>
      38                 :            : #include <svl/stritem.hxx>
      39                 :            : #include <svl/whiter.hxx>
      40                 :            : #include <vcl/msgbox.hxx>
      41                 :            : #include <sfx2/objface.hxx>
      42                 :            : #include <svx/svxdlg.hxx>
      43                 :            : #include <editeng/colritem.hxx>
      44                 :            : 
      45                 :            : #include "tabvwsh.hxx"
      46                 :            : #include "sc.hrc"
      47                 :            : #include "docsh.hxx"
      48                 :            : #include "document.hxx"
      49                 :            : #include "shtabdlg.hxx"
      50                 :            : #include "scresid.hxx"
      51                 :            : #include "globstr.hrc"
      52                 :            : #include "docfunc.hxx"
      53                 :            : #include "eventuno.hxx"
      54                 :            : 
      55                 :            : #include "scabstdlg.hxx"
      56                 :            : 
      57                 :            : #include "tabbgcolor.hxx"
      58                 :            : #include "tabbgcolordlg.hxx"
      59                 :            : #include "sccommands.h"
      60                 :            : #include "markdata.hxx"
      61                 :            : 
      62                 :            : #include <vector>
      63                 :            : 
      64                 :            : using ::boost::scoped_ptr;
      65                 :            : using namespace com::sun::star;
      66                 :            : 
      67                 :          0 : void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
      68                 :            : {
      69                 :          0 :     ScViewData* pViewData   = GetViewData();
      70                 :          0 :     ScDocument* pDoc        = pViewData->GetDocument();
      71                 :            : 
      72                 :          0 :     SCTAB       nCurrentTab = pViewData->GetTabNo();
      73                 :          0 :     SCTAB       nTabCount   = pDoc->GetTableCount();
      74                 :          0 :     sal_uInt16      nSlot       = rReq.GetSlot();
      75                 :          0 :     const SfxItemSet* pReqArgs = rReq.GetArgs();
      76                 :            : 
      77                 :          0 :     HideListBox();                  // Autofilter-DropDown-Listbox
      78                 :            : 
      79   [ #  #  #  #  :          0 :     switch ( nSlot )
          #  #  #  #  #  
                #  #  # ]
      80                 :            :     {
      81                 :            :         case FID_TABLE_VISIBLE:
      82                 :            :             {
      83                 :          0 :                 rtl::OUString aName;
      84         [ #  # ]:          0 :                 pDoc->GetName( nCurrentTab, aName );
      85                 :            : 
      86                 :          0 :                 sal_Bool bVisible=sal_True;
      87         [ #  # ]:          0 :                 if( pReqArgs != NULL )
      88                 :            :                 {
      89                 :            :                     const SfxPoolItem* pItem;
      90 [ #  # ][ #  # ]:          0 :                     if( pReqArgs->HasItem( FID_TABLE_VISIBLE, &pItem ) )
      91                 :          0 :                         bVisible = ((const SfxBoolItem*)pItem)->GetValue();
      92                 :            :                 }
      93                 :            : 
      94         [ #  # ]:          0 :                 if( ! bVisible )            // ausblenden
      95                 :            :                 {
      96         [ #  # ]:          0 :                     ScMarkData& rMark = pViewData->GetMarkData();
      97         [ #  # ]:          0 :                     SCTAB nTabSelCount = rMark.GetSelectCount();
      98                 :          0 :                     sal_uInt16 nVis = 0;
      99 [ #  # ][ #  # ]:          0 :                     for ( SCTAB i=0; i < nTabCount && nVis<2; i++ )
                 [ #  # ]
     100 [ #  # ][ #  # ]:          0 :                         if (pDoc->IsVisible(i))
     101                 :          0 :                             ++nVis;
     102 [ #  # ][ #  # ]:          0 :                     if ( nVis<2 || !pDoc->IsDocEditable() || nTabSelCount > 1 )
         [ #  # ][ #  # ]
                 [ #  # ]
     103                 :            :                         break;
     104                 :            : 
     105                 :            :                     SCTAB nHideTab;
     106 [ #  # ][ #  # ]:          0 :                     if (pDoc->GetTable( aName, nHideTab ))
     107         [ #  # ]:          0 :                         HideTable( nHideTab );
     108                 :            :                 }
     109                 :            :                 else                        // einblenden
     110                 :            :                 {
     111 [ #  # ][ #  # ]:          0 :                     ShowTable( aName );
                 [ #  # ]
     112         [ #  # ]:          0 :                 }
     113                 :            :             }
     114                 :          0 :             break;
     115                 :            : 
     116                 :            :         case FID_TABLE_HIDE:
     117                 :            :             {
     118         [ #  # ]:          0 :                 ScMarkData& rMark = pViewData->GetMarkData();
     119         [ #  # ]:          0 :                 SCTAB nTabSelCount = rMark.GetSelectCount();
     120                 :          0 :                 sal_uInt16 nVis = 0;
     121 [ #  # ][ #  # ]:          0 :                 for ( SCTAB i=0; i < nTabCount && nVis<2; i++ )
                 [ #  # ]
     122 [ #  # ][ #  # ]:          0 :                     if (pDoc->IsVisible(i))
     123                 :          0 :                         ++nVis;
     124 [ #  # ][ #  # ]:          0 :                 if ( nVis<2 || !pDoc->IsDocEditable() || nTabSelCount > 1 )
         [ #  # ][ #  # ]
                 [ #  # ]
     125                 :            :                     break;
     126                 :            : 
     127                 :            : 
     128                 :          0 :                 rtl::OUString aName;
     129         [ #  # ]:          0 :                 if( pReqArgs != NULL )
     130                 :            :                 {
     131                 :            :                     const SfxPoolItem* pItem;
     132 [ #  # ][ #  # ]:          0 :                     if( pReqArgs->HasItem( FID_TABLE_HIDE, &pItem ) )
     133         [ #  # ]:          0 :                         aName = ((const SfxStringItem*)pItem)->GetValue();
     134                 :            :                 }
     135                 :            : 
     136         [ #  # ]:          0 :                 if (aName.isEmpty())
     137                 :            :                 {
     138         [ #  # ]:          0 :                     pDoc->GetName( nCurrentTab, aName );        // aktuelle Tabelle
     139 [ #  # ][ #  # ]:          0 :                     rReq.AppendItem( SfxStringItem( FID_TABLE_HIDE, aName ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     140                 :            :                 }
     141                 :            : 
     142                 :            :                 SCTAB nHideTab;
     143 [ #  # ][ #  # ]:          0 :                 if (pDoc->GetTable( aName, nHideTab ))
     144         [ #  # ]:          0 :                     HideTable( nHideTab );
     145                 :            : 
     146 [ #  # ][ #  # ]:          0 :                 if( ! rReq.IsAPI() )
     147         [ #  # ]:          0 :                     rReq.Done();
     148                 :            :             }
     149                 :          0 :             break;
     150                 :            : 
     151                 :            :         case FID_TABLE_SHOW:
     152                 :            :             {
     153         [ #  # ]:          0 :                 String aName;
     154         [ #  # ]:          0 :                 if ( pReqArgs )
     155                 :            :                 {
     156                 :            :                     const SfxPoolItem* pItem;
     157 [ #  # ][ #  # ]:          0 :                     if( pReqArgs->HasItem( FID_TABLE_SHOW, &pItem ) )
     158                 :            :                     {
     159         [ #  # ]:          0 :                         aName = ((const SfxStringItem*)pItem)->GetValue();
     160                 :            : 
     161         [ #  # ]:          0 :                         ShowTable( aName );
     162                 :            : 
     163 [ #  # ][ #  # ]:          0 :                         if( ! rReq.IsAPI() )
     164         [ #  # ]:          0 :                             rReq.Done();
     165                 :            :                     }
     166                 :            :                 }
     167                 :            :                 else
     168                 :            :                 {
     169         [ #  # ]:          0 :                     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     170                 :            :                     OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
     171                 :            : 
     172 [ #  # ][ #  # ]:          0 :                     AbstractScShowTabDlg* pDlg = pFact->CreateScShowTabDlg( GetDialogParent(), RID_SCDLG_SHOW_TAB);
     173                 :            :                     OSL_ENSURE(pDlg, "Dialog create fail!");
     174                 :            : 
     175                 :          0 :                     rtl::OUString aTabName;
     176                 :          0 :                     sal_Bool bFirst = sal_True;
     177         [ #  # ]:          0 :                     for ( SCTAB i=0; i != nTabCount; i++ )
     178                 :            :                     {
     179 [ #  # ][ #  # ]:          0 :                         if (!pDoc->IsVisible(i))
     180                 :            :                         {
     181         [ #  # ]:          0 :                             pDoc->GetName( i, aTabName );
     182 [ #  # ][ #  # ]:          0 :                             pDlg->Insert( aTabName, bFirst );
                 [ #  # ]
     183                 :          0 :                             bFirst = false;
     184                 :            :                         }
     185                 :            :                     }
     186                 :            : 
     187 [ #  # ][ #  # ]:          0 :                     if ( pDlg->Execute() == RET_OK )
     188                 :            :                     {
     189         [ #  # ]:          0 :                         sal_uInt16 nCount = pDlg->GetSelectEntryCount();
     190         [ #  # ]:          0 :                         for (sal_uInt16 nPos=0; nPos<nCount; nPos++)
     191                 :            :                         {
     192 [ #  # ][ #  # ]:          0 :                             aName = pDlg->GetSelectEntry(nPos);
                 [ #  # ]
     193         [ #  # ]:          0 :                             ShowTable( aName );
     194                 :            :                         }
     195 [ #  # ][ #  # ]:          0 :                         rReq.AppendItem( SfxStringItem( FID_TABLE_SHOW, aName ) );
                 [ #  # ]
     196         [ #  # ]:          0 :                         rReq.Done();
     197                 :            :                     }
     198 [ #  # ][ #  # ]:          0 :                     delete pDlg;
     199         [ #  # ]:          0 :                 }
     200                 :            :             }
     201                 :          0 :             break;
     202                 :            : 
     203                 :            :         case FID_INS_TABLE:
     204                 :            :         case FID_INS_TABLE_EXT:
     205                 :            :             {
     206                 :          0 :                 ScMarkData& rMark    = pViewData->GetMarkData();
     207                 :          0 :                 SCTAB   nTabSelCount = rMark.GetSelectCount();
     208                 :          0 :                 SCTAB   nTabNr       = nCurrentTab;
     209                 :            : 
     210         [ #  # ]:          0 :                 if ( !pDoc->IsDocEditable() )
     211                 :          0 :                     break;                          // gesperrt
     212                 :            : 
     213         [ #  # ]:          0 :                 if ( pReqArgs != NULL )             // von Basic
     214                 :            :                 {
     215                 :          0 :                     sal_Bool bOk = false;
     216                 :            :                     const SfxPoolItem*  pTabItem;
     217                 :            :                     const SfxPoolItem*  pNameItem;
     218         [ #  # ]:          0 :                     String              aName;
     219                 :            : 
     220 [ #  # ][ #  # ]:          0 :                     if ( pReqArgs->HasItem( FN_PARAM_1, &pTabItem ) &&
         [ #  # ][ #  # ]
     221         [ #  # ]:          0 :                          pReqArgs->HasItem( nSlot, &pNameItem ) )
     222                 :            :                     {
     223                 :            :                         //  Tabellennr. von Basic: 1-basiert
     224                 :            : 
     225         [ #  # ]:          0 :                         aName = ((const SfxStringItem*)pNameItem)->GetValue();
     226                 :          0 :                         nTabNr = ((const SfxUInt16Item*)pTabItem)->GetValue() - 1;
     227         [ #  # ]:          0 :                         if ( nTabNr < nTabCount )
     228         [ #  # ]:          0 :                             bOk = InsertTable( aName, nTabNr );
     229                 :            :                     }
     230                 :            : 
     231         [ #  # ]:          0 :                     if (bOk)
     232 [ #  # ][ #  # ]:          0 :                         rReq.Done( *pReqArgs );
     233                 :            :                     //! sonst Fehler setzen
     234                 :            :                 }
     235                 :            :                 else                                // Dialog
     236                 :            :                 {
     237                 :          0 :                     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     238                 :            :                     OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
     239                 :            : 
     240                 :            :                     AbstractScInsertTableDlg* pDlg = pFact->CreateScInsertTableDlg( GetDialogParent(), *pViewData,
     241                 :            :                                                                                     nTabSelCount, nSlot == FID_INS_TABLE_EXT,
     242                 :          0 :                                                                                     RID_SCDLG_INSERT_TABLE);
     243                 :            :                     OSL_ENSURE(pDlg, "Dialog create fail!");
     244         [ #  # ]:          0 :                     if ( RET_OK == pDlg->Execute() )
     245                 :            :                     {
     246         [ #  # ]:          0 :                         if (pDlg->GetTablesFromFile())
     247                 :            :                         {
     248         [ #  # ]:          0 :                             std::vector<SCTAB> nTabs;
     249                 :          0 :                             sal_uInt16 n = 0;
     250         [ #  # ]:          0 :                             const String* pStr = pDlg->GetFirstTable( &n );
     251         [ #  # ]:          0 :                             while ( pStr )
     252                 :            :                             {
     253         [ #  # ]:          0 :                                 nTabs.push_back( static_cast<SCTAB>(n) );
     254         [ #  # ]:          0 :                                 pStr = pDlg->GetNextTable( &n );
     255                 :            :                             }
     256         [ #  # ]:          0 :                             sal_Bool bLink = pDlg->GetTablesAsLink();
     257         [ #  # ]:          0 :                             if (!nTabs.empty())
     258                 :            :                             {
     259 [ #  # ][ #  # ]:          0 :                                 if(pDlg->IsTableBefore())
     260                 :            :                                 {
     261         [ #  # ]:          0 :                                     ImportTables( pDlg->GetDocShellTables(), nTabs.size(), &nTabs[0],
     262 [ #  # ][ #  # ]:          0 :                                                 bLink,nTabNr );
     263                 :            :                                 }
     264                 :            :                                 else
     265                 :            :                                 {
     266                 :          0 :                                     SCTAB   nTabAfter    = nTabNr+1;
     267                 :            : 
     268         [ #  # ]:          0 :                                     for(SCTAB j=nCurrentTab+1;j<nTabCount;j++)
     269                 :            :                                     {
     270 [ #  # ][ #  # ]:          0 :                                         if(!pDoc->IsScenario(j))
     271                 :            :                                         {
     272                 :          0 :                                             nTabAfter=j;
     273                 :          0 :                                             break;
     274                 :            :                                         }
     275                 :            :                                     }
     276                 :            : 
     277         [ #  # ]:          0 :                                     ImportTables( pDlg->GetDocShellTables(), nTabs.size(), &nTabs[0],
     278 [ #  # ][ #  # ]:          0 :                                                 bLink,nTabAfter );
     279                 :            :                                 }
     280                 :          0 :                             }
     281                 :            :                         }
     282                 :            :                         else
     283                 :            :                         {
     284                 :          0 :                             SCTAB nCount=pDlg->GetTableCount();
     285         [ #  # ]:          0 :                             if(pDlg->IsTableBefore())
     286                 :            :                             {
     287 [ #  # ][ #  # ]:          0 :                                 if(nCount==1 && pDlg->GetFirstTable()->Len()>0)
                 [ #  # ]
     288                 :            :                                 {
     289         [ #  # ]:          0 :                                     rReq.AppendItem( SfxStringItem( FID_INS_TABLE, *pDlg->GetFirstTable() ) );
     290         [ #  # ]:          0 :                                     rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, static_cast<sal_uInt16>(nTabNr) + 1 ) );        // 1-based
     291                 :          0 :                                     rReq.Done();
     292                 :            : 
     293                 :          0 :                                     InsertTable( *pDlg->GetFirstTable(), nTabNr );
     294                 :            :                                 }
     295                 :            :                                 else
     296                 :            :                                 {
     297         [ #  # ]:          0 :                                     std::vector<rtl::OUString> aNames(0);
     298         [ #  # ]:          0 :                                     InsertTables( aNames, nTabNr,nCount );
     299                 :            :                                 }
     300                 :            :                             }
     301                 :            :                             else
     302                 :            :                             {
     303                 :          0 :                                 SCTAB   nTabAfter    = nTabNr+1;
     304                 :          0 :                                 SCTAB nSelHigh = rMark.GetLastSelected();
     305                 :            : 
     306         [ #  # ]:          0 :                                 for(SCTAB j=nSelHigh+1;j<nTabCount;j++)
     307                 :            :                                 {
     308         [ #  # ]:          0 :                                     if(!pDoc->IsScenario(j))
     309                 :            :                                     {
     310                 :          0 :                                         nTabAfter=j;
     311                 :          0 :                                         break;
     312                 :            :                                     }
     313                 :            :                                     else // #101672#; increase nTabAfter, because it is possible that the scenario tables are the last
     314                 :          0 :                                         nTabAfter = j + 1;
     315                 :            :                                 }
     316                 :            : 
     317 [ #  # ][ #  # ]:          0 :                                 if(nCount==1 && pDlg->GetFirstTable()->Len()>0)
                 [ #  # ]
     318                 :            :                                 {
     319         [ #  # ]:          0 :                                     rReq.AppendItem( SfxStringItem( FID_INS_TABLE, *pDlg->GetFirstTable() ) );
     320         [ #  # ]:          0 :                                     rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, static_cast<sal_uInt16>(nTabAfter) + 1 ) );     // 1-based
     321                 :          0 :                                     rReq.Done();
     322                 :            : 
     323                 :          0 :                                     InsertTable( *pDlg->GetFirstTable(), nTabAfter);
     324                 :            :                                 }
     325                 :            :                                 else
     326                 :            :                                 {
     327         [ #  # ]:          0 :                                     std::vector<rtl::OUString> aNames(0);
     328         [ #  # ]:          0 :                                     InsertTables( aNames, nTabAfter,nCount);
     329                 :            :                                 }
     330                 :            :                             }
     331                 :            :                         }
     332                 :            :                     }
     333                 :            : 
     334         [ #  # ]:          0 :                     delete pDlg;
     335                 :            :                 }
     336                 :            :             }
     337                 :          0 :             break;
     338                 :            : 
     339                 :            :         case FID_TAB_APPEND:
     340                 :            :         case FID_TAB_RENAME:
     341                 :            :         case FID_TAB_MENU_RENAME:
     342                 :            :             {
     343                 :            :                 //  FID_TAB_MENU_RENAME - "umbenennen" im Menu
     344                 :            :                 //  FID_TAB_RENAME      - "Name"-Property fuer Basic
     345                 :            :                 //  Execute ist gleich, aber im GetState wird MENU_RENAME evtl. disabled
     346                 :            : 
     347         [ #  # ]:          0 :                 if ( nSlot == FID_TAB_MENU_RENAME )
     348                 :          0 :                     nSlot = FID_TAB_RENAME;             // Execute ist gleich
     349                 :            : 
     350                 :          0 :                 SCTAB nTabNr = pViewData->GetTabNo();
     351                 :          0 :                 ScMarkData& rMark = pViewData->GetMarkData();
     352                 :          0 :                 SCTAB nTabSelCount = rMark.GetSelectCount();
     353                 :            : 
     354         [ #  # ]:          0 :                 if ( !pDoc->IsDocEditable() )
     355                 :          0 :                     break; // alles gesperrt
     356                 :            : 
     357   [ #  #  #  # ]:          0 :                 if ( nSlot != FID_TAB_APPEND &&
         [ #  # ][ #  # ]
     358                 :          0 :                         ( pDoc->IsTabProtected( nTabNr ) || nTabSelCount > 1 ) )
     359                 :          0 :                     break; // kein Rename
     360                 :            : 
     361         [ #  # ]:          0 :                 if( pReqArgs != NULL )
     362                 :            :                 {
     363                 :          0 :                     sal_Bool        bDone   = false;
     364                 :            :                     const SfxPoolItem* pItem;
     365         [ #  # ]:          0 :                     String      aName;
     366                 :            : 
     367 [ #  # ][ #  # ]:          0 :                     if( pReqArgs->HasItem( FN_PARAM_1, &pItem ) )
     368                 :          0 :                         nTabNr = ((const SfxUInt16Item*)pItem)->GetValue();
     369                 :            : 
     370 [ #  # ][ #  # ]:          0 :                     if( pReqArgs->HasItem( nSlot, &pItem ) )
     371         [ #  # ]:          0 :                         aName = ((const SfxStringItem*)pItem)->GetValue();
     372                 :            : 
     373      [ #  #  # ]:          0 :                     switch ( nSlot )
     374                 :            :                     {
     375                 :            :                         case FID_TAB_APPEND:
     376         [ #  # ]:          0 :                             bDone = AppendTable( aName );
     377                 :          0 :                             break;
     378                 :            :                         case FID_TAB_RENAME:
     379         [ #  # ]:          0 :                             bDone = RenameTable( aName, nTabNr );
     380                 :          0 :                             break;
     381                 :            :                     }
     382                 :            : 
     383         [ #  # ]:          0 :                     if( bDone )
     384                 :            :                     {
     385         [ #  # ]:          0 :                         rReq.Done( *pReqArgs );
     386         [ #  # ]:          0 :                     }
     387                 :            :                 }
     388                 :            :                 else
     389                 :            :                 {
     390                 :          0 :                     sal_uInt16      nRet    = RET_OK;
     391                 :          0 :                     sal_Bool        bDone   = false;
     392 [ #  # ][ #  # ]:          0 :                     String      aErrMsg ( ScGlobal::GetRscString( STR_INVALIDTABNAME ) );
     393                 :          0 :                     rtl::OUString aName;
     394         [ #  # ]:          0 :                     String      aDlgTitle;
     395                 :          0 :                     const sal_Char* pHelpId = 0;
     396                 :            : 
     397      [ #  #  # ]:          0 :                     switch ( nSlot )
     398                 :            :                     {
     399                 :            :                         case FID_TAB_APPEND:
     400 [ #  # ][ #  # ]:          0 :                             aDlgTitle = String(ScResId(SCSTR_APDTABLE));
         [ #  # ][ #  # ]
     401         [ #  # ]:          0 :                             pDoc->CreateValidTabName( aName );
     402                 :          0 :                             pHelpId = HID_SC_APPEND_NAME;
     403                 :          0 :                             break;
     404                 :            : 
     405                 :            :                         case FID_TAB_RENAME:
     406 [ #  # ][ #  # ]:          0 :                             aDlgTitle = String(ScResId(SCSTR_RENAMETAB));
         [ #  # ][ #  # ]
     407         [ #  # ]:          0 :                             pDoc->GetName( pViewData->GetTabNo(), aName );
     408                 :          0 :                             pHelpId = HID_SC_RENAME_NAME;
     409                 :          0 :                             break;
     410                 :            :                     }
     411                 :            : 
     412         [ #  # ]:          0 :                     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     413                 :            :                     OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
     414                 :            : 
     415                 :            :                     AbstractScStringInputDlg* pDlg = pFact->CreateScStringInputDlg(
     416                 :            :                         GetDialogParent(), aDlgTitle, String(ScResId(SCSTR_NAME)),
     417         [ #  # ]:          0 :                         aName, GetStaticInterface()->GetSlot(nSlot)->GetCommand(),
     418 [ #  # ][ #  # ]:          0 :                         pHelpId, RID_SCDLG_STRINPUT);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     419                 :            : 
     420                 :            :                     OSL_ENSURE(pDlg, "Dialog create fail!");
     421                 :            : 
     422 [ #  # ][ #  # ]:          0 :                     while ( !bDone && nRet == RET_OK )
                 [ #  # ]
     423                 :            :                     {
     424         [ #  # ]:          0 :                         nRet = pDlg->Execute();
     425                 :            : 
     426         [ #  # ]:          0 :                         if ( nRet == RET_OK )
     427                 :            :                         {
     428         [ #  # ]:          0 :                             pDlg->GetInputString( aName );
     429                 :            : 
     430                 :            : 
     431      [ #  #  # ]:          0 :                             switch ( nSlot )
     432                 :            :                             {
     433                 :            :                                 case FID_TAB_APPEND:
     434 [ #  # ][ #  # ]:          0 :                                     bDone = AppendTable( aName );
                 [ #  # ]
     435                 :          0 :                                     break;
     436                 :            :                                 case FID_TAB_RENAME:
     437 [ #  # ][ #  # ]:          0 :                                     bDone = RenameTable( aName, nTabNr );
                 [ #  # ]
     438                 :          0 :                                     break;
     439                 :            :                             }
     440                 :            : 
     441         [ #  # ]:          0 :                             if ( bDone )
     442                 :            :                             {
     443 [ #  # ][ #  # ]:          0 :                                 rReq.AppendItem( SfxStringItem( nSlot, aName ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     444         [ #  # ]:          0 :                                 rReq.Done();
     445                 :            :                             }
     446                 :            :                             else
     447                 :            :                             {
     448 [ #  # ][ #  # ]:          0 :                                 if( rReq.IsAPI() )
     449                 :            :                                 {
     450                 :            : #ifndef DISABLE_SCRIPTING
     451         [ #  # ]:          0 :                                     StarBASIC::Error( SbERR_SETPROP_FAILED ); // XXX Fehlerbehandlung???
     452                 :            : #endif
     453                 :            :                                 }
     454                 :            :                                 else
     455                 :            :                                 {
     456                 :            :                                     nRet = ErrorBox( GetDialogParent(),
     457                 :            :                                                      WinBits( WB_OK | WB_DEF_OK ),
     458                 :            :                                                      aErrMsg
     459 [ #  # ][ #  # ]:          0 :                                                    ).Execute();
         [ #  # ][ #  # ]
     460                 :            :                                 }
     461                 :            :                             }
     462                 :            :                         }
     463                 :            :                     }
     464 [ #  # ][ #  # ]:          0 :                     delete pDlg;
         [ #  # ][ #  # ]
     465                 :            :                 }
     466                 :            :             }
     467                 :          0 :             break;
     468                 :            : 
     469                 :            :         case FID_TAB_MOVE:
     470                 :            :             {
     471         [ #  # ]:          0 :                 if ( pDoc->GetChangeTrack() != NULL )
     472                 :            :                     break;      // bei aktiviertem ChangeTracking kein TabMove
     473                 :            : 
     474                 :          0 :                 sal_Bool   bDoIt = false;
     475                 :          0 :                 sal_uInt16 nDoc = 0;
     476                 :          0 :                 SCTAB nTab = pViewData->GetTabNo();
     477                 :          0 :                 sal_Bool   bCpy = false;
     478                 :          0 :                 rtl::OUString aDocName;
     479                 :          0 :                 rtl::OUString aTabName;
     480                 :            : 
     481         [ #  # ]:          0 :                 if( pReqArgs != NULL )
     482                 :            :                 {
     483         [ #  # ]:          0 :                     SCTAB nTableCount = pDoc->GetTableCount();
     484                 :            :                     const SfxPoolItem* pItem;
     485                 :            : 
     486 [ #  # ][ #  # ]:          0 :                     if( pReqArgs->HasItem( FID_TAB_MOVE, &pItem ) )
     487         [ #  # ]:          0 :                         aDocName = ((const SfxStringItem*)pItem)->GetValue();
     488 [ #  # ][ #  # ]:          0 :                     if( pReqArgs->HasItem( FN_PARAM_1, &pItem ) )
     489                 :            :                     {
     490                 :            :                         //  Tabelle ist 1-basiert
     491                 :          0 :                         nTab = ((const SfxUInt16Item*)pItem)->GetValue() - 1;
     492         [ #  # ]:          0 :                         if ( nTab >= nTableCount )
     493                 :          0 :                             nTab = SC_TAB_APPEND;
     494                 :            :                     }
     495 [ #  # ][ #  # ]:          0 :                     if( pReqArgs->HasItem( FN_PARAM_2, &pItem ) )
     496                 :          0 :                         bCpy = ((const SfxBoolItem*)pItem)->GetValue();
     497                 :            : 
     498         [ #  # ]:          0 :                     if (!aDocName.isEmpty())
     499                 :            :                     {
     500         [ #  # ]:          0 :                         SfxObjectShell* pSh     = SfxObjectShell::GetFirst();
     501                 :          0 :                         ScDocShell*     pScSh   = NULL;
     502                 :          0 :                         sal_uInt16          i=0;
     503                 :            : 
     504         [ #  # ]:          0 :                         while ( pSh )
     505                 :            :                         {
     506 [ #  # ][ #  # ]:          0 :                             pScSh = PTR_CAST( ScDocShell, pSh );
         [ #  # ][ #  # ]
     507                 :            : 
     508         [ #  # ]:          0 :                             if( pScSh )
     509                 :            :                             {
     510 [ #  # ][ #  # ]:          0 :                                 pScSh->GetTitle();
     511                 :            : 
     512 [ #  # ][ #  # ]:          0 :                                 if (aDocName.equals(pScSh->GetTitle()))
         [ #  # ][ #  # ]
     513                 :            :                                 {
     514                 :          0 :                                     nDoc = i;
     515                 :          0 :                                     ScDocument* pDestDoc = pScSh->GetDocument();
     516         [ #  # ]:          0 :                                     nTableCount = pDestDoc->GetTableCount();
     517         [ #  # ]:          0 :                                     bDoIt = pDestDoc->IsDocEditable();
     518                 :          0 :                                     break;
     519                 :            :                                 }
     520                 :            : 
     521                 :          0 :                                 i++;        // nur die ScDocShell's zaehlen
     522                 :            :                             }
     523         [ #  # ]:          0 :                             pSh = SfxObjectShell::GetNext( *pSh );
     524                 :            :                         }
     525                 :            :                     }
     526                 :            :                     else // Kein Dokumentname -> neues Dokument
     527                 :            :                     {
     528                 :          0 :                         nDoc = SC_DOC_NEW;
     529                 :          0 :                         bDoIt = sal_True;
     530                 :            :                     }
     531                 :            : 
     532 [ #  # ][ #  # ]:          0 :                     if ( bDoIt && nTab >= nTableCount )     // ggf. anhaengen
     533                 :          0 :                         nTab = SC_TAB_APPEND;
     534                 :            :                 }
     535                 :            :                 else
     536                 :            :                 {
     537                 :          0 :                     rtl::OUString aDefaultName;
     538         [ #  # ]:          0 :                     pDoc->GetName( pViewData->GetTabNo(), aDefaultName );
     539                 :            : 
     540         [ #  # ]:          0 :                     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     541                 :            :                     OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
     542                 :            : 
     543                 :            :                     AbstractScMoveTableDlg* pDlg = pFact->CreateScMoveTableDlg( GetDialogParent(),
     544                 :            :                                                                                 aDefaultName,
     545 [ #  # ][ #  # ]:          0 :                                                                                 RID_SCDLG_MOVETAB );
         [ #  # ][ #  # ]
     546                 :            :                     OSL_ENSURE(pDlg, "Dialog create fail!");
     547                 :            : 
     548         [ #  # ]:          0 :                     SCTAB nTableCount = pDoc->GetTableCount();
     549         [ #  # ]:          0 :                     ScMarkData& rMark       = GetViewData()->GetMarkData();
     550         [ #  # ]:          0 :                     SCTAB       nTabSelCount = rMark.GetSelectCount();
     551                 :            : 
     552                 :            : 
     553         [ #  # ]:          0 :                     if(nTableCount==nTabSelCount)
     554                 :            :                     {
     555         [ #  # ]:          0 :                         pDlg->SetForceCopyTable();
     556                 :            :                     }
     557                 :            : 
     558                 :            :                     // We support direct renaming of sheet only when one sheet
     559                 :            :                     // is selected.
     560         [ #  # ]:          0 :                     pDlg->EnableRenameTable(nTabSelCount == 1);
     561                 :            : 
     562 [ #  # ][ #  # ]:          0 :                     if ( pDlg->Execute() == RET_OK )
     563                 :            :                     {
     564         [ #  # ]:          0 :                         nDoc = pDlg->GetSelectedDocument();
     565         [ #  # ]:          0 :                         nTab = pDlg->GetSelectedTable();
     566         [ #  # ]:          0 :                         bCpy = pDlg->GetCopyTable();
     567         [ #  # ]:          0 :                         bool bRna = pDlg->GetRenameTable();
     568                 :            :                         // Leave aTabName string empty, when Rename is FALSE.
     569         [ #  # ]:          0 :                         if( bRna )
     570                 :            :                         {
     571         [ #  # ]:          0 :                            pDlg->GetTabNameString( aTabName );
     572                 :            :                         }
     573                 :          0 :                         bDoIt = true;
     574                 :            : 
     575         [ #  # ]:          0 :                         String aFoundDocName;
     576         [ #  # ]:          0 :                         if ( nDoc != SC_DOC_NEW )
     577                 :            :                         {
     578         [ #  # ]:          0 :                             ScDocShell* pSh = ScDocShell::GetShellByNum( nDoc );
     579         [ #  # ]:          0 :                             if (pSh)
     580                 :            :                             {
     581 [ #  # ][ #  # ]:          0 :                                 aFoundDocName = pSh->GetTitle();
                 [ #  # ]
     582 [ #  # ][ #  # ]:          0 :                                 if ( !pSh->GetDocument()->IsDocEditable() )
     583                 :            :                                 {
     584         [ #  # ]:          0 :                                     ErrorMessage(STR_READONLYERR);
     585                 :          0 :                                     bDoIt = false;
     586                 :            :                                 }
     587                 :            :                             }
     588                 :            :                         }
     589 [ #  # ][ #  # ]:          0 :                         rReq.AppendItem( SfxStringItem( FID_TAB_MOVE, aFoundDocName ) );
                 [ #  # ]
     590                 :            :                         //  Tabelle ist 1-basiert, wenn nicht APPEND
     591         [ #  # ]:          0 :                         SCTAB nBasicTab = ( nTab <= MAXTAB ) ? (nTab+1) : nTab;
     592 [ #  # ][ #  # ]:          0 :                         rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, static_cast<sal_uInt16>(nBasicTab) ) );
                 [ #  # ]
     593 [ #  # ][ #  # ]:          0 :                         rReq.AppendItem( SfxBoolItem( FN_PARAM_2, bCpy ) );
         [ #  # ][ #  # ]
     594                 :            :                     }
     595 [ #  # ][ #  # ]:          0 :                     delete pDlg;
     596                 :            :                 }
     597                 :            : 
     598         [ #  # ]:          0 :                 if( bDoIt )
     599                 :            :                 {
     600         [ #  # ]:          0 :                     rReq.Done();        // aufzeichnen, solange das Dokument noch aktiv ist
     601                 :            : 
     602         [ #  # ]:          0 :                     MoveTable( nDoc, nTab, bCpy, &aTabName );
     603                 :          0 :                 }
     604                 :            :             }
     605                 :          0 :             break;
     606                 :            : 
     607                 :            :         case FID_DELETE_TABLE:
     608                 :            :             {
     609                 :            :                 //  Parameter war ueberfluessig, weil die Methode an der Table haengt
     610                 :            : 
     611                 :          0 :                 sal_Bool bDoIt = rReq.IsAPI();
     612         [ #  # ]:          0 :                 if( !bDoIt )
     613                 :            :                 {
     614                 :            :                     //  wenn's nicht von Basic kommt, nochmal nachfragen:
     615                 :            : 
     616                 :            :                         bDoIt = ( RET_YES ==
     617                 :            :                                   QueryBox( GetDialogParent(),
     618                 :            :                                             WinBits( WB_YES_NO | WB_DEF_YES ),
     619                 :          0 :                                             ScGlobal::GetRscString(STR_QUERY_DELTAB)
     620         [ #  # ]:          0 :                                       ).Execute() );
     621                 :            :                 }
     622         [ #  # ]:          0 :                 if( bDoIt )
     623                 :            :                 {
     624                 :          0 :                     SCTAB nNewTab   = nCurrentTab;
     625                 :          0 :                     SCTAB nFirstTab=0;
     626                 :          0 :                     bool   bTabFlag=false;
     627         [ #  # ]:          0 :                     ScMarkData& rMark = pViewData->GetMarkData();
     628         [ #  # ]:          0 :                     std::vector<SCTAB> TheTabs;
     629         [ #  # ]:          0 :                     for(SCTAB i=0;i<nTabCount;i++)
     630                 :            :                     {
     631 [ #  # ][ #  # ]:          0 :                         if(rMark.GetTableSelect(i) &&!pDoc->IsTabProtected(i))
         [ #  # ][ #  # ]
                 [ #  # ]
     632                 :            :                         {
     633         [ #  # ]:          0 :                             TheTabs.push_back(i);
     634                 :          0 :                             bTabFlag=true;
     635         [ #  # ]:          0 :                             if(nNewTab==i) nNewTab++;
     636                 :            :                         }
     637         [ #  # ]:          0 :                         if(!bTabFlag) nFirstTab=i;
     638                 :            :                     }
     639         [ #  # ]:          0 :                     if(nNewTab>=nTabCount) nNewTab=nFirstTab;
     640                 :            : 
     641         [ #  # ]:          0 :                     pViewData->SetTabNo(nNewTab);
     642         [ #  # ]:          0 :                     DeleteTables(TheTabs);
     643                 :          0 :                     TheTabs.clear();
     644         [ #  # ]:          0 :                     rReq.Done();
     645                 :            :                 }
     646                 :            :             }
     647                 :          0 :             break;
     648                 :            : 
     649                 :            :         case FID_TAB_RTL:
     650                 :            :             {
     651                 :          0 :                 ScDocShell* pDocSh = pViewData->GetDocShell();
     652                 :          0 :                 ScDocFunc &rFunc = pDocSh->GetDocFunc();
     653                 :          0 :                 sal_Bool bSet = !pDoc->IsLayoutRTL( nCurrentTab );
     654                 :            : 
     655                 :          0 :                 const ScMarkData& rMark = pViewData->GetMarkData();
     656         [ #  # ]:          0 :                 if ( rMark.GetSelectCount() != 0 )
     657                 :            :                 {
     658                 :            :                     //  handle several sheets
     659                 :            : 
     660         [ #  # ]:          0 :                     ::svl::IUndoManager* pUndoManager = pDocSh->GetUndoManager();
     661 [ #  # ][ #  # ]:          0 :                     String aUndo = ScGlobal::GetRscString( STR_UNDO_TAB_RTL );
     662         [ #  # ]:          0 :                     pUndoManager->EnterListAction( aUndo, aUndo );
     663                 :            : 
     664 [ #  # ][ #  # ]:          0 :                     ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
     665 [ #  # ][ #  # ]:          0 :                     for (; itr != itrEnd; ++itr)
                 [ #  # ]
     666 [ #  # ][ #  # ]:          0 :                         rFunc.SetLayoutRTL( *itr, bSet, false );
     667                 :            : 
     668 [ #  # ][ #  # ]:          0 :                     pUndoManager->LeaveListAction();
     669                 :            :                 }
     670                 :            :                 else
     671                 :          0 :                     rFunc.SetLayoutRTL( nCurrentTab, bSet, false );
     672                 :            :             }
     673                 :          0 :             break;
     674                 :            : 
     675                 :            :         case FID_TAB_TOGGLE_GRID:
     676                 :            :             {
     677                 :          0 :                 bool bShowGrid = pViewData->GetShowGrid();
     678                 :          0 :                 pViewData->SetShowGrid(!bShowGrid);
     679                 :          0 :                 SfxBindings& rBindings = GetViewFrame()->GetBindings();
     680                 :          0 :                 rBindings.Invalidate( FID_TAB_TOGGLE_GRID );
     681                 :          0 :                 PaintGrid();
     682                 :          0 :                 rReq.Done();
     683                 :            :             }
     684                 :          0 :             break;
     685                 :            : 
     686                 :            :         case FID_TAB_SET_TAB_BG_COLOR:
     687                 :            :         case FID_TAB_MENU_SET_TAB_BG_COLOR:
     688                 :            :             {
     689         [ #  # ]:          0 :                 if ( nSlot == FID_TAB_MENU_SET_TAB_BG_COLOR )
     690                 :          0 :                     nSlot = FID_TAB_SET_TAB_BG_COLOR;
     691                 :          0 :                 SCTAB nTabNr = pViewData->GetTabNo();
     692                 :          0 :                 ScMarkData& rMark = pViewData->GetMarkData();
     693                 :          0 :                 SCTAB nTabSelCount = rMark.GetSelectCount();
     694         [ #  # ]:          0 :                 if ( !pDoc->IsDocEditable() )
     695                 :          0 :                     break;
     696                 :            : 
     697         [ #  # ]:          0 :                 if ( pDoc->IsTabProtected( nTabNr ) ) // ||nTabSelCount > 1
     698                 :          0 :                     break;
     699                 :            : 
     700         [ #  # ]:          0 :                 if( pReqArgs != NULL )
     701                 :            :                 {
     702                 :          0 :                     sal_Bool                bDone = false;
     703                 :            :                     const SfxPoolItem*  pItem;
     704                 :          0 :                     Color               aColor;
     705 [ #  # ][ #  # ]:          0 :                     if( pReqArgs->HasItem( FN_PARAM_1, &pItem ) )
     706                 :          0 :                         nTabNr = ((const SfxUInt16Item*)pItem)->GetValue();
     707                 :            : 
     708 [ #  # ][ #  # ]:          0 :                     if( pReqArgs->HasItem( nSlot, &pItem ) )
     709                 :          0 :                         aColor = ((const SvxColorItem*)pItem)->GetValue();
     710                 :            : 
     711         [ #  # ]:          0 :                     if ( nTabSelCount > 1 )
     712                 :            :                     {
     713                 :            :                         scoped_ptr<ScUndoTabColorInfo::List>
     714 [ #  # ][ #  # ]:          0 :                             pTabColorList(new ScUndoTabColorInfo::List);
     715 [ #  # ][ #  # ]:          0 :                         ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
     716 [ #  # ][ #  # ]:          0 :                         for (; itr != itrEnd; ++itr)
                 [ #  # ]
     717                 :            :                         {
     718 [ #  # ][ #  # ]:          0 :                             if ( !pDoc->IsTabProtected(*itr) )
                 [ #  # ]
     719                 :            :                             {
     720 [ #  # ][ #  # ]:          0 :                                 ScUndoTabColorInfo aTabColorInfo(*itr);
     721                 :          0 :                                 aTabColorInfo.maNewTabBgColor = aColor;
     722         [ #  # ]:          0 :                                 pTabColorList->push_back(aTabColorInfo);
     723                 :            :                             }
     724                 :            :                         }
     725 [ #  # ][ #  # ]:          0 :                         bDone = SetTabBgColor( *pTabColorList );
     726                 :            :                     }
     727                 :            :                     else
     728                 :            :                     {
     729         [ #  # ]:          0 :                         bDone = SetTabBgColor( aColor, nCurrentTab ); //ScViewFunc.SetTabBgColor
     730                 :            :                     }
     731         [ #  # ]:          0 :                     if( bDone )
     732                 :            :                     {
     733         [ #  # ]:          0 :                         rReq.Done( *pReqArgs );
     734                 :            :                     }
     735                 :            :                 }
     736                 :            :                 else
     737                 :            :                 {
     738                 :          0 :                     sal_uInt16      nRet    = RET_OK; /// temp
     739                 :          0 :                     sal_Bool        bDone   = false; /// temp
     740                 :          0 :                     Color       aTabBgColor;
     741                 :          0 :                     Color       aNewTabBgColor;
     742                 :            : 
     743         [ #  # ]:          0 :                     aTabBgColor = pDoc->GetTabBgColor( nCurrentTab );
     744         [ #  # ]:          0 :                     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     745                 :            :                     OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
     746                 :            :                     AbstractScTabBgColorDlg* pDlg = pFact->CreateScTabBgColorDlg(
     747                 :            :                                                                 GetDialogParent(),
     748                 :            :                                                                 String(ScResId(SCSTR_SET_TAB_BG_COLOR)),
     749                 :            :                                                                 String(ScResId(SCSTR_NO_TAB_BG_COLOR)),
     750                 :            :                                                                 aTabBgColor,
     751                 :            :                                                                 CMD_FID_TAB_SET_TAB_BG_COLOR,
     752 [ #  # ][ #  # ]:          0 :                                                                 RID_SCDLG_TAB_BG_COLOR);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     753 [ #  # ][ #  # ]:          0 :                     while ( !bDone && nRet == RET_OK )
                 [ #  # ]
     754                 :            :                     {
     755         [ #  # ]:          0 :                         nRet = pDlg->Execute();
     756         [ #  # ]:          0 :                         if( nRet == RET_OK )
     757                 :            :                         {
     758                 :          0 :                             Color aSelectedColor;
     759         [ #  # ]:          0 :                             pDlg->GetSelectedColor(aSelectedColor);
     760                 :            :                             scoped_ptr<ScUndoTabColorInfo::List>
     761 [ #  # ][ #  # ]:          0 :                                 pTabColorList(new ScUndoTabColorInfo::List);
     762         [ #  # ]:          0 :                             if ( nTabSelCount > 1 )
     763                 :            :                             {
     764 [ #  # ][ #  # ]:          0 :                                 ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
     765 [ #  # ][ #  # ]:          0 :                                 for (; itr != itrEnd; ++itr)
                 [ #  # ]
     766                 :            :                                     {
     767 [ #  # ][ #  # ]:          0 :                                         if ( !pDoc->IsTabProtected(*itr) )
                 [ #  # ]
     768                 :            :                                         {
     769 [ #  # ][ #  # ]:          0 :                                             ScUndoTabColorInfo aTabColorInfo(*itr);
     770                 :          0 :                                             aTabColorInfo.maNewTabBgColor = aSelectedColor;
     771         [ #  # ]:          0 :                                             pTabColorList->push_back(aTabColorInfo);
     772                 :            :                                         }
     773                 :            :                                     }
     774         [ #  # ]:          0 :                                     bDone = SetTabBgColor( *pTabColorList );
     775                 :            :                                 }
     776                 :            :                                 else
     777                 :            :                                 {
     778         [ #  # ]:          0 :                                     bDone = SetTabBgColor( aSelectedColor, nCurrentTab ); //ScViewFunc.SetTabBgColor
     779                 :            :                                 }
     780         [ #  # ]:          0 :                                 if ( bDone )
     781                 :            :                                 {
     782 [ #  # ][ #  # ]:          0 :                                     rReq.AppendItem( SvxColorItem( aTabBgColor, nSlot ) );
                 [ #  # ]
     783         [ #  # ]:          0 :                                     rReq.Done();
     784                 :            :                                 }
     785                 :            :                                 else
     786                 :            :                                 {
     787 [ #  # ][ #  # ]:          0 :                                     if( rReq.IsAPI() )
     788                 :            :                                     {
     789                 :            : #ifndef DISABLE_SCRIPTING
     790         [ #  # ]:          0 :                                         StarBASIC::Error( SbERR_SETPROP_FAILED );
     791                 :            : #endif
     792                 :            :                                     }
     793         [ #  # ]:          0 :                                 }
     794                 :            :                             }
     795                 :            :                         }
     796 [ #  # ][ #  # ]:          0 :                         delete( pDlg );
     797                 :            :                     }
     798                 :            :                 }
     799                 :          0 :                 break;
     800                 :            : 
     801                 :            :             case FID_TAB_EVENTS:
     802                 :            :                 {
     803                 :          0 :                     ScDocShell* pDocSh = pViewData->GetDocShell();
     804 [ #  # ][ #  # ]:          0 :                     uno::Reference<container::XNameReplace> xEvents( new ScSheetEventsObj( pDocSh, nCurrentTab ) );
                 [ #  # ]
     805 [ #  # ][ #  # ]:          0 :                     uno::Reference<frame::XFrame> xFrame = GetViewFrame()->GetFrame().GetFrameInterface();
     806         [ #  # ]:          0 :                     SvxAbstractDialogFactory* pDlgFactory = SvxAbstractDialogFactory::Create();
     807         [ #  # ]:          0 :                     if (pDlgFactory)
     808                 :            :                     {
     809                 :            :                         std::auto_ptr<VclAbstractDialog> pDialog( pDlgFactory->CreateSvxMacroAssignDlg(
     810 [ #  # ][ #  # ]:          0 :                             GetDialogParent(), xFrame, false, xEvents, 0 ) );
     811 [ #  # ][ #  # ]:          0 :                         if ( pDialog.get() && pDialog->Execute() == RET_OK )
                 [ #  # ]
     812                 :            :                         {
     813                 :            :                             // the dialog modifies the settings directly
     814         [ #  # ]:          0 :                         }
     815                 :          0 :                     }
     816                 :            :                 }
     817                 :          0 :                 break;
     818                 :            : 
     819                 :            :             default:
     820                 :            :                 OSL_FAIL("Unbekannte Message bei ViewShell");
     821                 :          0 :                 break;
     822                 :            :         }
     823                 :          0 :     }
     824                 :            : 
     825                 :            :     //------------------------------------------------------------------
     826                 :            : 
     827                 :        240 :     void ScTabViewShell::GetStateTable( SfxItemSet& rSet )
     828                 :            :     {
     829                 :        240 :         ScViewData* pViewData   = GetViewData();
     830         [ +  - ]:        240 :     ScDocument* pDoc        = pViewData->GetDocument();
     831                 :        240 :     ScDocShell* pDocShell   = pViewData->GetDocShell();
     832         [ +  - ]:        240 :     ScMarkData& rMark       = GetViewData()->GetMarkData();
     833                 :        240 :     SCTAB       nTab        = pViewData->GetTabNo();
     834                 :            : 
     835         [ +  - ]:        240 :     SCTAB nTabCount = pDoc->GetTableCount();
     836         [ +  - ]:        240 :     SCTAB nTabSelCount = rMark.GetSelectCount();
     837                 :            : 
     838         [ +  - ]:        240 :     SfxWhichIter    aIter(rSet);
     839         [ +  - ]:        240 :     sal_uInt16          nWhich = aIter.FirstWhich();
     840                 :            : 
     841         [ +  + ]:        480 :     while ( nWhich )
     842                 :            :     {
     843   [ -  -  -  -  :        240 :         switch ( nWhich )
          -  -  -  -  -  
             -  -  +  - ]
     844                 :            :         {
     845                 :            : 
     846                 :            :             case FID_TABLE_VISIBLE:
     847 [ #  # ][ #  # ]:          0 :                 rSet.Put( SfxBoolItem( nWhich, pDoc->IsVisible(nTab) ));
         [ #  # ][ #  # ]
     848                 :          0 :                 break;
     849                 :            : 
     850                 :            :             case FID_TABLE_HIDE:
     851                 :            :                 {
     852                 :          0 :                     sal_uInt16 nVis = 0;
     853 [ #  # ][ #  # ]:          0 :                     for ( SCTAB i=0; i < nTabCount && nVis<2; i++ )
                 [ #  # ]
     854 [ #  # ][ #  # ]:          0 :                         if (pDoc->IsVisible(i))
     855                 :          0 :                             ++nVis;
     856                 :            : 
     857 [ #  # ][ #  # ]:          0 :                     if ( nVis<2 || !pDoc->IsDocEditable() || nTabSelCount > 1 )
         [ #  # ][ #  # ]
                 [ #  # ]
     858         [ #  # ]:          0 :                         rSet.DisableItem( nWhich );
     859                 :            :                 }
     860                 :          0 :                 break;
     861                 :            : 
     862                 :            :             case FID_TABLE_SHOW:
     863                 :            :                 {
     864                 :          0 :                     sal_Bool bHasHidden = false;
     865 [ #  # ][ #  # ]:          0 :                     for ( SCTAB i=0; i < nTabCount && !bHasHidden; i++ )
                 [ #  # ]
     866 [ #  # ][ #  # ]:          0 :                         if (!pDoc->IsVisible(i))
     867                 :          0 :                             bHasHidden = sal_True;
     868 [ #  # ][ #  # ]:          0 :                     if ( !bHasHidden || pDoc->IsDocProtected() || nTabSelCount > 1 )
         [ #  # ][ #  # ]
                 [ #  # ]
     869         [ #  # ]:          0 :                         rSet.DisableItem( nWhich );
     870                 :            :                 }
     871                 :          0 :                 break;
     872                 :            : 
     873                 :            :             case FID_DELETE_TABLE:
     874                 :            :                 {
     875         [ #  # ]:          0 :                     if ( pDoc->GetChangeTrack() )
     876         [ #  # ]:          0 :                         rSet.DisableItem( nWhich );
     877                 :            :                     else
     878                 :            :                     {
     879                 :          0 :                         sal_uInt16 nVis = 0;
     880 [ #  # ][ #  # ]:          0 :                         for ( SCTAB i=0; i < nTabCount && nVis<2; i++ )
                 [ #  # ]
     881 [ #  # ][ #  # ]:          0 :                             if (pDoc->IsVisible(i))
     882                 :          0 :                                 ++nVis;
     883 [ #  # ][ #  # ]:          0 :                         if (   pDoc->IsTabProtected(nTab)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     884         [ #  # ]:          0 :                             || !pDoc->IsDocEditable()
     885                 :            :                             || nVis < 2
     886                 :            :                             || nTabSelCount == nTabCount)
     887         [ #  # ]:          0 :                         rSet.DisableItem( nWhich );
     888                 :            :                     }
     889                 :            :                 }
     890                 :          0 :                 break;
     891                 :            : 
     892                 :            :             case FID_INS_TABLE:
     893                 :            :             case FID_INS_TABLE_EXT:
     894                 :            :             case FID_TAB_APPEND:
     895 [ #  # ][ #  # ]:          0 :                 if ( !pDoc->IsDocEditable() ||
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     896                 :            :                      nTabCount > MAXTAB ||
     897         [ #  # ]:          0 :                      ( nWhich == FID_INS_TABLE_EXT && pDocShell && pDocShell->IsDocShared() ) )
     898         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     899                 :          0 :                 break;
     900                 :            : 
     901                 :            :             case FID_TAB_MOVE:
     902         [ #  # ]:          0 :                 if (   !pDoc->IsDocEditable()
           [ #  #  #  # ]
         [ #  # ][ #  # ]
     903                 :          0 :                     || pDoc->GetChangeTrack() != NULL
     904                 :            :                     || nTabCount > MAXTAB)
     905         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     906                 :          0 :                 break;
     907                 :            : 
     908                 :            :             //  FID_TAB_MENU_RENAME - "umbenennen" im Menu
     909                 :            :             //  FID_TAB_RENAME      - "Name"-Property fuer Basic
     910                 :            : 
     911                 :            :             case FID_TAB_MENU_RENAME:
     912 [ #  # ][ #  # ]:          0 :                 if ( !pDoc->IsDocEditable() ||
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     913         [ #  # ]:          0 :                      pDoc->IsTabProtected(nTab) ||nTabSelCount > 1 ||
     914         [ #  # ]:          0 :                      ( pDocShell && pDocShell->IsDocShared() ) )
     915         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     916                 :          0 :                 break;
     917                 :            : 
     918                 :            :             case FID_TAB_RENAME:
     919                 :            :                 {
     920                 :          0 :                     rtl::OUString aTabName;
     921         [ #  # ]:          0 :                     pDoc->GetName( nTab, aTabName );
     922                 :            : 
     923 [ #  # ][ #  # ]:          0 :                     rSet.Put( SfxStringItem( nWhich, aTabName ));
         [ #  # ][ #  # ]
                 [ #  # ]
     924                 :            : 
     925                 :            :                 }
     926                 :          0 :                 break;
     927                 :            : 
     928                 :            :             case FID_TAB_RTL:
     929                 :            :                 {
     930         [ #  # ]:          0 :                     SvtLanguageOptions aLangOpt;
     931 [ #  # ][ #  # ]:          0 :                     if ( !aLangOpt.IsCTLFontEnabled() )
     932         [ #  # ]:          0 :                         rSet.DisableItem( nWhich );
     933                 :            :                     else
     934 [ #  # ][ #  # ]:          0 :                         rSet.Put( SfxBoolItem( nWhich, pDoc->IsLayoutRTL( nTab ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     935                 :            :                 }
     936                 :          0 :                 break;
     937                 :            : 
     938                 :            :             case FID_TAB_MENU_SET_TAB_BG_COLOR:
     939                 :            :                 {
     940 [ #  # ][ #  # ]:          0 :                     if ( !pDoc->IsDocEditable()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     941         [ #  # ]:          0 :                         || ( pDocShell && pDocShell->IsDocShared() )
     942         [ #  # ]:          0 :                         || pDoc->IsTabProtected(nTab) )
     943         [ #  # ]:          0 :                         rSet.DisableItem( nWhich );
     944                 :            :                 }
     945                 :          0 :                 break;
     946                 :            : 
     947                 :            :             case FID_TAB_SET_TAB_BG_COLOR:
     948                 :            :                 {
     949                 :          0 :                     Color aColor;
     950         [ #  # ]:          0 :                     aColor = pDoc->GetTabBgColor( nTab );
     951 [ #  # ][ #  # ]:          0 :                     rSet.Put( SvxColorItem( aColor, nWhich ) );
                 [ #  # ]
     952                 :            :                 }
     953                 :          0 :                 break;
     954                 :            : 
     955                 :            :             case FID_TAB_TOGGLE_GRID:
     956 [ +  - ][ +  - ]:        240 :                 rSet.Put( SfxBoolItem(nWhich, pViewData->GetShowGrid()) );
                 [ +  - ]
     957                 :        240 :                 break;
     958                 :            :         }
     959         [ +  - ]:        240 :         nWhich = aIter.NextWhich();
     960         [ +  - ]:        240 :     }
     961                 :        240 : }
     962                 :            : 
     963                 :            : 
     964                 :            : 
     965                 :            : 
     966                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10