LibreOffice Module sc (master)  1
prevloc.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <prevloc.hxx>
21 #include <document.hxx>
22 
23 #include <o3tl/unit_conversion.hxx>
24 #include <osl/diagnose.h>
25 #include <vcl/outdev.hxx>
26 
27 namespace {
28 
30 {
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
40 };
41 
42 }
43 
45 {
49  bool bRepeatCol;
50  bool bRepeatRow;
51 
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 )
59  {
60  }
61 };
62 
64  nTab(0),
65  nCols(0),
66  nRows(0)
67 {
68 }
69 
71 {
72 }
73 
75 {
76  nTab = nNewTab;
77 }
78 
80 {
81  pColInfo.reset(pNewInfo);
82  nCols = nCount;
83 }
84 
86 {
87  pRowInfo.reset(pNewInfo);
88  nRows = nCount;
89 }
90 
92 {
93  if ( pColInfo )
94  {
95  // cells completely left of the visible area
96  SCCOL nStart = 0;
97  while ( nStart < nCols && pColInfo[nStart].nPixelEnd < rPixelArea.Left() )
98  ++nStart;
99 
100  // cells completely right of the visible area
101  SCCOL nEnd = nCols;
102  while ( nEnd > 0 && pColInfo[nEnd-1].nPixelStart > rPixelArea.Right() )
103  --nEnd;
104 
105  if ( nStart > 0 || nEnd < nCols )
106  {
107  if ( nEnd > nStart )
108  {
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 );
114  }
115  else
116  SetColInfo( 0, nullptr ); // all invisible
117  }
118  }
119 
120  if ( !pRowInfo )
121  return;
122 
123  // cells completely above the visible area
124  SCROW nStart = 0;
125  while ( nStart < nRows && pRowInfo[nStart].nPixelEnd < rPixelArea.Top() )
126  ++nStart;
127 
128  // cells completely below the visible area
129  SCROW nEnd = nRows;
130  while ( nEnd > 0 && pRowInfo[nEnd-1].nPixelStart > rPixelArea.Bottom() )
131  --nEnd;
132 
133  if ( nStart <= 0 && nEnd >= nRows )
134  return;
135 
136  if ( nEnd > nStart )
137  {
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 );
143  }
144  else
145  SetRowInfo( 0, nullptr ); // all invisible
146 }
147 
149  pWindow( pWin ),
150  pDoc( pDocument ),
151  nDrawRanges( 0 ),
152  nPrintTab( 0 )
153 {
154 }
155 
157 {
158  Clear();
159 }
160 
162 {
163  aCellMapMode = rMapMode;
164 }
165 
167 {
168  nPrintTab = nNew;
169 }
170 
172 {
173  m_Entries.clear();
174 
175  nDrawRanges = 0;
176 }
177 
178 void ScPreviewLocationData::AddCellRange( const tools::Rectangle& rRect, const ScRange& rRange, bool bRepCol, bool bRepRow,
179  const MapMode& rDrawMap )
180 {
181  tools::Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
182  m_Entries.push_front( std::make_unique<ScPreviewLocationEntry>(SC_PLOC_CELLRANGE, aPixelRect, rRange, bRepCol, bRepRow) );
183 
184  OSL_ENSURE( nDrawRanges < SC_PREVIEW_MAXRANGES, "too many ranges" );
185 
187  return;
188 
189  aDrawRectangle[nDrawRanges] = aPixelRect;
190  aDrawMapMode[nDrawRanges] = rDrawMap;
191 
192  if (bRepCol)
193  {
194  if (bRepRow)
196  else
198  }
199  else
200  {
201  if (bRepRow)
203  else
205  }
206 
207  ++nDrawRanges;
208 }
209 
210 void ScPreviewLocationData::AddColHeaders( const tools::Rectangle& rRect, SCCOL nStartCol, SCCOL nEndCol, bool bRepCol )
211 {
212  SCTAB nTab = 0;
213  ScRange aRange( nStartCol, 0, nTab, nEndCol, 0, nTab );
214  tools::Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
215 
216  m_Entries.push_front( std::make_unique<ScPreviewLocationEntry>(SC_PLOC_COLHEADER, aPixelRect, aRange, bRepCol, false) );
217 }
218 
219 void ScPreviewLocationData::AddRowHeaders( const tools::Rectangle& rRect, SCROW nStartRow, SCROW nEndRow, bool bRepRow )
220 {
221  SCTAB nTab = 0;
222  ScRange aRange( 0, nStartRow, nTab, 0, nEndRow, nTab );
223  tools::Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
224 
225  m_Entries.push_front( std::make_unique<ScPreviewLocationEntry>(SC_PLOC_ROWHEADER, aPixelRect, aRange, false, bRepRow) );
226 }
227 
228 void ScPreviewLocationData::AddHeaderFooter( const tools::Rectangle& rRect, bool bHeader, bool bLeft )
229 {
230  ScRange aRange;
231  tools::Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
232 
233  ScPreviewLocationType eType = bHeader ?
234  ( bLeft ? SC_PLOC_LEFTHEADER : SC_PLOC_RIGHTHEADER ) :
235  ( bLeft ? SC_PLOC_LEFTFOOTER : SC_PLOC_RIGHTFOOTER );
236 
237  m_Entries.push_front( std::make_unique<ScPreviewLocationEntry>(eType, aPixelRect, aRange, false, false) );
238 }
239 
241 {
242  ScRange aRange( rPos );
243  tools::Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
244 
245  m_Entries.push_front( std::make_unique<ScPreviewLocationEntry>(SC_PLOC_NOTEMARK, aPixelRect, aRange, false, false) );
246 }
247 
249 {
250  ScRange aRange( rPos );
251  tools::Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
252 
253  m_Entries.push_front( std::make_unique<ScPreviewLocationEntry>(SC_PLOC_NOTETEXT, aPixelRect, aRange, false, false) );
254 }
255 
256 void ScPreviewLocationData::GetDrawRange( sal_uInt16 nPos, tools::Rectangle& rPixelRect, MapMode& rMapMode, sal_uInt8& rRangeId ) const
257 {
258  OSL_ENSURE( nPos < nDrawRanges, "wrong position" );
259  if ( nPos < nDrawRanges )
260  {
261  rPixelRect = aDrawRectangle[nPos];
262  rMapMode = aDrawMapMode[nPos];
263  rRangeId = aDrawRangeId[nPos];
264  }
265 }
266 
268  ScPreviewLocationData::Entries_t const& rEntries,
269  const ScAddress& rPos, ScPreviewLocationType const eType)
270 {
271  for (auto const& it : rEntries)
272  {
273  if ( it->eType == eType && it->aCellRange.Contains( rPos ) )
274  return it.get();
275  }
276 
277  return nullptr;
278 }
279 
281 {
282  SCTAB nTab = rRange.aStart.Tab();
283 
284  tools::Long nPosX = 0;
285  SCCOL nEndCol = rCellPos.Col();
286  for (SCCOL nCol = rRange.aStart.Col(); nCol < nEndCol; nCol++)
287  {
288  sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
289  if (nDocW)
291  }
292  const tools::Long nSizeX
294 
295  SCROW nEndRow = rCellPos.Row();
296  tools::Long nPosY = o3tl::convert(pDoc->GetRowHeight(rRange.aStart.Row(), nEndRow, nTab),
298  tools::Long nSizeY
300 
301  Size aOffsetLogic( nPosX, nPosY );
302  Size aSizeLogic( nSizeX, nSizeY );
303  Size aOffsetPixel = pWindow->LogicToPixel( aOffsetLogic, aCellMapMode );
304  Size aSizePixel = pWindow->LogicToPixel( aSizeLogic, aCellMapMode );
305 
306  return tools::Rectangle( Point( aOffsetPixel.Width(), aOffsetPixel.Height() ), aSizePixel );
307 }
308 
309 void ScPreviewLocationData::GetCellPosition( const ScAddress& rCellPos, tools::Rectangle& rCellRect ) const
310 {
311  ScPreviewLocationEntry* pEntry = lcl_GetEntryByAddress( m_Entries, rCellPos, SC_PLOC_CELLRANGE );
312  if ( pEntry )
313  {
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() );
319  }
320 }
321 
323 {
324  for (auto const& it : m_Entries)
325  {
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;
329  }
330 
331  return false;
332 }
333 
335 {
336  for (auto const& it : m_Entries)
337  {
338  if ( it->eType == SC_PLOC_LEFTHEADER || it->eType == SC_PLOC_RIGHTHEADER )
339  {
340  rRect = it->aPixelRect;
341  return true;
342  }
343  }
344 
345  return false;
346 }
347 
349 {
350  for (auto const& it : m_Entries)
351  {
352  if ( it->eType == SC_PLOC_LEFTFOOTER || it->eType == SC_PLOC_RIGHTFOOTER )
353  {
354  rRect = it->aPixelRect;
355  return true;
356  }
357  }
358 
359  return false;
360 }
361 
363 {
364  for (auto const& it : m_Entries)
365  {
366  if ( it->eType == SC_PLOC_LEFTHEADER )
367  return true;
368 
369  if ( it->eType == SC_PLOC_RIGHTHEADER )
370  return false;
371  }
372 
373  return false;
374 }
375 
377 {
378  for (auto const& it : m_Entries)
379  {
380  if ( it->eType == SC_PLOC_LEFTFOOTER )
381  return true;
382 
383  if ( it->eType == SC_PLOC_RIGHTFOOTER )
384  return false;
385  }
386 
387  return false;
388 }
389 
390 tools::Long ScPreviewLocationData::GetNoteCountInRange( const tools::Rectangle& rVisiblePixel, bool bNoteMarks ) const
391 {
392  ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
393 
394  sal_uLong nRet = 0;
395  for (auto const& it : m_Entries)
396  {
397  if ( it->eType == eType && it->aPixelRect.Overlaps( rVisiblePixel ) )
398  ++nRet;
399  }
400 
401  return nRet;
402 }
403 
404 bool ScPreviewLocationData::GetNoteInRange( const tools::Rectangle& rVisiblePixel, tools::Long nIndex, bool bNoteMarks,
405  ScAddress& rCellPos, tools::Rectangle& rNoteRect ) const
406 {
407  ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
408 
409  sal_uLong nPos = 0;
410  for (auto const& it : m_Entries)
411  {
412  if ( it->eType == eType && it->aPixelRect.Overlaps( rVisiblePixel ) )
413  {
414  if ( nPos == sal::static_int_cast<sal_uLong>(nIndex) )
415  {
416  rCellPos = it->aCellRange.aStart;
417  rNoteRect = it->aPixelRect;
418  return true;
419  }
420  ++nPos;
421  }
422  }
423 
424  return false;
425 }
426 
427 tools::Rectangle ScPreviewLocationData::GetNoteInRangeOutputRect(const tools::Rectangle& rVisiblePixel, bool bNoteMarks, const ScAddress& aCellPos) const
428 {
429  ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
430 
431  for (auto const& it : m_Entries)
432  {
433  if ( it->eType == eType && it->aPixelRect.Overlaps( rVisiblePixel ) )
434  {
435  if ( aCellPos == it->aCellRange.aStart )
436  return it->aPixelRect;
437  }
438  }
439 
440  return tools::Rectangle();
441 }
442 
444 {
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;
453 
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;
462 
463  tools::Rectangle aHeaderRect, aRepeatRect, aMainRect;
464  SCTAB nTab = 0;
465 
466  for (auto const& it : m_Entries)
467  {
468  if ( it->eType == SC_PLOC_CELLRANGE )
469  {
470  if ( it->bRepeatCol )
471  {
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() );
477  }
478  else
479  {
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() );
485  }
486  if ( it->bRepeatRow )
487  {
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() );
493  }
494  else
495  {
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() );
501  }
502  nTab = it->aCellRange.aStart.Tab();
503  }
504  else if ( it->eType == SC_PLOC_ROWHEADER )
505  {
506  // row headers result in an additional column
507  bHasHeaderCol = true;
508  aHeaderRect.SetLeft( it->aPixelRect.Left() );
509  aHeaderRect.SetRight( it->aPixelRect.Right() );
510  }
511  else if ( it->eType == SC_PLOC_COLHEADER )
512  {
513  // column headers result in an additional row
514  bHasHeaderRow = true;
515  aHeaderRect.SetTop( it->aPixelRect.Top() );
516  aHeaderRect.SetBottom( it->aPixelRect.Bottom() );
517  }
518  }
519 
520  // get column info
521 
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;
534 
535  if ( nColCount > 0 )
536  {
537  ScPreviewColRowInfo* pColInfo = new ScPreviewColRowInfo[ nColCount ];
538  SCCOL nColPos = 0;
539 
540  if ( bHasHeaderCol )
541  {
542  pColInfo[nColPos].Set( true, 0, aHeaderRect.Left(), aHeaderRect.Right() );
543  ++nColPos;
544  }
545  if ( bHasRepCols )
546  {
547  tools::Long nPosX = 0;
548  for ( nCol=nRepeatColStart; nCol<=nRepeatColEnd; nCol++ )
549  if (!pDoc->ColHidden(nCol, nTab))
550  {
551  sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
552  tools::Long nNextX
554 
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 );
560 
561  nPosX = nNextX;
562  ++nColPos;
563  }
564  }
565  if ( bHasMainCols )
566  {
567  tools::Long nPosX = 0;
568  for ( nCol=nMainColStart; nCol<=nMainColEnd; nCol++ )
569  if (!pDoc->ColHidden(nCol, nTab))
570  {
571  sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
572  tools::Long nNextX
574 
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 );
580 
581  nPosX = nNextX;
582  ++nColPos;
583  }
584  }
585  rInfo.SetColInfo( nColCount, pColInfo );
586  }
587  else
588  rInfo.SetColInfo( 0, nullptr );
589 
590  // get row info
591 
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);
599 
600  if ( nRowCount > 0 )
601  {
602  ScPreviewColRowInfo* pRowInfo = new ScPreviewColRowInfo[ nRowCount ];
603  SCROW nRowPos = 0;
604 
605  if ( bHasHeaderRow )
606  {
607  pRowInfo[nRowPos].Set( true, 0, aHeaderRect.Top(), aHeaderRect.Bottom() );
608  ++nRowPos;
609  }
610  if ( bHasRepRows )
611  {
612  tools::Long nPosY = 0;
613  for (SCROW nRow = nRepeatRowStart; nRow <= nRepeatRowEnd; ++nRow)
614  {
615  if (pDoc->RowHidden(nRow, nTab))
616  continue;
617 
618  sal_uInt16 nDocH = pDoc->GetOriginalHeight( nRow, nTab );
619  tools::Long nNextY
621 
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 );
627 
628  nPosY = nNextY;
629  ++nRowPos;
630  }
631  }
632  if ( bHasMainRows )
633  {
634  tools::Long nPosY = 0;
635  for (SCROW nRow = nMainRowStart; nRow <= nMainRowEnd; ++nRow)
636  {
637  if (pDoc->RowHidden(nRow, nTab))
638  continue;
639 
640  sal_uInt16 nDocH = pDoc->GetOriginalHeight( nRow, nTab );
641  tools::Long nNextY
643 
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 );
649 
650  nPosY = nNextY;
651  ++nRowPos;
652  }
653  }
654  rInfo.SetRowInfo( nRowCount, pRowInfo );
655  }
656  else
657  rInfo.SetRowInfo( 0, nullptr );
658 
659  // limit to visible area
660 
661  rInfo.SetTab( nTab );
662  rInfo.LimitToArea( rVisiblePixel );
663 }
664 
665 tools::Rectangle ScPreviewLocationData::GetHeaderCellOutputRect(const tools::Rectangle& rVisRect, const ScAddress& rCellPos, bool bColHeader) const
666 {
667  // first a stupid implementation
668  // NN says here should be done more
669  tools::Rectangle aClipRect;
670  ScPreviewTableInfo aTableInfo;
671  GetTableInfo( rVisRect, aTableInfo );
672 
673  if ( (rCellPos.Col() >= 0) &&
674  (rCellPos.Row() >= 0) && (rCellPos.Col() < aTableInfo.GetCols()) &&
675  (rCellPos.Row() < aTableInfo.GetRows()) )
676  {
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];
685 
686  if ( rColInfo.bIsHeader || rRowInfo.bIsHeader )
687  aClipRect = tools::Rectangle( rColInfo.nPixelStart, rRowInfo.nPixelStart, rColInfo.nPixelEnd, rRowInfo.nPixelEnd );
688  }
689  return aClipRect;
690 }
691 
693 {
694  // first a stupid implementation
695  // NN says here should be done more
696  tools::Rectangle aRect;
697  GetCellPosition(rCellPos, aRect);
698  return aRect;
699 }
700 
701 // GetMainCellRange is used for links in PDF export
702 
704 {
705  for (auto const& it : m_Entries)
706  {
707  if ( it->eType == SC_PLOC_CELLRANGE && !it->bRepeatCol && !it->bRepeatRow )
708  {
709  rRange = it->aCellRange;
710  rPixRect = it->aPixelRect;
711  return true;
712  }
713  }
714 
715  return false;
716 }
717 
718 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void LimitToArea(const tools::Rectangle &rPixelArea)
Definition: prevloc.cxx:91
sal_uInt16 nDrawRanges
Definition: prevloc.hxx:96
ScAddress aStart
Definition: address.hxx:497
SCROW Row() const
Definition: address.hxx:274
tools::Long nPixelStart
Definition: prevloc.hxx:47
constexpr tools::Long Left() const
#define SC_PREVIEW_RANGE_REPROW
Definition: prevloc.hxx:36
sal_uIntPtr sal_uLong
long Long
tools::Rectangle GetOffsetPixel(const ScAddress &rCellPos, const ScRange &rRange) const
Definition: prevloc.cxx:280
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
tools::Rectangle GetNoteInRangeOutputRect(const tools::Rectangle &rVisiblePixel, bool bNoteMarks, const ScAddress &aCellPos) const
Definition: prevloc.cxx:427
void AddNoteText(const tools::Rectangle &rRect, const ScAddress &rPos)
Definition: prevloc.cxx:248
void GetCellPosition(const ScAddress &rCellPos, tools::Rectangle &rCellRect) const
Definition: prevloc.cxx:309
VclPtr< OutputDevice > pWindow
Definition: prevloc.hxx:90
#define SC_PREVIEW_MAXRANGES
Definition: prevloc.hxx:33
tools::Rectangle GetCellOutputRect(const ScAddress &rCellPos) const
Definition: prevloc.cxx:692
std::list< std::unique_ptr< ScPreviewLocationEntry > > Entries_t
Definition: prevloc.hxx:88
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4211
ScPreviewLocationEntry(ScPreviewLocationType eNewType, const tools::Rectangle &rPixel, const ScRange &rRange, bool bRepCol, bool bRepRow)
Definition: prevloc.cxx:52
constexpr tools::Long Width() const
static ScPreviewLocationEntry * lcl_GetEntryByAddress(ScPreviewLocationData::Entries_t const &rEntries, const ScAddress &rPos, ScPreviewLocationType const eType)
Definition: prevloc.cxx:267
bool GetNoteInRange(const tools::Rectangle &rVisiblePixel, tools::Long nIndex, bool bNoteMarks, ScAddress &rCellPos, tools::Rectangle &rNoteRect) const
Definition: prevloc.cxx:404
void Set(bool bHeader, SCCOLROW nIndex, tools::Long nStart, tools::Long nEnd)
Definition: prevloc.hxx:50
void AddNoteMark(const tools::Rectangle &rRect, const ScAddress &rPos)
Definition: prevloc.cxx:240
tools::Rectangle GetHeaderCellOutputRect(const tools::Rectangle &rVisRect, const ScAddress &rCellPos, bool bColHeader) const
Definition: prevloc.cxx:665
SCTAB Tab() const
Definition: address.hxx:283
void AddHeaderFooter(const tools::Rectangle &rRect, bool bHeader, bool bLeft)
Definition: prevloc.cxx:228
ScPreviewLocationData(ScDocument *pDocument, OutputDevice *pWin)
Definition: prevloc.cxx:148
SCROW GetRows() const
Definition: prevloc.hxx:75
constexpr void SetLeft(tools::Long v)
DocumentType eType
const ScPreviewColRowInfo * GetRowInfo() const
Definition: prevloc.hxx:77
void SetTab(SCTAB nNewTab)
Definition: prevloc.cxx:74
std::unique_ptr< ScPreviewColRowInfo[]> pRowInfo
Definition: prevloc.hxx:67
bool GetFooterPosition(tools::Rectangle &rFooterRect) const
Definition: prevloc.cxx:348
SC_DLLPUBLIC bool ColHidden(SCCOL nCol, SCTAB nTab, SCCOL *pFirstCol=nullptr, SCCOL *pLastCol=nullptr) const
Definition: document.cxx:4495
bool IsFooterLeft() const
Definition: prevloc.cxx:376
sal_uInt8 aDrawRangeId[SC_PREVIEW_MAXRANGES]
Definition: prevloc.hxx:95
int i
void SetRowInfo(SCROW nCount, ScPreviewColRowInfo *pNewInfo)
Definition: prevloc.cxx:85
ScPreviewLocationType
Definition: prevloc.cxx:29
MapMode aDrawMapMode[SC_PREVIEW_MAXRANGES]
Definition: prevloc.hxx:93
#define SC_PREVIEW_RANGE_TAB
Definition: prevloc.hxx:37
sal_Int16 SCCOL
Definition: types.hxx:21
bool HasCellsInRange(const tools::Rectangle &rVisiblePixel) const
Definition: prevloc.cxx:322
Entries_t m_Entries
Definition: prevloc.hxx:98
constexpr tools::Long Right() const
const ScPreviewColRowInfo * GetColInfo() const
Definition: prevloc.hxx:76
constexpr tools::Long Top() const
#define SC_PREVIEW_RANGE_REPCOL
Definition: prevloc.hxx:35
tools::Long nPixelEnd
Definition: prevloc.hxx:48
constexpr void SetRight(tools::Long v)
constexpr void SetBottom(tools::Long v)
void AddColHeaders(const tools::Rectangle &rRect, SCCOL nStartCol, SCCOL nEndCol, bool bRepCol)
Definition: prevloc.cxx:210
#define SC_PREVIEW_RANGE_EDGE
Definition: prevloc.hxx:34
bool IsHeaderLeft() const
Definition: prevloc.cxx:362
tools::Rectangle aDrawRectangle[SC_PREVIEW_MAXRANGES]
Definition: prevloc.hxx:94
constexpr void SetTop(tools::Long v)
void SetPrintTab(SCTAB nNew)
Definition: prevloc.cxx:166
SCCOL Col() const
Definition: address.hxx:279
std::unique_ptr< ScPreviewColRowInfo[]> pColInfo
Definition: prevloc.hxx:65
constexpr tools::Long Bottom() const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
void AddRowHeaders(const tools::Rectangle &rRect, SCROW nStartRow, SCROW nEndRow, bool bRepRow)
Definition: prevloc.cxx:219
ScDocument * pDoc
Definition: prevloc.hxx:91
sal_Int32 SCROW
Definition: types.hxx:17
SC_DLLPUBLIC sal_uInt16 GetOriginalHeight(SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4203
constexpr tools::Long Height() const
unsigned char sal_uInt8
tools::Long GetNoteCountInRange(const tools::Rectangle &rVisiblePixel, bool bNoteMarks) const
Definition: prevloc.cxx:390
void AddCellRange(const tools::Rectangle &rRect, const ScRange &rRange, bool bRepCol, bool bRepRow, const MapMode &rDrawMap)
Definition: prevloc.cxx:178
void GetDrawRange(sal_uInt16 nPos, tools::Rectangle &rPixelRect, MapMode &rMapMode, sal_uInt8 &rRangeId) const
Definition: prevloc.cxx:256
SCCOL GetCols() const
Definition: prevloc.hxx:74
ScPreviewLocationType eType
Definition: prevloc.cxx:48
SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
Definition: document.cxx:4479
void SetCellMapMode(const MapMode &rMapMode)
Definition: prevloc.cxx:161
void SetColInfo(SCCOL nCount, ScPreviewColRowInfo *pNewInfo)
Definition: prevloc.cxx:79
tools::Rectangle aPixelRect
Definition: prevloc.cxx:46
bool GetMainCellRange(ScRange &rRange, tools::Rectangle &rPixRect) const
Definition: prevloc.cxx:703
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4170
SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const
Definition: document.cxx:4541
void GetTableInfo(const tools::Rectangle &rVisiblePixel, ScPreviewTableInfo &rInfo) const
Definition: prevloc.cxx:443
sal_uInt16 nPos
sal_Int16 SCTAB
Definition: types.hxx:22
bool GetHeaderPosition(tools::Rectangle &rHeaderRect) const
Definition: prevloc.cxx:334