Files
libreoffice/sc/inc/column.hxx

472 lines
20 KiB
C++
Raw Normal View History

2000-09-18 16:07:07 +00:00
/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 16:07:07 +00:00
*
* $RCSfile: column.hxx,v $
2000-09-18 16:07:07 +00:00
*
* $Revision: 1.19 $
2000-09-18 16:07:07 +00:00
*
* last change: $Author: rt $ $Date: 2008-01-29 15:15:03 $
2000-09-18 16:07:07 +00:00
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
2000-09-18 16:07:07 +00:00
*
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
2000-09-18 16:07:07 +00:00
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
2000-09-18 16:07:07 +00:00
*
* This library 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 for more details.
2000-09-18 16:07:07 +00:00
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
2000-09-18 16:07:07 +00:00
*
************************************************************************/
#ifndef SC_COLUMN_HXX
#define SC_COLUMN_HXX
#ifndef SC_MARKARR_HXX
#include "markarr.hxx"
#endif
#ifndef SC_SCGLOB_HXX
#include "global.hxx"
#endif
#ifndef SC_COMPRESSEDARRAY_HXX
#include "compressedarray.hxx"
#endif
#ifndef SC_ADDRESS_HXX
#include "address.hxx"
#endif
#ifndef _SOLAR_H
#include <tools/solar.h>
#endif
2000-09-18 16:07:07 +00:00
class Fraction;
class OutputDevice;
class Rectangle;
class SfxBroadcaster;
class SfxItemPoolCache;
class SfxItemSet;
class SvtListener;
2000-09-18 16:07:07 +00:00
class SfxPoolItem;
class SfxStyleSheetBase;
class SvxBorderLine;
class SvxBoxInfoItem;
class SvxBoxItem;
class ScAttrIterator;
class ScAttrArray;
class ScBaseCell;
class ScDocument;
class ScFormulaCell;
class ScMarkData;
class ScMultipleReadHeader;
class ScMultipleWriteHeader;
class ScPatternAttr;
class ScStyleSheet;
class SvtBroadcaster;
2000-09-18 16:07:07 +00:00
class TypedStrCollection;
2002-10-01 16:10:37 +00:00
class ScProgress;
class ScPostIt;
2000-09-18 16:07:07 +00:00
struct ScFunctionData;
struct ScLineFlags;
struct ScMergePatternState;
2000-09-18 16:07:07 +00:00
#define COLUMN_DELTA 4
struct ScNeededSizeOptions
{
const ScPatternAttr* pPattern;
BOOL bFormula;
BOOL bSkipMerged;
BOOL bGetFont;
BOOL bTotalSize;
ScNeededSizeOptions()
{
pPattern = NULL;
bFormula = FALSE;
bSkipMerged = TRUE;
bGetFont = TRUE;
bTotalSize = FALSE;
}
};
struct ColEntry
{
SCROW nRow;
2000-09-18 16:07:07 +00:00
ScBaseCell* pCell;
};
class ScIndexMap;
class ScColumn
{
private:
SCCOL nCol;
SCTAB nTab;
2000-09-18 16:07:07 +00:00
SCSIZE nCount;
SCSIZE nLimit;
2000-09-18 16:07:07 +00:00
ColEntry* pItems;
ScAttrArray* pAttrArray;
ScDocument* pDocument;
friend class ScDocument; // fuer FillInfo
friend class ScDocumentIterator;
friend class ScValueIterator;
friend class ScQueryValueIterator;
friend class ScColumnIterator;
friend class ScQueryCellIterator;
friend class ScMarkedDataIter;
friend class ScCellIterator;
friend class ScHorizontalCellIterator;
friend class ScHorizontalAttrIterator;
public:
static BOOL bDoubleAlloc; // fuer Import: Groesse beim Allozieren verdoppeln
public:
ScColumn();
~ScColumn();
void Init(SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc);
2000-09-18 16:07:07 +00:00
BOOL Search( SCROW nRow, SCSIZE& nIndex ) const;
ScBaseCell* GetCell( SCROW nRow ) const;
void Insert( SCROW nRow, ScBaseCell* pCell );
void Insert( SCROW nRow, ULONG nFormatIndex, ScBaseCell* pCell );
void Append( SCROW nRow, ScBaseCell* pCell );
void Delete( SCROW nRow );
void DeleteAtIndex( SCSIZE nIndex );
2000-09-18 16:07:07 +00:00
void FreeAll();
void Resize( SCSIZE nSize );
void SetNewRow( SCROW nRow1, SCROW nRow2 );
void SwapRow( SCROW nRow1, SCROW nRow2 );
void SwapCell( SCROW nRow, ScColumn& rCol);
2000-09-18 16:07:07 +00:00
BOOL HasLines( SCROW nRow1, SCROW nRow2, Rectangle& rSizes,
2000-09-18 16:07:07 +00:00
BOOL bLeft, BOOL bRight ) const;
BOOL HasAttrib( SCROW nRow1, SCROW nRow2, USHORT nMask ) const;
2000-09-18 16:07:07 +00:00
BOOL HasAttribSelection( const ScMarkData& rMark, USHORT nMask ) const;
BOOL ExtendMerge( SCCOL nThisCol, SCROW nStartRow, SCROW nEndRow,
SCCOL& rPaintCol, SCROW& rPaintRow,
2000-09-18 16:07:07 +00:00
BOOL bRefresh, BOOL bAttrs );
BOOL IsEmptyVisData(BOOL bNotes) const; // ohne Broadcaster
BOOL IsEmptyData() const;
BOOL IsEmptyAttr() const;
BOOL IsEmpty() const;
// nur Daten:
BOOL IsEmptyBlock(SCROW nStartRow, SCROW nEndRow) const;
SCSIZE GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirection eDir ) const;
BOOL HasDataAt(SCROW nRow) const;
BOOL HasVisibleDataAt(SCROW nRow) const;
SCROW GetFirstDataPos() const;
SCROW GetLastDataPos() const;
SCROW GetLastVisDataPos(BOOL bNotes) const; // ohne Broadcaster
SCROW GetFirstVisDataPos(BOOL bNotes) const;
BOOL GetPrevDataPos(SCROW& rRow) const;
BOOL GetNextDataPos(SCROW& rRow) const;
void FindDataAreaPos(SCROW& rRow, long nMovY) const; // (ohne Broadcaster)
void FindUsed( SCROW nStartRow, SCROW nEndRow, BOOL* pUsed ) const;
SCSIZE VisibleCount( SCROW nStartRow, SCROW nEndRow ) const;
USHORT GetBlockMatrixEdges( SCROW nRow1, SCROW nRow2, USHORT nMask ) const;
2000-09-18 16:07:07 +00:00
BOOL HasSelectionMatrixFragment(const ScMarkData& rMark) const;
// Daten oder Attribute:
SCROW GetFirstEntryPos() const;
SCROW GetLastEntryPos() const;
2000-09-18 16:07:07 +00:00
// nur Attribute:
SCROW GetLastAttrPos() const;
BOOL GetFirstVisibleAttr( SCROW& rFirstRow ) const;
BOOL GetLastVisibleAttr( SCROW& rLastRow ) const;
BOOL HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const;
BOOL IsVisibleAttrEqual( const ScColumn& rCol, SCROW nStartRow = 0,
SCROW nEndRow = MAXROW ) const;
BOOL IsAllAttrEqual( const ScColumn& rCol, SCROW nStartRow, SCROW nEndRow ) const;
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, USHORT nDelFlag );
void DeleteArea(SCROW nStartRow, SCROW nEndRow, USHORT nDelFlag );
void CopyToClip(SCROW nRow1, SCROW nRow2, ScColumn& rColumn, BOOL bKeepScenarioFlags);
void CopyFromClip(SCROW nRow1, SCROW nRow2, long nDy,
USHORT nInsFlag, BOOL bAsLink, BOOL bSkipAttrForEmpty, ScColumn& rColumn);
void StartListeningInArea( SCROW nRow1, SCROW nRow2 );
void BroadcastInArea( SCROW nRow1, SCROW nRow2 );
2000-09-18 16:07:07 +00:00
void RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow );
2000-09-18 16:07:07 +00:00
// Markierung von diesem Dokument
void MixMarked( const ScMarkData& rMark, USHORT nFunction,
BOOL bSkipEmpty, ScColumn& rSrcCol );
void MixData( SCROW nRow1, SCROW nRow2, USHORT nFunction, BOOL bSkipEmpty,
2000-09-18 16:07:07 +00:00
ScColumn& rSrcCol );
ScFormulaCell* CreateRefCell( ScDocument* pDestDoc, const ScAddress& rDestPos,
SCSIZE nIndex, USHORT nFlags ) const;
2000-09-18 16:07:07 +00:00
ScAttrIterator* CreateAttrIterator( SCROW nStartRow, SCROW nEndRow ) const;
2000-09-18 16:07:07 +00:00
SCCOL GetCol() const { return nCol; }
2000-09-18 16:07:07 +00:00
// UpdateSelectionFunction: Mehrfachselektion
void UpdateSelectionFunction( const ScMarkData& rMark,
ScFunctionData& rData,
const ScBitMaskCompressedArray< SCROW, BYTE>* pRowFlags,
BOOL bDoExclude, SCROW nExStartRow, SCROW nExEndRow );
void UpdateAreaFunction( ScFunctionData& rData,
const ScBitMaskCompressedArray< SCROW, BYTE>* pRowFlags,
SCROW nStartRow, SCROW nEndRow );
2000-09-18 16:07:07 +00:00
void CopyToColumn(SCROW nRow1, SCROW nRow2, USHORT nFlags, BOOL bMarked,
2000-09-18 16:07:07 +00:00
ScColumn& rColumn, const ScMarkData* pMarkData = NULL,
BOOL bAsLink = FALSE );
void UndoToColumn(SCROW nRow1, SCROW nRow2, USHORT nFlags, BOOL bMarked,
2000-09-18 16:07:07 +00:00
ScColumn& rColumn, const ScMarkData* pMarkData = NULL );
void CopyScenarioFrom( const ScColumn& rSrcCol );
void CopyScenarioTo( ScColumn& rDestCol ) const;
BOOL TestCopyScenarioTo( const ScColumn& rDestCol ) const;
void MarkScenarioIn( ScMarkData& rDestMark ) const;
void CopyUpdated( const ScColumn& rPosCol, ScColumn& rDestCol ) const;
void SwapCol(ScColumn& rCol);
void MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol);
2000-09-18 16:07:07 +00:00
BOOL HasEditCells(SCROW nStartRow, SCROW nEndRow, SCROW& rFirst) const;
2000-09-18 16:07:07 +00:00
// TRUE = Zahlformat gesetzt
BOOL SetString( SCROW nRow, SCTAB nTab, const String& rString,
ScAddress::Convention conv = ScAddress::CONV_OOO );
void SetValue( SCROW nRow, const double& rVal);
void SetNote( SCROW nRow, const ScPostIt& rNote );
void SetError( SCROW nRow, const USHORT nError);
void GetString( SCROW nRow, String& rString ) const;
void GetInputString( SCROW nRow, String& rString ) const;
double GetValue( SCROW nRow ) const;
void GetFormula( SCROW nRow, String& rFormula,
2000-09-18 16:07:07 +00:00
BOOL bAsciiExport = FALSE ) const;
BOOL GetNote( SCROW nRow, ScPostIt& rNote ) const;
CellType GetCellType( SCROW nRow ) const;
SCSIZE GetCellCount() const { return nCount; }
ULONG GetWeightedCount() const;
2000-09-18 16:07:07 +00:00
ULONG GetCodeCount() const; // RPN-Code in Formeln
USHORT GetErrCode( SCROW nRow ) const;
2000-09-18 16:07:07 +00:00
BOOL HasStringData( SCROW nRow ) const;
BOOL HasValueData( SCROW nRow ) const;
USHORT GetErrorData( SCROW nRow) const;
BOOL HasStringCells( SCROW nStartRow, SCROW nEndRow ) const;
2000-09-18 16:07:07 +00:00
void SetDirty();
void SetDirty( const ScRange& );
void SetDirtyVar();
void SetDirtyAfterLoad();
2001-02-13 17:51:12 +00:00
void SetTableOpDirty( const ScRange& );
2000-09-18 16:07:07 +00:00
void CalcAll();
void CalcAfterLoad();
void CompileAll();
2002-10-01 16:10:37 +00:00
void CompileXML( ScProgress& rProgress );
2000-09-18 16:07:07 +00:00
void ResetChanged( SCROW nStartRow, SCROW nEndRow );
2000-09-18 16:07:07 +00:00
void UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
2000-09-18 16:07:07 +00:00
ScDocument* pUndoDoc = NULL );
void UpdateInsertTab( SCTAB nTable);
void UpdateInsertTabOnlyCells( SCTAB nTable);
void UpdateDeleteTab( SCTAB nTable, BOOL bIsMove, ScColumn* pRefUndo = NULL );
void UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo);
2000-09-18 16:07:07 +00:00
void UpdateCompile( BOOL bForceIfNameInUse = FALSE );
void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest,
ScDocument* pUndoDoc );
void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
2000-09-18 16:07:07 +00:00
void SetTabNo(SCTAB nNewTab);
BOOL IsRangeNameInUse(SCROW nRow1, SCROW nRow2, USHORT nIndex) const;
void ReplaceRangeNamesInUse( SCROW nRow1, SCROW nRow2, const ScIndexMap& rMap );
2000-09-18 16:07:07 +00:00
const SfxPoolItem* GetAttr( SCROW nRow, USHORT nWhich ) const;
const ScPatternAttr* GetPattern( SCROW nRow ) const;
const ScPatternAttr* GetMostUsedPattern( SCROW nStartRow, SCROW nEndRow ) const;
ULONG GetNumberFormat( SCROW nRow ) const;
2000-09-18 16:07:07 +00:00
void MergeSelectionPattern( ScMergePatternState& rState, const ScMarkData& rMark, BOOL bDeep ) const;
void MergePatternArea( ScMergePatternState& rState, SCROW nRow1, SCROW nRow2, BOOL bDeep ) const;
2000-09-18 16:07:07 +00:00
void MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner,
ScLineFlags& rFlags,
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,
SCROW nStartRow, SCROW nEndRow, BOOL bLeft, SCCOL nDistRight );
2000-09-18 16:07:07 +00:00
void ApplyAttr( SCROW nRow, const SfxPoolItem& rAttr );
void ApplyPattern( SCROW nRow, const ScPatternAttr& rPatAttr );
void ApplyPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr& rPatAttr );
void SetPattern( SCROW nRow, const ScPatternAttr& rPatAttr, BOOL bPutToPool = FALSE );
void SetPatternArea( SCROW nStartRow, SCROW nEndRow,
2000-09-18 16:07:07 +00:00
const ScPatternAttr& rPatAttr, BOOL bPutToPool = FALSE );
void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
const ScPatternAttr& rPattern, short nNewType );
void ApplyStyle( SCROW nRow, const ScStyleSheet& rStyle );
void ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const ScStyleSheet& rStyle );
2000-09-18 16:07:07 +00:00
void ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark);
void ApplySelectionLineStyle( const ScMarkData& rMark,
const SvxBorderLine* pLine, BOOL bColorOnly );
const ScStyleSheet* GetStyle( SCROW nRow ) const;
2000-09-18 16:07:07 +00:00
const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark, BOOL& rFound ) const;
const ScStyleSheet* GetAreaStyle( BOOL& rFound, SCROW nRow1, SCROW nRow2 ) const;
2000-09-18 16:07:07 +00:00
void FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, BOOL* pUsed, BOOL bReset );
BOOL IsStyleSheetUsed( const ScStyleSheet& rStyle, BOOL bGatherAllStyles ) const;
2000-09-18 16:07:07 +00:00
/// May return -1 if not found
SCsROW SearchStyle( SCsROW nRow, const ScStyleSheet* pSearchStyle,
2000-09-18 16:07:07 +00:00
BOOL bUp, BOOL bInSelection, const ScMarkData& rMark );
BOOL SearchStyleRange( SCsROW& rRow, SCsROW& rEndRow, const ScStyleSheet* pSearchStyle,
2000-09-18 16:07:07 +00:00
BOOL bUp, BOOL bInSelection, const ScMarkData& rMark );
BOOL ApplyFlags( SCROW nStartRow, SCROW nEndRow, INT16 nFlags );
BOOL RemoveFlags( SCROW nStartRow, SCROW nEndRow, INT16 nFlags );
void ClearItems( SCROW nStartRow, SCROW nEndRow, const USHORT* pWhich );
2000-09-18 16:07:07 +00:00
void RemoveProtected( SCROW nStartRow, SCROW nEndRow );
2000-09-18 16:07:07 +00:00
SCsROW ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark );
2000-09-18 16:07:07 +00:00
void DeleteSelection( USHORT nDelFlag, const ScMarkData& rMark );
void ClearSelectionItems( const USHORT* pWhich, const ScMarkData& rMark );
void ChangeSelectionIndent( BOOL bIncrement, const ScMarkData& rMark );
long GetNeededSize( SCROW nRow, OutputDevice* pDev,
2000-09-18 16:07:07 +00:00
double nPPTX, double nPPTY,
const Fraction& rZoomX, const Fraction& rZoomY,
BOOL bWidth, const ScNeededSizeOptions& rOptions );
USHORT GetOptimalColWidth( OutputDevice* pDev, double nPPTX, double nPPTY,
const Fraction& rZoomX, const Fraction& rZoomY,
BOOL bFormula, USHORT nOldWidth,
const ScMarkData* pMarkData,
BOOL bSimpleTextImport );
void GetOptimalHeight( SCROW nStartRow, SCROW nEndRow, USHORT* pHeight,
2000-09-18 16:07:07 +00:00
OutputDevice* pDev,
double nPPTX, double nPPTY,
const Fraction& rZoomX, const Fraction& rZoomY,
BOOL bShrink, USHORT nMinHeight, SCROW nMinStart );
2000-09-18 16:07:07 +00:00
private:
long GetSimpleTextNeededSize( SCSIZE nIndex, OutputDevice* pDev,
2000-09-18 16:07:07 +00:00
BOOL bWidth );
public:
/// Including current, may return -1
SCsROW GetNextUnprotected( SCROW nRow, BOOL bUp ) const;
2000-09-18 16:07:07 +00:00
void GetFilterEntries(SCROW nStartRow, SCROW nEndRow, TypedStrCollection& rStrings);
BOOL GetDataEntries(SCROW nRow, TypedStrCollection& rStrings, BOOL bLimit);
2000-09-18 16:07:07 +00:00
SCROW NoteCount( SCROW nMaxRow = MAXROW ) const;
2000-09-18 16:07:07 +00:00
void LoadData( SvStream& rStream );
void SaveData( SvStream& rStream ) const;
void LoadNotes( SvStream& rStream );
void SaveNotes( SvStream& rStream ) const;
BOOL Load( SvStream& rStream, ScMultipleReadHeader& rHdr );
BOOL Save( SvStream& rStream, ScMultipleWriteHeader& rHdr ) const;
void UpdateInsertTabAbs(SCTAB nNewPos);
BOOL TestTabRefAbs(SCTAB nTable);
BOOL GetNextSpellingCell(SCROW& nRow, BOOL bInSel, const ScMarkData& rData) const;
2000-09-18 16:07:07 +00:00
void RemoveAutoSpellObj();
void StartListening( SvtListener& rLst, SCROW nRow );
void EndListening( SvtListener& rLst, SCROW nRow );
void MoveListeners( SvtBroadcaster& rSource, SCROW nDestRow );
2000-09-18 16:07:07 +00:00
void StartAllListeners();
void StartNeededListeners(); // only for cells where NeedsListening()==TRUE
2000-09-18 16:07:07 +00:00
void SetRelNameDirty();
void CompileDBFormula();
void CompileDBFormula( BOOL bCreateFormulaString );
void CompileNameFormula( BOOL bCreateFormulaString );
void CompileColRowNameFormula();
sal_Int32 GetMaxStringLen( SCROW nRowStart, SCROW nRowEnd, CharSet eCharSet ) const;
2000-09-18 16:07:07 +00:00
xub_StrLen GetMaxNumberStringLen( USHORT& nPrecision,
SCROW nRowStart, SCROW nRowEnd ) const;
2000-09-18 16:07:07 +00:00
private:
ScBaseCell* CloneCell(SCSIZE nIndex, USHORT nFlags,
2000-09-18 16:07:07 +00:00
ScDocument* pDestDoc, const ScAddress& rDestPos);
void CorrectSymbolCells( CharSet eStreamCharSet );
2000-09-18 16:07:07 +00:00
};
class ScColumnIterator // alle Daten eines Bereichs durchgehen
{
const ScColumn* pColumn;
SCSIZE nPos;
SCROW nTop;
SCROW nBottom;
2000-09-18 16:07:07 +00:00
public:
ScColumnIterator( const ScColumn* pCol, SCROW nStart=0, SCROW nEnd=MAXROW );
2000-09-18 16:07:07 +00:00
~ScColumnIterator();
BOOL Next( SCROW& rRow, ScBaseCell*& rpCell );
SCSIZE GetIndex() const;
2000-09-18 16:07:07 +00:00
};
class ScMarkedDataIter // Daten in selektierten Bereichen durchgehen
{
const ScColumn* pColumn;
SCSIZE nPos;
2000-09-18 16:07:07 +00:00
ScMarkArrayIter* pMarkIter;
SCROW nTop;
SCROW nBottom;
2000-09-18 16:07:07 +00:00
BOOL bNext;
BOOL bAll;
public:
ScMarkedDataIter( const ScColumn* pCol, const ScMarkData* pMarkData,
BOOL bAllIfNone = FALSE );
~ScMarkedDataIter();
BOOL Next( SCSIZE& rIndex );
2000-09-18 16:07:07 +00:00
};
#endif