LCOV - code coverage report
Current view: top level - sc/source/core/data - table1.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 703 1085 64.8 %
Date: 2012-08-25 Functions: 67 86 77.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 587 1266 46.4 %

           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                 :            : #include <svx/algitem.hxx>
      31                 :            : #include <editeng/justifyitem.hxx>
      32                 :            : #include <unotools/textsearch.hxx>
      33                 :            : #include <sfx2/objsh.hxx>
      34                 :            : 
      35                 :            : #include "attrib.hxx"
      36                 :            : #include "patattr.hxx"
      37                 :            : #include "cell.hxx"
      38                 :            : #include "table.hxx"
      39                 :            : #include "document.hxx"
      40                 :            : #include "drwlayer.hxx"
      41                 :            : #include "olinetab.hxx"
      42                 :            : #include "stlsheet.hxx"
      43                 :            : #include "global.hxx"
      44                 :            : #include "globstr.hrc"
      45                 :            : #include "refupdat.hxx"
      46                 :            : #include "markdata.hxx"
      47                 :            : #include "progress.hxx"
      48                 :            : #include "hints.hxx"        // fuer Paint-Broadcast
      49                 :            : #include "prnsave.hxx"
      50                 :            : #include "tabprotection.hxx"
      51                 :            : #include "sheetevents.hxx"
      52                 :            : #include "segmenttree.hxx"
      53                 :            : #include "dbdata.hxx"
      54                 :            : #include "colorscale.hxx"
      55                 :            : #include "conditio.hxx"
      56                 :            : 
      57                 :            : #include <vector>
      58                 :            : 
      59                 :            : using ::std::vector;
      60                 :            : 
      61                 :            : namespace {
      62                 :            : 
      63                 :       1800 : ScProgress* GetProgressBar(
      64                 :            :     SCSIZE nCount, SCSIZE nTotalCount, ScProgress* pOuterProgress, ScDocument* pDoc)
      65                 :            : {
      66         [ +  + ]:       1800 :     if (nTotalCount < 1000)
      67                 :            :     {
      68                 :            :         // if the total number of rows is less than 1000, don't even bother
      69                 :            :         // with the progress bar because drawing progress bar can be very
      70                 :            :         // expensive especially in GTK.
      71                 :       1779 :         return NULL;
      72                 :            :     }
      73                 :            : 
      74         [ +  + ]:         21 :     if (pOuterProgress)
      75                 :          6 :         return pOuterProgress;
      76                 :            : 
      77         [ +  - ]:         15 :     if (nCount > 1)
      78                 :            :         return new ScProgress(
      79         [ +  - ]:         15 :             pDoc->GetDocumentShell(), ScGlobal::GetRscString(STR_PROGRESS_HEIGHTING), nTotalCount);
      80                 :            : 
      81                 :       1800 :     return NULL;
      82                 :            : }
      83                 :            : 
      84                 :       1800 : void GetOptimalHeightsInColumn(
      85                 :            :     ScColumn* pCol, SCROW nStartRow, SCROW nEndRow, vector<sal_uInt16>& aHeights,
      86                 :            :     OutputDevice* pDev, double nPPTX, double nPPTY, const Fraction& rZoomX, const Fraction& rZoomY, bool bForce,
      87                 :            :     ScProgress* pProgress, sal_uInt32 nProgressStart)
      88                 :            : {
      89                 :       1800 :     SCSIZE nCount = static_cast<SCSIZE>(nEndRow-nStartRow+1);
      90                 :            : 
      91                 :            :     //  zuerst einmal ueber den ganzen Bereich
      92                 :            :     //  (mit der letzten Spalte in der Hoffnung, dass die am ehesten noch auf
      93                 :            :     //   Standard formatiert ist)
      94                 :            : 
      95                 :            :     pCol[MAXCOL].GetOptimalHeight(
      96                 :       1800 :             nStartRow, nEndRow, &aHeights[0], pDev, nPPTX, nPPTY, rZoomX, rZoomY, bForce, 0, 0 );
      97                 :            : 
      98                 :            :     //  daraus Standardhoehe suchen, die im unteren Bereich gilt
      99                 :            : 
     100                 :       1800 :     sal_uInt16 nMinHeight = aHeights[nCount-1];
     101                 :       1800 :     SCSIZE nPos = nCount-1;
     102 [ +  + ][ +  - ]:  947916838 :     while ( nPos && aHeights[nPos-1] >= nMinHeight )
                 [ +  + ]
     103                 :  947915038 :         --nPos;
     104                 :       1800 :     SCROW nMinStart = nStartRow + nPos;
     105                 :            : 
     106                 :       1800 :     sal_uLong nWeightedCount = 0;
     107         [ +  + ]:    1843200 :     for (SCCOL nCol=0; nCol<MAXCOL; nCol++)     // MAXCOL schon oben
     108                 :            :     {
     109                 :            :         pCol[nCol].GetOptimalHeight(
     110                 :    1841400 :             nStartRow, nEndRow, &aHeights[0], pDev, nPPTX, nPPTY, rZoomX, rZoomY, bForce,
     111                 :    1841400 :             nMinHeight, nMinStart );
     112                 :            : 
     113         [ +  + ]:    1841400 :         if (pProgress)
     114                 :            :         {
     115                 :      21483 :             sal_uLong nWeight = pCol[nCol].GetWeightedCount();
     116         [ +  + ]:      21483 :             if (nWeight)        // nochmal denselben Status muss auch nicht sein
     117                 :            :             {
     118                 :        513 :                 nWeightedCount += nWeight;
     119                 :        513 :                 pProgress->SetState( nWeightedCount + nProgressStart );
     120                 :            :             }
     121                 :            :         }
     122                 :            :     }
     123                 :       1800 : }
     124                 :            : 
     125                 :       1800 : struct OptimalHeightsFuncObjBase
     126                 :            : {
     127         [ -  + ]:       1800 :     virtual ~OptimalHeightsFuncObjBase() {}
     128                 :            :     virtual bool operator() (SCROW nStartRow, SCROW nEndRow, sal_uInt16 nHeight) = 0;
     129                 :            : };
     130                 :            : 
     131         [ #  # ]:          0 : struct SetRowHeightOnlyFunc : public OptimalHeightsFuncObjBase
     132                 :            : {
     133                 :            :     ScTable* mpTab;
     134                 :          0 :     SetRowHeightOnlyFunc(ScTable* pTab) :
     135                 :          0 :         mpTab(pTab)
     136                 :          0 :     {}
     137                 :            : 
     138                 :          0 :     virtual bool operator() (SCROW nStartRow, SCROW nEndRow, sal_uInt16 nHeight)
     139                 :            :     {
     140                 :          0 :         mpTab->SetRowHeightOnly(nStartRow, nEndRow, nHeight);
     141                 :          0 :         return false;
     142                 :            :     }
     143                 :            : };
     144                 :            : 
     145         [ -  + ]:       1800 : struct SetRowHeightRangeFunc : public OptimalHeightsFuncObjBase
     146                 :            : {
     147                 :            :     ScTable* mpTab;
     148                 :            :     double mnPPTX;
     149                 :            :     double mnPPTY;
     150                 :            : 
     151                 :       1800 :     SetRowHeightRangeFunc(ScTable* pTab, double nPPTX, double nPPTY) :
     152                 :            :         mpTab(pTab),
     153                 :            :         mnPPTX(nPPTX),
     154                 :       1800 :         mnPPTY(nPPTY)
     155                 :       1800 :     {}
     156                 :            : 
     157                 :       2514 :     virtual bool operator() (SCROW nStartRow, SCROW nEndRow, sal_uInt16 nHeight)
     158                 :            :     {
     159                 :       2514 :         return mpTab->SetRowHeightRange(nStartRow, nEndRow, nHeight, mnPPTX, mnPPTY);
     160                 :            :     }
     161                 :            : };
     162                 :            : 
     163                 :       1800 : bool SetOptimalHeightsToRows( OptimalHeightsFuncObjBase& rFuncObj, ScTable* pTab,
     164                 :            :     ScBitMaskCompressedArray<SCROW, sal_uInt8>* pRowFlags, SCROW nStartRow, SCROW nEndRow, sal_uInt16 nExtra,
     165                 :            :     const vector<sal_uInt16>& aHeights, bool bForce)
     166                 :            : {
     167                 :       1800 :     pTab->IncRecalcLevel();       // #i116460# avoid problems with Excel files
     168                 :            : 
     169                 :       1800 :     SCSIZE nCount = static_cast<SCSIZE>(nEndRow-nStartRow+1);
     170                 :       1800 :     bool bChanged = false;
     171                 :       1800 :     SCROW nRngStart = 0;
     172                 :       1800 :     SCROW nRngEnd = 0;
     173                 :       1800 :     sal_uInt16 nLast = 0;
     174         [ +  + ]:       3600 :     for (SCSIZE i=0; i<nCount; i++)
     175                 :            :     {
     176                 :            :         size_t nIndex;
     177                 :            :         SCROW nRegionEndRow;
     178         [ +  - ]:       1800 :         sal_uInt8 nRowFlag = pRowFlags->GetValue( nStartRow+i, nIndex, nRegionEndRow );
     179         [ +  + ]:       1800 :         if ( nRegionEndRow > nEndRow )
     180                 :        896 :             nRegionEndRow = nEndRow;
     181                 :       1800 :         SCSIZE nMoreRows = nRegionEndRow - ( nStartRow+i );     // additional equal rows after first
     182                 :            : 
     183                 :       1800 :         bool bAutoSize = ((nRowFlag & CR_MANUALSIZE) == 0);
     184 [ -  + ][ #  # ]:       1800 :         if ( bAutoSize || bForce )
     185                 :            :         {
     186         [ -  + ]:       1800 :             if (nExtra)
     187                 :            :             {
     188         [ #  # ]:          0 :                 if (bAutoSize)
     189         [ #  # ]:          0 :                     pRowFlags->SetValue( nStartRow+i, nRegionEndRow, nRowFlag | CR_MANUALSIZE);
     190                 :            :             }
     191         [ -  + ]:       1800 :             else if (!bAutoSize)
     192         [ #  # ]:          0 :                 pRowFlags->SetValue( nStartRow+i, nRegionEndRow, nRowFlag & ~CR_MANUALSIZE);
     193                 :            : 
     194         [ +  + ]:  947918638 :             for (SCSIZE nInner = i; nInner <= i + nMoreRows; ++nInner)
     195                 :            :             {
     196         [ +  + ]:  947916838 :                 if (nLast)
     197                 :            :                 {
     198 [ +  - ][ +  + ]:  947915038 :                     if (aHeights[nInner]+nExtra == nLast)
     199                 :  947914324 :                         nRngEnd = nStartRow+nInner;
     200                 :            :                     else
     201                 :            :                     {
     202         [ +  - ]:        714 :                         bChanged |= rFuncObj(nRngStart, nRngEnd, nLast);
     203                 :        714 :                         nLast = 0;
     204                 :            :                     }
     205                 :            :                 }
     206         [ +  + ]:  947916838 :                 if (!nLast)
     207                 :            :                 {
     208         [ +  - ]:       2514 :                     nLast = aHeights[nInner]+nExtra;
     209                 :       2514 :                     nRngStart = nStartRow+nInner;
     210                 :       2514 :                     nRngEnd = nStartRow+nInner;
     211                 :            :                 }
     212                 :       1800 :             }
     213                 :            :         }
     214                 :            :         else
     215                 :            :         {
     216         [ #  # ]:          0 :             if (nLast)
     217         [ #  # ]:          0 :                 bChanged |= rFuncObj(nRngStart, nRngEnd, nLast);
     218                 :          0 :             nLast = 0;
     219                 :            :         }
     220                 :       1800 :         i += nMoreRows;     // already handled - skip
     221                 :            :     }
     222         [ +  - ]:       1800 :     if (nLast)
     223                 :       1800 :         bChanged |= rFuncObj(nRngStart, nRngEnd, nLast);
     224                 :            : 
     225                 :       1800 :     pTab->DecRecalcLevel();       // #i116460# avoid problems with Excel files
     226                 :            : 
     227                 :       1800 :     return bChanged;
     228                 :            : }
     229                 :            : 
     230                 :            : }
     231                 :            : 
     232                 :            : // -----------------------------------------------------------------------
     233                 :            : 
     234                 :       1936 : ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const rtl::OUString& rNewName,
     235                 :            :                     bool bColInfo, bool bRowInfo ) :
     236                 :            :     aName( rNewName ),
     237                 :            :     aCodeName( rNewName ),
     238                 :            :     nLinkMode( 0 ),
     239         [ +  - ]:       1936 :     aPageStyle( ScGlobal::GetRscString(STR_STYLENAME_STANDARD) ),
     240                 :            :     nRepeatStartX( SCCOL_REPEAT_NONE ),
     241                 :            :     nRepeatEndX( SCCOL_REPEAT_NONE ),
     242                 :            :     nRepeatStartY( SCROW_REPEAT_NONE ),
     243                 :            :     nRepeatEndY( SCROW_REPEAT_NONE ),
     244                 :            :     pTabProtection( NULL ),
     245                 :            :     pColWidth( NULL ),
     246                 :            :     mpRowHeights( static_cast<ScFlatUInt16RowSegments*>(NULL) ),
     247                 :            :     pColFlags( NULL ),
     248                 :            :     pRowFlags( NULL ),
     249         [ +  - ]:       1936 :     mpHiddenCols(new ScFlatBoolColSegments),
     250         [ +  - ]:       1936 :     mpHiddenRows(new ScFlatBoolRowSegments),
     251         [ +  - ]:       1936 :     mpFilteredCols(new ScFlatBoolColSegments),
     252         [ +  - ]:       1936 :     mpFilteredRows(new ScFlatBoolRowSegments),
     253                 :            :     pOutlineTable( NULL ),
     254                 :            :     pSheetEvents( NULL ),
     255                 :            :     nTab( nNewTab ),
     256                 :            :     nRecalcLvl( 0 ),
     257                 :            :     pDocument( pDoc ),
     258                 :            :     pSearchText ( NULL ),
     259                 :            :     pSortCollator( NULL ),
     260                 :            :     pRepeatColRange( NULL ),
     261                 :            :     pRepeatRowRange( NULL ),
     262                 :            :     nLockCount( 0 ),
     263                 :            :     pScenarioRanges( NULL ),
     264                 :            :     aScenarioColor( COL_LIGHTGRAY ),
     265                 :            :     aTabBgColor( COL_AUTO ),
     266                 :            :     nScenarioFlags( 0 ),
     267                 :            :     pDBDataNoName(NULL),
     268                 :            :     mpRangeName(NULL),
     269                 :          0 :     mpCondFormatList( new ScConditionalFormatList() ),
     270                 :            :     maNotes(pDoc),
     271                 :            :     bScenario(false),
     272                 :            :     bLayoutRTL(false),
     273                 :            :     bLoadingRTL(false),
     274                 :            :     bPageSizeValid(false),
     275                 :            :     bTableAreaValid(false),
     276                 :            :     bVisible(true),
     277                 :            :     bStreamValid(false),
     278                 :            :     bPendingRowHeights(false),
     279                 :            :     bCalcNotification(false),
     280                 :            :     bGlobalKeepQuery(false),
     281                 :            :     bPrintEntireSheet(true),
     282                 :            :     bActiveScenario(false),
     283 [ +  - ][ +  + ]:    1994080 :     mbPageBreaksValid(false)
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  -  
             #  #  #  # ]
     284                 :            : {
     285                 :            : 
     286         [ +  + ]:       1936 :     if (bColInfo)
     287                 :            :     {
     288         [ +  - ]:       1040 :         pColWidth  = new sal_uInt16[ MAXCOL+1 ];
     289         [ +  - ]:       1040 :         pColFlags  = new sal_uInt8[ MAXCOL+1 ];
     290                 :            : 
     291         [ +  + ]:    1066000 :         for (SCCOL i=0; i<=MAXCOL; i++)
     292                 :            :         {
     293                 :    1064960 :             pColWidth[i] = STD_COL_WIDTH;
     294                 :    1064960 :             pColFlags[i] = 0;
     295                 :            :         }
     296                 :            :     }
     297                 :            : 
     298         [ +  + ]:       1936 :     if (bRowInfo)
     299                 :            :     {
     300 [ +  - ][ +  - ]:       1050 :         mpRowHeights.reset(new ScFlatUInt16RowSegments(ScGlobal::nStdRowHeight));
                 [ +  - ]
     301 [ +  - ][ +  - ]:       1050 :         pRowFlags  = new ScBitMaskCompressedArray< SCROW, sal_uInt8>( MAXROW, 0);
     302                 :            :     }
     303                 :            : 
     304 [ +  - ][ +  + ]:       1936 :     if ( pDocument->IsDocVisible() )
     305                 :            :     {
     306                 :            :         //  when a sheet is added to a visible document,
     307                 :            :         //  initialize its RTL flag from the system locale
     308         [ +  - ]:         44 :         bLayoutRTL = ScGlobal::IsSystemRTL();
     309                 :            :     }
     310                 :            : 
     311         [ +  - ]:       1936 :     ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer();
     312         [ +  + ]:       1936 :     if (pDrawLayer)
     313                 :            :     {
     314 [ +  - ][ +  - ]:        197 :         if ( pDrawLayer->ScAddPage( nTab ) )    // sal_False (not inserted) during Undo
     315                 :            :         {
     316 [ +  - ][ +  - ]:        197 :             pDrawLayer->ScRenamePage( nTab, aName );
                 [ +  - ]
     317                 :        197 :             sal_uLong nx = (sal_uLong) ((double) (MAXCOL+1) * STD_COL_WIDTH           * HMM_PER_TWIPS );
     318                 :        197 :             sal_uLong ny = (sal_uLong) ((double) (MAXROW+1) * ScGlobal::nStdRowHeight * HMM_PER_TWIPS );
     319         [ +  - ]:        197 :             pDrawLayer->SetPageSize( static_cast<sal_uInt16>(nTab), Size( nx, ny ), false );
     320                 :            :         }
     321                 :            :     }
     322                 :            : 
     323         [ +  + ]:    1984400 :     for (SCCOL k=0; k<=MAXCOL; k++)
     324         [ +  - ]:    1982464 :         aCol[k].Init( k, nTab, pDocument );
     325   [ #  #  #  # ]:       1936 : }
     326                 :            : 
     327 [ +  - ][ +  - ]:    1791396 : ScTable::~ScTable()
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     328                 :            : {
     329         [ +  + ]:       1746 :     if (!pDocument->IsInDtorClear())
     330                 :            :     {
     331                 :            :         //  nicht im dtor die Pages in der falschen Reihenfolge loeschen
     332                 :            :         //  (nTab stimmt dann als Page-Number nicht!)
     333                 :            :         //  In ScDocument::Clear wird hinterher per Clear am Draw Layer alles geloescht.
     334                 :            : 
     335         [ +  - ]:        115 :         ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer();
     336         [ +  + ]:        115 :         if (pDrawLayer)
     337         [ +  - ]:         28 :             pDrawLayer->ScRemovePage( nTab );
     338                 :            :     }
     339                 :            : 
     340         [ +  + ]:       1746 :     delete[] pColWidth;
     341         [ +  + ]:       1746 :     delete[] pColFlags;
     342 [ +  + ][ +  - ]:       1746 :     delete pRowFlags;
     343 [ -  + ][ #  # ]:       1746 :     delete pSheetEvents;
     344 [ +  + ][ +  - ]:       1746 :     delete pOutlineTable;
     345 [ -  + ][ #  # ]:       1746 :     delete pSearchText;
     346                 :       1746 :     delete pRepeatColRange;
     347                 :       1746 :     delete pRepeatRowRange;
     348 [ #  # ][ -  + ]:       1746 :     delete pScenarioRanges;
     349 [ +  + ][ +  - ]:       1746 :     delete mpRangeName;
     350 [ +  + ][ +  - ]:       1746 :     delete pDBDataNoName;
     351         [ +  - ]:       1746 :     DestroySortCollator();
     352         [ +  + ]:    1791396 : }
           [ #  #  #  # ]
                 [ +  - ]
     353                 :            : 
     354                 :      29768 : void ScTable::GetName( rtl::OUString& rName ) const
     355                 :            : {
     356                 :      29768 :     rName = aName;
     357                 :      29768 : }
     358                 :            : 
     359                 :        289 : void ScTable::SetName( const rtl::OUString& rNewName )
     360                 :            : {
     361                 :        289 :     aName = rNewName;
     362                 :        289 :     aUpperName = rtl::OUString(); // invalidated if the name is changed
     363                 :            : 
     364                 :            :     // SetStreamValid is handled in ScDocument::RenameTab
     365                 :        289 : }
     366                 :            : 
     367                 :       5827 : const rtl::OUString& ScTable::GetUpperName() const
     368                 :            : {
     369 [ +  + ][ +  - ]:       5827 :     if (aUpperName.isEmpty() && !aName.isEmpty())
                 [ +  + ]
     370                 :        474 :         aUpperName = ScGlobal::pCharClass->uppercase(aName);
     371                 :       5827 :     return aUpperName;
     372                 :            : }
     373                 :            : 
     374                 :         48 : void ScTable::SetVisible( bool bVis )
     375                 :            : {
     376 [ +  + ][ -  + ]:         48 :     if (bVisible != bVis && IsStreamValid())
                 [ -  + ]
     377                 :          0 :         SetStreamValid(false);
     378                 :            : 
     379                 :         48 :     bVisible = bVis;
     380                 :         48 : }
     381                 :            : 
     382                 :        352 : void ScTable::SetStreamValid( bool bSet, bool bIgnoreLock )
     383                 :            : {
     384 [ +  + ][ +  - ]:        352 :     if ( bIgnoreLock || !pDocument->IsStreamValidLocked() )
                 [ +  - ]
     385                 :        352 :         bStreamValid = bSet;
     386                 :        352 : }
     387                 :            : 
     388                 :         14 : void ScTable::SetPendingRowHeights( bool bSet )
     389                 :            : {
     390                 :         14 :     bPendingRowHeights = bSet;
     391                 :         14 : }
     392                 :            : 
     393                 :        243 : void ScTable::SetLayoutRTL( bool bSet )
     394                 :            : {
     395                 :        243 :     bLayoutRTL = bSet;
     396                 :        243 : }
     397                 :            : 
     398                 :         12 : void ScTable::SetLoadingRTL( bool bSet )
     399                 :            : {
     400                 :         12 :     bLoadingRTL = bSet;
     401                 :         12 : }
     402                 :            : 
     403                 :       1599 : const Color& ScTable::GetTabBgColor() const
     404                 :            : {
     405                 :       1599 :     return aTabBgColor;
     406                 :            : }
     407                 :            : 
     408                 :         35 : void ScTable::SetTabBgColor(const Color& rColor)
     409                 :            : {
     410         [ +  + ]:         35 :     if (aTabBgColor != rColor)
     411                 :            :     {
     412                 :            :         // The tab color has changed.  Set this table 'modified'.
     413                 :          3 :         aTabBgColor = rColor;
     414         [ -  + ]:          3 :         if (IsStreamValid())
     415                 :          0 :             SetStreamValid(false);
     416                 :            :     }
     417                 :         35 : }
     418                 :            : 
     419                 :          1 : void ScTable::SetScenario( bool bFlag )
     420                 :            : {
     421                 :          1 :     bScenario = bFlag;
     422                 :          1 : }
     423                 :            : 
     424                 :          6 : void ScTable::SetLink( sal_uInt8 nMode,
     425                 :            :                         const String& rDoc, const String& rFlt, const String& rOpt,
     426                 :            :                         const String& rTab, sal_uLong nRefreshDelay )
     427                 :            : {
     428                 :          6 :     nLinkMode = nMode;
     429                 :          6 :     aLinkDoc = rDoc;        // Datei
     430                 :          6 :     aLinkFlt = rFlt;        // Filter
     431                 :          6 :     aLinkOpt = rOpt;        // Filter-Optionen
     432                 :          6 :     aLinkTab = rTab;        // Tabellenname in Quelldatei
     433                 :          6 :     nLinkRefreshDelay = nRefreshDelay;  // refresh delay in seconds, 0==off
     434                 :            : 
     435         [ -  + ]:          6 :     if (IsStreamValid())
     436                 :          0 :         SetStreamValid(false);
     437                 :          6 : }
     438                 :            : 
     439                 :        214 : sal_uInt16 ScTable::GetOptimalColWidth( SCCOL nCol, OutputDevice* pDev,
     440                 :            :                                     double nPPTX, double nPPTY,
     441                 :            :                                     const Fraction& rZoomX, const Fraction& rZoomY,
     442                 :            :                                     bool bFormula, const ScMarkData* pMarkData,
     443                 :            :                                     const ScColWidthParam* pParam )
     444                 :            : {
     445                 :        214 :     return aCol[nCol].GetOptimalColWidth( pDev, nPPTX, nPPTY, rZoomX, rZoomY,
     446                 :        214 :         bFormula, STD_COL_WIDTH - STD_EXTRA_WIDTH, pMarkData, pParam );
     447                 :            : }
     448                 :            : 
     449                 :       7747 : long ScTable::GetNeededSize( SCCOL nCol, SCROW nRow,
     450                 :            :                                 OutputDevice* pDev,
     451                 :            :                                 double nPPTX, double nPPTY,
     452                 :            :                                 const Fraction& rZoomX, const Fraction& rZoomY,
     453                 :            :                                 bool bWidth, bool bTotalSize )
     454                 :            : {
     455                 :       7747 :     ScNeededSizeOptions aOptions;
     456                 :       7747 :     aOptions.bSkipMerged = false;       // zusammengefasste mitzaehlen
     457                 :       7747 :     aOptions.bTotalSize  = bTotalSize;
     458                 :            : 
     459                 :       7747 :     return aCol[nCol].GetNeededSize
     460         [ +  - ]:       7747 :         ( nRow, pDev, nPPTX, nPPTY, rZoomX, rZoomY, bWidth, aOptions );
     461                 :            : }
     462                 :            : 
     463                 :       4111 : bool ScTable::SetOptimalHeight( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nExtra,
     464                 :            :                                 OutputDevice* pDev,
     465                 :            :                                 double nPPTX, double nPPTY,
     466                 :            :                                 const Fraction& rZoomX, const Fraction& rZoomY,
     467                 :            :                                 bool bForce, ScProgress* pOuterProgress, sal_uLong nProgressStart )
     468                 :            : {
     469                 :            :     OSL_ENSURE( nExtra==0 || bForce, "autom. OptimalHeight mit Extra" );
     470                 :            : 
     471         [ +  + ]:       4111 :     if ( !pDocument->IsAdjustHeightEnabled() )
     472                 :            :     {
     473                 :       2311 :         return false;
     474                 :            :     }
     475                 :            : 
     476                 :       1800 :     SCSIZE  nCount = static_cast<SCSIZE>(nEndRow-nStartRow+1);
     477                 :            : 
     478 [ +  - ][ +  - ]:       1800 :     ScProgress* pProgress = GetProgressBar(nCount, GetWeightedCount(), pOuterProgress, pDocument);
     479                 :            : 
     480         [ +  - ]:       1800 :     vector<sal_uInt16> aHeights(nCount, 0);
     481                 :            : 
     482                 :            :     GetOptimalHeightsInColumn(
     483                 :            :         aCol, nStartRow, nEndRow, aHeights, pDev, nPPTX, nPPTY, rZoomX, rZoomY, bForce,
     484         [ +  - ]:       1800 :         pProgress, nProgressStart);
     485                 :            : 
     486                 :       1800 :     SetRowHeightRangeFunc aFunc(this, nPPTX, nPPTY);
     487                 :            :     bool bChanged = SetOptimalHeightsToRows(
     488         [ +  - ]:       1800 :         aFunc, this, pRowFlags, nStartRow, nEndRow, nExtra, aHeights, bForce);
     489                 :            : 
     490         [ +  + ]:       1800 :     if ( pProgress != pOuterProgress )
     491 [ +  + ][ +  - ]:         27 :         delete pProgress;
     492                 :            : 
     493                 :       4111 :     return bChanged;
     494                 :            : }
     495                 :            : 
     496                 :          0 : void ScTable::SetOptimalHeightOnly( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nExtra,
     497                 :            :                                 OutputDevice* pDev,
     498                 :            :                                 double nPPTX, double nPPTY,
     499                 :            :                                 const Fraction& rZoomX, const Fraction& rZoomY,
     500                 :            :                                 bool bForce, ScProgress* pOuterProgress, sal_uLong nProgressStart )
     501                 :            : {
     502                 :            :     OSL_ENSURE( nExtra==0 || bForce, "autom. OptimalHeight mit Extra" );
     503                 :            : 
     504         [ #  # ]:          0 :     if ( !pDocument->IsAdjustHeightEnabled() )
     505                 :          0 :         return;
     506                 :            : 
     507                 :          0 :     SCSIZE  nCount = static_cast<SCSIZE>(nEndRow-nStartRow+1);
     508                 :            : 
     509 [ #  # ][ #  # ]:          0 :     ScProgress* pProgress = GetProgressBar(nCount, GetWeightedCount(), pOuterProgress, pDocument);
     510                 :            : 
     511         [ #  # ]:          0 :     vector<sal_uInt16> aHeights(nCount, 0);
     512                 :            : 
     513                 :            :     GetOptimalHeightsInColumn(
     514                 :            :         aCol, nStartRow, nEndRow, aHeights, pDev, nPPTX, nPPTY, rZoomX, rZoomY, bForce,
     515         [ #  # ]:          0 :         pProgress, nProgressStart);
     516                 :            : 
     517                 :          0 :     SetRowHeightOnlyFunc aFunc(this);
     518                 :            :     SetOptimalHeightsToRows(
     519         [ #  # ]:          0 :         aFunc, this, pRowFlags, nStartRow, nEndRow, nExtra, aHeights, bForce);
     520                 :            : 
     521         [ #  # ]:          0 :     if ( pProgress != pOuterProgress )
     522 [ #  # ][ #  # ]:          0 :         delete pProgress;
     523                 :            : }
     524                 :            : 
     525                 :         40 : bool ScTable::GetCellArea( SCCOL& rEndCol, SCROW& rEndRow ) const
     526                 :            : {
     527                 :         40 :     bool bFound = false;
     528                 :         40 :     SCCOL nMaxX = 0;
     529                 :         40 :     SCROW nMaxY = 0;
     530         [ +  + ]:      41000 :     for (SCCOL i=0; i<=MAXCOL; i++)
     531         [ +  + ]:      40960 :         if (!aCol[i].IsEmptyVisData())
     532                 :            :         {
     533                 :        272 :             bFound = true;
     534                 :        272 :             nMaxX = i;
     535                 :        272 :             SCROW nColY = aCol[i].GetLastVisDataPos();
     536         [ +  + ]:        272 :             if (nColY > nMaxY)
     537                 :         34 :                 nMaxY = nColY;
     538                 :            :         }
     539                 :            : 
     540 [ +  - ][ #  # ]:         40 :     for (ScNotes::const_iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr)
         [ +  - ][ +  - ]
                 [ -  + ]
     541                 :            :     {
     542         [ #  # ]:          0 :         SCCOL nCol = itr->first.first;
     543         [ #  # ]:          0 :         SCROW nRow = itr->first.second;
     544                 :            : 
     545         [ #  # ]:          0 :         if (nMaxX < nCol)
     546                 :          0 :             nMaxX = nCol;
     547         [ #  # ]:          0 :         if (nMaxY < nRow)
     548                 :          0 :             nMaxY = nRow;
     549                 :            :     }
     550                 :            : 
     551                 :         40 :     rEndCol = nMaxX;
     552                 :         40 :     rEndRow = nMaxY;
     553                 :         40 :     return bFound;
     554                 :            : }
     555                 :            : 
     556                 :       2308 : bool ScTable::GetTableArea( SCCOL& rEndCol, SCROW& rEndRow ) const
     557                 :            : {
     558                 :       2308 :     bool bRet = true;               //! merken?
     559         [ +  + ]:       2308 :     if (!bTableAreaValid)
     560                 :            :     {
     561                 :        308 :         bRet = GetPrintArea(nTableAreaX, nTableAreaY, true);
     562                 :        308 :         bTableAreaValid = true;
     563                 :            :     }
     564                 :       2308 :     rEndCol = nTableAreaX;
     565                 :       2308 :     rEndRow = nTableAreaY;
     566                 :       2308 :     return bRet;
     567                 :            : }
     568                 :            : 
     569                 :            : const SCCOL SC_COLUMNS_STOP = 30;
     570                 :            : 
     571                 :       1302 : bool ScTable::GetPrintArea( SCCOL& rEndCol, SCROW& rEndRow, bool bNotes, bool bFullFormattedArea ) const
     572                 :            : {
     573                 :       1302 :     bool bFound = false;
     574                 :       1302 :     SCCOL nMaxX = 0;
     575                 :       1302 :     SCROW nMaxY = 0;
     576                 :            :     SCCOL i;
     577                 :            : 
     578         [ +  + ]:    1334550 :     for (i=0; i<=MAXCOL; i++)               // Daten testen
     579         [ +  + ]:    1333248 :         if (!aCol[i].IsEmptyVisData())
     580                 :            :         {
     581                 :        888 :             bFound = true;
     582         [ +  + ]:        888 :             if (i>nMaxX)
     583                 :        562 :                 nMaxX = i;
     584                 :        888 :             SCROW nColY = aCol[i].GetLastVisDataPos();
     585         [ +  + ]:        888 :             if (nColY > nMaxY)
     586                 :        175 :                 nMaxY = nColY;
     587                 :            :         }
     588                 :            : 
     589         [ +  + ]:       1302 :     if (bNotes)
     590                 :            :     {
     591 [ +  - ][ #  # ]:       1178 :         for (ScNotes::const_iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr)
         [ +  - ][ +  - ]
                 [ -  + ]
     592                 :            :         {
     593         [ #  # ]:          0 :             SCCOL nCol = itr->first.first;
     594         [ #  # ]:          0 :             SCROW nRow = itr->first.second;
     595                 :            : 
     596         [ #  # ]:          0 :             if (nMaxX < nCol)
     597                 :          0 :                 nMaxX = nCol;
     598         [ #  # ]:          0 :             if (nMaxY < nRow)
     599                 :          0 :                 nMaxY = nRow;
     600                 :            :         }
     601                 :            :     }
     602                 :            : 
     603                 :       1302 :     SCCOL nMaxDataX = nMaxX;
     604                 :            : 
     605         [ +  + ]:    1334550 :     for (i=0; i<=MAXCOL; i++)               // Attribute testen
     606                 :            :     {
     607                 :            :         SCROW nLastRow;
     608 [ +  - ][ +  + ]:    1333248 :         if (aCol[i].GetLastVisibleAttr( nLastRow, bFullFormattedArea ))
     609                 :            :         {
     610                 :         40 :             bFound = true;
     611                 :         40 :             nMaxX = i;
     612         [ -  + ]:         40 :             if (nLastRow > nMaxY)
     613                 :          0 :                 nMaxY = nLastRow;
     614                 :            :         }
     615                 :            :     }
     616                 :            : 
     617         [ -  + ]:       1302 :     if (nMaxX == MAXCOL)                    // Attribute rechts weglassen
     618                 :            :     {
     619                 :          0 :         --nMaxX;
     620 [ #  # ][ #  # ]:          0 :         while ( nMaxX>0 && aCol[nMaxX].IsVisibleAttrEqual(aCol[nMaxX+1]) )
                 [ #  # ]
     621                 :          0 :             --nMaxX;
     622                 :            :     }
     623                 :            : 
     624         [ +  + ]:       1302 :     if ( nMaxX < nMaxDataX )
     625                 :            :     {
     626                 :         40 :         nMaxX = nMaxDataX;
     627                 :            :     }
     628         [ -  + ]:       1262 :     else if ( nMaxX > nMaxDataX )
     629                 :            :     {
     630                 :          0 :         SCCOL nAttrStartX = nMaxDataX + 1;
     631         [ #  # ]:          0 :         while ( nAttrStartX < MAXCOL )
     632                 :            :         {
     633                 :          0 :             SCCOL nAttrEndX = nAttrStartX;
     634 [ #  # ][ #  # ]:          0 :             while ( nAttrEndX < MAXCOL && aCol[nAttrStartX].IsVisibleAttrEqual(aCol[nAttrEndX+1]) )
                 [ #  # ]
     635                 :          0 :                 ++nAttrEndX;
     636         [ #  # ]:          0 :             if ( nAttrEndX + 1 - nAttrStartX >= SC_COLUMNS_STOP )
     637                 :            :             {
     638                 :            :                 // found equally-formatted columns behind data -> stop before these columns
     639                 :          0 :                 nMaxX = nAttrStartX - 1;
     640                 :            : 
     641                 :            :                 // also don't include default-formatted columns before that
     642                 :            :                 SCROW nDummyRow;
     643 [ #  # ][ #  # ]:          0 :                 while ( nMaxX > nMaxDataX && !aCol[nMaxX].GetLastVisibleAttr( nDummyRow ) )
         [ #  # ][ #  # ]
     644                 :          0 :                     --nMaxX;
     645                 :            :                 break;
     646                 :            :             }
     647                 :          0 :             nAttrStartX = nAttrEndX + 1;
     648                 :            :         }
     649                 :            :     }
     650                 :            : 
     651                 :       1302 :     rEndCol = nMaxX;
     652                 :       1302 :     rEndRow = nMaxY;
     653                 :       1302 :     return bFound;
     654                 :            : }
     655                 :            : 
     656                 :          0 : bool ScTable::GetPrintAreaHor( SCROW nStartRow, SCROW nEndRow,
     657                 :            :                                 SCCOL& rEndCol, bool /* bNotes */ ) const
     658                 :            : {
     659                 :          0 :     bool bFound = false;
     660                 :          0 :     SCCOL nMaxX = 0;
     661                 :            :     SCCOL i;
     662                 :            : 
     663         [ #  # ]:          0 :     for (i=0; i<=MAXCOL; i++)               // Attribute testen
     664                 :            :     {
     665         [ #  # ]:          0 :         if (aCol[i].HasVisibleAttrIn( nStartRow, nEndRow ))
     666                 :            :         {
     667                 :          0 :             bFound = true;
     668                 :          0 :             nMaxX = i;
     669                 :            :         }
     670                 :            :     }
     671                 :            : 
     672         [ #  # ]:          0 :     if (nMaxX == MAXCOL)                    // Attribute rechts weglassen
     673                 :            :     {
     674                 :          0 :         --nMaxX;
     675 [ #  # ][ #  # ]:          0 :         while ( nMaxX>0 && aCol[nMaxX].IsVisibleAttrEqual(aCol[nMaxX+1], nStartRow, nEndRow) )
                 [ #  # ]
     676                 :          0 :             --nMaxX;
     677                 :            :     }
     678                 :            : 
     679         [ #  # ]:          0 :     for (i=0; i<=MAXCOL; i++)               // Daten testen
     680                 :            :     {
     681         [ #  # ]:          0 :         if (!aCol[i].IsEmptyBlock( nStartRow, nEndRow ))        //! bNotes ??????
     682                 :            :         {
     683                 :          0 :             bFound = true;
     684         [ #  # ]:          0 :             if (i>nMaxX)
     685                 :          0 :                 nMaxX = i;
     686                 :            :         }
     687                 :            :     }
     688                 :            : 
     689                 :          0 :     rEndCol = nMaxX;
     690                 :          0 :     return bFound;
     691                 :            : }
     692                 :            : 
     693                 :         96 : bool ScTable::GetPrintAreaVer( SCCOL nStartCol, SCCOL nEndCol,
     694                 :            :                                 SCROW& rEndRow, bool bNotes ) const
     695                 :            : {
     696                 :         96 :     bool bFound = false;
     697                 :         96 :     SCROW nMaxY = 0;
     698                 :            :     SCCOL i;
     699                 :            : 
     700         [ +  + ]:        828 :     for (i=nStartCol; i<=nEndCol; i++)              // Attribute testen
     701                 :            :     {
     702                 :            :         SCROW nLastRow;
     703 [ +  - ][ -  + ]:        732 :         if (aCol[i].GetLastVisibleAttr( nLastRow ))
     704                 :            :         {
     705                 :          0 :             bFound = true;
     706         [ #  # ]:          0 :             if (nLastRow > nMaxY)
     707                 :          0 :                 nMaxY = nLastRow;
     708                 :            :         }
     709                 :            :     }
     710                 :            : 
     711         [ +  + ]:        828 :     for (i=nStartCol; i<=nEndCol; i++)              // Daten testen
     712         [ +  + ]:        732 :         if (!aCol[i].IsEmptyVisData())
     713                 :            :         {
     714                 :        160 :             bFound = true;
     715                 :        160 :             SCROW nColY = aCol[i].GetLastVisDataPos();
     716         [ +  + ]:        160 :             if (nColY > nMaxY)
     717                 :         44 :                 nMaxY = nColY;
     718                 :            :         }
     719                 :            : 
     720         [ -  + ]:         96 :     if (bNotes)
     721                 :            :     {
     722 [ #  # ][ #  # ]:          0 :         for (ScNotes::const_iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr)
         [ #  # ][ #  # ]
                 [ #  # ]
     723                 :            :         {
     724         [ #  # ]:          0 :             SCCOL nCol = itr->first.first;
     725         [ #  # ]:          0 :             SCROW nRow = itr->first.second;
     726                 :            : 
     727 [ #  # ][ #  # ]:          0 :             if (nStartCol > nCol || nEndCol < nCol)
     728                 :          0 :                 continue;
     729                 :            : 
     730         [ #  # ]:          0 :             if (nMaxY < nRow)
     731                 :          0 :                 nMaxY = nRow;
     732                 :            :         }
     733                 :            :     }
     734                 :            : 
     735                 :         96 :     rEndRow = nMaxY;
     736                 :         96 :     return bFound;
     737                 :            : }
     738                 :            : 
     739                 :        873 : bool ScTable::GetDataStart( SCCOL& rStartCol, SCROW& rStartRow ) const
     740                 :            : {
     741                 :        873 :     bool bFound = false;
     742                 :        873 :     SCCOL nMinX = MAXCOL;
     743                 :        873 :     SCROW nMinY = MAXROW;
     744                 :            :     SCCOL i;
     745                 :            : 
     746         [ +  + ]:     894825 :     for (i=0; i<=MAXCOL; i++)                   // Attribute testen
     747                 :            :     {
     748                 :            :         SCROW nFirstRow;
     749 [ +  - ][ +  + ]:     893952 :         if (aCol[i].GetFirstVisibleAttr( nFirstRow ))
     750                 :            :         {
     751         [ +  + ]:         90 :             if (!bFound)
     752                 :         12 :                 nMinX = i;
     753                 :         90 :             bFound = true;
     754         [ +  + ]:         90 :             if (nFirstRow < nMinY)
     755                 :         24 :                 nMinY = nFirstRow;
     756                 :            :         }
     757                 :            :     }
     758                 :            : 
     759         [ +  + ]:        873 :     if (nMinX == 0)                                     // Attribute links weglassen
     760                 :            :     {
     761         [ -  + ]:         12 :         if ( aCol[0].IsVisibleAttrEqual(aCol[1]) )      // keine einzelnen
     762                 :            :         {
     763                 :          0 :             ++nMinX;
     764 [ #  # ][ #  # ]:          0 :             while ( nMinX<MAXCOL && aCol[nMinX].IsVisibleAttrEqual(aCol[nMinX-1]) )
                 [ #  # ]
     765                 :          0 :                 ++nMinX;
     766                 :            :         }
     767                 :            :     }
     768                 :            : 
     769                 :        873 :     bool bDatFound = false;
     770         [ +  + ]:     894825 :     for (i=0; i<=MAXCOL; i++)                   // Daten testen
     771         [ +  + ]:     893952 :         if (!aCol[i].IsEmptyVisData())
     772                 :            :         {
     773 [ +  + ][ +  + ]:        331 :             if (!bDatFound && i<nMinX)
     774                 :        161 :                 nMinX = i;
     775                 :        331 :             bFound = bDatFound = true;
     776                 :        331 :             SCROW nColY = aCol[i].GetFirstVisDataPos();
     777         [ +  + ]:        331 :             if (nColY < nMinY)
     778                 :        179 :                 nMinY = nColY;
     779                 :            :         }
     780                 :            : 
     781 [ +  - ][ #  # ]:        873 :     for (ScNotes::const_iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr)
         [ +  - ][ +  - ]
                 [ -  + ]
     782                 :            :     {
     783                 :          0 :         bFound = bDatFound = true;
     784         [ #  # ]:          0 :         SCCOL nCol = itr->first.first;
     785         [ #  # ]:          0 :         SCROW nRow = itr->first.second;
     786                 :            : 
     787         [ #  # ]:          0 :         if (nMinX > nCol)
     788                 :          0 :             nMinX = nCol;
     789         [ #  # ]:          0 :         if (nMinY > nRow)
     790                 :          0 :             nMinY = nRow;
     791                 :            :     }
     792                 :            : 
     793                 :        873 :     rStartCol = nMinX;
     794                 :        873 :     rStartRow = nMinY;
     795                 :        873 :     return bFound;
     796                 :            : }
     797                 :            : 
     798                 :         34 : void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow,
     799                 :            :                            bool bIncludeOld, bool bOnlyDown ) const
     800                 :            : {
     801                 :            :     // return the smallest area containing at least all contiguous cells having data. This area
     802                 :            :     // is a square containing also empty cells. It may shrink or extend the area given as input
     803                 :            :     // Flags as modifiers:
     804                 :            :     //
     805                 :            :     //     bIncludeOld = true ensure that the returned area contains at least the initial area,
     806                 :            :     //                   independently of the emptniess of rows / columns (i.e. does not allow shrinking)
     807                 :            :     //     bOnlyDown = true means extend / shrink the inputed area only down, i.e modifiy only rEndRow
     808                 :            : 
     809                 :         34 :     bool bLeft = false;
     810                 :         34 :     bool bRight  = false;
     811                 :         34 :     bool bTop = false;
     812                 :         34 :     bool bBottom = false;
     813                 :         34 :     bool bChanged = false;
     814                 :            : 
     815         [ +  + ]:        177 :     do
     816                 :            :     {
     817                 :        177 :         bChanged = false;
     818                 :            : 
     819         [ +  - ]:        177 :         if (!bOnlyDown)
     820                 :            :         {
     821                 :        177 :             SCROW nStart = rStartRow;
     822                 :        177 :             SCROW nEnd = rEndRow;
     823         [ -  + ]:        177 :             if (nStart>0) --nStart;
     824         [ +  - ]:        177 :             if (nEnd<MAXROW) ++nEnd;
     825                 :            : 
     826         [ +  - ]:        177 :             if (rEndCol < MAXCOL)
     827         [ +  + ]:        177 :                 if (!aCol[rEndCol+1].IsEmptyBlock(nStart,nEnd))
     828                 :            :                 {
     829                 :        100 :                     ++rEndCol;
     830                 :        100 :                     bChanged = true;
     831                 :        100 :                     bRight = true;
     832                 :            :                 }
     833                 :            : 
     834         [ -  + ]:        177 :             if (rStartCol > 0)
     835         [ #  # ]:          0 :                 if (!aCol[rStartCol-1].IsEmptyBlock(nStart,nEnd))
     836                 :            :                 {
     837                 :          0 :                     --rStartCol;
     838                 :          0 :                     bChanged = true;
     839                 :          0 :                     bLeft = true;
     840                 :            :                 }
     841                 :            : 
     842         [ -  + ]:        177 :             if (rStartRow > 0)
     843                 :            :             {
     844                 :          0 :                 SCROW nTest = rStartRow-1;
     845                 :          0 :                 bool needExtend = false;
     846 [ #  # ][ #  # ]:          0 :                 for ( SCCOL i = rStartCol; i<=rEndCol && !needExtend; i++)
                 [ #  # ]
     847         [ #  # ]:          0 :                     if (aCol[i].HasDataAt(nTest))
     848                 :          0 :                         needExtend = true;
     849         [ #  # ]:          0 :                 if (needExtend)
     850                 :            :                 {
     851                 :          0 :                     --rStartRow;
     852                 :          0 :                     bChanged = true;
     853                 :          0 :                     bTop = true;
     854                 :            :                 }
     855                 :            :             }
     856                 :            :         }
     857                 :            : 
     858         [ +  - ]:        177 :         if (rEndRow < MAXROW)
     859                 :            :         {
     860                 :        177 :             SCROW nTest = rEndRow+1;
     861                 :        177 :             bool needExtend = false;
     862 [ +  + ][ +  + ]:        601 :             for ( SCCOL i = rStartCol; i<=rEndCol && !needExtend; i++)
                 [ +  + ]
     863         [ +  + ]:        424 :                 if (aCol[i].HasDataAt(nTest))
     864                 :         98 :                     needExtend = true;
     865         [ +  + ]:        177 :             if (needExtend)
     866                 :            :             {
     867                 :         98 :                 ++rEndRow;
     868                 :         98 :                 bChanged = true;
     869                 :         98 :                 bBottom = true;
     870                 :            :             }
     871                 :            :         }
     872                 :            :     }
     873                 :            :     while( bChanged );
     874                 :            : 
     875 [ +  + ][ +  - ]:         34 :     if ( !bIncludeOld && !bOnlyDown )
     876                 :            :     {
     877         [ +  - ]:         18 :         if ( !bLeft )
     878 [ -  + ][ #  # ]:         18 :             while ( aCol[rStartCol].IsEmptyBlock(rStartRow,rEndRow) && rStartCol < MAXCOL && rStartCol < rEndCol)
         [ #  # ][ -  + ]
     879                 :          0 :                 ++rStartCol;
     880                 :            : 
     881         [ +  + ]:         18 :         if ( !bRight )
     882 [ +  + ][ +  - ]:          4 :             while ( aCol[rEndCol].IsEmptyBlock(rStartRow,rEndRow) && rEndCol > 0 && rStartCol < rEndCol)
         [ +  - ][ +  + ]
     883                 :          2 :                 --rEndCol;
     884                 :            : 
     885 [ +  - ][ +  - ]:         18 :         if ( !bTop && rStartRow < MAXROW && rStartRow < rEndRow )
                 [ +  - ]
     886                 :            :         {
     887                 :         18 :             bool shrink = true;
     888 [ -  + ][ #  # ]:         18 :             do
         [ #  # ][ -  + ]
     889                 :            :             {
     890 [ +  - ][ +  + ]:         36 :                 for ( SCCOL i = rStartCol; i<=rEndCol && shrink; i++)
                 [ +  + ]
     891         [ +  - ]:         18 :                     if (aCol[i].HasDataAt(rStartRow))
     892                 :         18 :                         shrink = false;
     893         [ -  + ]:         18 :                 if (shrink)
     894                 :          0 :                     ++rStartRow;
     895                 :            :             }while( shrink && rStartRow < MAXROW && rStartRow < rEndRow);
     896                 :            :         }
     897                 :            :     }
     898                 :            : 
     899         [ +  + ]:         34 :     if ( !bIncludeOld )
     900                 :            :     {
     901 [ +  + ][ +  - ]:         18 :         if ( !bBottom && rEndRow > 0 && rStartRow < rEndRow )
                 [ +  - ]
     902                 :            :         {
     903                 :          2 :             bool shrink = true;
     904 [ +  + ][ +  - ]:          3 :             do
         [ +  - ][ +  + ]
     905                 :            :             {
     906 [ +  + ][ +  - ]:         17 :                 for ( SCCOL i = rStartCol; i<=rEndCol && shrink; i++)
                 [ +  + ]
     907         [ +  + ]:         14 :                     if (aCol[i].HasDataAt(rEndRow))
     908                 :          2 :                         shrink = false;
     909         [ +  + ]:          3 :                 if (shrink)
     910                 :          1 :                     --rEndRow;
     911                 :            :             }while( shrink && rEndRow > 0 && rStartRow < rEndRow );
     912                 :            :         }
     913                 :            :     }
     914                 :         34 : }
     915                 :            : 
     916                 :            : 
     917                 :         18 : bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rStartRow,
     918                 :            :         SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly ) const
     919                 :            : {
     920                 :         18 :     o_bShrunk = false;
     921                 :            : 
     922                 :         18 :     PutInOrder( rStartCol, rEndCol);
     923                 :         18 :     PutInOrder( rStartRow, rEndRow);
     924         [ -  + ]:         18 :     if (rStartCol < 0)
     925                 :          0 :         rStartCol = 0, o_bShrunk = true;
     926         [ -  + ]:         18 :     if (rStartRow < 0)
     927                 :          0 :         rStartRow = 0, o_bShrunk = true;
     928         [ -  + ]:         18 :     if (rEndCol > MAXCOL)
     929                 :          0 :         rEndCol = MAXCOL, o_bShrunk = true;
     930         [ -  + ]:         18 :     if (rEndRow > MAXROW)
     931                 :          0 :         rEndRow = MAXROW, o_bShrunk = true;
     932                 :            : 
     933                 :            :     bool bChanged;
     934         [ +  + ]:         27 :     do
     935                 :            :     {
     936                 :         27 :         bChanged = false;
     937                 :            : 
     938         [ -  + ]:         27 :         while (rStartCol < rEndCol)
     939                 :            :         {
     940         [ #  # ]:          0 :             if (aCol[rEndCol].IsEmptyBlock( rStartRow, rEndRow))
     941                 :            :             {
     942                 :          0 :                 --rEndCol;
     943                 :          0 :                 bChanged = true;
     944                 :            :             }
     945                 :            :             else
     946                 :          0 :                 break;  // while
     947                 :            :         }
     948                 :            : 
     949         [ -  + ]:         27 :         while (rStartCol < rEndCol)
     950                 :            :         {
     951         [ #  # ]:          0 :             if (aCol[rStartCol].IsEmptyBlock( rStartRow, rEndRow))
     952                 :            :             {
     953                 :          0 :                 ++rStartCol;
     954                 :          0 :                 bChanged = true;
     955                 :            :             }
     956                 :            :             else
     957                 :          0 :                 break;  // while
     958                 :            :         }
     959                 :            : 
     960         [ +  - ]:         27 :         if (!bColumnsOnly)
     961                 :            :         {
     962         [ +  - ]:         27 :             if (rStartRow < rEndRow)
     963                 :            :             {
     964                 :         27 :                 bool bFound = false;
     965 [ +  + ][ +  - ]:         54 :                 for (SCCOL i=rStartCol; i<=rEndCol && !bFound; i++)
                 [ +  + ]
     966         [ +  + ]:         27 :                     if (aCol[i].HasDataAt( rStartRow))
     967                 :         18 :                         bFound = true;
     968         [ +  + ]:         27 :                 if (!bFound)
     969                 :            :                 {
     970                 :          9 :                     ++rStartRow;
     971                 :          9 :                     bChanged = true;
     972                 :            :                 }
     973                 :            :             }
     974                 :            : 
     975         [ +  - ]:         27 :             if (rStartRow < rEndRow)
     976                 :            :             {
     977                 :         27 :                 bool bFound = false;
     978 [ +  + ][ +  - ]:         54 :                 for (SCCOL i=rStartCol; i<=rEndCol && !bFound; i++)
                 [ +  + ]
     979         [ +  - ]:         27 :                     if (aCol[i].HasDataAt( rEndRow))
     980                 :         27 :                         bFound = true;
     981         [ -  + ]:         27 :                 if (!bFound)
     982                 :            :                 {
     983                 :          0 :                     --rEndRow;
     984                 :          0 :                     bChanged = true;
     985                 :            :                 }
     986                 :            :             }
     987                 :            :         }
     988                 :            : 
     989         [ +  + ]:         27 :         if (bChanged)
     990                 :          9 :             o_bShrunk = true;
     991                 :            :     } while( bChanged );
     992                 :            : 
     993                 :            :     return rStartCol != rEndCol || (bColumnsOnly ?
     994                 :          0 :             !aCol[rStartCol].IsEmptyBlock( rStartRow, rEndRow) :
     995         [ +  - ]:         18 :             (rStartRow != rEndRow || aCol[rStartCol].HasDataAt( rStartRow)));
           [ -  +  #  # ]
         [ -  + ][ #  # ]
     996                 :            : }
     997                 :            : 
     998                 :            : 
     999                 :       2700 : SCSIZE ScTable::GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow,
    1000                 :            :                                         SCCOL nEndCol, SCROW nEndRow, ScDirection eDir ) const
    1001                 :            : {
    1002                 :       2700 :     SCSIZE nCount = 0;
    1003                 :            :     SCCOL nCol;
    1004 [ +  + ][ -  + ]:       2700 :     if ((eDir == DIR_BOTTOM) || (eDir == DIR_TOP))
    1005                 :            :     {
    1006                 :          6 :         nCount = static_cast<SCSIZE>(nEndRow - nStartRow);
    1007         [ +  + ]:         30 :         for (nCol = nStartCol; nCol <= nEndCol; nCol++)
    1008                 :         24 :             nCount = Min(nCount, aCol[nCol].GetEmptyLinesInBlock(nStartRow, nEndRow, eDir));
    1009                 :            :     }
    1010         [ +  - ]:       2694 :     else if (eDir == DIR_RIGHT)
    1011                 :            :     {
    1012                 :       2694 :         nCol = nEndCol;
    1013   [ +  +  +  + ]:    5458796 :         while (((SCsCOL)nCol >= (SCsCOL)nStartCol) &&
                 [ +  + ]
    1014                 :    2728119 :                  aCol[nCol].IsEmptyBlock(nStartRow, nEndRow))
    1015                 :            :         {
    1016                 :    2727983 :             nCount++;
    1017                 :    2727983 :             nCol--;
    1018                 :            :         }
    1019                 :            :     }
    1020                 :            :     else
    1021                 :            :     {
    1022                 :          0 :         nCol = nStartCol;
    1023 [ #  # ][ #  # ]:          0 :         while ((nCol <= nEndCol) && aCol[nCol].IsEmptyBlock(nStartRow, nEndRow))
                 [ #  # ]
    1024                 :            :         {
    1025                 :          0 :             nCount++;
    1026                 :          0 :             nCol++;
    1027                 :            :         }
    1028                 :            :     }
    1029                 :       2700 :     return nCount;
    1030                 :            : }
    1031                 :            : 
    1032                 :          0 : bool ScTable::IsEmptyLine( SCROW nRow, SCCOL nStartCol, SCCOL nEndCol ) const
    1033                 :            : {
    1034                 :          0 :     bool bFound = false;
    1035 [ #  # ][ #  # ]:          0 :     for (SCCOL i=nStartCol; i<=nEndCol && !bFound; i++)
                 [ #  # ]
    1036         [ #  # ]:          0 :         if (aCol[i].HasDataAt(nRow))
    1037                 :          0 :             bFound = true;
    1038                 :          0 :     return !bFound;
    1039                 :            : }
    1040                 :            : 
    1041                 :          0 : void ScTable::LimitChartArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow ) const
    1042                 :            : {
    1043 [ #  # ][ #  # ]:          0 :     while ( rStartCol<rEndCol && aCol[rStartCol].IsEmptyBlock(rStartRow,rEndRow) )
                 [ #  # ]
    1044                 :          0 :         ++rStartCol;
    1045                 :            : 
    1046 [ #  # ][ #  # ]:          0 :     while ( rStartCol<rEndCol && aCol[rEndCol].IsEmptyBlock(rStartRow,rEndRow) )
                 [ #  # ]
    1047                 :          0 :         --rEndCol;
    1048                 :            : 
    1049 [ #  # ][ #  # ]:          0 :     while ( rStartRow<rEndRow && IsEmptyLine(rStartRow, rStartCol, rEndCol) )
                 [ #  # ]
    1050                 :          0 :         ++rStartRow;
    1051                 :            : 
    1052 [ #  # ][ #  # ]:          0 :     while ( rStartRow<rEndRow && IsEmptyLine(rEndRow, rStartCol, rEndCol) )
                 [ #  # ]
    1053                 :          0 :         --rEndRow;
    1054                 :          0 : }
    1055                 :            : 
    1056                 :         27 : SCCOL ScTable::FindNextVisibleCol( SCCOL nCol, bool bRight ) const
    1057                 :            : {
    1058         [ +  - ]:         27 :     if(bRight)
    1059                 :            :     {
    1060                 :         27 :         nCol++;
    1061                 :         27 :         SCCOL nEnd = 0;
    1062         [ +  - ]:         27 :         bool bHidden = pDocument->ColHidden(nCol, nTab, NULL, &nEnd);
    1063         [ +  + ]:         27 :         if(bHidden)
    1064                 :          6 :             nCol = nEnd +1;
    1065                 :            : 
    1066         [ +  - ]:         27 :         return std::min<SCCOL>(MAXCOL, nCol);
    1067                 :            :     }
    1068                 :            :     else
    1069                 :            :     {
    1070                 :          0 :         nCol--;
    1071                 :          0 :         SCCOL nStart = MAXCOL;
    1072         [ #  # ]:          0 :         bool bHidden = pDocument->ColHidden(nCol, nTab, &nStart, NULL);
    1073         [ #  # ]:          0 :         if(bHidden)
    1074                 :          0 :             nCol = nStart - 1;
    1075                 :            : 
    1076         [ #  # ]:         27 :         return std::max<SCCOL>(0, nCol);
    1077                 :            :     }
    1078                 :            : }
    1079                 :            : 
    1080                 :         12 : SCCOL ScTable::FindNextVisibleColWithContent( SCCOL nCol, bool bRight, SCROW nRow ) const
    1081                 :            : {
    1082         [ +  - ]:         12 :     if(bRight)
    1083                 :            :     {
    1084         [ -  + ]:         12 :         if(nCol == MAXCOL)
    1085                 :          0 :             return MAXCOL;
    1086                 :            : 
    1087         [ +  + ]:       3066 :         do
    1088                 :            :         {
    1089                 :       3066 :             nCol++;
    1090                 :       3066 :             SCCOL nEndCol = 0;
    1091         [ +  - ]:       3066 :             bool bHidden = pDocument->ColHidden( nCol, nTab, NULL, &nEndCol );
    1092         [ +  + ]:       3066 :             if(bHidden)
    1093                 :            :             {
    1094                 :          6 :                 nCol = nEndCol +1;
    1095         [ -  + ]:          6 :                 if(nEndCol >= MAXCOL)
    1096                 :          0 :                     return MAXCOL;
    1097                 :            :             }
    1098                 :            : 
    1099 [ +  - ][ +  + ]:       3066 :             if(aCol[nCol].HasVisibleDataAt(nRow))
    1100                 :          9 :                 return nCol;
    1101                 :            :         }
    1102                 :            :         while(nCol < MAXCOL);
    1103                 :            : 
    1104                 :          3 :         return MAXCOL;
    1105                 :            :     }
    1106                 :            :     else
    1107                 :            :     {
    1108         [ #  # ]:          0 :         if(nCol == 0)
    1109                 :          0 :             return 0;
    1110                 :            : 
    1111         [ #  # ]:          0 :         do
    1112                 :            :         {
    1113                 :          0 :             nCol--;
    1114                 :          0 :             SCCOL nStartCol = MAXCOL;
    1115         [ #  # ]:          0 :             bool bHidden = pDocument->ColHidden( nCol, nTab, &nStartCol, NULL );
    1116         [ #  # ]:          0 :             if(bHidden)
    1117                 :            :             {
    1118                 :          0 :                 nCol = nStartCol -1;
    1119         [ #  # ]:          0 :                 if(nCol <= 0)
    1120                 :          0 :                     return 0;
    1121                 :            :             }
    1122                 :            : 
    1123 [ #  # ][ #  # ]:          0 :             if(aCol[nCol].HasVisibleDataAt(nRow))
    1124                 :          0 :                 return nCol;
    1125                 :            :         }
    1126                 :            :         while(nCol > 0);
    1127                 :            : 
    1128                 :         12 :         return 0;
    1129                 :            :     }
    1130                 :            : }
    1131                 :            : 
    1132                 :         42 : void ScTable::FindAreaPos( SCCOL& rCol, SCROW& rRow, ScMoveDirection eDirection ) const
    1133                 :            : {
    1134 [ +  - ][ +  + ]:         42 :     if (eDirection == SC_MOVE_LEFT || eDirection == SC_MOVE_RIGHT)
    1135                 :            :     {
    1136                 :         21 :         SCCOL nNewCol = rCol;
    1137                 :         21 :         bool bThere = aCol[nNewCol].HasVisibleDataAt(rRow);
    1138                 :         21 :         bool bRight = (eDirection == SC_MOVE_RIGHT);
    1139         [ +  + ]:         21 :         if (bThere)
    1140                 :            :         {
    1141 [ -  + ][ #  # ]:         18 :             if(nNewCol >= MAXCOL && eDirection == SC_MOVE_RIGHT)
    1142                 :          0 :                 return;
    1143 [ -  + ][ #  # ]:         18 :             else if(nNewCol == 0 && eDirection == SC_MOVE_LEFT)
    1144                 :          0 :                 return;
    1145                 :            : 
    1146                 :         18 :             SCCOL nNextCol = FindNextVisibleCol( nNewCol, bRight );
    1147                 :            : 
    1148         [ +  + ]:         18 :             if(aCol[nNextCol].HasVisibleDataAt(rRow))
    1149                 :            :             {
    1150                 :          9 :                 bool bFound = false;
    1151                 :          9 :                 nNewCol = nNextCol;
    1152 [ -  + ][ #  # ]:          9 :                 do
         [ #  # ][ -  + ]
    1153                 :            :                 {
    1154                 :          9 :                     nNextCol = FindNextVisibleCol( nNewCol, bRight );
    1155         [ -  + ]:          9 :                     if(aCol[nNextCol].HasVisibleDataAt(rRow))
    1156                 :          0 :                         nNewCol = nNextCol;
    1157                 :            :                     else
    1158                 :          9 :                         bFound = true;
    1159                 :            :                 }
    1160                 :          9 :                 while(!bFound && nNextCol > 0 && nNextCol < MAXCOL);
    1161                 :            :             }
    1162                 :            :             else
    1163                 :            :             {
    1164                 :          9 :                 nNewCol = FindNextVisibleColWithContent(nNewCol, bRight, rRow);
    1165                 :            :             }
    1166                 :            :         }
    1167                 :            :         else
    1168                 :            :         {
    1169                 :          3 :             nNewCol = FindNextVisibleColWithContent(nNewCol, bRight, rRow);
    1170                 :            :         }
    1171                 :            : 
    1172         [ -  + ]:         21 :         if (nNewCol<0)
    1173                 :          0 :             nNewCol=0;
    1174         [ -  + ]:         21 :         if (nNewCol>MAXCOL)
    1175                 :          0 :             nNewCol=MAXCOL;
    1176                 :         21 :         rCol = nNewCol;
    1177                 :            :     }
    1178                 :            :     else
    1179                 :            :     {
    1180                 :         42 :         aCol[rCol].FindDataAreaPos(rRow,eDirection == SC_MOVE_DOWN);
    1181                 :            :     }
    1182                 :            : }
    1183                 :            : 
    1184                 :          0 : bool ScTable::ValidNextPos( SCCOL nCol, SCROW nRow, const ScMarkData& rMark,
    1185                 :            :                                 bool bMarked, bool bUnprotected ) const
    1186                 :            : {
    1187 [ #  # ][ #  # ]:          0 :     if (!ValidCol(nCol) || !ValidRow(nRow))
                 [ #  # ]
    1188                 :          0 :         return false;
    1189                 :            : 
    1190         [ #  # ]:          0 :     if (pDocument->HasAttrib(nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_OVERLAPPED))
    1191                 :            :         // Skip an overlapped cell.
    1192                 :          0 :         return false;
    1193                 :            : 
    1194 [ #  # ][ #  # ]:          0 :     if (bMarked && !rMark.IsCellMarked(nCol,nRow))
                 [ #  # ]
    1195                 :          0 :         return false;
    1196                 :            : 
    1197   [ #  #  #  # ]:          0 :     if (bUnprotected && ((const ScProtectionAttr*)
                 [ #  # ]
    1198                 :          0 :                         GetAttr(nCol,nRow,ATTR_PROTECTION))->GetProtection())
    1199                 :          0 :         return false;
    1200                 :            : 
    1201 [ #  # ][ #  # ]:          0 :     if (bMarked || bUnprotected)        //! auch sonst ???
    1202                 :            :     {
    1203                 :            :         //  ausgeblendete muessen uebersprungen werden, weil der Cursor sonst
    1204                 :            :         //  auf der naechsten Zelle landet, auch wenn die geschuetzt/nicht markiert ist.
    1205                 :            :         //! per Extra-Parameter steuern, nur fuer Cursor-Bewegung ???
    1206                 :            : 
    1207         [ #  # ]:          0 :         if (RowHidden(nRow))
    1208                 :          0 :             return false;
    1209                 :            : 
    1210         [ #  # ]:          0 :         if (ColHidden(nCol))
    1211                 :          0 :             return false;
    1212                 :            :     }
    1213                 :            : 
    1214                 :          0 :     return true;
    1215                 :            : }
    1216                 :            : 
    1217                 :          2 : void ScTable::GetNextPos( SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY,
    1218                 :            :                                 bool bMarked, bool bUnprotected, const ScMarkData& rMark ) const
    1219                 :            : {
    1220 [ +  - ][ +  - ]:          2 :     if (bUnprotected && !IsProtected())     // Tabelle ueberhaupt geschuetzt?
                 [ +  - ]
    1221                 :          2 :         bUnprotected = false;
    1222                 :            : 
    1223                 :          2 :     sal_uInt16 nWrap = 0;
    1224                 :          2 :     SCsCOL nCol = rCol;
    1225                 :          2 :     SCsROW nRow = rRow;
    1226                 :            : 
    1227                 :          2 :     nCol = sal::static_int_cast<SCsCOL>( nCol + nMovX );
    1228                 :          2 :     nRow = sal::static_int_cast<SCsROW>( nRow + nMovY );
    1229                 :            : 
    1230                 :            :     OSL_ENSURE( !nMovY || !bUnprotected,
    1231                 :            :                 "GetNextPos mit bUnprotected horizontal nicht implementiert" );
    1232                 :            : 
    1233 [ #  # ][ -  + ]:          2 :     if ( nMovY && bMarked )
    1234                 :            :     {
    1235                 :          0 :         bool bUp = ( nMovY < 0 );
    1236                 :          0 :         nRow = rMark.GetNextMarked( nCol, nRow, bUp );
    1237   [ #  #  #  #  :          0 :         while ( VALIDROW(nRow) &&
           #  # ][ #  # ]
    1238                 :          0 :                 (RowHidden(nRow) || pDocument->HasAttrib(nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_OVERLAPPED)) )
    1239                 :            :         {
    1240                 :            :             //  ausgeblendete ueberspringen (s.o.)
    1241                 :          0 :             nRow += nMovY;
    1242                 :          0 :             nRow = rMark.GetNextMarked( nCol, nRow, bUp );
    1243                 :            :         }
    1244                 :            : 
    1245 [ #  # ][ #  # ]:          0 :         while ( nRow < 0 || nRow > MAXROW )
                 [ #  # ]
    1246                 :            :         {
    1247                 :          0 :             nCol = sal::static_int_cast<SCsCOL>( nCol + static_cast<SCsCOL>(nMovY) );
    1248 [ #  # ][ #  # ]:          0 :             while ( VALIDCOL(nCol) && ColHidden(nCol) )
                 [ #  # ]
    1249                 :          0 :                 nCol = sal::static_int_cast<SCsCOL>( nCol + static_cast<SCsCOL>(nMovY) );   //  skip hidden rows (see above)
    1250         [ #  # ]:          0 :             if (nCol < 0)
    1251                 :            :             {
    1252                 :          0 :                 nCol = MAXCOL;
    1253         [ #  # ]:          0 :                 if (++nWrap >= 2)
    1254                 :          0 :                     return;
    1255                 :            :             }
    1256         [ #  # ]:          0 :             else if (nCol > MAXCOL)
    1257                 :            :             {
    1258                 :          0 :                 nCol = 0;
    1259         [ #  # ]:          0 :                 if (++nWrap >= 2)
    1260                 :          0 :                     return;
    1261                 :            :             }
    1262         [ #  # ]:          0 :             if (nRow < 0)
    1263                 :          0 :                 nRow = MAXROW;
    1264         [ #  # ]:          0 :             else if (nRow > MAXROW)
    1265                 :          0 :                 nRow = 0;
    1266                 :          0 :             nRow = rMark.GetNextMarked( nCol, nRow, bUp );
    1267   [ #  #  #  #  :          0 :             while ( VALIDROW(nRow) &&
           #  # ][ #  # ]
    1268                 :          0 :                     (RowHidden(nRow) || pDocument->HasAttrib(nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_OVERLAPPED)) )
    1269                 :            :             {
    1270                 :            :                 //  ausgeblendete ueberspringen (s.o.)
    1271                 :          0 :                 nRow += nMovY;
    1272                 :          0 :                 nRow = rMark.GetNextMarked( nCol, nRow, bUp );
    1273                 :            :             }
    1274                 :            :         }
    1275                 :            :     }
    1276                 :            : 
    1277 [ +  - ][ +  - ]:          2 :     if ( nMovX && ( bMarked || bUnprotected ) )
                 [ -  + ]
    1278                 :            :     {
    1279                 :            :         // initiales Weiterzaehlen wrappen:
    1280         [ #  # ]:          0 :         if (nCol<0)
    1281                 :            :         {
    1282                 :          0 :             nCol = MAXCOL;
    1283                 :          0 :             --nRow;
    1284         [ #  # ]:          0 :             if (nRow<0)
    1285                 :          0 :                 nRow = MAXROW;
    1286                 :            :         }
    1287         [ #  # ]:          0 :         if (nCol>MAXCOL)
    1288                 :            :         {
    1289                 :          0 :             nCol = 0;
    1290                 :          0 :             ++nRow;
    1291         [ #  # ]:          0 :             if (nRow>MAXROW)
    1292                 :          0 :                 nRow = 0;
    1293                 :            :         }
    1294                 :            : 
    1295         [ #  # ]:          0 :         if ( !ValidNextPos(nCol, nRow, rMark, bMarked, bUnprotected) )
    1296                 :            :         {
    1297                 :          0 :             SCsROW* pNextRows = new SCsROW[MAXCOL+1];
    1298                 :            :             SCCOL i;
    1299                 :            : 
    1300         [ #  # ]:          0 :             if ( nMovX > 0 )                            //  vorwaerts
    1301                 :            :             {
    1302         [ #  # ]:          0 :                 for (i=0; i<=MAXCOL; i++)
    1303         [ #  # ]:          0 :                     pNextRows[i] = (i<nCol) ? (nRow+1) : nRow;
    1304         [ #  # ]:          0 :                 do
    1305                 :            :                 {
    1306                 :          0 :                     SCsROW nNextRow = pNextRows[nCol] + 1;
    1307         [ #  # ]:          0 :                     if ( bMarked )
    1308                 :          0 :                         nNextRow = rMark.GetNextMarked( nCol, nNextRow, false );
    1309         [ #  # ]:          0 :                     if ( bUnprotected )
    1310                 :          0 :                         nNextRow = aCol[nCol].GetNextUnprotected( nNextRow, false );
    1311                 :          0 :                     pNextRows[nCol] = nNextRow;
    1312                 :            : 
    1313                 :          0 :                     SCsROW nMinRow = MAXROW+1;
    1314         [ #  # ]:          0 :                     for (i=0; i<=MAXCOL; i++)
    1315         [ #  # ]:          0 :                         if (pNextRows[i] < nMinRow)     // bei gleichen den linken
    1316                 :            :                         {
    1317                 :          0 :                             nMinRow = pNextRows[i];
    1318                 :          0 :                             nCol = i;
    1319                 :            :                         }
    1320                 :          0 :                     nRow = nMinRow;
    1321                 :            : 
    1322         [ #  # ]:          0 :                     if ( nRow > MAXROW )
    1323                 :            :                     {
    1324         [ #  # ]:          0 :                         if (++nWrap >= 2) break;        // ungueltigen Wert behalten
    1325                 :          0 :                         nCol = 0;
    1326                 :          0 :                         nRow = 0;
    1327         [ #  # ]:          0 :                         for (i=0; i<=MAXCOL; i++)
    1328                 :          0 :                             pNextRows[i] = 0;           // alles ganz von vorne
    1329                 :            :                     }
    1330                 :            :                 }
    1331                 :          0 :                 while ( !ValidNextPos(nCol, nRow, rMark, bMarked, bUnprotected) );
    1332                 :            :             }
    1333                 :            :             else                                        //  rueckwaerts
    1334                 :            :             {
    1335         [ #  # ]:          0 :                 for (i=0; i<=MAXCOL; i++)
    1336         [ #  # ]:          0 :                     pNextRows[i] = (i>nCol) ? (nRow-1) : nRow;
    1337         [ #  # ]:          0 :                 do
    1338                 :            :                 {
    1339                 :          0 :                     SCsROW nNextRow = pNextRows[nCol] - 1;
    1340         [ #  # ]:          0 :                     if ( bMarked )
    1341                 :          0 :                         nNextRow = rMark.GetNextMarked( nCol, nNextRow, true );
    1342         [ #  # ]:          0 :                     if ( bUnprotected )
    1343                 :          0 :                         nNextRow = aCol[nCol].GetNextUnprotected( nNextRow, true );
    1344                 :          0 :                     pNextRows[nCol] = nNextRow;
    1345                 :            : 
    1346                 :          0 :                     SCsROW nMaxRow = -1;
    1347         [ #  # ]:          0 :                     for (i=0; i<=MAXCOL; i++)
    1348         [ #  # ]:          0 :                         if (pNextRows[i] >= nMaxRow)    // bei gleichen den rechten
    1349                 :            :                         {
    1350                 :          0 :                             nMaxRow = pNextRows[i];
    1351                 :          0 :                             nCol = i;
    1352                 :            :                         }
    1353                 :          0 :                     nRow = nMaxRow;
    1354                 :            : 
    1355         [ #  # ]:          0 :                     if ( nRow < 0 )
    1356                 :            :                     {
    1357         [ #  # ]:          0 :                         if (++nWrap >= 2) break;        // ungueltigen Wert behalten
    1358                 :          0 :                         nCol = MAXCOL;
    1359                 :          0 :                         nRow = MAXROW;
    1360         [ #  # ]:          0 :                         for (i=0; i<=MAXCOL; i++)
    1361                 :          0 :                             pNextRows[i] = MAXROW;      // alles ganz von vorne
    1362                 :            :                     }
    1363                 :            :                 }
    1364                 :          0 :                 while ( !ValidNextPos(nCol, nRow, rMark, bMarked, bUnprotected) );
    1365                 :            :             }
    1366                 :            : 
    1367         [ #  # ]:          0 :             delete[] pNextRows;
    1368                 :            :         }
    1369                 :            :     }
    1370                 :            : 
    1371                 :            :     //  ungueltige Werte kommen z.b. bei Tab heraus,
    1372                 :            :     //  wenn nicht markiert und nicht geschuetzt ist (linker / rechter Rand),
    1373                 :            :     //  dann Werte unveraendert lassen
    1374                 :            : 
    1375         [ +  - ]:          2 :     if (VALIDCOLROW(nCol,nRow))
    1376                 :            :     {
    1377                 :          2 :         rCol = nCol;
    1378                 :          2 :         rRow = nRow;
    1379                 :            :     }
    1380                 :            : }
    1381                 :            : 
    1382                 :          4 : bool ScTable::GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark ) const
    1383                 :            : {
    1384                 :          4 :     const ScMarkArray* pMarkArray = rMark.GetArray();
    1385                 :            :     OSL_ENSURE(pMarkArray,"GetNextMarkedCell ohne MarkArray");
    1386         [ -  + ]:          4 :     if ( !pMarkArray )
    1387                 :          0 :         return false;
    1388                 :            : 
    1389                 :          4 :     ++rRow;                 // naechste Zelle ist gesucht
    1390                 :            : 
    1391         [ +  + ]:       1030 :     while ( rCol <= MAXCOL )
    1392                 :            :     {
    1393                 :       1029 :         const ScMarkArray& rArray = pMarkArray[rCol];
    1394         [ +  + ]:       2055 :         while ( rRow <= MAXROW )
    1395                 :            :         {
    1396                 :       1029 :             SCROW nStart = (SCROW) rArray.GetNextMarked( (SCsROW) rRow, false );
    1397         [ +  + ]:       1029 :             if ( nStart <= MAXROW )
    1398                 :            :             {
    1399         [ +  - ]:       1027 :                 SCROW nEnd = rArray.GetMarkEnd( nStart, false );
    1400         [ +  - ]:       1027 :                 ScColumnIterator aColIter( &aCol[rCol], nStart, nEnd );
    1401                 :            :                 SCROW nCellRow;
    1402                 :       1027 :                 ScBaseCell* pCell = NULL;
    1403 [ +  - ][ +  + ]:       1027 :                 while ( aColIter.Next( nCellRow, pCell ) )
    1404                 :            :                 {
    1405 [ +  - ][ +  - ]:          3 :                     if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE )
                 [ +  - ]
    1406                 :            :                     {
    1407                 :          3 :                         rRow = nCellRow;
    1408                 :          3 :                         return true;            // Zelle gefunden
    1409                 :            :                     }
    1410                 :            :                 }
    1411 [ +  - ][ +  + ]:       1027 :                 rRow = nEnd + 1;                // naechsten markierten Bereich suchen
    1412                 :            :             }
    1413                 :            :             else
    1414                 :          2 :                 rRow = MAXROW + 1;              // Ende der Spalte
    1415                 :            :         }
    1416                 :       1026 :         rRow = 0;
    1417                 :       1026 :         ++rCol;                                 // naechste Spalte testen
    1418                 :            :     }
    1419                 :            : 
    1420                 :          4 :     return false;                               // alle Spalten durch
    1421                 :            : }
    1422                 :            : 
    1423                 :         52 : void ScTable::UpdateDrawRef( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
    1424                 :            :                                     SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
    1425                 :            :                                     SCsCOL nDx, SCsROW nDy, SCsTAB nDz, bool bUpdateNoteCaptionPos )
    1426                 :            : {
    1427 [ +  - ][ +  - ]:         52 :     if ( nTab >= nTab1 && nTab <= nTab2 && nDz == 0 )       // only within the table
                 [ +  + ]
    1428                 :            :     {
    1429                 :         40 :         InitializeNoteCaptions();
    1430                 :         40 :         ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer();
    1431 [ +  + ][ +  - ]:         40 :         if ( eUpdateRefMode != URM_COPY && pDrawLayer )
    1432                 :            :         {
    1433         [ -  + ]:         28 :             if ( eUpdateRefMode == URM_MOVE )
    1434                 :            :             {                                               // source range
    1435                 :          0 :                 nCol1 = sal::static_int_cast<SCCOL>( nCol1 - nDx );
    1436                 :          0 :                 nRow1 = sal::static_int_cast<SCROW>( nRow1 - nDy );
    1437                 :          0 :                 nCol2 = sal::static_int_cast<SCCOL>( nCol2 - nDx );
    1438                 :          0 :                 nRow2 = sal::static_int_cast<SCROW>( nRow2 - nDy );
    1439                 :            :             }
    1440                 :            :             pDrawLayer->MoveArea( nTab, nCol1,nRow1, nCol2,nRow2, nDx,nDy,
    1441                 :         28 :                                     (eUpdateRefMode == URM_INSDEL), bUpdateNoteCaptionPos );
    1442                 :            :         }
    1443                 :            :     }
    1444                 :         52 : }
    1445                 :            : 
    1446                 :         86 : void ScTable::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
    1447                 :            :                      SCCOL nCol2, SCROW nRow2, SCTAB nTab2, SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
    1448                 :            :                      ScDocument* pUndoDoc, bool bIncludeDraw, bool bUpdateNoteCaptionPos )
    1449                 :            : {
    1450                 :         86 :     bool bUpdated = false;
    1451                 :            :     SCCOL i;
    1452                 :            :     SCCOL iMax;
    1453         [ +  + ]:         86 :     if ( eUpdateRefMode == URM_COPY )
    1454                 :            :     {
    1455                 :         37 :         i = nCol1;
    1456                 :         37 :         iMax = nCol2;
    1457                 :            :     }
    1458                 :            :     else
    1459                 :            :     {
    1460                 :         49 :         i = 0;
    1461                 :         49 :         iMax = MAXCOL;
    1462                 :            :     }
    1463                 :            : 
    1464                 :            :     // Named expressions need to be updated before formulas acessing them.
    1465         [ +  + ]:         86 :     if (mpRangeName)
    1466                 :            :     {
    1467                 :         21 :         ScRange aRange( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );;
    1468         [ +  - ]:         21 :         mpRangeName->UpdateReference( eUpdateRefMode, aRange, nDx, nDy, nDz, true );
    1469                 :            :     }
    1470                 :            : 
    1471         [ +  + ]:      62645 :     for ( ; i<=iMax; i++)
    1472                 :      62559 :         bUpdated |= aCol[i].UpdateReference(
    1473                 :      62559 :             eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz, pUndoDoc );
    1474                 :            : 
    1475         [ +  + ]:         86 :     if ( bIncludeDraw )
    1476                 :         31 :         UpdateDrawRef( eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz, bUpdateNoteCaptionPos );
    1477                 :            : 
    1478 [ +  - ][ +  + ]:         86 :     if ( nTab >= nTab1 && nTab <= nTab2 && nDz == 0 )       // print ranges: only within the table
                 [ +  + ]
    1479                 :            :     {
    1480                 :         59 :         SCTAB nSTab = nTab;
    1481                 :         59 :         SCTAB nETab = nTab;
    1482                 :         59 :         SCCOL nSCol = 0;
    1483                 :         59 :         SCROW nSRow = 0;
    1484                 :         59 :         SCCOL nECol = 0;
    1485                 :         59 :         SCROW nERow = 0;
    1486                 :         59 :         bool bRecalcPages = false;
    1487                 :            : 
    1488 [ +  - ][ -  + ]:         59 :         for ( ScRangeVec::iterator aIt = aPrintRanges.begin(), aEnd = aPrintRanges.end(); aIt != aEnd; ++aIt )
    1489                 :            :         {
    1490                 :          0 :             nSCol = aIt->aStart.Col();
    1491                 :          0 :             nSRow = aIt->aStart.Row();
    1492                 :          0 :             nECol = aIt->aEnd.Col();
    1493                 :          0 :             nERow = aIt->aEnd.Row();
    1494                 :            : 
    1495                 :            :             // do not try to modify sheet index of print range
    1496         [ #  # ]:          0 :             if ( ScRefUpdate::Update( pDocument, eUpdateRefMode,
    1497                 :            :                                       nCol1,nRow1,nTab, nCol2,nRow2,nTab,
    1498                 :            :                                       nDx,nDy,0,
    1499         [ #  # ]:          0 :                                       nSCol,nSRow,nSTab, nECol,nERow,nETab ) )
    1500                 :            :             {
    1501                 :          0 :                 *aIt = ScRange( nSCol, nSRow, 0, nECol, nERow, 0 );
    1502                 :          0 :                 bRecalcPages = true;
    1503                 :            :             }
    1504                 :            :         }
    1505                 :            : 
    1506         [ -  + ]:         59 :         if ( pRepeatColRange )
    1507                 :            :         {
    1508                 :          0 :             nSCol = pRepeatColRange->aStart.Col();
    1509                 :          0 :             nSRow = pRepeatColRange->aStart.Row();
    1510                 :          0 :             nECol = pRepeatColRange->aEnd.Col();
    1511                 :          0 :             nERow = pRepeatColRange->aEnd.Row();
    1512                 :            : 
    1513                 :            :             // do not try to modify sheet index of repeat range
    1514         [ #  # ]:          0 :             if ( ScRefUpdate::Update( pDocument, eUpdateRefMode,
    1515                 :            :                                       nCol1,nRow1,nTab, nCol2,nRow2,nTab,
    1516                 :            :                                       nDx,nDy,0,
    1517         [ #  # ]:          0 :                                       nSCol,nSRow,nSTab, nECol,nERow,nETab ) )
    1518                 :            :             {
    1519                 :          0 :                 *pRepeatColRange = ScRange( nSCol, nSRow, 0, nECol, nERow, 0 );
    1520                 :          0 :                 bRecalcPages = true;
    1521                 :          0 :                 nRepeatStartX = nSCol;  // fuer UpdatePageBreaks
    1522                 :          0 :                 nRepeatEndX = nECol;
    1523                 :            :             }
    1524                 :            :         }
    1525                 :            : 
    1526         [ -  + ]:         59 :         if ( pRepeatRowRange )
    1527                 :            :         {
    1528                 :          0 :             nSCol = pRepeatRowRange->aStart.Col();
    1529                 :          0 :             nSRow = pRepeatRowRange->aStart.Row();
    1530                 :          0 :             nECol = pRepeatRowRange->aEnd.Col();
    1531                 :          0 :             nERow = pRepeatRowRange->aEnd.Row();
    1532                 :            : 
    1533                 :            :             // do not try to modify sheet index of repeat range
    1534         [ #  # ]:          0 :             if ( ScRefUpdate::Update( pDocument, eUpdateRefMode,
    1535                 :            :                                       nCol1,nRow1,nTab, nCol2,nRow2,nTab,
    1536                 :            :                                       nDx,nDy,0,
    1537         [ #  # ]:          0 :                                       nSCol,nSRow,nSTab, nECol,nERow,nETab ) )
    1538                 :            :             {
    1539                 :          0 :                 *pRepeatRowRange = ScRange( nSCol, nSRow, 0, nECol, nERow, 0 );
    1540                 :          0 :                 bRecalcPages = true;
    1541                 :          0 :                 nRepeatStartY = nSRow;  // fuer UpdatePageBreaks
    1542                 :          0 :                 nRepeatEndY = nERow;
    1543                 :            :             }
    1544                 :            :         }
    1545                 :            : 
    1546                 :            :         //  updating print ranges is not necessary with multiple print ranges
    1547 [ -  + ][ #  # ]:         59 :         if ( bRecalcPages && GetPrintRangeCount() <= 1 )
                 [ -  + ]
    1548                 :            :         {
    1549         [ #  # ]:          0 :             UpdatePageBreaks(NULL);
    1550                 :            : 
    1551         [ #  # ]:         59 :             pDocument->RepaintRange( ScRange(0,0,nTab,MAXCOL,MAXROW,nTab) );
    1552                 :            :         }
    1553                 :            :     }
    1554                 :            : 
    1555 [ +  + ][ +  + ]:         86 :     if (bUpdated && IsStreamValid())
                 [ +  + ]
    1556                 :          6 :         SetStreamValid(false);
    1557                 :            : 
    1558         [ +  - ]:         86 :     if(mpCondFormatList)
    1559         [ +  - ]:         86 :         mpCondFormatList->UpdateReference( eUpdateRefMode, ScRange(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2), nDx, nDy, nDz);
    1560                 :         86 : }
    1561                 :            : 
    1562                 :          0 : void ScTable::UpdateTranspose( const ScRange& rSource, const ScAddress& rDest,
    1563                 :            :                                     ScDocument* pUndoDoc )
    1564                 :            : {
    1565         [ #  # ]:          0 :     for ( SCCOL i=0; i<=MAXCOL; i++ )
    1566                 :          0 :         aCol[i].UpdateTranspose( rSource, rDest, pUndoDoc );
    1567                 :          0 : }
    1568                 :            : 
    1569                 :          0 : void ScTable::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY )
    1570                 :            : {
    1571         [ #  # ]:          0 :     for ( SCCOL i=0; i<=MAXCOL; i++ )
    1572                 :          0 :         aCol[i].UpdateGrow( rArea, nGrowX, nGrowY );
    1573                 :          0 : }
    1574                 :            : 
    1575                 :        110 : void ScTable::UpdateInsertTab(SCTAB nTable, SCTAB nNewSheets)
    1576                 :            : {
    1577         [ +  + ]:        110 :     if (nTab >= nTable)
    1578                 :            :     {
    1579                 :         88 :         nTab += nNewSheets;
    1580         [ -  + ]:         88 :         if (pDBDataNoName)
    1581                 :          0 :             pDBDataNoName->UpdateMoveTab(nTab - 1 ,nTab);
    1582                 :            :     }
    1583         [ +  + ]:     112750 :     for (SCCOL i=0; i <= MAXCOL; i++) aCol[i].UpdateInsertTab(nTable, nNewSheets);
    1584                 :            : 
    1585         [ +  + ]:        110 :     if (mpRangeName)
    1586                 :         36 :         mpRangeName->UpdateTabRef( nTable, 1, 0, nNewSheets);
    1587                 :            : 
    1588         [ +  + ]:        110 :     if (mpRangeName)
    1589                 :         36 :         mpRangeName->UpdateTabRef( nTable, 1);
    1590                 :            : 
    1591         [ +  + ]:        110 :     if (IsStreamValid())
    1592                 :          4 :         SetStreamValid(false);
    1593                 :            : 
    1594         [ +  - ]:        110 :     if(mpCondFormatList)
    1595         [ +  - ]:        110 :         mpCondFormatList->UpdateReference( URM_INSDEL, ScRange(0,0, nTable, MAXCOL, MAXROW, nTable+nNewSheets-1),0,0, nNewSheets);
    1596                 :        110 : }
    1597                 :            : 
    1598                 :        267 : void ScTable::UpdateDeleteTab( SCTAB nTable, bool bIsMove, ScTable* pRefUndo, SCTAB nSheets )
    1599                 :            : {
    1600         [ +  + ]:        267 :     if (nTab > nTable)
    1601                 :            :     {
    1602                 :         57 :         nTab -= nSheets;
    1603         [ -  + ]:         57 :         if (pDBDataNoName)
    1604                 :          0 :             pDBDataNoName->UpdateMoveTab(nTab + 1,nTab);
    1605                 :            :     }
    1606                 :            : 
    1607                 :            :     SCCOL i;
    1608         [ +  + ]:        267 :     if (pRefUndo)
    1609         [ +  + ]:      43050 :         for (i=0; i <= MAXCOL; i++) aCol[i].UpdateDeleteTab(nTable, bIsMove, &pRefUndo->aCol[i], nSheets);
    1610                 :            :     else
    1611         [ +  + ]:     230625 :         for (i=0; i <= MAXCOL; i++) aCol[i].UpdateDeleteTab(nTable, bIsMove, NULL, nSheets);
    1612                 :            : 
    1613         [ +  + ]:        267 :     if (mpRangeName)
    1614                 :            :     {
    1615         [ +  + ]:         58 :         for (SCTAB aTab = 0; aTab < nSheets; ++aTab)
    1616                 :            :         {
    1617                 :         29 :             mpRangeName->UpdateTabRef( nTable + aTab, 2 );
    1618                 :            :         }
    1619                 :            :     }
    1620                 :            : 
    1621         [ +  + ]:        267 :     if (mpRangeName)
    1622                 :            :     {
    1623                 :         29 :         mpRangeName->UpdateTabRef( nTable, 2 );
    1624                 :            :     }
    1625                 :            : 
    1626         [ +  + ]:        267 :     if (IsStreamValid())
    1627                 :          9 :         SetStreamValid(false);
    1628                 :            : 
    1629         [ +  - ]:        267 :     if(mpCondFormatList)
    1630         [ +  - ]:        267 :         mpCondFormatList->UpdateReference( URM_INSDEL, ScRange(0,0, nTable, MAXCOL, MAXROW, nTable+nSheets-1),0,0, -1*nSheets);
    1631                 :        267 : }
    1632                 :            : 
    1633                 :         30 : void ScTable::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo,
    1634                 :            :         ScProgress* pProgress )
    1635                 :            : {
    1636                 :         30 :     nTab = nTabNo;
    1637         [ +  + ]:      30750 :     for ( SCCOL i=0; i <= MAXCOL; i++ )
    1638                 :            :     {
    1639                 :      30720 :         aCol[i].UpdateMoveTab( nOldPos, nNewPos, nTabNo );
    1640         [ -  + ]:      30720 :         if (pProgress)
    1641                 :          0 :             pProgress->SetState(pProgress->GetState() + aCol[i].GetCodeCount());
    1642                 :            :     }
    1643                 :            : 
    1644         [ -  + ]:         30 :     if (mpRangeName)
    1645                 :          0 :         mpRangeName->UpdateTabRef(nOldPos, 3, nNewPos);
    1646                 :            : 
    1647         [ -  + ]:         30 :     if (IsStreamValid())
    1648                 :          0 :         SetStreamValid(false);
    1649         [ -  + ]:         30 :    if (pDBDataNoName)
    1650                 :          0 :         pDBDataNoName->UpdateMoveTab(nOldPos, nNewPos);
    1651                 :            : 
    1652         [ +  - ]:         30 :     if(mpCondFormatList)
    1653                 :         30 :         mpCondFormatList->UpdateMoveTab(nOldPos, nNewPos);
    1654                 :         30 : }
    1655                 :            : 
    1656                 :        374 : void ScTable::UpdateCompile( bool bForceIfNameInUse )
    1657                 :            : {
    1658         [ +  + ]:     383350 :     for (SCCOL i=0; i <= MAXCOL; i++)
    1659                 :            :     {
    1660                 :     382976 :         aCol[i].UpdateCompile( bForceIfNameInUse );
    1661                 :            :     }
    1662                 :        374 : }
    1663                 :            : 
    1664                 :          4 : void ScTable::SetTabNo(SCTAB nNewTab)
    1665                 :            : {
    1666                 :          4 :     nTab = nNewTab;
    1667         [ +  + ]:       4100 :     for (SCCOL i=0; i <= MAXCOL; i++) aCol[i].SetTabNo(nNewTab);
    1668                 :          4 : }
    1669                 :            : 
    1670                 :          3 : void ScTable::FindRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
    1671                 :            :                                std::set<sal_uInt16>& rIndexes) const
    1672                 :            : {
    1673 [ +  + ][ +  - ]:         12 :     for (SCCOL i = nCol1; i <= nCol2 && ValidCol(i); i++)
                 [ +  + ]
    1674                 :          9 :         aCol[i].FindRangeNamesInUse(nRow1, nRow2, rIndexes);
    1675                 :          3 : }
    1676                 :            : 
    1677                 :         96 : void ScTable::ExtendPrintArea( OutputDevice* pDev,
    1678                 :            :                     SCCOL /* nStartCol */, SCROW nStartRow, SCCOL& rEndCol, SCROW nEndRow )
    1679                 :            : {
    1680 [ +  - ][ +  - ]:         96 :     if ( !pColFlags || !pRowFlags )
    1681                 :            :     {
    1682                 :            :         OSL_FAIL("keine ColInfo oder RowInfo in ExtendPrintArea");
    1683                 :            :         return;
    1684                 :            :     }
    1685                 :            : 
    1686 [ +  - ][ +  - ]:         96 :     Point aPix1000 = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP );
                 [ +  - ]
    1687                 :         96 :     double nPPTX = aPix1000.X() / 1000.0;
    1688                 :         96 :     double nPPTY = aPix1000.Y() / 1000.0;
    1689                 :            : 
    1690                 :            :     // First, mark those columns that we need to skip i.e. hidden and empty columns.
    1691                 :            : 
    1692         [ +  - ]:         96 :     ScFlatBoolColSegments aSkipCols;
    1693         [ +  - ]:         96 :     aSkipCols.setFalse(0, MAXCOL);
    1694         [ +  + ]:        192 :     for (SCCOL i = 0; i <= MAXCOL; ++i)
    1695                 :            :     {
    1696                 :         96 :         SCCOL nLastCol = i;
    1697 [ +  - ][ -  + ]:         96 :         if (ColHidden(i, NULL, &nLastCol))
    1698                 :            :         {
    1699                 :            :             // Columns are hidden in this range.
    1700         [ #  # ]:          0 :             aSkipCols.setTrue(i, nLastCol);
    1701                 :            :         }
    1702                 :            :         else
    1703                 :            :         {
    1704                 :            :             // These columns are visible.  Check for empty columns.
    1705         [ +  + ]:      98400 :             for (SCCOL j = i; j <= nLastCol; ++j)
    1706                 :            :             {
    1707 [ +  - ][ +  + ]:      98304 :                 if (aCol[j].GetCellCount() == 0)
    1708                 :            :                     // empty
    1709         [ +  - ]:      98144 :                     aSkipCols.setTrue(j,j);
    1710                 :            :             }
    1711                 :            :         }
    1712                 :         96 :         i = nLastCol;
    1713                 :            :     }
    1714                 :            : 
    1715                 :            :     ScFlatBoolColSegments::RangeData aColData;
    1716         [ +  + ]:        220 :     for (SCCOL nCol = rEndCol; nCol >= 0; --nCol)
    1717                 :            :     {
    1718 [ +  - ][ -  + ]:        124 :         if (!aSkipCols.getRangeData(nCol, aColData))
    1719                 :            :             // Failed to get the data.  This should never happen!
    1720                 :            :             return;
    1721                 :            : 
    1722         [ +  + ]:        124 :         if (aColData.mbValue)
    1723                 :            :         {
    1724                 :            :             // Skip these columns.
    1725                 :         17 :             nCol = aColData.mnCol1; // move toward 0.
    1726                 :         17 :             continue;
    1727                 :            :         }
    1728                 :            : 
    1729                 :            :         // These are visible and non-empty columns.
    1730 [ +  + ][ +  + ]:        267 :         for (SCCOL nDataCol = nCol; 0 <= nDataCol && nDataCol >= aColData.mnCol1; --nDataCol)
                 [ +  + ]
    1731                 :            :         {
    1732                 :        160 :             SCCOL nPrintCol = nDataCol;
    1733                 :        160 :             VisibleDataCellIterator aIter(*mpHiddenRows, aCol[nDataCol]);
    1734         [ +  - ]:        160 :             ScBaseCell* pCell = aIter.reset(nStartRow);
    1735         [ -  + ]:        160 :             if (!pCell)
    1736                 :            :                 // No visible cells found in this column.  Skip it.
    1737                 :          0 :                 continue;
    1738                 :            : 
    1739         [ +  + ]:        598 :             while (pCell)
    1740                 :            :             {
    1741                 :        438 :                 SCCOL nNewCol = nDataCol;
    1742                 :        438 :                 SCROW nRow = aIter.getRow();
    1743         [ +  - ]:        438 :                 if (nRow > nEndRow)
    1744                 :            :                     // Went past the last row position.  Bail out.
    1745                 :            :                     break;
    1746                 :            : 
    1747         [ +  - ]:        438 :                 MaybeAddExtraColumn(nNewCol, nRow, pDev, nPPTX, nPPTY);
    1748         [ +  + ]:        438 :                 if (nNewCol > nPrintCol)
    1749                 :         46 :                     nPrintCol = nNewCol;
    1750         [ +  - ]:        438 :                 pCell = aIter.next();
    1751                 :            :             }
    1752                 :            : 
    1753         [ +  + ]:        160 :             if (nPrintCol > rEndCol)
    1754                 :            :                 // Make sure we don't shrink the print area.
    1755                 :        160 :                 rEndCol = nPrintCol;
    1756         [ +  - ]:        160 :         }
    1757                 :        107 :         nCol = aColData.mnCol1; // move toward 0.
    1758 [ +  - ][ +  - ]:         96 :     }
    1759                 :            : }
    1760                 :            : 
    1761                 :        438 : void ScTable::MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY)
    1762                 :            : {
    1763                 :        438 :     ScBaseCell* pCell = aCol[rCol].GetCell(nRow);
    1764 [ +  + ][ +  + ]:        438 :     if (!pCell || !pCell->HasStringData())
                 [ +  - ]
    1765                 :        438 :         return;
    1766                 :            : 
    1767                 :        243 :     bool bFormula = false;  //! ueberge
    1768                 :        243 :     long nPixel = pCell->GetTextWidth();
    1769                 :            : 
    1770                 :            :     // Breite bereits im Idle-Handler berechnet?
    1771         [ +  + ]:        243 :     if ( TEXTWIDTH_DIRTY == nPixel )
    1772                 :            :     {
    1773                 :        188 :         ScNeededSizeOptions aOptions;
    1774                 :        188 :         aOptions.bTotalSize  = true;
    1775                 :        188 :         aOptions.bFormula    = bFormula;
    1776                 :        188 :         aOptions.bSkipMerged = false;
    1777                 :            : 
    1778         [ +  - ]:        188 :         Fraction aZoom(1,1);
    1779                 :        188 :         nPixel = aCol[rCol].GetNeededSize(
    1780         [ +  - ]:        188 :             nRow, pDev, nPPTX, nPPTY, aZoom, aZoom, true, aOptions );
    1781                 :        188 :         pCell->SetTextWidth( (sal_uInt16)nPixel );
    1782                 :            :     }
    1783                 :            : 
    1784                 :        243 :     long nTwips = (long) (nPixel / nPPTX);
    1785                 :        243 :     long nDocW = GetColWidth( rCol );
    1786                 :            : 
    1787                 :        243 :     long nMissing = nTwips - nDocW;
    1788         [ +  + ]:        243 :     if ( nMissing > 0 )
    1789                 :            :     {
    1790                 :            :         //  look at alignment
    1791                 :            : 
    1792                 :         50 :         const ScPatternAttr* pPattern = GetPattern( rCol, nRow );
    1793                 :         50 :         const SfxItemSet* pCondSet = NULL;
    1794         [ -  + ]:         50 :         if ( ((const SfxUInt32Item&)pPattern->GetItem(ATTR_CONDITIONAL)).GetValue() )
    1795                 :          0 :             pCondSet = pDocument->GetCondResult( rCol, nRow, nTab );
    1796                 :            : 
    1797                 :            :         SvxCellHorJustify eHorJust = (SvxCellHorJustify)((const SvxHorJustifyItem&)
    1798                 :         50 :                         pPattern->GetItem( ATTR_HOR_JUSTIFY, pCondSet )).GetValue();
    1799         [ -  + ]:         50 :         if ( eHorJust == SVX_HOR_JUSTIFY_CENTER )
    1800                 :          0 :             nMissing /= 2;                          // distributed into both directions
    1801                 :            :         else
    1802                 :            :         {
    1803                 :            :             // STANDARD is LEFT (only text is handled here)
    1804                 :         50 :             bool bRight = ( eHorJust == SVX_HOR_JUSTIFY_RIGHT );
    1805         [ -  + ]:         50 :             if ( IsLayoutRTL() )
    1806                 :          0 :                 bRight = !bRight;
    1807         [ -  + ]:         50 :             if ( bRight )
    1808                 :          0 :                 nMissing = 0;       // extended only to the left (logical)
    1809                 :            :         }
    1810                 :            :     }
    1811                 :            : 
    1812                 :        243 :     SCCOL nNewCol = rCol;
    1813 [ +  + ][ +  - ]:        790 :     while (nMissing > 0 && nNewCol < MAXCOL)
                 [ +  + ]
    1814                 :            :     {
    1815                 :        547 :         ScBaseCell* pNextCell = aCol[nNewCol+1].GetCell(nRow);
    1816 [ #  # ][ -  + ]:        547 :         if (pNextCell && pNextCell->GetCellType() != CELLTYPE_NOTE)
                 [ -  + ]
    1817                 :            :             // Cell content in a next column ends display of this string.
    1818                 :          0 :             nMissing = 0;
    1819                 :            :         else
    1820                 :        547 :             nMissing -= GetColWidth(++nNewCol);
    1821                 :            :     }
    1822                 :        243 :     rCol = nNewCol;
    1823                 :            : }
    1824                 :            : 
    1825                 :            : namespace {
    1826                 :            : 
    1827                 :            : class SetTableIndex : public ::std::unary_function<ScRange, void>
    1828                 :            : {
    1829                 :            :     SCTAB mnTab;
    1830                 :            : public:
    1831                 :         10 :     SetTableIndex(SCTAB nTab) : mnTab(nTab) {}
    1832                 :            : 
    1833                 :          0 :     void operator() (ScRange& rRange) const
    1834                 :            :     {
    1835                 :          0 :         rRange.aStart.SetTab(mnTab);
    1836                 :          0 :         rRange.aEnd.SetTab(mnTab);
    1837                 :          0 :     }
    1838                 :            : };
    1839                 :            : 
    1840                 :          4 : void setPrintRange(ScRange*& pRange1, const ScRange* pRange2)
    1841                 :            : {
    1842         [ +  - ]:          4 :     if (pRange2)
    1843                 :            :     {
    1844         [ -  + ]:          4 :         if (pRange1)
    1845                 :          0 :             *pRange1 = *pRange2;
    1846                 :            :         else
    1847                 :          4 :             pRange1 = new ScRange(*pRange2);
    1848                 :            :     }
    1849                 :            :     else
    1850                 :          0 :         DELETEZ(pRange1);
    1851                 :          4 : }
    1852                 :            : 
    1853                 :            : }
    1854                 :            : 
    1855                 :         10 : void ScTable::CopyPrintRange(const ScTable& rTable)
    1856                 :            : {
    1857                 :            :     // The table index shouldn't be used when the print range is used, but
    1858                 :            :     // just in case set the correct table index.
    1859                 :            : 
    1860                 :         10 :     aPrintRanges = rTable.aPrintRanges;
    1861         [ +  - ]:         10 :     ::std::for_each(aPrintRanges.begin(), aPrintRanges.end(), SetTableIndex(nTab));
    1862                 :            : 
    1863                 :         10 :     bPrintEntireSheet = rTable.bPrintEntireSheet;
    1864                 :            : 
    1865                 :         10 :     delete pRepeatColRange;
    1866                 :         10 :     pRepeatColRange = NULL;
    1867         [ -  + ]:         10 :     if (rTable.pRepeatColRange)
    1868                 :            :     {
    1869                 :          0 :         pRepeatColRange = new ScRange(*rTable.pRepeatColRange);
    1870                 :          0 :         pRepeatColRange->aStart.SetTab(nTab);
    1871                 :          0 :         pRepeatColRange->aEnd.SetTab(nTab);
    1872                 :            :     }
    1873                 :            : 
    1874                 :         10 :     delete pRepeatRowRange;
    1875                 :         10 :     pRepeatRowRange = NULL;
    1876         [ -  + ]:         10 :     if (rTable.pRepeatRowRange)
    1877                 :            :     {
    1878                 :          0 :         pRepeatRowRange = new ScRange(*rTable.pRepeatRowRange);
    1879                 :          0 :         pRepeatRowRange->aStart.SetTab(nTab);
    1880                 :          0 :         pRepeatRowRange->aEnd.SetTab(nTab);
    1881                 :            :     }
    1882                 :         10 : }
    1883                 :            : 
    1884                 :        162 : void ScTable::DoColResize( SCCOL nCol1, SCCOL nCol2, SCSIZE nAdd )
    1885                 :            : {
    1886         [ +  + ]:        579 :     for (SCCOL nCol=nCol1; nCol<=nCol2; nCol++)
    1887                 :        417 :         aCol[nCol].Resize(aCol[nCol].GetCellCount() + nAdd);
    1888                 :        162 : }
    1889                 :            : 
    1890                 :          2 : void ScTable::SetRepeatColRange( const ScRange* pNew )
    1891                 :            : {
    1892                 :          2 :     setPrintRange( pRepeatColRange, pNew );
    1893                 :            : 
    1894         [ -  + ]:          2 :     if (IsStreamValid())
    1895                 :          0 :         SetStreamValid(false);
    1896                 :            : 
    1897                 :          2 :     InvalidatePageBreaks();
    1898                 :          2 : }
    1899                 :            : 
    1900                 :          2 : void ScTable::SetRepeatRowRange( const ScRange* pNew )
    1901                 :            : {
    1902                 :          2 :     setPrintRange( pRepeatRowRange, pNew );
    1903                 :            : 
    1904         [ -  + ]:          2 :     if (IsStreamValid())
    1905                 :          0 :         SetStreamValid(false);
    1906                 :            : 
    1907                 :          2 :     InvalidatePageBreaks();
    1908                 :          2 : }
    1909                 :            : 
    1910                 :         65 : void ScTable::ClearPrintRanges()
    1911                 :            : {
    1912                 :         65 :     aPrintRanges.clear();
    1913                 :         65 :     bPrintEntireSheet = false;
    1914                 :            : 
    1915         [ -  + ]:         65 :     if (IsStreamValid())
    1916                 :          0 :         SetStreamValid(false);
    1917                 :            : 
    1918                 :         65 :     InvalidatePageBreaks();
    1919                 :         65 : }
    1920                 :            : 
    1921                 :          0 : void ScTable::AddPrintRange( const ScRange& rNew )
    1922                 :            : {
    1923                 :          0 :     bPrintEntireSheet = false;
    1924         [ #  # ]:          0 :     if( aPrintRanges.size() < 0xFFFF )
    1925                 :          0 :         aPrintRanges.push_back( rNew );
    1926                 :            : 
    1927         [ #  # ]:          0 :     if (IsStreamValid())
    1928                 :          0 :         SetStreamValid(false);
    1929                 :            : 
    1930                 :          0 :     InvalidatePageBreaks();
    1931                 :          0 : }
    1932                 :            : 
    1933                 :            : 
    1934                 :          0 : void ScTable::SetPrintEntireSheet()
    1935                 :            : {
    1936         [ #  # ]:          0 :     if( !IsPrintEntireSheet() )
    1937                 :            :     {
    1938                 :          0 :         ClearPrintRanges();
    1939                 :          0 :         bPrintEntireSheet = true;
    1940                 :            :     }
    1941                 :          0 : }
    1942                 :            : 
    1943                 :        210 : const ScRange* ScTable::GetPrintRange(sal_uInt16 nPos) const
    1944                 :            : {
    1945         [ -  + ]:        210 :     return (nPos < GetPrintRangeCount()) ? &aPrintRanges[ nPos ] : NULL;
    1946                 :            : }
    1947                 :            : 
    1948                 :        135 : void ScTable::FillPrintSaver( ScPrintSaverTab& rSaveTab ) const
    1949                 :            : {
    1950                 :        135 :     rSaveTab.SetAreas( aPrintRanges, bPrintEntireSheet );
    1951                 :        135 :     rSaveTab.SetRepeat( pRepeatColRange, pRepeatRowRange );
    1952                 :        135 : }
    1953                 :            : 
    1954                 :          0 : void ScTable::RestorePrintRanges( const ScPrintSaverTab& rSaveTab )
    1955                 :            : {
    1956                 :          0 :     aPrintRanges = rSaveTab.GetPrintRanges();
    1957                 :          0 :     bPrintEntireSheet = rSaveTab.IsEntireSheet();
    1958                 :          0 :     SetRepeatColRange( rSaveTab.GetRepeatCol() );
    1959                 :          0 :     SetRepeatRowRange( rSaveTab.GetRepeatRow() );
    1960                 :            : 
    1961                 :          0 :     InvalidatePageBreaks();     // #i117952# forget page breaks for an old print range
    1962                 :          0 :     UpdatePageBreaks(NULL);
    1963                 :          0 : }
    1964                 :            : 
    1965                 :            : SCROW ScTable::VisibleDataCellIterator::ROW_NOT_FOUND = -1;
    1966                 :            : 
    1967                 :        160 : ScTable::VisibleDataCellIterator::VisibleDataCellIterator(ScFlatBoolRowSegments& rRowSegs, ScColumn& rColumn) :
    1968                 :            :     mrRowSegs(rRowSegs),
    1969                 :            :     mrColumn(rColumn),
    1970                 :            :     mpCell(NULL),
    1971                 :            :     mnCurRow(ROW_NOT_FOUND),
    1972                 :        160 :     mnUBound(ROW_NOT_FOUND)
    1973                 :            : {
    1974                 :        160 : }
    1975                 :            : 
    1976                 :        160 : ScTable::VisibleDataCellIterator::~VisibleDataCellIterator()
    1977                 :            : {
    1978                 :        160 : }
    1979                 :            : 
    1980                 :        160 : ScBaseCell* ScTable::VisibleDataCellIterator::reset(SCROW nRow)
    1981                 :            : {
    1982         [ -  + ]:        160 :     if (nRow > MAXROW)
    1983                 :            :     {
    1984                 :          0 :         mnCurRow = ROW_NOT_FOUND;
    1985                 :          0 :         return NULL;
    1986                 :            :     }
    1987                 :            : 
    1988                 :            :     ScFlatBoolRowSegments::RangeData aData;
    1989 [ +  - ][ -  + ]:        160 :     if (!mrRowSegs.getRangeData(nRow, aData))
    1990                 :            :     {
    1991                 :          0 :         mnCurRow = ROW_NOT_FOUND;
    1992                 :          0 :         return NULL;
    1993                 :            :     }
    1994                 :            : 
    1995         [ +  - ]:        160 :     if (!aData.mbValue)
    1996                 :            :     {
    1997                 :            :         // specified row is visible.  Take it.
    1998                 :        160 :         mnCurRow = nRow;
    1999                 :        160 :         mnUBound = aData.mnRow2;
    2000                 :            :     }
    2001                 :            :     else
    2002                 :            :     {
    2003                 :            :         // specified row is not-visible.  The first visible row is the start of
    2004                 :            :         // the next segment.
    2005                 :          0 :         mnCurRow = aData.mnRow2 + 1;
    2006                 :          0 :         mnUBound = mnCurRow; // get range data on the next iteration.
    2007         [ #  # ]:          0 :         if (mnCurRow > MAXROW)
    2008                 :            :         {
    2009                 :            :             // Make sure the row doesn't exceed our current limit.
    2010                 :          0 :             mnCurRow = ROW_NOT_FOUND;
    2011                 :          0 :             return NULL;
    2012                 :            :         }
    2013                 :            :     }
    2014                 :            : 
    2015         [ +  - ]:        160 :     mpCell = mrColumn.GetCell(mnCurRow);
    2016         [ +  + ]:        160 :     if (mpCell)
    2017                 :            :         // First visible cell found.
    2018                 :        135 :         return mpCell;
    2019                 :            : 
    2020                 :            :     // Find a first visible cell below this row (if any).
    2021         [ +  - ]:        160 :     return next();
    2022                 :            : }
    2023                 :            : 
    2024                 :        463 : ScBaseCell* ScTable::VisibleDataCellIterator::next()
    2025                 :            : {
    2026         [ -  + ]:        463 :     if (mnCurRow == ROW_NOT_FOUND)
    2027                 :          0 :         return NULL;
    2028                 :            : 
    2029         [ +  + ]:        463 :     while (mrColumn.GetNextDataPos(mnCurRow))
    2030                 :            :     {
    2031         [ -  + ]:        303 :         if (mnCurRow > mnUBound)
    2032                 :            :         {
    2033                 :            :             // We don't know the visibility of this row range.  Query it.
    2034                 :            :             ScFlatBoolRowSegments::RangeData aData;
    2035 [ #  # ][ #  # ]:          0 :             if (!mrRowSegs.getRangeData(mnCurRow, aData))
    2036                 :            :             {
    2037                 :          0 :                 mnCurRow = ROW_NOT_FOUND;
    2038                 :          0 :                 return NULL;
    2039                 :            :             }
    2040                 :            : 
    2041         [ #  # ]:          0 :             if (aData.mbValue)
    2042                 :            :             {
    2043                 :            :                 // This row is invisible.  Skip to the last invisible row and
    2044                 :            :                 // try again.
    2045                 :          0 :                 mnCurRow = mnUBound = aData.mnRow2;
    2046                 :          0 :                 continue;
    2047                 :            :             }
    2048                 :            : 
    2049                 :            :             // This row is visible.
    2050                 :          0 :             mnUBound = aData.mnRow2;
    2051                 :            :         }
    2052                 :            : 
    2053                 :        303 :         mpCell = mrColumn.GetCell(mnCurRow);
    2054         [ +  - ]:        303 :         if (mpCell)
    2055                 :        303 :             return mpCell;
    2056                 :            :     }
    2057                 :        160 :     mnCurRow = ROW_NOT_FOUND;
    2058                 :        463 :     return NULL;
    2059                 :            : }
    2060                 :            : 
    2061                 :        438 : SCROW ScTable::VisibleDataCellIterator::getRow() const
    2062                 :            : {
    2063                 :        438 :     return mnCurRow;
    2064                 :            : }
    2065                 :            : 
    2066                 :        480 : void ScTable::SetAnonymousDBData(ScDBData* pDBData)
    2067                 :            : {
    2068         [ +  + ]:        480 :     delete pDBDataNoName;
    2069                 :        480 :     pDBDataNoName = pDBData;
    2070                 :        480 : }
    2071                 :            : 
    2072                 :        468 : ScDBData* ScTable::GetAnonymousDBData()
    2073                 :            : {
    2074                 :        468 :     return pDBDataNoName;
    2075                 :            : }
    2076                 :            : 
    2077                 :         41 : sal_uLong ScTable::AddCondFormat( ScConditionalFormat* pNew )
    2078                 :            : {
    2079         [ -  + ]:         41 :     if(!mpCondFormatList)
    2080         [ #  # ]:          0 :         mpCondFormatList.reset(new ScConditionalFormatList());
    2081                 :            : 
    2082                 :         41 :     sal_uLong nMax = 0;
    2083 [ +  - ][ +  - ]:        226 :     for(ScConditionalFormatList::const_iterator itr = mpCondFormatList->begin();
         [ +  - ][ +  - ]
                 [ +  + ]
    2084         [ +  - ]:        113 :             itr != mpCondFormatList->end(); ++itr)
    2085                 :            :     {
    2086         [ +  - ]:         72 :         sal_uLong nKey = itr->GetKey();
    2087         [ +  - ]:         72 :         if(nKey > nMax)
    2088                 :         72 :             nMax = nKey;
    2089                 :            :     }
    2090                 :            : 
    2091                 :         41 :     pNew->SetKey(nMax+1);
    2092                 :         41 :     mpCondFormatList->InsertNew(pNew);
    2093                 :            : 
    2094                 :         41 :     return nMax + 1;
    2095                 :            : }
    2096                 :            : 
    2097                 :          0 : void ScTable::DeleteConditionalFormat( sal_uLong nIndex )
    2098                 :            : {
    2099                 :          0 :     mpCondFormatList->erase(nIndex);
    2100                 :          0 : }
    2101                 :            : 
    2102                 :         13 : void ScTable::SetCondFormList( ScConditionalFormatList* pNew )
    2103                 :            : {
    2104                 :         13 :     mpCondFormatList.reset( pNew );
    2105                 :         13 : }
    2106                 :            : 
    2107                 :      68033 : ScConditionalFormatList* ScTable::GetCondFormList()
    2108                 :            : {
    2109         [ -  + ]:      68033 :     if(!mpCondFormatList)
    2110         [ #  # ]:          0 :         mpCondFormatList.reset( new ScConditionalFormatList() );
    2111                 :            : 
    2112                 :      68033 :     return mpCondFormatList.get();
    2113                 :            : }
    2114                 :            : 
    2115                 :          0 : const ScConditionalFormatList* ScTable::GetCondFormList() const
    2116                 :            : {
    2117                 :          0 :     return mpCondFormatList.get();
    2118                 :            : }
    2119                 :            : 
    2120                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10