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 <osl/diagnose.h>
24 #include <vcl/outdev.hxx>
25 
26 namespace {
27 
29 {
30  SC_PLOC_CELLRANGE,
31  SC_PLOC_COLHEADER,
32  SC_PLOC_ROWHEADER,
33  SC_PLOC_LEFTHEADER,
34  SC_PLOC_RIGHTHEADER,
35  SC_PLOC_LEFTFOOTER,
36  SC_PLOC_RIGHTFOOTER,
37  SC_PLOC_NOTEMARK,
38  SC_PLOC_NOTETEXT
39 };
40 
41 }
42 
44 {
48  bool bRepeatCol;
49  bool bRepeatRow;
50 
51  ScPreviewLocationEntry( ScPreviewLocationType eNewType, const tools::Rectangle& rPixel, const ScRange& rRange,
52  bool bRepCol, bool bRepRow ) :
53  eType( eNewType ),
54  aPixelRect( rPixel ),
55  aCellRange( rRange ),
56  bRepeatCol( bRepCol ),
57  bRepeatRow( bRepRow )
58  {
59  }
60 };
61 
63  nTab(0),
64  nCols(0),
65  nRows(0)
66 {
67 }
68 
70 {
71 }
72 
74 {
75  nTab = nNewTab;
76 }
77 
79 {
80  pColInfo.reset(pNewInfo);
81  nCols = nCount;
82 }
83 
85 {
86  pRowInfo.reset(pNewInfo);
87  nRows = nCount;
88 }
89 
91 {
92  if ( pColInfo )
93  {
94  // cells completely left of the visible area
95  SCCOL nStart = 0;
96  while ( nStart < nCols && pColInfo[nStart].nPixelEnd < rPixelArea.Left() )
97  ++nStart;
98 
99  // cells completely right of the visible area
100  SCCOL nEnd = nCols;
101  while ( nEnd > 0 && pColInfo[nEnd-1].nPixelStart > rPixelArea.Right() )
102  --nEnd;
103 
104  if ( nStart > 0 || nEnd < nCols )
105  {
106  if ( nEnd > nStart )
107  {
108  SCCOL nNewCount = nEnd - nStart;
109  ScPreviewColRowInfo* pNewInfo = new ScPreviewColRowInfo[nNewCount];
110  for (SCCOL i=0; i<nNewCount; i++)
111  pNewInfo[i] = pColInfo[nStart + i];
112  SetColInfo( nNewCount, pNewInfo );
113  }
114  else
115  SetColInfo( 0, nullptr ); // all invisible
116  }
117  }
118 
119  if ( !pRowInfo )
120  return;
121 
122  // cells completely above the visible area
123  SCROW nStart = 0;
124  while ( nStart < nRows && pRowInfo[nStart].nPixelEnd < rPixelArea.Top() )
125  ++nStart;
126 
127  // cells completely below the visible area
128  SCROW nEnd = nRows;
129  while ( nEnd > 0 && pRowInfo[nEnd-1].nPixelStart > rPixelArea.Bottom() )
130  --nEnd;
131 
132  if ( nStart <= 0 && nEnd >= nRows )
133  return;
134 
135  if ( nEnd > nStart )
136  {
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 );
142  }
143  else
144  SetRowInfo( 0, nullptr ); // all invisible
145 }
146 
148  pWindow( pWin ),
149  pDoc( pDocument ),
150  nDrawRanges( 0 ),
151  nPrintTab( 0 )
152 {
153 }
154 
156 {
157  Clear();
158 }
159 
161 {
162  aCellMapMode = rMapMode;
163 }
164 
166 {
167  nPrintTab = nNew;
168 }
169 
171 {
172  m_Entries.clear();
173 
174  nDrawRanges = 0;
175 }
176 
177 void ScPreviewLocationData::AddCellRange( const tools::Rectangle& rRect, const ScRange& rRange, bool bRepCol, bool bRepRow,
178  const MapMode& rDrawMap )
179 {
180  tools::Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
181  m_Entries.push_front( std::make_unique<ScPreviewLocationEntry>(SC_PLOC_CELLRANGE, aPixelRect, rRange, bRepCol, bRepRow) );
182 
183  OSL_ENSURE( nDrawRanges < SC_PREVIEW_MAXRANGES, "too many ranges" );
184 
186  return;
187 
188  aDrawRectangle[nDrawRanges] = aPixelRect;
189  aDrawMapMode[nDrawRanges] = rDrawMap;
190 
191  if (bRepCol)
192  {
193  if (bRepRow)
195  else
197  }
198  else
199  {
200  if (bRepRow)
202  else
204  }
205 
206  ++nDrawRanges;
207 }
208 
209 void ScPreviewLocationData::AddColHeaders( const tools::Rectangle& rRect, SCCOL nStartCol, SCCOL nEndCol, bool bRepCol )
210 {
211  SCTAB nTab = 0;
212  ScRange aRange( nStartCol, 0, nTab, nEndCol, 0, nTab );
213  tools::Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
214 
215  m_Entries.push_front( std::make_unique<ScPreviewLocationEntry>(SC_PLOC_COLHEADER, aPixelRect, aRange, bRepCol, false) );
216 }
217 
218 void ScPreviewLocationData::AddRowHeaders( const tools::Rectangle& rRect, SCROW nStartRow, SCROW nEndRow, bool bRepRow )
219 {
220  SCTAB nTab = 0;
221  ScRange aRange( 0, nStartRow, nTab, 0, nEndRow, nTab );
222  tools::Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
223 
224  m_Entries.push_front( std::make_unique<ScPreviewLocationEntry>(SC_PLOC_ROWHEADER, aPixelRect, aRange, false, bRepRow) );
225 }
226 
227 void ScPreviewLocationData::AddHeaderFooter( const tools::Rectangle& rRect, bool bHeader, bool bLeft )
228 {
229  ScRange aRange;
230  tools::Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
231 
232  ScPreviewLocationType eType = bHeader ?
233  ( bLeft ? SC_PLOC_LEFTHEADER : SC_PLOC_RIGHTHEADER ) :
234  ( bLeft ? SC_PLOC_LEFTFOOTER : SC_PLOC_RIGHTFOOTER );
235 
236  m_Entries.push_front( std::make_unique<ScPreviewLocationEntry>(eType, aPixelRect, aRange, false, false) );
237 }
238 
240 {
241  ScRange aRange( rPos );
242  tools::Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
243 
244  m_Entries.push_front( std::make_unique<ScPreviewLocationEntry>(SC_PLOC_NOTEMARK, aPixelRect, aRange, false, false) );
245 }
246 
248 {
249  ScRange aRange( rPos );
250  tools::Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
251 
252  m_Entries.push_front( std::make_unique<ScPreviewLocationEntry>(SC_PLOC_NOTETEXT, aPixelRect, aRange, false, false) );
253 }
254 
255 void ScPreviewLocationData::GetDrawRange( sal_uInt16 nPos, tools::Rectangle& rPixelRect, MapMode& rMapMode, sal_uInt8& rRangeId ) const
256 {
257  OSL_ENSURE( nPos < nDrawRanges, "wrong position" );
258  if ( nPos < nDrawRanges )
259  {
260  rPixelRect = aDrawRectangle[nPos];
261  rMapMode = aDrawMapMode[nPos];
262  rRangeId = aDrawRangeId[nPos];
263  }
264 }
265 
267  ScPreviewLocationData::Entries_t const& rEntries,
268  const ScAddress& rPos, ScPreviewLocationType const eType)
269 {
270  for (auto const& it : rEntries)
271  {
272  if ( it->eType == eType && it->aCellRange.In( rPos ) )
273  return it.get();
274  }
275 
276  return nullptr;
277 }
278 
280 {
281  const double nScaleX = HMM_PER_TWIPS;
282  const double nScaleY = HMM_PER_TWIPS;
283  SCTAB nTab = rRange.aStart.Tab();
284 
285  tools::Long nPosX = 0;
286  SCCOL nEndCol = rCellPos.Col();
287  for (SCCOL nCol = rRange.aStart.Col(); nCol < nEndCol; nCol++)
288  {
289  sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
290  if (nDocW)
291  nPosX += static_cast<tools::Long>(nDocW * nScaleX);
292  }
293  tools::Long nSizeX = static_cast<tools::Long>( pDoc->GetColWidth( nEndCol, nTab ) * nScaleX );
294 
295  SCROW nEndRow = rCellPos.Row();
296  tools::Long nPosY = static_cast<tools::Long>(pDoc->GetScaledRowHeight( rRange.aStart.Row(),
297  nEndRow, nTab, nScaleY));
298  tools::Long nSizeY = static_cast<tools::Long>( pDoc->GetRowHeight( nEndRow, nTab ) * nScaleY );
299 
300  Size aOffsetLogic( nPosX, nPosY );
301  Size aSizeLogic( nSizeX, nSizeY );
302  Size aOffsetPixel = pWindow->LogicToPixel( aOffsetLogic, aCellMapMode );
303  Size aSizePixel = pWindow->LogicToPixel( aSizeLogic, aCellMapMode );
304 
305  return tools::Rectangle( Point( aOffsetPixel.Width(), aOffsetPixel.Height() ), aSizePixel );
306 }
307 
308 void ScPreviewLocationData::GetCellPosition( const ScAddress& rCellPos, tools::Rectangle& rCellRect ) const
309 {
310  ScPreviewLocationEntry* pEntry = lcl_GetEntryByAddress( m_Entries, rCellPos, SC_PLOC_CELLRANGE );
311  if ( pEntry )
312  {
313  tools::Rectangle aOffsetRect = GetOffsetPixel( rCellPos, pEntry->aCellRange );
314  rCellRect = tools::Rectangle( aOffsetRect.Left() + pEntry->aPixelRect.Left(),
315  aOffsetRect.Top() + pEntry->aPixelRect.Top(),
316  aOffsetRect.Right() + pEntry->aPixelRect.Left(),
317  aOffsetRect.Bottom() + pEntry->aPixelRect.Top() );
318  }
319 }
320 
322 {
323  for (auto const& it : m_Entries)
324  {
325  if ( it->eType == SC_PLOC_CELLRANGE || it->eType == SC_PLOC_COLHEADER || it->eType == SC_PLOC_ROWHEADER )
326  if ( it->aPixelRect.IsOver( rVisiblePixel ) )
327  return true;
328  }
329 
330  return false;
331 }
332 
334 {
335  for (auto const& it : m_Entries)
336  {
337  if ( it->eType == SC_PLOC_LEFTHEADER || it->eType == SC_PLOC_RIGHTHEADER )
338  {
339  rRect = it->aPixelRect;
340  return true;
341  }
342  }
343 
344  return false;
345 }
346 
348 {
349  for (auto const& it : m_Entries)
350  {
351  if ( it->eType == SC_PLOC_LEFTFOOTER || it->eType == SC_PLOC_RIGHTFOOTER )
352  {
353  rRect = it->aPixelRect;
354  return true;
355  }
356  }
357 
358  return false;
359 }
360 
362 {
363  for (auto const& it : m_Entries)
364  {
365  if ( it->eType == SC_PLOC_LEFTHEADER )
366  return true;
367 
368  if ( it->eType == SC_PLOC_RIGHTHEADER )
369  return false;
370  }
371 
372  return false;
373 }
374 
376 {
377  for (auto const& it : m_Entries)
378  {
379  if ( it->eType == SC_PLOC_LEFTFOOTER )
380  return true;
381 
382  if ( it->eType == SC_PLOC_RIGHTFOOTER )
383  return false;
384  }
385 
386  return false;
387 }
388 
389 tools::Long ScPreviewLocationData::GetNoteCountInRange( const tools::Rectangle& rVisiblePixel, bool bNoteMarks ) const
390 {
391  ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
392 
393  sal_uLong nRet = 0;
394  for (auto const& it : m_Entries)
395  {
396  if ( it->eType == eType && it->aPixelRect.IsOver( rVisiblePixel ) )
397  ++nRet;
398  }
399 
400  return nRet;
401 }
402 
403 bool ScPreviewLocationData::GetNoteInRange( const tools::Rectangle& rVisiblePixel, tools::Long nIndex, bool bNoteMarks,
404  ScAddress& rCellPos, tools::Rectangle& rNoteRect ) const
405 {
406  ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
407 
408  sal_uLong nPos = 0;
409  for (auto const& it : m_Entries)
410  {
411  if ( it->eType == eType && it->aPixelRect.IsOver( rVisiblePixel ) )
412  {
413  if ( nPos == sal::static_int_cast<sal_uLong>(nIndex) )
414  {
415  rCellPos = it->aCellRange.aStart;
416  rNoteRect = it->aPixelRect;
417  return true;
418  }
419  ++nPos;
420  }
421  }
422 
423  return false;
424 }
425 
426 tools::Rectangle ScPreviewLocationData::GetNoteInRangeOutputRect(const tools::Rectangle& rVisiblePixel, bool bNoteMarks, const ScAddress& aCellPos) const
427 {
428  ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
429 
430  sal_uLong nPos = 0;
431  for (auto const& it : m_Entries)
432  {
433  if ( it->eType == eType && it->aPixelRect.IsOver( rVisiblePixel ) )
434  {
435  if ( aCellPos == it->aCellRange.aStart )
436  return it->aPixelRect;
437  ++nPos;
438  }
439  }
440 
441  return tools::Rectangle();
442 }
443 
445 {
446  const double nScaleX = HMM_PER_TWIPS;
447  const double nScaleY = HMM_PER_TWIPS;
448 
449  // from left to right:
450  bool bHasHeaderCol = false;
451  bool bHasRepCols = false;
452  bool bHasMainCols = false;
453  SCCOL nRepeatColStart = 0;
454  SCCOL nRepeatColEnd = 0;
455  SCCOL nMainColStart = 0;
456  SCCOL nMainColEnd = 0;
457 
458  // from top to bottom:
459  bool bHasHeaderRow = false;
460  bool bHasRepRows = false;
461  bool bHasMainRows = false;
462  SCROW nRepeatRowStart = 0;
463  SCROW nRepeatRowEnd = 0;
464  SCROW nMainRowStart = 0;
465  SCROW nMainRowEnd = 0;
466 
467  tools::Rectangle aHeaderRect, aRepeatRect, aMainRect;
468  SCTAB nTab = 0;
469 
470  for (auto const& it : m_Entries)
471  {
472  if ( it->eType == SC_PLOC_CELLRANGE )
473  {
474  if ( it->bRepeatCol )
475  {
476  bHasRepCols = true;
477  nRepeatColStart = it->aCellRange.aStart.Col();
478  nRepeatColEnd = it->aCellRange.aEnd.Col();
479  aRepeatRect.SetLeft( it->aPixelRect.Left() );
480  aRepeatRect.SetRight( it->aPixelRect.Right() );
481  }
482  else
483  {
484  bHasMainCols = true;
485  nMainColStart = it->aCellRange.aStart.Col();
486  nMainColEnd = it->aCellRange.aEnd.Col();
487  aMainRect.SetLeft( it->aPixelRect.Left() );
488  aMainRect.SetRight( it->aPixelRect.Right() );
489  }
490  if ( it->bRepeatRow )
491  {
492  bHasRepRows = true;
493  nRepeatRowStart = it->aCellRange.aStart.Row();
494  nRepeatRowEnd = it->aCellRange.aEnd.Row();
495  aRepeatRect.SetTop( it->aPixelRect.Top() );
496  aRepeatRect.SetBottom( it->aPixelRect.Bottom() );
497  }
498  else
499  {
500  bHasMainRows = true;
501  nMainRowStart = it->aCellRange.aStart.Row();
502  nMainRowEnd = it->aCellRange.aEnd.Row();
503  aMainRect.SetTop( it->aPixelRect.Top() );
504  aMainRect.SetBottom( it->aPixelRect.Bottom() );
505  }
506  nTab = it->aCellRange.aStart.Tab();
507  }
508  else if ( it->eType == SC_PLOC_ROWHEADER )
509  {
510  // row headers result in an additional column
511  bHasHeaderCol = true;
512  aHeaderRect.SetLeft( it->aPixelRect.Left() );
513  aHeaderRect.SetRight( it->aPixelRect.Right() );
514  }
515  else if ( it->eType == SC_PLOC_COLHEADER )
516  {
517  // column headers result in an additional row
518  bHasHeaderRow = true;
519  aHeaderRect.SetTop( it->aPixelRect.Top() );
520  aHeaderRect.SetBottom( it->aPixelRect.Bottom() );
521  }
522  }
523 
524  // get column info
525 
526  SCCOL nColCount = 0;
527  SCCOL nCol;
528  if ( bHasHeaderCol )
529  ++nColCount;
530  if ( bHasRepCols )
531  for ( nCol=nRepeatColStart; nCol<=nRepeatColEnd; nCol++ )
532  if (!pDoc->ColHidden(nCol, nTab))
533  ++nColCount;
534  if ( bHasMainCols )
535  for ( nCol=nMainColStart; nCol<=nMainColEnd; nCol++ )
536  if (!pDoc->ColHidden(nCol, nTab))
537  ++nColCount;
538 
539  if ( nColCount > 0 )
540  {
541  ScPreviewColRowInfo* pColInfo = new ScPreviewColRowInfo[ nColCount ];
542  SCCOL nColPos = 0;
543 
544  if ( bHasHeaderCol )
545  {
546  pColInfo[nColPos].Set( true, 0, aHeaderRect.Left(), aHeaderRect.Right() );
547  ++nColPos;
548  }
549  if ( bHasRepCols )
550  {
551  tools::Long nPosX = 0;
552  for ( nCol=nRepeatColStart; nCol<=nRepeatColEnd; nCol++ )
553  if (!pDoc->ColHidden(nCol, nTab))
554  {
555  sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
556  tools::Long nNextX = nPosX + static_cast<tools::Long>(nDocW * nScaleX);
557 
558  tools::Long nPixelStart = pWindow->LogicToPixel( Size( nPosX, 0 ), aCellMapMode ).Width();
559  tools::Long nPixelEnd = pWindow->LogicToPixel( Size( nNextX, 0 ), aCellMapMode ).Width() - 1;
560  pColInfo[nColPos].Set( false, nCol,
561  aRepeatRect.Left() + nPixelStart,
562  aRepeatRect.Left() + nPixelEnd );
563 
564  nPosX = nNextX;
565  ++nColPos;
566  }
567  }
568  if ( bHasMainCols )
569  {
570  tools::Long nPosX = 0;
571  for ( nCol=nMainColStart; nCol<=nMainColEnd; nCol++ )
572  if (!pDoc->ColHidden(nCol, nTab))
573  {
574  sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab );
575  tools::Long nNextX = nPosX + static_cast<tools::Long>(nDocW * nScaleX);
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 = nPosY + static_cast<tools::Long>(nDocH * nScaleY);
622 
623  tools::Long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height();
624  tools::Long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1;
625  pRowInfo[nRowPos].Set( false, nRow,
626  aRepeatRect.Top() + nPixelStart,
627  aRepeatRect.Top() + nPixelEnd );
628 
629  nPosY = nNextY;
630  ++nRowPos;
631  }
632  }
633  if ( bHasMainRows )
634  {
635  tools::Long nPosY = 0;
636  for (SCROW nRow = nMainRowStart; nRow <= nMainRowEnd; ++nRow)
637  {
638  if (pDoc->RowHidden(nRow, nTab))
639  continue;
640 
641  sal_uInt16 nDocH = pDoc->GetOriginalHeight( nRow, nTab );
642  tools::Long nNextY = nPosY + static_cast<tools::Long>(nDocH * nScaleY);
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: */
const int nColCount
void LimitToArea(const tools::Rectangle &rPixelArea)
Definition: prevloc.cxx:90
sal_uInt16 nDrawRanges
Definition: prevloc.hxx:97
ScAddress aStart
Definition: address.hxx:500
SCROW Row() const
Definition: address.hxx:262
tools::Long nPixelStart
Definition: prevloc.hxx:48
#define SC_PREVIEW_RANGE_REPROW
Definition: prevloc.hxx:37
sal_uIntPtr sal_uLong
long Long
tools::Rectangle GetOffsetPixel(const ScAddress &rCellPos, const ScRange &rRange) const
Definition: prevloc.cxx:279
tools::Rectangle GetNoteInRangeOutputRect(const tools::Rectangle &rVisiblePixel, bool bNoteMarks, const ScAddress &aCellPos) const
Definition: prevloc.cxx:426
void AddNoteText(const tools::Rectangle &rRect, const ScAddress &rPos)
Definition: prevloc.cxx:247
void GetCellPosition(const ScAddress &rCellPos, tools::Rectangle &rCellRect) const
Definition: prevloc.cxx:308
VclPtr< OutputDevice > pWindow
Definition: prevloc.hxx:91
#define SC_PREVIEW_MAXRANGES
Definition: prevloc.hxx:34
tools::Rectangle GetCellOutputRect(const ScAddress &rCellPos) const
Definition: prevloc.cxx:692
std::list< std::unique_ptr< ScPreviewLocationEntry > > Entries_t
Definition: prevloc.hxx:89
void SetRight(tools::Long v)
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4161
ScPreviewLocationEntry(ScPreviewLocationType eNewType, const tools::Rectangle &rPixel, const ScRange &rRange, bool bRepCol, bool bRepRow)
Definition: prevloc.cxx:51
static ScPreviewLocationEntry * lcl_GetEntryByAddress(ScPreviewLocationData::Entries_t const &rEntries, const ScAddress &rPos, ScPreviewLocationType const eType)
Definition: prevloc.cxx:266
bool GetNoteInRange(const tools::Rectangle &rVisiblePixel, tools::Long nIndex, bool bNoteMarks, ScAddress &rCellPos, tools::Rectangle &rNoteRect) const
Definition: prevloc.cxx:403
tools::Long Left() const
void SetLeft(tools::Long v)
ScPreviewLocationType
Definition: prevloc.cxx:28
void Set(bool bHeader, SCCOLROW nIndex, tools::Long nStart, tools::Long nEnd)
Definition: prevloc.hxx:51
void AddNoteMark(const tools::Rectangle &rRect, const ScAddress &rPos)
Definition: prevloc.cxx:239
tools::Long Bottom() const
tools::Rectangle GetHeaderCellOutputRect(const tools::Rectangle &rVisRect, const ScAddress &rCellPos, bool bColHeader) const
Definition: prevloc.cxx:665
#define HMM_PER_TWIPS
Definition: global.hxx:92
SCTAB Tab() const
Definition: address.hxx:271
void AddHeaderFooter(const tools::Rectangle &rRect, bool bHeader, bool bLeft)
Definition: prevloc.cxx:227
ScPreviewLocationData(ScDocument *pDocument, OutputDevice *pWin)
Definition: prevloc.cxx:147
SCROW GetRows() const
Definition: prevloc.hxx:76
DocumentType eType
const ScPreviewColRowInfo * GetRowInfo() const
Definition: prevloc.hxx:78
void SetTab(SCTAB nNewTab)
Definition: prevloc.cxx:73
std::unique_ptr< ScPreviewColRowInfo[]> pRowInfo
Definition: prevloc.hxx:68
bool GetFooterPosition(tools::Rectangle &rFooterRect) const
Definition: prevloc.cxx:347
SC_DLLPUBLIC bool ColHidden(SCCOL nCol, SCTAB nTab, SCCOL *pFirstCol=nullptr, SCCOL *pLastCol=nullptr) const
Definition: document.cxx:4445
bool IsFooterLeft() const
Definition: prevloc.cxx:375
sal_uInt8 aDrawRangeId[SC_PREVIEW_MAXRANGES]
Definition: prevloc.hxx:96
int i
void SetRowInfo(SCROW nCount, ScPreviewColRowInfo *pNewInfo)
Definition: prevloc.cxx:84
MapMode aDrawMapMode[SC_PREVIEW_MAXRANGES]
Definition: prevloc.hxx:94
#define SC_PREVIEW_RANGE_TAB
Definition: prevloc.hxx:38
sal_Int16 SCCOL
Definition: types.hxx:22
bool HasCellsInRange(const tools::Rectangle &rVisiblePixel) const
Definition: prevloc.cxx:321
sal_uLong GetScaledRowHeight(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, double fScale, const sal_uLong *pnMaxHeight=nullptr) const
Definition: document.cxx:4198
Entries_t m_Entries
Definition: prevloc.hxx:99
tools::Long Width() const
const ScPreviewColRowInfo * GetColInfo() const
Definition: prevloc.hxx:77
#define SC_PREVIEW_RANGE_REPCOL
Definition: prevloc.hxx:36
void SetTop(tools::Long v)
tools::Long nPixelEnd
Definition: prevloc.hxx:49
void SetBottom(tools::Long v)
void AddColHeaders(const tools::Rectangle &rRect, SCCOL nStartCol, SCCOL nEndCol, bool bRepCol)
Definition: prevloc.cxx:209
tools::Long Top() const
#define SC_PREVIEW_RANGE_EDGE
Definition: prevloc.hxx:35
bool IsHeaderLeft() const
Definition: prevloc.cxx:361
tools::Rectangle aDrawRectangle[SC_PREVIEW_MAXRANGES]
Definition: prevloc.hxx:95
void SetPrintTab(SCTAB nNew)
Definition: prevloc.cxx:165
SCCOL Col() const
Definition: address.hxx:267
std::unique_ptr< ScPreviewColRowInfo[]> pColInfo
Definition: prevloc.hxx:66
Point LogicToPixel(const Point &rLogicPt) const
void AddRowHeaders(const tools::Rectangle &rRect, SCROW nStartRow, SCROW nEndRow, bool bRepRow)
Definition: prevloc.cxx:218
ScDocument * pDoc
Definition: prevloc.hxx:92
sal_Int32 SCROW
Definition: types.hxx:18
SC_DLLPUBLIC sal_uInt16 GetOriginalHeight(SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4153
unsigned char sal_uInt8
tools::Long GetNoteCountInRange(const tools::Rectangle &rVisiblePixel, bool bNoteMarks) const
Definition: prevloc.cxx:389
void AddCellRange(const tools::Rectangle &rRect, const ScRange &rRange, bool bRepCol, bool bRepRow, const MapMode &rDrawMap)
Definition: prevloc.cxx:177
void GetDrawRange(sal_uInt16 nPos, tools::Rectangle &rPixelRect, MapMode &rMapMode, sal_uInt8 &rRangeId) const
Definition: prevloc.cxx:255
tools::Long Height() const
SCCOL GetCols() const
Definition: prevloc.hxx:75
ScPreviewLocationType eType
Definition: prevloc.cxx:45
SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
Definition: document.cxx:4429
void SetCellMapMode(const MapMode &rMapMode)
Definition: prevloc.cxx:160
void SetColInfo(SCCOL nCount, ScPreviewColRowInfo *pNewInfo)
Definition: prevloc.cxx:78
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:4120
SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const
Definition: document.cxx:4491
void GetTableInfo(const tools::Rectangle &rVisiblePixel, ScPreviewTableInfo &rInfo) const
Definition: prevloc.cxx:444
tools::Long Right() const
sal_uInt16 nPos
sal_Int16 SCTAB
Definition: types.hxx:23
bool GetHeaderPosition(tools::Rectangle &rHeaderRect) const
Definition: prevloc.cxx:333