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  eType( eNewType ),
55  aPixelRect( rPixel ),
56  aCellRange( rRange ),
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.In( 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.IsOver( 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.IsOver( 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.IsOver( 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  sal_uLong nPos = 0;
432  for (auto const& it : m_Entries)
433  {
434  if ( it->eType == eType && it->aPixelRect.IsOver( rVisiblePixel ) )
435  {
436  if ( aCellPos == it->aCellRange.aStart )
437  return it->aPixelRect;
438  ++nPos;
439  }
440  }
441 
442  return tools::Rectangle();
443 }
444 
446 {
447  // from left to right:
448  bool bHasHeaderCol = false;
449  bool bHasRepCols = false;
450  bool bHasMainCols = false;
451  SCCOL nRepeatColStart = 0;
452  SCCOL nRepeatColEnd = 0;
453  SCCOL nMainColStart = 0;
454  SCCOL nMainColEnd = 0;
455 
456  // from top to bottom:
457  bool bHasHeaderRow = false;
458  bool bHasRepRows = false;
459  bool bHasMainRows = false;
460  SCROW nRepeatRowStart = 0;
461  SCROW nRepeatRowEnd = 0;
462  SCROW nMainRowStart = 0;
463  SCROW nMainRowEnd = 0;
464 
465  tools::Rectangle aHeaderRect, aRepeatRect, aMainRect;
466  SCTAB nTab = 0;
467 
468  for (auto const& it : m_Entries)
469  {
470  if ( it->eType == SC_PLOC_CELLRANGE )
471  {
472  if ( it->bRepeatCol )
473  {
474  bHasRepCols = true;
475  nRepeatColStart = it->aCellRange.aStart.Col();
476  nRepeatColEnd = it->aCellRange.aEnd.Col();
477  aRepeatRect.SetLeft( it->aPixelRect.Left() );
478  aRepeatRect.SetRight( it->aPixelRect.Right() );
479  }
480  else
481  {
482  bHasMainCols = true;
483  nMainColStart = it->aCellRange.aStart.Col();
484  nMainColEnd = it->aCellRange.aEnd.Col();
485  aMainRect.SetLeft( it->aPixelRect.Left() );
486  aMainRect.SetRight( it->aPixelRect.Right() );
487  }
488  if ( it->bRepeatRow )
489  {
490  bHasRepRows = true;
491  nRepeatRowStart = it->aCellRange.aStart.Row();
492  nRepeatRowEnd = it->aCellRange.aEnd.Row();
493  aRepeatRect.SetTop( it->aPixelRect.Top() );
494  aRepeatRect.SetBottom( it->aPixelRect.Bottom() );
495  }
496  else
497  {
498  bHasMainRows = true;
499  nMainRowStart = it->aCellRange.aStart.Row();
500  nMainRowEnd = it->aCellRange.aEnd.Row();
501  aMainRect.SetTop( it->aPixelRect.Top() );
502  aMainRect.SetBottom( it->aPixelRect.Bottom() );
503  }
504  nTab = it->aCellRange.aStart.Tab();
505  }
506  else if ( it->eType == SC_PLOC_ROWHEADER )
507  {
508  // row headers result in an additional column
509  bHasHeaderCol = true;
510  aHeaderRect.SetLeft( it->aPixelRect.Left() );
511  aHeaderRect.SetRight( it->aPixelRect.Right() );
512  }
513  else if ( it->eType == SC_PLOC_COLHEADER )
514  {
515  // column headers result in an additional row
516  bHasHeaderRow = true;
517  aHeaderRect.SetTop( it->aPixelRect.Top() );
518  aHeaderRect.SetBottom( it->aPixelRect.Bottom() );
519  }
520  }
521 
522  // get column info
523 
524  SCCOL nColCount = 0;
525  SCCOL nCol;
526  if ( bHasHeaderCol )
527  ++nColCount;
528  if ( bHasRepCols )
529  for ( nCol=nRepeatColStart; nCol<=nRepeatColEnd; nCol++ )
530  if (!pDoc->ColHidden(nCol, nTab))
531  ++nColCount;
532  if ( bHasMainCols )
533  for ( nCol=nMainColStart; nCol<=nMainColEnd; nCol++ )
534  if (!pDoc->ColHidden(nCol, nTab))
535  ++nColCount;
536 
537  if ( nColCount > 0 )
538  {
539  ScPreviewColRowInfo* pColInfo = new ScPreviewColRowInfo[ nColCount ];
540  SCCOL nColPos = 0;
541 
542  if ( bHasHeaderCol )
543  {
544  pColInfo[nColPos].Set( true, 0, aHeaderRect.Left(), aHeaderRect.Right() );
545  ++nColPos;
546  }
547  if ( bHasRepCols )
548  {
549  tools::Long nPosX = 0;
550  for ( nCol=nRepeatColStart; nCol<=nRepeatColEnd; nCol++ )
551  if (!pDoc->ColHidden(nCol, nTab))
552  {
553  sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
554  tools::Long nNextX
556 
557  tools::Long nPixelStart = pWindow->LogicToPixel( Size( nPosX, 0 ), aCellMapMode ).Width();
558  tools::Long nPixelEnd = pWindow->LogicToPixel( Size( nNextX, 0 ), aCellMapMode ).Width() - 1;
559  pColInfo[nColPos].Set( false, nCol,
560  aRepeatRect.Left() + nPixelStart,
561  aRepeatRect.Left() + nPixelEnd );
562 
563  nPosX = nNextX;
564  ++nColPos;
565  }
566  }
567  if ( bHasMainCols )
568  {
569  tools::Long nPosX = 0;
570  for ( nCol=nMainColStart; nCol<=nMainColEnd; nCol++ )
571  if (!pDoc->ColHidden(nCol, nTab))
572  {
573  sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
574  tools::Long nNextX
576 
577  tools::Long nPixelStart = pWindow->LogicToPixel( Size( nPosX, 0 ), aCellMapMode ).Width();
578  tools::Long nPixelEnd = pWindow->LogicToPixel( Size( nNextX, 0 ), aCellMapMode ).Width() - 1;
579  pColInfo[nColPos].Set( false, nCol,
580  aMainRect.Left() + nPixelStart,
581  aMainRect.Left() + nPixelEnd );
582 
583  nPosX = nNextX;
584  ++nColPos;
585  }
586  }
587  rInfo.SetColInfo( nColCount, pColInfo );
588  }
589  else
590  rInfo.SetColInfo( 0, nullptr );
591 
592  // get row info
593 
594  SCROW nRowCount = 0;
595  if ( bHasHeaderRow )
596  ++nRowCount;
597  if ( bHasRepRows )
598  nRowCount += pDoc->CountVisibleRows(nRepeatRowStart, nRepeatRowEnd, nTab);
599  if ( bHasMainRows )
600  nRowCount += pDoc->CountVisibleRows(nMainRowStart, nMainRowEnd, nTab);
601 
602  if ( nRowCount > 0 )
603  {
604  ScPreviewColRowInfo* pRowInfo = new ScPreviewColRowInfo[ nRowCount ];
605  SCROW nRowPos = 0;
606 
607  if ( bHasHeaderRow )
608  {
609  pRowInfo[nRowPos].Set( true, 0, aHeaderRect.Top(), aHeaderRect.Bottom() );
610  ++nRowPos;
611  }
612  if ( bHasRepRows )
613  {
614  tools::Long nPosY = 0;
615  for (SCROW nRow = nRepeatRowStart; nRow <= nRepeatRowEnd; ++nRow)
616  {
617  if (pDoc->RowHidden(nRow, nTab))
618  continue;
619 
620  sal_uInt16 nDocH = pDoc->GetOriginalHeight( nRow, nTab );
621  tools::Long nNextY
623 
624  tools::Long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height();
625  tools::Long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1;
626  pRowInfo[nRowPos].Set( false, nRow,
627  aRepeatRect.Top() + nPixelStart,
628  aRepeatRect.Top() + nPixelEnd );
629 
630  nPosY = nNextY;
631  ++nRowPos;
632  }
633  }
634  if ( bHasMainRows )
635  {
636  tools::Long nPosY = 0;
637  for (SCROW nRow = nMainRowStart; nRow <= nMainRowEnd; ++nRow)
638  {
639  if (pDoc->RowHidden(nRow, nTab))
640  continue;
641 
642  sal_uInt16 nDocH = pDoc->GetOriginalHeight( nRow, nTab );
643  tools::Long nNextY
645 
646  tools::Long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height();
647  tools::Long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1;
648  pRowInfo[nRowPos].Set( false, nRow,
649  aMainRect.Top() + nPixelStart,
650  aMainRect.Top() + nPixelEnd );
651 
652  nPosY = nNextY;
653  ++nRowPos;
654  }
655  }
656  rInfo.SetRowInfo( nRowCount, pRowInfo );
657  }
658  else
659  rInfo.SetRowInfo( 0, nullptr );
660 
661  // limit to visible area
662 
663  rInfo.SetTab( nTab );
664  rInfo.LimitToArea( rVisiblePixel );
665 }
666 
667 tools::Rectangle ScPreviewLocationData::GetHeaderCellOutputRect(const tools::Rectangle& rVisRect, const ScAddress& rCellPos, bool bColHeader) const
668 {
669  // first a stupid implementation
670  // NN says here should be done more
671  tools::Rectangle aClipRect;
672  ScPreviewTableInfo aTableInfo;
673  GetTableInfo( rVisRect, aTableInfo );
674 
675  if ( (rCellPos.Col() >= 0) &&
676  (rCellPos.Row() >= 0) && (rCellPos.Col() < aTableInfo.GetCols()) &&
677  (rCellPos.Row() < aTableInfo.GetRows()) )
678  {
679  SCCOL nCol(0);
680  SCROW nRow(0);
681  if (bColHeader)
682  nCol = rCellPos.Col();
683  else
684  nRow = rCellPos.Row();
685  const ScPreviewColRowInfo& rColInfo = aTableInfo.GetColInfo()[nCol];
686  const ScPreviewColRowInfo& rRowInfo = aTableInfo.GetRowInfo()[nRow];
687 
688  if ( rColInfo.bIsHeader || rRowInfo.bIsHeader )
689  aClipRect = tools::Rectangle( rColInfo.nPixelStart, rRowInfo.nPixelStart, rColInfo.nPixelEnd, rRowInfo.nPixelEnd );
690  }
691  return aClipRect;
692 }
693 
695 {
696  // first a stupid implementation
697  // NN says here should be done more
698  tools::Rectangle aRect;
699  GetCellPosition(rCellPos, aRect);
700  return aRect;
701 }
702 
703 // GetMainCellRange is used for links in PDF export
704 
706 {
707  for (auto const& it : m_Entries)
708  {
709  if ( it->eType == SC_PLOC_CELLRANGE && !it->bRepeatCol && !it->bRepeatRow )
710  {
711  rRange = it->aCellRange;
712  rPixRect = it->aPixelRect;
713  return true;
714  }
715  }
716 
717  return false;
718 }
719 
720 /* 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:499
SCROW Row() const
Definition: address.hxx:261
tools::Long nPixelStart
Definition: prevloc.hxx:47
#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
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:694
std::list< std::unique_ptr< ScPreviewLocationEntry > > Entries_t
Definition: prevloc.hxx:88
void SetRight(tools::Long v)
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4153
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
tools::Long Left() const
void SetLeft(tools::Long v)
ScPreviewLocationType
Definition: prevloc.cxx:29
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::Long Bottom() const
tools::Rectangle GetHeaderCellOutputRect(const tools::Rectangle &rVisRect, const ScAddress &rCellPos, bool bColHeader) const
Definition: prevloc.cxx:667
SCTAB Tab() const
Definition: address.hxx:270
void AddHeaderFooter(const tools::Rectangle &rRect, bool bHeader, bool bLeft)
Definition: prevloc.cxx:228
constexpr auto convert(N n, sal_Int64 mul, sal_Int64 div)
ScPreviewLocationData(ScDocument *pDocument, OutputDevice *pWin)
Definition: prevloc.cxx:148
SCROW GetRows() const
Definition: prevloc.hxx:75
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:4437
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
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
const ScPreviewColRowInfo * GetColInfo() const
Definition: prevloc.hxx:76
#define SC_PREVIEW_RANGE_REPCOL
Definition: prevloc.hxx:35
void SetTop(tools::Long v)
tools::Long nPixelEnd
Definition: prevloc.hxx:48
void SetBottom(tools::Long v)
void AddColHeaders(const tools::Rectangle &rRect, SCCOL nStartCol, SCCOL nEndCol, bool bRepCol)
Definition: prevloc.cxx:210
tools::Long Top() const
#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
void SetPrintTab(SCTAB nNew)
Definition: prevloc.cxx:166
SCCOL Col() const
Definition: address.hxx:266
std::unique_ptr< ScPreviewColRowInfo[]> pColInfo
Definition: prevloc.hxx:65
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:4145
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:46
SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
Definition: document.cxx:4421
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:47
bool GetMainCellRange(ScRange &rRange, tools::Rectangle &rPixRect) const
Definition: prevloc.cxx:705
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4112
SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const
Definition: document.cxx:4483
void GetTableInfo(const tools::Rectangle &rVisiblePixel, ScPreviewTableInfo &rInfo) const
Definition: prevloc.cxx:445
tools::Long Right() const
sal_uInt16 nPos
sal_Int16 SCTAB
Definition: types.hxx:22
bool GetHeaderPosition(tools::Rectangle &rHeaderRect) const
Definition: prevloc.cxx:334