tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / view / prevloc.cxx
blob1e2375ab5c0739feef004d1ec5b0842041f43ec8
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 <prevloc.hxx>
21 #include <document.hxx>
23 #include <o3tl/unit_conversion.hxx>
24 #include <osl/diagnose.h>
25 #include <vcl/outdev.hxx>
27 namespace {
29 enum ScPreviewLocationType : sal_uInt8
31 SC_PLOC_CELLRANGE,
32 SC_PLOC_COLHEADER,
33 SC_PLOC_ROWHEADER,
34 SC_PLOC_LEFTHEADER,
35 SC_PLOC_RIGHTHEADER,
36 SC_PLOC_LEFTFOOTER,
37 SC_PLOC_RIGHTFOOTER,
38 SC_PLOC_NOTEMARK,
39 SC_PLOC_NOTETEXT
44 struct ScPreviewLocationEntry
46 tools::Rectangle aPixelRect;
47 ScRange aCellRange;
48 ScPreviewLocationType eType;
49 bool bRepeatCol;
50 bool bRepeatRow;
52 ScPreviewLocationEntry( ScPreviewLocationType eNewType, const tools::Rectangle& rPixel, const ScRange& rRange,
53 bool bRepCol, bool bRepRow ) :
54 aPixelRect( rPixel ),
55 aCellRange( rRange ),
56 eType( eNewType ),
57 bRepeatCol( bRepCol ),
58 bRepeatRow( bRepRow )
63 ScPreviewTableInfo::ScPreviewTableInfo() :
64 nTab(0),
65 nCols(0),
66 nRows(0)
70 ScPreviewTableInfo::~ScPreviewTableInfo()
74 void ScPreviewTableInfo::SetTab( SCTAB nNewTab )
76 nTab = nNewTab;
79 void ScPreviewTableInfo::SetColInfo( SCCOL nCount, ScPreviewColRowInfo* pNewInfo )
81 pColInfo.reset(pNewInfo);
82 nCols = nCount;
85 void ScPreviewTableInfo::SetRowInfo( SCROW nCount, ScPreviewColRowInfo* pNewInfo )
87 pRowInfo.reset(pNewInfo);
88 nRows = nCount;
91 void ScPreviewTableInfo::LimitToArea( const tools::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, nullptr ); // all invisible
120 if ( !pRowInfo )
121 return;
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 )
134 return;
136 if ( nEnd > nStart )
138 SCROW nNewCount = nEnd - nStart;
139 ScPreviewColRowInfo* pNewInfo = new ScPreviewColRowInfo[nNewCount];
140 for (SCROW i=0; i<nNewCount; i++)
141 pNewInfo[i] = pRowInfo[nStart + i];
142 SetRowInfo( nNewCount, pNewInfo );
144 else
145 SetRowInfo( 0, nullptr ); // 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 m_Entries.clear();
175 nDrawRanges = 0;
178 void ScPreviewLocationData::AddCellRange( const tools::Rectangle& rRect, const ScRange& rRange, bool bRepCol, bool bRepRow,
179 const MapMode& rDrawMap )
181 tools::Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
182 m_Entries.push_front( std::make_unique<ScPreviewLocationEntry>(SC_PLOC_CELLRANGE, aPixelRect, rRange, bRepCol, bRepRow) );
184 OSL_ENSURE( nDrawRanges < SC_PREVIEW_MAXRANGES, "too many ranges" );
186 if ( nDrawRanges >= SC_PREVIEW_MAXRANGES )
187 return;
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;
210 void ScPreviewLocationData::AddColHeaders( const tools::Rectangle& rRect, SCCOL nStartCol, SCCOL nEndCol, bool bRepCol )
212 SCTAB nTab = 0; //! ?
213 ScRange aRange( nStartCol, 0, nTab, nEndCol, 0, nTab );
214 tools::Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
216 m_Entries.push_front( std::make_unique<ScPreviewLocationEntry>(SC_PLOC_COLHEADER, aPixelRect, aRange, bRepCol, false) );
219 void ScPreviewLocationData::AddRowHeaders( const tools::Rectangle& rRect, SCROW nStartRow, SCROW nEndRow, bool bRepRow )
221 SCTAB nTab = 0; //! ?
222 ScRange aRange( 0, nStartRow, nTab, 0, nEndRow, nTab );
223 tools::Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
225 m_Entries.push_front( std::make_unique<ScPreviewLocationEntry>(SC_PLOC_ROWHEADER, aPixelRect, aRange, false, bRepRow) );
228 void ScPreviewLocationData::AddHeaderFooter( const tools::Rectangle& rRect, bool bHeader, bool bLeft )
230 ScRange aRange; //! ?
231 tools::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 m_Entries.push_front( std::make_unique<ScPreviewLocationEntry>(eType, aPixelRect, aRange, false, false) );
240 void ScPreviewLocationData::AddNoteMark( const tools::Rectangle& rRect, const ScAddress& rPos )
242 ScRange aRange( rPos );
243 tools::Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
245 m_Entries.push_front( std::make_unique<ScPreviewLocationEntry>(SC_PLOC_NOTEMARK, aPixelRect, aRange, false, false) );
248 void ScPreviewLocationData::AddNoteText( const tools::Rectangle& rRect, const ScAddress& rPos )
250 ScRange aRange( rPos );
251 tools::Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
253 m_Entries.push_front( std::make_unique<ScPreviewLocationEntry>(SC_PLOC_NOTETEXT, aPixelRect, aRange, false, false) );
256 void ScPreviewLocationData::GetDrawRange( sal_uInt16 nPos, tools::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(
268 ScPreviewLocationData::Entries_t const& rEntries,
269 const ScAddress& rPos, ScPreviewLocationType const eType)
271 for (auto const& it : rEntries)
273 if ( it->eType == eType && it->aCellRange.Contains( rPos ) )
274 return it.get();
277 return nullptr;
280 tools::Rectangle ScPreviewLocationData::GetOffsetPixel( const ScAddress& rCellPos, const ScRange& rRange ) const
282 SCTAB nTab = rRange.aStart.Tab();
284 tools::Long nPosX = 0;
285 SCCOL nEndCol = rCellPos.Col();
286 for (SCCOL nCol = rRange.aStart.Col(); nCol < nEndCol; nCol++)
288 sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
289 if (nDocW)
290 nPosX += o3tl::convert(nDocW, o3tl::Length::twip, o3tl::Length::mm100);
292 const tools::Long nSizeX
293 = o3tl::convert(pDoc->GetColWidth(nEndCol, nTab), o3tl::Length::twip, o3tl::Length::mm100);
295 SCROW nEndRow = rCellPos.Row();
296 tools::Long nPosY = o3tl::convert(pDoc->GetRowHeight(rRange.aStart.Row(), nEndRow, nTab),
297 o3tl::Length::twip, o3tl::Length::mm100);
298 tools::Long nSizeY
299 = o3tl::convert(pDoc->GetRowHeight(nEndRow, nTab), o3tl::Length::twip, o3tl::Length::mm100);
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 tools::Rectangle( Point( aOffsetPixel.Width(), aOffsetPixel.Height() ), aSizePixel );
309 void ScPreviewLocationData::GetCellPosition( const ScAddress& rCellPos, tools::Rectangle& rCellRect ) const
311 ScPreviewLocationEntry* pEntry = lcl_GetEntryByAddress( m_Entries, rCellPos, SC_PLOC_CELLRANGE );
312 if ( pEntry )
314 tools::Rectangle aOffsetRect = GetOffsetPixel( rCellPos, pEntry->aCellRange );
315 rCellRect = tools::Rectangle( aOffsetRect.Left() + pEntry->aPixelRect.Left(),
316 aOffsetRect.Top() + pEntry->aPixelRect.Top(),
317 aOffsetRect.Right() + pEntry->aPixelRect.Left(),
318 aOffsetRect.Bottom() + pEntry->aPixelRect.Top() );
322 bool ScPreviewLocationData::HasCellsInRange( const tools::Rectangle& rVisiblePixel ) const
324 for (auto const& it : m_Entries)
326 if ( it->eType == SC_PLOC_CELLRANGE || it->eType == SC_PLOC_COLHEADER || it->eType == SC_PLOC_ROWHEADER )
327 if ( it->aPixelRect.Overlaps( rVisiblePixel ) )
328 return true;
331 return false;
334 bool ScPreviewLocationData::GetHeaderPosition( tools::Rectangle& rRect ) const
336 for (auto const& it : m_Entries)
338 if ( it->eType == SC_PLOC_LEFTHEADER || it->eType == SC_PLOC_RIGHTHEADER )
340 rRect = it->aPixelRect;
341 return true;
345 return false;
348 bool ScPreviewLocationData::GetFooterPosition( tools::Rectangle& rRect ) const
350 for (auto const& it : m_Entries)
352 if ( it->eType == SC_PLOC_LEFTFOOTER || it->eType == SC_PLOC_RIGHTFOOTER )
354 rRect = it->aPixelRect;
355 return true;
359 return false;
362 bool ScPreviewLocationData::IsHeaderLeft() const
364 for (auto const& it : m_Entries)
366 if ( it->eType == SC_PLOC_LEFTHEADER )
367 return true;
369 if ( it->eType == SC_PLOC_RIGHTHEADER )
370 return false;
373 return false;
376 bool ScPreviewLocationData::IsFooterLeft() const
378 for (auto const& it : m_Entries)
380 if ( it->eType == SC_PLOC_LEFTFOOTER )
381 return true;
383 if ( it->eType == SC_PLOC_RIGHTFOOTER )
384 return false;
387 return false;
390 tools::Long ScPreviewLocationData::GetNoteCountInRange( const tools::Rectangle& rVisiblePixel, bool bNoteMarks ) const
392 ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
394 sal_uLong nRet = 0;
395 for (auto const& it : m_Entries)
397 if ( it->eType == eType && it->aPixelRect.Overlaps( rVisiblePixel ) )
398 ++nRet;
401 return nRet;
404 bool ScPreviewLocationData::GetNoteInRange( const tools::Rectangle& rVisiblePixel, tools::Long nIndex, bool bNoteMarks,
405 ScAddress& rCellPos, tools::Rectangle& rNoteRect ) const
407 ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
409 sal_uLong nPos = 0;
410 for (auto const& it : m_Entries)
412 if ( it->eType == eType && it->aPixelRect.Overlaps( rVisiblePixel ) )
414 if ( nPos == sal::static_int_cast<sal_uLong>(nIndex) )
416 rCellPos = it->aCellRange.aStart;
417 rNoteRect = it->aPixelRect;
418 return true;
420 ++nPos;
424 return false;
427 tools::Rectangle ScPreviewLocationData::GetNoteInRangeOutputRect(const tools::Rectangle& rVisiblePixel, bool bNoteMarks, const ScAddress& aCellPos) const
429 ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
431 for (auto const& it : m_Entries)
433 if ( it->eType == eType && it->aPixelRect.Overlaps( rVisiblePixel ) )
435 if ( aCellPos == it->aCellRange.aStart )
436 return it->aPixelRect;
440 return tools::Rectangle();
443 void ScPreviewLocationData::GetTableInfo( const tools::Rectangle& rVisiblePixel, ScPreviewTableInfo& rInfo ) const
445 // from left to right:
446 bool bHasHeaderCol = false;
447 bool bHasRepCols = false;
448 bool bHasMainCols = false;
449 SCCOL nRepeatColStart = 0;
450 SCCOL nRepeatColEnd = 0;
451 SCCOL nMainColStart = 0;
452 SCCOL nMainColEnd = 0;
454 // from top to bottom:
455 bool bHasHeaderRow = false;
456 bool bHasRepRows = false;
457 bool bHasMainRows = false;
458 SCROW nRepeatRowStart = 0;
459 SCROW nRepeatRowEnd = 0;
460 SCROW nMainRowStart = 0;
461 SCROW nMainRowEnd = 0;
463 tools::Rectangle aHeaderRect, aRepeatRect, aMainRect;
464 SCTAB nTab = 0;
466 for (auto const& it : m_Entries)
468 if ( it->eType == SC_PLOC_CELLRANGE )
470 if ( it->bRepeatCol )
472 bHasRepCols = true;
473 nRepeatColStart = it->aCellRange.aStart.Col();
474 nRepeatColEnd = it->aCellRange.aEnd.Col();
475 aRepeatRect.SetLeft( it->aPixelRect.Left() );
476 aRepeatRect.SetRight( it->aPixelRect.Right() );
478 else
480 bHasMainCols = true;
481 nMainColStart = it->aCellRange.aStart.Col();
482 nMainColEnd = it->aCellRange.aEnd.Col();
483 aMainRect.SetLeft( it->aPixelRect.Left() );
484 aMainRect.SetRight( it->aPixelRect.Right() );
486 if ( it->bRepeatRow )
488 bHasRepRows = true;
489 nRepeatRowStart = it->aCellRange.aStart.Row();
490 nRepeatRowEnd = it->aCellRange.aEnd.Row();
491 aRepeatRect.SetTop( it->aPixelRect.Top() );
492 aRepeatRect.SetBottom( it->aPixelRect.Bottom() );
494 else
496 bHasMainRows = true;
497 nMainRowStart = it->aCellRange.aStart.Row();
498 nMainRowEnd = it->aCellRange.aEnd.Row();
499 aMainRect.SetTop( it->aPixelRect.Top() );
500 aMainRect.SetBottom( it->aPixelRect.Bottom() );
502 nTab = it->aCellRange.aStart.Tab(); //! store separately?
504 else if ( it->eType == SC_PLOC_ROWHEADER )
506 // row headers result in an additional column
507 bHasHeaderCol = true;
508 aHeaderRect.SetLeft( it->aPixelRect.Left() );
509 aHeaderRect.SetRight( it->aPixelRect.Right() );
511 else if ( it->eType == SC_PLOC_COLHEADER )
513 // column headers result in an additional row
514 bHasHeaderRow = true;
515 aHeaderRect.SetTop( it->aPixelRect.Top() );
516 aHeaderRect.SetBottom( it->aPixelRect.Bottom() );
520 // get column info
522 SCCOL nColCount = 0;
523 SCCOL nCol;
524 if ( bHasHeaderCol )
525 ++nColCount;
526 if ( bHasRepCols )
527 for ( nCol=nRepeatColStart; nCol<=nRepeatColEnd; nCol++ )
528 if (!pDoc->ColHidden(nCol, nTab))
529 ++nColCount;
530 if ( bHasMainCols )
531 for ( nCol=nMainColStart; nCol<=nMainColEnd; nCol++ )
532 if (!pDoc->ColHidden(nCol, nTab))
533 ++nColCount;
535 if ( nColCount > 0 )
537 ScPreviewColRowInfo* pColInfo = new ScPreviewColRowInfo[ nColCount ];
538 SCCOL nColPos = 0;
540 if ( bHasHeaderCol )
542 pColInfo[nColPos].Set( true, 0, aHeaderRect.Left(), aHeaderRect.Right() );
543 ++nColPos;
545 if ( bHasRepCols )
547 tools::Long nPosX = 0;
548 for ( nCol=nRepeatColStart; nCol<=nRepeatColEnd; nCol++ )
549 if (!pDoc->ColHidden(nCol, nTab))
551 sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
552 tools::Long nNextX
553 = nPosX + o3tl::convert(nDocW, o3tl::Length::twip, o3tl::Length::mm100);
555 tools::Long nPixelStart = pWindow->LogicToPixel( Size( nPosX, 0 ), aCellMapMode ).Width();
556 tools::Long nPixelEnd = pWindow->LogicToPixel( Size( nNextX, 0 ), aCellMapMode ).Width() - 1;
557 pColInfo[nColPos].Set( false, nCol,
558 aRepeatRect.Left() + nPixelStart,
559 aRepeatRect.Left() + nPixelEnd );
561 nPosX = nNextX;
562 ++nColPos;
565 if ( bHasMainCols )
567 tools::Long nPosX = 0;
568 for ( nCol=nMainColStart; nCol<=nMainColEnd; nCol++ )
569 if (!pDoc->ColHidden(nCol, nTab))
571 sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
572 tools::Long nNextX
573 = nPosX + o3tl::convert(nDocW, o3tl::Length::twip, o3tl::Length::mm100);
575 tools::Long nPixelStart = pWindow->LogicToPixel( Size( nPosX, 0 ), aCellMapMode ).Width();
576 tools::Long nPixelEnd = pWindow->LogicToPixel( Size( nNextX, 0 ), aCellMapMode ).Width() - 1;
577 pColInfo[nColPos].Set( false, nCol,
578 aMainRect.Left() + nPixelStart,
579 aMainRect.Left() + nPixelEnd );
581 nPosX = nNextX;
582 ++nColPos;
585 rInfo.SetColInfo( nColCount, pColInfo );
587 else
588 rInfo.SetColInfo( 0, nullptr );
590 // get row info
592 SCROW nRowCount = 0;
593 if ( bHasHeaderRow )
594 ++nRowCount;
595 if ( bHasRepRows )
596 nRowCount += pDoc->CountVisibleRows(nRepeatRowStart, nRepeatRowEnd, nTab);
597 if ( bHasMainRows )
598 nRowCount += pDoc->CountVisibleRows(nMainRowStart, nMainRowEnd, nTab);
600 if ( nRowCount > 0 )
602 ScPreviewColRowInfo* pRowInfo = new ScPreviewColRowInfo[ nRowCount ];
603 SCROW nRowPos = 0;
605 if ( bHasHeaderRow )
607 pRowInfo[nRowPos].Set( true, 0, aHeaderRect.Top(), aHeaderRect.Bottom() );
608 ++nRowPos;
610 if ( bHasRepRows )
612 tools::Long nPosY = 0;
613 for (SCROW nRow = nRepeatRowStart; nRow <= nRepeatRowEnd; ++nRow)
615 if (pDoc->RowHidden(nRow, nTab))
616 continue;
618 sal_uInt16 nDocH = pDoc->GetOriginalHeight( nRow, nTab );
619 tools::Long nNextY
620 = nPosY + o3tl::convert(nDocH, o3tl::Length::twip, o3tl::Length::mm100);
622 tools::Long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height();
623 tools::Long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1;
624 pRowInfo[nRowPos].Set( false, nRow,
625 aRepeatRect.Top() + nPixelStart,
626 aRepeatRect.Top() + nPixelEnd );
628 nPosY = nNextY;
629 ++nRowPos;
632 if ( bHasMainRows )
634 tools::Long nPosY = 0;
635 for (SCROW nRow = nMainRowStart; nRow <= nMainRowEnd; ++nRow)
637 if (pDoc->RowHidden(nRow, nTab))
638 continue;
640 sal_uInt16 nDocH = pDoc->GetOriginalHeight( nRow, nTab );
641 tools::Long nNextY
642 = nPosY + o3tl::convert(nDocH, o3tl::Length::twip, o3tl::Length::mm100);
644 tools::Long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height();
645 tools::Long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1;
646 pRowInfo[nRowPos].Set( false, nRow,
647 aMainRect.Top() + nPixelStart,
648 aMainRect.Top() + nPixelEnd );
650 nPosY = nNextY;
651 ++nRowPos;
654 rInfo.SetRowInfo( nRowCount, pRowInfo );
656 else
657 rInfo.SetRowInfo( 0, nullptr );
659 // limit to visible area
661 rInfo.SetTab( nTab );
662 rInfo.LimitToArea( rVisiblePixel );
665 tools::Rectangle ScPreviewLocationData::GetHeaderCellOutputRect(const tools::Rectangle& rVisRect, const ScAddress& rCellPos, bool bColHeader) const
667 // first a stupid implementation
668 // NN says here should be done more
669 tools::Rectangle aClipRect;
670 ScPreviewTableInfo aTableInfo;
671 GetTableInfo( rVisRect, aTableInfo );
673 if ( (rCellPos.Col() >= 0) &&
674 (rCellPos.Row() >= 0) && (rCellPos.Col() < aTableInfo.GetCols()) &&
675 (rCellPos.Row() < aTableInfo.GetRows()) )
677 SCCOL nCol(0);
678 SCROW nRow(0);
679 if (bColHeader)
680 nCol = rCellPos.Col();
681 else
682 nRow = rCellPos.Row();
683 const ScPreviewColRowInfo& rColInfo = aTableInfo.GetColInfo()[nCol];
684 const ScPreviewColRowInfo& rRowInfo = aTableInfo.GetRowInfo()[nRow];
686 if ( rColInfo.bIsHeader || rRowInfo.bIsHeader )
687 aClipRect = tools::Rectangle( rColInfo.nPixelStart, rRowInfo.nPixelStart, rColInfo.nPixelEnd, rRowInfo.nPixelEnd );
689 return aClipRect;
692 tools::Rectangle ScPreviewLocationData::GetCellOutputRect(const ScAddress& rCellPos) const
694 // first a stupid implementation
695 // NN says here should be done more
696 tools::Rectangle aRect;
697 GetCellPosition(rCellPos, aRect);
698 return aRect;
701 // GetMainCellRange is used for links in PDF export
703 bool ScPreviewLocationData::GetMainCellRange( ScRange& rRange, tools::Rectangle& rPixRect ) const
705 for (auto const& it : m_Entries)
707 if ( it->eType == SC_PLOC_CELLRANGE && !it->bRepeatCol && !it->bRepeatRow )
709 rRange = it->aCellRange;
710 rPixRect = it->aPixelRect;
711 return true;
715 return false;
718 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */