GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / sc / source / ui / view / prevloc.cxx
blobbcafad2b232f882b751f59eaa5f01cebffe67c6e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <vcl/outdev.hxx>
23 #include "prevloc.hxx"
24 #include "document.hxx"
26 enum ScPreviewLocationType
28 SC_PLOC_CELLRANGE,
29 SC_PLOC_COLHEADER,
30 SC_PLOC_ROWHEADER,
31 SC_PLOC_LEFTHEADER,
32 SC_PLOC_RIGHTHEADER,
33 SC_PLOC_LEFTFOOTER,
34 SC_PLOC_RIGHTFOOTER,
35 SC_PLOC_NOTEMARK,
36 SC_PLOC_NOTETEXT
39 struct ScPreviewLocationEntry
41 ScPreviewLocationType eType;
42 Rectangle aPixelRect;
43 ScRange aCellRange;
44 sal_Bool bRepeatCol;
45 sal_Bool bRepeatRow;
47 ScPreviewLocationEntry( ScPreviewLocationType eNewType, const Rectangle& rPixel, const ScRange& rRange,
48 sal_Bool bRepCol, sal_Bool bRepRow ) :
49 eType( eNewType ),
50 aPixelRect( rPixel ),
51 aCellRange( rRange ),
52 bRepeatCol( bRepCol ),
53 bRepeatRow( bRepRow )
58 ScPreviewTableInfo::ScPreviewTableInfo() :
59 nTab(0),
60 nCols(0),
61 nRows(0),
62 pColInfo(NULL),
63 pRowInfo(NULL)
67 ScPreviewTableInfo::~ScPreviewTableInfo()
69 delete[] pColInfo;
70 delete[] pRowInfo;
73 void ScPreviewTableInfo::SetTab( SCTAB nNewTab )
75 nTab = nNewTab;
78 void ScPreviewTableInfo::SetColInfo( SCCOL nCount, ScPreviewColRowInfo* pNewInfo )
80 delete[] pColInfo;
81 pColInfo = pNewInfo;
82 nCols = nCount;
85 void ScPreviewTableInfo::SetRowInfo( SCROW nCount, ScPreviewColRowInfo* pNewInfo )
87 delete[] pRowInfo;
88 pRowInfo = pNewInfo;
89 nRows = nCount;
92 void ScPreviewTableInfo::LimitToArea( const Rectangle& rPixelArea )
94 if ( pColInfo )
96 // cells completely left of the visible area
97 SCCOL nStart = 0;
98 while ( nStart < nCols && pColInfo[nStart].nPixelEnd < rPixelArea.Left() )
99 ++nStart;
101 // cells completely right of the visible area
102 SCCOL nEnd = nCols;
103 while ( nEnd > 0 && pColInfo[nEnd-1].nPixelStart > rPixelArea.Right() )
104 --nEnd;
106 if ( nStart > 0 || nEnd < nCols )
108 if ( nEnd > nStart )
110 SCCOL nNewCount = nEnd - nStart;
111 ScPreviewColRowInfo* pNewInfo = new ScPreviewColRowInfo[nNewCount];
112 for (SCCOL i=0; i<nNewCount; i++)
113 pNewInfo[i] = pColInfo[nStart + i];
114 SetColInfo( nNewCount, pNewInfo );
116 else
117 SetColInfo( 0, NULL ); // all invisible
121 if ( pRowInfo )
123 // cells completely above the visible area
124 SCROW nStart = 0;
125 while ( nStart < nRows && pRowInfo[nStart].nPixelEnd < rPixelArea.Top() )
126 ++nStart;
128 // cells completely below the visible area
129 SCROW nEnd = nRows;
130 while ( nEnd > 0 && pRowInfo[nEnd-1].nPixelStart > rPixelArea.Bottom() )
131 --nEnd;
133 if ( nStart > 0 || nEnd < nRows )
135 if ( nEnd > nStart )
137 SCROW nNewCount = nEnd - nStart;
138 ScPreviewColRowInfo* pNewInfo = new ScPreviewColRowInfo[nNewCount];
139 for (SCROW i=0; i<nNewCount; i++)
140 pNewInfo[i] = pRowInfo[nStart + i];
141 SetRowInfo( nNewCount, pNewInfo );
143 else
144 SetRowInfo( 0, NULL ); // all invisible
149 ScPreviewLocationData::ScPreviewLocationData( ScDocument* pDocument, OutputDevice* pWin ) :
150 pWindow( pWin ),
151 pDoc( pDocument ),
152 nDrawRanges( 0 ),
153 nPrintTab( 0 )
157 ScPreviewLocationData::~ScPreviewLocationData()
159 Clear();
162 void ScPreviewLocationData::SetCellMapMode( const MapMode& rMapMode )
164 aCellMapMode = rMapMode;
167 void ScPreviewLocationData::SetPrintTab( SCTAB nNew )
169 nPrintTab = nNew;
172 void ScPreviewLocationData::Clear()
174 aEntries.clear();
176 nDrawRanges = 0;
179 void ScPreviewLocationData::AddCellRange( const Rectangle& rRect, const ScRange& rRange, sal_Bool bRepCol, sal_Bool bRepRow,
180 const MapMode& rDrawMap )
182 Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
183 aEntries.push_front( new ScPreviewLocationEntry( SC_PLOC_CELLRANGE, aPixelRect, rRange, bRepCol, bRepRow ) );
185 OSL_ENSURE( nDrawRanges < SC_PREVIEW_MAXRANGES, "too many ranges" );
187 if ( nDrawRanges < SC_PREVIEW_MAXRANGES )
189 aDrawRectangle[nDrawRanges] = aPixelRect;
190 aDrawMapMode[nDrawRanges] = rDrawMap;
192 if (bRepCol)
194 if (bRepRow)
195 aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_EDGE;
196 else
197 aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_REPCOL;
199 else
201 if (bRepRow)
202 aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_REPROW;
203 else
204 aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_TAB;
207 ++nDrawRanges;
211 void ScPreviewLocationData::AddColHeaders( const Rectangle& rRect, SCCOL nStartCol, SCCOL nEndCol, sal_Bool bRepCol )
213 SCTAB nTab = 0; //! ?
214 ScRange aRange( nStartCol, 0, nTab, nEndCol, 0, nTab );
215 Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
217 aEntries.push_front( new ScPreviewLocationEntry( SC_PLOC_COLHEADER, aPixelRect, aRange, bRepCol, false ) );
220 void ScPreviewLocationData::AddRowHeaders( const Rectangle& rRect, SCROW nStartRow, SCROW nEndRow, sal_Bool bRepRow )
222 SCTAB nTab = 0; //! ?
223 ScRange aRange( 0, nStartRow, nTab, 0, nEndRow, nTab );
224 Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
226 aEntries.push_front( new ScPreviewLocationEntry( SC_PLOC_ROWHEADER, aPixelRect, aRange, false, bRepRow ) );
229 void ScPreviewLocationData::AddHeaderFooter( const Rectangle& rRect, sal_Bool bHeader, sal_Bool bLeft )
231 ScRange aRange; //! ?
232 Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
234 ScPreviewLocationType eType = bHeader ?
235 ( bLeft ? SC_PLOC_LEFTHEADER : SC_PLOC_RIGHTHEADER ) :
236 ( bLeft ? SC_PLOC_LEFTFOOTER : SC_PLOC_RIGHTFOOTER );
238 aEntries.push_front( new ScPreviewLocationEntry( eType, aPixelRect, aRange, false, false ) );
241 void ScPreviewLocationData::AddNoteMark( const Rectangle& rRect, const ScAddress& rPos )
243 ScRange aRange( rPos );
244 Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
246 aEntries.push_front( new ScPreviewLocationEntry( SC_PLOC_NOTEMARK, aPixelRect, aRange, false, false ) );
249 void ScPreviewLocationData::AddNoteText( const Rectangle& rRect, const ScAddress& rPos )
251 ScRange aRange( rPos );
252 Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
254 aEntries.push_front( new ScPreviewLocationEntry( SC_PLOC_NOTETEXT, aPixelRect, aRange, false, false ) );
257 void ScPreviewLocationData::GetDrawRange( sal_uInt16 nPos, Rectangle& rPixelRect, MapMode& rMapMode, sal_uInt8& rRangeId ) const
259 OSL_ENSURE( nPos < nDrawRanges, "wrong position" );
260 if ( nPos < nDrawRanges )
262 rPixelRect = aDrawRectangle[nPos];
263 rMapMode = aDrawMapMode[nPos];
264 rRangeId = aDrawRangeId[nPos];
268 static ScPreviewLocationEntry* lcl_GetEntryByAddress( const boost::ptr_list<ScPreviewLocationEntry> &rEntries,
269 const ScAddress& rPos, ScPreviewLocationType eType )
271 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
272 for (it = rEntries.begin(); it != rEntries.end(); ++it)
274 if ( it->eType == eType && it->aCellRange.In( rPos ) )
275 return const_cast<ScPreviewLocationEntry*>(&(*it));
278 return NULL;
282 Rectangle ScPreviewLocationData::GetOffsetPixel( const ScAddress& rCellPos, const ScRange& rRange ) const
284 const double nScaleX = HMM_PER_TWIPS;
285 const double nScaleY = HMM_PER_TWIPS;
286 SCTAB nTab = rRange.aStart.Tab();
288 long nPosX = 0;
289 SCCOL nEndCol = rCellPos.Col();
290 for (SCCOL nCol = rRange.aStart.Col(); nCol < nEndCol; nCol++)
292 sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
293 if (nDocW)
294 nPosX += (long) (nDocW * nScaleX);
296 long nSizeX = (long) ( pDoc->GetColWidth( nEndCol, nTab ) * nScaleX );
298 SCROW nEndRow = rCellPos.Row();
299 long nPosY = (long) pDoc->GetScaledRowHeight( rRange.aStart.Row(),
300 nEndRow, nTab, nScaleY);
301 long nSizeY = (long) ( pDoc->GetRowHeight( nEndRow, nTab ) * nScaleY );
303 Size aOffsetLogic( nPosX, nPosY );
304 Size aSizeLogic( nSizeX, nSizeY );
305 Size aOffsetPixel = pWindow->LogicToPixel( aOffsetLogic, aCellMapMode );
306 Size aSizePixel = pWindow->LogicToPixel( aSizeLogic, aCellMapMode );
308 return Rectangle( Point( aOffsetPixel.Width(), aOffsetPixel.Height() ), aSizePixel );
311 sal_Bool ScPreviewLocationData::GetCellPosition( const ScAddress& rCellPos, Rectangle& rCellRect ) const
313 ScPreviewLocationEntry* pEntry = lcl_GetEntryByAddress( aEntries, rCellPos, SC_PLOC_CELLRANGE );
314 if ( pEntry )
316 Rectangle aOffsetRect = GetOffsetPixel( rCellPos, pEntry->aCellRange );
317 rCellRect = Rectangle( aOffsetRect.Left() + pEntry->aPixelRect.Left(),
318 aOffsetRect.Top() + pEntry->aPixelRect.Top(),
319 aOffsetRect.Right() + pEntry->aPixelRect.Left(),
320 aOffsetRect.Bottom() + pEntry->aPixelRect.Top() );
321 return sal_True;
323 return false;
326 sal_Bool ScPreviewLocationData::HasCellsInRange( const Rectangle& rVisiblePixel ) const
328 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
329 for (it = aEntries.begin(); it != aEntries.end(); ++it)
331 if ( it->eType == SC_PLOC_CELLRANGE || it->eType == SC_PLOC_COLHEADER || it->eType == SC_PLOC_ROWHEADER )
332 if ( it->aPixelRect.IsOver( rVisiblePixel ) )
333 return true;
336 return false;
339 sal_Bool ScPreviewLocationData::GetHeaderPosition( Rectangle& rRect ) const
341 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
342 for (it = aEntries.begin(); it != aEntries.end(); ++it)
344 if ( it->eType == SC_PLOC_LEFTHEADER || it->eType == SC_PLOC_RIGHTHEADER )
346 rRect = it->aPixelRect;
347 return true;
351 return false;
354 sal_Bool ScPreviewLocationData::GetFooterPosition( Rectangle& rRect ) const
356 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
357 for (it = aEntries.begin(); it != aEntries.end(); ++it)
359 if ( it->eType == SC_PLOC_LEFTFOOTER || it->eType == SC_PLOC_RIGHTFOOTER )
361 rRect = it->aPixelRect;
362 return true;
366 return false;
369 sal_Bool ScPreviewLocationData::IsHeaderLeft() const
371 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
372 for (it = aEntries.begin(); it != aEntries.end(); ++it)
374 if ( it->eType == SC_PLOC_LEFTHEADER )
375 return true;
377 if ( it->eType == SC_PLOC_RIGHTHEADER )
378 return false;
381 return false;
384 sal_Bool ScPreviewLocationData::IsFooterLeft() const
386 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
387 for (it = aEntries.begin(); it != aEntries.end(); ++it)
389 if ( it->eType == SC_PLOC_LEFTFOOTER )
390 return true;
392 if ( it->eType == SC_PLOC_RIGHTFOOTER )
393 return false;
396 return false;
399 long ScPreviewLocationData::GetNoteCountInRange( const Rectangle& rVisiblePixel, sal_Bool bNoteMarks ) const
401 ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
403 sal_uLong nRet = 0;
404 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
405 for (it = aEntries.begin(); it != aEntries.end(); ++it)
407 if ( it->eType == eType && it->aPixelRect.IsOver( rVisiblePixel ) )
408 ++nRet;
411 return nRet;
414 sal_Bool ScPreviewLocationData::GetNoteInRange( const Rectangle& rVisiblePixel, long nIndex, sal_Bool bNoteMarks,
415 ScAddress& rCellPos, Rectangle& rNoteRect ) const
417 ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
419 sal_uLong nPos = 0;
420 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
421 for (it = aEntries.begin(); it != aEntries.end(); ++it)
423 if ( it->eType == eType && it->aPixelRect.IsOver( rVisiblePixel ) )
425 if ( nPos == sal::static_int_cast<sal_uLong>(nIndex) )
427 rCellPos = it->aCellRange.aStart;
428 rNoteRect = it->aPixelRect;
429 return true;
431 ++nPos;
435 return false;
438 Rectangle ScPreviewLocationData::GetNoteInRangeOutputRect(const Rectangle& rVisiblePixel, sal_Bool bNoteMarks, const ScAddress& aCellPos) const
440 ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
442 sal_uLong nPos = 0;
443 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
444 for (it = aEntries.begin(); it != aEntries.end(); ++it)
446 if ( it->eType == eType && it->aPixelRect.IsOver( rVisiblePixel ) )
448 if ( aCellPos == it->aCellRange.aStart )
449 return it->aPixelRect;
450 ++nPos;
454 return Rectangle();
457 void ScPreviewLocationData::GetTableInfo( const Rectangle& rVisiblePixel, ScPreviewTableInfo& rInfo ) const
459 const double nScaleX = HMM_PER_TWIPS;
460 const double nScaleY = HMM_PER_TWIPS;
462 // from left to right:
463 sal_Bool bHasHeaderCol = false;
464 sal_Bool bHasRepCols = false;
465 sal_Bool bHasMainCols = false;
466 SCCOL nRepeatColStart = 0;
467 SCCOL nRepeatColEnd = 0;
468 SCCOL nMainColStart = 0;
469 SCCOL nMainColEnd = 0;
471 // from top to bottom:
472 sal_Bool bHasHeaderRow = false;
473 sal_Bool bHasRepRows = false;
474 sal_Bool bHasMainRows = false;
475 SCROW nRepeatRowStart = 0;
476 SCROW nRepeatRowEnd = 0;
477 SCROW nMainRowStart = 0;
478 SCROW nMainRowEnd = 0;
480 Rectangle aHeaderRect, aRepeatRect, aMainRect;
481 SCTAB nTab = 0;
483 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
484 for (it = aEntries.begin(); it != aEntries.end(); ++it)
486 if ( it->eType == SC_PLOC_CELLRANGE )
488 if ( it->bRepeatCol )
490 bHasRepCols = true;
491 nRepeatColStart = it->aCellRange.aStart.Col();
492 nRepeatColEnd = it->aCellRange.aEnd.Col();
493 aRepeatRect.Left() = it->aPixelRect.Left();
494 aRepeatRect.Right() = it->aPixelRect.Right();
496 else
498 bHasMainCols = true;
499 nMainColStart = it->aCellRange.aStart.Col();
500 nMainColEnd = it->aCellRange.aEnd.Col();
501 aMainRect.Left() = it->aPixelRect.Left();
502 aMainRect.Right() = it->aPixelRect.Right();
504 if ( it->bRepeatRow )
506 bHasRepRows = true;
507 nRepeatRowStart = it->aCellRange.aStart.Row();
508 nRepeatRowEnd = it->aCellRange.aEnd.Row();
509 aRepeatRect.Top() = it->aPixelRect.Top();
510 aRepeatRect.Bottom() = it->aPixelRect.Bottom();
512 else
514 bHasMainRows = true;
515 nMainRowStart = it->aCellRange.aStart.Row();
516 nMainRowEnd = it->aCellRange.aEnd.Row();
517 aMainRect.Top() = it->aPixelRect.Top();
518 aMainRect.Bottom() = it->aPixelRect.Bottom();
520 nTab = it->aCellRange.aStart.Tab(); //! store separately?
522 else if ( it->eType == SC_PLOC_ROWHEADER )
524 // row headers result in an additional column
525 bHasHeaderCol = true;
526 aHeaderRect.Left() = it->aPixelRect.Left();
527 aHeaderRect.Right() = it->aPixelRect.Right();
529 else if ( it->eType == SC_PLOC_COLHEADER )
531 // column headers result in an additional row
532 bHasHeaderRow = true;
533 aHeaderRect.Top() = it->aPixelRect.Top();
534 aHeaderRect.Bottom() = it->aPixelRect.Bottom();
539 // get column info
542 SCCOL nColCount = 0;
543 SCCOL nCol;
544 if ( bHasHeaderCol )
545 ++nColCount;
546 if ( bHasRepCols )
547 for ( nCol=nRepeatColStart; nCol<=nRepeatColEnd; nCol++ )
548 if (!pDoc->ColHidden(nCol, nTab))
549 ++nColCount;
550 if ( bHasMainCols )
551 for ( nCol=nMainColStart; nCol<=nMainColEnd; nCol++ )
552 if (!pDoc->ColHidden(nCol, nTab))
553 ++nColCount;
555 if ( nColCount > 0 )
557 ScPreviewColRowInfo* pColInfo = new ScPreviewColRowInfo[ nColCount ];
558 SCCOL nColPos = 0;
560 if ( bHasHeaderCol )
562 pColInfo[nColPos].Set( sal_True, 0, aHeaderRect.Left(), aHeaderRect.Right() );
563 ++nColPos;
565 if ( bHasRepCols )
567 long nPosX = 0;
568 for ( nCol=nRepeatColStart; nCol<=nRepeatColEnd; nCol++ )
569 if (!pDoc->ColHidden(nCol, nTab))
571 sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
572 long nNextX = nPosX + (long) (nDocW * nScaleX);
574 long nPixelStart = pWindow->LogicToPixel( Size( nPosX, 0 ), aCellMapMode ).Width();
575 long nPixelEnd = pWindow->LogicToPixel( Size( nNextX, 0 ), aCellMapMode ).Width() - 1;
576 pColInfo[nColPos].Set( false, nCol,
577 aRepeatRect.Left() + nPixelStart,
578 aRepeatRect.Left() + nPixelEnd );
580 nPosX = nNextX;
581 ++nColPos;
584 if ( bHasMainCols )
586 long nPosX = 0;
587 for ( nCol=nMainColStart; nCol<=nMainColEnd; nCol++ )
588 if (!pDoc->ColHidden(nCol, nTab))
590 sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
591 long nNextX = nPosX + (long) (nDocW * nScaleX);
593 long nPixelStart = pWindow->LogicToPixel( Size( nPosX, 0 ), aCellMapMode ).Width();
594 long nPixelEnd = pWindow->LogicToPixel( Size( nNextX, 0 ), aCellMapMode ).Width() - 1;
595 pColInfo[nColPos].Set( false, nCol,
596 aMainRect.Left() + nPixelStart,
597 aMainRect.Left() + nPixelEnd );
599 nPosX = nNextX;
600 ++nColPos;
603 rInfo.SetColInfo( nColCount, pColInfo );
605 else
606 rInfo.SetColInfo( 0, NULL );
609 // get row info
612 SCROW nRowCount = 0;
613 if ( bHasHeaderRow )
614 ++nRowCount;
615 if ( bHasRepRows )
616 nRowCount += pDoc->CountVisibleRows(nRepeatRowStart, nRepeatRowEnd, nTab);
617 if ( bHasMainRows )
618 nRowCount += pDoc->CountVisibleRows(nMainRowStart, nMainRowEnd, nTab);
620 if ( nRowCount > 0 )
622 ScPreviewColRowInfo* pRowInfo = new ScPreviewColRowInfo[ nRowCount ];
623 SCROW nRowPos = 0;
625 if ( bHasHeaderRow )
627 pRowInfo[nRowPos].Set( sal_True, 0, aHeaderRect.Top(), aHeaderRect.Bottom() );
628 ++nRowPos;
630 if ( bHasRepRows )
632 long nPosY = 0;
633 for (SCROW nRow = nRepeatRowStart; nRow <= nRepeatRowEnd; ++nRow)
635 if (pDoc->RowHidden(nRow, nTab))
636 continue;
638 sal_uInt16 nDocH = pDoc->GetOriginalHeight( nRow, nTab );
639 long nNextY = nPosY + (long) (nDocH * nScaleY);
641 long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height();
642 long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1;
643 pRowInfo[nRowPos].Set( false, nRow,
644 aRepeatRect.Top() + nPixelStart,
645 aRepeatRect.Top() + nPixelEnd );
647 nPosY = nNextY;
648 ++nRowPos;
651 if ( bHasMainRows )
653 long nPosY = 0;
654 for (SCROW nRow = nMainRowStart; nRow <= nMainRowEnd; ++nRow)
656 if (pDoc->RowHidden(nRow, nTab))
657 continue;
659 sal_uInt16 nDocH = pDoc->GetOriginalHeight( nRow, nTab );
660 long nNextY = nPosY + (long) (nDocH * nScaleY);
662 long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height();
663 long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1;
664 pRowInfo[nRowPos].Set( false, nRow,
665 aMainRect.Top() + nPixelStart,
666 aMainRect.Top() + nPixelEnd );
668 nPosY = nNextY;
669 ++nRowPos;
672 rInfo.SetRowInfo( nRowCount, pRowInfo );
674 else
675 rInfo.SetRowInfo( 0, NULL );
678 // limit to visible area
681 rInfo.SetTab( nTab );
682 rInfo.LimitToArea( rVisiblePixel );
685 Rectangle ScPreviewLocationData::GetHeaderCellOutputRect(const Rectangle& rVisRect, const ScAddress& rCellPos, sal_Bool bColHeader) const
687 // first a stupid implementation
688 // NN says here should be done more
689 Rectangle aClipRect;
690 ScPreviewTableInfo aTableInfo;
691 GetTableInfo( rVisRect, aTableInfo );
693 if ( (rCellPos.Col() >= 0) &&
694 (rCellPos.Row() >= 0) && (rCellPos.Col() < aTableInfo.GetCols()) &&
695 (rCellPos.Row() < aTableInfo.GetRows()) )
697 SCCOL nCol(0);
698 SCROW nRow(0);
699 if (bColHeader)
700 nCol = rCellPos.Col();
701 else
702 nRow = rCellPos.Row();
703 const ScPreviewColRowInfo& rColInfo = aTableInfo.GetColInfo()[nCol];
704 const ScPreviewColRowInfo& rRowInfo = aTableInfo.GetRowInfo()[nRow];
706 if ( rColInfo.bIsHeader || rRowInfo.bIsHeader )
707 aClipRect = Rectangle( rColInfo.nPixelStart, rRowInfo.nPixelStart, rColInfo.nPixelEnd, rRowInfo.nPixelEnd );
709 return aClipRect;
712 Rectangle ScPreviewLocationData::GetCellOutputRect(const ScAddress& rCellPos) const
714 // first a stupid implementation
715 // NN says here should be done more
716 Rectangle aRect;
717 GetCellPosition(rCellPos, aRect);
718 return aRect;
721 // GetMainCellRange is used for links in PDF export
723 sal_Bool ScPreviewLocationData::GetMainCellRange( ScRange& rRange, Rectangle& rPixRect ) const
725 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
726 for (it = aEntries.begin(); it != aEntries.end(); ++it)
728 if ( it->eType == SC_PLOC_CELLRANGE && !it->bRepeatCol && !it->bRepeatRow )
730 rRange = it->aCellRange;
731 rPixRect = it->aPixelRect;
732 return true;
736 return false;
739 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */