Update ooo320-m1
[ooovba.git] / sw / source / core / inc / tblrwcl.hxx
blob62e71094ed9bac0f9c03b8020980e790898aea8c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tblrwcl.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _TBLRWCL_HXX
31 #define _TBLRWCL_HXX
32 #ifndef _SVSTDARR_HXX
33 #define _SVSTDARR_USHORTS
34 #include <svtools/svstdarr.hxx>
35 #endif
36 #include <vector>
37 #include <swtypes.hxx>
38 #include <tblsel.hxx>
39 #include <swtable.hxx>
41 class SvxBorderLine;
42 class SwDoc;
43 class SwTableNode;
44 class _FndLine;
45 class _FndBox;
46 class SwTableLine;
47 class SwTableBox;
48 class SwTableBoxFmt;
49 class SwHistory;
50 class SwCntntNode;
51 class SfxPoolItem;
52 class SwShareBoxFmts;
53 class SwFmtFrmSize;
55 // Funktions Deklarationen:
56 BOOL lcl_CopyRow( const _FndLine*& rpFndLine, void* pPara );
57 BOOL lcl_CopyCol( const _FndBox*& rpFndBox, void* pPara );
59 BOOL lcl_MergeGCBox( const SwTableBox*& rpBox, void* pPara );
60 BOOL lcl_MergeGCLine( const SwTableLine*& rpLine, void* pPara );
62 BOOL lcl_Merge_MoveBox( const _FndBox*& rpFndBox, void* pPara );
63 BOOL lcl_Merge_MoveLine( const _FndLine*& rpFndLine, void* pPara );
65 BOOL lcl_CopyBoxToDoc( const _FndBox*& rpFndBox, void* pPara );
66 BOOL lcl_CopyLineToDoc( const _FndLine*& rpFndLn, void* pPara );
68 BOOL lcl_BoxSetHeadCondColl( const SwTableBox*& rpBox, void* pPara );
69 BOOL lcl_LineSetHeadCondColl( const SwTableLine*& rpLine, void* pPara );
72 #ifndef PRODUCT
73 void _CheckBoxWidth( const SwTableLine& rLine, SwTwips nSize );
74 #endif
76 void _InsTblBox( SwDoc* pDoc, SwTableNode* pTblNd,
77 SwTableLine* pLine, SwTableBoxFmt* pBoxFrmFmt,
78 SwTableBox* pBox, USHORT nInsPos, USHORT nCnt = 1 );
80 SW_DLLPUBLIC void _DeleteBox( SwTable& rTbl, SwTableBox* pBox, SwUndo* pUndo = 0,
81 BOOL bCalcNewSize = TRUE, const BOOL bCorrBorder = TRUE,
82 SwShareBoxFmts* pShareFmts = 0 );
84 // Klasse fuers SplitTable
85 // sammelt von einer Line die Boxen aller obersten oder untersten Lines
86 // in einem Array. Zusaetzlich werden die Positionen vermerkt.
87 // ( die Implementierung steht im ndtbl.cxx)
89 class SwCollectTblLineBoxes
91 SvUShorts aPosArr;
92 SwSelBoxes_SAR aBoxes;
93 SwHistory* pHst;
94 USHORT nMode, nWidth;
95 BOOL bGetFromTop : 1;
96 BOOL bGetValues : 1;
98 public:
99 SwCollectTblLineBoxes( BOOL bTop, USHORT nMd = 0, SwHistory* pHist=0 )
100 : aPosArr( 16, 16 ), aBoxes( 16, 16 ),
101 pHst( pHist ), nMode( nMd ), nWidth( 0 ),
102 bGetFromTop( bTop ), bGetValues( TRUE )
106 void AddBox( const SwTableBox& rBox );
107 const SwTableBox* GetBoxOfPos( const SwTableBox& rBox );
108 void AddToUndoHistory( const SwCntntNode& rNd );
110 USHORT Count() const { return aBoxes.Count(); }
111 const SwTableBox& GetBox( USHORT nPos, USHORT* pWidth = 0 ) const
113 // hier wird die EndPos der Spalte benoetigt!
114 if( pWidth )
115 *pWidth = nPos+1 == aPosArr.Count() ? nWidth
116 : aPosArr[ nPos+1 ];
117 return *aBoxes[ nPos ];
120 BOOL IsGetFromTop() const { return bGetFromTop; }
121 BOOL IsGetValues() const { return bGetValues; }
123 USHORT GetMode() const { return nMode; }
124 void SetValues( BOOL bFlag ) { bGetValues = FALSE; nWidth = 0;
125 bGetFromTop = bFlag; }
126 BOOL Resize( USHORT nOffset, USHORT nWidth );
129 BOOL lcl_Box_CollectBox( const SwTableBox*& rpBox, void* pPara );
130 BOOL lcl_Line_CollectBox( const SwTableLine*& rpLine, void* pPara );
132 BOOL lcl_BoxSetSplitBoxFmts( const SwTableBox*& rpBox, void* pPara );
134 // This structure is needed by Undo to restore row span attributes
135 // when a table has been splitted into two tables
136 struct SwSaveRowSpan
138 USHORT mnSplitLine; // the line number where the table has been splitted
139 std::vector< long > mnRowSpans; // the row span attributes in this line
140 SwSaveRowSpan( SwTableBoxes& rBoxes, USHORT nSplitLn );
143 struct _SwGCLineBorder
145 const SwTableLines* pLines;
146 SwShareBoxFmts* pShareFmts;
147 USHORT nLinePos;
149 _SwGCLineBorder( const SwTable& rTable )
150 : pLines( &rTable.GetTabLines() ), pShareFmts(0), nLinePos( 0 ) {}
152 _SwGCLineBorder( const SwTableBox& rBox )
153 : pLines( &rBox.GetTabLines() ), pShareFmts(0), nLinePos( 0 ) {}
154 BOOL IsLastLine() const { return nLinePos + 1 >= pLines->Count(); }
157 class _SwGCBorder_BoxBrd
159 const SvxBorderLine* pBrdLn;
160 BOOL bAnyBorderFnd;
161 public:
162 _SwGCBorder_BoxBrd() : pBrdLn( 0 ), bAnyBorderFnd( FALSE ) {}
164 void SetBorder( const SvxBorderLine& rBorderLine )
165 { pBrdLn = &rBorderLine; bAnyBorderFnd = FALSE; }
167 // checke, ob die linke Border dieselbe wie die gesetzte ist
168 // returnt FALSE falls gar keine Border gesetzt ist
169 BOOL CheckLeftBorderOfFormat( const SwFrmFmt& rFmt );
171 BOOL IsAnyBorderFound() const { return bAnyBorderFnd; }
174 BOOL lcl_GC_Line_Border( const SwTableLine*& , void* pPara );
175 BOOL lcl_GC_Box_Border( const SwTableBox*& , void* pPara );
177 BOOL lcl_GCBorder_ChkBoxBrd_L( const SwTableLine*& , void* pPara );
178 BOOL lcl_GCBorder_ChkBoxBrd_B( const SwTableBox*& , void* pPara );
180 BOOL lcl_GCBorder_GetLastBox_L( const SwTableLine*& , void* pPara );
181 BOOL lcl_GCBorder_GetLastBox_B( const SwTableBox*& , void* pPara );
184 class SwShareBoxFmt
186 const SwFrmFmt* pOldFmt;
187 SvPtrarr aNewFmts;
189 public:
190 SwShareBoxFmt( const SwFrmFmt& rFmt )
191 : pOldFmt( &rFmt ), aNewFmts( 1, 4 )
194 const SwFrmFmt& GetOldFormat() const { return *pOldFmt; }
196 SwFrmFmt* GetFormat( long nWidth ) const;
197 SwFrmFmt* GetFormat( const SfxPoolItem& rItem ) const;
198 void AddFormat( const SwFrmFmt& rFmt );
199 // returnt TRUE, wenn geloescht werden kann
200 BOOL RemoveFormat( const SwFrmFmt& rFmt );
204 SV_DECL_PTRARR_DEL( _SwShareBoxFmts, SwShareBoxFmt*, 8, 8 )
206 class SwShareBoxFmts
208 _SwShareBoxFmts aShareArr;
209 BOOL Seek_Entry( const SwFrmFmt& rFmt, USHORT* pPos ) const;
211 void ChangeFrmFmt( SwTableBox* pBox, SwTableLine* pLn, SwFrmFmt& rFmt );
213 public:
214 SwShareBoxFmts() {}
215 ~SwShareBoxFmts();
217 SwFrmFmt* GetFormat( const SwFrmFmt& rFmt, long nWidth ) const;
218 SwFrmFmt* GetFormat( const SwFrmFmt& rFmt, const SfxPoolItem& ) const;
220 void AddFormat( const SwFrmFmt& rOld, const SwFrmFmt& rNew );
222 void SetSize( SwTableBox& rBox, const SwFmtFrmSize& rSz );
223 void SetAttr( SwTableBox& rBox, const SfxPoolItem& rItem );
224 void SetAttr( SwTableLine& rLine, const SfxPoolItem& rItem );
226 void RemoveFormat( const SwFrmFmt& rFmt );
231 #endif