xref: /AOO41X/main/sw/source/core/inc/tblrwcl.hxx (revision 1d2dbeb0b7301723c6d13094e87a8714ef81a328)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _TBLRWCL_HXX
24 #define _TBLRWCL_HXX
25 #ifndef _SVSTDARR_HXX
26 #define _SVSTDARR_USHORTS
27 #include <svl/svstdarr.hxx>
28 #endif
29 #include <vector>
30 #include <swtypes.hxx>
31 #include <tblsel.hxx>
32 #include <swtable.hxx>
33 
34 class SvxBorderLine;
35 class SwDoc;
36 class SwTableNode;
37 class _FndLine;
38 class _FndBox;
39 class SwTableLine;
40 class SwTableBox;
41 class SwTableBoxFmt;
42 class SwHistory;
43 class SwCntntNode;
44 class SfxPoolItem;
45 class SwShareBoxFmts;
46 class SwFmtFrmSize;
47 
48 // Funktions Deklarationen:
49 sal_Bool lcl_CopyRow( const _FndLine*& rpFndLine, void* pPara );
50 sal_Bool lcl_CopyCol( const _FndBox*& rpFndBox, void* pPara );
51 
52 sal_Bool lcl_MergeGCBox( const SwTableBox*& rpBox, void* pPara );
53 sal_Bool lcl_MergeGCLine( const SwTableLine*& rpLine, void* pPara );
54 
55 sal_Bool lcl_Merge_MoveBox( const _FndBox*& rpFndBox, void* pPara );
56 sal_Bool lcl_Merge_MoveLine( const _FndLine*& rpFndLine, void* pPara );
57 
58 sal_Bool lcl_CopyBoxToDoc( const _FndBox*& rpFndBox, void* pPara );
59 sal_Bool lcl_CopyLineToDoc( const _FndLine*& rpFndLn, void* pPara );
60 
61 sal_Bool lcl_BoxSetHeadCondColl( const SwTableBox*& rpBox, void* pPara );
62 sal_Bool lcl_LineSetHeadCondColl( const SwTableLine*& rpLine, void* pPara );
63 
64 
65 #ifdef DBG_UTIL
66 void _CheckBoxWidth( const SwTableLine& rLine, SwTwips nSize );
67 #endif
68 
69 void _InsTblBox( SwDoc* pDoc, SwTableNode* pTblNd,
70                 SwTableLine* pLine, SwTableBoxFmt* pBoxFrmFmt,
71                 SwTableBox* pBox, sal_uInt16 nInsPos, sal_uInt16 nCnt = 1 );
72 
73 SW_DLLPUBLIC void _DeleteBox( SwTable& rTbl, SwTableBox* pBox, SwUndo* pUndo = 0,
74                 sal_Bool bCalcNewSize = sal_True, const sal_Bool bCorrBorder = sal_True,
75                 SwShareBoxFmts* pShareFmts = 0 );
76 
77 // Klasse fuers SplitTable
78 // sammelt von einer Line die Boxen aller obersten oder untersten Lines
79 // in einem Array. Zusaetzlich werden die Positionen vermerkt.
80 // ( die Implementierung steht im ndtbl.cxx)
81 
82 class SwCollectTblLineBoxes
83 {
84     SvUShorts aPosArr;
85     SwSelBoxes_SAR aBoxes;
86     SwHistory* pHst;
87     sal_uInt16 nMode, nWidth;
88     sal_Bool bGetFromTop : 1;
89     sal_Bool bGetValues : 1;
90 
91 public:
SwCollectTblLineBoxes(sal_Bool bTop,sal_uInt16 nMd=0,SwHistory * pHist=0)92     SwCollectTblLineBoxes( sal_Bool bTop, sal_uInt16 nMd = 0, SwHistory* pHist=0 )
93         : aPosArr( 16, 16 ), aBoxes( 16, 16 ),
94         pHst( pHist ), nMode( nMd ), nWidth( 0 ),
95         bGetFromTop( bTop ), bGetValues( sal_True )
96 
97     {}
98 
99     void AddBox( const SwTableBox& rBox );
100     const SwTableBox* GetBoxOfPos( const SwTableBox& rBox );
101     void AddToUndoHistory( const SwCntntNode& rNd );
102 
Count() const103     sal_uInt16 Count() const                { return aBoxes.Count(); }
GetBox(sal_uInt16 nPos,sal_uInt16 * pWidth=0) const104     const SwTableBox& GetBox( sal_uInt16 nPos, sal_uInt16* pWidth = 0 ) const
105         {
106             // hier wird die EndPos der Spalte benoetigt!
107             if( pWidth )
108                 *pWidth = nPos+1 == aPosArr.Count() ? nWidth
109                                                     : aPosArr[ nPos+1 ];
110             return *aBoxes[ nPos ];
111         }
112 
IsGetFromTop() const113     sal_Bool IsGetFromTop() const           { return bGetFromTop; }
IsGetValues() const114     sal_Bool IsGetValues() const            { return bGetValues; }
115 
GetMode() const116     sal_uInt16 GetMode() const              { return nMode; }
SetValues(sal_Bool bFlag)117     void SetValues( sal_Bool bFlag )        { bGetValues = sal_False; nWidth = 0;
118                                           bGetFromTop = bFlag; }
119     sal_Bool Resize( sal_uInt16 nOffset, sal_uInt16 nWidth );
120 };
121 
122 sal_Bool lcl_Box_CollectBox( const SwTableBox*& rpBox, void* pPara );
123 sal_Bool lcl_Line_CollectBox( const SwTableLine*& rpLine, void* pPara );
124 
125 sal_Bool lcl_BoxSetSplitBoxFmts( const SwTableBox*& rpBox, void* pPara );
126 
127 // This structure is needed by Undo to restore row span attributes
128 // when a table has been splitted into two tables
129 struct SwSaveRowSpan
130 {
131     sal_uInt16 mnSplitLine; // the line number where the table has been splitted
132     std::vector< long > mnRowSpans; // the row span attributes in this line
133     SwSaveRowSpan( SwTableBoxes& rBoxes, sal_uInt16 nSplitLn );
134 };
135 
136 struct _SwGCLineBorder
137 {
138     const SwTableLines* pLines;
139     SwShareBoxFmts* pShareFmts;
140     sal_uInt16 nLinePos;
141 
_SwGCLineBorder_SwGCLineBorder142     _SwGCLineBorder( const SwTable& rTable )
143         : pLines( &rTable.GetTabLines() ), pShareFmts(0), nLinePos( 0 )  {}
144 
_SwGCLineBorder_SwGCLineBorder145     _SwGCLineBorder( const SwTableBox& rBox )
146         : pLines( &rBox.GetTabLines() ), pShareFmts(0), nLinePos( 0 )  {}
IsLastLine_SwGCLineBorder147     sal_Bool IsLastLine() const { return nLinePos + 1 >= pLines->Count(); }
148 };
149 
150 class _SwGCBorder_BoxBrd
151 {
152     const SvxBorderLine* pBrdLn;
153     sal_Bool bAnyBorderFnd;
154 public:
_SwGCBorder_BoxBrd()155     _SwGCBorder_BoxBrd() : pBrdLn( 0 ), bAnyBorderFnd( sal_False ) {}
156 
SetBorder(const SvxBorderLine & rBorderLine)157     void SetBorder( const SvxBorderLine& rBorderLine )
158         { pBrdLn = &rBorderLine; bAnyBorderFnd = sal_False; }
159 
160     // checke, ob die linke Border dieselbe wie die gesetzte ist
161     // returnt sal_False falls gar keine Border gesetzt ist
162     sal_Bool CheckLeftBorderOfFormat( const SwFrmFmt& rFmt );
163 
IsAnyBorderFound() const164     sal_Bool IsAnyBorderFound() const { return bAnyBorderFnd; }
165 };
166 
167 sal_Bool lcl_GC_Line_Border( const SwTableLine*& , void* pPara );
168 sal_Bool lcl_GC_Box_Border( const SwTableBox*& , void* pPara );
169 
170 sal_Bool lcl_GCBorder_ChkBoxBrd_L( const SwTableLine*& , void* pPara );
171 sal_Bool lcl_GCBorder_ChkBoxBrd_B( const SwTableBox*& , void* pPara );
172 
173 sal_Bool lcl_GCBorder_GetLastBox_L( const SwTableLine*& , void* pPara );
174 sal_Bool lcl_GCBorder_GetLastBox_B( const SwTableBox*& , void* pPara );
175 
176 
177 class SwShareBoxFmt
178 {
179     const SwFrmFmt* pOldFmt;
180     SvPtrarr aNewFmts;
181 
182 public:
SwShareBoxFmt(const SwFrmFmt & rFmt)183     SwShareBoxFmt( const SwFrmFmt& rFmt )
184         : pOldFmt( &rFmt ), aNewFmts( 1, 4 )
185     {}
186 
GetOldFormat() const187     const SwFrmFmt& GetOldFormat() const { return *pOldFmt; }
188 
189     SwFrmFmt* GetFormat( long nWidth ) const;
190     SwFrmFmt* GetFormat( const SfxPoolItem& rItem ) const;
191     void AddFormat( const SwFrmFmt& rFmt );
192     // returnt sal_True, wenn geloescht werden kann
193     sal_Bool RemoveFormat( const SwFrmFmt& rFmt );
194 };
195 
196 
197 SV_DECL_PTRARR_DEL( _SwShareBoxFmts, SwShareBoxFmt*, 8, 8 )
198 
199 class SwShareBoxFmts
200 {
201     _SwShareBoxFmts aShareArr;
202     sal_Bool Seek_Entry( const SwFrmFmt& rFmt, sal_uInt16* pPos ) const;
203 
204     void ChangeFrmFmt( SwTableBox* pBox, SwTableLine* pLn, SwFrmFmt& rFmt );
205 
206 public:
SwShareBoxFmts()207     SwShareBoxFmts() {}
208     ~SwShareBoxFmts();
209 
210     SwFrmFmt* GetFormat( const SwFrmFmt& rFmt, long nWidth ) const;
211     SwFrmFmt* GetFormat( const SwFrmFmt& rFmt, const SfxPoolItem& ) const;
212 
213     void AddFormat( const SwFrmFmt& rOld, const SwFrmFmt& rNew );
214 
215     void SetSize( SwTableBox& rBox, const SwFmtFrmSize& rSz );
216     void SetAttr( SwTableBox& rBox, const SfxPoolItem& rItem );
217     void SetAttr( SwTableLine& rLine, const SfxPoolItem& rItem );
218 
219     void RemoveFormat( const SwFrmFmt& rFmt );
220 };
221 
222 
223 
224 #endif
225