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