fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / view / prevloc.cxx
blob7da573bbbe1fc5d016a8a26a1acd5664fbef1801
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 .
20 #include <vcl/outdev.hxx>
22 #include "prevloc.hxx"
23 #include "document.hxx"
25 enum ScPreviewLocationType
27 SC_PLOC_CELLRANGE,
28 SC_PLOC_COLHEADER,
29 SC_PLOC_ROWHEADER,
30 SC_PLOC_LEFTHEADER,
31 SC_PLOC_RIGHTHEADER,
32 SC_PLOC_LEFTFOOTER,
33 SC_PLOC_RIGHTFOOTER,
34 SC_PLOC_NOTEMARK,
35 SC_PLOC_NOTETEXT
38 struct ScPreviewLocationEntry
40 ScPreviewLocationType eType;
41 Rectangle aPixelRect;
42 ScRange aCellRange;
43 bool bRepeatCol;
44 bool bRepeatRow;
46 ScPreviewLocationEntry( ScPreviewLocationType eNewType, const Rectangle& rPixel, const ScRange& rRange,
47 bool bRepCol, bool bRepRow ) :
48 eType( eNewType ),
49 aPixelRect( rPixel ),
50 aCellRange( rRange ),
51 bRepeatCol( bRepCol ),
52 bRepeatRow( bRepRow )
57 ScPreviewTableInfo::ScPreviewTableInfo() :
58 nTab(0),
59 nCols(0),
60 nRows(0),
61 pColInfo(NULL),
62 pRowInfo(NULL)
66 ScPreviewTableInfo::~ScPreviewTableInfo()
68 delete[] pColInfo;
69 delete[] pRowInfo;
72 void ScPreviewTableInfo::SetTab( SCTAB nNewTab )
74 nTab = nNewTab;
77 void ScPreviewTableInfo::SetColInfo( SCCOL nCount, ScPreviewColRowInfo* pNewInfo )
79 delete[] pColInfo;
80 pColInfo = pNewInfo;
81 nCols = nCount;
84 void ScPreviewTableInfo::SetRowInfo( SCROW nCount, ScPreviewColRowInfo* pNewInfo )
86 delete[] pRowInfo;
87 pRowInfo = pNewInfo;
88 nRows = nCount;
91 void ScPreviewTableInfo::LimitToArea( const Rectangle& rPixelArea )
93 if ( pColInfo )
95 // cells completely left of the visible area
96 SCCOL nStart = 0;
97 while ( nStart < nCols && pColInfo[nStart].nPixelEnd < rPixelArea.Left() )
98 ++nStart;
100 // cells completely right of the visible area
101 SCCOL nEnd = nCols;
102 while ( nEnd > 0 && pColInfo[nEnd-1].nPixelStart > rPixelArea.Right() )
103 --nEnd;
105 if ( nStart > 0 || nEnd < nCols )
107 if ( nEnd > nStart )
109 SCCOL nNewCount = nEnd - nStart;
110 ScPreviewColRowInfo* pNewInfo = new ScPreviewColRowInfo[nNewCount];
111 for (SCCOL i=0; i<nNewCount; i++)
112 pNewInfo[i] = pColInfo[nStart + i];
113 SetColInfo( nNewCount, pNewInfo );
115 else
116 SetColInfo( 0, NULL ); // all invisible
120 if ( pRowInfo )
122 // cells completely above the visible area
123 SCROW nStart = 0;
124 while ( nStart < nRows && pRowInfo[nStart].nPixelEnd < rPixelArea.Top() )
125 ++nStart;
127 // cells completely below the visible area
128 SCROW nEnd = nRows;
129 while ( nEnd > 0 && pRowInfo[nEnd-1].nPixelStart > rPixelArea.Bottom() )
130 --nEnd;
132 if ( nStart > 0 || nEnd < nRows )
134 if ( nEnd > nStart )
136 SCROW nNewCount = nEnd - nStart;
137 ScPreviewColRowInfo* pNewInfo = new ScPreviewColRowInfo[nNewCount];
138 for (SCROW i=0; i<nNewCount; i++)
139 pNewInfo[i] = pRowInfo[nStart + i];
140 SetRowInfo( nNewCount, pNewInfo );
142 else
143 SetRowInfo( 0, NULL ); // all invisible
148 ScPreviewLocationData::ScPreviewLocationData( ScDocument* pDocument, OutputDevice* pWin ) :
149 pWindow( pWin ),
150 pDoc( pDocument ),
151 nDrawRanges( 0 ),
152 nPrintTab( 0 )
156 ScPreviewLocationData::~ScPreviewLocationData()
158 Clear();
161 void ScPreviewLocationData::SetCellMapMode( const MapMode& rMapMode )
163 aCellMapMode = rMapMode;
166 void ScPreviewLocationData::SetPrintTab( SCTAB nNew )
168 nPrintTab = nNew;
171 void ScPreviewLocationData::Clear()
173 aEntries.clear();
175 nDrawRanges = 0;
178 void ScPreviewLocationData::AddCellRange( const Rectangle& rRect, const ScRange& rRange, bool bRepCol, bool bRepRow,
179 const MapMode& rDrawMap )
181 Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
182 aEntries.push_front( new ScPreviewLocationEntry( SC_PLOC_CELLRANGE, aPixelRect, rRange, bRepCol, bRepRow ) );
184 OSL_ENSURE( nDrawRanges < SC_PREVIEW_MAXRANGES, "too many ranges" );
186 if ( nDrawRanges < SC_PREVIEW_MAXRANGES )
188 aDrawRectangle[nDrawRanges] = aPixelRect;
189 aDrawMapMode[nDrawRanges] = rDrawMap;
191 if (bRepCol)
193 if (bRepRow)
194 aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_EDGE;
195 else
196 aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_REPCOL;
198 else
200 if (bRepRow)
201 aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_REPROW;
202 else
203 aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_TAB;
206 ++nDrawRanges;
210 void ScPreviewLocationData::AddColHeaders( const Rectangle& rRect, SCCOL nStartCol, SCCOL nEndCol, bool bRepCol )
212 SCTAB nTab = 0; //! ?
213 ScRange aRange( nStartCol, 0, nTab, nEndCol, 0, nTab );
214 Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
216 aEntries.push_front( new ScPreviewLocationEntry( SC_PLOC_COLHEADER, aPixelRect, aRange, bRepCol, false ) );
219 void ScPreviewLocationData::AddRowHeaders( const Rectangle& rRect, SCROW nStartRow, SCROW nEndRow, bool bRepRow )
221 SCTAB nTab = 0; //! ?
222 ScRange aRange( 0, nStartRow, nTab, 0, nEndRow, nTab );
223 Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
225 aEntries.push_front( new ScPreviewLocationEntry( SC_PLOC_ROWHEADER, aPixelRect, aRange, false, bRepRow ) );
228 void ScPreviewLocationData::AddHeaderFooter( const Rectangle& rRect, bool bHeader, bool bLeft )
230 ScRange aRange; //! ?
231 Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
233 ScPreviewLocationType eType = bHeader ?
234 ( bLeft ? SC_PLOC_LEFTHEADER : SC_PLOC_RIGHTHEADER ) :
235 ( bLeft ? SC_PLOC_LEFTFOOTER : SC_PLOC_RIGHTFOOTER );
237 aEntries.push_front( new ScPreviewLocationEntry( eType, aPixelRect, aRange, false, false ) );
240 void ScPreviewLocationData::AddNoteMark( const Rectangle& rRect, const ScAddress& rPos )
242 ScRange aRange( rPos );
243 Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
245 aEntries.push_front( new ScPreviewLocationEntry( SC_PLOC_NOTEMARK, aPixelRect, aRange, false, false ) );
248 void ScPreviewLocationData::AddNoteText( const Rectangle& rRect, const ScAddress& rPos )
250 ScRange aRange( rPos );
251 Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
253 aEntries.push_front( new ScPreviewLocationEntry( SC_PLOC_NOTETEXT, aPixelRect, aRange, false, false ) );
256 void ScPreviewLocationData::GetDrawRange( sal_uInt16 nPos, Rectangle& rPixelRect, MapMode& rMapMode, sal_uInt8& rRangeId ) const
258 OSL_ENSURE( nPos < nDrawRanges, "wrong position" );
259 if ( nPos < nDrawRanges )
261 rPixelRect = aDrawRectangle[nPos];
262 rMapMode = aDrawMapMode[nPos];
263 rRangeId = aDrawRangeId[nPos];
267 static ScPreviewLocationEntry* lcl_GetEntryByAddress( const boost::ptr_list<ScPreviewLocationEntry> &rEntries,
268 const ScAddress& rPos, ScPreviewLocationType eType )
270 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
271 for (it = rEntries.begin(); it != rEntries.end(); ++it)
273 if ( it->eType == eType && it->aCellRange.In( rPos ) )
274 return const_cast<ScPreviewLocationEntry*>(&(*it));
277 return NULL;
280 Rectangle ScPreviewLocationData::GetOffsetPixel( const ScAddress& rCellPos, const ScRange& rRange ) const
282 const double nScaleX = HMM_PER_TWIPS;
283 const double nScaleY = HMM_PER_TWIPS;
284 SCTAB nTab = rRange.aStart.Tab();
286 long nPosX = 0;
287 SCCOL nEndCol = rCellPos.Col();
288 for (SCCOL nCol = rRange.aStart.Col(); nCol < nEndCol; nCol++)
290 sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
291 if (nDocW)
292 nPosX += (long) (nDocW * nScaleX);
294 long nSizeX = (long) ( pDoc->GetColWidth( nEndCol, nTab ) * nScaleX );
296 SCROW nEndRow = rCellPos.Row();
297 long nPosY = (long) pDoc->GetScaledRowHeight( rRange.aStart.Row(),
298 nEndRow, nTab, nScaleY);
299 long nSizeY = (long) ( pDoc->GetRowHeight( nEndRow, nTab ) * nScaleY );
301 Size aOffsetLogic( nPosX, nPosY );
302 Size aSizeLogic( nSizeX, nSizeY );
303 Size aOffsetPixel = pWindow->LogicToPixel( aOffsetLogic, aCellMapMode );
304 Size aSizePixel = pWindow->LogicToPixel( aSizeLogic, aCellMapMode );
306 return Rectangle( Point( aOffsetPixel.Width(), aOffsetPixel.Height() ), aSizePixel );
309 bool ScPreviewLocationData::GetCellPosition( const ScAddress& rCellPos, Rectangle& rCellRect ) const
311 ScPreviewLocationEntry* pEntry = lcl_GetEntryByAddress( aEntries, rCellPos, SC_PLOC_CELLRANGE );
312 if ( pEntry )
314 Rectangle aOffsetRect = GetOffsetPixel( rCellPos, pEntry->aCellRange );
315 rCellRect = Rectangle( aOffsetRect.Left() + pEntry->aPixelRect.Left(),
316 aOffsetRect.Top() + pEntry->aPixelRect.Top(),
317 aOffsetRect.Right() + pEntry->aPixelRect.Left(),
318 aOffsetRect.Bottom() + pEntry->aPixelRect.Top() );
319 return true;
321 return false;
324 bool ScPreviewLocationData::HasCellsInRange( const Rectangle& rVisiblePixel ) const
326 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
327 for (it = aEntries.begin(); it != aEntries.end(); ++it)
329 if ( it->eType == SC_PLOC_CELLRANGE || it->eType == SC_PLOC_COLHEADER || it->eType == SC_PLOC_ROWHEADER )
330 if ( it->aPixelRect.IsOver( rVisiblePixel ) )
331 return true;
334 return false;
337 bool ScPreviewLocationData::GetHeaderPosition( Rectangle& rRect ) const
339 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
340 for (it = aEntries.begin(); it != aEntries.end(); ++it)
342 if ( it->eType == SC_PLOC_LEFTHEADER || it->eType == SC_PLOC_RIGHTHEADER )
344 rRect = it->aPixelRect;
345 return true;
349 return false;
352 bool ScPreviewLocationData::GetFooterPosition( Rectangle& rRect ) const
354 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
355 for (it = aEntries.begin(); it != aEntries.end(); ++it)
357 if ( it->eType == SC_PLOC_LEFTFOOTER || it->eType == SC_PLOC_RIGHTFOOTER )
359 rRect = it->aPixelRect;
360 return true;
364 return false;
367 bool ScPreviewLocationData::IsHeaderLeft() const
369 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
370 for (it = aEntries.begin(); it != aEntries.end(); ++it)
372 if ( it->eType == SC_PLOC_LEFTHEADER )
373 return true;
375 if ( it->eType == SC_PLOC_RIGHTHEADER )
376 return false;
379 return false;
382 bool ScPreviewLocationData::IsFooterLeft() const
384 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
385 for (it = aEntries.begin(); it != aEntries.end(); ++it)
387 if ( it->eType == SC_PLOC_LEFTFOOTER )
388 return true;
390 if ( it->eType == SC_PLOC_RIGHTFOOTER )
391 return false;
394 return false;
397 long ScPreviewLocationData::GetNoteCountInRange( const Rectangle& rVisiblePixel, bool bNoteMarks ) const
399 ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
401 sal_uLong nRet = 0;
402 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
403 for (it = aEntries.begin(); it != aEntries.end(); ++it)
405 if ( it->eType == eType && it->aPixelRect.IsOver( rVisiblePixel ) )
406 ++nRet;
409 return nRet;
412 bool ScPreviewLocationData::GetNoteInRange( const Rectangle& rVisiblePixel, long nIndex, bool bNoteMarks,
413 ScAddress& rCellPos, Rectangle& rNoteRect ) const
415 ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
417 sal_uLong nPos = 0;
418 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
419 for (it = aEntries.begin(); it != aEntries.end(); ++it)
421 if ( it->eType == eType && it->aPixelRect.IsOver( rVisiblePixel ) )
423 if ( nPos == sal::static_int_cast<sal_uLong>(nIndex) )
425 rCellPos = it->aCellRange.aStart;
426 rNoteRect = it->aPixelRect;
427 return true;
429 ++nPos;
433 return false;
436 Rectangle ScPreviewLocationData::GetNoteInRangeOutputRect(const Rectangle& rVisiblePixel, bool bNoteMarks, const ScAddress& aCellPos) const
438 ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
440 sal_uLong nPos = 0;
441 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
442 for (it = aEntries.begin(); it != aEntries.end(); ++it)
444 if ( it->eType == eType && it->aPixelRect.IsOver( rVisiblePixel ) )
446 if ( aCellPos == it->aCellRange.aStart )
447 return it->aPixelRect;
448 ++nPos;
452 return Rectangle();
455 void ScPreviewLocationData::GetTableInfo( const Rectangle& rVisiblePixel, ScPreviewTableInfo& rInfo ) const
457 const double nScaleX = HMM_PER_TWIPS;
458 const double nScaleY = HMM_PER_TWIPS;
460 // from left to right:
461 bool bHasHeaderCol = false;
462 bool bHasRepCols = false;
463 bool bHasMainCols = false;
464 SCCOL nRepeatColStart = 0;
465 SCCOL nRepeatColEnd = 0;
466 SCCOL nMainColStart = 0;
467 SCCOL nMainColEnd = 0;
469 // from top to bottom:
470 bool bHasHeaderRow = false;
471 bool bHasRepRows = false;
472 bool bHasMainRows = false;
473 SCROW nRepeatRowStart = 0;
474 SCROW nRepeatRowEnd = 0;
475 SCROW nMainRowStart = 0;
476 SCROW nMainRowEnd = 0;
478 Rectangle aHeaderRect, aRepeatRect, aMainRect;
479 SCTAB nTab = 0;
481 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
482 for (it = aEntries.begin(); it != aEntries.end(); ++it)
484 if ( it->eType == SC_PLOC_CELLRANGE )
486 if ( it->bRepeatCol )
488 bHasRepCols = true;
489 nRepeatColStart = it->aCellRange.aStart.Col();
490 nRepeatColEnd = it->aCellRange.aEnd.Col();
491 aRepeatRect.Left() = it->aPixelRect.Left();
492 aRepeatRect.Right() = it->aPixelRect.Right();
494 else
496 bHasMainCols = true;
497 nMainColStart = it->aCellRange.aStart.Col();
498 nMainColEnd = it->aCellRange.aEnd.Col();
499 aMainRect.Left() = it->aPixelRect.Left();
500 aMainRect.Right() = it->aPixelRect.Right();
502 if ( it->bRepeatRow )
504 bHasRepRows = true;
505 nRepeatRowStart = it->aCellRange.aStart.Row();
506 nRepeatRowEnd = it->aCellRange.aEnd.Row();
507 aRepeatRect.Top() = it->aPixelRect.Top();
508 aRepeatRect.Bottom() = it->aPixelRect.Bottom();
510 else
512 bHasMainRows = true;
513 nMainRowStart = it->aCellRange.aStart.Row();
514 nMainRowEnd = it->aCellRange.aEnd.Row();
515 aMainRect.Top() = it->aPixelRect.Top();
516 aMainRect.Bottom() = it->aPixelRect.Bottom();
518 nTab = it->aCellRange.aStart.Tab(); //! store separately?
520 else if ( it->eType == SC_PLOC_ROWHEADER )
522 // row headers result in an additional column
523 bHasHeaderCol = true;
524 aHeaderRect.Left() = it->aPixelRect.Left();
525 aHeaderRect.Right() = it->aPixelRect.Right();
527 else if ( it->eType == SC_PLOC_COLHEADER )
529 // column headers result in an additional row
530 bHasHeaderRow = true;
531 aHeaderRect.Top() = it->aPixelRect.Top();
532 aHeaderRect.Bottom() = it->aPixelRect.Bottom();
536 // get column info
538 SCCOL nColCount = 0;
539 SCCOL nCol;
540 if ( bHasHeaderCol )
541 ++nColCount;
542 if ( bHasRepCols )
543 for ( nCol=nRepeatColStart; nCol<=nRepeatColEnd; nCol++ )
544 if (!pDoc->ColHidden(nCol, nTab))
545 ++nColCount;
546 if ( bHasMainCols )
547 for ( nCol=nMainColStart; nCol<=nMainColEnd; nCol++ )
548 if (!pDoc->ColHidden(nCol, nTab))
549 ++nColCount;
551 if ( nColCount > 0 )
553 ScPreviewColRowInfo* pColInfo = new ScPreviewColRowInfo[ nColCount ];
554 SCCOL nColPos = 0;
556 if ( bHasHeaderCol )
558 pColInfo[nColPos].Set( true, 0, aHeaderRect.Left(), aHeaderRect.Right() );
559 ++nColPos;
561 if ( bHasRepCols )
563 long nPosX = 0;
564 for ( nCol=nRepeatColStart; nCol<=nRepeatColEnd; nCol++ )
565 if (!pDoc->ColHidden(nCol, nTab))
567 sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
568 long nNextX = nPosX + (long) (nDocW * nScaleX);
570 long nPixelStart = pWindow->LogicToPixel( Size( nPosX, 0 ), aCellMapMode ).Width();
571 long nPixelEnd = pWindow->LogicToPixel( Size( nNextX, 0 ), aCellMapMode ).Width() - 1;
572 pColInfo[nColPos].Set( false, nCol,
573 aRepeatRect.Left() + nPixelStart,
574 aRepeatRect.Left() + nPixelEnd );
576 nPosX = nNextX;
577 ++nColPos;
580 if ( bHasMainCols )
582 long nPosX = 0;
583 for ( nCol=nMainColStart; nCol<=nMainColEnd; nCol++ )
584 if (!pDoc->ColHidden(nCol, nTab))
586 sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
587 long nNextX = nPosX + (long) (nDocW * nScaleX);
589 long nPixelStart = pWindow->LogicToPixel( Size( nPosX, 0 ), aCellMapMode ).Width();
590 long nPixelEnd = pWindow->LogicToPixel( Size( nNextX, 0 ), aCellMapMode ).Width() - 1;
591 pColInfo[nColPos].Set( false, nCol,
592 aMainRect.Left() + nPixelStart,
593 aMainRect.Left() + nPixelEnd );
595 nPosX = nNextX;
596 ++nColPos;
599 rInfo.SetColInfo( nColCount, pColInfo );
601 else
602 rInfo.SetColInfo( 0, NULL );
604 // get row info
606 SCROW nRowCount = 0;
607 if ( bHasHeaderRow )
608 ++nRowCount;
609 if ( bHasRepRows )
610 nRowCount += pDoc->CountVisibleRows(nRepeatRowStart, nRepeatRowEnd, nTab);
611 if ( bHasMainRows )
612 nRowCount += pDoc->CountVisibleRows(nMainRowStart, nMainRowEnd, nTab);
614 if ( nRowCount > 0 )
616 ScPreviewColRowInfo* pRowInfo = new ScPreviewColRowInfo[ nRowCount ];
617 SCROW nRowPos = 0;
619 if ( bHasHeaderRow )
621 pRowInfo[nRowPos].Set( true, 0, aHeaderRect.Top(), aHeaderRect.Bottom() );
622 ++nRowPos;
624 if ( bHasRepRows )
626 long nPosY = 0;
627 for (SCROW nRow = nRepeatRowStart; nRow <= nRepeatRowEnd; ++nRow)
629 if (pDoc->RowHidden(nRow, nTab))
630 continue;
632 sal_uInt16 nDocH = pDoc->GetOriginalHeight( nRow, nTab );
633 long nNextY = nPosY + (long) (nDocH * nScaleY);
635 long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height();
636 long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1;
637 pRowInfo[nRowPos].Set( false, nRow,
638 aRepeatRect.Top() + nPixelStart,
639 aRepeatRect.Top() + nPixelEnd );
641 nPosY = nNextY;
642 ++nRowPos;
645 if ( bHasMainRows )
647 long nPosY = 0;
648 for (SCROW nRow = nMainRowStart; nRow <= nMainRowEnd; ++nRow)
650 if (pDoc->RowHidden(nRow, nTab))
651 continue;
653 sal_uInt16 nDocH = pDoc->GetOriginalHeight( nRow, nTab );
654 long nNextY = nPosY + (long) (nDocH * nScaleY);
656 long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height();
657 long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1;
658 pRowInfo[nRowPos].Set( false, nRow,
659 aMainRect.Top() + nPixelStart,
660 aMainRect.Top() + nPixelEnd );
662 nPosY = nNextY;
663 ++nRowPos;
666 rInfo.SetRowInfo( nRowCount, pRowInfo );
668 else
669 rInfo.SetRowInfo( 0, NULL );
671 // limit to visible area
673 rInfo.SetTab( nTab );
674 rInfo.LimitToArea( rVisiblePixel );
677 Rectangle ScPreviewLocationData::GetHeaderCellOutputRect(const Rectangle& rVisRect, const ScAddress& rCellPos, bool bColHeader) const
679 // first a stupid implementation
680 // NN says here should be done more
681 Rectangle aClipRect;
682 ScPreviewTableInfo aTableInfo;
683 GetTableInfo( rVisRect, aTableInfo );
685 if ( (rCellPos.Col() >= 0) &&
686 (rCellPos.Row() >= 0) && (rCellPos.Col() < aTableInfo.GetCols()) &&
687 (rCellPos.Row() < aTableInfo.GetRows()) )
689 SCCOL nCol(0);
690 SCROW nRow(0);
691 if (bColHeader)
692 nCol = rCellPos.Col();
693 else
694 nRow = rCellPos.Row();
695 const ScPreviewColRowInfo& rColInfo = aTableInfo.GetColInfo()[nCol];
696 const ScPreviewColRowInfo& rRowInfo = aTableInfo.GetRowInfo()[nRow];
698 if ( rColInfo.bIsHeader || rRowInfo.bIsHeader )
699 aClipRect = Rectangle( rColInfo.nPixelStart, rRowInfo.nPixelStart, rColInfo.nPixelEnd, rRowInfo.nPixelEnd );
701 return aClipRect;
704 Rectangle ScPreviewLocationData::GetCellOutputRect(const ScAddress& rCellPos) const
706 // first a stupid implementation
707 // NN says here should be done more
708 Rectangle aRect;
709 GetCellPosition(rCellPos, aRect);
710 return aRect;
713 // GetMainCellRange is used for links in PDF export
715 bool ScPreviewLocationData::GetMainCellRange( ScRange& rRange, Rectangle& rPixRect ) const
717 boost::ptr_list<ScPreviewLocationEntry>::const_iterator it;
718 for (it = aEntries.begin(); it != aEntries.end(); ++it)
720 if ( it->eType == SC_PLOC_CELLRANGE && !it->bRepeatCol && !it->bRepeatRow )
722 rRange = it->aCellRange;
723 rPixRect = it->aPixelRect;
724 return true;
728 return false;
731 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */