LCOV - code coverage report
Current view: top level - sc/inc - attarray.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 20 21 95.2 %
Date: 2012-08-25 Functions: 6 7 85.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 6 100.0 %

           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_ATRARR_HXX
      30                 :            : #define SC_ATRARR_HXX
      31                 :            : 
      32                 :            : #include "global.hxx"
      33                 :            : #include "attrib.hxx"
      34                 :            : 
      35                 :            : class ScDocument;
      36                 :            : class ScEditDataArray;
      37                 :            : class ScMarkArray;
      38                 :            : class ScPatternAttr;
      39                 :            : class ScStyleSheet;
      40                 :            : class ScFlatBoolRowSegments;
      41                 :            : 
      42                 :            : class SfxItemPoolCache;
      43                 :            : class SfxStyleSheetBase;
      44                 :            : class SvxBoxItem;
      45                 :            : class SvxBoxInfoItem;
      46                 :            : 
      47                 :            : namespace editeng { class SvxBorderLine; }
      48                 :            : 
      49                 :            : #define SC_LINE_EMPTY           0
      50                 :            : #define SC_LINE_SET             1
      51                 :            : #define SC_LINE_DONTCARE        2
      52                 :            : 
      53                 :            : #define SC_ATTRARRAY_DELTA      4
      54                 :            : 
      55                 :            : struct ScLineFlags
      56                 :            : {
      57                 :            :     sal_uInt8   nLeft;
      58                 :            :     sal_uInt8   nRight;
      59                 :            :     sal_uInt8   nTop;
      60                 :            :     sal_uInt8   nBottom;
      61                 :            :     sal_uInt8   nHori;
      62                 :            :     sal_uInt8   nVert;
      63                 :            : 
      64                 :         50 :     ScLineFlags() : nLeft(SC_LINE_EMPTY),nRight(SC_LINE_EMPTY),nTop(SC_LINE_EMPTY),
      65                 :         50 :                     nBottom(SC_LINE_EMPTY),nHori(SC_LINE_EMPTY),nVert(SC_LINE_EMPTY) {}
      66                 :            : };
      67                 :            : 
      68                 :            : struct ScMergePatternState
      69                 :            : {
      70                 :            :     SfxItemSet* pItemSet;           // allocated in MergePatternArea, used for resulting ScPatternAttr
      71                 :            :     const ScPatternAttr* pOld1;     // existing objects, temporary
      72                 :            :     const ScPatternAttr* pOld2;
      73                 :            : 
      74                 :       7303 :     ScMergePatternState() : pItemSet(NULL), pOld1(NULL), pOld2(NULL) {}
      75                 :            : };
      76                 :            : 
      77                 :            : struct ScAttrEntry
      78                 :            : {
      79                 :            :     SCROW                   nRow;
      80                 :            :     const ScPatternAttr*    pPattern;
      81                 :            : };
      82                 :            : 
      83                 :            : 
      84                 :            : class ScAttrArray
      85                 :            : {
      86                 :            : private:
      87                 :            :     SCCOL           nCol;
      88                 :            :     SCTAB           nTab;
      89                 :            :     ScDocument*     pDocument;
      90                 :            : 
      91                 :            :     SCSIZE          nCount;
      92                 :            :     SCSIZE          nLimit;
      93                 :            :     ScAttrEntry*    pData;
      94                 :            : 
      95                 :            : friend class ScDocument;                // for FillInfo
      96                 :            : friend class ScDocumentIterator;
      97                 :            : friend class ScAttrIterator;
      98                 :            : friend class ScHorizontalAttrIterator;
      99                 :            : friend void lcl_IterGetNumberFormat( sal_uLong& nFormat,
     100                 :            :         const ScAttrArray*& rpArr, SCROW& nAttrEndRow,
     101                 :            :         const ScAttrArray* pNewArr, SCROW nRow, ScDocument* pDoc );
     102                 :            : 
     103                 :            :     bool    ApplyFrame( const SvxBoxItem* pLineOuter, const SvxBoxInfoItem* pLineInner,
     104                 :            :                             SCROW nStartRow, SCROW nEndRow,
     105                 :            :                             bool bLeft, SCCOL nDistRight, bool bTop, SCROW nDistBottom );
     106                 :            : 
     107                 :            :     void RemoveCellCharAttribs( SCROW nStartRow, SCROW nEndRow,
     108                 :            :                               const ScPatternAttr* pPattern, ScEditDataArray* pDataArray );
     109                 :            : 
     110                 :            : public:
     111                 :            :             ScAttrArray( SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc );
     112                 :            :             ~ScAttrArray();
     113                 :            : 
     114                 :     183296 :     void    SetTab(SCTAB nNewTab)   { nTab = nNewTab; }
     115                 :      16364 :     void    SetCol(SCCOL nNewCol)   { nCol = nNewCol; }
     116                 :            : #if OSL_DEBUG_LEVEL > 1
     117                 :            :     void    TestData() const;
     118                 :            : #endif
     119                 :            :     void    Reset( const ScPatternAttr* pPattern, bool bAlloc = sal_True );
     120                 :            :     bool    Concat(SCSIZE nPos);
     121                 :            : 
     122                 :            :     const ScPatternAttr* GetPattern( SCROW nRow ) const;
     123                 :            :     const ScPatternAttr* GetPatternRange( SCROW& rStartRow, SCROW& rEndRow, SCROW nRow ) const;
     124                 :            :     void    MergePatternArea( SCROW nStartRow, SCROW nEndRow, ScMergePatternState& rState, bool bDeep ) const;
     125                 :            : 
     126                 :            :     void    MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner, ScLineFlags& rFlags,
     127                 :            :                             SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight ) const;
     128                 :            :     void    ApplyBlockFrame( const SvxBoxItem* pLineOuter, const SvxBoxInfoItem* pLineInner,
     129                 :            :                             SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight );
     130                 :            : 
     131                 :            :     void    SetPattern( SCROW nRow, const ScPatternAttr* pPattern, bool bPutToPool = false );
     132                 :            :     void    SetPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr* pPattern,
     133                 :            :                             bool bPutToPool = false, ScEditDataArray* pDataArray = NULL );
     134                 :            :     void    ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, ScStyleSheet* pStyle );
     135                 :            :     void    ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCache* pCache,
     136                 :            :                             ScEditDataArray* pDataArray = NULL );
     137                 :            :     bool    SetAttrEntries(ScAttrEntry* pNewData, SCSIZE nSize);
     138                 :            :     void    ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow,
     139                 :            :                                 const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
     140                 :            : 
     141                 :            :     void    ClearItems( SCROW nStartRow, SCROW nEndRow, const sal_uInt16* pWhich );
     142                 :            :     void    ChangeIndent( SCROW nStartRow, SCROW nEndRow, bool bIncrement );
     143                 :            : 
     144                 :            :             /// Including current, may return -1
     145                 :            :     SCsROW  GetNextUnprotected( SCsROW nRow, bool bUp ) const;
     146                 :            : 
     147                 :            :             /// May return -1 if not found
     148                 :            :     SCsROW  SearchStyle( SCsROW nRow, const ScStyleSheet* pSearchStyle,
     149                 :            :                             bool bUp, ScMarkArray* pMarkArray = NULL );
     150                 :            :     bool    SearchStyleRange( SCsROW& rRow, SCsROW& rEndRow, const ScStyleSheet* pSearchStyle,
     151                 :            :                             bool bUp, ScMarkArray* pMarkArray = NULL );
     152                 :            : 
     153                 :            :     bool    ApplyFlags( SCROW nStartRow, SCROW nEndRow, sal_Int16 nFlags );
     154                 :            :     bool    RemoveFlags( SCROW nStartRow, SCROW nEndRow, sal_Int16 nFlags );
     155                 :            : 
     156                 :            :     bool    Search( SCROW nRow, SCSIZE& nIndex ) const;
     157                 :            : 
     158                 :            :     bool    HasAttrib( SCROW nRow1, SCROW nRow2, sal_uInt16 nMask ) const;
     159                 :            :     bool    ExtendMerge( SCCOL nThisCol, SCROW nStartRow, SCROW nEndRow,
     160                 :            :                                 SCCOL& rPaintCol, SCROW& rPaintRow,
     161                 :            :                                 bool bRefresh );
     162                 :            :     bool    RemoveAreaMerge( SCROW nStartRow, SCROW nEndRow );
     163                 :            : 
     164                 :            :     void    FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBoolRowSegments& rUsedRows, bool bReset );
     165                 :            :     bool    IsStyleSheetUsed( const ScStyleSheet& rStyle, bool bGatherAllStyles ) const;
     166                 :            : 
     167                 :            :     void    DeleteAreaSafe(SCROW nStartRow, SCROW nEndRow);
     168                 :            :     void    SetPatternAreaSafe( SCROW nStartRow, SCROW nEndRow,
     169                 :            :                                     const ScPatternAttr* pWantedPattern, bool bDefault );
     170                 :            :     void    CopyAreaSafe( SCROW nStartRow, SCROW nEndRow, long nDy, ScAttrArray& rAttrArray );
     171                 :            : 
     172                 :            :     bool    IsEmpty() const;
     173                 :            : 
     174                 :            :     bool    GetFirstVisibleAttr( SCROW& rFirstRow ) const;
     175                 :            :     bool    GetLastVisibleAttr( SCROW& rLastRow, SCROW nLastData, bool bFullFormattedArea = false ) const;
     176                 :            :     bool    HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const;
     177                 :            :     bool    IsVisibleEqual( const ScAttrArray& rOther,
     178                 :            :                             SCROW nStartRow, SCROW nEndRow ) const;
     179                 :            :     bool    IsAllEqual( const ScAttrArray& rOther, SCROW nStartRow, SCROW nEndRow ) const;
     180                 :            : 
     181                 :            :     bool    TestInsertCol( SCROW nStartRow, SCROW nEndRow) const;
     182                 :            :     bool    TestInsertRow( SCSIZE nSize ) const;
     183                 :            :     void    InsertRow( SCROW nStartRow, SCSIZE nSize );
     184                 :            :     void    DeleteRow( SCROW nStartRow, SCSIZE nSize );
     185                 :            :     void    DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex );
     186                 :            :     void    DeleteArea( SCROW nStartRow, SCROW nEndRow );
     187                 :            :     void    MoveTo( SCROW nStartRow, SCROW nEndRow, ScAttrArray& rAttrArray );
     188                 :            :     void    CopyArea( SCROW nStartRow, SCROW nEndRow, long nDy, ScAttrArray& rAttrArray,
     189                 :            :                         sal_Int16 nStripFlags = 0 );
     190                 :            : 
     191                 :            :     void    DeleteHardAttr( SCROW nStartRow, SCROW nEndRow );
     192                 :            : };
     193                 :            : 
     194                 :            : 
     195                 :            : //  ------------------------------------------------------------------------------
     196                 :            : //                              Iterator for attributes
     197                 :            : //  ------------------------------------------------------------------------------
     198                 :            : 
     199                 :            : class ScAttrIterator
     200                 :            : {
     201                 :            :     const ScAttrArray*  pArray;
     202                 :            :     SCSIZE              nPos;
     203                 :            :     SCROW               nRow;
     204                 :            :     SCROW               nEndRow;
     205                 :            : public:
     206                 :            :     inline              ScAttrIterator( const ScAttrArray* pNewArray, SCROW nStart, SCROW nEnd );
     207                 :            :     inline const ScPatternAttr* Next( SCROW& rTop, SCROW& rBottom );
     208                 :          0 :     SCROW               GetNextRow() const { return nRow; }
     209                 :            : };
     210                 :            : 
     211                 :            : 
     212                 :    2400571 : inline ScAttrIterator::ScAttrIterator( const ScAttrArray* pNewArray, SCROW nStart, SCROW nEnd ) :
     213                 :            :     pArray( pNewArray ),
     214                 :            :     nRow( nStart ),
     215                 :    2400571 :     nEndRow( nEnd )
     216                 :            : {
     217         [ +  + ]:    2400571 :     if ( nStart > 0 )
     218                 :     350224 :         pArray->Search( nStart, nPos );
     219                 :            :     else
     220                 :    2050347 :         nPos = 0;
     221                 :    2400571 : }
     222                 :            : 
     223                 :    4803236 : inline const ScPatternAttr* ScAttrIterator::Next( SCROW& rTop, SCROW& rBottom )
     224                 :            : {
     225                 :            :     const ScPatternAttr* pRet;
     226 [ +  + ][ +  + ]:    4803236 :     if ( nPos < pArray->nCount && nRow <= nEndRow )
     227                 :            :     {
     228                 :    2402765 :         rTop = nRow;
     229                 :    2402765 :         rBottom = Min( pArray->pData[nPos].nRow, nEndRow );
     230                 :    2402765 :         pRet = pArray->pData[nPos].pPattern;
     231                 :    2402765 :         nRow = rBottom + 1;
     232                 :    2402765 :         ++nPos;
     233                 :            :     }
     234                 :            :     else
     235                 :    2400471 :         pRet = NULL;
     236                 :    4803236 :     return pRet;
     237                 :            : }
     238                 :            : 
     239                 :            : 
     240                 :            : 
     241                 :            : #endif
     242                 :            : 
     243                 :            : 
     244                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10