LCOV - code coverage report
Current view: top level - libreoffice/sc/inc - attarray.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 18 21 85.7 %
Date: 2012-12-27 Functions: 5 7 71.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef SC_ATRARR_HXX
      21             : #define SC_ATRARR_HXX
      22             : 
      23             : #include "global.hxx"
      24             : #include "attrib.hxx"
      25             : 
      26             : class ScDocument;
      27             : class ScEditDataArray;
      28             : class ScMarkArray;
      29             : class ScPatternAttr;
      30             : class ScStyleSheet;
      31             : class ScFlatBoolRowSegments;
      32             : 
      33             : class SfxItemPoolCache;
      34             : class SfxStyleSheetBase;
      35             : class SvxBoxItem;
      36             : class SvxBoxInfoItem;
      37             : 
      38             : namespace editeng { class SvxBorderLine; }
      39             : 
      40             : #define SC_LINE_EMPTY           0
      41             : #define SC_LINE_SET             1
      42             : #define SC_LINE_DONTCARE        2
      43             : 
      44             : #define SC_ATTRARRAY_DELTA      4
      45             : 
      46             : struct ScLineFlags
      47             : {
      48             :     sal_uInt8   nLeft;
      49             :     sal_uInt8   nRight;
      50             :     sal_uInt8   nTop;
      51             :     sal_uInt8   nBottom;
      52             :     sal_uInt8   nHori;
      53             :     sal_uInt8   nVert;
      54             : 
      55           0 :     ScLineFlags() : nLeft(SC_LINE_EMPTY),nRight(SC_LINE_EMPTY),nTop(SC_LINE_EMPTY),
      56           0 :                     nBottom(SC_LINE_EMPTY),nHori(SC_LINE_EMPTY),nVert(SC_LINE_EMPTY) {}
      57             : };
      58             : 
      59             : struct ScMergePatternState
      60             : {
      61             :     SfxItemSet* pItemSet;           ///< allocated in MergePatternArea, used for resulting ScPatternAttr
      62             :     const ScPatternAttr* pOld1;     ///< existing objects, temporary
      63             :     const ScPatternAttr* pOld2;
      64             : 
      65         185 :     ScMergePatternState() : pItemSet(NULL), pOld1(NULL), pOld2(NULL) {}
      66             : };
      67             : 
      68             : struct ScAttrEntry
      69             : {
      70             :     SCROW                   nRow;
      71             :     const ScPatternAttr*    pPattern;
      72             : };
      73             : 
      74             : 
      75             : class ScAttrArray
      76             : {
      77             : private:
      78             :     SCCOL           nCol;
      79             :     SCTAB           nTab;
      80             :     ScDocument*     pDocument;
      81             : 
      82             :     SCSIZE          nCount;
      83             :     SCSIZE          nLimit;
      84             :     ScAttrEntry*    pData;
      85             : 
      86             : friend class ScDocument;                // for FillInfo
      87             : friend class ScDocumentIterator;
      88             : friend class ScAttrIterator;
      89             : friend class ScHorizontalAttrIterator;
      90             : friend void ScAttrArray_IterGetNumberFormat( sal_uLong& nFormat,
      91             :         const ScAttrArray*& rpArr, SCROW& nAttrEndRow,
      92             :         const ScAttrArray* pNewArr, SCROW nRow, ScDocument* pDoc );
      93             : 
      94             :     bool    ApplyFrame( const SvxBoxItem* pLineOuter, const SvxBoxInfoItem* pLineInner,
      95             :                             SCROW nStartRow, SCROW nEndRow,
      96             :                             bool bLeft, SCCOL nDistRight, bool bTop, SCROW nDistBottom );
      97             : 
      98             :     void RemoveCellCharAttribs( SCROW nStartRow, SCROW nEndRow,
      99             :                               const ScPatternAttr* pPattern, ScEditDataArray* pDataArray );
     100             : 
     101             : public:
     102             :             ScAttrArray( SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc );
     103             :             ~ScAttrArray();
     104             : 
     105       40960 :     void    SetTab(SCTAB nNewTab)   { nTab = nNewTab; }
     106        6130 :     void    SetCol(SCCOL nNewCol)   { nCol = nNewCol; }
     107             : #if OSL_DEBUG_LEVEL > 1
     108             :     void    TestData() const;
     109             : #endif
     110             :     void    Reset( const ScPatternAttr* pPattern, bool bAlloc = sal_True );
     111             :     bool    Concat(SCSIZE nPos);
     112             : 
     113             :     const ScPatternAttr* GetPattern( SCROW nRow ) const;
     114             :     const ScPatternAttr* GetPatternRange( SCROW& rStartRow, SCROW& rEndRow, SCROW nRow ) const;
     115             :     void    MergePatternArea( SCROW nStartRow, SCROW nEndRow, ScMergePatternState& rState, bool bDeep ) const;
     116             : 
     117             :     void    MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner, ScLineFlags& rFlags,
     118             :                             SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight ) const;
     119             :     void    ApplyBlockFrame( const SvxBoxItem* pLineOuter, const SvxBoxInfoItem* pLineInner,
     120             :                             SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight );
     121             : 
     122             :     void    SetPattern( SCROW nRow, const ScPatternAttr* pPattern, bool bPutToPool = false );
     123             :     void    SetPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr* pPattern,
     124             :                             bool bPutToPool = false, ScEditDataArray* pDataArray = NULL );
     125             :     void    ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, ScStyleSheet* pStyle );
     126             :     void    ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCache* pCache,
     127             :                             ScEditDataArray* pDataArray = NULL );
     128             :     bool    SetAttrEntries(ScAttrEntry* pNewData, SCSIZE nSize);
     129             :     void    ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow,
     130             :                                 const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
     131             : 
     132             :     void    AddCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
     133             :     void    RemoveCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
     134             : 
     135             :     void    ClearItems( SCROW nStartRow, SCROW nEndRow, const sal_uInt16* pWhich );
     136             :     void    ChangeIndent( SCROW nStartRow, SCROW nEndRow, bool bIncrement );
     137             : 
     138             :             /// Including current, may return -1
     139             :     SCsROW  GetNextUnprotected( SCsROW nRow, bool bUp ) const;
     140             : 
     141             :             /// May return -1 if not found
     142             :     SCsROW SearchStyle(
     143             :         SCsROW nRow, const ScStyleSheet* pSearchStyle, bool bUp,
     144             :         const ScMarkArray* pMarkArray = NULL) const;
     145             : 
     146             :     bool SearchStyleRange(
     147             :         SCsROW& rRow, SCsROW& rEndRow, const ScStyleSheet* pSearchStyle, bool bUp,
     148             :         const ScMarkArray* pMarkArray = NULL) const;
     149             : 
     150             :     bool    ApplyFlags( SCROW nStartRow, SCROW nEndRow, sal_Int16 nFlags );
     151             :     bool    RemoveFlags( SCROW nStartRow, SCROW nEndRow, sal_Int16 nFlags );
     152             : 
     153             :     bool    Search( SCROW nRow, SCSIZE& nIndex ) const;
     154             : 
     155             :     bool    HasAttrib( SCROW nRow1, SCROW nRow2, sal_uInt16 nMask ) const;
     156             :     bool    ExtendMerge( SCCOL nThisCol, SCROW nStartRow, SCROW nEndRow,
     157             :                                 SCCOL& rPaintCol, SCROW& rPaintRow,
     158             :                                 bool bRefresh );
     159             :     bool    RemoveAreaMerge( SCROW nStartRow, SCROW nEndRow );
     160             : 
     161             :     void    FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBoolRowSegments& rUsedRows, bool bReset );
     162             :     bool    IsStyleSheetUsed( const ScStyleSheet& rStyle, bool bGatherAllStyles ) const;
     163             : 
     164             :     void    DeleteAreaSafe(SCROW nStartRow, SCROW nEndRow);
     165             :     void    SetPatternAreaSafe( SCROW nStartRow, SCROW nEndRow,
     166             :                                     const ScPatternAttr* pWantedPattern, bool bDefault );
     167             :     void    CopyAreaSafe( SCROW nStartRow, SCROW nEndRow, long nDy, ScAttrArray& rAttrArray );
     168             : 
     169             :     bool    IsEmpty() const;
     170             : 
     171             :     bool    GetFirstVisibleAttr( SCROW& rFirstRow ) const;
     172             :     bool    GetLastVisibleAttr( SCROW& rLastRow, SCROW nLastData, bool bFullFormattedArea = false ) const;
     173             :     bool    HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const;
     174             :     bool    IsVisibleEqual( const ScAttrArray& rOther,
     175             :                             SCROW nStartRow, SCROW nEndRow ) const;
     176             :     bool    IsAllEqual( const ScAttrArray& rOther, SCROW nStartRow, SCROW nEndRow ) const;
     177             : 
     178             :     bool    TestInsertCol( SCROW nStartRow, SCROW nEndRow) const;
     179             :     bool    TestInsertRow( SCSIZE nSize ) const;
     180             :     void    InsertRow( SCROW nStartRow, SCSIZE nSize );
     181             :     void    DeleteRow( SCROW nStartRow, SCSIZE nSize );
     182             :     void    DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex );
     183             :     void    DeleteArea( SCROW nStartRow, SCROW nEndRow );
     184             :     void    MoveTo( SCROW nStartRow, SCROW nEndRow, ScAttrArray& rAttrArray );
     185             :     void    CopyArea(
     186             :         SCROW nStartRow, SCROW nEndRow, long nDy, ScAttrArray& rAttrArray, sal_Int16 nStripFlags = 0) const;
     187             : 
     188             :     void    DeleteHardAttr( SCROW nStartRow, SCROW nEndRow );
     189             : };
     190             : 
     191             : 
     192             : //  ------------------------------------------------------------------------------
     193             : //                              Iterator for attributes
     194             : //  ------------------------------------------------------------------------------
     195             : 
     196             : class ScAttrIterator
     197             : {
     198             :     const ScAttrArray*  pArray;
     199             :     SCSIZE              nPos;
     200             :     SCROW               nRow;
     201             :     SCROW               nEndRow;
     202             : public:
     203             :     inline              ScAttrIterator( const ScAttrArray* pNewArray, SCROW nStart, SCROW nEnd );
     204             :     inline const ScPatternAttr* Next( SCROW& rTop, SCROW& rBottom );
     205           0 :     SCROW               GetNextRow() const { return nRow; }
     206             : };
     207             : 
     208             : 
     209      269321 : inline ScAttrIterator::ScAttrIterator( const ScAttrArray* pNewArray, SCROW nStart, SCROW nEnd ) :
     210             :     pArray( pNewArray ),
     211             :     nRow( nStart ),
     212      269321 :     nEndRow( nEnd )
     213             : {
     214      269321 :     if ( nStart > 0 )
     215        5120 :         pArray->Search( nStart, nPos );
     216             :     else
     217      264201 :         nPos = 0;
     218      269321 : }
     219             : 
     220      538844 : inline const ScPatternAttr* ScAttrIterator::Next( SCROW& rTop, SCROW& rBottom )
     221             : {
     222             :     const ScPatternAttr* pRet;
     223      538844 :     if ( nPos < pArray->nCount && nRow <= nEndRow )
     224             :     {
     225      269530 :         rTop = nRow;
     226      269530 :         rBottom = Min( pArray->pData[nPos].nRow, nEndRow );
     227      269530 :         pRet = pArray->pData[nPos].pPattern;
     228      269530 :         nRow = rBottom + 1;
     229      269530 :         ++nPos;
     230             :     }
     231             :     else
     232      269314 :         pRet = NULL;
     233      538844 :     return pRet;
     234             : }
     235             : 
     236             : 
     237             : 
     238             : #endif
     239             : 
     240             : 
     241             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10