1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tblrwcl.hxx,v $
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 ************************************************************************/
33 #define _SVSTDARR_USHORTS
34 #include <svtools/svstdarr.hxx>
37 #include <swtypes.hxx>
39 #include <swtable.hxx>
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
);
73 void _CheckBoxWidth( const SwTableLine
& rLine
, SwTwips nSize
);
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
92 SwSelBoxes_SAR aBoxes
;
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!
115 *pWidth
= nPos
+1 == aPosArr
.Count() ? nWidth
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
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
;
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
;
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
);
186 const SwFrmFmt
* pOldFmt
;
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 )
208 _SwShareBoxFmts aShareArr
;
209 BOOL
Seek_Entry( const SwFrmFmt
& rFmt
, USHORT
* pPos
) const;
211 void ChangeFrmFmt( SwTableBox
* pBox
, SwTableLine
* pLn
, SwFrmFmt
& rFmt
);
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
);