xref: /AOO41X/main/sw/inc/htmltbl.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 
28*cdf0e10cSrcweir #ifndef _HTMLTBL_HXX
29*cdf0e10cSrcweir #define _HTMLTBL_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include <vcl/timer.hxx>
33*cdf0e10cSrcweir #include <editeng/svxenum.hxx>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include "swtypes.hxx"
36*cdf0e10cSrcweir #include "node.hxx"		// Fuer SwStartNode
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir class SwTableBox;
40*cdf0e10cSrcweir class SwTable;
41*cdf0e10cSrcweir class SwHTMLTableLayout;
42*cdf0e10cSrcweir class SwDoc;
43*cdf0e10cSrcweir class SwFrmFmt;
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir #define HTMLTABLE_RESIZE_NOW (ULONG_MAX)
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir class SwHTMLTableLayoutCnts
48*cdf0e10cSrcweir {
49*cdf0e10cSrcweir 	SwHTMLTableLayoutCnts *pNext;	// der naechste Inhalt
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir 	// von den beiden naechsten Pointern darf nur einer gesetzt sein!
52*cdf0e10cSrcweir 	SwTableBox *pBox;	   		// ein Box
53*cdf0e10cSrcweir 	SwHTMLTableLayout *pTable;	// eine "Tabelle in der Tabelle"
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir 	// Beim ersten Durchlauf gibt es noch keine Boxen. Es wird dann
56*cdf0e10cSrcweir 	// pStartNode anstelle von pBox verwendet.
57*cdf0e10cSrcweir 	const SwStartNode *pStartNode;
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir 	// Die folgenden Zahler geben an, wie oft ein Pass bereits fuer diesen
60*cdf0e10cSrcweir 	// Inhalt durchgefuehrt wurde. Dazu werden sie mit einer Soll-Vorgabe
61*cdf0e10cSrcweir 	// verglichen. Wird 255 erreicht laufen sie bei 0 weiter. So wird
62*cdf0e10cSrcweir 	// eine Reinitialisierung bei jedem Resize vermieden.
63*cdf0e10cSrcweir 	sal_uInt8 nPass1Done;      		// Wieoft wurde Pass 1 aufgerufen?
64*cdf0e10cSrcweir 	sal_uInt8 nWidthSet;				// Wieoft wurde die Breite gesetzt?
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir 	sal_Bool bNoBreakTag;		// <NOBR>-Tag ueber gesamten Inhalt
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir public:
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir 	SwHTMLTableLayoutCnts( const SwStartNode* pSttNd, SwHTMLTableLayout* pTab,
71*cdf0e10cSrcweir 						   sal_Bool bNoBreakTag, SwHTMLTableLayoutCnts* pNxt );
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir 	~SwHTMLTableLayoutCnts();
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir 	void SetTableBox( SwTableBox *pBx ) { pBox = pBx; }
76*cdf0e10cSrcweir 	SwTableBox *GetTableBox() const { return pBox; }
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir 	SwHTMLTableLayout *GetTable() const { return pTable; }
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir 	const SwStartNode *GetStartNode() const;
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir 	// Ermitteln des naechsten Knotens
83*cdf0e10cSrcweir 	SwHTMLTableLayoutCnts *GetNext() const { return pNext; }
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir 	void SetWidthSet( sal_uInt8 nRef ) { nWidthSet = nRef; }
86*cdf0e10cSrcweir 	sal_Bool IsWidthSet( sal_uInt8 nRef ) const { return nRef==nWidthSet; }
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 	void SetPass1Done( sal_uInt8 nRef ) { nPass1Done = nRef; }
89*cdf0e10cSrcweir 	sal_Bool IsPass1Done( sal_uInt8 nRef ) const { return nRef==nPass1Done; }
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir 	sal_Bool HasNoBreakTag() const { return bNoBreakTag; }
92*cdf0e10cSrcweir };
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir /*  */
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir class SwHTMLTableLayoutCell
97*cdf0e10cSrcweir {
98*cdf0e10cSrcweir 	SwHTMLTableLayoutCnts *pContents;  		// der Inhalt der Zelle
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 	sal_uInt16 nRowSpan;	// ROWSPAN der Zelle
101*cdf0e10cSrcweir 	sal_uInt16 nColSpan;	// COLSPAN der Zelle
102*cdf0e10cSrcweir 	sal_uInt16 nWidthOption;// angegebene Breite der Zelle in Twip oder %
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 	sal_Bool bPrcWidthOption : 1;// nWidth ist %-Angabe
105*cdf0e10cSrcweir 	sal_Bool bNoWrapOption : 1;	// NOWRAP-Option
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir public:
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 	SwHTMLTableLayoutCell( SwHTMLTableLayoutCnts *pCnts,
110*cdf0e10cSrcweir 						 sal_uInt16 nRSpan, sal_uInt16 nCSpan,
111*cdf0e10cSrcweir 						 sal_uInt16 nWidthOpt, sal_Bool bPrcWdthOpt,
112*cdf0e10cSrcweir 						 sal_Bool nNWrapOpt );
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 	~SwHTMLTableLayoutCell();
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir 	// Setzen/Ermitteln des Inhalts einer Zelle
117*cdf0e10cSrcweir 	void SetContents( SwHTMLTableLayoutCnts *pCnts ) { pContents = pCnts; }
118*cdf0e10cSrcweir 	SwHTMLTableLayoutCnts *GetContents() const { return pContents; }
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 	inline void SetProtected();
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 	// ROWSPAN/COLSPAN der Zelle Setzen/Ermitteln
123*cdf0e10cSrcweir 	void SetRowSpan( sal_uInt16 nRSpan ) { nRowSpan = nRSpan; }
124*cdf0e10cSrcweir 	sal_uInt16 GetRowSpan() const { return nRowSpan; }
125*cdf0e10cSrcweir 	sal_uInt16 GetColSpan() const { return nColSpan; }
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 	sal_uInt16 GetWidthOption() const { return nWidthOption; }
128*cdf0e10cSrcweir 	sal_Bool IsPrcWidthOption() const { return bPrcWidthOption; }
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 	sal_Bool HasNoWrapOption() const { return bNoWrapOption; }
131*cdf0e10cSrcweir };
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir /*  */
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir class SwHTMLTableLayoutColumn
136*cdf0e10cSrcweir {
137*cdf0e10cSrcweir 	// Zwischenwerte von AutoLayoutPass1
138*cdf0e10cSrcweir 	sal_uLong nMinNoAlign, nMaxNoAlign, nAbsMinNoAlign;
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir 	// Ergebnisse von AutoLayoutPass1
141*cdf0e10cSrcweir 	sal_uLong nMin, nMax;
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 	// Ergibnisse von Pass 2
144*cdf0e10cSrcweir 	sal_uInt16 nAbsColWidth;				// in Twips
145*cdf0e10cSrcweir 	sal_uInt16 nRelColWidth;				// in Twips bzw. relativ zu USHRT_MAX
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 	sal_uInt16 nWidthOption;				// Optionen von <COL> oder <TD>/<TH>
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 	sal_Bool bRelWidthOption : 1;
150*cdf0e10cSrcweir 	sal_Bool bLeftBorder : 1;
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir public:
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 	SwHTMLTableLayoutColumn( sal_uInt16 nColWidthOpt, sal_Bool bRelColWidthOpt,
155*cdf0e10cSrcweir 							 sal_Bool bLBorder );
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir 	~SwHTMLTableLayoutColumn() {}
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 	inline void MergeCellWidthOption( sal_uInt16 nWidth, sal_Bool bPrc );
160*cdf0e10cSrcweir 	inline void SetWidthOption( sal_uInt16 nWidth, sal_Bool bRelWidth, sal_Bool bTest );
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 	sal_uInt16 GetWidthOption() const { return nWidthOption; }
163*cdf0e10cSrcweir 	sal_Bool IsRelWidthOption() const { return bRelWidthOption; }
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 	inline void MergeMinMaxNoAlign( sal_uLong nMin, sal_uLong nMax, sal_uLong nAbsMin );
166*cdf0e10cSrcweir 	sal_uLong GetMinNoAlign() const { return nMinNoAlign; }
167*cdf0e10cSrcweir 	sal_uLong GetMaxNoAlign() const { return nMaxNoAlign; }
168*cdf0e10cSrcweir 	sal_uLong GetAbsMinNoAlign() const { return nAbsMinNoAlign; }
169*cdf0e10cSrcweir 	inline void ClearPass1Info( sal_Bool bWidthOpt );
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir 	inline void SetMinMax( sal_uLong nMin, sal_uLong nMax );
172*cdf0e10cSrcweir 	void SetMax( sal_uLong nVal ) { nMax = nVal; }
173*cdf0e10cSrcweir 	void AddToMin( sal_uLong nVal ) { nMin += nVal; }
174*cdf0e10cSrcweir 	void AddToMax( sal_uLong nVal ) { nMax += nVal; }
175*cdf0e10cSrcweir 	sal_uLong GetMin() const { return nMin; }
176*cdf0e10cSrcweir 	sal_uLong GetMax() const { return nMax; }
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 	void SetAbsColWidth( sal_uInt16 nWidth ) { nAbsColWidth = nWidth; }
179*cdf0e10cSrcweir 	sal_uInt16 GetAbsColWidth() const { return nAbsColWidth; }
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir 	void SetRelColWidth( sal_uInt16 nWidth ) { nRelColWidth = nWidth; }
182*cdf0e10cSrcweir 	sal_uInt16 GetRelColWidth() const { return nRelColWidth; }
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 	sal_Bool HasLeftBorder() const { return bLeftBorder; }
185*cdf0e10cSrcweir };
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir /*  */
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir class SwHTMLTableLayout
190*cdf0e10cSrcweir {
191*cdf0e10cSrcweir 	Timer aResizeTimer;				// Timer fuer DelayedResize
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 	SwHTMLTableLayoutColumn **aColumns;
194*cdf0e10cSrcweir 	SwHTMLTableLayoutCell **aCells;
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir 	const SwTable *pSwTable;		// die SwTable (nur Top-Table)
197*cdf0e10cSrcweir 	SwTableBox *pLeftFillerBox;		// linke Filler-Zelle (nur Tab in Tab)
198*cdf0e10cSrcweir 	SwTableBox *pRightFillerBox;	// rechte Filler-Zelle (nur Tab-in Tab)
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir 	sal_uLong nMin;						// minimale Breite der Tabelle (Twips)
201*cdf0e10cSrcweir 	sal_uLong nMax;						// maximale Breite der Tabelle (Twips)
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir 	sal_uInt16 nRows;					// Anzahl Zeilen
204*cdf0e10cSrcweir 	sal_uInt16 nCols;       			// Anzahl Spalten
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir 	sal_uInt16 nLeftMargin;				// Abstand zum linken Rand (aus Absatz)
207*cdf0e10cSrcweir 	sal_uInt16 nRightMargin;		   	// Abstand zum rechten Rand (aus Absatz)
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir 	sal_uInt16 nInhAbsLeftSpace;		// von umgebender Zelle geerbter Abstand,
210*cdf0e10cSrcweir 	sal_uInt16 nInhAbsRightSpace;		// der Zellen zugeschlagen wurde
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir 	sal_uInt16 nRelLeftFill;			// relative Breiten der Zellen zur
213*cdf0e10cSrcweir 	sal_uInt16 nRelRightFill;			// Ausrichtung von Tabellen in Tabellen
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir 	sal_uInt16 nRelTabWidth;			// Die relative Breite der Tabelle
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir 	sal_uInt16 nWidthOption;			// die Breite der Tabelle (in Twip oder %)
218*cdf0e10cSrcweir 	sal_uInt16 nCellPadding;			// Abstand zum Inhalt (in Twip)
219*cdf0e10cSrcweir 	sal_uInt16 nCellSpacing;			// Absatnd zwischen Zellen (in Twip)
220*cdf0e10cSrcweir 	sal_uInt16 nBorder;					// Dicke der ausseren Umrandung bzw.
221*cdf0e10cSrcweir 									// Platz, den Netscape hierfuer einrechnet.
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir 	sal_uInt16 nLeftBorderWidth;
224*cdf0e10cSrcweir 	sal_uInt16 nRightBorderWidth;
225*cdf0e10cSrcweir 	sal_uInt16 nInhLeftBorderWidth;
226*cdf0e10cSrcweir 	sal_uInt16 nInhRightBorderWidth;
227*cdf0e10cSrcweir 	sal_uInt16 nBorderWidth;
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir 	sal_uInt16 nDelayedResizeAbsAvail;	// Param fuer's verzoegerte Resize
230*cdf0e10cSrcweir 	sal_uInt16 nLastResizeAbsAvail;
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir 	sal_uInt8 nPass1Done;				// Vorgabe-Werte fuer die einzelen
233*cdf0e10cSrcweir 	sal_uInt8 nWidthSet;					// Schleifen-Durchlauefe
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir 	SvxAdjust eTableAdjust;			// Die Ausrichtung der Tabelle
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir 	sal_Bool bColsOption : 1;			// Tabelle besitzt eine COLS-Option
238*cdf0e10cSrcweir 	sal_Bool bColTags : 1;				// Tabelle besitzt COL/COLGRP-Tags
239*cdf0e10cSrcweir 	sal_Bool bPrcWidthOption : 1;	  	// Breite ist eine %-Angabe
240*cdf0e10cSrcweir 	sal_Bool bUseRelWidth : 1;			// SwTable bekommt relative Breite
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir 	sal_Bool bMustResize : 1;			// Tabelle muss in der Breite ang. werden
243*cdf0e10cSrcweir 	sal_Bool bExportable : 1;			// Layout kann zum Export genutzt werden
244*cdf0e10cSrcweir 	sal_Bool bBordersChanged : 1;		// Umrandung wurde geaendert
245*cdf0e10cSrcweir 	sal_Bool bMayBeInFlyFrame : 1;		// Die Tabelle koennte im Rahmen sein
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir 	sal_Bool bDelayedResizeRecalc : 1;	// Param fuer's verzoegerte Resize
248*cdf0e10cSrcweir 	sal_Bool bMustNotResize : 1;		// Die Tabelle darf nicht reseized werden
249*cdf0e10cSrcweir 	sal_Bool bMustNotRecalc : 1;		// Tabelle darf nicht an Inhalt angepasst
250*cdf0e10cSrcweir 									// werden
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir //	sal_uInt16 GetLeftBorderWidth( sal_uInt16 nCol ) const;
253*cdf0e10cSrcweir //	sal_uInt16 GetRightBorderWidth( sal_uInt16 nCol, sal_uInt16 nColSpan ) const;
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir 	void AddBorderWidth( sal_uLong &rMin, sal_uLong &rMax, sal_uLong& rAbsMin,
256*cdf0e10cSrcweir 						 sal_uInt16 nCol, sal_uInt16 nColSpan,
257*cdf0e10cSrcweir 						 sal_Bool bSwBorders=sal_True ) const;
258*cdf0e10cSrcweir 	void SetBoxWidth( SwTableBox *pBox, sal_uInt16 nCol, sal_uInt16 nColSpan ) const;
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir 	const SwStartNode *GetAnyBoxStartNode() const;
261*cdf0e10cSrcweir 	SwFrmFmt *FindFlyFrmFmt() const;
262*cdf0e10cSrcweir 	const SwDoc *GetDoc() const { return GetAnyBoxStartNode()->GetDoc(); }
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir 	void ClearPass1Info() { nMin = nMax = 0; }
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir 	void _Resize( sal_uInt16 nAbsAvail, sal_Bool bRecalc=sal_False );
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir 	DECL_STATIC_LINK( SwHTMLTableLayout, DelayedResize_Impl, void* );
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir     static sal_uInt16 GetBrowseWidthByVisArea( const SwDoc& rDoc );
271*cdf0e10cSrcweir public:
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir 	SwHTMLTableLayout( const SwTable *pSwTbl,
274*cdf0e10cSrcweir 					   sal_uInt16 nRows, sal_uInt16 nCols, sal_Bool bColsOpt, sal_Bool ColTgs,
275*cdf0e10cSrcweir 					   sal_uInt16 nWidth, sal_Bool bPrcWidth, sal_uInt16 nBorderOpt,
276*cdf0e10cSrcweir 					   sal_uInt16 nCellPad, sal_uInt16 nCellSp, SvxAdjust eAdjust,
277*cdf0e10cSrcweir 					   sal_uInt16 nLMargin, sal_uInt16 nRMargin, sal_uInt16 nBWidth,
278*cdf0e10cSrcweir 					   sal_uInt16 nLeftBWidth, sal_uInt16 nRightBWidth,
279*cdf0e10cSrcweir 					   sal_uInt16 nInhLeftBWidth, sal_uInt16 nInhRightBWidth );
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir 	~SwHTMLTableLayout();
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir 	sal_uInt16 GetLeftCellSpace( sal_uInt16 nCol, sal_uInt16 nColSpan,
284*cdf0e10cSrcweir 							 sal_Bool bSwBorders=sal_True ) const;
285*cdf0e10cSrcweir 	sal_uInt16 GetRightCellSpace( sal_uInt16 nCol, sal_uInt16 nColSpan,
286*cdf0e10cSrcweir 							  sal_Bool bSwBorders=sal_True ) const;
287*cdf0e10cSrcweir 	inline sal_uInt16 GetInhCellSpace( sal_uInt16 nCol, sal_uInt16 nColSpan ) const;
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir 	inline void SetInhBorderWidths( sal_uInt16 nLeft, sal_uInt16 nRight );
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir 	void GetAvail( sal_uInt16 nCol, sal_uInt16 nColSpan, sal_uInt16& rAbsAvail,
293*cdf0e10cSrcweir 				   sal_uInt16& rRelAvail ) const;
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir 	void AutoLayoutPass1();
296*cdf0e10cSrcweir 	void AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAvail,
297*cdf0e10cSrcweir 						  sal_uInt16 nAbsLeftSpace, sal_uInt16 nAbsRightSpace,
298*cdf0e10cSrcweir 						  sal_uInt16 nParentInhSpace );
299*cdf0e10cSrcweir 	void SetWidths( sal_Bool bCallPass2=sal_False, sal_uInt16 nAbsAvail=0,
300*cdf0e10cSrcweir 					sal_uInt16 nRelAvail=0, sal_uInt16 nAbsLeftSpace=0,
301*cdf0e10cSrcweir 					sal_uInt16 nAbsRightSpace=0,
302*cdf0e10cSrcweir 					sal_uInt16 nParentInhSpace=0 );
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir 	inline SwHTMLTableLayoutColumn *GetColumn( sal_uInt16 nCol ) const;
305*cdf0e10cSrcweir 	inline void SetColumn( SwHTMLTableLayoutColumn *pCol, sal_uInt16 nCol );
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir 	inline SwHTMLTableLayoutCell *GetCell( sal_uInt16 nRow, sal_uInt16 nCol ) const;
308*cdf0e10cSrcweir 	inline void SetCell( SwHTMLTableLayoutCell *pCell, sal_uInt16 nRow, sal_uInt16 nCol );
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir 	void SetLeftFillerBox( SwTableBox *pBox ) { pLeftFillerBox = pBox; }
311*cdf0e10cSrcweir 	void SetRightFillerBox( SwTableBox *pBox ) { pRightFillerBox = pBox; }
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir 	sal_uLong GetMin() const { return nMin; }
314*cdf0e10cSrcweir 	sal_uLong GetMax() const { return nMax; }
315*cdf0e10cSrcweir 	sal_uInt16 GetRelLeftFill() const { return nRelLeftFill; }
316*cdf0e10cSrcweir 	sal_uInt16 GetRelRightFill() const { return nRelRightFill; }
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir 	inline long GetBrowseWidthMin() const;
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir 	sal_Bool HasColsOption() const { return bColsOption; }
321*cdf0e10cSrcweir 	sal_Bool HasColTags() const { return bColTags; }
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir 	sal_Bool IsTopTable() const  { return pSwTable != 0; }
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir 	void SetMustResize( sal_Bool bSet ) { bMustResize = bSet; }
326*cdf0e10cSrcweir 	void SetMustNotResize( sal_Bool bSet ) { bMustNotResize = bSet; }
327*cdf0e10cSrcweir 	void SetMustNotRecalc( sal_Bool bSet ) { bMustNotRecalc = bSet; }
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir 	// Neueberechnung der Tabellenbreiten fuer die uebergebene verfuegbare
330*cdf0e10cSrcweir 	// Breite.
331*cdf0e10cSrcweir 	// - Wenn bRecalc gesetzt ist, werden auch der Inhalt der Boxen
332*cdf0e10cSrcweir 	//   zur Berechnung herangezogen.
333*cdf0e10cSrcweir 	//   neu berechnet.
334*cdf0e10cSrcweir 	// - Wenn bForce gesetzt ist, wird die Tabelle auch neu berechnet, wenn
335*cdf0e10cSrcweir 	//   dies mit SetMustNotResize unterdrueckt werden soll.
336*cdf0e10cSrcweir 	// - Wenn nDelay>0 wird die Berechnung entsprechend verzoegert.
337*cdf0e10cSrcweir 	//   Innerhalb der Verzeoegerung auftretende Resize-Aufrufe werden
338*cdf0e10cSrcweir 	//   ignoriert, die Verzeogerung wird aber ggf. uebernommen.
339*cdf0e10cSrcweir 	// - Wenn nDelay==HTMLTABLE_RESIZE_NOW ist, wird sofort Resized und
340*cdf0e10cSrcweir 	//   eventuell noch asstehende Resize-Aufrufe werden nicht mehr
341*cdf0e10cSrcweir 	//	 ausgefuehrt.
342*cdf0e10cSrcweir 	// - Der Rueckgabewert gibt an, ob sich die Tabelle geaendert hat.
343*cdf0e10cSrcweir 	sal_Bool Resize( sal_uInt16 nAbsAvail, sal_Bool bRecalc=sal_False, sal_Bool bForce=sal_False,
344*cdf0e10cSrcweir 				 sal_uLong nDelay=0 );
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir 	void BordersChanged( sal_uInt16 nAbsAvail, sal_Bool bRecalc=sal_False );
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir 	// Ermitteln der verfuegbaren Breite. Das geht nur, wenn ein Layout
349*cdf0e10cSrcweir 	// oder eine ViewShell vorhanden ist. Sonst wird 0 zurueckgegeben.
350*cdf0e10cSrcweir 	// (Wird vom HTML-Filter benoetigt, da der nicht an das Layout kommt.)
351*cdf0e10cSrcweir 	static sal_uInt16 GetBrowseWidth( const SwDoc& rDoc );
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir 	// Ermitteln der verfuegbaren Breite uber den Tabellen-Frame
354*cdf0e10cSrcweir 	sal_uInt16 GetBrowseWidthByTabFrm( const SwTabFrm& rTabFrm ) const;
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir 	// Ermitteln der verfuegbaren Breite uber den Tabellen-Frame oder
357*cdf0e10cSrcweir 	// das statische GetBrowseWidth, wenn kein Layout existiert.
358*cdf0e10cSrcweir 	sal_uInt16 GetBrowseWidthByTable( const SwDoc& rDoc ) const;
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir 	// Fuer Export
361*cdf0e10cSrcweir 	sal_uInt16 GetWidthOption() const { return nWidthOption; }
362*cdf0e10cSrcweir 	sal_Bool   HasPrcWidthOption() const { return bPrcWidthOption; }
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir 	sal_uInt16 GetCellPadding() const { return nCellPadding; }
365*cdf0e10cSrcweir 	sal_uInt16 GetCellSpacing() const { return nCellSpacing; }
366*cdf0e10cSrcweir 	sal_uInt16 GetBorder() const { return nBorder; }
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir 	sal_uInt16 GetRowCount() const { return nRows; }
369*cdf0e10cSrcweir 	sal_uInt16 GetColCount() const { return nCols; }
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir 	void SetExportable( sal_Bool bSet ) { bExportable = bSet; }
372*cdf0e10cSrcweir 	sal_Bool IsExportable() const { return bExportable; }
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir 	sal_Bool HaveBordersChanged() const { return bBordersChanged; }
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir 	void SetMayBeInFlyFrame( sal_Bool bSet ) { bMayBeInFlyFrame = bSet; }
377*cdf0e10cSrcweir 	sal_Bool MayBeInFlyFrame() const { return bMayBeInFlyFrame; }
378*cdf0e10cSrcweir };
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir /*  */
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir inline void SwHTMLTableLayoutCell::SetProtected()
383*cdf0e10cSrcweir {
384*cdf0e10cSrcweir 	nRowSpan = 1;
385*cdf0e10cSrcweir 	nColSpan = 1;
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir 	pContents = 0;
388*cdf0e10cSrcweir }
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir /*  */
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir inline void SwHTMLTableLayoutColumn::MergeMinMaxNoAlign( sal_uLong nCMin,
393*cdf0e10cSrcweir     sal_uLong nCMax,    sal_uLong nAbsMin )
394*cdf0e10cSrcweir {
395*cdf0e10cSrcweir     if( nCMin > nMinNoAlign )
396*cdf0e10cSrcweir         nMinNoAlign = nCMin;
397*cdf0e10cSrcweir     if( nCMax > nMaxNoAlign )
398*cdf0e10cSrcweir         nMaxNoAlign = nCMax;
399*cdf0e10cSrcweir 	if( nAbsMin > nAbsMinNoAlign )
400*cdf0e10cSrcweir 		nAbsMinNoAlign = nAbsMin;
401*cdf0e10cSrcweir }
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir inline void SwHTMLTableLayoutColumn::ClearPass1Info( sal_Bool bWidthOpt )
404*cdf0e10cSrcweir {
405*cdf0e10cSrcweir 	nMinNoAlign = nMaxNoAlign = nAbsMinNoAlign = MINLAY;
406*cdf0e10cSrcweir 	nMin = nMax = 0;
407*cdf0e10cSrcweir 	if( bWidthOpt )
408*cdf0e10cSrcweir 	{
409*cdf0e10cSrcweir 		nWidthOption = 0;
410*cdf0e10cSrcweir 		bRelWidthOption = sal_False;
411*cdf0e10cSrcweir 	}
412*cdf0e10cSrcweir }
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir inline void SwHTMLTableLayoutColumn::MergeCellWidthOption(
415*cdf0e10cSrcweir 	sal_uInt16 nWidth, sal_Bool bRel )
416*cdf0e10cSrcweir {
417*cdf0e10cSrcweir 	if( !nWidthOption ||
418*cdf0e10cSrcweir 		(bRel==bRelWidthOption && nWidthOption < nWidth) )
419*cdf0e10cSrcweir 	{
420*cdf0e10cSrcweir 		nWidthOption = nWidth;
421*cdf0e10cSrcweir 		bRelWidthOption = bRel;
422*cdf0e10cSrcweir 	}
423*cdf0e10cSrcweir }
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir inline void SwHTMLTableLayoutColumn::SetMinMax( sal_uLong nMn, sal_uLong nMx )
426*cdf0e10cSrcweir {
427*cdf0e10cSrcweir 	nMin = nMn;
428*cdf0e10cSrcweir 	nMax = nMx;
429*cdf0e10cSrcweir }
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir /*  */
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir inline sal_uInt16 SwHTMLTableLayout::GetInhCellSpace( sal_uInt16 nCol,
434*cdf0e10cSrcweir 												  sal_uInt16 nColSpan ) const
435*cdf0e10cSrcweir {
436*cdf0e10cSrcweir 	sal_uInt16 nSpace = 0;
437*cdf0e10cSrcweir 	if( nCol==0 )
438*cdf0e10cSrcweir         nSpace = nSpace + sal::static_int_cast< sal_uInt16 >(nInhAbsLeftSpace);
439*cdf0e10cSrcweir 	if( nCol+nColSpan==nCols )
440*cdf0e10cSrcweir 		nSpace = nSpace + sal::static_int_cast< sal_uInt16 >(nInhAbsRightSpace);
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir 	return nSpace;
443*cdf0e10cSrcweir }
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir inline SwHTMLTableLayoutColumn *SwHTMLTableLayout::GetColumn( sal_uInt16 nCol ) const
446*cdf0e10cSrcweir {
447*cdf0e10cSrcweir 	return aColumns[nCol];
448*cdf0e10cSrcweir }
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir inline void SwHTMLTableLayoutColumn::SetWidthOption(
451*cdf0e10cSrcweir 	sal_uInt16 nWidth, sal_Bool bRelWidth, sal_Bool bTest )
452*cdf0e10cSrcweir {
453*cdf0e10cSrcweir 	if( bTest && bRelWidthOption==bRelWidth )
454*cdf0e10cSrcweir 	{
455*cdf0e10cSrcweir 		if( nWidth > nWidthOption )
456*cdf0e10cSrcweir 			nWidthOption = nWidth;
457*cdf0e10cSrcweir 	}
458*cdf0e10cSrcweir 	else
459*cdf0e10cSrcweir 		nWidthOption = nWidth;
460*cdf0e10cSrcweir 	bRelWidthOption = bRelWidth;
461*cdf0e10cSrcweir }
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir inline void SwHTMLTableLayout::SetColumn( SwHTMLTableLayoutColumn *pCol, sal_uInt16 nCol )
464*cdf0e10cSrcweir {
465*cdf0e10cSrcweir 	aColumns[nCol] = pCol;
466*cdf0e10cSrcweir }
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir inline SwHTMLTableLayoutCell *SwHTMLTableLayout::GetCell( sal_uInt16 nRow, sal_uInt16 nCol ) const
469*cdf0e10cSrcweir {
470*cdf0e10cSrcweir 	return aCells[nRow*nCols+nCol];
471*cdf0e10cSrcweir }
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir inline void SwHTMLTableLayout::SetCell( SwHTMLTableLayoutCell *pCell,
474*cdf0e10cSrcweir 							   sal_uInt16 nRow, sal_uInt16 nCol )
475*cdf0e10cSrcweir {
476*cdf0e10cSrcweir 	aCells[nRow*nCols+nCol] = pCell;
477*cdf0e10cSrcweir }
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir inline long SwHTMLTableLayout::GetBrowseWidthMin() const
480*cdf0e10cSrcweir {
481*cdf0e10cSrcweir 	return (long)( (!nWidthOption || bPrcWidthOption) ? nMin : nRelTabWidth );
482*cdf0e10cSrcweir }
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir void SwHTMLTableLayout::SetInhBorderWidths( sal_uInt16 nLeft, sal_uInt16 nRight )
485*cdf0e10cSrcweir {
486*cdf0e10cSrcweir 	nInhLeftBorderWidth = nLeft;
487*cdf0e10cSrcweir 	nInhRightBorderWidth = nRight;
488*cdf0e10cSrcweir }
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir #endif
492