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 _TBLRWCL_HXX 24cdf0e10cSrcweir #define _TBLRWCL_HXX 25cdf0e10cSrcweir #ifndef _SVSTDARR_HXX 26cdf0e10cSrcweir #define _SVSTDARR_USHORTS 27cdf0e10cSrcweir #include <svl/svstdarr.hxx> 28cdf0e10cSrcweir #endif 29cdf0e10cSrcweir #include <vector> 30cdf0e10cSrcweir #include <swtypes.hxx> 31cdf0e10cSrcweir #include <tblsel.hxx> 32cdf0e10cSrcweir #include <swtable.hxx> 33cdf0e10cSrcweir 34cdf0e10cSrcweir class SvxBorderLine; 35cdf0e10cSrcweir class SwDoc; 36cdf0e10cSrcweir class SwTableNode; 37cdf0e10cSrcweir class _FndLine; 38cdf0e10cSrcweir class _FndBox; 39cdf0e10cSrcweir class SwTableLine; 40cdf0e10cSrcweir class SwTableBox; 41cdf0e10cSrcweir class SwTableBoxFmt; 42cdf0e10cSrcweir class SwHistory; 43cdf0e10cSrcweir class SwCntntNode; 44cdf0e10cSrcweir class SfxPoolItem; 45cdf0e10cSrcweir class SwShareBoxFmts; 46cdf0e10cSrcweir class SwFmtFrmSize; 47cdf0e10cSrcweir 48cdf0e10cSrcweir // Funktions Deklarationen: 49cdf0e10cSrcweir sal_Bool lcl_CopyRow( const _FndLine*& rpFndLine, void* pPara ); 50cdf0e10cSrcweir sal_Bool lcl_CopyCol( const _FndBox*& rpFndBox, void* pPara ); 51cdf0e10cSrcweir 52cdf0e10cSrcweir sal_Bool lcl_MergeGCBox( const SwTableBox*& rpBox, void* pPara ); 53cdf0e10cSrcweir sal_Bool lcl_MergeGCLine( const SwTableLine*& rpLine, void* pPara ); 54cdf0e10cSrcweir 55cdf0e10cSrcweir sal_Bool lcl_Merge_MoveBox( const _FndBox*& rpFndBox, void* pPara ); 56cdf0e10cSrcweir sal_Bool lcl_Merge_MoveLine( const _FndLine*& rpFndLine, void* pPara ); 57cdf0e10cSrcweir 58cdf0e10cSrcweir sal_Bool lcl_CopyBoxToDoc( const _FndBox*& rpFndBox, void* pPara ); 59cdf0e10cSrcweir sal_Bool lcl_CopyLineToDoc( const _FndLine*& rpFndLn, void* pPara ); 60cdf0e10cSrcweir 61cdf0e10cSrcweir sal_Bool lcl_BoxSetHeadCondColl( const SwTableBox*& rpBox, void* pPara ); 62cdf0e10cSrcweir sal_Bool lcl_LineSetHeadCondColl( const SwTableLine*& rpLine, void* pPara ); 63cdf0e10cSrcweir 64cdf0e10cSrcweir 65cdf0e10cSrcweir #ifdef DBG_UTIL 66cdf0e10cSrcweir void _CheckBoxWidth( const SwTableLine& rLine, SwTwips nSize ); 67cdf0e10cSrcweir #endif 68cdf0e10cSrcweir 69cdf0e10cSrcweir void _InsTblBox( SwDoc* pDoc, SwTableNode* pTblNd, 70cdf0e10cSrcweir SwTableLine* pLine, SwTableBoxFmt* pBoxFrmFmt, 71cdf0e10cSrcweir SwTableBox* pBox, sal_uInt16 nInsPos, sal_uInt16 nCnt = 1 ); 72cdf0e10cSrcweir 73cdf0e10cSrcweir SW_DLLPUBLIC void _DeleteBox( SwTable& rTbl, SwTableBox* pBox, SwUndo* pUndo = 0, 74cdf0e10cSrcweir sal_Bool bCalcNewSize = sal_True, const sal_Bool bCorrBorder = sal_True, 75cdf0e10cSrcweir SwShareBoxFmts* pShareFmts = 0 ); 76cdf0e10cSrcweir 77cdf0e10cSrcweir // Klasse fuers SplitTable 78cdf0e10cSrcweir // sammelt von einer Line die Boxen aller obersten oder untersten Lines 79cdf0e10cSrcweir // in einem Array. Zusaetzlich werden die Positionen vermerkt. 80cdf0e10cSrcweir // ( die Implementierung steht im ndtbl.cxx) 81cdf0e10cSrcweir 82cdf0e10cSrcweir class SwCollectTblLineBoxes 83cdf0e10cSrcweir { 84cdf0e10cSrcweir SvUShorts aPosArr; 85cdf0e10cSrcweir SwSelBoxes_SAR aBoxes; 86cdf0e10cSrcweir SwHistory* pHst; 87cdf0e10cSrcweir sal_uInt16 nMode, nWidth; 88cdf0e10cSrcweir sal_Bool bGetFromTop : 1; 89cdf0e10cSrcweir sal_Bool bGetValues : 1; 90cdf0e10cSrcweir 91cdf0e10cSrcweir public: SwCollectTblLineBoxes(sal_Bool bTop,sal_uInt16 nMd=0,SwHistory * pHist=0)92cdf0e10cSrcweir SwCollectTblLineBoxes( sal_Bool bTop, sal_uInt16 nMd = 0, SwHistory* pHist=0 ) 93cdf0e10cSrcweir : aPosArr( 16, 16 ), aBoxes( 16, 16 ), 94cdf0e10cSrcweir pHst( pHist ), nMode( nMd ), nWidth( 0 ), 95cdf0e10cSrcweir bGetFromTop( bTop ), bGetValues( sal_True ) 96cdf0e10cSrcweir 97cdf0e10cSrcweir {} 98cdf0e10cSrcweir 99cdf0e10cSrcweir void AddBox( const SwTableBox& rBox ); 100cdf0e10cSrcweir const SwTableBox* GetBoxOfPos( const SwTableBox& rBox ); 101cdf0e10cSrcweir void AddToUndoHistory( const SwCntntNode& rNd ); 102cdf0e10cSrcweir Count() const103cdf0e10cSrcweir sal_uInt16 Count() const { return aBoxes.Count(); } GetBox(sal_uInt16 nPos,sal_uInt16 * pWidth=0) const104cdf0e10cSrcweir const SwTableBox& GetBox( sal_uInt16 nPos, sal_uInt16* pWidth = 0 ) const 105cdf0e10cSrcweir { 106cdf0e10cSrcweir // hier wird die EndPos der Spalte benoetigt! 107cdf0e10cSrcweir if( pWidth ) 108cdf0e10cSrcweir *pWidth = nPos+1 == aPosArr.Count() ? nWidth 109cdf0e10cSrcweir : aPosArr[ nPos+1 ]; 110cdf0e10cSrcweir return *aBoxes[ nPos ]; 111cdf0e10cSrcweir } 112cdf0e10cSrcweir IsGetFromTop() const113cdf0e10cSrcweir sal_Bool IsGetFromTop() const { return bGetFromTop; } IsGetValues() const114cdf0e10cSrcweir sal_Bool IsGetValues() const { return bGetValues; } 115cdf0e10cSrcweir GetMode() const116cdf0e10cSrcweir sal_uInt16 GetMode() const { return nMode; } SetValues(sal_Bool bFlag)117cdf0e10cSrcweir void SetValues( sal_Bool bFlag ) { bGetValues = sal_False; nWidth = 0; 118cdf0e10cSrcweir bGetFromTop = bFlag; } 119cdf0e10cSrcweir sal_Bool Resize( sal_uInt16 nOffset, sal_uInt16 nWidth ); 120cdf0e10cSrcweir }; 121cdf0e10cSrcweir 122cdf0e10cSrcweir sal_Bool lcl_Box_CollectBox( const SwTableBox*& rpBox, void* pPara ); 123cdf0e10cSrcweir sal_Bool lcl_Line_CollectBox( const SwTableLine*& rpLine, void* pPara ); 124cdf0e10cSrcweir 125cdf0e10cSrcweir sal_Bool lcl_BoxSetSplitBoxFmts( const SwTableBox*& rpBox, void* pPara ); 126cdf0e10cSrcweir 127cdf0e10cSrcweir // This structure is needed by Undo to restore row span attributes 128cdf0e10cSrcweir // when a table has been splitted into two tables 129cdf0e10cSrcweir struct SwSaveRowSpan 130cdf0e10cSrcweir { 131cdf0e10cSrcweir sal_uInt16 mnSplitLine; // the line number where the table has been splitted 132cdf0e10cSrcweir std::vector< long > mnRowSpans; // the row span attributes in this line 133cdf0e10cSrcweir SwSaveRowSpan( SwTableBoxes& rBoxes, sal_uInt16 nSplitLn ); 134cdf0e10cSrcweir }; 135cdf0e10cSrcweir 136cdf0e10cSrcweir struct _SwGCLineBorder 137cdf0e10cSrcweir { 138cdf0e10cSrcweir const SwTableLines* pLines; 139cdf0e10cSrcweir SwShareBoxFmts* pShareFmts; 140cdf0e10cSrcweir sal_uInt16 nLinePos; 141cdf0e10cSrcweir _SwGCLineBorder_SwGCLineBorder142cdf0e10cSrcweir _SwGCLineBorder( const SwTable& rTable ) 143cdf0e10cSrcweir : pLines( &rTable.GetTabLines() ), pShareFmts(0), nLinePos( 0 ) {} 144cdf0e10cSrcweir _SwGCLineBorder_SwGCLineBorder145cdf0e10cSrcweir _SwGCLineBorder( const SwTableBox& rBox ) 146cdf0e10cSrcweir : pLines( &rBox.GetTabLines() ), pShareFmts(0), nLinePos( 0 ) {} IsLastLine_SwGCLineBorder147cdf0e10cSrcweir sal_Bool IsLastLine() const { return nLinePos + 1 >= pLines->Count(); } 148cdf0e10cSrcweir }; 149cdf0e10cSrcweir 150cdf0e10cSrcweir class _SwGCBorder_BoxBrd 151cdf0e10cSrcweir { 152cdf0e10cSrcweir const SvxBorderLine* pBrdLn; 153cdf0e10cSrcweir sal_Bool bAnyBorderFnd; 154cdf0e10cSrcweir public: _SwGCBorder_BoxBrd()155cdf0e10cSrcweir _SwGCBorder_BoxBrd() : pBrdLn( 0 ), bAnyBorderFnd( sal_False ) {} 156cdf0e10cSrcweir SetBorder(const SvxBorderLine & rBorderLine)157cdf0e10cSrcweir void SetBorder( const SvxBorderLine& rBorderLine ) 158cdf0e10cSrcweir { pBrdLn = &rBorderLine; bAnyBorderFnd = sal_False; } 159cdf0e10cSrcweir 160cdf0e10cSrcweir // checke, ob die linke Border dieselbe wie die gesetzte ist 161cdf0e10cSrcweir // returnt sal_False falls gar keine Border gesetzt ist 162cdf0e10cSrcweir sal_Bool CheckLeftBorderOfFormat( const SwFrmFmt& rFmt ); 163cdf0e10cSrcweir IsAnyBorderFound() const164cdf0e10cSrcweir sal_Bool IsAnyBorderFound() const { return bAnyBorderFnd; } 165cdf0e10cSrcweir }; 166cdf0e10cSrcweir 167cdf0e10cSrcweir sal_Bool lcl_GC_Line_Border( const SwTableLine*& , void* pPara ); 168cdf0e10cSrcweir sal_Bool lcl_GC_Box_Border( const SwTableBox*& , void* pPara ); 169cdf0e10cSrcweir 170cdf0e10cSrcweir sal_Bool lcl_GCBorder_ChkBoxBrd_L( const SwTableLine*& , void* pPara ); 171cdf0e10cSrcweir sal_Bool lcl_GCBorder_ChkBoxBrd_B( const SwTableBox*& , void* pPara ); 172cdf0e10cSrcweir 173cdf0e10cSrcweir sal_Bool lcl_GCBorder_GetLastBox_L( const SwTableLine*& , void* pPara ); 174cdf0e10cSrcweir sal_Bool lcl_GCBorder_GetLastBox_B( const SwTableBox*& , void* pPara ); 175cdf0e10cSrcweir 176cdf0e10cSrcweir 177cdf0e10cSrcweir class SwShareBoxFmt 178cdf0e10cSrcweir { 179cdf0e10cSrcweir const SwFrmFmt* pOldFmt; 180cdf0e10cSrcweir SvPtrarr aNewFmts; 181cdf0e10cSrcweir 182cdf0e10cSrcweir public: SwShareBoxFmt(const SwFrmFmt & rFmt)183cdf0e10cSrcweir SwShareBoxFmt( const SwFrmFmt& rFmt ) 184cdf0e10cSrcweir : pOldFmt( &rFmt ), aNewFmts( 1, 4 ) 185cdf0e10cSrcweir {} 186cdf0e10cSrcweir GetOldFormat() const187cdf0e10cSrcweir const SwFrmFmt& GetOldFormat() const { return *pOldFmt; } 188cdf0e10cSrcweir 189cdf0e10cSrcweir SwFrmFmt* GetFormat( long nWidth ) const; 190cdf0e10cSrcweir SwFrmFmt* GetFormat( const SfxPoolItem& rItem ) const; 191cdf0e10cSrcweir void AddFormat( const SwFrmFmt& rFmt ); 192cdf0e10cSrcweir // returnt sal_True, wenn geloescht werden kann 193cdf0e10cSrcweir sal_Bool RemoveFormat( const SwFrmFmt& rFmt ); 194cdf0e10cSrcweir }; 195cdf0e10cSrcweir 196cdf0e10cSrcweir 197cdf0e10cSrcweir SV_DECL_PTRARR_DEL( _SwShareBoxFmts, SwShareBoxFmt*, 8, 8 ) 198cdf0e10cSrcweir 199cdf0e10cSrcweir class SwShareBoxFmts 200cdf0e10cSrcweir { 201cdf0e10cSrcweir _SwShareBoxFmts aShareArr; 202cdf0e10cSrcweir sal_Bool Seek_Entry( const SwFrmFmt& rFmt, sal_uInt16* pPos ) const; 203cdf0e10cSrcweir 204cdf0e10cSrcweir void ChangeFrmFmt( SwTableBox* pBox, SwTableLine* pLn, SwFrmFmt& rFmt ); 205cdf0e10cSrcweir 206cdf0e10cSrcweir public: SwShareBoxFmts()207cdf0e10cSrcweir SwShareBoxFmts() {} 208cdf0e10cSrcweir ~SwShareBoxFmts(); 209cdf0e10cSrcweir 210cdf0e10cSrcweir SwFrmFmt* GetFormat( const SwFrmFmt& rFmt, long nWidth ) const; 211cdf0e10cSrcweir SwFrmFmt* GetFormat( const SwFrmFmt& rFmt, const SfxPoolItem& ) const; 212cdf0e10cSrcweir 213cdf0e10cSrcweir void AddFormat( const SwFrmFmt& rOld, const SwFrmFmt& rNew ); 214cdf0e10cSrcweir 215cdf0e10cSrcweir void SetSize( SwTableBox& rBox, const SwFmtFrmSize& rSz ); 216cdf0e10cSrcweir void SetAttr( SwTableBox& rBox, const SfxPoolItem& rItem ); 217cdf0e10cSrcweir void SetAttr( SwTableLine& rLine, const SfxPoolItem& rItem ); 218cdf0e10cSrcweir 219cdf0e10cSrcweir void RemoveFormat( const SwFrmFmt& rFmt ); 220cdf0e10cSrcweir }; 221cdf0e10cSrcweir 222cdf0e10cSrcweir 223cdf0e10cSrcweir 224cdf0e10cSrcweir #endif 225