LCOV - code coverage report
Current view: top level - sc/inc - dociter.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 21 29 72.4 %
Date: 2012-08-25 Functions: 14 22 63.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 5 8 62.5 %

           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                 :            : #ifndef SC_DOCITER_HXX
      30                 :            : #define SC_DOCITER_HXX
      31                 :            : 
      32                 :            : #include "address.hxx"
      33                 :            : #include <tools/solar.h>
      34                 :            : #include "global.hxx"
      35                 :            : #include "scdllapi.h"
      36                 :            : 
      37                 :            : #include <memory>
      38                 :            : 
      39                 :            : #include <set>
      40                 :            : #include <vector>
      41                 :            : #include <boost/shared_ptr.hpp>
      42                 :            : #include <boost/scoped_ptr.hpp>
      43                 :            : 
      44                 :            : class ScDocument;
      45                 :            : class ScBaseCell;
      46                 :            : class ScPatternAttr;
      47                 :            : class ScAttrArray;
      48                 :            : class ScAttrIterator;
      49                 :            : class ScRange;
      50                 :            : class ScFlatBoolRowSegments;
      51                 :            : class ScMatrix;
      52                 :            : struct ScDBQueryParamBase;
      53                 :            : struct ScQueryParam;
      54                 :            : struct ScDBQueryParamInternal;
      55                 :            : struct ScDBQueryParamMatrix;
      56                 :            : 
      57                 :            : class ScDocumentIterator                // walk through all non-empty cells
      58                 :            : {
      59                 :            : private:
      60                 :            :     ScDocument*             pDoc;
      61                 :            :     SCTAB                   nStartTab;
      62                 :            :     SCTAB                   nEndTab;
      63                 :            : 
      64                 :            :     const ScPatternAttr*    pDefPattern;
      65                 :            : 
      66                 :            :     SCCOL                   nCol;
      67                 :            :     SCROW                   nRow;
      68                 :            :     SCTAB                   nTab;
      69                 :            :     ScBaseCell*             pCell;
      70                 :            :     const ScPatternAttr*    pPattern;
      71                 :            : 
      72                 :            : 
      73                 :            :     SCSIZE                  nColPos;
      74                 :            :     SCSIZE                  nAttrPos;
      75                 :            : 
      76                 :            :     bool                    GetThis();
      77                 :            :     bool                    GetThisCol();
      78                 :            : 
      79                 :            : public:
      80                 :            :             ScDocumentIterator( ScDocument* pDocument, SCTAB nStartTable, SCTAB nEndTable );
      81                 :            :             ~ScDocumentIterator();
      82                 :            : 
      83                 :            :     bool                    GetFirst();
      84                 :            :     bool                    GetNext();
      85                 :            : 
      86                 :            :     ScBaseCell*             GetCell();
      87                 :            :     const ScPatternAttr*    GetPattern();
      88                 :            :     void                    GetPos( SCCOL& rCol, SCROW& rRow, SCTAB& rTab );
      89                 :            : };
      90                 :            : 
      91                 :            : class ScValueIterator            // walk through all values in an area
      92                 :            : {
      93                 :            : private:
      94                 :            :     double          fNextValue;
      95                 :            :     ScDocument*     pDoc;
      96                 :            :     const ScAttrArray*  pAttrArray;
      97                 :            :     sal_uLong           nNumFormat;     // for CalcAsShown
      98                 :            :     sal_uLong           nNumFmtIndex;
      99                 :            :     SCCOL           nStartCol;
     100                 :            :     SCROW           nStartRow;
     101                 :            :     SCTAB           nStartTab;
     102                 :            :     SCCOL           nEndCol;
     103                 :            :     SCROW           nEndRow;
     104                 :            :     SCTAB           nEndTab;
     105                 :            :     SCCOL           nCol;
     106                 :            :     SCROW           nRow;
     107                 :            :     SCTAB           nTab;
     108                 :            :     SCSIZE          nColRow;
     109                 :            :     SCROW           nNextRow;
     110                 :            :     SCROW           nAttrEndRow;
     111                 :            :     short           nNumFmtType;
     112                 :            :     bool            bNumValid;
     113                 :            :     bool            bSubTotal;
     114                 :            :     bool            bNextValid;
     115                 :            :     bool            bCalcAsShown;
     116                 :            :     bool            bTextAsZero;
     117                 :            : 
     118                 :            :     bool            GetThis(double& rValue, sal_uInt16& rErr);
     119                 :            : public:
     120                 :            : 
     121                 :            :                     ScValueIterator(ScDocument* pDocument,
     122                 :            :                                     const ScRange& rRange, bool bSTotal = false,
     123                 :            :                                     bool bTextAsZero = false );
     124                 :            :     void            GetCurNumFmtInfo( short& nType, sal_uLong& nIndex );
     125                 :            :     /// Does NOT reset rValue if no value found!
     126                 :            :     bool            GetFirst(double& rValue, sal_uInt16& rErr);
     127                 :            :     /// Does NOT reset rValue if no value found!
     128                 :       6583 :     bool            GetNext(double& rValue, sal_uInt16& rErr)
     129                 :            :                     {
     130                 :            :                         return bNextValid ? ( bNextValid = false, rValue = fNextValue,
     131                 :            :                                                 rErr = 0, nRow = nNextRow,
     132                 :            :                                                 ++nColRow, bNumValid = false, true )
     133         [ +  + ]:       6583 :                                           : ( ++nRow, GetThis(rValue, rErr) );
     134                 :            :                     }
     135                 :            : };
     136                 :            : 
     137         [ +  - ]:         12 : class ScDBQueryDataIterator
     138                 :            : {
     139                 :            : public:
     140                 :         12 :     struct Value
     141                 :            :     {
     142                 :            :         ::rtl::OUString maString;
     143                 :            :         double          mfValue;
     144                 :            :         sal_uInt16      mnError;
     145                 :            :         bool            mbIsNumber;
     146                 :            : 
     147                 :            :         Value();
     148                 :            :     };
     149                 :            : 
     150                 :            : private:
     151                 :            :     static SCROW        GetRowByColEntryIndex(ScDocument& rDoc, SCTAB nTab, SCCOL nCol, SCSIZE nColRow);
     152                 :            :     static ScBaseCell*  GetCellByColEntryIndex(ScDocument& rDoc, SCTAB nTab, SCCOL nCol, SCSIZE nColRow);
     153                 :            :     static ScAttrArray* GetAttrArrayByCol(ScDocument& rDoc, SCTAB nTab, SCCOL nCol);
     154                 :            :     static bool         IsQueryValid(ScDocument& rDoc, const ScQueryParam& rParam, SCTAB nTab, SCROW nRow, ScBaseCell* pCell);
     155                 :            :     static SCSIZE       SearchColEntryIndex(ScDocument& rDoc, SCTAB nTab, SCROW nRow, SCCOL nCol);
     156                 :            : 
     157                 :            :     class DataAccess
     158                 :            :     {
     159                 :            :     public:
     160                 :            :         DataAccess(const ScDBQueryDataIterator* pParent);
     161                 :            :         virtual ~DataAccess() = 0;
     162                 :            :         virtual bool getCurrent(Value& rValue) = 0;
     163                 :            :         virtual bool getFirst(Value& rValue) = 0;
     164                 :            :         virtual bool getNext(Value& rValue) = 0;
     165                 :            :     protected:
     166                 :            :         const ScDBQueryDataIterator* mpParent;
     167                 :            :     };
     168                 :            : 
     169                 :            :     class DataAccessInternal : public DataAccess
     170                 :            :     {
     171                 :            :     public:
     172                 :            :         DataAccessInternal(const ScDBQueryDataIterator* pParent, ScDBQueryParamInternal* pParam, ScDocument* pDoc);
     173                 :            :         virtual ~DataAccessInternal();
     174                 :            :         virtual bool getCurrent(Value& rValue);
     175                 :            :         virtual bool getFirst(Value& rValue);
     176                 :            :         virtual bool getNext(Value& rValue);
     177                 :            : 
     178                 :            :     private:
     179                 :            :         ScDBQueryParamInternal* mpParam;
     180                 :            :         ScDocument*         mpDoc;
     181                 :            :         const ScAttrArray*  pAttrArray;
     182                 :            :         sal_uLong               nNumFormat;     // for CalcAsShown
     183                 :            :         sal_uLong               nNumFmtIndex;
     184                 :            :         SCCOL               nCol;
     185                 :            :         SCROW               nRow;
     186                 :            :         SCSIZE              nColRow;
     187                 :            :         SCROW               nAttrEndRow;
     188                 :            :         SCTAB               nTab;
     189                 :            :         short               nNumFmtType;
     190                 :            :         bool                bCalcAsShown;
     191                 :            :     };
     192                 :            : 
     193                 :            :     class DataAccessMatrix : public DataAccess
     194                 :            :     {
     195                 :            :     public:
     196                 :            :         DataAccessMatrix(const ScDBQueryDataIterator* pParent, ScDBQueryParamMatrix* pParam);
     197                 :            :         virtual ~DataAccessMatrix();
     198                 :            :         virtual bool getCurrent(Value& rValue);
     199                 :            :         virtual bool getFirst(Value& rValue);
     200                 :            :         virtual bool getNext(Value& rValue);
     201                 :            : 
     202                 :            :     private:
     203                 :            :         bool isValidQuery(SCROW mnRow, const ScMatrix& rMat) const;
     204                 :            : 
     205                 :            :         ScDBQueryParamMatrix* mpParam;
     206                 :            :         SCROW mnCurRow;
     207                 :            :         SCROW mnRows;
     208                 :            :         SCCOL mnCols;
     209                 :            :     };
     210                 :            : 
     211                 :            :     ::std::auto_ptr<ScDBQueryParamBase> mpParam;
     212                 :            :     ::std::auto_ptr<DataAccess>         mpData;
     213                 :            : 
     214                 :            : public:
     215                 :            :                     ScDBQueryDataIterator(ScDocument* pDocument, ScDBQueryParamBase* pParam);
     216                 :            :     /// Does NOT reset rValue if no value found!
     217                 :            :     bool            GetFirst(Value& rValue);
     218                 :            :     /// Does NOT reset rValue if no value found!
     219                 :            :     bool            GetNext(Value& rValue);
     220                 :            : };
     221                 :            : 
     222                 :            : class ScCellIterator            // walk through all cells in an area
     223                 :            : {                               // for SubTotal no hidden and no sub-total lines
     224                 :            : private:
     225                 :            :     ScDocument*     pDoc;
     226                 :            :     SCCOL           nStartCol;
     227                 :            :     SCROW           nStartRow;
     228                 :            :     SCTAB           nStartTab;
     229                 :            :     SCCOL           nEndCol;
     230                 :            :     SCROW           nEndRow;
     231                 :            :     SCTAB           nEndTab;
     232                 :            :     SCCOL           nCol;
     233                 :            :     SCROW           nRow;
     234                 :            :     SCTAB           nTab;
     235                 :            :     SCSIZE          nColRow;
     236                 :            :     bool            bSubTotal;
     237                 :            : 
     238                 :            :     ScBaseCell*     GetThis();
     239                 :            : public:
     240                 :            :                     ScCellIterator(ScDocument* pDocument,
     241                 :            :                                    SCCOL nSCol, SCROW nSRow, SCTAB nSTab,
     242                 :            :                                    SCCOL nECol, SCROW nERow, SCTAB nETab,
     243                 :            :                                    bool bSTotal = false);
     244                 :            :                     ScCellIterator(ScDocument* pDocument,
     245                 :            :                                    const ScRange& rRange, bool bSTotal = false);
     246                 :            :     ScBaseCell*     GetFirst();
     247                 :            :     ScBaseCell*     GetNext();
     248                 :        415 :     SCCOL           GetCol() const { return nCol; }
     249                 :        622 :     SCROW           GetRow() const { return nRow; }
     250                 :        427 :     SCTAB           GetTab() const { return nTab; }
     251                 :         24 :     ScAddress       GetPos() const { return ScAddress( nCol, nRow, nTab ); }
     252                 :            : };
     253                 :            : 
     254                 :        225 : class ScQueryCellIterator           // walk through all non-empty cells in an area
     255                 :            : {
     256                 :            :     enum StopOnMismatchBits
     257                 :            :     {
     258                 :            :         nStopOnMismatchDisabled = 0x00,
     259                 :            :         nStopOnMismatchEnabled  = 0x01,
     260                 :            :         nStopOnMismatchOccurred  = 0x02,
     261                 :            :         nStopOnMismatchExecuted = nStopOnMismatchEnabled | nStopOnMismatchOccurred
     262                 :            :     };
     263                 :            : 
     264                 :            :     enum TestEqualConditionBits
     265                 :            :     {
     266                 :            :         nTestEqualConditionDisabled = 0x00,
     267                 :            :         nTestEqualConditionEnabled  = 0x01,
     268                 :            :         nTestEqualConditionMatched  = 0x02,
     269                 :            :         nTestEqualConditionFulfilled = nTestEqualConditionEnabled | nTestEqualConditionMatched
     270                 :            :     };
     271                 :            : 
     272                 :            : private:
     273                 :            :     boost::scoped_ptr<ScQueryParam> mpParam;
     274                 :            :     ScDocument*     pDoc;
     275                 :            :     const ScAttrArray*  pAttrArray;
     276                 :            :     sal_uLong           nNumFormat;
     277                 :            :     SCTAB           nTab;
     278                 :            :     SCCOL           nCol;
     279                 :            :     SCROW           nRow;
     280                 :            :     SCSIZE          nColRow;
     281                 :            :     SCROW           nAttrEndRow;
     282                 :            :     sal_uInt8            nStopOnMismatch;
     283                 :            :     sal_uInt8            nTestEqualCondition;
     284                 :            :     bool            bAdvanceQuery;
     285                 :            :     bool            bIgnoreMismatchOnLeadingStrings;
     286                 :            : 
     287                 :            :     ScBaseCell*     GetThis();
     288                 :            : 
     289                 :            :                     /* Only works if no regular expression is involved, only
     290                 :            :                        searches for rows in one column, and only the first
     291                 :            :                        query entry is considered with simple conditions
     292                 :            :                        SC_LESS_EQUAL (sorted ascending) or SC_GREATER_EQUAL
     293                 :            :                        (sorted descending). Check these things before
     294                 :            :                        invocation! Delivers a starting point, continue with
     295                 :            :                        GetThis() and GetNext() afterwards. Introduced for
     296                 :            :                        FindEqualOrSortedLastInRange()
     297                 :            :                      */
     298                 :            :     ScBaseCell*     BinarySearch();
     299                 :            : 
     300                 :            : public:
     301                 :            :                     ScQueryCellIterator(ScDocument* pDocument, SCTAB nTable,
     302                 :            :                                         const ScQueryParam& aParam, bool bMod = true);
     303                 :            :                                         // for bMod = FALSE the QueryParam has to be filled
     304                 :            :                                         // (bIsString)
     305                 :            :     ScBaseCell*     GetFirst();
     306                 :            :     ScBaseCell*     GetNext();
     307                 :        132 :     SCCOL           GetCol() { return nCol; }
     308                 :        132 :     SCROW           GetRow() { return nRow; }
     309                 :            : 
     310                 :            :                     // increments all Entry.nField, if column
     311                 :            :                     // changes, for ScInterpreter ScHLookup()
     312                 :         69 :     void            SetAdvanceQueryParamEntryField( bool bVal )
     313                 :         69 :                         { bAdvanceQuery = bVal; }
     314                 :            :     void            AdvanceQueryParamEntryField();
     315                 :            : 
     316                 :            :                     /** If set, iterator stops on first non-matching cell
     317                 :            :                         content. May be used in SC_LESS_EQUAL queries where a
     318                 :            :                         cell range is assumed to be sorted; stops on first
     319                 :            :                         value being greater than the queried value and
     320                 :            :                         GetFirst()/GetNext() return NULL. StoppedOnMismatch()
     321                 :            :                         returns true then.
     322                 :            :                         However, the iterator's conditions are not set to end
     323                 :            :                         all queries, GetCol() and GetRow() return values for
     324                 :            :                         the non-matching cell, further GetNext() calls may be
     325                 :            :                         executed. */
     326                 :        144 :     void            SetStopOnMismatch( bool bVal )
     327                 :            :                         {
     328                 :            :                             nStopOnMismatch = sal::static_int_cast<sal_uInt8>(bVal ? nStopOnMismatchEnabled :
     329         [ +  - ]:        144 :                                 nStopOnMismatchDisabled);
     330                 :        144 :                         }
     331                 :          0 :     bool            StoppedOnMismatch() const
     332                 :          0 :                         { return nStopOnMismatch == nStopOnMismatchExecuted; }
     333                 :            : 
     334                 :            :                     /** If set, an additional test for SC_EQUAL condition is
     335                 :            :                         executed in ScTable::ValidQuery() if SC_LESS_EQUAL or
     336                 :            :                         SC_GREATER_EQUAL conditions are to be tested. May be
     337                 :            :                         used where a cell range is assumed to be sorted to stop
     338                 :            :                         if an equal match is found. */
     339                 :        144 :     void            SetTestEqualCondition( bool bVal )
     340                 :            :                         {
     341                 :            :                             nTestEqualCondition = sal::static_int_cast<sal_uInt8>(bVal ?
     342                 :            :                                 nTestEqualConditionEnabled :
     343         [ +  - ]:        144 :                                 nTestEqualConditionDisabled);
     344                 :        144 :                         }
     345                 :        405 :     bool            IsEqualConditionFulfilled() const
     346                 :        405 :                         { return nTestEqualCondition == nTestEqualConditionFulfilled; }
     347                 :            : 
     348                 :            :                     /** In a range assumed to be sorted find either the last of
     349                 :            :                         a sequence of equal entries or the last being less than
     350                 :            :                         (or greater than) the queried value. Used by the
     351                 :            :                         interpreter for [HV]?LOOKUP() and MATCH(). Column and
     352                 :            :                         row position of the found entry are returned, otherwise
     353                 :            :                         invalid.
     354                 :            : 
     355                 :            :                         @param bSearchForEqualAfterMismatch
     356                 :            :                             Continue searching for an equal entry even if the
     357                 :            :                             last entry matching the range was found, in case
     358                 :            :                             the data is not sorted. Is always done if regular
     359                 :            :                             expressions are involved.
     360                 :            : 
     361                 :            :                         @param bIgnoreMismatchOnLeadingStrings
     362                 :            :                             Normally strings are sorted behind numerical
     363                 :            :                             values. If this parameter is true, the search does
     364                 :            :                             not stop when encountering a string and does not
     365                 :            :                             assume that no values follow anymore.
     366                 :            :                             If querying for a string a mismatch on the first
     367                 :            :                             entry, e.g. column header, is ignored.
     368                 :            : 
     369                 :            :                         @ATTENTION! StopOnMismatch, TestEqualCondition and
     370                 :            :                         the internal IgnoreMismatchOnLeadingStrings and query
     371                 :            :                         params are in an undefined state upon return! The
     372                 :            :                         iterator is not usable anymore except for obtaining the
     373                 :            :                         number format!
     374                 :            :                       */
     375                 :            :     bool            FindEqualOrSortedLastInRange( SCCOL& nFoundCol,
     376                 :            :                         SCROW& nFoundRow, bool bSearchForEqualAfterMismatch = false,
     377                 :            :                         bool bIgnoreMismatchOnLeadingStrings = true );
     378                 :            : };
     379                 :            : 
     380                 :            : class ScDocAttrIterator             // all attribute areas
     381                 :            : {
     382                 :            : private:
     383                 :            :     ScDocument*     pDoc;
     384                 :            :     SCTAB           nTab;
     385                 :            :     SCCOL           nEndCol;
     386                 :            :     SCROW           nStartRow;
     387                 :            :     SCROW           nEndRow;
     388                 :            :     SCCOL           nCol;
     389                 :            :     ScAttrIterator* pColIter;
     390                 :            : 
     391                 :            : public:
     392                 :            :                     ScDocAttrIterator(ScDocument* pDocument, SCTAB nTable,
     393                 :            :                                     SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
     394                 :            :                     ~ScDocAttrIterator();
     395                 :            : 
     396                 :            :     const ScPatternAttr*    GetNext( SCCOL& rCol, SCROW& rRow1, SCROW& rRow2 );
     397                 :            : };
     398                 :            : 
     399                 :            : class ScAttrRectIterator            // all attribute areas, including areas stretching
     400                 :            :                                     // across more then one column
     401                 :            : {
     402                 :            : private:
     403                 :            :     ScDocument*     pDoc;
     404                 :            :     SCTAB           nTab;
     405                 :            :     SCCOL           nEndCol;
     406                 :            :     SCROW           nStartRow;
     407                 :            :     SCROW           nEndRow;
     408                 :            :     SCCOL           nIterStartCol;
     409                 :            :     SCCOL           nIterEndCol;
     410                 :            :     ScAttrIterator* pColIter;
     411                 :            : 
     412                 :            : public:
     413                 :            :                     ScAttrRectIterator(ScDocument* pDocument, SCTAB nTable,
     414                 :            :                                     SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
     415                 :            :                     ~ScAttrRectIterator();
     416                 :            : 
     417                 :            :     void                    DataChanged();
     418                 :            :     const ScPatternAttr*    GetNext( SCCOL& rCol1, SCCOL& rCol2, SCROW& rRow1, SCROW& rRow2 );
     419                 :            : };
     420                 :            : 
     421                 :            : class ScHorizontalCellIterator      // walk through all non empty cells in an area
     422                 :            : {                                   // row by row
     423                 :            : private:
     424                 :            :     ScDocument*     pDoc;
     425                 :            :     SCTAB           nTab;
     426                 :            :     SCCOL           nStartCol;
     427                 :            :     SCCOL           nEndCol;
     428                 :            :    SCROW           nStartRow;
     429                 :            :     SCROW           nEndRow;
     430                 :            :     SCROW*          pNextRows;
     431                 :            :     SCSIZE*         pNextIndices;
     432                 :            :     SCCOL           nCol;
     433                 :            :     SCROW           nRow;
     434                 :            :     bool            bMore;
     435                 :            : 
     436                 :            : public:
     437                 :            :                     ScHorizontalCellIterator(ScDocument* pDocument, SCTAB nTable,
     438                 :            :                                     SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
     439                 :            :                     ~ScHorizontalCellIterator();
     440                 :            : 
     441                 :            :     ScBaseCell*     GetNext( SCCOL& rCol, SCROW& rRow );
     442                 :            :     bool            ReturnNext( SCCOL& rCol, SCROW& rRow );
     443                 :            :     /// Set a(nother) sheet and (re)init.
     444                 :            :     void            SetTab( SCTAB nTab );
     445                 :            : 
     446                 :            : private:
     447                 :            :     void            Advance();
     448                 :            : };
     449                 :            : 
     450                 :            : 
     451                 :            : /** Row-wise value iterator. */
     452                 :            : class ScHorizontalValueIterator
     453                 :            : {
     454                 :            : private:
     455                 :            :     ScDocument               *pDoc;
     456                 :            :     const ScAttrArray        *pAttrArray;
     457                 :            :     ScHorizontalCellIterator *pCellIter;
     458                 :            :     sal_uLong                 nNumFormat;     // for CalcAsShown
     459                 :            :     sal_uLong                 nNumFmtIndex;
     460                 :            :     SCTAB                     nEndTab;
     461                 :            :     SCCOL                     nCurCol;
     462                 :            :     SCROW                     nCurRow;
     463                 :            :     SCTAB                     nCurTab;
     464                 :            :     SCROW                     nAttrEndRow;
     465                 :            :     short                     nNumFmtType;
     466                 :            :     bool                      bNumValid;
     467                 :            :     bool                      bSubTotal;
     468                 :            :     bool                      bCalcAsShown;
     469                 :            :     bool                      bTextAsZero;
     470                 :            : 
     471                 :            : public:
     472                 :            : 
     473                 :            :                     ScHorizontalValueIterator( ScDocument* pDocument,
     474                 :            :                                                const ScRange& rRange,
     475                 :            :                                                bool bSTotal = false,
     476                 :            :                                                bool bTextAsZero = false );
     477                 :            :                     ~ScHorizontalValueIterator();
     478                 :            :     /// Does NOT reset rValue if no value found!
     479                 :            :     bool            GetNext( double& rValue, sal_uInt16& rErr );
     480                 :            : };
     481                 :            : 
     482                 :            : 
     483                 :            : //
     484                 :            : //  returns all areas with non-default formatting (horizontal)
     485                 :            : //
     486                 :            : 
     487                 :            : class ScHorizontalAttrIterator
     488                 :            : {
     489                 :            : private:
     490                 :            :     ScDocument*             pDoc;
     491                 :            :     SCTAB                   nTab;
     492                 :            :     SCCOL                   nStartCol;
     493                 :            :     SCROW                   nStartRow;
     494                 :            :     SCCOL                   nEndCol;
     495                 :            :     SCROW                   nEndRow;
     496                 :            : 
     497                 :            :     SCROW*                  pNextEnd;
     498                 :            :     SCSIZE*                 pIndices;
     499                 :            :     const ScPatternAttr**   ppPatterns;
     500                 :            :     SCCOL                   nCol;
     501                 :            :     SCROW                   nRow;
     502                 :            :     bool                    bRowEmpty;
     503                 :            : 
     504                 :            : public:
     505                 :            :             ScHorizontalAttrIterator( ScDocument* pDocument, SCTAB nTable,
     506                 :            :                                     SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
     507                 :            :             ~ScHorizontalAttrIterator();
     508                 :            : 
     509                 :            :     const ScPatternAttr*    GetNext( SCCOL& rCol1, SCCOL& rCol2, SCROW& rRow );
     510                 :            : };
     511                 :            : 
     512                 :            : //
     513                 :            : //  returns non-empty cells and areas with formatting (horizontal)
     514                 :            : //
     515                 :            : 
     516                 :            : class SC_DLLPUBLIC ScUsedAreaIterator
     517                 :            : {
     518                 :            : private:
     519                 :            :     ScHorizontalCellIterator    aCellIter;
     520                 :            :     ScHorizontalAttrIterator    aAttrIter;
     521                 :            : 
     522                 :            :     SCCOL                   nNextCol;
     523                 :            :     SCROW                   nNextRow;
     524                 :            : 
     525                 :            :     SCCOL                   nCellCol;
     526                 :            :     SCROW                   nCellRow;
     527                 :            :     const ScBaseCell*       pCell;
     528                 :            :     SCCOL                   nAttrCol1;
     529                 :            :     SCCOL                   nAttrCol2;
     530                 :            :     SCROW                   nAttrRow;
     531                 :            :     const ScPatternAttr*    pPattern;
     532                 :            : 
     533                 :            :     SCCOL                   nFoundStartCol;         // results after GetNext
     534                 :            :     SCCOL                   nFoundEndCol;
     535                 :            :     SCROW                   nFoundRow;
     536                 :            :     const ScPatternAttr*    pFoundPattern;
     537                 :            :     const ScBaseCell*       pFoundCell;
     538                 :            : 
     539                 :            : public:
     540                 :            :             ScUsedAreaIterator( ScDocument* pDocument, SCTAB nTable,
     541                 :            :                                 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
     542                 :            :             ~ScUsedAreaIterator();
     543                 :            : 
     544                 :            :     bool    GetNext();
     545                 :            : 
     546                 :          0 :     SCCOL                   GetStartCol() const     { return nFoundStartCol; }
     547                 :          0 :     SCCOL                   GetEndCol() const       { return nFoundEndCol; }
     548                 :          0 :     SCROW                   GetRow() const          { return nFoundRow; }
     549                 :          0 :     const ScPatternAttr*    GetPattern() const      { return pFoundPattern; }
     550                 :          0 :     const ScBaseCell*       GetCell() const         { return pFoundCell; }
     551                 :            : };
     552                 :            : 
     553                 :            : class ScRowBreakIterator
     554                 :            : {
     555                 :            : public:
     556                 :            :     static SCROW NOT_FOUND;
     557                 :            : 
     558                 :            :     explicit ScRowBreakIterator(::std::set<SCROW>& rBreaks);
     559                 :            :     SCROW first();
     560                 :            :     SCROW next();
     561                 :            : 
     562                 :            : private:
     563                 :            :     ::std::set<SCROW>& mrBreaks;
     564                 :            :     ::std::set<SCROW>::const_iterator maItr;
     565                 :            :     ::std::set<SCROW>::const_iterator maEnd;
     566                 :            : };
     567                 :            : 
     568                 :            : class ScDocRowHeightUpdater
     569                 :            : {
     570                 :            : public:
     571                 :          0 :     struct TabRanges
     572                 :            :     {
     573                 :            :         SCTAB mnTab;
     574                 :            :         ::boost::shared_ptr<ScFlatBoolRowSegments> mpRanges;
     575                 :            : 
     576                 :            :         TabRanges(SCTAB nTab);
     577                 :            :     };
     578                 :            : 
     579                 :            :     /**
     580                 :            :      * Passing a NULL pointer to pTabRangesArray forces the heights of all
     581                 :            :      * rows in all tables to be updated.
     582                 :            :      */
     583                 :            :     explicit ScDocRowHeightUpdater(
     584                 :            :         ScDocument& rDoc, OutputDevice* pOutDev, double fPPTX, double fPPTY,
     585                 :            :         const ::std::vector<TabRanges>* pTabRangesArray = NULL);
     586                 :            : 
     587                 :            :     void update();
     588                 :            : 
     589                 :            : private:
     590                 :            :     void updateAll();
     591                 :            : 
     592                 :            : private:
     593                 :            :     ScDocument& mrDoc;
     594                 :            :     OutputDevice* mpOutDev;
     595                 :            :     double mfPPTX;
     596                 :            :     double mfPPTY;
     597                 :            :     const ::std::vector<TabRanges>* mpTabRangesArray;
     598                 :            : };
     599                 :            : 
     600                 :            : 
     601                 :            : #endif
     602                 :            : 
     603                 :            : 
     604                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10