1*1d2dbeb0SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*1d2dbeb0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*1d2dbeb0SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*1d2dbeb0SAndrew Rist * distributed with this work for additional information 6*1d2dbeb0SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*1d2dbeb0SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*1d2dbeb0SAndrew Rist * "License"); you may not use this file except in compliance 9*1d2dbeb0SAndrew Rist * with the License. You may obtain a copy of the License at 10*1d2dbeb0SAndrew Rist * 11*1d2dbeb0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*1d2dbeb0SAndrew Rist * 13*1d2dbeb0SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*1d2dbeb0SAndrew Rist * software distributed under the License is distributed on an 15*1d2dbeb0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*1d2dbeb0SAndrew Rist * KIND, either express or implied. See the License for the 17*1d2dbeb0SAndrew Rist * specific language governing permissions and limitations 18*1d2dbeb0SAndrew Rist * under the License. 19*1d2dbeb0SAndrew Rist * 20*1d2dbeb0SAndrew Rist *************************************************************/ 21*1d2dbeb0SAndrew Rist 22*1d2dbeb0SAndrew Rist 23cdf0e10cSrcweir #ifndef _SWTABLE_HXX 24cdf0e10cSrcweir #define _SWTABLE_HXX 25cdf0e10cSrcweir #include <tools/mempool.hxx> 26cdf0e10cSrcweir #include <tools/ref.hxx> 27cdf0e10cSrcweir #include <svl/svarray.hxx> 28cdf0e10cSrcweir #include <tblenum.hxx> 29cdf0e10cSrcweir #include <swtypes.hxx> 30cdf0e10cSrcweir #include <calbck.hxx> 31cdf0e10cSrcweir #include <swrect.hxx> 32cdf0e10cSrcweir #ifndef DBG_UTIL 33cdf0e10cSrcweir #include <node.hxx> // fuer StartNode->GetMyIndex 34cdf0e10cSrcweir #else 35cdf0e10cSrcweir class SwStartNode; 36cdf0e10cSrcweir #include <memory> 37cdf0e10cSrcweir #include <boost/noncopyable.hpp> 38cdf0e10cSrcweir #endif 39cdf0e10cSrcweir 40cdf0e10cSrcweir class SwFmt; 41cdf0e10cSrcweir class Color; 42cdf0e10cSrcweir class SwFrmFmt; 43cdf0e10cSrcweir class SwTableFmt; 44cdf0e10cSrcweir class SwTableLineFmt; 45cdf0e10cSrcweir class SwTableBoxFmt; 46cdf0e10cSrcweir class SwHTMLTableLayout; 47cdf0e10cSrcweir class SwTableLine; 48cdf0e10cSrcweir class SwTableBox; 49cdf0e10cSrcweir class SwTableNode; 50cdf0e10cSrcweir class SwTabCols; 51cdf0e10cSrcweir class SwDoc; 52cdf0e10cSrcweir class SwSelBoxes; 53cdf0e10cSrcweir class SwTblCalcPara; 54cdf0e10cSrcweir class SwChartLines; 55cdf0e10cSrcweir struct SwPosition; 56cdf0e10cSrcweir class SwNodeIndex; 57cdf0e10cSrcweir class SwNode; 58cdf0e10cSrcweir class SfxPoolItem; 59cdf0e10cSrcweir class SwUndoTblMerge; 60cdf0e10cSrcweir class SwUndo; 61cdf0e10cSrcweir class SwPaM; 62cdf0e10cSrcweir class SwTableBox_Impl; 63cdf0e10cSrcweir class SwUndoTblCpyTbl; 64cdf0e10cSrcweir class SwBoxSelection; 65cdf0e10cSrcweir struct SwSaveRowSpan; 66cdf0e10cSrcweir struct Parm; 67cdf0e10cSrcweir 68cdf0e10cSrcweir #ifndef SW_DECL_SWSERVEROBJECT_DEFINED 69cdf0e10cSrcweir #define SW_DECL_SWSERVEROBJECT_DEFINED 70cdf0e10cSrcweir SV_DECL_REF( SwServerObject ) 71cdf0e10cSrcweir #endif 72cdf0e10cSrcweir 73cdf0e10cSrcweir SV_DECL_PTRARR_DEL(SwTableLines, SwTableLine*, 10, 20) 74cdf0e10cSrcweir SV_DECL_PTRARR_DEL(SwTableBoxes, SwTableBox*, 25, 50) 75cdf0e10cSrcweir 76cdf0e10cSrcweir // speicher die Inhaltstragenden Box-Pointer zusaetzlich in einem 77cdf0e10cSrcweir // sortierten Array (fuers rechnen in der Tabelle) 78cdf0e10cSrcweir typedef SwTableBox* SwTableBoxPtr; 79cdf0e10cSrcweir SV_DECL_PTRARR_SORT( SwTableSortBoxes, SwTableBoxPtr, 25, 50 ) 80cdf0e10cSrcweir typedef SwTableLine* SwTableLinePtr; 81cdf0e10cSrcweir 82cdf0e10cSrcweir class SW_DLLPUBLIC SwTable: public SwClient //Client vom FrmFmt 83cdf0e10cSrcweir { 84cdf0e10cSrcweir 85cdf0e10cSrcweir 86cdf0e10cSrcweir protected: 87cdf0e10cSrcweir SwTableLines aLines; 88cdf0e10cSrcweir SwTableSortBoxes aSortCntBoxes; 89cdf0e10cSrcweir SwServerObjectRef refObj; // falls DataServer -> Pointer gesetzt 90cdf0e10cSrcweir 91cdf0e10cSrcweir SwHTMLTableLayout *pHTMLLayout; 92cdf0e10cSrcweir 93cdf0e10cSrcweir // Usually, the table node of a SwTable can be accessed by getting a box 94cdf0e10cSrcweir // out of aSortCntBoxes, which know their SwStartNode. But in some rare 95cdf0e10cSrcweir // cases, we need to know the table node of a SwTable, before the table 96cdf0e10cSrcweir // boxes have been build (SwTableNode::MakeCopy with tables in tables). 97cdf0e10cSrcweir SwTableNode* pTableNode; 98cdf0e10cSrcweir 99cdf0e10cSrcweir //SOLL das fuer jede Tabelle einstellbar sein? 100cdf0e10cSrcweir TblChgMode eTblChgMode; 101cdf0e10cSrcweir 102cdf0e10cSrcweir sal_uInt16 nGrfsThatResize; // Anzahl der Grfs, die beim HTML-Import 103cdf0e10cSrcweir // noch ein Resize der Tbl. anstossen 104cdf0e10cSrcweir sal_uInt16 nRowsToRepeat; // number of rows to repeat on every page 105cdf0e10cSrcweir 106cdf0e10cSrcweir sal_Bool bModifyLocked :1; 107cdf0e10cSrcweir sal_Bool bNewModel :1; // sal_False: old SubTableModel; sal_True: new RowSpanModel 108cdf0e10cSrcweir #ifdef DBG_UTIL 109cdf0e10cSrcweir bool bDontChangeModel; // This is set by functions (like Merge()) to forbid a laet model change 110cdf0e10cSrcweir #endif 111cdf0e10cSrcweir IsModifyLocked()112cdf0e10cSrcweir sal_Bool IsModifyLocked(){ return bModifyLocked;} 113cdf0e10cSrcweir 114cdf0e10cSrcweir virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ); 115cdf0e10cSrcweir 116cdf0e10cSrcweir public: 117cdf0e10cSrcweir enum SearchType 118cdf0e10cSrcweir { 119cdf0e10cSrcweir SEARCH_NONE, // Default: expand to rectangle 120cdf0e10cSrcweir SEARCH_ROW, // row selection 121cdf0e10cSrcweir SEARCH_COL // column selection 122cdf0e10cSrcweir }; 123cdf0e10cSrcweir 124cdf0e10cSrcweir TYPEINFO(); 125cdf0e10cSrcweir 126cdf0e10cSrcweir // single argument ctors shall be explicit. 127cdf0e10cSrcweir explicit SwTable( SwTableFmt* ); 128cdf0e10cSrcweir virtual ~SwTable(); 129cdf0e10cSrcweir 130cdf0e10cSrcweir // @@@ public copy ctor, but no copy assignment? 131cdf0e10cSrcweir SwTable( const SwTable& rTable ); // kein Copy der Lines !! 132cdf0e10cSrcweir private: 133cdf0e10cSrcweir // @@@ public copy ctor, but no copy assignment? 134cdf0e10cSrcweir SwTable & operator= (const SwTable &); 135cdf0e10cSrcweir // no default ctor. 136cdf0e10cSrcweir SwTable(); 137cdf0e10cSrcweir sal_Bool OldMerge( SwDoc*, const SwSelBoxes&, SwTableBox*, SwUndoTblMerge* ); 138cdf0e10cSrcweir sal_Bool OldSplitRow( SwDoc*, const SwSelBoxes&, sal_uInt16, sal_Bool ); 139cdf0e10cSrcweir sal_Bool NewMerge( SwDoc*, const SwSelBoxes&, const SwSelBoxes& rMerged, 140cdf0e10cSrcweir SwTableBox*, SwUndoTblMerge* ); 141cdf0e10cSrcweir sal_Bool NewSplitRow( SwDoc*, const SwSelBoxes&, sal_uInt16, sal_Bool ); 142cdf0e10cSrcweir SwBoxSelection* CollectBoxSelection( const SwPaM& rPam ) const; 143cdf0e10cSrcweir void InsertSpannedRow( SwDoc* pDoc, sal_uInt16 nIdx, sal_uInt16 nCnt ); 144cdf0e10cSrcweir sal_Bool _InsertRow( SwDoc*, const SwSelBoxes&, sal_uInt16 nCnt, sal_Bool bBehind ); 145cdf0e10cSrcweir sal_Bool NewInsertCol( SwDoc*, const SwSelBoxes& rBoxes, sal_uInt16 nCnt, sal_Bool ); 146cdf0e10cSrcweir void _FindSuperfluousRows( SwSelBoxes& rBoxes, SwTableLine*, SwTableLine* ); 147cdf0e10cSrcweir void AdjustWidths( const long nOld, const long nNew ); 148cdf0e10cSrcweir void NewSetTabCols( Parm &rP, const SwTabCols &rNew, const SwTabCols &rOld, 149cdf0e10cSrcweir const SwTableBox *pStart, sal_Bool bCurRowOnly ); 150cdf0e10cSrcweir 151cdf0e10cSrcweir public: 152cdf0e10cSrcweir GetHTMLTableLayout()153cdf0e10cSrcweir SwHTMLTableLayout *GetHTMLTableLayout() { return pHTMLLayout; } GetHTMLTableLayout() const154cdf0e10cSrcweir const SwHTMLTableLayout *GetHTMLTableLayout() const { return pHTMLLayout; } 155cdf0e10cSrcweir void SetHTMLTableLayout( SwHTMLTableLayout *p ); //Eigentumsuebergang! 156cdf0e10cSrcweir IncGrfsThatResize()157cdf0e10cSrcweir sal_uInt16 IncGrfsThatResize() { return ++nGrfsThatResize; } DecGrfsThatResize()158cdf0e10cSrcweir sal_uInt16 DecGrfsThatResize() { return nGrfsThatResize ? --nGrfsThatResize : 0; } 159cdf0e10cSrcweir LockModify()160cdf0e10cSrcweir void LockModify() { bModifyLocked = sal_True; } //Muessen _immer_ paarig UnlockModify()161cdf0e10cSrcweir void UnlockModify() { bModifyLocked = sal_False;} //benutzt werden! 162cdf0e10cSrcweir SetTableModel(sal_Bool bNew)163cdf0e10cSrcweir void SetTableModel( sal_Bool bNew ){ bNewModel = bNew; } IsNewModel() const164cdf0e10cSrcweir sal_Bool IsNewModel() const { return bNewModel; } 165cdf0e10cSrcweir GetRowsToRepeat() const166cdf0e10cSrcweir sal_uInt16 GetRowsToRepeat() const { return Min( GetTabLines().Count(), nRowsToRepeat ); } _GetRowsToRepeat() const167cdf0e10cSrcweir sal_uInt16 _GetRowsToRepeat() const { return nRowsToRepeat; } SetRowsToRepeat(sal_uInt16 nNumOfRows)168cdf0e10cSrcweir void SetRowsToRepeat( sal_uInt16 nNumOfRows ) { nRowsToRepeat = nNumOfRows; } 169cdf0e10cSrcweir 170cdf0e10cSrcweir bool IsHeadline( const SwTableLine& rLine ) const; 171cdf0e10cSrcweir GetTabLines()172cdf0e10cSrcweir SwTableLines &GetTabLines() { return aLines; } GetTabLines() const173cdf0e10cSrcweir const SwTableLines &GetTabLines() const { return aLines; } 174cdf0e10cSrcweir GetFrmFmt()175cdf0e10cSrcweir SwFrmFmt* GetFrmFmt() { return (SwFrmFmt*)GetRegisteredIn(); } GetFrmFmt() const176cdf0e10cSrcweir SwFrmFmt* GetFrmFmt() const { return (SwFrmFmt*)GetRegisteredIn(); } GetTableFmt() const177cdf0e10cSrcweir SwTableFmt* GetTableFmt() const { return (SwTableFmt*)GetRegisteredIn(); } 178cdf0e10cSrcweir 179cdf0e10cSrcweir void GetTabCols( SwTabCols &rToFill, const SwTableBox *pStart, 180cdf0e10cSrcweir sal_Bool bHidden = sal_False, sal_Bool bCurRowOnly = sal_False ) const; 181cdf0e10cSrcweir void SetTabCols( const SwTabCols &rNew, const SwTabCols &rOld, 182cdf0e10cSrcweir const SwTableBox *pStart, sal_Bool bCurRowOnly ); 183cdf0e10cSrcweir 184cdf0e10cSrcweir // The following functions are for new table model only... 185cdf0e10cSrcweir void CreateSelection( const SwPaM& rPam, SwSelBoxes& rBoxes, 186cdf0e10cSrcweir const SearchType eSearchType, bool bProtect ) const; 187cdf0e10cSrcweir void CreateSelection( const SwNode* pStart, const SwNode* pEnd, 188cdf0e10cSrcweir SwSelBoxes& rBoxes, const SearchType eSearchType, bool bProtect ) const; 189cdf0e10cSrcweir void ExpandSelection( SwSelBoxes& rBoxes ) const; 190cdf0e10cSrcweir // When a table is splitted into two tables, the row spans which overlaps 191cdf0e10cSrcweir // the split have to be corrected and stored for undo 192cdf0e10cSrcweir // SwSavRowSpan is the structure needed by Undo to undo the split operation 193cdf0e10cSrcweir // CleanUpRowSpan corrects the (top of the) second table and delviers the structure 194cdf0e10cSrcweir // for Undo 195cdf0e10cSrcweir SwSaveRowSpan* CleanUpTopRowSpan( sal_uInt16 nSplitLine ); 196cdf0e10cSrcweir // RestoreRowSpan is called by Undo to restore the old row span values 197cdf0e10cSrcweir void RestoreRowSpan( const SwSaveRowSpan& ); 198cdf0e10cSrcweir // CleanUpBottomRowSpan corrects the overhanging row spans at the end of the first table 199cdf0e10cSrcweir void CleanUpBottomRowSpan( sal_uInt16 nDelLines ); 200cdf0e10cSrcweir 201cdf0e10cSrcweir 202cdf0e10cSrcweir // The following functions are "pseudo-virtual", i.e. they are different for old and new table model 203cdf0e10cSrcweir // It's not allowed to change the table model after the first call of one of these functions. 204cdf0e10cSrcweir Merge(SwDoc * pDoc,const SwSelBoxes & rBoxes,const SwSelBoxes & rMerged,SwTableBox * pMergeBox,SwUndoTblMerge * pUndo=0)205cdf0e10cSrcweir sal_Bool Merge( SwDoc* pDoc, const SwSelBoxes& rBoxes, const SwSelBoxes& rMerged, 206cdf0e10cSrcweir SwTableBox* pMergeBox, SwUndoTblMerge* pUndo = 0 ) 207cdf0e10cSrcweir { 208cdf0e10cSrcweir #ifdef DBG_UTIL 209cdf0e10cSrcweir bDontChangeModel = true; 210cdf0e10cSrcweir #endif 211cdf0e10cSrcweir return bNewModel ? NewMerge( pDoc, rBoxes, rMerged, pMergeBox, pUndo ) : 212cdf0e10cSrcweir OldMerge( pDoc, rBoxes, pMergeBox, pUndo ); 213cdf0e10cSrcweir } SplitRow(SwDoc * pDoc,const SwSelBoxes & rBoxes,sal_uInt16 nCnt=1,sal_Bool bSameHeight=sal_False)214cdf0e10cSrcweir sal_Bool SplitRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 nCnt=1, 215cdf0e10cSrcweir sal_Bool bSameHeight = sal_False ) 216cdf0e10cSrcweir { 217cdf0e10cSrcweir #ifdef DBG_UTIL 218cdf0e10cSrcweir bDontChangeModel = true; 219cdf0e10cSrcweir #endif 220cdf0e10cSrcweir return bNewModel ? NewSplitRow( pDoc, rBoxes, nCnt, bSameHeight ) : 221cdf0e10cSrcweir OldSplitRow( pDoc, rBoxes, nCnt, bSameHeight ); 222cdf0e10cSrcweir } 223cdf0e10cSrcweir bool PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes, 224cdf0e10cSrcweir SwSelBoxes& rMerged, SwTableBox** ppMergeBox, SwUndoTblMerge* pUndo ); 225cdf0e10cSrcweir void ExpandColumnSelection( SwSelBoxes& rBoxes, long &rMin, long &rMax ) const; 226cdf0e10cSrcweir void PrepareDeleteCol( long nMin, long nMax ); 227cdf0e10cSrcweir 228cdf0e10cSrcweir sal_Bool InsertCol( SwDoc*, const SwSelBoxes& rBoxes, 229cdf0e10cSrcweir sal_uInt16 nCnt = 1, sal_Bool bBehind = sal_True ); 230cdf0e10cSrcweir sal_Bool InsertRow( SwDoc*, const SwSelBoxes& rBoxes, 231cdf0e10cSrcweir sal_uInt16 nCnt = 1, sal_Bool bBehind = sal_True ); 232cdf0e10cSrcweir sal_Bool AppendRow( SwDoc* pDoc, sal_uInt16 nCnt = 1 ); 233cdf0e10cSrcweir void PrepareDelBoxes( const SwSelBoxes& rBoxes ); 234cdf0e10cSrcweir sal_Bool DeleteSel( SwDoc*, const SwSelBoxes& rBoxes, const SwSelBoxes* pMerged, 235cdf0e10cSrcweir SwUndo* pUndo, const sal_Bool bDelMakeFrms, const sal_Bool bCorrBorder ); 236cdf0e10cSrcweir sal_Bool SplitCol( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 nCnt=1 ); 237cdf0e10cSrcweir sal_Bool Merge( const SwSelBoxes& rBoxes, 238cdf0e10cSrcweir SwTableBox* pMergeBox, SwUndoTblMerge* = 0 ); 239cdf0e10cSrcweir FindSuperfluousRows(SwSelBoxes & rBoxes)240cdf0e10cSrcweir void FindSuperfluousRows( SwSelBoxes& rBoxes ) 241cdf0e10cSrcweir { _FindSuperfluousRows( rBoxes, 0, 0 ); } 242cdf0e10cSrcweir void CheckRowSpan( SwTableLinePtr &rpLine, bool bUp ) const; 243cdf0e10cSrcweir GetTabSortBoxes()244cdf0e10cSrcweir SwTableSortBoxes& GetTabSortBoxes() { return aSortCntBoxes; } GetTabSortBoxes() const245cdf0e10cSrcweir const SwTableSortBoxes& GetTabSortBoxes() const { return aSortCntBoxes; } 246cdf0e10cSrcweir 247cdf0e10cSrcweir // lese die 1. Nummer und loesche sie aus dem String 248cdf0e10cSrcweir // (wird von GetTblBox und SwTblFld benutzt) 249cdf0e10cSrcweir // --> OD 2007-08-03 #i80314# 250cdf0e10cSrcweir // add 3rd parameter in order to control validation check on <rStr> 251cdf0e10cSrcweir static sal_uInt16 _GetBoxNum( String& rStr, 252cdf0e10cSrcweir sal_Bool bFirst = sal_False, 253cdf0e10cSrcweir const bool bPerformValidCheck = false ); 254cdf0e10cSrcweir // <-- 255cdf0e10cSrcweir // suche die Inhaltstragende Box mit dem Namen 256cdf0e10cSrcweir // --> OD 2007-08-03 #i80314# 257cdf0e10cSrcweir // add 2nd parameter in order to control validation check in called method 258cdf0e10cSrcweir // <_GetBoxNum(..)> 259cdf0e10cSrcweir const SwTableBox* GetTblBox( const String& rName, 260cdf0e10cSrcweir const bool bPerformValidCheck = false ) const; 261cdf0e10cSrcweir // <-- 262cdf0e10cSrcweir // kopiere die selektierten Boxen in ein anderes Dokument. 263cdf0e10cSrcweir sal_Bool MakeCopy( SwDoc*, const SwPosition&, const SwSelBoxes&, 264cdf0e10cSrcweir sal_Bool bCpyNds = sal_True, sal_Bool bCpyName = sal_False ) const; 265cdf0e10cSrcweir // kopiere die Tabelle in diese. (die Logik steht im TBLRWCL.CXX) 266cdf0e10cSrcweir sal_Bool InsTable( const SwTable& rCpyTbl, const SwNodeIndex&, 267cdf0e10cSrcweir SwUndoTblCpyTbl* pUndo = 0 ); 268cdf0e10cSrcweir sal_Bool InsTable( const SwTable& rCpyTbl, const SwSelBoxes&, 269cdf0e10cSrcweir SwUndoTblCpyTbl* pUndo = 0 ); 270cdf0e10cSrcweir sal_Bool InsNewTable( const SwTable& rCpyTbl, const SwSelBoxes&, 271cdf0e10cSrcweir SwUndoTblCpyTbl* pUndo ); 272cdf0e10cSrcweir // kopiere die Headline (mit Inhalt!) der Tabelle in eine andere 273cdf0e10cSrcweir sal_Bool CopyHeadlineIntoTable( SwTableNode& rTblNd ); 274cdf0e10cSrcweir 275cdf0e10cSrcweir // erfrage die Box, dessen Start-Index auf nBoxStt steht 276cdf0e10cSrcweir SwTableBox* GetTblBox( sal_uLong nSttIdx ); GetTblBox(sal_uLong nSttIdx) const277cdf0e10cSrcweir const SwTableBox* GetTblBox( sal_uLong nSttIdx ) const 278cdf0e10cSrcweir { return ((SwTable*)this)->GetTblBox( nSttIdx ); } 279cdf0e10cSrcweir 280cdf0e10cSrcweir // returnt sal_True wenn sich in der Tabelle Verschachtelungen befinden 281cdf0e10cSrcweir sal_Bool IsTblComplex() const; 282cdf0e10cSrcweir 283cdf0e10cSrcweir //returnt sal_True wenn die Tabelle oder Selektion ausgeglichen ist 284cdf0e10cSrcweir sal_Bool IsTblComplexForChart( const String& rSel, 285cdf0e10cSrcweir SwChartLines* pGetCLines = 0 ) const; 286cdf0e10cSrcweir 287cdf0e10cSrcweir // suche alle Inhaltstragenden-Boxen der Grundline in der diese Box 288cdf0e10cSrcweir // steht. rBoxes auch als Return-Wert, um es gleich weiter zu benutzen 289cdf0e10cSrcweir //JP 31.01.97: bToTop = sal_True -> hoch bis zur Grundline, 290cdf0e10cSrcweir // sal_False-> sonst nur die Line der Box 291cdf0e10cSrcweir SwSelBoxes& SelLineFromBox( const SwTableBox* pBox, 292cdf0e10cSrcweir SwSelBoxes& rBoxes, sal_Bool bToTop = sal_True ) const; 293cdf0e10cSrcweir // erfrage vom Client Informationen 294cdf0e10cSrcweir virtual sal_Bool GetInfo( SfxPoolItem& ) const; 295cdf0e10cSrcweir 296cdf0e10cSrcweir // suche im Format nach der angemeldeten Tabelle 297cdf0e10cSrcweir static SwTable * FindTable( SwFrmFmt const*const pFmt ); 298cdf0e10cSrcweir 299cdf0e10cSrcweir // Struktur ein wenig aufraeumen 300cdf0e10cSrcweir void GCLines(); 301cdf0e10cSrcweir 302cdf0e10cSrcweir // returns the table node via aSortCntBoxes or pTableNode 303cdf0e10cSrcweir SwTableNode* GetTableNode() const; SetTableNode(SwTableNode * pNode)304cdf0e10cSrcweir void SetTableNode( SwTableNode* pNode ) { pTableNode = pNode; } 305cdf0e10cSrcweir 306cdf0e10cSrcweir // Daten Server-Methoden 307cdf0e10cSrcweir void SetRefObject( SwServerObject* ); GetObject() const308cdf0e10cSrcweir const SwServerObject* GetObject() const { return &refObj; } GetObject()309cdf0e10cSrcweir SwServerObject* GetObject() { return &refObj; } 310cdf0e10cSrcweir 311cdf0e10cSrcweir //Daten fuer das Chart fuellen. 312cdf0e10cSrcweir void UpdateCharts() const; 313cdf0e10cSrcweir GetTblChgMode() const314cdf0e10cSrcweir TblChgMode GetTblChgMode() const { return eTblChgMode; } SetTblChgMode(TblChgMode eMode)315cdf0e10cSrcweir void SetTblChgMode( TblChgMode eMode ) { eTblChgMode = eMode; } 316cdf0e10cSrcweir 317cdf0e10cSrcweir sal_Bool SetColWidth( SwTableBox& rAktBox, sal_uInt16 eType, 318cdf0e10cSrcweir SwTwips nAbsDiff, SwTwips nRelDiff, SwUndo** ppUndo ); 319cdf0e10cSrcweir sal_Bool SetRowHeight( SwTableBox& rAktBox, sal_uInt16 eType, 320cdf0e10cSrcweir SwTwips nAbsDiff, SwTwips nRelDiff, SwUndo** ppUndo ); 321cdf0e10cSrcweir void RegisterToFormat( SwFmt& rFmt ); 322cdf0e10cSrcweir #ifdef DBG_UTIL 323cdf0e10cSrcweir void CheckConsistency() const; 324cdf0e10cSrcweir #endif 325cdf0e10cSrcweir }; 326cdf0e10cSrcweir 327cdf0e10cSrcweir class SW_DLLPUBLIC SwTableLine: public SwClient // Client vom FrmFmt 328cdf0e10cSrcweir { 329cdf0e10cSrcweir SwTableBoxes aBoxes; 330cdf0e10cSrcweir SwTableBox *pUpper; 331cdf0e10cSrcweir 332cdf0e10cSrcweir public: 333cdf0e10cSrcweir TYPEINFO(); 334cdf0e10cSrcweir SwTableLine()335cdf0e10cSrcweir SwTableLine() : pUpper(0) {} 336cdf0e10cSrcweir 337cdf0e10cSrcweir SwTableLine( SwTableLineFmt*, sal_uInt16 nBoxes, SwTableBox *pUp ); 338cdf0e10cSrcweir virtual ~SwTableLine(); 339cdf0e10cSrcweir GetTabBoxes()340cdf0e10cSrcweir SwTableBoxes &GetTabBoxes() { return aBoxes; } GetTabBoxes() const341cdf0e10cSrcweir const SwTableBoxes &GetTabBoxes() const { return aBoxes; } 342cdf0e10cSrcweir GetUpper()343cdf0e10cSrcweir SwTableBox *GetUpper() { return pUpper; } GetUpper() const344cdf0e10cSrcweir const SwTableBox *GetUpper() const { return pUpper; } SetUpper(SwTableBox * pNew)345cdf0e10cSrcweir void SetUpper( SwTableBox *pNew ) { pUpper = pNew; } 346cdf0e10cSrcweir 347cdf0e10cSrcweir GetFrmFmt()348cdf0e10cSrcweir SwFrmFmt* GetFrmFmt() { return (SwFrmFmt*)GetRegisteredIn(); } GetFrmFmt() const349cdf0e10cSrcweir SwFrmFmt* GetFrmFmt() const { return (SwFrmFmt*)GetRegisteredIn(); } 350cdf0e10cSrcweir 351cdf0e10cSrcweir //Macht ein eingenes FrmFmt wenn noch mehr Lines von ihm abhaengen. 352cdf0e10cSrcweir SwFrmFmt* ClaimFrmFmt(); 353cdf0e10cSrcweir void ChgFrmFmt( SwTableLineFmt* pNewFmt ); 354cdf0e10cSrcweir 355cdf0e10cSrcweir // suche nach der naechsten/vorherigen Box mit Inhalt 356cdf0e10cSrcweir SwTableBox* FindNextBox( const SwTable&, const SwTableBox* =0, 357cdf0e10cSrcweir sal_Bool bOvrTblLns=sal_True ) const; 358cdf0e10cSrcweir SwTableBox* FindPreviousBox( const SwTable&, const SwTableBox* =0, 359cdf0e10cSrcweir sal_Bool bOvrTblLns=sal_True ) const; 360cdf0e10cSrcweir 361cdf0e10cSrcweir SwTwips GetTableLineHeight( bool& bLayoutAvailable ) const; 362cdf0e10cSrcweir 363cdf0e10cSrcweir bool hasSoftPageBreak() const; 364cdf0e10cSrcweir void RegisterToFormat( SwFmt& rFmt ); 365cdf0e10cSrcweir }; 366cdf0e10cSrcweir 367cdf0e10cSrcweir class SW_DLLPUBLIC SwTableBox: public SwClient //Client vom FrmFmt 368cdf0e10cSrcweir { 369cdf0e10cSrcweir friend class SwNodes; // um den Index umzusetzen ! 370cdf0e10cSrcweir friend void DelBoxNode(SwTableSortBoxes&); // um den StartNode* zu loeschen ! 371cdf0e10cSrcweir friend class SwXMLTableContext; 372cdf0e10cSrcweir 373cdf0e10cSrcweir //nicht (mehr) implementiert. 374cdf0e10cSrcweir SwTableBox( const SwTableBox & ); 375cdf0e10cSrcweir SwTableBox &operator=( const SwTableBox &); //gibts nicht. 376cdf0e10cSrcweir 377cdf0e10cSrcweir SwTableLines aLines; 378cdf0e10cSrcweir const SwStartNode * pSttNd; 379cdf0e10cSrcweir SwTableLine *pUpper; 380cdf0e10cSrcweir SwTableBox_Impl* pImpl; 381cdf0e10cSrcweir 382cdf0e10cSrcweir // falls das Format schon Formeln/Values enthaelt, muss ein neues 383cdf0e10cSrcweir // fuer die neue Box erzeugt werden. 384cdf0e10cSrcweir SwTableBoxFmt* CheckBoxFmt( SwTableBoxFmt* ); 385cdf0e10cSrcweir 386cdf0e10cSrcweir public: 387cdf0e10cSrcweir TYPEINFO(); 388cdf0e10cSrcweir SwTableBox()389cdf0e10cSrcweir SwTableBox() : pSttNd(0), pUpper(0), pImpl(0) {} 390cdf0e10cSrcweir 391cdf0e10cSrcweir SwTableBox( SwTableBoxFmt*, sal_uInt16 nLines, SwTableLine *pUp = 0 ); 392cdf0e10cSrcweir SwTableBox( SwTableBoxFmt*, const SwStartNode&, SwTableLine *pUp = 0 ); 393cdf0e10cSrcweir SwTableBox( SwTableBoxFmt*, const SwNodeIndex&, SwTableLine *pUp = 0 ); 394cdf0e10cSrcweir virtual ~SwTableBox(); 395cdf0e10cSrcweir GetTabLines()396cdf0e10cSrcweir SwTableLines &GetTabLines() { return aLines; } GetTabLines() const397cdf0e10cSrcweir const SwTableLines &GetTabLines() const { return aLines; } 398cdf0e10cSrcweir GetUpper()399cdf0e10cSrcweir SwTableLine *GetUpper() { return pUpper; } GetUpper() const400cdf0e10cSrcweir const SwTableLine *GetUpper() const { return pUpper; } SetUpper(SwTableLine * pNew)401cdf0e10cSrcweir void SetUpper( SwTableLine *pNew ) { pUpper = pNew; } 402cdf0e10cSrcweir GetFrmFmt()403cdf0e10cSrcweir SwFrmFmt* GetFrmFmt() { return (SwFrmFmt*)GetRegisteredIn(); } GetFrmFmt() const404cdf0e10cSrcweir SwFrmFmt* GetFrmFmt() const { return (SwFrmFmt*)GetRegisteredIn(); } 405cdf0e10cSrcweir 406cdf0e10cSrcweir //Macht ein eingenes FrmFmt wenn noch mehr Boxen von ihm abhaengen. 407cdf0e10cSrcweir SwFrmFmt* ClaimFrmFmt(); 408cdf0e10cSrcweir void ChgFrmFmt( SwTableBoxFmt *pNewFmt ); 409cdf0e10cSrcweir GetSttNd() const410cdf0e10cSrcweir const SwStartNode *GetSttNd() const { return pSttNd; } GetSttIdx() const411cdf0e10cSrcweir sal_uLong GetSttIdx() const 412cdf0e10cSrcweir #ifndef DBG_UTIL 413cdf0e10cSrcweir { return pSttNd ? pSttNd->GetIndex() : 0; } 414cdf0e10cSrcweir #else 415cdf0e10cSrcweir ; 416cdf0e10cSrcweir #endif 417cdf0e10cSrcweir 418cdf0e10cSrcweir // suche nach der naechsten/vorherigen Box mit Inhalt 419cdf0e10cSrcweir SwTableBox* FindNextBox( const SwTable&, const SwTableBox* =0, 420cdf0e10cSrcweir sal_Bool bOvrTblLns=sal_True ) const; 421cdf0e10cSrcweir SwTableBox* FindPreviousBox( const SwTable&, const SwTableBox* =0, 422cdf0e10cSrcweir sal_Bool bOvrTblLns=sal_True ) const; 423cdf0e10cSrcweir // gebe den Namen dieser Box zurueck. Dieser wird dynamisch bestimmt 424cdf0e10cSrcweir // und ergibt sich aus der Position in den Lines/Boxen/Tabelle 425cdf0e10cSrcweir String GetName() const; 426cdf0e10cSrcweir // gebe den "Wert" der Box zurueck (fuers rechnen in der Tabelle) 427cdf0e10cSrcweir double GetValue( SwTblCalcPara& rPara ) const; 428cdf0e10cSrcweir 429cdf0e10cSrcweir sal_Bool IsInHeadline( const SwTable* pTbl = 0 ) const; 430cdf0e10cSrcweir 431cdf0e10cSrcweir // enthaelt die Box Inhalt, der als Nummer formatiert werden kann? 432cdf0e10cSrcweir sal_Bool HasNumCntnt( double& rNum, sal_uInt32& rFmtIndex, 433cdf0e10cSrcweir sal_Bool& rIsEmptyTxtNd ) const; 434cdf0e10cSrcweir sal_uLong IsValidNumTxtNd( sal_Bool bCheckAttr = sal_True ) const; 435cdf0e10cSrcweir // teste ob der BoxInhalt mit der Nummer uebereinstimmt, wenn eine 436cdf0e10cSrcweir // Tabellenformel gesetzt ist. (fuers Redo des Change vom NumFormat!) 437cdf0e10cSrcweir sal_Bool IsNumberChanged() const; 438cdf0e10cSrcweir 439cdf0e10cSrcweir // ist das eine FormelBox oder eine Box mit numerischen Inhalt (AutoSum) 440cdf0e10cSrcweir // Was es ist, besagt der ReturnWert - die WhichId des Attributes 441cdf0e10cSrcweir // Leere Boxen haben den ReturnWert USHRT_MAX !! 442cdf0e10cSrcweir sal_uInt16 IsFormulaOrValueBox() const; 443cdf0e10cSrcweir 444cdf0e10cSrcweir // Loading of a document requires an actualisation of cells with values 445cdf0e10cSrcweir void ActualiseValueBox(); 446cdf0e10cSrcweir 447cdf0e10cSrcweir DECL_FIXEDMEMPOOL_NEWDEL(SwTableBox) 448cdf0e10cSrcweir 449cdf0e10cSrcweir // zugriff auf interne Daten - z.Z. benutzt fuer den NumFormatter 450cdf0e10cSrcweir inline const Color* GetSaveUserColor() const; 451cdf0e10cSrcweir inline const Color* GetSaveNumFmtColor() const; 452cdf0e10cSrcweir inline void SetSaveUserColor(const Color* p ); 453cdf0e10cSrcweir inline void SetSaveNumFmtColor( const Color* p ); 454cdf0e10cSrcweir 455cdf0e10cSrcweir long getRowSpan() const; 456cdf0e10cSrcweir void setRowSpan( long nNewRowSpan ); 457cdf0e10cSrcweir bool getDummyFlag() const; 458cdf0e10cSrcweir void setDummyFlag( bool bDummy ); 459cdf0e10cSrcweir 460cdf0e10cSrcweir SwTableBox& FindStartOfRowSpan( const SwTable&, sal_uInt16 nMaxStep = USHRT_MAX ); FindStartOfRowSpan(const SwTable & rTable,sal_uInt16 nMaxStep=USHRT_MAX) const461cdf0e10cSrcweir const SwTableBox& FindStartOfRowSpan( const SwTable& rTable, 462cdf0e10cSrcweir sal_uInt16 nMaxStep = USHRT_MAX ) const 463cdf0e10cSrcweir { return const_cast<SwTableBox*>(this)->FindStartOfRowSpan( rTable, nMaxStep ); } 464cdf0e10cSrcweir 465cdf0e10cSrcweir SwTableBox& FindEndOfRowSpan( const SwTable&, sal_uInt16 nMaxStep = USHRT_MAX ); FindEndOfRowSpan(const SwTable & rTable,sal_uInt16 nMaxStep=USHRT_MAX) const466cdf0e10cSrcweir const SwTableBox& FindEndOfRowSpan( const SwTable& rTable, 467cdf0e10cSrcweir sal_uInt16 nMaxStep = USHRT_MAX ) const 468cdf0e10cSrcweir { return const_cast<SwTableBox*>(this)->FindEndOfRowSpan( rTable, nMaxStep ); } 469cdf0e10cSrcweir void RegisterToFormat( SwFmt& rFmt ) ; 470cdf0e10cSrcweir void ForgetFrmFmt(); 471cdf0e10cSrcweir }; 472cdf0e10cSrcweir 473cdf0e10cSrcweir class SwCellFrm; 474cdf0e10cSrcweir class SW_DLLPUBLIC SwTableCellInfo : public ::boost::noncopyable 475cdf0e10cSrcweir { 476cdf0e10cSrcweir struct Impl; 477cdf0e10cSrcweir ::std::auto_ptr<Impl> m_pImpl; 478cdf0e10cSrcweir 479cdf0e10cSrcweir const SwCellFrm * getCellFrm() const ; 480cdf0e10cSrcweir 481cdf0e10cSrcweir public: 482cdf0e10cSrcweir SwTableCellInfo(const SwTable * pTable); 483cdf0e10cSrcweir ~SwTableCellInfo(); 484cdf0e10cSrcweir 485cdf0e10cSrcweir bool getNext(); 486cdf0e10cSrcweir SwRect getRect() const; 487cdf0e10cSrcweir const SwTableBox * getTableBox() const; 488cdf0e10cSrcweir }; 489cdf0e10cSrcweir 490cdf0e10cSrcweir #endif //_SWTABLE_HXX 491