xref: /aoo41x/main/sc/source/ui/view/prevloc.cxx (revision b3f79822)
1*b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b3f79822SAndrew Rist  * distributed with this work for additional information
6*b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9*b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b3f79822SAndrew Rist  *
11*b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b3f79822SAndrew Rist  *
13*b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15*b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b3f79822SAndrew Rist  * specific language governing permissions and limitations
18*b3f79822SAndrew Rist  * under the License.
19*b3f79822SAndrew Rist  *
20*b3f79822SAndrew Rist  *************************************************************/
21*b3f79822SAndrew Rist 
22*b3f79822SAndrew 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 <vcl/outdev.hxx>
32cdf0e10cSrcweir #include <tools/debug.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include "prevloc.hxx"
35cdf0e10cSrcweir #include "document.hxx"
36cdf0e10cSrcweir 
37cdf0e10cSrcweir //==================================================================
38cdf0e10cSrcweir 
39cdf0e10cSrcweir enum ScPreviewLocationType
40cdf0e10cSrcweir {
41cdf0e10cSrcweir 	SC_PLOC_CELLRANGE,
42cdf0e10cSrcweir 	SC_PLOC_COLHEADER,
43cdf0e10cSrcweir 	SC_PLOC_ROWHEADER,
44cdf0e10cSrcweir 	SC_PLOC_LEFTHEADER,
45cdf0e10cSrcweir 	SC_PLOC_RIGHTHEADER,
46cdf0e10cSrcweir 	SC_PLOC_LEFTFOOTER,
47cdf0e10cSrcweir 	SC_PLOC_RIGHTFOOTER,
48cdf0e10cSrcweir 	SC_PLOC_NOTEMARK,
49cdf0e10cSrcweir 	SC_PLOC_NOTETEXT
50cdf0e10cSrcweir };
51cdf0e10cSrcweir 
52cdf0e10cSrcweir struct ScPreviewLocationEntry
53cdf0e10cSrcweir {
54cdf0e10cSrcweir 	ScPreviewLocationType	eType;
55cdf0e10cSrcweir 	Rectangle				aPixelRect;
56cdf0e10cSrcweir 	ScRange					aCellRange;
57cdf0e10cSrcweir 	sal_Bool					bRepeatCol;
58cdf0e10cSrcweir 	sal_Bool					bRepeatRow;
59cdf0e10cSrcweir 
ScPreviewLocationEntryScPreviewLocationEntry60cdf0e10cSrcweir 	ScPreviewLocationEntry( ScPreviewLocationType eNewType, const Rectangle& rPixel, const ScRange& rRange,
61cdf0e10cSrcweir 							sal_Bool bRepCol, sal_Bool bRepRow ) :
62cdf0e10cSrcweir 		eType( eNewType ),
63cdf0e10cSrcweir 		aPixelRect( rPixel ),
64cdf0e10cSrcweir 		aCellRange( rRange ),
65cdf0e10cSrcweir 		bRepeatCol( bRepCol ),
66cdf0e10cSrcweir 		bRepeatRow( bRepRow )
67cdf0e10cSrcweir 	{
68cdf0e10cSrcweir 	}
69cdf0e10cSrcweir };
70cdf0e10cSrcweir 
71cdf0e10cSrcweir //==================================================================
72cdf0e10cSrcweir 
ScPreviewTableInfo()73cdf0e10cSrcweir ScPreviewTableInfo::ScPreviewTableInfo() :
74cdf0e10cSrcweir 	nTab(0),
75cdf0e10cSrcweir 	nCols(0),
76cdf0e10cSrcweir 	nRows(0),
77cdf0e10cSrcweir 	pColInfo(NULL),
78cdf0e10cSrcweir 	pRowInfo(NULL)
79cdf0e10cSrcweir {
80cdf0e10cSrcweir }
81cdf0e10cSrcweir 
~ScPreviewTableInfo()82cdf0e10cSrcweir ScPreviewTableInfo::~ScPreviewTableInfo()
83cdf0e10cSrcweir {
84cdf0e10cSrcweir 	delete[] pColInfo;
85cdf0e10cSrcweir 	delete[] pRowInfo;
86cdf0e10cSrcweir }
87cdf0e10cSrcweir 
SetTab(SCTAB nNewTab)88cdf0e10cSrcweir void ScPreviewTableInfo::SetTab( SCTAB nNewTab )
89cdf0e10cSrcweir {
90cdf0e10cSrcweir 	nTab = nNewTab;
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
SetColInfo(SCCOL nCount,ScPreviewColRowInfo * pNewInfo)93cdf0e10cSrcweir void ScPreviewTableInfo::SetColInfo( SCCOL nCount, ScPreviewColRowInfo* pNewInfo )
94cdf0e10cSrcweir {
95cdf0e10cSrcweir 	delete[] pColInfo;
96cdf0e10cSrcweir 	pColInfo = pNewInfo;
97cdf0e10cSrcweir 	nCols = nCount;
98cdf0e10cSrcweir }
99cdf0e10cSrcweir 
SetRowInfo(SCROW nCount,ScPreviewColRowInfo * pNewInfo)100cdf0e10cSrcweir void ScPreviewTableInfo::SetRowInfo( SCROW nCount, ScPreviewColRowInfo* pNewInfo )
101cdf0e10cSrcweir {
102cdf0e10cSrcweir 	delete[] pRowInfo;
103cdf0e10cSrcweir 	pRowInfo = pNewInfo;
104cdf0e10cSrcweir 	nRows = nCount;
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
LimitToArea(const Rectangle & rPixelArea)107cdf0e10cSrcweir void ScPreviewTableInfo::LimitToArea( const Rectangle& rPixelArea )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir 	if ( pColInfo )
110cdf0e10cSrcweir 	{
111cdf0e10cSrcweir 		//	cells completely left of the visible area
112cdf0e10cSrcweir 		SCCOL nStart = 0;
113cdf0e10cSrcweir 		while ( nStart < nCols && pColInfo[nStart].nPixelEnd < rPixelArea.Left() )
114cdf0e10cSrcweir 			++nStart;
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 		//	cells completely right of the visible area
117cdf0e10cSrcweir 		SCCOL nEnd = nCols;
118cdf0e10cSrcweir 		while ( nEnd > 0 && pColInfo[nEnd-1].nPixelStart > rPixelArea.Right() )
119cdf0e10cSrcweir 			--nEnd;
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 		if ( nStart > 0 || nEnd < nCols )
122cdf0e10cSrcweir 		{
123cdf0e10cSrcweir 			if ( nEnd > nStart )
124cdf0e10cSrcweir 			{
125cdf0e10cSrcweir 				SCCOL nNewCount = nEnd - nStart;
126cdf0e10cSrcweir 				ScPreviewColRowInfo* pNewInfo = new ScPreviewColRowInfo[nNewCount];
127cdf0e10cSrcweir 				for (SCCOL i=0; i<nNewCount; i++)
128cdf0e10cSrcweir 					pNewInfo[i] = pColInfo[nStart + i];
129cdf0e10cSrcweir 				SetColInfo( nNewCount, pNewInfo );
130cdf0e10cSrcweir 			}
131cdf0e10cSrcweir 			else
132cdf0e10cSrcweir 				SetColInfo( 0, NULL );		// all invisible
133cdf0e10cSrcweir 		}
134cdf0e10cSrcweir 	}
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 	if ( pRowInfo )
137cdf0e10cSrcweir 	{
138cdf0e10cSrcweir 		//	cells completely above the visible area
139cdf0e10cSrcweir 		SCROW nStart = 0;
140cdf0e10cSrcweir 		while ( nStart < nRows && pRowInfo[nStart].nPixelEnd < rPixelArea.Top() )
141cdf0e10cSrcweir 			++nStart;
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 		//	cells completely below the visible area
144cdf0e10cSrcweir 		SCROW nEnd = nRows;
145cdf0e10cSrcweir 		while ( nEnd > 0 && pRowInfo[nEnd-1].nPixelStart > rPixelArea.Bottom() )
146cdf0e10cSrcweir 			--nEnd;
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 		if ( nStart > 0 || nEnd < nRows )
149cdf0e10cSrcweir 		{
150cdf0e10cSrcweir 			if ( nEnd > nStart )
151cdf0e10cSrcweir 			{
152cdf0e10cSrcweir 				SCROW nNewCount = nEnd - nStart;
153cdf0e10cSrcweir 				ScPreviewColRowInfo* pNewInfo = new ScPreviewColRowInfo[nNewCount];
154cdf0e10cSrcweir 				for (SCROW i=0; i<nNewCount; i++)
155cdf0e10cSrcweir 					pNewInfo[i] = pRowInfo[nStart + i];
156cdf0e10cSrcweir 				SetRowInfo( nNewCount, pNewInfo );
157cdf0e10cSrcweir 			}
158cdf0e10cSrcweir 			else
159cdf0e10cSrcweir 				SetRowInfo( 0, NULL );		// all invisible
160cdf0e10cSrcweir 		}
161cdf0e10cSrcweir 	}
162cdf0e10cSrcweir }
163cdf0e10cSrcweir 
164cdf0e10cSrcweir //------------------------------------------------------------------
165cdf0e10cSrcweir 
ScPreviewLocationData(ScDocument * pDocument,OutputDevice * pWin)166cdf0e10cSrcweir ScPreviewLocationData::ScPreviewLocationData( ScDocument* pDocument, OutputDevice* pWin ) :
167cdf0e10cSrcweir 	pWindow( pWin ),
168cdf0e10cSrcweir 	pDoc( pDocument ),
169cdf0e10cSrcweir 	nDrawRanges( 0 ),
170cdf0e10cSrcweir 	nPrintTab( 0 )
171cdf0e10cSrcweir {
172cdf0e10cSrcweir }
173cdf0e10cSrcweir 
~ScPreviewLocationData()174cdf0e10cSrcweir ScPreviewLocationData::~ScPreviewLocationData()
175cdf0e10cSrcweir {
176cdf0e10cSrcweir 	Clear();
177cdf0e10cSrcweir }
178cdf0e10cSrcweir 
SetCellMapMode(const MapMode & rMapMode)179cdf0e10cSrcweir void ScPreviewLocationData::SetCellMapMode( const MapMode& rMapMode )
180cdf0e10cSrcweir {
181cdf0e10cSrcweir 	aCellMapMode = rMapMode;
182cdf0e10cSrcweir }
183cdf0e10cSrcweir 
SetPrintTab(SCTAB nNew)184cdf0e10cSrcweir void ScPreviewLocationData::SetPrintTab( SCTAB nNew )
185cdf0e10cSrcweir {
186cdf0e10cSrcweir 	nPrintTab = nNew;
187cdf0e10cSrcweir }
188cdf0e10cSrcweir 
Clear()189cdf0e10cSrcweir void ScPreviewLocationData::Clear()
190cdf0e10cSrcweir {
191cdf0e10cSrcweir 	void* pEntry = aEntries.First();
192cdf0e10cSrcweir 	while ( pEntry )
193cdf0e10cSrcweir 	{
194cdf0e10cSrcweir 		delete (ScPreviewLocationEntry*) pEntry;
195cdf0e10cSrcweir 		pEntry = aEntries.Next();
196cdf0e10cSrcweir 	}
197cdf0e10cSrcweir 	aEntries.Clear();
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 	nDrawRanges = 0;
200cdf0e10cSrcweir }
201cdf0e10cSrcweir 
AddCellRange(const Rectangle & rRect,const ScRange & rRange,sal_Bool bRepCol,sal_Bool bRepRow,const MapMode & rDrawMap)202cdf0e10cSrcweir void ScPreviewLocationData::AddCellRange( const Rectangle& rRect, const ScRange& rRange, sal_Bool bRepCol, sal_Bool bRepRow,
203cdf0e10cSrcweir 											const MapMode& rDrawMap )
204cdf0e10cSrcweir {
205cdf0e10cSrcweir 	Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
206cdf0e10cSrcweir 	aEntries.Insert( new ScPreviewLocationEntry( SC_PLOC_CELLRANGE, aPixelRect, rRange, bRepCol, bRepRow ) );
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 	DBG_ASSERT( nDrawRanges < SC_PREVIEW_MAXRANGES, "too many ranges" );
209cdf0e10cSrcweir 	if ( nDrawRanges < SC_PREVIEW_MAXRANGES )
210cdf0e10cSrcweir 	{
211cdf0e10cSrcweir 		aDrawRectangle[nDrawRanges] = aPixelRect;
212cdf0e10cSrcweir 		aDrawMapMode[nDrawRanges] = rDrawMap;
213cdf0e10cSrcweir 	        if (bRepCol)
214cdf0e10cSrcweir         	    if (bRepRow)
215cdf0e10cSrcweir                 	aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_EDGE;
216cdf0e10cSrcweir 	            else
217cdf0e10cSrcweir         	        aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_REPCOL;
218cdf0e10cSrcweir 	        else
219cdf0e10cSrcweir         	    if (bRepRow)
220cdf0e10cSrcweir                 	aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_REPROW;
221cdf0e10cSrcweir 	            else
222cdf0e10cSrcweir         	        aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_TAB;
223cdf0e10cSrcweir 		++nDrawRanges;
224cdf0e10cSrcweir 	}
225cdf0e10cSrcweir }
226cdf0e10cSrcweir 
AddColHeaders(const Rectangle & rRect,SCCOL nStartCol,SCCOL nEndCol,sal_Bool bRepCol)227cdf0e10cSrcweir void ScPreviewLocationData::AddColHeaders( const Rectangle& rRect, SCCOL nStartCol, SCCOL nEndCol, sal_Bool bRepCol )
228cdf0e10cSrcweir {
229cdf0e10cSrcweir 	SCTAB nTab = 0;	//! ?
230cdf0e10cSrcweir 	ScRange aRange( nStartCol, 0, nTab, nEndCol, 0, nTab );
231cdf0e10cSrcweir 	Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
232cdf0e10cSrcweir 	aEntries.Insert( new ScPreviewLocationEntry( SC_PLOC_COLHEADER, aPixelRect, aRange, bRepCol, sal_False ) );
233cdf0e10cSrcweir }
234cdf0e10cSrcweir 
AddRowHeaders(const Rectangle & rRect,SCROW nStartRow,SCROW nEndRow,sal_Bool bRepRow)235cdf0e10cSrcweir void ScPreviewLocationData::AddRowHeaders( const Rectangle& rRect, SCROW nStartRow, SCROW nEndRow, sal_Bool bRepRow )
236cdf0e10cSrcweir {
237cdf0e10cSrcweir 	SCTAB nTab = 0;	//! ?
238cdf0e10cSrcweir 	ScRange aRange( 0, nStartRow, nTab, 0, nEndRow, nTab );
239cdf0e10cSrcweir 	Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
240cdf0e10cSrcweir 	aEntries.Insert( new ScPreviewLocationEntry( SC_PLOC_ROWHEADER, aPixelRect, aRange, sal_False, bRepRow ) );
241cdf0e10cSrcweir }
242cdf0e10cSrcweir 
AddHeaderFooter(const Rectangle & rRect,sal_Bool bHeader,sal_Bool bLeft)243cdf0e10cSrcweir void ScPreviewLocationData::AddHeaderFooter( const Rectangle& rRect, sal_Bool bHeader, sal_Bool bLeft )
244cdf0e10cSrcweir {
245cdf0e10cSrcweir 	ScRange aRange;		//! ?
246cdf0e10cSrcweir 	Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 	ScPreviewLocationType eType = bHeader ?
249cdf0e10cSrcweir 				( bLeft ? SC_PLOC_LEFTHEADER : SC_PLOC_RIGHTHEADER ) :
250cdf0e10cSrcweir 				( bLeft ? SC_PLOC_LEFTFOOTER : SC_PLOC_RIGHTFOOTER );
251cdf0e10cSrcweir 	aEntries.Insert( new ScPreviewLocationEntry( eType, aPixelRect, aRange, sal_False, sal_False ) );
252cdf0e10cSrcweir }
253cdf0e10cSrcweir 
AddNoteMark(const Rectangle & rRect,const ScAddress & rPos)254cdf0e10cSrcweir void ScPreviewLocationData::AddNoteMark( const Rectangle& rRect, const ScAddress& rPos )
255cdf0e10cSrcweir {
256cdf0e10cSrcweir 	ScRange aRange( rPos );
257cdf0e10cSrcweir 	Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
258cdf0e10cSrcweir 	aEntries.Insert( new ScPreviewLocationEntry( SC_PLOC_NOTEMARK, aPixelRect, aRange, sal_False, sal_False ) );
259cdf0e10cSrcweir }
260cdf0e10cSrcweir 
AddNoteText(const Rectangle & rRect,const ScAddress & rPos)261cdf0e10cSrcweir void ScPreviewLocationData::AddNoteText( const Rectangle& rRect, const ScAddress& rPos )
262cdf0e10cSrcweir {
263cdf0e10cSrcweir 	ScRange aRange( rPos );
264cdf0e10cSrcweir 	Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
265cdf0e10cSrcweir 	aEntries.Insert( new ScPreviewLocationEntry( SC_PLOC_NOTETEXT, aPixelRect, aRange, sal_False, sal_False ) );
266cdf0e10cSrcweir }
267cdf0e10cSrcweir 
268cdf0e10cSrcweir //------------------------------------------------------------------
269cdf0e10cSrcweir 
GetDrawRange(sal_uInt16 nPos,Rectangle & rPixelRect,MapMode & rMapMode,sal_uInt8 & rRangeId) const270cdf0e10cSrcweir void ScPreviewLocationData::GetDrawRange( sal_uInt16 nPos, Rectangle& rPixelRect, MapMode& rMapMode, sal_uInt8& rRangeId ) const
271cdf0e10cSrcweir {
272cdf0e10cSrcweir 	DBG_ASSERT( nPos < nDrawRanges, "wrong position" );
273cdf0e10cSrcweir 	if ( nPos < nDrawRanges )
274cdf0e10cSrcweir 	{
275cdf0e10cSrcweir 		rPixelRect = aDrawRectangle[nPos];
276cdf0e10cSrcweir 		rMapMode = aDrawMapMode[nPos];
277cdf0e10cSrcweir         rRangeId = aDrawRangeId[nPos];
278cdf0e10cSrcweir 	}
279cdf0e10cSrcweir }
280cdf0e10cSrcweir 
lcl_GetEntryByAddress(const List & rEntries,const ScAddress & rPos,ScPreviewLocationType eType)281cdf0e10cSrcweir ScPreviewLocationEntry* lcl_GetEntryByAddress( const List& rEntries, const ScAddress& rPos, ScPreviewLocationType eType )
282cdf0e10cSrcweir {
283cdf0e10cSrcweir 	sal_uLong nCount = rEntries.Count();
284cdf0e10cSrcweir 	for (sal_uLong nListPos=0; nListPos<nCount; nListPos++)
285cdf0e10cSrcweir 	{
286cdf0e10cSrcweir 		ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)rEntries.GetObject(nListPos);
287cdf0e10cSrcweir 		if ( pEntry->eType == eType && pEntry->aCellRange.In( rPos ) )
288cdf0e10cSrcweir 			return pEntry;
289cdf0e10cSrcweir 	}
290cdf0e10cSrcweir 	return NULL;
291cdf0e10cSrcweir }
292cdf0e10cSrcweir 
293cdf0e10cSrcweir //UNUSED2008-05  ScAddress ScPreviewLocationData::GetCellFromRange( const Size& rOffsetPixel, const ScRange& rRange ) const
294cdf0e10cSrcweir //UNUSED2008-05  {
295cdf0e10cSrcweir //UNUSED2008-05      const double nScaleX = HMM_PER_TWIPS;
296cdf0e10cSrcweir //UNUSED2008-05      const double nScaleY = HMM_PER_TWIPS;
297cdf0e10cSrcweir //UNUSED2008-05
298cdf0e10cSrcweir //UNUSED2008-05      Size aOffsetLogic = pWindow->PixelToLogic( rOffsetPixel, aCellMapMode );
299cdf0e10cSrcweir //UNUSED2008-05      SCTAB nTab = rRange.aStart.Tab();
300cdf0e10cSrcweir //UNUSED2008-05
301cdf0e10cSrcweir //UNUSED2008-05      long nPosX = 0;
302cdf0e10cSrcweir //UNUSED2008-05      SCCOL nCol = rRange.aStart.Col();
303cdf0e10cSrcweir //UNUSED2008-05      SCCOL nEndCol = rRange.aEnd.Col();
304cdf0e10cSrcweir //UNUSED2008-05      while ( nCol <= nEndCol && nPosX < aOffsetLogic.Width() )
305cdf0e10cSrcweir //UNUSED2008-05      {
306cdf0e10cSrcweir //UNUSED2008-05          sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
307cdf0e10cSrcweir //UNUSED2008-05          if (nDocW)
308cdf0e10cSrcweir //UNUSED2008-05              nPosX += (long) (nDocW * nScaleX);
309cdf0e10cSrcweir //UNUSED2008-05          ++nCol;
310cdf0e10cSrcweir //UNUSED2008-05      }
311cdf0e10cSrcweir //UNUSED2008-05      if ( nCol > rRange.aStart.Col() )
312cdf0e10cSrcweir //UNUSED2008-05          --nCol;
313cdf0e10cSrcweir //UNUSED2008-05
314cdf0e10cSrcweir //UNUSED2008-05      long nPosY = 0;
315cdf0e10cSrcweir //UNUSED2008-05      ScCoupledCompressedArrayIterator< SCROW, sal_uInt8, sal_uInt16> aIter(
316cdf0e10cSrcweir //UNUSED2008-05              pDoc->GetRowFlagsArray( nTab), rRange.aStart.Row(),
317cdf0e10cSrcweir //UNUSED2008-05              rRange.aEnd.Row(), CR_HIDDEN, 0, pDoc->GetRowHeightArray( nTab));
318cdf0e10cSrcweir //UNUSED2008-05      while ( aIter && nPosY < aOffsetLogic.Height() )
319cdf0e10cSrcweir //UNUSED2008-05      {
320cdf0e10cSrcweir //UNUSED2008-05          sal_uInt16 nDocH = *aIter;
321cdf0e10cSrcweir //UNUSED2008-05          if (nDocH)
322cdf0e10cSrcweir //UNUSED2008-05              nPosY += (long) (nDocH * nScaleY);
323cdf0e10cSrcweir //UNUSED2008-05          ++aIter;
324cdf0e10cSrcweir //UNUSED2008-05      }
325cdf0e10cSrcweir //UNUSED2008-05      SCROW nRow = aIter.GetPos();
326cdf0e10cSrcweir //UNUSED2008-05      if ( nRow > rRange.aStart.Row() )
327cdf0e10cSrcweir //UNUSED2008-05          --nRow;
328cdf0e10cSrcweir //UNUSED2008-05
329cdf0e10cSrcweir //UNUSED2008-05      return ScAddress( nCol, nRow, nTab );
330cdf0e10cSrcweir //UNUSED2008-05  }
331cdf0e10cSrcweir 
GetOffsetPixel(const ScAddress & rCellPos,const ScRange & rRange) const332cdf0e10cSrcweir Rectangle ScPreviewLocationData::GetOffsetPixel( const ScAddress& rCellPos, const ScRange& rRange ) const
333cdf0e10cSrcweir {
334cdf0e10cSrcweir 	const double nScaleX = HMM_PER_TWIPS;
335cdf0e10cSrcweir 	const double nScaleY = HMM_PER_TWIPS;
336cdf0e10cSrcweir 	SCTAB nTab = rRange.aStart.Tab();
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 	long nPosX = 0;
339cdf0e10cSrcweir 	SCCOL nEndCol = rCellPos.Col();
340cdf0e10cSrcweir 	for (SCCOL nCol = rRange.aStart.Col(); nCol < nEndCol; nCol++)
341cdf0e10cSrcweir 	{
342cdf0e10cSrcweir 		sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
343cdf0e10cSrcweir 		if (nDocW)
344cdf0e10cSrcweir 			nPosX += (long) (nDocW * nScaleX);
345cdf0e10cSrcweir 	}
346cdf0e10cSrcweir 	long nSizeX = (long) ( pDoc->GetColWidth( nEndCol, nTab ) * nScaleX );
347cdf0e10cSrcweir 
348cdf0e10cSrcweir 	SCROW nEndRow = rCellPos.Row();
349cdf0e10cSrcweir     long nPosY = (long) pDoc->GetScaledRowHeight( rRange.aStart.Row(),
350cdf0e10cSrcweir             nEndRow, nTab, nScaleY);
351cdf0e10cSrcweir 	long nSizeY = (long) ( pDoc->GetRowHeight( nEndRow, nTab ) * nScaleY );
352cdf0e10cSrcweir 
353cdf0e10cSrcweir 	Size aOffsetLogic( nPosX, nPosY );
354cdf0e10cSrcweir 	Size aSizeLogic( nSizeX, nSizeY );
355cdf0e10cSrcweir 	Size aOffsetPixel = pWindow->LogicToPixel( aOffsetLogic, aCellMapMode );
356cdf0e10cSrcweir 	Size aSizePixel = pWindow->LogicToPixel( aSizeLogic, aCellMapMode );
357cdf0e10cSrcweir 
358cdf0e10cSrcweir 	return Rectangle( Point( aOffsetPixel.Width(), aOffsetPixel.Height() ), aSizePixel );
359cdf0e10cSrcweir }
360cdf0e10cSrcweir 
GetCellPosition(const ScAddress & rCellPos,Rectangle & rCellRect) const361cdf0e10cSrcweir sal_Bool ScPreviewLocationData::GetCellPosition( const ScAddress& rCellPos, Rectangle& rCellRect ) const
362cdf0e10cSrcweir {
363cdf0e10cSrcweir 	ScPreviewLocationEntry* pEntry = lcl_GetEntryByAddress( aEntries, rCellPos, SC_PLOC_CELLRANGE );
364cdf0e10cSrcweir 	if ( pEntry )
365cdf0e10cSrcweir 	{
366cdf0e10cSrcweir 		Rectangle aOffsetRect = GetOffsetPixel( rCellPos, pEntry->aCellRange );
367cdf0e10cSrcweir 		rCellRect = Rectangle( aOffsetRect.Left() + pEntry->aPixelRect.Left(),
368cdf0e10cSrcweir 							   aOffsetRect.Top() + pEntry->aPixelRect.Top(),
369cdf0e10cSrcweir 							   aOffsetRect.Right() + pEntry->aPixelRect.Left(),
370cdf0e10cSrcweir 							   aOffsetRect.Bottom() + pEntry->aPixelRect.Top() );
371cdf0e10cSrcweir 		return sal_True;
372cdf0e10cSrcweir 	}
373cdf0e10cSrcweir 	return sal_False;
374cdf0e10cSrcweir }
375cdf0e10cSrcweir 
HasCellsInRange(const Rectangle & rVisiblePixel) const376cdf0e10cSrcweir sal_Bool ScPreviewLocationData::HasCellsInRange( const Rectangle& rVisiblePixel ) const
377cdf0e10cSrcweir {
378cdf0e10cSrcweir 	sal_uLong nCount = aEntries.Count();
379cdf0e10cSrcweir 	for (sal_uLong nListPos=0; nListPos<nCount; nListPos++)
380cdf0e10cSrcweir 	{
381cdf0e10cSrcweir 		ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
382cdf0e10cSrcweir 		ScPreviewLocationType eType = pEntry->eType;
383cdf0e10cSrcweir 		if ( eType == SC_PLOC_CELLRANGE || eType == SC_PLOC_COLHEADER || eType == SC_PLOC_ROWHEADER )
384cdf0e10cSrcweir 			if ( pEntry->aPixelRect.IsOver( rVisiblePixel ) )
385cdf0e10cSrcweir 				return sal_True;
386cdf0e10cSrcweir 	}
387cdf0e10cSrcweir 	return sal_False;
388cdf0e10cSrcweir }
389cdf0e10cSrcweir 
GetHeaderPosition(Rectangle & rRect) const390cdf0e10cSrcweir sal_Bool ScPreviewLocationData::GetHeaderPosition( Rectangle& rRect ) const
391cdf0e10cSrcweir {
392cdf0e10cSrcweir 	sal_uLong nCount = aEntries.Count();
393cdf0e10cSrcweir 	for (sal_uLong nListPos=0; nListPos<nCount; nListPos++)
394cdf0e10cSrcweir 	{
395cdf0e10cSrcweir 		ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
396cdf0e10cSrcweir 		if ( pEntry->eType == SC_PLOC_LEFTHEADER || pEntry->eType == SC_PLOC_RIGHTHEADER )
397cdf0e10cSrcweir 		{
398cdf0e10cSrcweir 			rRect = pEntry->aPixelRect;
399cdf0e10cSrcweir 			return sal_True;
400cdf0e10cSrcweir 		}
401cdf0e10cSrcweir 	}
402cdf0e10cSrcweir 	return sal_False;
403cdf0e10cSrcweir }
404cdf0e10cSrcweir 
GetFooterPosition(Rectangle & rRect) const405cdf0e10cSrcweir sal_Bool ScPreviewLocationData::GetFooterPosition( Rectangle& rRect ) const
406cdf0e10cSrcweir {
407cdf0e10cSrcweir 	sal_uLong nCount = aEntries.Count();
408cdf0e10cSrcweir 	for (sal_uLong nListPos=0; nListPos<nCount; nListPos++)
409cdf0e10cSrcweir 	{
410cdf0e10cSrcweir 		ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
411cdf0e10cSrcweir 		if ( pEntry->eType == SC_PLOC_LEFTFOOTER || pEntry->eType == SC_PLOC_RIGHTFOOTER )
412cdf0e10cSrcweir 		{
413cdf0e10cSrcweir 			rRect = pEntry->aPixelRect;
414cdf0e10cSrcweir 			return sal_True;
415cdf0e10cSrcweir 		}
416cdf0e10cSrcweir 	}
417cdf0e10cSrcweir 	return sal_False;
418cdf0e10cSrcweir }
419cdf0e10cSrcweir 
IsHeaderLeft() const420cdf0e10cSrcweir sal_Bool ScPreviewLocationData::IsHeaderLeft() const
421cdf0e10cSrcweir {
422cdf0e10cSrcweir 	sal_uLong nCount = aEntries.Count();
423cdf0e10cSrcweir 	for (sal_uLong nListPos=0; nListPos<nCount; nListPos++)
424cdf0e10cSrcweir 	{
425cdf0e10cSrcweir 		ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
426cdf0e10cSrcweir 		if ( pEntry->eType == SC_PLOC_LEFTHEADER )
427cdf0e10cSrcweir 			return sal_True;
428cdf0e10cSrcweir 		if ( pEntry->eType == SC_PLOC_RIGHTHEADER )
429cdf0e10cSrcweir 			return sal_False;
430cdf0e10cSrcweir 	}
431cdf0e10cSrcweir 	return sal_False;
432cdf0e10cSrcweir }
433cdf0e10cSrcweir 
IsFooterLeft() const434cdf0e10cSrcweir sal_Bool ScPreviewLocationData::IsFooterLeft() const
435cdf0e10cSrcweir {
436cdf0e10cSrcweir 	sal_uLong nCount = aEntries.Count();
437cdf0e10cSrcweir 	for (sal_uLong nListPos=0; nListPos<nCount; nListPos++)
438cdf0e10cSrcweir 	{
439cdf0e10cSrcweir 		ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
440cdf0e10cSrcweir 		if ( pEntry->eType == SC_PLOC_LEFTFOOTER )
441cdf0e10cSrcweir 			return sal_True;
442cdf0e10cSrcweir 		if ( pEntry->eType == SC_PLOC_RIGHTFOOTER )
443cdf0e10cSrcweir 			return sal_False;
444cdf0e10cSrcweir 	}
445cdf0e10cSrcweir 	return sal_False;
446cdf0e10cSrcweir }
447cdf0e10cSrcweir 
GetNoteCountInRange(const Rectangle & rVisiblePixel,sal_Bool bNoteMarks) const448cdf0e10cSrcweir long ScPreviewLocationData::GetNoteCountInRange( const Rectangle& rVisiblePixel, sal_Bool bNoteMarks ) const
449cdf0e10cSrcweir {
450cdf0e10cSrcweir 	ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
451cdf0e10cSrcweir 
452cdf0e10cSrcweir 	sal_uLong nRet = 0;
453cdf0e10cSrcweir 	sal_uLong nCount = aEntries.Count();
454cdf0e10cSrcweir 	for (sal_uLong nListPos=0; nListPos<nCount; nListPos++)
455cdf0e10cSrcweir 	{
456cdf0e10cSrcweir 		ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
457cdf0e10cSrcweir 		if ( pEntry->eType == eType && pEntry->aPixelRect.IsOver( rVisiblePixel ) )
458cdf0e10cSrcweir 			++nRet;
459cdf0e10cSrcweir 	}
460cdf0e10cSrcweir 	return nRet;
461cdf0e10cSrcweir }
462cdf0e10cSrcweir 
GetNoteInRange(const Rectangle & rVisiblePixel,long nIndex,sal_Bool bNoteMarks,ScAddress & rCellPos,Rectangle & rNoteRect) const463cdf0e10cSrcweir sal_Bool ScPreviewLocationData::GetNoteInRange( const Rectangle& rVisiblePixel, long nIndex, sal_Bool bNoteMarks,
464cdf0e10cSrcweir 											ScAddress& rCellPos, Rectangle& rNoteRect ) const
465cdf0e10cSrcweir {
466cdf0e10cSrcweir 	ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
467cdf0e10cSrcweir 
468cdf0e10cSrcweir 	sal_uLong nPos = 0;
469cdf0e10cSrcweir 	sal_uLong nCount = aEntries.Count();
470cdf0e10cSrcweir 	for (sal_uLong nListPos=0; nListPos<nCount; nListPos++)
471cdf0e10cSrcweir 	{
472cdf0e10cSrcweir 		ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
473cdf0e10cSrcweir 		if ( pEntry->eType == eType && pEntry->aPixelRect.IsOver( rVisiblePixel ) )
474cdf0e10cSrcweir 		{
475cdf0e10cSrcweir             if ( nPos == sal::static_int_cast<sal_uLong>(nIndex) )
476cdf0e10cSrcweir 			{
477cdf0e10cSrcweir 				rCellPos = pEntry->aCellRange.aStart;
478cdf0e10cSrcweir 				rNoteRect = pEntry->aPixelRect;
479cdf0e10cSrcweir 				return sal_True;
480cdf0e10cSrcweir 			}
481cdf0e10cSrcweir 			++nPos;
482cdf0e10cSrcweir 		}
483cdf0e10cSrcweir 	}
484cdf0e10cSrcweir 	return sal_False;
485cdf0e10cSrcweir }
486cdf0e10cSrcweir 
GetNoteInRangeOutputRect(const Rectangle & rVisiblePixel,sal_Bool bNoteMarks,const ScAddress & aCellPos) const487cdf0e10cSrcweir Rectangle ScPreviewLocationData::GetNoteInRangeOutputRect(const Rectangle& rVisiblePixel, sal_Bool bNoteMarks, const ScAddress& aCellPos) const
488cdf0e10cSrcweir {
489cdf0e10cSrcweir 	ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
490cdf0e10cSrcweir 
491cdf0e10cSrcweir 	sal_uLong nPos = 0;
492cdf0e10cSrcweir 	sal_uLong nCount = aEntries.Count();
493cdf0e10cSrcweir 	for (sal_uLong nListPos=0; nListPos<nCount; nListPos++)
494cdf0e10cSrcweir 	{
495cdf0e10cSrcweir 		ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
496cdf0e10cSrcweir 		if ( pEntry->eType == eType && pEntry->aPixelRect.IsOver( rVisiblePixel ) )
497cdf0e10cSrcweir 		{
498cdf0e10cSrcweir 			if ( aCellPos == pEntry->aCellRange.aStart )
499cdf0e10cSrcweir 				return pEntry->aPixelRect;
500cdf0e10cSrcweir 			++nPos;
501cdf0e10cSrcweir 		}
502cdf0e10cSrcweir 	}
503cdf0e10cSrcweir 	return Rectangle();
504cdf0e10cSrcweir }
505cdf0e10cSrcweir 
GetTableInfo(const Rectangle & rVisiblePixel,ScPreviewTableInfo & rInfo) const506cdf0e10cSrcweir void ScPreviewLocationData::GetTableInfo( const Rectangle& rVisiblePixel, ScPreviewTableInfo& rInfo ) const
507cdf0e10cSrcweir {
508cdf0e10cSrcweir 	const double nScaleX = HMM_PER_TWIPS;
509cdf0e10cSrcweir 	const double nScaleY = HMM_PER_TWIPS;
510cdf0e10cSrcweir 
511cdf0e10cSrcweir 	// from left to right:
512cdf0e10cSrcweir 	sal_Bool bHasHeaderCol = sal_False;
513cdf0e10cSrcweir 	sal_Bool bHasRepCols   = sal_False;
514cdf0e10cSrcweir 	sal_Bool bHasMainCols  = sal_False;
515cdf0e10cSrcweir 	SCCOL nRepeatColStart = 0;
516cdf0e10cSrcweir 	SCCOL nRepeatColEnd   = 0;
517cdf0e10cSrcweir 	SCCOL nMainColStart   = 0;
518cdf0e10cSrcweir 	SCCOL nMainColEnd     = 0;
519cdf0e10cSrcweir 
520cdf0e10cSrcweir 	// from top to bottom:
521cdf0e10cSrcweir 	sal_Bool bHasHeaderRow = sal_False;
522cdf0e10cSrcweir 	sal_Bool bHasRepRows   = sal_False;
523cdf0e10cSrcweir 	sal_Bool bHasMainRows  = sal_False;
524cdf0e10cSrcweir 	SCROW nRepeatRowStart = 0;
525cdf0e10cSrcweir 	SCROW nRepeatRowEnd   = 0;
526cdf0e10cSrcweir 	SCROW nMainRowStart   = 0;
527cdf0e10cSrcweir 	SCROW nMainRowEnd     = 0;
528cdf0e10cSrcweir 
529cdf0e10cSrcweir 	Rectangle aHeaderRect, aRepeatRect, aMainRect;
530cdf0e10cSrcweir 	SCTAB nTab = 0;
531cdf0e10cSrcweir 
532cdf0e10cSrcweir 	sal_uLong nCount = aEntries.Count();
533cdf0e10cSrcweir 	for (sal_uLong nListPos=0; nListPos<nCount; nListPos++)
534cdf0e10cSrcweir 	{
535cdf0e10cSrcweir 		ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
536cdf0e10cSrcweir 		if ( pEntry->eType == SC_PLOC_CELLRANGE )
537cdf0e10cSrcweir 		{
538cdf0e10cSrcweir 			if ( pEntry->bRepeatCol )
539cdf0e10cSrcweir 			{
540cdf0e10cSrcweir 				bHasRepCols = sal_True;
541cdf0e10cSrcweir 				nRepeatColStart = pEntry->aCellRange.aStart.Col();
542cdf0e10cSrcweir 				nRepeatColEnd = pEntry->aCellRange.aEnd.Col();
543cdf0e10cSrcweir 				aRepeatRect.Left() = pEntry->aPixelRect.Left();
544cdf0e10cSrcweir 				aRepeatRect.Right() = pEntry->aPixelRect.Right();
545cdf0e10cSrcweir 			}
546cdf0e10cSrcweir 			else
547cdf0e10cSrcweir 			{
548cdf0e10cSrcweir 				bHasMainCols = sal_True;
549cdf0e10cSrcweir 				nMainColStart = pEntry->aCellRange.aStart.Col();
550cdf0e10cSrcweir 				nMainColEnd = pEntry->aCellRange.aEnd.Col();
551cdf0e10cSrcweir 				aMainRect.Left() = pEntry->aPixelRect.Left();
552cdf0e10cSrcweir 				aMainRect.Right() = pEntry->aPixelRect.Right();
553cdf0e10cSrcweir 			}
554cdf0e10cSrcweir 			if ( pEntry->bRepeatRow )
555cdf0e10cSrcweir 			{
556cdf0e10cSrcweir 				bHasRepRows = sal_True;
557cdf0e10cSrcweir 				nRepeatRowStart = pEntry->aCellRange.aStart.Row();
558cdf0e10cSrcweir 				nRepeatRowEnd = pEntry->aCellRange.aEnd.Row();
559cdf0e10cSrcweir 				aRepeatRect.Top() = pEntry->aPixelRect.Top();
560cdf0e10cSrcweir 				aRepeatRect.Bottom() = pEntry->aPixelRect.Bottom();
561cdf0e10cSrcweir 			}
562cdf0e10cSrcweir 			else
563cdf0e10cSrcweir 			{
564cdf0e10cSrcweir 				bHasMainRows = sal_True;
565cdf0e10cSrcweir 				nMainRowStart = pEntry->aCellRange.aStart.Row();
566cdf0e10cSrcweir 				nMainRowEnd = pEntry->aCellRange.aEnd.Row();
567cdf0e10cSrcweir 				aMainRect.Top() = pEntry->aPixelRect.Top();
568cdf0e10cSrcweir 				aMainRect.Bottom() = pEntry->aPixelRect.Bottom();
569cdf0e10cSrcweir 			}
570cdf0e10cSrcweir 			nTab = pEntry->aCellRange.aStart.Tab();		//! store separately?
571cdf0e10cSrcweir 		}
572cdf0e10cSrcweir 		else if ( pEntry->eType == SC_PLOC_ROWHEADER )
573cdf0e10cSrcweir 		{
574cdf0e10cSrcweir 			// row headers result in an additional column
575cdf0e10cSrcweir 			bHasHeaderCol = sal_True;
576cdf0e10cSrcweir 			aHeaderRect.Left() = pEntry->aPixelRect.Left();
577cdf0e10cSrcweir 			aHeaderRect.Right() = pEntry->aPixelRect.Right();
578cdf0e10cSrcweir 		}
579cdf0e10cSrcweir 		else if ( pEntry->eType == SC_PLOC_COLHEADER )
580cdf0e10cSrcweir 		{
581cdf0e10cSrcweir 			// column headers result in an additional row
582cdf0e10cSrcweir 			bHasHeaderRow = sal_True;
583cdf0e10cSrcweir 			aHeaderRect.Top() = pEntry->aPixelRect.Top();
584cdf0e10cSrcweir 			aHeaderRect.Bottom() = pEntry->aPixelRect.Bottom();
585cdf0e10cSrcweir 		}
586cdf0e10cSrcweir 	}
587cdf0e10cSrcweir 
588cdf0e10cSrcweir 	//
589cdf0e10cSrcweir 	//	get column info
590cdf0e10cSrcweir 	//
591cdf0e10cSrcweir 
592cdf0e10cSrcweir 	SCCOL nColCount = 0;
593cdf0e10cSrcweir 	SCCOL nCol;
594cdf0e10cSrcweir 	if ( bHasHeaderCol )
595cdf0e10cSrcweir 		++nColCount;
596cdf0e10cSrcweir 	if ( bHasRepCols )
597cdf0e10cSrcweir 		for ( nCol=nRepeatColStart; nCol<=nRepeatColEnd; nCol++ )
598cdf0e10cSrcweir             if (!pDoc->ColHidden(nCol, nTab))
599cdf0e10cSrcweir 				++nColCount;
600cdf0e10cSrcweir 	if ( bHasMainCols )
601cdf0e10cSrcweir 		for ( nCol=nMainColStart; nCol<=nMainColEnd; nCol++ )
602cdf0e10cSrcweir             if (!pDoc->ColHidden(nCol, nTab))
603cdf0e10cSrcweir 				++nColCount;
604cdf0e10cSrcweir 
605cdf0e10cSrcweir 	if ( nColCount > 0 )
606cdf0e10cSrcweir 	{
607cdf0e10cSrcweir 		ScPreviewColRowInfo* pColInfo = new ScPreviewColRowInfo[ nColCount ];
608cdf0e10cSrcweir 		SCCOL nColPos = 0;
609cdf0e10cSrcweir 
610cdf0e10cSrcweir 		if ( bHasHeaderCol )
611cdf0e10cSrcweir 		{
612cdf0e10cSrcweir 			pColInfo[nColPos].Set( sal_True, 0, aHeaderRect.Left(), aHeaderRect.Right() );
613cdf0e10cSrcweir 			++nColPos;
614cdf0e10cSrcweir 		}
615cdf0e10cSrcweir 		if ( bHasRepCols )
616cdf0e10cSrcweir 		{
617cdf0e10cSrcweir 			long nPosX = 0;
618cdf0e10cSrcweir 			for ( nCol=nRepeatColStart; nCol<=nRepeatColEnd; nCol++ )
619cdf0e10cSrcweir                 if (!pDoc->ColHidden(nCol, nTab))
620cdf0e10cSrcweir 				{
621cdf0e10cSrcweir 					sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
622cdf0e10cSrcweir 					long nNextX = nPosX + (long) (nDocW * nScaleX);
623cdf0e10cSrcweir 
624cdf0e10cSrcweir 					long nPixelStart = pWindow->LogicToPixel( Size( nPosX, 0 ), aCellMapMode ).Width();
625cdf0e10cSrcweir 					long nPixelEnd = pWindow->LogicToPixel( Size( nNextX, 0 ), aCellMapMode ).Width() - 1;
626cdf0e10cSrcweir 					pColInfo[nColPos].Set( sal_False, nCol,
627cdf0e10cSrcweir 												aRepeatRect.Left() + nPixelStart,
628cdf0e10cSrcweir 												aRepeatRect.Left() + nPixelEnd );
629cdf0e10cSrcweir 
630cdf0e10cSrcweir 					nPosX = nNextX;
631cdf0e10cSrcweir 					++nColPos;
632cdf0e10cSrcweir 				}
633cdf0e10cSrcweir 		}
634cdf0e10cSrcweir 		if ( bHasMainCols )
635cdf0e10cSrcweir 		{
636cdf0e10cSrcweir 			long nPosX = 0;
637cdf0e10cSrcweir 			for ( nCol=nMainColStart; nCol<=nMainColEnd; nCol++ )
638cdf0e10cSrcweir                 if (!pDoc->ColHidden(nCol, nTab))
639cdf0e10cSrcweir 				{
640cdf0e10cSrcweir 					sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
641cdf0e10cSrcweir 					long nNextX = nPosX + (long) (nDocW * nScaleX);
642cdf0e10cSrcweir 
643cdf0e10cSrcweir 					long nPixelStart = pWindow->LogicToPixel( Size( nPosX, 0 ), aCellMapMode ).Width();
644cdf0e10cSrcweir 					long nPixelEnd = pWindow->LogicToPixel( Size( nNextX, 0 ), aCellMapMode ).Width() - 1;
645cdf0e10cSrcweir 					pColInfo[nColPos].Set( sal_False, nCol,
646cdf0e10cSrcweir 												aMainRect.Left() + nPixelStart,
647cdf0e10cSrcweir 												aMainRect.Left() + nPixelEnd );
648cdf0e10cSrcweir 
649cdf0e10cSrcweir 					nPosX = nNextX;
650cdf0e10cSrcweir 					++nColPos;
651cdf0e10cSrcweir 				}
652cdf0e10cSrcweir 		}
653cdf0e10cSrcweir 		rInfo.SetColInfo( nColCount, pColInfo );
654cdf0e10cSrcweir 	}
655cdf0e10cSrcweir 	else
656cdf0e10cSrcweir 		rInfo.SetColInfo( 0, NULL );
657cdf0e10cSrcweir 
658cdf0e10cSrcweir 	//
659cdf0e10cSrcweir 	//	get row info
660cdf0e10cSrcweir 	//
661cdf0e10cSrcweir 
662cdf0e10cSrcweir 	SCROW nRowCount = 0;
663cdf0e10cSrcweir 	if ( bHasHeaderRow )
664cdf0e10cSrcweir 		++nRowCount;
665cdf0e10cSrcweir 	if ( bHasRepRows )
666cdf0e10cSrcweir         nRowCount += pDoc->CountVisibleRows(nRepeatRowStart, nRepeatRowEnd, nTab);
667cdf0e10cSrcweir 	if ( bHasMainRows )
668cdf0e10cSrcweir         nRowCount += pDoc->CountVisibleRows(nMainRowStart, nMainRowEnd, nTab);
669cdf0e10cSrcweir 
670cdf0e10cSrcweir 	if ( nRowCount > 0 )
671cdf0e10cSrcweir 	{
672cdf0e10cSrcweir 		ScPreviewColRowInfo* pRowInfo = new ScPreviewColRowInfo[ nRowCount ];
673cdf0e10cSrcweir 		SCROW nRowPos = 0;
674cdf0e10cSrcweir 
675cdf0e10cSrcweir 		if ( bHasHeaderRow )
676cdf0e10cSrcweir 		{
677cdf0e10cSrcweir 			pRowInfo[nRowPos].Set( sal_True, 0, aHeaderRect.Top(), aHeaderRect.Bottom() );
678cdf0e10cSrcweir 			++nRowPos;
679cdf0e10cSrcweir 		}
680cdf0e10cSrcweir 		if ( bHasRepRows )
681cdf0e10cSrcweir 		{
682cdf0e10cSrcweir 			long nPosY = 0;
683cdf0e10cSrcweir             for (SCROW nRow = nRepeatRowStart; nRow <= nRepeatRowEnd; ++nRow)
684cdf0e10cSrcweir             {
685cdf0e10cSrcweir                 if (pDoc->RowHidden(nRow, nTab))
686cdf0e10cSrcweir                     continue;
687cdf0e10cSrcweir 
688cdf0e10cSrcweir                 sal_uInt16 nDocH = pDoc->GetOriginalHeight( nRow, nTab );
689cdf0e10cSrcweir                 long nNextY = nPosY + (long) (nDocH * nScaleY);
690cdf0e10cSrcweir 
691cdf0e10cSrcweir                 long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height();
692cdf0e10cSrcweir                 long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1;
693cdf0e10cSrcweir                 pRowInfo[nRowPos].Set( sal_False, nRow,
694cdf0e10cSrcweir                         aRepeatRect.Top() + nPixelStart,
695cdf0e10cSrcweir                         aRepeatRect.Top() + nPixelEnd );
696cdf0e10cSrcweir 
697cdf0e10cSrcweir                 nPosY = nNextY;
698cdf0e10cSrcweir                 ++nRowPos;
699cdf0e10cSrcweir             }
700cdf0e10cSrcweir 		}
701cdf0e10cSrcweir 		if ( bHasMainRows )
702cdf0e10cSrcweir 		{
703cdf0e10cSrcweir 			long nPosY = 0;
704cdf0e10cSrcweir             for (SCROW nRow = nMainRowStart; nRow <= nMainRowEnd; ++nRow)
705cdf0e10cSrcweir             {
706cdf0e10cSrcweir                 if (pDoc->RowHidden(nRow, nTab))
707cdf0e10cSrcweir                     continue;
708cdf0e10cSrcweir 
709cdf0e10cSrcweir                 sal_uInt16 nDocH = pDoc->GetOriginalHeight( nRow, nTab );
710cdf0e10cSrcweir                 long nNextY = nPosY + (long) (nDocH * nScaleY);
711cdf0e10cSrcweir 
712cdf0e10cSrcweir                 long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height();
713cdf0e10cSrcweir                 long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1;
714cdf0e10cSrcweir                 pRowInfo[nRowPos].Set( sal_False, nRow,
715cdf0e10cSrcweir                         aMainRect.Top() + nPixelStart,
716cdf0e10cSrcweir                         aMainRect.Top() + nPixelEnd );
717cdf0e10cSrcweir 
718cdf0e10cSrcweir                 nPosY = nNextY;
719cdf0e10cSrcweir                 ++nRowPos;
720cdf0e10cSrcweir             }
721cdf0e10cSrcweir 		}
722cdf0e10cSrcweir 		rInfo.SetRowInfo( nRowCount, pRowInfo );
723cdf0e10cSrcweir 	}
724cdf0e10cSrcweir 	else
725cdf0e10cSrcweir 		rInfo.SetRowInfo( 0, NULL );
726cdf0e10cSrcweir 
727cdf0e10cSrcweir 	//
728cdf0e10cSrcweir 	//	limit to visible area
729cdf0e10cSrcweir 	//
730cdf0e10cSrcweir 
731cdf0e10cSrcweir 	rInfo.SetTab( nTab );
732cdf0e10cSrcweir 	rInfo.LimitToArea( rVisiblePixel );
733cdf0e10cSrcweir }
734cdf0e10cSrcweir 
GetHeaderCellOutputRect(const Rectangle & rVisRect,const ScAddress & rCellPos,sal_Bool bColHeader) const735cdf0e10cSrcweir Rectangle ScPreviewLocationData::GetHeaderCellOutputRect(const Rectangle& rVisRect, const ScAddress& rCellPos, sal_Bool bColHeader) const
736cdf0e10cSrcweir {
737cdf0e10cSrcweir 	// first a stupid implementation
738cdf0e10cSrcweir 	// NN says here should be done more
739cdf0e10cSrcweir 	Rectangle aClipRect;
740cdf0e10cSrcweir 	ScPreviewTableInfo aTableInfo;
741cdf0e10cSrcweir 	GetTableInfo( rVisRect, aTableInfo );
742cdf0e10cSrcweir 
743cdf0e10cSrcweir 	if ( (rCellPos.Col() >= 0) &&
744cdf0e10cSrcweir 		(rCellPos.Row() >= 0) && (rCellPos.Col() < aTableInfo.GetCols()) &&
745cdf0e10cSrcweir 		(rCellPos.Row() < aTableInfo.GetRows()) )
746cdf0e10cSrcweir 	{
747cdf0e10cSrcweir 		SCCOL nCol(0);
748cdf0e10cSrcweir 		SCROW nRow(0);
749cdf0e10cSrcweir 		if (bColHeader)
750cdf0e10cSrcweir 			nCol = rCellPos.Col();
751cdf0e10cSrcweir 		else
752cdf0e10cSrcweir 			nRow = rCellPos.Row();
753cdf0e10cSrcweir 		const ScPreviewColRowInfo& rColInfo = aTableInfo.GetColInfo()[nCol];
754cdf0e10cSrcweir 		const ScPreviewColRowInfo& rRowInfo = aTableInfo.GetRowInfo()[nRow];
755cdf0e10cSrcweir 
756cdf0e10cSrcweir 		if ( rColInfo.bIsHeader || rRowInfo.bIsHeader )
757cdf0e10cSrcweir 			aClipRect = Rectangle( rColInfo.nPixelStart, rRowInfo.nPixelStart, rColInfo.nPixelEnd, rRowInfo.nPixelEnd );
758cdf0e10cSrcweir 	}
759cdf0e10cSrcweir 	return aClipRect;
760cdf0e10cSrcweir }
761cdf0e10cSrcweir 
GetCellOutputRect(const ScAddress & rCellPos) const762cdf0e10cSrcweir Rectangle ScPreviewLocationData::GetCellOutputRect(const ScAddress& rCellPos) const
763cdf0e10cSrcweir {
764cdf0e10cSrcweir 	// first a stupid implementation
765cdf0e10cSrcweir 	// NN says here should be done more
766cdf0e10cSrcweir 	Rectangle aRect;
767cdf0e10cSrcweir 	GetCellPosition(rCellPos, aRect);
768cdf0e10cSrcweir 	return aRect;
769cdf0e10cSrcweir }
770cdf0e10cSrcweir 
771cdf0e10cSrcweir // GetMainCellRange is used for links in PDF export
772cdf0e10cSrcweir 
GetMainCellRange(ScRange & rRange,Rectangle & rPixRect) const773cdf0e10cSrcweir sal_Bool ScPreviewLocationData::GetMainCellRange( ScRange& rRange, Rectangle& rPixRect ) const
774cdf0e10cSrcweir {
775cdf0e10cSrcweir     sal_uLong nCount = aEntries.Count();
776cdf0e10cSrcweir     for (sal_uLong nListPos=0; nListPos<nCount; nListPos++)
777cdf0e10cSrcweir     {
778cdf0e10cSrcweir         ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
779cdf0e10cSrcweir         if ( pEntry->eType == SC_PLOC_CELLRANGE && !pEntry->bRepeatCol && !pEntry->bRepeatRow )
780cdf0e10cSrcweir         {
781cdf0e10cSrcweir             rRange = pEntry->aCellRange;
782cdf0e10cSrcweir             rPixRect = pEntry->aPixelRect;
783cdf0e10cSrcweir             return sal_True;
784cdf0e10cSrcweir         }
785cdf0e10cSrcweir     }
786cdf0e10cSrcweir     return sal_False;       // not found
787cdf0e10cSrcweir }
788cdf0e10cSrcweir 
789