LCOV - code coverage report
Current view: top level - sc/source/ui/view - cellsh.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 140 487 28.7 %
Date: 2012-08-25 Functions: 14 23 60.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 148 1154 12.8 %

           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                 :            : #include "scitems.hxx"
      30                 :            : 
      31                 :            : #include <svl/slstitm.hxx>
      32                 :            : #include <svl/stritem.hxx>
      33                 :            : #include <svl/whiter.hxx>
      34                 :            : #include <unotools/moduleoptions.hxx>
      35                 :            : #include <svtools/cliplistener.hxx>
      36                 :            : #include <svtools/insdlg.hxx>
      37                 :            : #include <sot/formats.hxx>
      38                 :            : #include <svx/hlnkitem.hxx>
      39                 :            : #include <sfx2/app.hxx>
      40                 :            : #include <sfx2/bindings.hxx>
      41                 :            : #include <sfx2/childwin.hxx>
      42                 :            : #include <sfx2/objface.hxx>
      43                 :            : #include <sfx2/request.hxx>
      44                 :            : #include <sfx2/viewfrm.hxx>
      45                 :            : #include <svx/clipfmtitem.hxx>
      46                 :            : #include <editeng/langitem.hxx>
      47                 :            : 
      48                 :            : #include "cellsh.hxx"
      49                 :            : #include "sc.hrc"
      50                 :            : #include "docsh.hxx"
      51                 :            : #include "attrib.hxx"
      52                 :            : #include "scresid.hxx"
      53                 :            : #include "tabvwsh.hxx"
      54                 :            : #include "impex.hxx"
      55                 :            : #include "cell.hxx"
      56                 :            : #include "scmod.hxx"
      57                 :            : #include "globstr.hrc"
      58                 :            : #include "transobj.hxx"
      59                 :            : #include "drwtrans.hxx"
      60                 :            : #include "scabstdlg.hxx"
      61                 :            : #include "dociter.hxx"
      62                 :            : #include "postit.hxx"
      63                 :            : #include "cliputil.hxx"
      64                 :            : #include "clipparam.hxx"
      65                 :            : #include "markdata.hxx"
      66                 :            : 
      67                 :            : //------------------------------------------------------------------
      68                 :            : 
      69                 :            : #define ScCellShell
      70                 :            : #define CellMovement
      71                 :            : #include "scslots.hxx"
      72                 :            : 
      73 [ -  + ][ -  + ]:       4176 : TYPEINIT1( ScCellShell, ScFormatShell );
      74                 :            : 
      75 [ +  + ][ +  - ]:      93526 : SFX_IMPL_INTERFACE(ScCellShell, ScFormatShell , ScResId(SCSTR_CELLSHELL) )
         [ +  - ][ +  - ]
      76                 :            : {
      77         [ +  - ]:         51 :     SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD |
      78                 :            :                                 SFX_VISIBILITY_SERVER,
      79         [ +  - ]:         51 :                                 ScResId(RID_OBJECTBAR_FORMAT));
      80 [ +  - ][ +  - ]:         51 :     SFX_POPUPMENU_REGISTRATION(ScResId(RID_POPUP_CELLS));
      81                 :         51 : }
      82                 :            : 
      83                 :            : 
      84                 :        229 : ScCellShell::ScCellShell(ScViewData* pData) :
      85                 :            :     ScFormatShell(pData),
      86                 :            :     pImpl( new CellShell_Impl() ),
      87         [ +  - ]:        229 :     bPastePossible(false)
      88                 :            : {
      89         [ +  - ]:        229 :     SetHelpId(HID_SCSHELL_CELLSH);
      90 [ +  - ][ +  - ]:        229 :     SetName(rtl::OUString("Cell"));
                 [ +  - ]
      91                 :        229 : }
      92                 :            : 
      93                 :        225 : ScCellShell::~ScCellShell()
      94                 :            : {
      95         [ +  + ]:        225 :     if ( pImpl->m_pClipEvtLstnr )
      96                 :            :     {
      97 [ +  - ][ +  - ]:        193 :         pImpl->m_pClipEvtLstnr->AddRemoveListener( GetViewData()->GetActiveWin(), false );
      98                 :            : 
      99                 :            :         //  The listener may just now be waiting for the SolarMutex and call the link
     100                 :            :         //  afterwards, in spite of RemoveListener. So the link has to be reset, too.
     101         [ +  - ]:        193 :         pImpl->m_pClipEvtLstnr->ClearCallbackLink();
     102                 :            : 
     103                 :        193 :         pImpl->m_pClipEvtLstnr->release();
     104                 :            :     }
     105                 :            : 
     106 [ -  + ][ #  # ]:        225 :     delete pImpl->m_pLinkedDlg;
     107 [ -  + ][ #  # ]:        225 :     delete pImpl->m_pRequest;
     108                 :        225 :     delete pImpl;
     109         [ -  + ]:        450 : }
     110                 :            : 
     111                 :            : //------------------------------------------------------------------
     112                 :            : 
     113                 :       1229 : void ScCellShell::GetBlockState( SfxItemSet& rSet )
     114                 :            : {
     115                 :       1229 :     ScTabViewShell* pTabViewShell   = GetViewData()->GetViewShell();
     116                 :       1229 :     ScRange aMarkRange;
     117         [ +  - ]:       1229 :     ScMarkType eMarkType = GetViewData()->GetSimpleArea( aMarkRange );
     118                 :       1229 :     bool bSimpleArea = (eMarkType == SC_MARK_SIMPLE);
     119                 :            :     bool bOnlyNotBecauseOfMatrix;
     120         [ +  - ]:       1229 :     bool bEditable = pTabViewShell->SelectionEditable( &bOnlyNotBecauseOfMatrix );
     121         [ +  - ]:       1229 :     ScDocument* pDoc = GetViewData()->GetDocument();
     122                 :       1229 :     ScDocShell* pDocShell = GetViewData()->GetDocShell();
     123         [ +  - ]:       1229 :     ScMarkData& rMark = GetViewData()->GetMarkData();
     124                 :            :     SCCOL nCol1, nCol2;
     125                 :            :     SCROW nRow1, nRow2;
     126                 :       1229 :     nCol1 = aMarkRange.aStart.Col();
     127                 :       1229 :     nRow1 = aMarkRange.aStart.Row();
     128                 :       1229 :     nCol2 = aMarkRange.aEnd.Col();
     129                 :       1229 :     nRow2 = aMarkRange.aEnd.Row();
     130                 :            : 
     131         [ +  - ]:       1229 :     SfxWhichIter aIter(rSet);
     132         [ +  - ]:       1229 :     sal_uInt16 nWhich = aIter.FirstWhich();
     133         [ +  + ]:       2833 :     while ( nWhich )
     134                 :            :     {
     135                 :       1604 :         bool bDisable = false;
     136                 :       1604 :         bool bNeedEdit = true;      // need selection be editable?
     137   [ -  -  -  -  :       1604 :         switch ( nWhich )
          -  +  +  +  +  
             -  -  -  -  
                      + ]
     138                 :            :         {
     139                 :            :             case FID_FILL_TO_BOTTOM:    // fill to top / bottom
     140                 :            :             {
     141 [ #  # ][ #  # ]:          0 :                 bDisable = !bSimpleArea || (nRow1 == 0 && nRow2 == 0);
                 [ #  # ]
     142 [ #  # ][ #  # ]:          0 :                 if ( !bDisable && bEditable )
     143                 :            :                 {   // do not damage matrix
     144                 :            :                     bDisable = pDoc->HasSelectedBlockMatrixFragment(
     145         [ #  # ]:          0 :                         nCol1, nRow1, nCol2, nRow1, rMark );    // first row
     146                 :            :                 }
     147                 :            :             }
     148                 :          0 :             break;
     149                 :            :             case FID_FILL_TO_TOP:
     150                 :            :             {
     151 [ #  # ][ #  # ]:          0 :                 bDisable = (!bSimpleArea) || (nRow1 == MAXROW && nRow2 == MAXROW);
                 [ #  # ]
     152 [ #  # ][ #  # ]:          0 :                 if ( !bDisable && bEditable )
     153                 :            :                 {   // do not damage matrix
     154                 :            :                     bDisable = pDoc->HasSelectedBlockMatrixFragment(
     155         [ #  # ]:          0 :                         nCol1, nRow2, nCol2, nRow2, rMark );    // last row
     156                 :            :                 }
     157                 :            :             }
     158                 :          0 :             break;
     159                 :            :             case FID_FILL_TO_RIGHT:     // fill to left / right
     160                 :            :             {
     161 [ #  # ][ #  # ]:          0 :                 bDisable = !bSimpleArea || (nCol1 == 0 && nCol2 == 0);
                 [ #  # ]
     162                 :            :                 bDisable = pDoc->HasSelectedBlockMatrixFragment(
     163         [ #  # ]:          0 :                     nCol1, nRow1, nCol1, nRow2, rMark );    // first column
     164                 :            :             }
     165                 :          0 :             break;
     166                 :            :             case FID_FILL_TO_LEFT:
     167                 :            :             {
     168 [ #  # ][ #  # ]:          0 :                 bDisable = (!bSimpleArea) || (nCol1 == MAXCOL && nCol2 == MAXCOL);
                 [ #  # ]
     169 [ #  # ][ #  # ]:          0 :                 if ( !bDisable && bEditable )
     170                 :            :                 {   // Matrix nicht zerreissen
     171                 :            :                     bDisable = pDoc->HasSelectedBlockMatrixFragment(
     172         [ #  # ]:          0 :                         nCol2, nRow1, nCol2, nRow2, rMark );    // last column
     173                 :            :                 }
     174                 :            :             }
     175                 :          0 :             break;
     176                 :            :             case FID_FILL_SERIES:       // fill block
     177                 :            :             case SID_OPENDLG_TABOP:     // multiple-cell operations, are at least 2 cells marked?
     178 [ #  # ][ #  # ]:          0 :                 if (pDoc->GetChangeTrack()!=NULL &&nWhich ==SID_OPENDLG_TABOP)
                 [ #  # ]
     179                 :          0 :                     bDisable = sal_True;
     180                 :            :                 else
     181 [ #  # ][ #  # ]:          0 :                     bDisable = (!bSimpleArea) || (nCol1 == nCol2 && nRow1 == nRow2);
                 [ #  # ]
     182                 :            : 
     183 [ #  # ][ #  # ]:          0 :                 if ( !bDisable && bEditable && nWhich == FID_FILL_SERIES )
                 [ #  # ]
     184                 :            :                 {   // do not damage matrix
     185                 :            :                     bDisable = pDoc->HasSelectedBlockMatrixFragment(
     186         [ #  # ]:          0 :                             nCol1, nRow1, nCol2, nRow1, rMark )     // first row
     187                 :            :                         ||  pDoc->HasSelectedBlockMatrixFragment(
     188         [ #  # ]:          0 :                             nCol1, nRow2, nCol2, nRow2, rMark )     // last row
     189                 :            :                         ||  pDoc->HasSelectedBlockMatrixFragment(
     190         [ #  # ]:          0 :                             nCol1, nRow1, nCol1, nRow2, rMark )     // first column
     191                 :            :                         ||  pDoc->HasSelectedBlockMatrixFragment(
     192 [ #  # ][ #  # ]:          0 :                             nCol2, nRow1, nCol2, nRow2, rMark );    // last column
         [ #  # ][ #  # ]
                 [ #  # ]
     193                 :            :                 }
     194                 :          0 :                 break;
     195                 :            : 
     196                 :            :             case SID_CUT:               // cut
     197                 :            :             case FID_INS_CELL:          // insert cells, just simple selection
     198                 :        268 :                 bDisable = (!bSimpleArea);
     199                 :        268 :                 break;
     200                 :            : 
     201                 :            :             case FID_INS_ROW:           // insert rows
     202                 :            :             case FID_INS_CELLSDOWN:
     203 [ +  - ][ +  - ]:        267 :                 bDisable = (!bSimpleArea) || GetViewData()->SimpleColMarked();
                 [ -  + ]
     204                 :        267 :                 break;
     205                 :            : 
     206                 :            :             case FID_INS_COLUMN:        // insert columns
     207                 :            :             case FID_INS_CELLSRIGHT:
     208 [ +  - ][ +  - ]:        267 :                 bDisable = (!bSimpleArea) || GetViewData()->SimpleRowMarked();
                 [ -  + ]
     209                 :        267 :                 break;
     210                 :            : 
     211                 :            :             case SID_COPY:              // copy
     212                 :            :                 // not editable because of matrix only? Do not damage matrix
     213                 :            :                 //! is not called, when protected AND matrix, we will have
     214                 :            :                 //! to live with this... is caught in Copy-Routine, otherwise
     215                 :            :                 //! work is to be done once more
     216 [ +  + ][ -  + ]:        268 :                 if ( !(!bEditable && bOnlyNotBecauseOfMatrix) )
     217                 :        267 :                     bNeedEdit = false;          // allowed when protected/ReadOnly
     218                 :        268 :                 break;
     219                 :            : 
     220                 :            :             case SID_AUTOFORMAT:        // Autoformat, at least 3x3 selected
     221                 :          0 :                 bDisable =    (!bSimpleArea)
     222 [ #  # ][ #  # ]:          0 :                            || ((nCol2 - nCol1) < 2) || ((nRow2 - nRow1) < 2);
                 [ #  # ]
     223                 :          0 :                 break;
     224                 :            : 
     225                 :            :             case SID_CELL_FORMAT_RESET :
     226                 :            :             case FID_CELL_FORMAT :
     227                 :            :             case SID_ENABLE_HYPHENATION :
     228                 :            :                 // not editable because of matrix only? Attribute ok nonetheless
     229 [ #  # ][ #  # ]:          0 :                 if ( !bEditable && bOnlyNotBecauseOfMatrix )
     230                 :          0 :                     bNeedEdit = false;
     231                 :          0 :                 break;
     232                 :            : 
     233                 :            :             case FID_VALIDATION:
     234                 :            :                 {
     235 [ #  # ][ #  # ]:          0 :                     if ( pDocShell && pDocShell->IsDocShared() )
         [ #  # ][ #  # ]
     236                 :            :                     {
     237                 :          0 :                         bDisable = sal_True;
     238                 :            :                     }
     239                 :            :                 }
     240                 :          0 :                 break;
     241                 :            : 
     242                 :            :             case SID_TRANSLITERATE_HALFWIDTH:
     243                 :            :             case SID_TRANSLITERATE_FULLWIDTH:
     244                 :            :             case SID_TRANSLITERATE_HIRAGANA:
     245                 :            :             case SID_TRANSLITERATE_KATAGANA:
     246 [ #  # ][ #  # ]:          0 :                 ScViewUtil::HideDisabledSlot( rSet, GetViewData()->GetBindings(), nWhich );
     247                 :          0 :             break;
     248                 :            :         }
     249 [ +  - ][ +  + ]:       1604 :         if (!bDisable && bNeedEdit && !bEditable)
                 [ +  + ]
     250                 :          6 :             bDisable = sal_True;
     251                 :            : 
     252         [ +  + ]:       1604 :         if (bDisable)
     253         [ +  - ]:          6 :             rSet.DisableItem(nWhich);
     254         [ -  + ]:       1598 :         else if (nWhich == SID_ENABLE_HYPHENATION)
     255                 :            :         {
     256                 :            :             // toggle slots need a bool item
     257 [ #  # ][ #  # ]:          0 :             rSet.Put( SfxBoolItem( nWhich, false ) );
                 [ #  # ]
     258                 :            :         }
     259         [ +  - ]:       1604 :         nWhich = aIter.NextWhich();
     260         [ +  - ]:       1229 :     }
     261                 :       1229 : }
     262                 :            : 
     263                 :            : //  functionen, disabled depending on cursor position
     264                 :            : //  Default:
     265                 :            : //      SID_INSERT_POSTIT, SID_CHARMAP, SID_OPENDLG_FUNCTION
     266                 :            : 
     267                 :          0 : void ScCellShell::GetCellState( SfxItemSet& rSet )
     268                 :            : {
     269                 :          0 :     ScDocShell* pDocShell = GetViewData()->GetDocShell();
     270                 :          0 :     ScDocument* pDoc = GetViewData()->GetDocShell()->GetDocument();
     271                 :          0 :     ScAddress aCursor( GetViewData()->GetCurX(), GetViewData()->GetCurY(),
     272                 :          0 :                         GetViewData()->GetTabNo() );
     273                 :            : 
     274         [ #  # ]:          0 :     SfxWhichIter aIter(rSet);
     275         [ #  # ]:          0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     276         [ #  # ]:          0 :     while ( nWhich )
     277                 :            :     {
     278                 :          0 :         sal_Bool bDisable = false;
     279                 :          0 :         sal_Bool bNeedEdit = sal_True;      // need cursor position be editable?
     280   [ #  #  #  # ]:          0 :         switch ( nWhich )
     281                 :            :         {
     282                 :            :             case SID_THESAURUS:
     283                 :            :                 {
     284         [ #  # ]:          0 :                     CellType eType = pDoc->GetCellType( aCursor );
     285 [ #  # ][ #  # ]:          0 :                     bDisable = ( eType != CELLTYPE_STRING && eType != CELLTYPE_EDIT);
     286         [ #  # ]:          0 :                     if (!bDisable)
     287                 :            :                     {
     288                 :            :                         //  test for available languages
     289         [ #  # ]:          0 :                         sal_uInt16 nLang = ScViewUtil::GetEffLanguage( pDoc, aCursor );
     290         [ #  # ]:          0 :                         bDisable = !ScModule::HasThesaurusLanguage( nLang );
     291                 :            :                     }
     292                 :            :                 }
     293                 :          0 :                 break;
     294                 :            :             case SID_OPENDLG_FUNCTION:
     295                 :            :                 {
     296 [ #  # ][ #  # ]:          0 :                     ScMarkData aMarkData=GetViewData()->GetMarkData();
     297         [ #  # ]:          0 :                     aMarkData.MarkToSimple();
     298                 :          0 :                     ScRange aRange;
     299         [ #  # ]:          0 :                     aMarkData.GetMarkArea(aRange);
     300         [ #  # ]:          0 :                     if(aMarkData.IsMarked())
     301                 :            :                     {
     302         [ #  # ]:          0 :                         if (!pDoc->IsBlockEditable( aCursor.Tab(), aRange.aStart.Col(),aRange.aStart.Row(),
     303         [ #  # ]:          0 :                                             aRange.aEnd.Col(),aRange.aEnd.Row() ))
     304                 :            :                         {
     305                 :          0 :                             bDisable = sal_True;
     306                 :            :                         }
     307                 :          0 :                         bNeedEdit=false;
     308         [ #  # ]:          0 :                     }
     309                 :            : 
     310                 :            :                 }
     311                 :          0 :                 break;
     312                 :            :             case SID_INSERT_POSTIT:
     313                 :            :                 {
     314 [ #  # ][ #  # ]:          0 :                     if ( pDocShell && pDocShell->IsDocShared() )
         [ #  # ][ #  # ]
     315                 :            :                     {
     316                 :          0 :                         bDisable = sal_True;
     317                 :            :                     }
     318                 :            :                 }
     319                 :          0 :                 break;
     320                 :            :         }
     321 [ #  # ][ #  # ]:          0 :         if (!bDisable && bNeedEdit)
     322         [ #  # ]:          0 :             if (!pDoc->IsBlockEditable( aCursor.Tab(), aCursor.Col(),aCursor.Row(),
     323         [ #  # ]:          0 :                                         aCursor.Col(),aCursor.Row() ))
     324                 :          0 :                 bDisable = sal_True;
     325         [ #  # ]:          0 :         if (bDisable)
     326         [ #  # ]:          0 :             rSet.DisableItem(nWhich);
     327         [ #  # ]:          0 :         nWhich = aIter.NextWhich();
     328         [ #  # ]:          0 :     }
     329                 :          0 : }
     330                 :            : 
     331                 :          0 : sal_Bool lcl_TestFormat( SvxClipboardFmtItem& rFormats, const TransferableDataHelper& rDataHelper,
     332                 :            :                         SotFormatStringId nFormatId )
     333                 :            : {
     334         [ #  # ]:          0 :     if ( rDataHelper.HasFormat( nFormatId ) )
     335                 :            :     {
     336                 :            :         //  translated format name strings are no longer inserted here,
     337                 :            :         //  handled by "paste special" dialog / toolbox controller instead.
     338                 :            :         //  Only the object type name has to be set here:
     339         [ #  # ]:          0 :         String aStrVal;
     340         [ #  # ]:          0 :         if ( nFormatId == SOT_FORMATSTR_ID_EMBED_SOURCE )
     341                 :            :         {
     342         [ #  # ]:          0 :             TransferableObjectDescriptor aDesc;
     343         [ #  # ]:          0 :             if ( ((TransferableDataHelper&)rDataHelper).GetTransferableObjectDescriptor(
     344         [ #  # ]:          0 :                                         SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aDesc ) )
     345 [ #  # ][ #  # ]:          0 :                 aStrVal = aDesc.maTypeName;
     346                 :            :         }
     347 [ #  # ][ #  # ]:          0 :         else if ( nFormatId == SOT_FORMATSTR_ID_EMBED_SOURCE_OLE
     348                 :            :           || nFormatId == SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE )
     349                 :            :         {
     350         [ #  # ]:          0 :             String aSource;
     351 [ #  # ][ #  # ]:          0 :             SvPasteObjectHelper::GetEmbeddedName( rDataHelper, aStrVal, aSource, nFormatId );
     352                 :            :         }
     353                 :            : 
     354         [ #  # ]:          0 :         if ( aStrVal.Len() )
     355 [ #  # ][ #  # ]:          0 :             rFormats.AddClipbrdFormat( nFormatId, aStrVal );
     356                 :            :         else
     357         [ #  # ]:          0 :             rFormats.AddClipbrdFormat( nFormatId );
     358                 :            : 
     359         [ #  # ]:          0 :         return sal_True;
     360                 :            :     }
     361                 :            : 
     362                 :          0 :     return false;
     363                 :            : }
     364                 :            : 
     365                 :          0 : void ScCellShell::GetPossibleClipboardFormats( SvxClipboardFmtItem& rFormats )
     366                 :            : {
     367         [ #  # ]:          0 :     Window* pWin = GetViewData()->GetActiveWin();
     368         [ #  # ]:          0 :     sal_Bool bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != NULL );
     369                 :            : 
     370         [ #  # ]:          0 :     TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pWin ) );
     371                 :            : 
     372         [ #  # ]:          0 :     lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_DRAWING );
     373         [ #  # ]:          0 :     lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_SVXB );
     374         [ #  # ]:          0 :     lcl_TestFormat( rFormats, aDataHelper, SOT_FORMAT_GDIMETAFILE );
     375         [ #  # ]:          0 :     lcl_TestFormat( rFormats, aDataHelper, SOT_FORMAT_BITMAP );
     376         [ #  # ]:          0 :     lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_EMBED_SOURCE );
     377                 :            : 
     378         [ #  # ]:          0 :     if ( !bDraw )
     379                 :            :     {
     380         [ #  # ]:          0 :         lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_LINK );
     381         [ #  # ]:          0 :         lcl_TestFormat( rFormats, aDataHelper, SOT_FORMAT_STRING );
     382         [ #  # ]:          0 :         lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_DIF );
     383         [ #  # ]:          0 :         lcl_TestFormat( rFormats, aDataHelper, SOT_FORMAT_RTF );
     384         [ #  # ]:          0 :         lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_HTML );
     385         [ #  # ]:          0 :         lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_HTML_SIMPLE );
     386         [ #  # ]:          0 :         lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_BIFF_8 );
     387         [ #  # ]:          0 :         lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_BIFF_5 );
     388                 :            :     }
     389                 :            : 
     390 [ #  # ][ #  # ]:          0 :     if ( !lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ) )
     391 [ #  # ][ #  # ]:          0 :         lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE );
     392                 :          0 : }
     393                 :            : 
     394                 :            : //  insert, insert contents
     395                 :            : 
     396                 :        193 : sal_Bool lcl_IsCellPastePossible( const TransferableDataHelper& rData )
     397                 :            : {
     398                 :        193 :     sal_Bool bPossible = false;
     399 [ +  - ][ -  + ]:        193 :     if ( ScTransferObj::GetOwnClipboard( NULL ) || ScDrawTransferObj::GetOwnClipboard( NULL ) )
                 [ -  + ]
     400                 :          0 :         bPossible = sal_True;
     401                 :            :     else
     402                 :            :     {
     403   [ +  -  +  -  :       3088 :         if ( rData.HasFormat( SOT_FORMAT_BITMAP ) ||
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  -  + ]
                 [ -  + ]
     404                 :        193 :              rData.HasFormat( SOT_FORMAT_GDIMETAFILE ) ||
     405                 :        193 :              rData.HasFormat( SOT_FORMATSTR_ID_SVXB ) ||
     406                 :        193 :              rData.HasFormat( FORMAT_PRIVATE ) ||
     407                 :        193 :              rData.HasFormat( SOT_FORMAT_RTF ) ||
     408                 :        193 :              rData.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ) ||
     409                 :        193 :              rData.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE ) ||
     410                 :        193 :              rData.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ) ||
     411                 :        193 :              rData.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ) ||
     412                 :        193 :              rData.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE ) ||
     413                 :        193 :              rData.HasFormat( SOT_FORMAT_STRING ) ||
     414                 :        193 :              rData.HasFormat( SOT_FORMATSTR_ID_SYLK ) ||
     415                 :        193 :              rData.HasFormat( SOT_FORMATSTR_ID_LINK ) ||
     416                 :        193 :              rData.HasFormat( SOT_FORMATSTR_ID_HTML ) ||
     417                 :        193 :              rData.HasFormat( SOT_FORMATSTR_ID_HTML_SIMPLE ) ||
     418                 :        193 :              rData.HasFormat( SOT_FORMATSTR_ID_DIF ) )
     419                 :            :         {
     420                 :          0 :             bPossible = sal_True;
     421                 :            :         }
     422                 :            :     }
     423                 :        193 :     return bPossible;
     424                 :            : }
     425                 :            : 
     426                 :          0 : IMPL_LINK( ScCellShell, ClipboardChanged, TransferableDataHelper*, pDataHelper )
     427                 :            : {
     428         [ #  # ]:          0 :     if ( pDataHelper )
     429                 :            :     {
     430                 :          0 :         bPastePossible = lcl_IsCellPastePossible( *pDataHelper );
     431                 :            : 
     432                 :          0 :         SfxBindings& rBindings = GetViewData()->GetBindings();
     433                 :          0 :         rBindings.Invalidate( SID_PASTE );
     434                 :          0 :         rBindings.Invalidate( SID_PASTE_SPECIAL );
     435                 :          0 :         rBindings.Invalidate( SID_PASTE_ONLY_VALUE );
     436                 :          0 :         rBindings.Invalidate( SID_PASTE_ONLY_TEXT );
     437                 :          0 :         rBindings.Invalidate( SID_PASTE_ONLY_FORMULA );
     438                 :          0 :         rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
     439                 :            :     }
     440                 :          0 :     return 0;
     441                 :            : }
     442                 :            : 
     443                 :            : namespace {
     444                 :            : 
     445                 :          0 : bool checkDestRanges(ScViewData& rViewData)
     446                 :            : {
     447                 :          0 :     ScRange aDummy;
     448         [ #  # ]:          0 :     ScMarkType eMarkType = rViewData.GetSimpleArea( aDummy);
     449         [ #  # ]:          0 :     if (eMarkType != SC_MARK_MULTI)
     450                 :            :     {
     451                 :            :         // Single destination range.
     452 [ #  # ][ #  # ]:          0 :         if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
     453                 :          0 :             return false;
     454                 :            :     }
     455                 :            : 
     456                 :            :     // Multiple destination ranges.
     457                 :            : 
     458         [ #  # ]:          0 :     ScDocument* pDoc = rViewData.GetDocument();
     459         [ #  # ]:          0 :     Window* pWin = rViewData.GetActiveWin();
     460         [ #  # ]:          0 :     if (!pWin)
     461                 :          0 :         return false;
     462                 :            : 
     463         [ #  # ]:          0 :     ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(pWin);
     464         [ #  # ]:          0 :     if (!pOwnClip)
     465                 :            :         // If it's not a Calc document, we won't be picky.
     466                 :          0 :         return true;
     467                 :            : 
     468                 :          0 :     ScDocument* pClipDoc = pOwnClip->GetDocument();
     469         [ #  # ]:          0 :     if (!pClipDoc)
     470                 :          0 :         return false;
     471                 :            : 
     472 [ #  # ][ #  # ]:          0 :     ScRange aSrcRange = pClipDoc->GetClipParam().getWholeRange();
     473                 :          0 :     SCROW nRowSize = aSrcRange.aEnd.Row() - aSrcRange.aStart.Row() + 1;
     474                 :          0 :     SCCOL nColSize = aSrcRange.aEnd.Col() - aSrcRange.aStart.Col() + 1;
     475                 :            : 
     476 [ #  # ][ #  # ]:          0 :     ScMarkData aMark = rViewData.GetMarkData();
     477         [ #  # ]:          0 :     ScRangeList aRanges;
     478         [ #  # ]:          0 :     aMark.MarkToSimple();
     479         [ #  # ]:          0 :     aMark.FillRangeListWithMarks(&aRanges, false);
     480                 :            : 
     481 [ #  # ][ #  # ]:          0 :     return ScClipUtil::CheckDestRanges(pDoc, nColSize, nRowSize, aMark, aRanges);
                 [ #  # ]
     482                 :            : }
     483                 :            : 
     484                 :            : }
     485                 :            : 
     486                 :        506 : void ScCellShell::GetClipState( SfxItemSet& rSet )
     487                 :            : {
     488                 :            : // SID_PASTE
     489                 :            : // SID_PASTE_SPECIAL
     490                 :            : // SID_CLIPBOARD_FORMAT_ITEMS
     491                 :            : 
     492         [ +  + ]:        506 :     if ( !pImpl->m_pClipEvtLstnr )
     493                 :            :     {
     494                 :            :         // create listener
     495 [ +  - ][ +  - ]:        193 :         pImpl->m_pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScCellShell, ClipboardChanged ) );
     496                 :        193 :         pImpl->m_pClipEvtLstnr->acquire();
     497         [ +  - ]:        193 :         Window* pWin = GetViewData()->GetActiveWin();
     498         [ +  - ]:        193 :         pImpl->m_pClipEvtLstnr->AddRemoveListener( pWin, sal_True );
     499                 :            : 
     500                 :            :         // get initial state
     501         [ +  - ]:        193 :         TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pWin ) );
     502 [ +  - ][ +  - ]:        193 :         bPastePossible = lcl_IsCellPastePossible( aDataHelper );
     503                 :            :     }
     504                 :            : 
     505                 :        506 :     bool bDisable = !bPastePossible;
     506                 :            : 
     507                 :            :     //  cell protection / multiple selection
     508                 :            : 
     509         [ -  + ]:        506 :     if (!bDisable)
     510                 :            :     {
     511                 :          0 :         SCCOL nCol = GetViewData()->GetCurX();
     512                 :          0 :         SCROW nRow = GetViewData()->GetCurY();
     513                 :          0 :         SCTAB nTab = GetViewData()->GetTabNo();
     514                 :          0 :         ScDocument* pDoc = GetViewData()->GetDocShell()->GetDocument();
     515         [ #  # ]:          0 :         if (!pDoc->IsBlockEditable( nTab, nCol,nRow, nCol,nRow ))
     516                 :          0 :             bDisable = true;
     517                 :            : 
     518         [ #  # ]:          0 :         if (!checkDestRanges(*GetViewData()))
     519                 :          0 :             bDisable = true;
     520                 :            :     }
     521                 :            : 
     522         [ +  - ]:        506 :     if (bDisable)
     523                 :            :     {
     524                 :        506 :         rSet.DisableItem( SID_PASTE );
     525                 :        506 :         rSet.DisableItem( SID_PASTE_SPECIAL );
     526                 :        506 :         rSet.DisableItem( SID_PASTE_ONLY_VALUE );
     527                 :        506 :         rSet.DisableItem( SID_PASTE_ONLY_TEXT );
     528                 :        506 :         rSet.DisableItem( SID_PASTE_ONLY_FORMULA );
     529                 :        506 :         rSet.DisableItem( SID_CLIPBOARD_FORMAT_ITEMS );
     530                 :            :     }
     531         [ #  # ]:          0 :     else if ( rSet.GetItemState( SID_CLIPBOARD_FORMAT_ITEMS ) != SFX_ITEM_UNKNOWN )
     532                 :            :     {
     533         [ #  # ]:          0 :         SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
     534         [ #  # ]:          0 :         GetPossibleClipboardFormats( aFormats );
     535 [ #  # ][ #  # ]:          0 :         rSet.Put( aFormats );
     536                 :            :     }
     537                 :        506 : }
     538                 :            : 
     539                 :            : //  only SID_HYPERLINK_GETLINK:
     540                 :            : 
     541                 :          0 : void ScCellShell::GetHLinkState( SfxItemSet& rSet )
     542                 :            : {
     543                 :            :     //  always return an item (or inserting will be disabled)
     544                 :            :     //  if the cell at the cursor contains only a link, return that link
     545                 :            : 
     546         [ #  # ]:          0 :     SvxHyperlinkItem aHLinkItem;
     547         [ #  # ]:          0 :     if ( !GetViewData()->GetView()->HasBookmarkAtCursor( &aHLinkItem ) )
     548                 :            :     {
     549                 :            :         //! put selected text into item?
     550                 :            :     }
     551                 :            : 
     552 [ #  # ][ #  # ]:          0 :     rSet.Put(aHLinkItem);
     553                 :          0 : }
     554                 :            : 
     555                 :       1813 : void ScCellShell::GetState(SfxItemSet &rSet)
     556                 :            : {
     557                 :       1813 :     ScTabViewShell* pTabViewShell   = GetViewData()->GetViewShell();
     558                 :       1813 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
     559                 :       1813 :     ScViewData* pData       = GetViewData();
     560         [ +  - ]:       1813 :     ScDocument* pDoc        = pData->GetDocument();
     561         [ +  - ]:       1813 :     ScMarkData& rMark       = pData->GetMarkData();
     562                 :       1813 :     SCCOL       nPosX       = pData->GetCurX();
     563                 :       1813 :     SCROW       nPosY       = pData->GetCurY();
     564                 :       1813 :     SCTAB       nTab        = pData->GetTabNo();
     565                 :            : 
     566         [ +  - ]:       1813 :     SCTAB nTabCount = pDoc->GetTableCount();
     567         [ +  - ]:       1813 :     SCTAB nTabSelCount = rMark.GetSelectCount();
     568                 :            : 
     569         [ +  - ]:       1813 :     SfxWhichIter aIter(rSet);
     570         [ +  - ]:       1813 :     sal_uInt16 nWhich = aIter.FirstWhich();
     571         [ +  + ]:       4009 :     while ( nWhich )
     572                 :            :     {
     573   [ -  -  -  -  :       2196 :         switch ( nWhich )
          -  -  -  -  -  
          +  +  +  -  -  
          -  -  +  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
                   +  + ]
     574                 :            :         {
     575                 :            :             case SID_DETECTIVE_REFRESH:
     576 [ #  # ][ #  # ]:          0 :                 if (!pDoc->HasDetectiveOperations())
     577         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     578                 :          0 :                 break;
     579                 :            : 
     580                 :            :             case SID_RANGE_ADDRESS:
     581                 :            :                 {
     582                 :          0 :                     ScRange aRange;
     583 [ #  # ][ #  # ]:          0 :                     if ( pData->GetSimpleArea( aRange ) == SC_MARK_SIMPLE )
     584                 :            :                     {
     585         [ #  # ]:          0 :                         String aStr;
     586                 :          0 :                         sal_uInt16 nFlags = SCA_VALID | SCA_TAB_3D;
     587         [ #  # ]:          0 :                         aRange.Format(aStr,nFlags,pDoc);
     588 [ #  # ][ #  # ]:          0 :                         rSet.Put( SfxStringItem( nWhich, aStr ) );
         [ #  # ][ #  # ]
     589                 :            :                     }
     590                 :            :                 }
     591                 :          0 :                 break;
     592                 :            : 
     593                 :            :             case SID_RANGE_NOTETEXT:
     594                 :            :                 {
     595                 :            :                     //  always take cursor position, do not use top-left cell of selection
     596         [ #  # ]:          0 :                     String aNoteText;
     597 [ #  # ][ #  # ]:          0 :                     if ( const ScPostIt* pNote = pDoc->GetNotes(nTab)->findByAddress(nPosX, nPosY) )
                 [ #  # ]
     598 [ #  # ][ #  # ]:          0 :                         aNoteText = pNote->GetText();
     599 [ #  # ][ #  # ]:          0 :                     rSet.Put( SfxStringItem( nWhich, aNoteText ) );
         [ #  # ][ #  # ]
     600                 :            :                 }
     601                 :          0 :                 break;
     602                 :            : 
     603                 :            :             case SID_RANGE_ROW:
     604 [ #  # ][ #  # ]:          0 :                 rSet.Put( SfxInt32Item( nWhich, nPosY+1 ) );
                 [ #  # ]
     605                 :          0 :                 break;
     606                 :            : 
     607                 :            :             case SID_RANGE_COL:
     608 [ #  # ][ #  # ]:          0 :                 rSet.Put( SfxInt16Item( nWhich, nPosX+1 ) );
                 [ #  # ]
     609                 :          0 :                 break;
     610                 :            : 
     611                 :            :             case SID_RANGE_TABLE:
     612 [ #  # ][ #  # ]:          0 :                 rSet.Put( SfxInt16Item( nWhich, nTab+1 ) );
                 [ #  # ]
     613                 :          0 :                 break;
     614                 :            : 
     615                 :            :             case SID_RANGE_VALUE:
     616                 :            :                 {
     617                 :            :                     double nValue;
     618         [ #  # ]:          0 :                     pDoc->GetValue( nPosX, nPosY, nTab, nValue );
     619 [ #  # ][ #  # ]:          0 :                     rSet.Put( ScDoubleItem( nWhich, nValue ) );
                 [ #  # ]
     620                 :            :                 }
     621                 :          0 :                 break;
     622                 :            : 
     623                 :            :             case SID_RANGE_FORMULA:
     624                 :            :                 {
     625         [ #  # ]:          0 :                     String aString;
     626         [ #  # ]:          0 :                     pDoc->GetFormula( nPosX, nPosY, nTab, aString );
     627         [ #  # ]:          0 :                     if( aString.Len() == 0 )
     628                 :            :                     {
     629         [ #  # ]:          0 :                         pDoc->GetInputString( nPosX, nPosY, nTab, aString );
     630                 :            :                     }
     631 [ #  # ][ #  # ]:          0 :                     rSet.Put( SfxStringItem( nWhich, aString ) );
         [ #  # ][ #  # ]
     632                 :            :                 }
     633                 :          0 :                 break;
     634                 :            : 
     635                 :            :             case SID_RANGE_TEXTVALUE:
     636                 :            :                 {
     637         [ #  # ]:          0 :                     String aString;
     638         [ #  # ]:          0 :                     pDoc->GetString( nPosX, nPosY, nTab, aString );
     639 [ #  # ][ #  # ]:          0 :                     rSet.Put( SfxStringItem( nWhich, aString ) );
         [ #  # ][ #  # ]
     640                 :            :                 }
     641                 :          0 :                 break;
     642                 :            : 
     643                 :            :             case SID_STATUS_SELMODE:
     644                 :            :                 {
     645                 :            :                     /* 0: STD   Click cancels Sel
     646                 :            :                      * 1: ER    Click extends selection
     647                 :            :                      * 2: ERG   Click defines further selection
     648                 :            :                      */
     649         [ +  - ]:        247 :                     sal_uInt16 nMode = pTabViewShell->GetLockedModifiers();
     650                 :            : 
     651      [ -  -  + ]:        247 :                     switch ( nMode )
     652                 :            :                     {
     653                 :          0 :                         case KEY_SHIFT: nMode = 1;  break;
     654                 :          0 :                         case KEY_MOD1:  nMode = 2;  break; // Control-key
     655                 :            :                         case 0:
     656                 :            :                         default:
     657                 :        247 :                             nMode = 0;
     658                 :            :                     }
     659                 :            : 
     660 [ +  - ][ +  - ]:        247 :                     rSet.Put( SfxUInt16Item( nWhich, nMode ) );
                 [ +  - ]
     661                 :            :                 }
     662                 :        247 :                 break;
     663                 :            : 
     664                 :            :             case SID_STATUS_DOCPOS:
     665                 :            :                 {
     666 [ +  - ][ +  - ]:        247 :                     String  aStr( ScGlobal::GetRscString( STR_TABLE ) );
     667                 :            : 
     668         [ +  - ]:        247 :                     aStr += ' ';
     669 [ +  - ][ +  - ]:        247 :                     aStr += String::CreateFromInt32( nTab + 1 );
                 [ +  - ]
     670         [ +  - ]:        247 :                     aStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " / " ));
     671 [ +  - ][ +  - ]:        247 :                     aStr += String::CreateFromInt32( nTabCount );
                 [ +  - ]
     672 [ +  - ][ +  - ]:        247 :                     rSet.Put( SfxStringItem( nWhich, aStr ) );
         [ +  - ][ +  - ]
     673                 :            :                 }
     674                 :        247 :                 break;
     675                 :            : 
     676                 :            :             //  calculations etc. with date/time/Fail/position&size together
     677                 :            : 
     678                 :            :             // #i34458# The SfxStringItem belongs only into SID_TABLE_CELL. It no longer has to be
     679                 :            :             // duplicated in SID_ATTR_POSITION or SID_ATTR_SIZE for SvxPosSizeStatusBarControl.
     680                 :            :             case SID_TABLE_CELL:
     681                 :            :                 {
     682                 :            :                     //  Test, if error under cursor
     683                 :            :                     //  (not pDoc->GetErrCode, to avoid erasing circular references)
     684                 :            : 
     685                 :            :                     // In interpreter may happen via rescheduled Basic
     686         [ -  + ]:        247 :                     if ( pDoc->IsInInterpreter() )
     687 [ #  # ][ #  # ]:          0 :                         rSet.Put( SfxStringItem( nWhich, rtl::OUString("...") ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     688                 :            :                     else
     689                 :            :                     {
     690                 :        247 :                         sal_uInt16 nErrCode = 0;
     691                 :            :                         ScBaseCell* pCell;
     692         [ +  - ]:        247 :                         pDoc->GetCell( nPosX, nPosY, nTab, pCell );
     693 [ +  + ][ -  + ]:        247 :                         if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
                 [ -  + ]
     694                 :            :                         {
     695         [ #  # ]:          0 :                             ScFormulaCell* pFCell = (ScFormulaCell*) pCell;
     696         [ #  # ]:          0 :                             if (!pFCell->IsRunning())
     697         [ #  # ]:          0 :                                 nErrCode = pFCell->GetErrCode();
     698                 :            :                         }
     699                 :            : 
     700         [ +  - ]:        247 :                         String aFuncStr;
     701 [ +  - ][ +  + ]:        247 :                         if ( pTabViewShell->GetFunction( aFuncStr, nErrCode ) )
     702 [ +  - ][ +  - ]:        247 :                             rSet.Put( SfxStringItem( nWhich, aFuncStr ) );
         [ +  - ][ +  - ]
     703                 :            :                     }
     704                 :            :                 }
     705                 :        247 :                 break;
     706                 :            : 
     707                 :            :             case SID_DATA_SELECT:
     708                 :            :                 // HasSelectionData includes column content and validity,
     709                 :            :                 // page fields have to be checked separately.
     710 [ #  # ][ #  # ]:          0 :                 if ( !pDoc->HasSelectionData( nPosX, nPosY, nTab ) &&
         [ #  # ][ #  # ]
     711         [ #  # ]:          0 :                      !pTabViewShell->HasPageFieldDataAtCursor() )
     712         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     713                 :          0 :                 break;
     714                 :            : 
     715                 :            :             case SID_STATUS_SUM:
     716                 :            :                 {
     717         [ #  # ]:          0 :                     String aFuncStr;
     718 [ #  # ][ #  # ]:          0 :                     if ( pTabViewShell->GetFunction( aFuncStr ) )
     719 [ #  # ][ #  # ]:          0 :                         rSet.Put( SfxStringItem( nWhich, aFuncStr ) );
         [ #  # ][ #  # ]
     720                 :            :                 }
     721                 :          0 :                 break;
     722                 :            : 
     723                 :            :             case FID_MERGE_ON:
     724 [ #  # ][ #  # ]:          0 :                 if ( pDoc->GetChangeTrack() || !pTabViewShell->TestMergeCells() )
         [ #  # ][ #  # ]
     725         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     726                 :          0 :                 break;
     727                 :            : 
     728                 :            :             case FID_MERGE_OFF:
     729 [ #  # ][ #  # ]:          0 :                 if ( pDoc->GetChangeTrack() || !pTabViewShell->TestRemoveMerge() )
         [ #  # ][ #  # ]
     730         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     731                 :          0 :                 break;
     732                 :            : 
     733                 :            :             case FID_MERGE_TOGGLE:
     734         [ -  + ]:        240 :                 if ( pDoc->GetChangeTrack() )
     735         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     736                 :            :                 else
     737                 :            :                 {
     738         [ +  - ]:        240 :                     bool bCanMerge = pTabViewShell->TestMergeCells();
     739         [ +  - ]:        240 :                     bool bCanSplit = pTabViewShell->TestRemoveMerge();
     740 [ +  - ][ +  - ]:        240 :                     if( !bCanMerge && !bCanSplit )
     741         [ +  - ]:        240 :                         rSet.DisableItem( nWhich );
     742                 :            :                     else
     743 [ #  # ][ #  # ]:          0 :                         rSet.Put( SfxBoolItem( nWhich, bCanSplit ) );
                 [ #  # ]
     744                 :            :                 }
     745                 :        240 :                 break;
     746                 :            : 
     747                 :            :             case FID_INS_ROWBRK:
     748 [ #  # ][ #  # ]:          0 :                 if ( nPosY==0 || (pDoc->HasRowBreak(nPosY, nTab) & BREAK_MANUAL) )
         [ #  # ][ #  # ]
     749         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     750                 :          0 :                 break;
     751                 :            : 
     752                 :            :             case FID_INS_COLBRK:
     753 [ #  # ][ #  # ]:          0 :                 if ( nPosX==0 || (pDoc->HasColBreak(nPosX, nTab) & BREAK_MANUAL) )
         [ #  # ][ #  # ]
     754         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     755                 :          0 :                 break;
     756                 :            : 
     757                 :            :             case FID_DEL_ROWBRK:
     758 [ #  # ][ #  # ]:          0 :                 if ( nPosY==0 || (pDoc->HasRowBreak(nPosY, nTab) & BREAK_MANUAL) == 0 )
         [ #  # ][ #  # ]
     759         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     760                 :          0 :                 break;
     761                 :            : 
     762                 :            :             case FID_DEL_COLBRK:
     763 [ #  # ][ #  # ]:          0 :                 if ( nPosX==0 || (pDoc->HasColBreak(nPosX, nTab) & BREAK_MANUAL) == 0 )
         [ #  # ][ #  # ]
     764         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     765                 :          0 :                 break;
     766                 :            : 
     767                 :            :             case FID_FILL_TAB:
     768         [ #  # ]:          0 :                 if ( nTabSelCount < 2 )
     769         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     770                 :          0 :                 break;
     771                 :            : 
     772                 :            :             case SID_SELECT_SCENARIO:
     773                 :            :                 {
     774         [ #  # ]:          0 :                     std::vector<String> aList;
     775                 :          0 :                     Color   aDummyCol;
     776                 :            : 
     777 [ #  # ][ #  # ]:          0 :                     if ( !pDoc->IsScenario(nTab) )
     778                 :            :                     {
     779                 :          0 :                         rtl::OUString aStr;
     780                 :            :                         sal_uInt16 nFlags;
     781                 :          0 :                         SCTAB nScTab = nTab + 1;
     782         [ #  # ]:          0 :                         String aProtect;
     783         [ #  # ]:          0 :                         bool bSheetProtected = pDoc->IsTabProtected(nTab);
     784                 :            : 
     785 [ #  # ][ #  # ]:          0 :                         while ( pDoc->IsScenario(nScTab) )
     786                 :            :                         {
     787         [ #  # ]:          0 :                             pDoc->GetName( nScTab, aStr );
     788 [ #  # ][ #  # ]:          0 :                             aList.push_back(aStr);
                 [ #  # ]
     789         [ #  # ]:          0 :                             pDoc->GetScenarioData( nScTab, aStr, aDummyCol, nFlags );
     790 [ #  # ][ #  # ]:          0 :                             aList.push_back(aStr);
                 [ #  # ]
     791                 :            :                             // Protection is sal_True if both Sheet and Scenario are protected
     792 [ #  # ][ #  # ]:          0 :                             aProtect = (bSheetProtected && (nFlags & SC_SCENARIO_PROTECT)) ? '1' : '0';
                 [ #  # ]
     793         [ #  # ]:          0 :                             aList.push_back(aProtect);
     794                 :          0 :                             ++nScTab;
     795         [ #  # ]:          0 :                         }
     796                 :            :                     }
     797                 :            :                     else
     798                 :            :                     {
     799                 :          0 :                         rtl::OUString aComment;
     800                 :            :                         sal_uInt16  nDummyFlags;
     801         [ #  # ]:          0 :                         pDoc->GetScenarioData( nTab, aComment, aDummyCol, nDummyFlags );
     802                 :            :                         OSL_ENSURE( aList.empty(), "List not empty!" );
     803 [ #  # ][ #  # ]:          0 :                         aList.push_back(aComment);
                 [ #  # ]
     804                 :            :                     }
     805                 :            : 
     806 [ #  # ][ #  # ]:          0 :                     rSet.Put( SfxStringListItem( nWhich, &aList ) );
                 [ #  # ]
     807                 :            :                 }
     808                 :          0 :                 break;
     809                 :            : 
     810                 :            :             case FID_ROW_HIDE:
     811                 :            :             case FID_ROW_SHOW:
     812                 :            :             case FID_COL_HIDE:
     813                 :            :             case FID_COL_SHOW:
     814                 :            :             case FID_COL_OPT_WIDTH:
     815                 :            :             case FID_ROW_OPT_HEIGHT:
     816                 :            :             case FID_DELETE_CELL:
     817 [ #  # ][ #  # ]:          0 :                 if ( pDoc->IsTabProtected(nTab) || pDocSh->IsReadOnly())
         [ #  # ][ #  # ]
                 [ #  # ]
     818         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     819                 :          0 :                 break;
     820                 :            : 
     821                 :            :             case SID_OUTLINE_MAKE:
     822                 :            :                 {
     823         [ #  # ]:          0 :                     if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
     824 [ #  # ][ #  # ]:          0 :                                             GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
     825                 :            :                     {
     826                 :            :                         //! test for data pilot operation
     827                 :            :                     }
     828 [ #  # ][ #  # ]:          0 :                     else if (pDoc->GetChangeTrack()!=NULL || GetViewData()->IsMultiMarked())
         [ #  # ][ #  # ]
     829                 :            :                     {
     830         [ #  # ]:          0 :                         rSet.DisableItem( nWhich );
     831                 :            :                     }
     832                 :            :                 }
     833                 :          0 :                 break;
     834                 :            :             case SID_OUTLINE_SHOW:
     835         [ #  # ]:          0 :                 if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
     836 [ #  # ][ #  # ]:          0 :                                         GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
     837                 :            :                 {
     838                 :            :                     //! test for data pilot operation
     839                 :            :                 }
     840 [ #  # ][ #  # ]:          0 :                 else if (!pTabViewShell->OutlinePossible(false))
     841         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     842                 :          0 :                 break;
     843                 :            : 
     844                 :            :             case SID_OUTLINE_HIDE:
     845         [ #  # ]:          0 :                 if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
     846 [ #  # ][ #  # ]:          0 :                                         GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
     847                 :            :                 {
     848                 :            :                     //! test for data pilot operation
     849                 :            :                 }
     850 [ #  # ][ #  # ]:          0 :                 else if (!pTabViewShell->OutlinePossible(sal_True))
     851         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     852                 :          0 :                 break;
     853                 :            : 
     854                 :            :             case SID_OUTLINE_REMOVE:
     855                 :            :                 {
     856         [ #  # ]:          0 :                     if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
     857 [ #  # ][ #  # ]:          0 :                                             GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
     858                 :            :                     {
     859                 :            :                         //! test for data pilot operation
     860                 :            :                     }
     861                 :            :                     else
     862                 :            :                     {
     863                 :            :                         sal_Bool bCol, bRow;
     864         [ #  # ]:          0 :                         pTabViewShell->TestRemoveOutline( bCol, bRow );
     865 [ #  # ][ #  # ]:          0 :                         if ( !bCol && !bRow )
     866         [ #  # ]:          0 :                             rSet.DisableItem( nWhich );
     867                 :            :                     }
     868                 :            :                 }
     869                 :          0 :                 break;
     870                 :            : 
     871                 :            :             case FID_COL_WIDTH:
     872                 :            :                 {
     873                 :            :                     //GetViewData()->GetCurX();
     874 [ #  # ][ #  # ]:          0 :                     SfxUInt16Item aWidthItem( FID_COL_WIDTH, pDoc->GetColWidth( nPosX , nTab) );
     875         [ #  # ]:          0 :                     rSet.Put( aWidthItem );
     876 [ #  # ][ #  # ]:          0 :                     if ( pDocSh->IsReadOnly())
     877 [ #  # ][ #  # ]:          0 :                         rSet.DisableItem( nWhich );
     878                 :            : 
     879                 :            :                     //XXX disable if not conclusive
     880                 :            :                 }
     881                 :          0 :                 break;
     882                 :            : 
     883                 :            :             case FID_ROW_HEIGHT:
     884                 :            :                 {
     885                 :            :                     //GetViewData()->GetCurY();
     886 [ #  # ][ #  # ]:          0 :                     SfxUInt16Item aHeightItem( FID_ROW_HEIGHT, pDoc->GetRowHeight( nPosY , nTab) );
     887         [ #  # ]:          0 :                     rSet.Put( aHeightItem );
     888                 :            :                     //XXX disable if not conclusive
     889 [ #  # ][ #  # ]:          0 :                     if ( pDocSh->IsReadOnly())
     890 [ #  # ][ #  # ]:          0 :                         rSet.DisableItem( nWhich );
     891                 :            :                 }
     892                 :          0 :                 break;
     893                 :            : 
     894                 :            :             case SID_DETECTIVE_FILLMODE:
     895 [ #  # ][ #  # ]:          0 :                 rSet.Put(SfxBoolItem( nWhich, pTabViewShell->IsAuditShell() ));
         [ #  # ][ #  # ]
     896                 :          0 :                 break;
     897                 :            : 
     898                 :            :             case FID_INPUTLINE_STATUS:
     899                 :            :                 OSL_FAIL( "Old update method. Use ScTabViewShell::UpdateInputHandler()." );
     900                 :          0 :                 break;
     901                 :            : 
     902                 :            :             case SID_SCENARIOS:                                     // scenarios:
     903 [ #  # ][ #  # ]:          0 :                 if (!(rMark.IsMarked() || rMark.IsMultiMarked()))   // only, if something selected
                 [ #  # ]
     904         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     905                 :          0 :                 break;
     906                 :            : 
     907                 :            :             case FID_NOTE_VISIBLE:
     908                 :            :                 {
     909 [ #  # ][ #  # ]:          0 :                     const ScPostIt* pNote = pDoc->GetNotes(nTab)->findByAddress(nPosX, nPosY);
     910 [ #  # ][ #  # ]:          0 :                     if ( pNote && pDoc->IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) )
         [ #  # ][ #  # ]
     911 [ #  # ][ #  # ]:          0 :                         rSet.Put( SfxBoolItem( nWhich, pNote->IsCaptionShown() ) );
                 [ #  # ]
     912                 :            :                     else
     913         [ #  # ]:          0 :                         rSet.DisableItem( nWhich );
     914                 :            :                 }
     915                 :          0 :                 break;
     916                 :            : 
     917                 :            :             case SID_DELETE_NOTE:
     918                 :            :                 {
     919                 :          0 :                     bool bEnable = false;
     920 [ #  # ][ #  # ]:          0 :                     if ( rMark.IsMarked() || rMark.IsMultiMarked() )
                 [ #  # ]
     921                 :            :                     {
     922 [ #  # ][ #  # ]:          0 :                         if ( pDoc->IsSelectionEditable( rMark ) )
     923                 :            :                         {
     924                 :            :                             // look for at least one note in selection
     925         [ #  # ]:          0 :                             ScRangeList aRanges;
     926         [ #  # ]:          0 :                             rMark.FillRangeListWithMarks( &aRanges, false );
     927         [ #  # ]:          0 :                             size_t nCount = aRanges.size();
     928 [ #  # ][ #  # ]:          0 :                             for (size_t nPos = 0; nPos < nCount && !bEnable; ++nPos)
                 [ #  # ]
     929                 :            :                             {
     930 [ #  # ][ #  # ]:          0 :                                 ScNotes* pNotes = pDoc->GetNotes( aRanges[nPos]->aStart.Tab() );
     931 [ #  # ][ #  # ]:          0 :                                 for (ScNotes::const_iterator itr = pNotes->begin(); itr != pNotes->end(); ++itr)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     932                 :            :                                 {
     933         [ #  # ]:          0 :                                     SCCOL nCol = itr->first.first;
     934         [ #  # ]:          0 :                                     SCROW nRow = itr->first.second;
     935                 :            : 
     936 [ #  # ][ #  # ]:          0 :                                     if ( nCol <= aRanges[nPos]->aEnd.Col() && nRow <= aRanges[nPos]->aEnd.Row()
         [ #  # ][ #  #  
             #  #  #  # ]
                 [ #  # ]
     937 [ #  # ][ #  # ]:          0 :                                             && nCol >= aRanges[nPos]->aStart.Col() && nRow >= aRanges[nPos]->aStart.Row() )
     938                 :          0 :                                         bEnable = true; //note found
     939                 :            :                                 }
     940         [ #  # ]:          0 :                             }
     941                 :            :                         }
     942                 :            :                     }
     943                 :            :                     else
     944                 :            :                     {
     945         [ #  # ]:          0 :                         bEnable = pDoc->IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) &&
     946 [ #  # ][ #  # ]:          0 :                                   pDoc->GetNotes(nTab)->findByAddress( nPosX, nPosY );
         [ #  # ][ #  # ]
     947                 :            :                     }
     948         [ #  # ]:          0 :                     if ( !bEnable )
     949         [ #  # ]:          0 :                         rSet.DisableItem( nWhich );
     950                 :            :                 }
     951                 :          0 :                 break;
     952                 :            : 
     953                 :            :             case SID_OPENDLG_CONSOLIDATE:
     954                 :            :             case SCITEM_CONSOLIDATEDATA:
     955                 :            :                 {
     956         [ #  # ]:          0 :                     if(pDoc->GetChangeTrack()!=NULL)
     957         [ #  # ]:          0 :                                 rSet.DisableItem( nWhich);
     958                 :            :                 }
     959                 :          0 :                 break;
     960                 :            : 
     961                 :            :             case SID_CHINESE_CONVERSION:
     962                 :            :             case SID_HANGUL_HANJA_CONVERSION:
     963 [ #  # ][ #  # ]:          0 :                 ScViewUtil::HideDisabledSlot( rSet, pData->GetBindings(), nWhich );
     964                 :          0 :             break;
     965                 :            : 
     966                 :            :             case FID_USE_NAME:
     967                 :            :                 {
     968 [ #  # ][ #  # ]:          0 :                     if ( pDocSh && pDocSh->IsDocShared() )
         [ #  # ][ #  # ]
     969         [ #  # ]:          0 :                         rSet.DisableItem( nWhich );
     970                 :            :                     else
     971                 :            :                     {
     972                 :          0 :                         ScRange aRange;
     973 [ #  # ][ #  # ]:          0 :                         if ( pData->GetSimpleArea( aRange ) != SC_MARK_SIMPLE )
     974         [ #  # ]:          0 :                             rSet.DisableItem( nWhich );
     975                 :            :                     }
     976                 :            :                 }
     977                 :          0 :                 break;
     978                 :            : 
     979                 :            :             case FID_DEFINE_NAME:
     980                 :            :             case FID_INSERT_NAME:
     981                 :            :             case FID_ADD_NAME:
     982                 :            :             case SID_DEFINE_COLROWNAMERANGES:
     983                 :            :                 {
     984 [ #  # ][ #  # ]:          0 :                     if ( pDocSh && pDocSh->IsDocShared() )
         [ #  # ][ #  # ]
     985                 :            :                     {
     986         [ #  # ]:          0 :                         rSet.DisableItem( nWhich );
     987                 :            :                     }
     988                 :            :                 }
     989                 :          0 :                 break;
     990                 :            : 
     991                 :            :             case SID_SPELL_DIALOG:
     992                 :            :                 {
     993 [ +  - ][ +  - ]:        241 :                     if ( pDoc && pData && pDoc->IsTabProtected( pData->GetTabNo() ) )
         [ +  - ][ -  + ]
                 [ -  + ]
     994                 :            :                     {
     995                 :          0 :                         bool bVisible = false;
     996         [ #  # ]:          0 :                         SfxViewFrame* pViewFrame = ( pTabViewShell ? pTabViewShell->GetViewFrame() : NULL );
     997 [ #  # ][ #  # ]:          0 :                         if ( pViewFrame && pViewFrame->HasChildWindow( nWhich ) )
         [ #  # ][ #  # ]
     998                 :            :                         {
     999         [ #  # ]:          0 :                             SfxChildWindow* pChild = pViewFrame->GetChildWindow( nWhich );
    1000         [ #  # ]:          0 :                             Window* pWin = ( pChild ? pChild->GetWindow() : NULL );
    1001 [ #  # ][ #  # ]:          0 :                             if ( pWin && pWin->IsVisible() )
         [ #  # ][ #  # ]
    1002                 :            :                             {
    1003                 :          0 :                                 bVisible = true;
    1004                 :            :                             }
    1005                 :            :                         }
    1006         [ #  # ]:          0 :                         if ( !bVisible )
    1007                 :            :                         {
    1008         [ #  # ]:          0 :                             rSet.DisableItem( nWhich );
    1009                 :            :                         }
    1010                 :            :                     }
    1011                 :            :                 }
    1012                 :        241 :                 break;
    1013                 :            : 
    1014                 :            :         } // switch ( nWitch )
    1015         [ +  - ]:       2196 :         nWhich = aIter.NextWhich();
    1016         [ +  - ]:       1813 :     } // while ( nWitch )
    1017                 :       1813 : }
    1018                 :            : 
    1019                 :            : //------------------------------------------------------------------
    1020                 :            : 
    1021                 :            : 
    1022                 :            : 
    1023                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10