Files
libreoffice/sc/inc/attarray.hxx

246 lines
9.1 KiB
C++
Raw Normal View History

2010-10-27 12:43:08 +01:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2000-09-18 16:07:07 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 16:07:07 +00:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-09-18 16:07:07 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 16:07:07 +00:00
*
* This file is part of OpenOffice.org.
2000-09-18 16:07:07 +00:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2000-09-18 16:07:07 +00:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2000-09-18 16:07:07 +00:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2000-09-18 16:07:07 +00:00
*
************************************************************************/
#ifndef SC_ATRARR_HXX
#define SC_ATRARR_HXX
#include "global.hxx"
#include "attrib.hxx"
class ScDocument;
class ScEditDataArray;
2000-09-18 16:07:07 +00:00
class ScMarkArray;
class ScPatternAttr;
class ScStyleSheet;
class ScFlatBoolRowSegments;
2000-09-18 16:07:07 +00:00
class Rectangle;
class SfxItemPoolCache;
class SfxStyleSheetBase;
class SvxBoxItem;
class SvxBoxInfoItem;
namespace editeng { class SvxBorderLine; }
2000-09-18 16:07:07 +00:00
#define SC_LINE_EMPTY 0
#define SC_LINE_SET 1
#define SC_LINE_DONTCARE 2
#define SC_ATTRARRAY_DELTA 4
2000-09-18 16:07:07 +00:00
struct ScLineFlags
{
sal_uInt8 nLeft;
sal_uInt8 nRight;
sal_uInt8 nTop;
sal_uInt8 nBottom;
sal_uInt8 nHori;
sal_uInt8 nVert;
2000-09-18 16:07:07 +00:00
ScLineFlags() : nLeft(SC_LINE_EMPTY),nRight(SC_LINE_EMPTY),nTop(SC_LINE_EMPTY),
nBottom(SC_LINE_EMPTY),nHori(SC_LINE_EMPTY),nVert(SC_LINE_EMPTY) {}
};
struct ScMergePatternState
{
SfxItemSet* pItemSet; // allocated in MergePatternArea, used for resulting ScPatternAttr
const ScPatternAttr* pOld1; // existing objects, temporary
const ScPatternAttr* pOld2;
ScMergePatternState() : pItemSet(NULL), pOld1(NULL), pOld2(NULL) {}
};
2000-09-18 16:07:07 +00:00
struct ScAttrEntry
{
SCROW nRow;
2000-09-18 16:07:07 +00:00
const ScPatternAttr* pPattern;
};
class ScAttrArray
{
private:
SCCOL nCol;
SCTAB nTab;
2000-09-18 16:07:07 +00:00
ScDocument* pDocument;
SCSIZE nCount;
SCSIZE nLimit;
2000-09-18 16:07:07 +00:00
ScAttrEntry* pData;
2011-03-10 21:56:49 +01:00
friend class ScDocument; // for FillInfo
2000-09-18 16:07:07 +00:00
friend class ScDocumentIterator;
friend class ScAttrIterator;
friend class ScHorizontalAttrIterator;
friend void lcl_IterGetNumberFormat( sal_uLong& nFormat,
const ScAttrArray*& rpArr, SCROW& nAttrEndRow,
const ScAttrArray* pNewArr, SCROW nRow, ScDocument* pDoc );
2000-09-18 16:07:07 +00:00
2011-11-10 15:21:48 +01:00
bool ApplyFrame( const SvxBoxItem* pLineOuter, const SvxBoxInfoItem* pLineInner,
SCROW nStartRow, SCROW nEndRow,
2011-11-10 15:21:48 +01:00
bool bLeft, SCCOL nDistRight, bool bTop, SCROW nDistBottom );
2000-09-18 16:07:07 +00:00
void RemoveCellCharAttribs( SCROW nStartRow, SCROW nEndRow,
const ScPatternAttr* pPattern, ScEditDataArray* pDataArray );
2000-09-18 16:07:07 +00:00
public:
ScAttrArray( SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc );
2000-09-18 16:07:07 +00:00
~ScAttrArray();
void SetTab(SCTAB nNewTab) { nTab = nNewTab; }
void SetCol(SCCOL nNewCol) { nCol = nNewCol; }
#if OSL_DEBUG_LEVEL > 1
2000-09-18 16:07:07 +00:00
void TestData() const;
#endif
2011-11-10 15:21:48 +01:00
void Reset( const ScPatternAttr* pPattern, bool bAlloc = sal_True );
bool Concat(SCSIZE nPos);
2000-09-18 16:07:07 +00:00
const ScPatternAttr* GetPattern( SCROW nRow ) const;
const ScPatternAttr* GetPatternRange( SCROW& rStartRow, SCROW& rEndRow, SCROW nRow ) const;
2011-11-10 15:21:48 +01:00
void MergePatternArea( SCROW nStartRow, SCROW nEndRow, ScMergePatternState& rState, bool bDeep ) const;
2000-09-18 16:07:07 +00:00
void MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner, ScLineFlags& rFlags,
2011-11-10 15:21:48 +01:00
SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight ) const;
2000-09-18 16:07:07 +00:00
void ApplyBlockFrame( const SvxBoxItem* pLineOuter, const SvxBoxInfoItem* pLineInner,
2011-11-10 15:21:48 +01:00
SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight );
2000-09-18 16:07:07 +00:00
2011-11-10 15:21:48 +01:00
void SetPattern( SCROW nRow, const ScPatternAttr* pPattern, bool bPutToPool = false );
void SetPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr* pPattern,
2011-11-10 15:21:48 +01:00
bool bPutToPool = false, ScEditDataArray* pDataArray = NULL );
void ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, ScStyleSheet* pStyle );
void ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCache* pCache,
ScEditDataArray* pDataArray = NULL );
bool SetAttrEntries(ScAttrEntry* pNewData, SCSIZE nSize);
void ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow,
2011-11-10 15:21:48 +01:00
const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
2000-09-18 16:07:07 +00:00
void ClearItems( SCROW nStartRow, SCROW nEndRow, const sal_uInt16* pWhich );
2011-11-10 15:21:48 +01:00
void ChangeIndent( SCROW nStartRow, SCROW nEndRow, bool bIncrement );
2000-09-18 16:07:07 +00:00
/// Including current, may return -1
2011-11-10 15:21:48 +01:00
SCsROW GetNextUnprotected( SCsROW nRow, bool bUp ) const;
2000-09-18 16:07:07 +00:00
/// May return -1 if not found
SCsROW SearchStyle( SCsROW nRow, const ScStyleSheet* pSearchStyle,
2011-11-10 15:21:48 +01:00
bool bUp, ScMarkArray* pMarkArray = NULL );
bool SearchStyleRange( SCsROW& rRow, SCsROW& rEndRow, const ScStyleSheet* pSearchStyle,
bool bUp, ScMarkArray* pMarkArray = NULL );
2000-09-18 16:07:07 +00:00
2011-11-10 15:21:48 +01:00
bool ApplyFlags( SCROW nStartRow, SCROW nEndRow, sal_Int16 nFlags );
bool RemoveFlags( SCROW nStartRow, SCROW nEndRow, sal_Int16 nFlags );
2000-09-18 16:07:07 +00:00
2011-11-10 15:21:48 +01:00
bool Search( SCROW nRow, SCSIZE& nIndex ) const;
2000-09-18 16:07:07 +00:00
bool HasAttrib( SCROW nRow1, SCROW nRow2, sal_uInt16 nMask ) const;
2011-11-10 15:21:48 +01:00
bool ExtendMerge( SCCOL nThisCol, SCROW nStartRow, SCROW nEndRow,
SCCOL& rPaintCol, SCROW& rPaintRow,
2011-11-10 15:21:48 +01:00
bool bRefresh );
bool RemoveAreaMerge( SCROW nStartRow, SCROW nEndRow );
2000-09-18 16:07:07 +00:00
void FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBoolRowSegments& rUsedRows, bool bReset );
2011-11-10 15:21:48 +01:00
bool IsStyleSheetUsed( const ScStyleSheet& rStyle, bool bGatherAllStyles ) const;
2000-09-18 16:07:07 +00:00
void DeleteAreaSafe(SCROW nStartRow, SCROW nEndRow);
void SetPatternAreaSafe( SCROW nStartRow, SCROW nEndRow,
2011-11-10 15:21:48 +01:00
const ScPatternAttr* pWantedPattern, bool bDefault );
void CopyAreaSafe( SCROW nStartRow, SCROW nEndRow, long nDy, ScAttrArray& rAttrArray );
2000-09-18 16:07:07 +00:00
2011-11-10 15:21:48 +01:00
bool IsEmpty() const;
2000-09-18 16:07:07 +00:00
2011-11-10 15:21:48 +01:00
bool GetFirstVisibleAttr( SCROW& rFirstRow ) const;
bool GetLastVisibleAttr( SCROW& rLastRow, SCROW nLastData, bool bFullFormattedArea = false ) const;
2011-11-10 15:21:48 +01:00
bool HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const;
bool IsVisibleEqual( const ScAttrArray& rOther,
SCROW nStartRow, SCROW nEndRow ) const;
2011-11-10 15:21:48 +01:00
bool IsAllEqual( const ScAttrArray& rOther, SCROW nStartRow, SCROW nEndRow ) const;
2011-11-10 15:21:48 +01:00
bool TestInsertCol( SCROW nStartRow, SCROW nEndRow) const;
bool TestInsertRow( SCSIZE nSize ) const;
void InsertRow( SCROW nStartRow, SCSIZE nSize );
void DeleteRow( SCROW nStartRow, SCSIZE nSize );
void DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex );
void DeleteArea( SCROW nStartRow, SCROW nEndRow );
void MoveTo( SCROW nStartRow, SCROW nEndRow, ScAttrArray& rAttrArray );
void CopyArea( SCROW nStartRow, SCROW nEndRow, long nDy, ScAttrArray& rAttrArray,
sal_Int16 nStripFlags = 0 );
2000-09-18 16:07:07 +00:00
void DeleteHardAttr( SCROW nStartRow, SCROW nEndRow );
2000-09-18 16:07:07 +00:00
};
// ------------------------------------------------------------------------------
2011-03-10 21:56:49 +01:00
// Iterator for attributes
2000-09-18 16:07:07 +00:00
// ------------------------------------------------------------------------------
class ScAttrIterator
{
const ScAttrArray* pArray;
SCSIZE nPos;
SCROW nRow;
SCROW nEndRow;
2000-09-18 16:07:07 +00:00
public:
inline ScAttrIterator( const ScAttrArray* pNewArray, SCROW nStart, SCROW nEnd );
inline const ScPatternAttr* Next( SCROW& rTop, SCROW& rBottom );
SCROW GetNextRow() const { return nRow; }
2000-09-18 16:07:07 +00:00
};
inline ScAttrIterator::ScAttrIterator( const ScAttrArray* pNewArray, SCROW nStart, SCROW nEnd ) :
2000-09-18 16:07:07 +00:00
pArray( pNewArray ),
nRow( nStart ),
nEndRow( nEnd )
{
if ( nStart > 0 )
2000-09-18 16:07:07 +00:00
pArray->Search( nStart, nPos );
else
nPos = 0;
}
inline const ScPatternAttr* ScAttrIterator::Next( SCROW& rTop, SCROW& rBottom )
2000-09-18 16:07:07 +00:00
{
const ScPatternAttr* pRet;
if ( nPos < pArray->nCount && nRow <= nEndRow )
2000-09-18 16:07:07 +00:00
{
rTop = nRow;
rBottom = Min( pArray->pData[nPos].nRow, nEndRow );
pRet = pArray->pData[nPos].pPattern;
nRow = rBottom + 1;
++nPos;
}
else
pRet = NULL;
return pRet;
}
#endif
2010-10-27 12:43:08 +01:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */