xref: /aoo41x/main/sc/source/core/data/fillinfo.cxx (revision acf6b796)
1b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5b3f79822SAndrew Rist  * distributed with this work for additional information
6b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10b3f79822SAndrew Rist  *
11b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12b3f79822SAndrew Rist  *
13b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17b3f79822SAndrew Rist  * specific language governing permissions and limitations
18b3f79822SAndrew Rist  * under the License.
19b3f79822SAndrew Rist  *
20b3f79822SAndrew Rist  *************************************************************/
21b3f79822SAndrew Rist 
22b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include "scitems.hxx"
32cdf0e10cSrcweir #include <editeng/boxitem.hxx>
33cdf0e10cSrcweir #include <editeng/bolnitem.hxx>
34cdf0e10cSrcweir #include <editeng/editdata.hxx>		// can be removed if table has a bLayoutRTL flag
35cdf0e10cSrcweir #include <editeng/shaditem.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include "fillinfo.hxx"
38cdf0e10cSrcweir #include "document.hxx"
39cdf0e10cSrcweir #include "cell.hxx"
40cdf0e10cSrcweir #include "table.hxx"
41cdf0e10cSrcweir #include "attrib.hxx"
42cdf0e10cSrcweir #include "attarray.hxx"
43cdf0e10cSrcweir #include "markarr.hxx"
44cdf0e10cSrcweir #include "markdata.hxx"
45cdf0e10cSrcweir #include "patattr.hxx"
46cdf0e10cSrcweir #include "poolhelp.hxx"
47cdf0e10cSrcweir #include "docpool.hxx"
48cdf0e10cSrcweir #include "conditio.hxx"
49cdf0e10cSrcweir #include "stlpool.hxx"
50cdf0e10cSrcweir 
51cdf0e10cSrcweir // -----------------------------------------------------------------------
52cdf0e10cSrcweir 
53cdf0e10cSrcweir const sal_uInt16 ROWINFO_MAX = 1024;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 
56cdf0e10cSrcweir enum FillInfoLinePos
57cdf0e10cSrcweir 	{
58cdf0e10cSrcweir 		FILP_TOP,
59cdf0e10cSrcweir 		FILP_BOTTOM,
60cdf0e10cSrcweir 		FILP_LEFT,
61cdf0e10cSrcweir 		FILP_RIGHT
62cdf0e10cSrcweir 	};
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 
GetNullOrLine(const SvxBoxItem * pBox,FillInfoLinePos eWhich)65cdf0e10cSrcweir inline const SvxBorderLine* GetNullOrLine( const SvxBoxItem* pBox, FillInfoLinePos eWhich )
66cdf0e10cSrcweir {
67cdf0e10cSrcweir 	if (pBox)
68cdf0e10cSrcweir 	{
69cdf0e10cSrcweir 		if (eWhich==FILP_TOP)
70cdf0e10cSrcweir 			return pBox->GetTop();
71cdf0e10cSrcweir 		else if (eWhich==FILP_BOTTOM)
72cdf0e10cSrcweir 			return pBox->GetBottom();
73cdf0e10cSrcweir 		else if (eWhich==FILP_LEFT)
74cdf0e10cSrcweir 			return pBox->GetLeft();
75cdf0e10cSrcweir 		else
76cdf0e10cSrcweir 			return pBox->GetRight();
77cdf0e10cSrcweir 	}
78cdf0e10cSrcweir 	else
79cdf0e10cSrcweir 		return NULL;
80cdf0e10cSrcweir }
81cdf0e10cSrcweir 
82cdf0e10cSrcweir //	aehnlich wie in output.cxx
83cdf0e10cSrcweir 
lcl_GetMergeRange(SCsCOL nX,SCsROW nY,SCSIZE nArrY,ScDocument * pDoc,RowInfo * pRowInfo,SCCOL nX1,SCROW nY1,SCCOL,SCROW,SCTAB nTab,SCsCOL & rStartX,SCsROW & rStartY,SCsCOL & rEndX,SCsROW & rEndY)84cdf0e10cSrcweir void lcl_GetMergeRange( SCsCOL nX, SCsROW nY, SCSIZE nArrY,
85cdf0e10cSrcweir 							ScDocument* pDoc, RowInfo* pRowInfo,
86cdf0e10cSrcweir 							SCCOL nX1, SCROW nY1, SCCOL /* nX2 */, SCROW /* nY2 */, SCTAB nTab,
87cdf0e10cSrcweir 							SCsCOL& rStartX, SCsROW& rStartY, SCsCOL& rEndX, SCsROW& rEndY )
88cdf0e10cSrcweir {
89cdf0e10cSrcweir 	CellInfo* pInfo = &pRowInfo[nArrY].pCellInfo[nX+1];
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 	rStartX = nX;
92cdf0e10cSrcweir 	rStartY = nY;
93cdf0e10cSrcweir 	sal_Bool bHOver = pInfo->bHOverlapped;
94cdf0e10cSrcweir 	sal_Bool bVOver = pInfo->bVOverlapped;
95cdf0e10cSrcweir     SCCOL nLastCol;
96cdf0e10cSrcweir     SCROW nLastRow;
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	while (bHOver)				// nY konstant
99cdf0e10cSrcweir 	{
100cdf0e10cSrcweir 		--rStartX;
101cdf0e10cSrcweir         if (rStartX >= (SCsCOL) nX1 && !pDoc->ColHidden(rStartX, nTab, nLastCol))
102cdf0e10cSrcweir 		{
103cdf0e10cSrcweir 			bHOver = pRowInfo[nArrY].pCellInfo[rStartX+1].bHOverlapped;
104cdf0e10cSrcweir 			bVOver = pRowInfo[nArrY].pCellInfo[rStartX+1].bVOverlapped;
105cdf0e10cSrcweir 		}
106cdf0e10cSrcweir 		else
107cdf0e10cSrcweir 		{
108cdf0e10cSrcweir 			sal_uInt16 nOverlap = ((ScMergeFlagAttr*)pDoc->GetAttr(
109cdf0e10cSrcweir 								rStartX, rStartY, nTab, ATTR_MERGE_FLAG ))->GetValue();
110cdf0e10cSrcweir 			bHOver = ((nOverlap & SC_MF_HOR) != 0);
111cdf0e10cSrcweir 			bVOver = ((nOverlap & SC_MF_VER) != 0);
112cdf0e10cSrcweir 		}
113cdf0e10cSrcweir 	}
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 	while (bVOver)
116cdf0e10cSrcweir 	{
117cdf0e10cSrcweir 		--rStartY;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 		if (nArrY>0)
120cdf0e10cSrcweir 			--nArrY;						// lokale Kopie !
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 		if (rStartX >= (SCsCOL) nX1 && rStartY >= (SCsROW) nY1 &&
123cdf0e10cSrcweir             !pDoc->ColHidden(rStartX, nTab, nLastCol) &&
124cdf0e10cSrcweir             !pDoc->RowHidden(rStartY, nTab, nLastRow) &&
125cdf0e10cSrcweir 			(SCsROW) pRowInfo[nArrY].nRowNo == rStartY)
126cdf0e10cSrcweir 		{
127cdf0e10cSrcweir 			bHOver = pRowInfo[nArrY].pCellInfo[rStartX+1].bHOverlapped;
128cdf0e10cSrcweir 			bVOver = pRowInfo[nArrY].pCellInfo[rStartX+1].bVOverlapped;
129cdf0e10cSrcweir 		}
130cdf0e10cSrcweir 		else
131cdf0e10cSrcweir 		{
132cdf0e10cSrcweir 			sal_uInt16 nOverlap = ((ScMergeFlagAttr*)pDoc->GetAttr(
133cdf0e10cSrcweir 								rStartX, rStartY, nTab, ATTR_MERGE_FLAG ))->GetValue();
134cdf0e10cSrcweir 			bHOver = ((nOverlap & SC_MF_HOR) != 0);
135cdf0e10cSrcweir 			bVOver = ((nOverlap & SC_MF_VER) != 0);
136cdf0e10cSrcweir 		}
137cdf0e10cSrcweir 	}
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	const ScMergeAttr* pMerge;
140cdf0e10cSrcweir 	if (rStartX >= (SCsCOL) nX1 && rStartY >= (SCsROW) nY1 &&
141cdf0e10cSrcweir         !pDoc->ColHidden(rStartX, nTab, nLastCol) &&
142cdf0e10cSrcweir         !pDoc->RowHidden(rStartY, nTab, nLastRow) &&
143cdf0e10cSrcweir 		(SCsROW) pRowInfo[nArrY].nRowNo == rStartY)
144cdf0e10cSrcweir 	{
145cdf0e10cSrcweir 		pMerge = (const ScMergeAttr*) &pRowInfo[nArrY].pCellInfo[rStartX+1].pPatternAttr->
146cdf0e10cSrcweir 										GetItem(ATTR_MERGE);
147cdf0e10cSrcweir 	}
148cdf0e10cSrcweir 	else
149cdf0e10cSrcweir 		pMerge = (const ScMergeAttr*) pDoc->GetAttr(rStartX,rStartY,nTab,ATTR_MERGE);
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 	rEndX = rStartX + pMerge->GetColMerge() - 1;
152cdf0e10cSrcweir 	rEndY = rStartY + pMerge->GetRowMerge() - 1;
153cdf0e10cSrcweir }
154cdf0e10cSrcweir 
155cdf0e10cSrcweir #define CELLINFO(x,y) pRowInfo[nArrY+y].pCellInfo[nArrX+x]
156cdf0e10cSrcweir 
FillInfo(ScTableInfo & rTabInfo,SCCOL nX1,SCROW nY1,SCCOL nX2,SCROW nY2,SCTAB nTab,double nScaleX,double nScaleY,sal_Bool bPageMode,sal_Bool bFormulaMode,const ScMarkData * pMarkData)157cdf0e10cSrcweir void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
158cdf0e10cSrcweir 							SCTAB nTab, double nScaleX, double nScaleY,
159cdf0e10cSrcweir 							sal_Bool bPageMode, sal_Bool bFormulaMode, const ScMarkData* pMarkData )
160cdf0e10cSrcweir {
161cdf0e10cSrcweir 	DBG_ASSERT( pTab[nTab], "Tabelle existiert nicht" );
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	sal_Bool bLayoutRTL = IsLayoutRTL( nTab );
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 	ScDocumentPool* pPool = xPoolHelper->GetDocPool();
166cdf0e10cSrcweir 	ScStyleSheetPool* pStlPool = xPoolHelper->GetStylePool();
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     RowInfo* pRowInfo = rTabInfo.mpRowInfo;
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 	const SvxBrushItem* pDefBackground =
171cdf0e10cSrcweir 			(const SvxBrushItem*) &pPool->GetDefaultItem( ATTR_BACKGROUND );
172cdf0e10cSrcweir 	const ScMergeAttr* pDefMerge =
173cdf0e10cSrcweir 			(const ScMergeAttr*) &pPool->GetDefaultItem( ATTR_MERGE );
174cdf0e10cSrcweir 	const SvxShadowItem* pDefShadow =
175cdf0e10cSrcweir 			(const SvxShadowItem*) &pPool->GetDefaultItem( ATTR_SHADOW );
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 	SCROW nThisRow;
178cdf0e10cSrcweir 	SCCOL nX;
179cdf0e10cSrcweir 	SCROW nY;
180cdf0e10cSrcweir 	SCsROW nSignedY;
181cdf0e10cSrcweir 	SCCOL nArrX;
182cdf0e10cSrcweir 	SCSIZE nArrY;
183cdf0e10cSrcweir 	SCSIZE nArrCount;
184cdf0e10cSrcweir 	sal_Bool bAnyMerged = sal_False;
185cdf0e10cSrcweir 	sal_Bool bAnyShadow = sal_False;
186cdf0e10cSrcweir 	sal_Bool bAnyCondition = sal_False;
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 	sal_Bool bTabProtect = IsTabProtected(nTab);
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 												// fuer Blockmarken von zusammengefassten Zellen mit
191cdf0e10cSrcweir 												// versteckter erster Zeile / Spalte
192cdf0e10cSrcweir 	sal_Bool bPaintMarks = sal_False;
193cdf0e10cSrcweir 	sal_Bool bSkipMarks = sal_False;
194cdf0e10cSrcweir     SCCOL nBlockStartX = 0, nBlockEndX = 0;
195cdf0e10cSrcweir     SCROW nBlockEndY = 0, nBlockStartY = 0;
196cdf0e10cSrcweir 	if (pMarkData && pMarkData->IsMarked())
197cdf0e10cSrcweir 	{
198cdf0e10cSrcweir 		ScRange aTmpRange;
199cdf0e10cSrcweir 		pMarkData->GetMarkArea(aTmpRange);
200cdf0e10cSrcweir 		if ( nTab >= aTmpRange.aStart.Tab() && nTab <= aTmpRange.aEnd.Tab() )
201cdf0e10cSrcweir 		{
202cdf0e10cSrcweir 			nBlockStartX = aTmpRange.aStart.Col();
203cdf0e10cSrcweir 			nBlockStartY = aTmpRange.aStart.Row();
204cdf0e10cSrcweir 			nBlockEndX = aTmpRange.aEnd.Col();
205cdf0e10cSrcweir 			nBlockEndY = aTmpRange.aEnd.Row();
206cdf0e10cSrcweir 			ExtendHidden( nBlockStartX, nBlockStartY, nBlockEndX, nBlockEndY, nTab );	//? noetig ?
207cdf0e10cSrcweir 			if (pMarkData->IsMarkNegative())
208cdf0e10cSrcweir 				bSkipMarks = sal_True;
209cdf0e10cSrcweir 			else
210cdf0e10cSrcweir 				bPaintMarks = sal_True;
211cdf0e10cSrcweir 		}
212cdf0e10cSrcweir 	}
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 	//	zuerst nur die Eintraege fuer die ganze Spalte
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 	nArrY=0;
217cdf0e10cSrcweir 	SCROW nYExtra = nY2+1;
218cdf0e10cSrcweir     sal_uInt16 nDocHeight = ScGlobal::nStdRowHeight;
219cdf0e10cSrcweir     SCROW nDocHeightEndRow = -1;
220cdf0e10cSrcweir 	for (nSignedY=((SCsROW)nY1)-1; nSignedY<=(SCsROW)nYExtra; nSignedY++)
221cdf0e10cSrcweir 	{
222cdf0e10cSrcweir 		if (nSignedY >= 0)
223cdf0e10cSrcweir 			nY = (SCROW) nSignedY;
224cdf0e10cSrcweir 		else
225cdf0e10cSrcweir 			nY = MAXROW+1;			// ungueltig
226cdf0e10cSrcweir 
227cdf0e10cSrcweir         if (nY > nDocHeightEndRow)
228cdf0e10cSrcweir         {
229cdf0e10cSrcweir             if (ValidRow(nY))
230cdf0e10cSrcweir                 nDocHeight = GetRowHeight( nY, nTab, NULL, &nDocHeightEndRow );
231cdf0e10cSrcweir             else
232cdf0e10cSrcweir                 nDocHeight = ScGlobal::nStdRowHeight;
233cdf0e10cSrcweir         }
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 		if ( nArrY==0 || nDocHeight || nY > MAXROW )
236cdf0e10cSrcweir 		{
237cdf0e10cSrcweir 			RowInfo* pThisRowInfo = &pRowInfo[nArrY];
238cdf0e10cSrcweir 			pThisRowInfo->pCellInfo = NULL;					// wird unten belegt
239cdf0e10cSrcweir 
240cdf0e10cSrcweir 			sal_uInt16 nHeight = (sal_uInt16) ( nDocHeight * nScaleY );
241cdf0e10cSrcweir 			if (!nHeight)
242cdf0e10cSrcweir 				nHeight = 1;
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 			pThisRowInfo->nRowNo		= nY;				//! Fall < 0 ?
245cdf0e10cSrcweir 			pThisRowInfo->nHeight 		= nHeight;
246cdf0e10cSrcweir 			pThisRowInfo->bEmptyBack	= sal_True;
247cdf0e10cSrcweir 			pThisRowInfo->bEmptyText	= sal_True;
248cdf0e10cSrcweir 			pThisRowInfo->bChanged		= sal_True;
249cdf0e10cSrcweir 			pThisRowInfo->bAutoFilter	= sal_False;
250cdf0e10cSrcweir 			pThisRowInfo->bPushButton	= sal_False;
251cdf0e10cSrcweir 			pThisRowInfo->nRotMaxCol	= SC_ROTMAX_NONE;
252cdf0e10cSrcweir 
253cdf0e10cSrcweir 			++nArrY;
254cdf0e10cSrcweir 			if (nArrY >= ROWINFO_MAX)
255cdf0e10cSrcweir 			{
256cdf0e10cSrcweir 				DBG_ERROR("Zu grosser Bereich bei FillInfo" );
257cdf0e10cSrcweir 				nYExtra = nSignedY;									// Ende
258cdf0e10cSrcweir 				nY2 = nYExtra - 1;									// Bereich anpassen
259cdf0e10cSrcweir 			}
260cdf0e10cSrcweir 		}
261cdf0e10cSrcweir 		else
262cdf0e10cSrcweir 			if (nSignedY==(SCsROW) nYExtra)							// zusaetzliche Zeile verdeckt ?
263cdf0e10cSrcweir 				++nYExtra;
264cdf0e10cSrcweir 	}
265cdf0e10cSrcweir 	nArrCount = nArrY;										// incl. Dummys
266cdf0e10cSrcweir 
267cdf0e10cSrcweir 	//	rotierter Text...
268cdf0e10cSrcweir 
269cdf0e10cSrcweir 	//	Attribut im Dokument ueberhaupt verwendet?
270cdf0e10cSrcweir 	sal_Bool bAnyItem = sal_False;
271cdf0e10cSrcweir 	sal_uInt32 nRotCount = pPool->GetItemCount2( ATTR_ROTATE_VALUE );
272cdf0e10cSrcweir 	for (sal_uInt32 nItem=0; nItem<nRotCount; nItem++)
273cdf0e10cSrcweir 		if (pPool->GetItem2( ATTR_ROTATE_VALUE, nItem ))
274cdf0e10cSrcweir 		{
275cdf0e10cSrcweir 			bAnyItem = sal_True;
276cdf0e10cSrcweir 			break;
277cdf0e10cSrcweir 		}
278cdf0e10cSrcweir 
279cdf0e10cSrcweir 	SCCOL nRotMax = nX2;
280cdf0e10cSrcweir 	if ( bAnyItem && HasAttrib( 0,nY1,nTab, MAXCOL,nY2+1,nTab,
281cdf0e10cSrcweir 								HASATTR_ROTATE | HASATTR_CONDITIONAL ) )
282cdf0e10cSrcweir 	{
283cdf0e10cSrcweir 		//!	Conditionals auch bei HASATTR_ROTATE abfragen ????
284cdf0e10cSrcweir 
285cdf0e10cSrcweir 		DBG_ASSERT( nArrCount>2, "nArrCount zu klein" );
286cdf0e10cSrcweir //		FindMaxRotCol( nTab, &pRowInfo[1], nArrCount-2, nX1, nX2 );
287cdf0e10cSrcweir 		FindMaxRotCol( nTab, &pRowInfo[1], nArrCount-1, nX1, nX2 );
288cdf0e10cSrcweir 		//	FindMaxRotCol setzt nRotMaxCol
289cdf0e10cSrcweir 
290cdf0e10cSrcweir 		for (nArrY=0; nArrY<nArrCount; nArrY++)
291cdf0e10cSrcweir 			if (pRowInfo[nArrY].nRotMaxCol != SC_ROTMAX_NONE && pRowInfo[nArrY].nRotMaxCol > nRotMax)
292cdf0e10cSrcweir 				nRotMax = pRowInfo[nArrY].nRotMaxCol;
293cdf0e10cSrcweir 	}
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 	//	Zell-Infos erst nach dem Test auf gedrehte allozieren
296cdf0e10cSrcweir 	//	bis nRotMax wegen nRotateDir Flag
297cdf0e10cSrcweir 
298cdf0e10cSrcweir 	for (nArrY=0; nArrY<nArrCount; nArrY++)
299cdf0e10cSrcweir 	{
300cdf0e10cSrcweir 		RowInfo* pThisRowInfo = &pRowInfo[nArrY];
301cdf0e10cSrcweir 		nY = pThisRowInfo->nRowNo;
302cdf0e10cSrcweir 		pThisRowInfo->pCellInfo = new CellInfo[ nRotMax+1+2 ];	// vom Aufrufer zu loeschen !
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 		for (nArrX=0; nArrX<=nRotMax+2; nArrX++)				// Zell-Infos vorbelegen
305cdf0e10cSrcweir 		{
306cdf0e10cSrcweir 			if (nArrX>0)
307cdf0e10cSrcweir 				nX = nArrX-1;
308cdf0e10cSrcweir 			else
309cdf0e10cSrcweir 				nX = MAXCOL+1;		// ungueltig
310cdf0e10cSrcweir 
311cdf0e10cSrcweir 			CellInfo* pInfo = &pThisRowInfo->pCellInfo[nArrX];
312cdf0e10cSrcweir 			pInfo->bEmptyCellText = sal_True;
313cdf0e10cSrcweir 			pInfo->pCell = NULL;
314cdf0e10cSrcweir 			if (bPaintMarks)
315cdf0e10cSrcweir 				pInfo->bMarked = ( nX >= nBlockStartX && nX <= nBlockEndX
316cdf0e10cSrcweir 								&& nY >= nBlockStartY && nY <= nBlockEndY );
317cdf0e10cSrcweir 			else
318cdf0e10cSrcweir 				pInfo->bMarked = sal_False;
319cdf0e10cSrcweir 			pInfo->nWidth = 0;
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 			pInfo->nClipMark	= SC_CLIPMARK_NONE;
322cdf0e10cSrcweir 			pInfo->bMerged		= sal_False;
323cdf0e10cSrcweir 			pInfo->bHOverlapped = sal_False;
324cdf0e10cSrcweir 			pInfo->bVOverlapped = sal_False;
325cdf0e10cSrcweir 			pInfo->bAutoFilter	= sal_False;
326cdf0e10cSrcweir 			pInfo->bPushButton	= sal_False;
327cdf0e10cSrcweir             pInfo->bPopupButton = false;
328cdf0e10cSrcweir             pInfo->bFilterActive = false;
329cdf0e10cSrcweir 			pInfo->nRotateDir	= SC_ROTDIR_NONE;
330cdf0e10cSrcweir 
331cdf0e10cSrcweir 			pInfo->bPrinted		= sal_False;					//	view-intern
332cdf0e10cSrcweir 			pInfo->bHideGrid	= sal_False;					//	view-intern
333cdf0e10cSrcweir 			pInfo->bEditEngine	= sal_False;					//	view-intern
334cdf0e10cSrcweir 
335cdf0e10cSrcweir 			pInfo->pBackground  = NULL;						//! weglassen?
336cdf0e10cSrcweir 			pInfo->pPatternAttr = NULL;
337cdf0e10cSrcweir 			pInfo->pConditionSet= NULL;
338cdf0e10cSrcweir 
339cdf0e10cSrcweir             pInfo->pLinesAttr   = NULL;
340cdf0e10cSrcweir             pInfo->mpTLBRLine   = NULL;
341cdf0e10cSrcweir             pInfo->mpBLTRLine   = NULL;
342cdf0e10cSrcweir 
343cdf0e10cSrcweir 			pInfo->pShadowAttr	  = pDefShadow;
344cdf0e10cSrcweir 			pInfo->pHShadowOrigin = NULL;
345cdf0e10cSrcweir 			pInfo->pVShadowOrigin = NULL;
346cdf0e10cSrcweir 		}
347cdf0e10cSrcweir 	}
348cdf0e10cSrcweir 
349cdf0e10cSrcweir 	for (nArrX=nX2+3; nArrX<=nRotMax+2; nArrX++)			// restliche Breiten eintragen
350cdf0e10cSrcweir 	{
351cdf0e10cSrcweir 		nX = nArrX-1;
352cdf0e10cSrcweir 		if ( ValidCol(nX) )
353cdf0e10cSrcweir 		{
354cdf0e10cSrcweir             if (!ColHidden(nX, nTab))
355cdf0e10cSrcweir 			{
356cdf0e10cSrcweir 				sal_uInt16 nThisWidth = (sal_uInt16) (GetColWidth( nX, nTab ) * nScaleX);
357cdf0e10cSrcweir 				if (!nThisWidth)
358cdf0e10cSrcweir 					nThisWidth = 1;
359cdf0e10cSrcweir 
360cdf0e10cSrcweir 				pRowInfo[0].pCellInfo[nArrX].nWidth = nThisWidth;
361cdf0e10cSrcweir 			}
362cdf0e10cSrcweir 		}
363cdf0e10cSrcweir 	}
364cdf0e10cSrcweir 
365cdf0e10cSrcweir 	for (nArrX=0; nArrX<=nX2+2; nArrX++)					// links & rechts + 1
366cdf0e10cSrcweir 	{
367cdf0e10cSrcweir 		nX = (nArrX>0) ? nArrX-1 : MAXCOL+1;					// negativ -> ungueltig
368cdf0e10cSrcweir 
369cdf0e10cSrcweir 		if ( ValidCol(nX) )
370cdf0e10cSrcweir 		{
371cdf0e10cSrcweir             // #i58049#, #i57939# Hidden columns must be skipped here, or their attributes
372cdf0e10cSrcweir             // will disturb the output
373cdf0e10cSrcweir 
374cdf0e10cSrcweir             // TODO: Optimize this loop.
375cdf0e10cSrcweir             if (!ColHidden(nX, nTab))
376cdf0e10cSrcweir 			{
377cdf0e10cSrcweir 				sal_uInt16 nThisWidth = (sal_uInt16) (GetColWidth( nX, nTab ) * nScaleX);
378cdf0e10cSrcweir                 if (!nThisWidth)
379cdf0e10cSrcweir 					nThisWidth = 1;
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 				pRowInfo[0].pCellInfo[nArrX].nWidth = nThisWidth;			//! dies sollte reichen
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 				ScColumn* pThisCol = &pTab[nTab]->aCol[nX];					// Spalten-Daten
384cdf0e10cSrcweir 
385cdf0e10cSrcweir                 nArrY = 1;
386cdf0e10cSrcweir                 SCSIZE nUIndex;
387cdf0e10cSrcweir                 bool bHiddenRow = true;
388cdf0e10cSrcweir                 SCROW nHiddenEndRow = -1;
389cdf0e10cSrcweir                 (void) pThisCol->Search( nY1, nUIndex );
390cdf0e10cSrcweir                 while ( nUIndex < pThisCol->nCount &&
391cdf0e10cSrcweir                         (nThisRow=pThisCol->pItems[nUIndex].nRow) <= nY2 )
392cdf0e10cSrcweir                 {
393cdf0e10cSrcweir                     if (nThisRow > nHiddenEndRow)
394cdf0e10cSrcweir                         bHiddenRow = RowHidden( nThisRow, nTab, nHiddenEndRow);
395cdf0e10cSrcweir                     if ( !bHiddenRow )
396cdf0e10cSrcweir                     {
397cdf0e10cSrcweir                         while ( pRowInfo[nArrY].nRowNo < nThisRow )
398cdf0e10cSrcweir                             ++nArrY;
399cdf0e10cSrcweir                         DBG_ASSERT( pRowInfo[nArrY].nRowNo == nThisRow, "Zeile nicht gefunden in FillInfo" );
400cdf0e10cSrcweir 
401cdf0e10cSrcweir                         RowInfo* pThisRowInfo = &pRowInfo[nArrY];
402cdf0e10cSrcweir                         CellInfo* pInfo = &pThisRowInfo->pCellInfo[nArrX];
403cdf0e10cSrcweir                         pInfo->pCell = pThisCol->pItems[nUIndex].pCell;
404cdf0e10cSrcweir                         if (pInfo->pCell->GetCellType() != CELLTYPE_NOTE)
405cdf0e10cSrcweir                         {
406cdf0e10cSrcweir                             pThisRowInfo->bEmptyText = sal_False;                   // Zeile nicht leer
407cdf0e10cSrcweir                             pInfo->bEmptyCellText = sal_False;                      // Zelle nicht leer
408cdf0e10cSrcweir                         }
409cdf0e10cSrcweir                         ++nArrY;
410cdf0e10cSrcweir                     }
411cdf0e10cSrcweir                     ++nUIndex;
412cdf0e10cSrcweir                 }
413cdf0e10cSrcweir 
414cdf0e10cSrcweir 				if (nX+1 >= nX1)								// Attribute/Blockmarken ab nX1-1
415cdf0e10cSrcweir 				{
416cdf0e10cSrcweir 					ScAttrArray* pThisAttrArr = pThisCol->pAttrArray;		// Attribute
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 					nArrY = 0;
419cdf0e10cSrcweir 					const ScPatternAttr* pPattern;
420cdf0e10cSrcweir 					SCROW nCurRow=nY1;					// einzelne Zeile
421cdf0e10cSrcweir 					if (nCurRow>0)
422cdf0e10cSrcweir 						--nCurRow;						// oben 1 mehr
423cdf0e10cSrcweir 					else
424cdf0e10cSrcweir 						nArrY = 1;
425cdf0e10cSrcweir 					nThisRow=nCurRow;					// Ende des Bereichs
426cdf0e10cSrcweir 					SCSIZE  nIndex;
427cdf0e10cSrcweir 					(void) pThisAttrArr->Search( nCurRow, nIndex );
428cdf0e10cSrcweir 
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 					do
431cdf0e10cSrcweir 					{
432cdf0e10cSrcweir 						nThisRow=pThisAttrArr->pData[nIndex].nRow;				// Ende des Bereichs
433cdf0e10cSrcweir 						pPattern=pThisAttrArr->pData[nIndex].pPattern;
434cdf0e10cSrcweir 
435cdf0e10cSrcweir 						const SvxBrushItem* pBackground = (const SvxBrushItem*)
436cdf0e10cSrcweir 														&pPattern->GetItem(ATTR_BACKGROUND);
437cdf0e10cSrcweir 						const SvxBoxItem* pLinesAttr = (const SvxBoxItem*)
438cdf0e10cSrcweir 														&pPattern->GetItem(ATTR_BORDER);
439cdf0e10cSrcweir 
440cdf0e10cSrcweir                         const SvxLineItem* pTLBRLine = static_cast< const SvxLineItem* >(
441cdf0e10cSrcweir                             &pPattern->GetItem( ATTR_BORDER_TLBR ) );
442cdf0e10cSrcweir                         const SvxLineItem* pBLTRLine = static_cast< const SvxLineItem* >(
443cdf0e10cSrcweir                             &pPattern->GetItem( ATTR_BORDER_BLTR ) );
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 						const SvxShadowItem* pShadowAttr = (const SvxShadowItem*)
446cdf0e10cSrcweir 														&pPattern->GetItem(ATTR_SHADOW);
447cdf0e10cSrcweir 						if (pShadowAttr != pDefShadow)
448cdf0e10cSrcweir 							bAnyShadow = sal_True;
449cdf0e10cSrcweir 
450cdf0e10cSrcweir 						const ScMergeAttr* pMergeAttr = (const ScMergeAttr*)
451cdf0e10cSrcweir 												&pPattern->GetItem(ATTR_MERGE);
452cdf0e10cSrcweir 						sal_Bool bMerged = ( pMergeAttr != pDefMerge && *pMergeAttr != *pDefMerge );
453cdf0e10cSrcweir 						sal_uInt16 nOverlap = ((const ScMergeFlagAttr*) &pPattern->GetItemSet().
454cdf0e10cSrcweir 														Get(ATTR_MERGE_FLAG))->GetValue();
455cdf0e10cSrcweir 						sal_Bool bHOverlapped = ((nOverlap & SC_MF_HOR) != 0);
456cdf0e10cSrcweir 						sal_Bool bVOverlapped = ((nOverlap & SC_MF_VER) != 0);
457cdf0e10cSrcweir 						sal_Bool bAutoFilter  = ((nOverlap & SC_MF_AUTO) != 0);
458cdf0e10cSrcweir 						sal_Bool bPushButton  = ((nOverlap & SC_MF_BUTTON) != 0);
459cdf0e10cSrcweir 						sal_Bool bScenario	  = ((nOverlap & SC_MF_SCENARIO) != 0);
460cdf0e10cSrcweir                         bool bPopupButton = ((nOverlap & SC_MF_BUTTON_POPUP) != 0);
461cdf0e10cSrcweir                         bool bFilterActive = ((nOverlap & SC_MF_HIDDEN_MEMBER) != 0);
462cdf0e10cSrcweir 						if (bMerged||bHOverlapped||bVOverlapped)
463cdf0e10cSrcweir 							bAnyMerged = sal_True;								// intern
464cdf0e10cSrcweir 
465cdf0e10cSrcweir 						sal_Bool bHidden, bHideFormula;
466cdf0e10cSrcweir 						if (bTabProtect)
467cdf0e10cSrcweir 						{
468cdf0e10cSrcweir 							const ScProtectionAttr& rProtAttr = (const ScProtectionAttr&)
469cdf0e10cSrcweir 														pPattern->GetItem(ATTR_PROTECTION);
470cdf0e10cSrcweir 							bHidden = rProtAttr.GetHideCell();
471cdf0e10cSrcweir 							bHideFormula = rProtAttr.GetHideFormula();
472cdf0e10cSrcweir 						}
473cdf0e10cSrcweir 						else
474cdf0e10cSrcweir 							bHidden = bHideFormula = sal_False;
475cdf0e10cSrcweir 
476cdf0e10cSrcweir 						sal_uLong nConditional = ((const SfxUInt32Item&)pPattern->
477cdf0e10cSrcweir 												GetItem(ATTR_CONDITIONAL)).GetValue();
478cdf0e10cSrcweir 						const ScConditionalFormat* pCondForm = NULL;
479cdf0e10cSrcweir 						if ( nConditional && pCondFormList )
480cdf0e10cSrcweir 							pCondForm = pCondFormList->GetFormat( nConditional );
481cdf0e10cSrcweir 
482cdf0e10cSrcweir 						do
483cdf0e10cSrcweir 						{
484cdf0e10cSrcweir                             SCROW nLastHiddenRow = -1;
485cdf0e10cSrcweir                             bool bRowHidden = RowHidden(nCurRow, nTab, nLastHiddenRow);
486cdf0e10cSrcweir 							if ( nArrY==0 || !bRowHidden )
487cdf0e10cSrcweir 							{
488cdf0e10cSrcweir 								RowInfo* pThisRowInfo = &pRowInfo[nArrY];
489cdf0e10cSrcweir 								if (pBackground != pDefBackground)			// Spalten-HG == Standard ?
490cdf0e10cSrcweir 									pThisRowInfo->bEmptyBack = sal_False;
491cdf0e10cSrcweir 								if (bAutoFilter)
492cdf0e10cSrcweir 									pThisRowInfo->bAutoFilter = sal_True;
493cdf0e10cSrcweir 								if (bPushButton)
494cdf0e10cSrcweir 									pThisRowInfo->bPushButton = sal_True;
495cdf0e10cSrcweir 
496cdf0e10cSrcweir 								CellInfo* pInfo = &pThisRowInfo->pCellInfo[nArrX];
497cdf0e10cSrcweir 								pInfo->pBackground	= pBackground;
498cdf0e10cSrcweir 								pInfo->pPatternAttr	= pPattern;
499cdf0e10cSrcweir 								pInfo->bMerged		= bMerged;
500cdf0e10cSrcweir 								pInfo->bHOverlapped	= bHOverlapped;
501cdf0e10cSrcweir 								pInfo->bVOverlapped	= bVOverlapped;
502cdf0e10cSrcweir 								pInfo->bAutoFilter	= bAutoFilter;
503cdf0e10cSrcweir 								pInfo->bPushButton	= bPushButton;
504cdf0e10cSrcweir                                 pInfo->bPopupButton = bPopupButton;
505cdf0e10cSrcweir                                 pInfo->bFilterActive = bFilterActive;
506cdf0e10cSrcweir 								pInfo->pLinesAttr	= pLinesAttr;
507cdf0e10cSrcweir                                 pInfo->mpTLBRLine   = pTLBRLine;
508cdf0e10cSrcweir                                 pInfo->mpBLTRLine   = pBLTRLine;
509cdf0e10cSrcweir 								pInfo->pShadowAttr	= pShadowAttr;
510cdf0e10cSrcweir 								//	nWidth wird nicht mehr einzeln gesetzt
511cdf0e10cSrcweir 
512*acf6b796SHerbert Dürr                                 sal_Bool bEmbed = sal_False; /*bIsEmbedded &&
513cdf0e10cSrcweir 										nTab	>= aEmbedRange.aStart.Tab() &&
514cdf0e10cSrcweir 										nTab    <= aEmbedRange.aEnd.Tab()   &&
515cdf0e10cSrcweir 										nX		>= aEmbedRange.aStart.Col() &&
516cdf0e10cSrcweir 										nX	    <= aEmbedRange.aEnd.Col()   &&
517cdf0e10cSrcweir 										nCurRow >= aEmbedRange.aStart.Row() &&
518*acf6b796SHerbert Dürr 										nCurRow <= aEmbedRange.aEnd.Row(); */
519cdf0e10cSrcweir 
520cdf0e10cSrcweir 								if (bScenario)
521cdf0e10cSrcweir 								{
522cdf0e10cSrcweir 									pInfo->pBackground = ScGlobal::GetButtonBrushItem();
523cdf0e10cSrcweir 									pThisRowInfo->bEmptyBack = sal_False;
524cdf0e10cSrcweir 								}
525cdf0e10cSrcweir 								else if (bEmbed)
526cdf0e10cSrcweir 								{
527cdf0e10cSrcweir 									pInfo->pBackground = ScGlobal::GetEmbeddedBrushItem();
528cdf0e10cSrcweir 									pThisRowInfo->bEmptyBack = sal_False;
529cdf0e10cSrcweir 								}
530cdf0e10cSrcweir 
531cdf0e10cSrcweir 								if (bHidden || ( bFormulaMode && bHideFormula && pInfo->pCell
532cdf0e10cSrcweir 													&& pInfo->pCell->GetCellType()
533cdf0e10cSrcweir 														== CELLTYPE_FORMULA ))
534cdf0e10cSrcweir 									pInfo->bEmptyCellText = sal_True;
535cdf0e10cSrcweir 
536cdf0e10cSrcweir 								if ( pCondForm )
537cdf0e10cSrcweir 								{
538cdf0e10cSrcweir 									String aStyle = pCondForm->GetCellStyle( pInfo->pCell,
539cdf0e10cSrcweir 														ScAddress( nX, nCurRow, nTab ) );
540cdf0e10cSrcweir 									if (aStyle.Len())
541cdf0e10cSrcweir 									{
542cdf0e10cSrcweir 										SfxStyleSheetBase* pStyleSheet =
543cdf0e10cSrcweir 												pStlPool->Find( aStyle, SFX_STYLE_FAMILY_PARA );
544cdf0e10cSrcweir 										if ( pStyleSheet )
545cdf0e10cSrcweir 										{
546cdf0e10cSrcweir 											//!	Style-Sets cachen !!!
547cdf0e10cSrcweir 											pInfo->pConditionSet = &pStyleSheet->GetItemSet();
548cdf0e10cSrcweir 											bAnyCondition = sal_True;
549cdf0e10cSrcweir 										}
550cdf0e10cSrcweir 										// if style is not there, treat like no condition
551cdf0e10cSrcweir 									}
552cdf0e10cSrcweir 								}
553cdf0e10cSrcweir 
554cdf0e10cSrcweir 								++nArrY;
555cdf0e10cSrcweir 							}
556cdf0e10cSrcweir                             else if (bRowHidden && nLastHiddenRow >= 0)
557cdf0e10cSrcweir                             {
558cdf0e10cSrcweir                                 nCurRow = nLastHiddenRow;
559cdf0e10cSrcweir                                 if (nCurRow > nThisRow)
560cdf0e10cSrcweir                                     nCurRow = nThisRow;
561cdf0e10cSrcweir                             }
562cdf0e10cSrcweir 							++nCurRow;
563cdf0e10cSrcweir 						}
564cdf0e10cSrcweir 						while (nCurRow <= nThisRow && nCurRow <= nYExtra);
565cdf0e10cSrcweir 						++nIndex;
566cdf0e10cSrcweir 					}
567cdf0e10cSrcweir 					while ( nIndex < pThisAttrArr->nCount && nThisRow < nYExtra );
568cdf0e10cSrcweir 
569cdf0e10cSrcweir 
570cdf0e10cSrcweir 					if (pMarkData && pMarkData->IsMultiMarked())
571cdf0e10cSrcweir 					{
572cdf0e10cSrcweir 						//	Blockmarken
573cdf0e10cSrcweir 						const ScMarkArray* pThisMarkArr = pMarkData->GetArray()+nX;
574cdf0e10cSrcweir 						sal_Bool bThisMarked;
575cdf0e10cSrcweir 						nArrY = 1;
576cdf0e10cSrcweir 						nCurRow = nY1;										// einzelne Zeile
577cdf0e10cSrcweir 						nThisRow = nY1;										// Ende des Bereichs
578cdf0e10cSrcweir 
579cdf0e10cSrcweir                         if ( pThisMarkArr->Search( nY1, nIndex ) )
580cdf0e10cSrcweir                         {
581cdf0e10cSrcweir                             do
582cdf0e10cSrcweir                             {
583cdf0e10cSrcweir                                 nThisRow=pThisMarkArr->pData[nIndex].nRow;      // Ende des Bereichs
584cdf0e10cSrcweir                                 bThisMarked=pThisMarkArr->pData[nIndex].bMarked;
585cdf0e10cSrcweir 
586cdf0e10cSrcweir                                 do
587cdf0e10cSrcweir                                 {
588cdf0e10cSrcweir                                     if ( !RowHidden( nCurRow,nTab ) )
589cdf0e10cSrcweir                                     {
590cdf0e10cSrcweir                                         if ( bThisMarked )
591cdf0e10cSrcweir                                         {
592cdf0e10cSrcweir                                             sal_Bool bSkip = bSkipMarks &&
593cdf0e10cSrcweir                                                         nX      >= nBlockStartX &&
594cdf0e10cSrcweir                                                         nX      <= nBlockEndX   &&
595cdf0e10cSrcweir                                                         nCurRow >= nBlockStartY &&
596cdf0e10cSrcweir                                                         nCurRow <= nBlockEndY;
597cdf0e10cSrcweir                                             if (!bSkip)
598cdf0e10cSrcweir                                             {
599cdf0e10cSrcweir                                                 RowInfo* pThisRowInfo = &pRowInfo[nArrY];
600cdf0e10cSrcweir                                                 CellInfo* pInfo = &pThisRowInfo->pCellInfo[nArrX];
601cdf0e10cSrcweir                                                 pInfo->bMarked = sal_True;
602cdf0e10cSrcweir                                             }
603cdf0e10cSrcweir                                         }
604cdf0e10cSrcweir                                         ++nArrY;
605cdf0e10cSrcweir                                     }
606cdf0e10cSrcweir                                     ++nCurRow;
607cdf0e10cSrcweir                                 }
608cdf0e10cSrcweir                                 while (nCurRow <= nThisRow && nCurRow <= nY2);
609cdf0e10cSrcweir                                 ++nIndex;
610cdf0e10cSrcweir                             }
611cdf0e10cSrcweir                             while ( nIndex < pThisMarkArr->nCount && nThisRow < nY2 );
612cdf0e10cSrcweir                         }
613cdf0e10cSrcweir 					}
614cdf0e10cSrcweir 				}
615cdf0e10cSrcweir 				else									// vordere Spalten
616cdf0e10cSrcweir 				{
617cdf0e10cSrcweir 					for (nArrY=1; nArrY+1<nArrCount; nArrY++)
618cdf0e10cSrcweir 					{
619cdf0e10cSrcweir 						RowInfo* pThisRowInfo = &pRowInfo[nArrY];
620cdf0e10cSrcweir 						CellInfo* pInfo = &pThisRowInfo->pCellInfo[nArrX];
621cdf0e10cSrcweir 
622cdf0e10cSrcweir 						pInfo->nWidth		= nThisWidth;			//! oder nur 0 abfragen ??
623cdf0e10cSrcweir 					}
624cdf0e10cSrcweir 				}
625cdf0e10cSrcweir 			}
626cdf0e10cSrcweir 		}
627cdf0e10cSrcweir 		else
628cdf0e10cSrcweir 			pRowInfo[0].pCellInfo[nArrX].nWidth = STD_COL_WIDTH;
629cdf0e10cSrcweir 		// STD_COL_WIDTH ganz links und rechts wird fuer DrawExtraShadow gebraucht
630cdf0e10cSrcweir 	}
631cdf0e10cSrcweir 
632cdf0e10cSrcweir 	//-------------------------------------------------------------------------
633cdf0e10cSrcweir 	//	bedingte Formatierung auswerten
634cdf0e10cSrcweir 
635cdf0e10cSrcweir 	if (bAnyCondition)
636cdf0e10cSrcweir 	{
637cdf0e10cSrcweir 		for (nArrY=0; nArrY<nArrCount; nArrY++)
638cdf0e10cSrcweir 		{
639cdf0e10cSrcweir 			for (nArrX=nX1; nArrX<=nX2+2; nArrX++)					// links und rechts einer mehr
640cdf0e10cSrcweir 			{
641cdf0e10cSrcweir 				CellInfo* pInfo = &pRowInfo[nArrY].pCellInfo[nArrX];
642cdf0e10cSrcweir 				const SfxItemSet* pCondSet = pInfo->pConditionSet;
643cdf0e10cSrcweir 				if (pCondSet)
644cdf0e10cSrcweir 				{
645cdf0e10cSrcweir 					const SfxPoolItem* pItem;
646cdf0e10cSrcweir 
647cdf0e10cSrcweir 							//	Hintergrund
648cdf0e10cSrcweir 					if ( pCondSet->GetItemState( ATTR_BACKGROUND, sal_True, &pItem ) == SFX_ITEM_SET )
649cdf0e10cSrcweir 					{
650cdf0e10cSrcweir 						pInfo->pBackground = (const SvxBrushItem*) pItem;
651cdf0e10cSrcweir 						pRowInfo[nArrY].bEmptyBack = sal_False;
652cdf0e10cSrcweir 					}
653cdf0e10cSrcweir 
654cdf0e10cSrcweir 							//	Umrandung
655cdf0e10cSrcweir 					if ( pCondSet->GetItemState( ATTR_BORDER, sal_True, &pItem ) == SFX_ITEM_SET )
656cdf0e10cSrcweir 						pInfo->pLinesAttr = (const SvxBoxItem*) pItem;
657cdf0e10cSrcweir 
658cdf0e10cSrcweir                     if ( pCondSet->GetItemState( ATTR_BORDER_TLBR, sal_True, &pItem ) == SFX_ITEM_SET )
659cdf0e10cSrcweir                         pInfo->mpTLBRLine = static_cast< const SvxLineItem* >( pItem );
660cdf0e10cSrcweir                     if ( pCondSet->GetItemState( ATTR_BORDER_BLTR, sal_True, &pItem ) == SFX_ITEM_SET )
661cdf0e10cSrcweir                         pInfo->mpBLTRLine = static_cast< const SvxLineItem* >( pItem );
662cdf0e10cSrcweir 
663cdf0e10cSrcweir 							//	Schatten
664cdf0e10cSrcweir 					if ( pCondSet->GetItemState( ATTR_SHADOW, sal_True, &pItem ) == SFX_ITEM_SET )
665cdf0e10cSrcweir 					{
666cdf0e10cSrcweir 						pInfo->pShadowAttr = (const SvxShadowItem*) pItem;
667cdf0e10cSrcweir 						bAnyShadow = sal_True;
668cdf0e10cSrcweir 					}
669cdf0e10cSrcweir 				}
670cdf0e10cSrcweir 			}
671cdf0e10cSrcweir 		}
672cdf0e10cSrcweir 	}
673cdf0e10cSrcweir 
674cdf0e10cSrcweir 	//	bedingte Formatierung Ende
675cdf0e10cSrcweir 	//-------------------------------------------------------------------------
676cdf0e10cSrcweir 
677cdf0e10cSrcweir 				//
678cdf0e10cSrcweir 				//		Daten von zusammengefassten Zellen anpassen
679cdf0e10cSrcweir 				//
680cdf0e10cSrcweir 
681cdf0e10cSrcweir 	if (bAnyMerged)
682cdf0e10cSrcweir 	{
683cdf0e10cSrcweir 		for (nArrY=0; nArrY<nArrCount; nArrY++)
684cdf0e10cSrcweir 		{
685cdf0e10cSrcweir 			RowInfo* pThisRowInfo = &pRowInfo[nArrY];
686cdf0e10cSrcweir             nSignedY = nArrY ? pThisRowInfo->nRowNo : ((SCsROW)nY1)-1;
687cdf0e10cSrcweir 
688cdf0e10cSrcweir 			for (nArrX=nX1; nArrX<=nX2+2; nArrX++)					// links und rechts einer mehr
689cdf0e10cSrcweir 			{
690cdf0e10cSrcweir                 SCsCOL nSignedX = ((SCsCOL) nArrX) - 1;
691cdf0e10cSrcweir 				CellInfo* pInfo = &pThisRowInfo->pCellInfo[nArrX];
692cdf0e10cSrcweir 
693cdf0e10cSrcweir 				if (pInfo->bMerged || pInfo->bHOverlapped || pInfo->bVOverlapped)
694cdf0e10cSrcweir 				{
695cdf0e10cSrcweir 					SCsCOL nStartX;
696cdf0e10cSrcweir 					SCsROW nStartY;
697cdf0e10cSrcweir 					SCsCOL nEndX;
698cdf0e10cSrcweir 					SCsROW nEndY;
699cdf0e10cSrcweir 					lcl_GetMergeRange( nSignedX,nSignedY, nArrY, this,pRowInfo, nX1,nY1,nX2,nY2,nTab,
700cdf0e10cSrcweir 										nStartX,nStartY, nEndX,nEndY );
701cdf0e10cSrcweir 					const ScPatternAttr* pStartPattern = GetPattern( nStartX,nStartY,nTab );
702cdf0e10cSrcweir 					const SfxItemSet* pStartCond = GetCondResult( nStartX,nStartY,nTab );
703cdf0e10cSrcweir 					const SfxPoolItem* pItem;
704cdf0e10cSrcweir 
705cdf0e10cSrcweir 					// Hintergrund kopieren (oder in output.cxx)
706cdf0e10cSrcweir 
707cdf0e10cSrcweir 					if ( !pStartCond || pStartCond->
708cdf0e10cSrcweir 									GetItemState(ATTR_BACKGROUND,sal_True,&pItem) != SFX_ITEM_SET )
709cdf0e10cSrcweir 						pItem = &pStartPattern->GetItem(ATTR_BACKGROUND);
710cdf0e10cSrcweir 					pInfo->pBackground = (const SvxBrushItem*) pItem;
711cdf0e10cSrcweir 					pRowInfo[nArrY].bEmptyBack = sal_False;
712cdf0e10cSrcweir 
713cdf0e10cSrcweir 					// Schatten
714cdf0e10cSrcweir 
715cdf0e10cSrcweir 					if ( !pStartCond || pStartCond->
716cdf0e10cSrcweir 									GetItemState(ATTR_SHADOW,sal_True,&pItem) != SFX_ITEM_SET )
717cdf0e10cSrcweir 						pItem = &pStartPattern->GetItem(ATTR_SHADOW);
718cdf0e10cSrcweir 					pInfo->pShadowAttr = (const SvxShadowItem*) pItem;
719cdf0e10cSrcweir 					if (pInfo->pShadowAttr != pDefShadow)
720cdf0e10cSrcweir 						bAnyShadow = sal_True;
721cdf0e10cSrcweir 
722cdf0e10cSrcweir 					// Blockmarken - wieder mit Original-Merge-Werten
723cdf0e10cSrcweir 
724cdf0e10cSrcweir 					sal_Bool bCellMarked = sal_False;
725cdf0e10cSrcweir 					if (bPaintMarks)
726cdf0e10cSrcweir 						bCellMarked = ( nStartX >= (SCsCOL) nBlockStartX
727cdf0e10cSrcweir 									&& nStartX <= (SCsCOL) nBlockEndX
728cdf0e10cSrcweir 									&& nStartY >= (SCsROW) nBlockStartY
729cdf0e10cSrcweir 									&& nStartY <= (SCsROW) nBlockEndY );
730cdf0e10cSrcweir 					if (pMarkData && pMarkData->IsMultiMarked() && !bCellMarked)
731cdf0e10cSrcweir 					{
732cdf0e10cSrcweir 						const ScMarkArray* pThisMarkArr = pMarkData->GetArray()+nStartX;
733cdf0e10cSrcweir 						SCSIZE nIndex;
734cdf0e10cSrcweir                         if ( pThisMarkArr->Search( nStartY, nIndex ) )
735cdf0e10cSrcweir                             bCellMarked=pThisMarkArr->pData[nIndex].bMarked;
736cdf0e10cSrcweir 					}
737cdf0e10cSrcweir 
738cdf0e10cSrcweir 					pInfo->bMarked = bCellMarked;
739cdf0e10cSrcweir 				}
740cdf0e10cSrcweir 			}
741cdf0e10cSrcweir 		}
742cdf0e10cSrcweir 	}
743cdf0e10cSrcweir 
744cdf0e10cSrcweir 	if (bAnyShadow)								// Schatten verteilen
745cdf0e10cSrcweir 	{
746cdf0e10cSrcweir 		for (nArrY=0; nArrY<nArrCount; nArrY++)
747cdf0e10cSrcweir 		{
748cdf0e10cSrcweir 			sal_Bool bTop = ( nArrY == 0 );
749cdf0e10cSrcweir 			sal_Bool bBottom = ( nArrY+1 == nArrCount );
750cdf0e10cSrcweir 
751cdf0e10cSrcweir 			for (nArrX=nX1; nArrX<=nX2+2; nArrX++)					// links und rechts einer mehr
752cdf0e10cSrcweir 			{
753cdf0e10cSrcweir 				sal_Bool bLeft = ( nArrX == nX1 );
754cdf0e10cSrcweir 				sal_Bool bRight = ( nArrX == nX2+2 );
755cdf0e10cSrcweir 
756cdf0e10cSrcweir 				CellInfo* pInfo = &pRowInfo[nArrY].pCellInfo[nArrX];
757cdf0e10cSrcweir 				const SvxShadowItem* pThisAttr = pInfo->pShadowAttr;
758cdf0e10cSrcweir 				SvxShadowLocation eLoc = pThisAttr ? pThisAttr->GetLocation() : SVX_SHADOW_NONE;
759cdf0e10cSrcweir 				if (eLoc != SVX_SHADOW_NONE)
760cdf0e10cSrcweir 				{
761cdf0e10cSrcweir 					//	oder Test auf != eLoc
762cdf0e10cSrcweir 
763cdf0e10cSrcweir 					SCsCOL nDxPos = 1;
764cdf0e10cSrcweir 					SCsCOL nDxNeg = -1;
765cdf0e10cSrcweir 
766cdf0e10cSrcweir 					while ( nArrX+nDxPos < nX2+2 && pRowInfo[0].pCellInfo[nArrX+nDxPos].nWidth == 0 )
767cdf0e10cSrcweir 						++nDxPos;
768cdf0e10cSrcweir 					while ( nArrX+nDxNeg > nX1 && pRowInfo[0].pCellInfo[nArrX+nDxNeg].nWidth == 0 )
769cdf0e10cSrcweir 						--nDxNeg;
770cdf0e10cSrcweir 
771cdf0e10cSrcweir 					sal_Bool bLeftDiff = !bLeft &&
772cdf0e10cSrcweir 							CELLINFO(nDxNeg,0).pShadowAttr->GetLocation() == SVX_SHADOW_NONE;
773cdf0e10cSrcweir 					sal_Bool bRightDiff = !bRight &&
774cdf0e10cSrcweir 							CELLINFO(nDxPos,0).pShadowAttr->GetLocation() == SVX_SHADOW_NONE;
775cdf0e10cSrcweir 					sal_Bool bTopDiff = !bTop &&
776cdf0e10cSrcweir 							CELLINFO(0,-1).pShadowAttr->GetLocation() == SVX_SHADOW_NONE;
777cdf0e10cSrcweir 					sal_Bool bBottomDiff = !bBottom &&
778cdf0e10cSrcweir 							CELLINFO(0,1).pShadowAttr->GetLocation() == SVX_SHADOW_NONE;
779cdf0e10cSrcweir 
780cdf0e10cSrcweir 					if ( bLayoutRTL )
781cdf0e10cSrcweir 					{
782cdf0e10cSrcweir 						switch (eLoc)
783cdf0e10cSrcweir 						{
784cdf0e10cSrcweir 							case SVX_SHADOW_BOTTOMRIGHT: eLoc = SVX_SHADOW_BOTTOMLEFT;	break;
785cdf0e10cSrcweir 							case SVX_SHADOW_BOTTOMLEFT:	 eLoc = SVX_SHADOW_BOTTOMRIGHT;	break;
786cdf0e10cSrcweir 							case SVX_SHADOW_TOPRIGHT:	 eLoc = SVX_SHADOW_TOPLEFT;		break;
787cdf0e10cSrcweir 							case SVX_SHADOW_TOPLEFT:	 eLoc = SVX_SHADOW_TOPRIGHT;	break;
788cdf0e10cSrcweir                             default:
789cdf0e10cSrcweir                             {
790cdf0e10cSrcweir                                 // added to avoid warnings
791cdf0e10cSrcweir                             }
792cdf0e10cSrcweir 						}
793cdf0e10cSrcweir 					}
794cdf0e10cSrcweir 
795cdf0e10cSrcweir 					switch (eLoc)
796cdf0e10cSrcweir 					{
797cdf0e10cSrcweir 						case SVX_SHADOW_BOTTOMRIGHT:
798cdf0e10cSrcweir 							if (bBottomDiff)
799cdf0e10cSrcweir 							{
800cdf0e10cSrcweir 								CELLINFO(0,1).pHShadowOrigin = pThisAttr;
801cdf0e10cSrcweir 								CELLINFO(0,1).eHShadowPart =
802cdf0e10cSrcweir 												bLeftDiff ? SC_SHADOW_HSTART : SC_SHADOW_HORIZ;
803cdf0e10cSrcweir 							}
804cdf0e10cSrcweir 							if (bRightDiff)
805cdf0e10cSrcweir 							{
806cdf0e10cSrcweir 								CELLINFO(1,0).pVShadowOrigin = pThisAttr;
807cdf0e10cSrcweir 								CELLINFO(1,0).eVShadowPart =
808cdf0e10cSrcweir 												bTopDiff ? SC_SHADOW_VSTART : SC_SHADOW_VERT;
809cdf0e10cSrcweir 							}
810cdf0e10cSrcweir 							if (bBottomDiff && bRightDiff)
811cdf0e10cSrcweir 							{
812cdf0e10cSrcweir 								CELLINFO(1,1).pHShadowOrigin = pThisAttr;
813cdf0e10cSrcweir 								CELLINFO(1,1).eHShadowPart = SC_SHADOW_CORNER;
814cdf0e10cSrcweir 							}
815cdf0e10cSrcweir 							break;
816cdf0e10cSrcweir 
817cdf0e10cSrcweir 						case SVX_SHADOW_BOTTOMLEFT:
818cdf0e10cSrcweir 							if (bBottomDiff)
819cdf0e10cSrcweir 							{
820cdf0e10cSrcweir 								CELLINFO(0,1).pHShadowOrigin = pThisAttr;
821cdf0e10cSrcweir 								CELLINFO(0,1).eHShadowPart =
822cdf0e10cSrcweir 												bRightDiff ? SC_SHADOW_HSTART : SC_SHADOW_HORIZ;
823cdf0e10cSrcweir 							}
824cdf0e10cSrcweir 							if (bLeftDiff)
825cdf0e10cSrcweir 							{
826cdf0e10cSrcweir 								CELLINFO(-1,0).pVShadowOrigin = pThisAttr;
827cdf0e10cSrcweir 								CELLINFO(-1,0).eVShadowPart =
828cdf0e10cSrcweir 												bTopDiff ? SC_SHADOW_VSTART : SC_SHADOW_VERT;
829cdf0e10cSrcweir 							}
830cdf0e10cSrcweir 							if (bBottomDiff && bLeftDiff)
831cdf0e10cSrcweir 							{
832cdf0e10cSrcweir 								CELLINFO(-1,1).pHShadowOrigin = pThisAttr;
833cdf0e10cSrcweir 								CELLINFO(-1,1).eHShadowPart = SC_SHADOW_CORNER;
834cdf0e10cSrcweir 							}
835cdf0e10cSrcweir 							break;
836cdf0e10cSrcweir 
837cdf0e10cSrcweir 						case SVX_SHADOW_TOPRIGHT:
838cdf0e10cSrcweir 							if (bTopDiff)
839cdf0e10cSrcweir 							{
840cdf0e10cSrcweir 								CELLINFO(0,-1).pHShadowOrigin = pThisAttr;
841cdf0e10cSrcweir 								CELLINFO(0,-1).eHShadowPart =
842cdf0e10cSrcweir 												bLeftDiff ? SC_SHADOW_HSTART : SC_SHADOW_HORIZ;
843cdf0e10cSrcweir 							}
844cdf0e10cSrcweir 							if (bRightDiff)
845cdf0e10cSrcweir 							{
846cdf0e10cSrcweir 								CELLINFO(1,0).pVShadowOrigin = pThisAttr;
847cdf0e10cSrcweir 								CELLINFO(1,0).eVShadowPart =
848cdf0e10cSrcweir 												bBottomDiff ? SC_SHADOW_VSTART : SC_SHADOW_VERT;
849cdf0e10cSrcweir 							}
850cdf0e10cSrcweir 							if (bTopDiff && bRightDiff)
851cdf0e10cSrcweir 							{
852cdf0e10cSrcweir 								CELLINFO(1,-1).pHShadowOrigin = pThisAttr;
853cdf0e10cSrcweir 								CELLINFO(1,-1).eHShadowPart = SC_SHADOW_CORNER;
854cdf0e10cSrcweir 							}
855cdf0e10cSrcweir 							break;
856cdf0e10cSrcweir 
857cdf0e10cSrcweir 						case SVX_SHADOW_TOPLEFT:
858cdf0e10cSrcweir 							if (bTopDiff)
859cdf0e10cSrcweir 							{
860cdf0e10cSrcweir 								CELLINFO(0,-1).pHShadowOrigin = pThisAttr;
861cdf0e10cSrcweir 								CELLINFO(0,-1).eHShadowPart =
862cdf0e10cSrcweir 												bRightDiff ? SC_SHADOW_HSTART : SC_SHADOW_HORIZ;
863cdf0e10cSrcweir 							}
864cdf0e10cSrcweir 							if (bLeftDiff)
865cdf0e10cSrcweir 							{
866cdf0e10cSrcweir 								CELLINFO(-1,0).pVShadowOrigin = pThisAttr;
867cdf0e10cSrcweir 								CELLINFO(-1,0).eVShadowPart =
868cdf0e10cSrcweir 												bBottomDiff ? SC_SHADOW_VSTART : SC_SHADOW_VERT;
869cdf0e10cSrcweir 							}
870cdf0e10cSrcweir 							if (bTopDiff && bLeftDiff)
871cdf0e10cSrcweir 							{
872cdf0e10cSrcweir 								CELLINFO(-1,-1).pHShadowOrigin = pThisAttr;
873cdf0e10cSrcweir 								CELLINFO(-1,-1).eHShadowPart = SC_SHADOW_CORNER;
874cdf0e10cSrcweir 							}
875cdf0e10cSrcweir 							break;
876cdf0e10cSrcweir 
877cdf0e10cSrcweir 						default:
878cdf0e10cSrcweir 							DBG_ERROR("falscher Shadow-Enum");
879cdf0e10cSrcweir 					}
880cdf0e10cSrcweir 				}
881cdf0e10cSrcweir 			}
882cdf0e10cSrcweir 		}
883cdf0e10cSrcweir 	}
884cdf0e10cSrcweir 
885cdf0e10cSrcweir     rTabInfo.mnArrCount = sal::static_int_cast<sal_uInt16>(nArrCount);
886cdf0e10cSrcweir     rTabInfo.mbPageMode = bPageMode;
887cdf0e10cSrcweir 
888cdf0e10cSrcweir     // ========================================================================
889cdf0e10cSrcweir     // *** create the frame border array ***
890cdf0e10cSrcweir 
891cdf0e10cSrcweir     // RowInfo structs are filled in the range [ 0 , nArrCount-1 ]
892cdf0e10cSrcweir     // each RowInfo contains CellInfo structs in the range [ nX1-1 , nX2+1 ]
893cdf0e10cSrcweir 
894cdf0e10cSrcweir     size_t nColCount = nX2 - nX1 + 3;
895cdf0e10cSrcweir     size_t nRowCount = nArrCount;
896cdf0e10cSrcweir 
897cdf0e10cSrcweir     svx::frame::Array& rArray = rTabInfo.maArray;
898cdf0e10cSrcweir     rArray.Initialize( nColCount, nRowCount );
899cdf0e10cSrcweir     rArray.SetUseDiagDoubleClipping( false );
900cdf0e10cSrcweir 
901cdf0e10cSrcweir     for( size_t nRow = 0; nRow < nRowCount; ++nRow )
902cdf0e10cSrcweir     {
903cdf0e10cSrcweir         sal_uInt16 nCellInfoY = static_cast< sal_uInt16 >( nRow );
904cdf0e10cSrcweir         RowInfo& rThisRowInfo = pRowInfo[ nCellInfoY ];
905cdf0e10cSrcweir 
906cdf0e10cSrcweir         for( size_t nCol = 0; nCol < nColCount; ++nCol )
907cdf0e10cSrcweir         {
908cdf0e10cSrcweir             sal_uInt16 nCellInfoX = static_cast< sal_uInt16 >( nCol + nX1 );
909cdf0e10cSrcweir             const CellInfo& rInfo = rThisRowInfo.pCellInfo[ nCellInfoX ];
910cdf0e10cSrcweir 
911cdf0e10cSrcweir             const SvxBoxItem* pBox = rInfo.pLinesAttr;
912cdf0e10cSrcweir             const SvxLineItem* pTLBR = rInfo.mpTLBRLine;
913cdf0e10cSrcweir             const SvxLineItem* pBLTR = rInfo.mpBLTRLine;
914cdf0e10cSrcweir 
915cdf0e10cSrcweir             size_t nFirstCol = nCol;
916cdf0e10cSrcweir             size_t nFirstRow = nRow;
917cdf0e10cSrcweir 
918cdf0e10cSrcweir             // *** merged cells *** -------------------------------------------
919cdf0e10cSrcweir 
920cdf0e10cSrcweir             if( !rArray.IsMerged( nCol, nRow ) && (rInfo.bMerged || rInfo.bHOverlapped || rInfo.bVOverlapped) )
921cdf0e10cSrcweir             {
922cdf0e10cSrcweir                 // *** insert merged range in svx::frame::Array ***
923cdf0e10cSrcweir 
924cdf0e10cSrcweir                 /*  #i69369# top-left cell of a merged range may be located in
925cdf0e10cSrcweir                     a hidden column or row. Use lcl_GetMergeRange() to find the
926cdf0e10cSrcweir                     complete merged range, then calculate dimensions and
927cdf0e10cSrcweir                     document position of the visible range. */
928cdf0e10cSrcweir 
929cdf0e10cSrcweir                 // note: document columns are always one less than CellInfoX coords
930cdf0e10cSrcweir                 // note: document rows must be looked up in RowInfo structs
931cdf0e10cSrcweir 
932cdf0e10cSrcweir                 // current column and row in document coordinates
933cdf0e10cSrcweir                 SCCOL nCurrDocCol = static_cast< SCCOL >( nCellInfoX - 1 );
934cdf0e10cSrcweir                 SCROW nCurrDocRow = static_cast< SCROW >( (nCellInfoY > 0) ? rThisRowInfo.nRowNo : (nY1 - 1) );
935cdf0e10cSrcweir 
936cdf0e10cSrcweir                 // find entire merged range in document, returns signed document coordinates
937cdf0e10cSrcweir                 SCsCOL nFirstRealDocColS, nLastRealDocColS;
938cdf0e10cSrcweir                 SCsROW nFirstRealDocRowS, nLastRealDocRowS;
939cdf0e10cSrcweir                 lcl_GetMergeRange( static_cast< SCsCOL >( nCurrDocCol ), static_cast< SCsROW >( nCurrDocRow ),
940cdf0e10cSrcweir                     nCellInfoY, this, pRowInfo, nX1,nY1,nX2,nY2,nTab,
941cdf0e10cSrcweir                     nFirstRealDocColS, nFirstRealDocRowS, nLastRealDocColS, nLastRealDocRowS );
942cdf0e10cSrcweir 
943cdf0e10cSrcweir                 // *complete* merged range in document coordinates
944cdf0e10cSrcweir                 SCCOL nFirstRealDocCol = static_cast< SCCOL >( nFirstRealDocColS );
945cdf0e10cSrcweir                 SCROW nFirstRealDocRow = static_cast< SCROW >( nFirstRealDocRowS );
946cdf0e10cSrcweir                 SCCOL nLastRealDocCol  = static_cast< SCCOL >( nLastRealDocColS );
947cdf0e10cSrcweir                 SCROW nLastRealDocRow  = static_cast< SCROW >( nLastRealDocRowS );
948cdf0e10cSrcweir 
949cdf0e10cSrcweir                 // first visible column (nX1-1 is first processed document column)
950cdf0e10cSrcweir                 SCCOL nFirstDocCol = (nX1 > 0) ? ::std::max< SCCOL >( nFirstRealDocCol, nX1 - 1 ) : nFirstRealDocCol;
951cdf0e10cSrcweir                 sal_uInt16 nFirstCellInfoX = static_cast< sal_uInt16 >( nFirstDocCol + 1 );
952cdf0e10cSrcweir                 nFirstCol = static_cast< size_t >( nFirstCellInfoX - nX1 );
953cdf0e10cSrcweir 
954cdf0e10cSrcweir                 // last visible column (nX2+1 is last processed document column)
955cdf0e10cSrcweir                 SCCOL nLastDocCol = (nX2 < MAXCOL) ? ::std::min< SCCOL >( nLastRealDocCol, nX2 + 1 ) : nLastRealDocCol;
956cdf0e10cSrcweir                 sal_uInt16 nLastCellInfoX = static_cast< sal_uInt16 >( nLastDocCol + 1 );
957cdf0e10cSrcweir                 size_t nLastCol = static_cast< size_t >( nLastCellInfoX - nX1 );
958cdf0e10cSrcweir 
959cdf0e10cSrcweir                 // first visible row
960cdf0e10cSrcweir                 sal_uInt16 nFirstCellInfoY = nCellInfoY;
961cdf0e10cSrcweir                 while( ((nFirstCellInfoY > 1) && (pRowInfo[ nFirstCellInfoY - 1 ].nRowNo >= nFirstRealDocRow)) ||
962cdf0e10cSrcweir                        ((nFirstCellInfoY == 1) && (static_cast< SCROW >( nY1 - 1 ) >= nFirstRealDocRow)) )
963cdf0e10cSrcweir                     --nFirstCellInfoY;
964cdf0e10cSrcweir                 SCROW nFirstDocRow = (nFirstCellInfoY > 0) ? pRowInfo[ nFirstCellInfoY ].nRowNo : static_cast< SCROW >( nY1 - 1 );
965cdf0e10cSrcweir                 nFirstRow = static_cast< size_t >( nFirstCellInfoY );
966cdf0e10cSrcweir 
967cdf0e10cSrcweir                 // last visible row
968cdf0e10cSrcweir                 sal_uInt16 nLastCellInfoY = nCellInfoY;
969cdf0e10cSrcweir                 while( (sal::static_int_cast<SCSIZE>(nLastCellInfoY + 1) < nArrCount) &&
970cdf0e10cSrcweir                             (pRowInfo[ nLastCellInfoY + 1 ].nRowNo <= nLastRealDocRow) )
971cdf0e10cSrcweir                     ++nLastCellInfoY;
972cdf0e10cSrcweir                 SCROW nLastDocRow = (nLastCellInfoY > 0) ? pRowInfo[ nLastCellInfoY ].nRowNo : static_cast< SCROW >( nY1 - 1 );
973cdf0e10cSrcweir                 size_t nLastRow = static_cast< size_t >( nLastCellInfoY );
974cdf0e10cSrcweir 
975cdf0e10cSrcweir                 // insert merged range
976cdf0e10cSrcweir                 rArray.SetMergedRange( nFirstCol, nFirstRow, nLastCol, nLastRow );
977cdf0e10cSrcweir 
978cdf0e10cSrcweir                 // *** find additional size not included in svx::frame::Array ***
979cdf0e10cSrcweir 
980cdf0e10cSrcweir                 // additional space before first column
981cdf0e10cSrcweir                 if( nFirstCol == 0 )
982cdf0e10cSrcweir                 {
983cdf0e10cSrcweir                     long nSize = 0;
984cdf0e10cSrcweir                     for( SCCOL nDocCol = nFirstRealDocCol; nDocCol < nFirstDocCol; ++nDocCol )
985cdf0e10cSrcweir                         nSize += std::max( static_cast< long >( GetColWidth( nDocCol, nTab ) * nScaleX ), 1L );
986cdf0e10cSrcweir                     rArray.SetAddMergedLeftSize( nCol, nRow, nSize );
987cdf0e10cSrcweir                 }
988cdf0e10cSrcweir                 // additional space after last column
989cdf0e10cSrcweir                 if( nLastCol + 1 == nColCount )
990cdf0e10cSrcweir                 {
991cdf0e10cSrcweir                     long nSize = 0;
992cdf0e10cSrcweir                     for( SCCOL nDocCol = nLastDocCol + 1; nDocCol <= nLastRealDocCol; ++nDocCol )
993cdf0e10cSrcweir                         nSize += std::max( static_cast< long >( GetColWidth( nDocCol, nTab ) * nScaleX ), 1L );
994cdf0e10cSrcweir                     rArray.SetAddMergedRightSize( nCol, nRow, nSize );
995cdf0e10cSrcweir                 }
996cdf0e10cSrcweir                 // additional space above first row
997cdf0e10cSrcweir                 if( nFirstRow == 0 )
998cdf0e10cSrcweir                 {
999cdf0e10cSrcweir                     long nSize = 0;
1000cdf0e10cSrcweir                     for( SCROW nDocRow = nFirstRealDocRow; nDocRow < nFirstDocRow; ++nDocRow )
1001cdf0e10cSrcweir                         nSize += std::max( static_cast< long >( GetRowHeight( nDocRow, nTab ) * nScaleY ), 1L );
1002cdf0e10cSrcweir                     rArray.SetAddMergedTopSize( nCol, nRow, nSize );
1003cdf0e10cSrcweir                 }
1004cdf0e10cSrcweir                 // additional space beyond last row
1005cdf0e10cSrcweir                 if( nLastRow + 1 == nRowCount )
1006cdf0e10cSrcweir                 {
1007cdf0e10cSrcweir                     long nSize = 0;
1008cdf0e10cSrcweir                     for( SCROW nDocRow = nLastDocRow + 1; nDocRow <= nLastRealDocRow; ++nDocRow )
1009cdf0e10cSrcweir                         nSize += std::max( static_cast< long >( GetRowHeight( nDocRow, nTab ) * nScaleY ), 1L );
1010cdf0e10cSrcweir                     rArray.SetAddMergedBottomSize( nCol, nRow, nSize );
1011cdf0e10cSrcweir                 }
1012cdf0e10cSrcweir 
1013cdf0e10cSrcweir                 // *** use line attributes from real origin cell ***
1014cdf0e10cSrcweir 
1015cdf0e10cSrcweir                 if( (nFirstRealDocCol != nCurrDocCol) || (nFirstRealDocRow != nCurrDocRow) )
1016cdf0e10cSrcweir                 {
1017cdf0e10cSrcweir                     if( const ScPatternAttr* pPattern = GetPattern( nFirstRealDocCol, nFirstRealDocRow, nTab ) )
1018cdf0e10cSrcweir                     {
1019cdf0e10cSrcweir                         const SfxItemSet* pCond = GetCondResult( nFirstRealDocCol, nFirstRealDocRow, nTab );
1020cdf0e10cSrcweir                         pBox = static_cast< const SvxBoxItem* >( &pPattern->GetItem( ATTR_BORDER, pCond ) );
1021cdf0e10cSrcweir                         pTLBR = static_cast< const SvxLineItem* >( &pPattern->GetItem( ATTR_BORDER_TLBR, pCond ) );
1022cdf0e10cSrcweir                         pBLTR = static_cast< const SvxLineItem* >( &pPattern->GetItem( ATTR_BORDER_BLTR, pCond ) );
1023cdf0e10cSrcweir                     }
1024cdf0e10cSrcweir                     else
1025cdf0e10cSrcweir                     {
1026cdf0e10cSrcweir                         pBox = 0;
1027cdf0e10cSrcweir                         pTLBR = pBLTR = 0;
1028cdf0e10cSrcweir                     }
1029cdf0e10cSrcweir                 }
1030cdf0e10cSrcweir             }
1031cdf0e10cSrcweir 
1032cdf0e10cSrcweir             // *** borders *** ------------------------------------------------
1033cdf0e10cSrcweir 
1034cdf0e10cSrcweir             if( pBox )
1035cdf0e10cSrcweir             {
1036cdf0e10cSrcweir                 rArray.SetCellStyleLeft(   nFirstCol, nFirstRow, svx::frame::Style( pBox->GetLeft(),   nScaleX ) );
1037cdf0e10cSrcweir                 rArray.SetCellStyleRight(  nFirstCol, nFirstRow, svx::frame::Style( pBox->GetRight(),  nScaleX ) );
1038cdf0e10cSrcweir                 rArray.SetCellStyleTop(    nFirstCol, nFirstRow, svx::frame::Style( pBox->GetTop(),    nScaleY ) );
1039cdf0e10cSrcweir                 rArray.SetCellStyleBottom( nFirstCol, nFirstRow, svx::frame::Style( pBox->GetBottom(), nScaleY ) );
1040cdf0e10cSrcweir             }
1041cdf0e10cSrcweir 
1042cdf0e10cSrcweir             if( pTLBR )
1043cdf0e10cSrcweir                 rArray.SetCellStyleTLBR( nFirstCol, nFirstRow, svx::frame::Style( pTLBR->GetLine(), nScaleY ) );
1044cdf0e10cSrcweir             if( rInfo.mpBLTRLine )
1045cdf0e10cSrcweir                 rArray.SetCellStyleBLTR( nFirstCol, nFirstRow, svx::frame::Style( pBLTR->GetLine(), nScaleY ) );
1046cdf0e10cSrcweir         }
1047cdf0e10cSrcweir     }
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir     /*  Mirror the entire frame array.
1050cdf0e10cSrcweir         1st param = Mirror the vertical double line styles as well.
1051cdf0e10cSrcweir         2nd param = Do not swap diagonal lines.
1052cdf0e10cSrcweir      */
1053cdf0e10cSrcweir     if( bLayoutRTL )
1054cdf0e10cSrcweir         rArray.MirrorSelfX( true, false );
1055cdf0e10cSrcweir }
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir // ============================================================================
1058cdf0e10cSrcweir 
ScTableInfo()1059cdf0e10cSrcweir ScTableInfo::ScTableInfo() :
1060cdf0e10cSrcweir     mpRowInfo( new RowInfo[ ROWINFO_MAX ] ),
1061cdf0e10cSrcweir     mbPageMode( false )
1062cdf0e10cSrcweir {
1063cdf0e10cSrcweir     for( sal_uInt16 nIdx = 0; nIdx < ROWINFO_MAX; ++nIdx )
1064cdf0e10cSrcweir         mpRowInfo[ nIdx ].pCellInfo = 0;
1065cdf0e10cSrcweir }
1066cdf0e10cSrcweir 
~ScTableInfo()1067cdf0e10cSrcweir ScTableInfo::~ScTableInfo()
1068cdf0e10cSrcweir {
1069cdf0e10cSrcweir     for( sal_uInt16 nIdx = 0; nIdx < ROWINFO_MAX; ++nIdx )
1070cdf0e10cSrcweir         delete [] mpRowInfo[ nIdx ].pCellInfo;
1071cdf0e10cSrcweir     delete [] mpRowInfo;
1072cdf0e10cSrcweir }
1073cdf0e10cSrcweir 
1074cdf0e10cSrcweir // ============================================================================
1075cdf0e10cSrcweir 
1076