LibreOffice Module sc (master)  1
gridwin4.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 <memory>
21 #include <scitems.hxx>
22 #include <editeng/eeitem.hxx>
23 
24 #include <svtools/colorcfg.hxx>
25 #include <editeng/colritem.hxx>
26 #include <editeng/editview.hxx>
27 #include <editeng/fhgtitem.hxx>
28 #include <sfx2/bindings.hxx>
29 #include <sfx2/printer.hxx>
30 #include <vcl/cursor.hxx>
31 #include <vcl/settings.hxx>
32 
33 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
34 #include <comphelper/lok.hxx>
35 #include <sfx2/lokhelper.hxx>
36 
37 #include <svx/svdview.hxx>
38 #include <svx/svdpagv.hxx>
39 #include <svx/sdrpagewindow.hxx>
43 #include <tabvwsh.hxx>
44 
45 #include <gridwin.hxx>
46 #include <viewdata.hxx>
47 #include <output.hxx>
48 #include <document.hxx>
49 #include <attrib.hxx>
50 #include <patattr.hxx>
51 #include <dbdata.hxx>
52 #include <docoptio.hxx>
53 #include <notemark.hxx>
54 #include <dbfunc.hxx>
55 #include <scmod.hxx>
56 #include <inputhdl.hxx>
57 #include <rfindlst.hxx>
58 #include <hiranges.hxx>
59 #include <pagedata.hxx>
60 #include <docpool.hxx>
61 #include <globstr.hrc>
62 #include <scresid.hxx>
63 #include <docsh.hxx>
64 #include <cbutton.hxx>
65 #include <invmerge.hxx>
66 #include <editutil.hxx>
67 #include <inputopt.hxx>
68 #include <fillinfo.hxx>
69 #include <dpcontrol.hxx>
70 #include <queryparam.hxx>
71 #include <queryentry.hxx>
72 #include <markdata.hxx>
73 #include <sc.hrc>
74 #include <vcl/virdev.hxx>
75 #include <svx/sdrpaintwindow.hxx>
76 #include <drwlayer.hxx>
77 
78 static void lcl_LimitRect( tools::Rectangle& rRect, const tools::Rectangle& rVisible )
79 {
80  if ( rRect.Top() < rVisible.Top()-1 ) rRect.SetTop( rVisible.Top()-1 );
81  if ( rRect.Bottom() > rVisible.Bottom()+1 ) rRect.SetBottom( rVisible.Bottom()+1 );
82 
83  // The header row must be drawn also when the inner rectangle is not visible,
84  // that is why there is no return value anymore.
85  // When it is far away, then lcl_DrawOneFrame is not even called.
86 }
87 
88 static void lcl_DrawOneFrame( vcl::RenderContext* pDev, const tools::Rectangle& rInnerPixel,
89  const OUString& rTitle, const Color& rColor, bool bTextBelow,
90  double nPPTX, double nPPTY, const Fraction& rZoomY,
91  ScDocument& rDoc, ScViewData& rButtonViewData, bool bLayoutRTL )
92 {
93  // rButtonViewData is only used to set the button size,
94 
95  tools::Rectangle aInner = rInnerPixel;
96  if ( bLayoutRTL )
97  {
98  aInner.SetLeft( rInnerPixel.Right() );
99  aInner.SetRight( rInnerPixel.Left() );
100  }
101 
102  tools::Rectangle aVisible( Point(0,0), pDev->GetOutputSizePixel() );
103  lcl_LimitRect( aInner, aVisible );
104 
105  tools::Rectangle aOuter = aInner;
106  tools::Long nHor = static_cast<tools::Long>( SC_SCENARIO_HSPACE * nPPTX );
107  tools::Long nVer = static_cast<tools::Long>( SC_SCENARIO_VSPACE * nPPTY );
108  aOuter.AdjustLeft( -nHor );
109  aOuter.AdjustRight(nHor );
110  aOuter.AdjustTop( -nVer );
111  aOuter.AdjustBottom(nVer );
112 
113  // use ScPatternAttr::GetFont only for font size
114  vcl::Font aAttrFont;
116  GetFont(aAttrFont,SC_AUTOCOL_BLACK,pDev,&rZoomY);
117 
118  // everything else from application font
119  vcl::Font aAppFont = pDev->GetSettings().GetStyleSettings().GetAppFont();
120  aAppFont.SetFontSize( aAttrFont.GetFontSize() );
121 
122  aAppFont.SetAlignment( ALIGN_TOP );
123  pDev->SetFont( aAppFont );
124 
125  Size aTextSize( pDev->GetTextWidth( rTitle ), pDev->GetTextHeight() );
126 
127  if ( bTextBelow )
128  aOuter.AdjustBottom(aTextSize.Height() );
129  else
130  aOuter.AdjustTop( -(aTextSize.Height()) );
131 
132  pDev->SetLineColor();
133  pDev->SetFillColor( rColor );
134  // left, top, right, bottom
135  pDev->DrawRect( tools::Rectangle( aOuter.Left(), aOuter.Top(), aInner.Left(), aOuter.Bottom() ) );
136  pDev->DrawRect( tools::Rectangle( aOuter.Left(), aOuter.Top(), aOuter.Right(), aInner.Top() ) );
137  pDev->DrawRect( tools::Rectangle( aInner.Right(), aOuter.Top(), aOuter.Right(), aOuter.Bottom() ) );
138  pDev->DrawRect( tools::Rectangle( aOuter.Left(), aInner.Bottom(), aOuter.Right(), aOuter.Bottom() ) );
139 
140  tools::Long nButtonY = bTextBelow ? aInner.Bottom() : aOuter.Top();
141 
142  ScDDComboBoxButton aComboButton(pDev);
143  aComboButton.SetOptSizePixel();
144  tools::Long nBWidth = tools::Long(aComboButton.GetSizePixel().Width() * rZoomY);
145  tools::Long nBHeight = nVer + aTextSize.Height() + 1;
146  Size aButSize( nBWidth, nBHeight );
147  tools::Long nButtonPos = bLayoutRTL ? aOuter.Left() : aOuter.Right()-nBWidth+1;
148  aComboButton.Draw( Point(nButtonPos, nButtonY), aButSize );
149  rButtonViewData.SetScenButSize( aButSize );
150 
151  tools::Long nTextStart = bLayoutRTL ? aInner.Right() - aTextSize.Width() + 1 : aInner.Left();
152 
153  bool bWasClip = false;
154  vcl::Region aOldClip;
155  bool bClip = ( aTextSize.Width() > aOuter.Right() - nBWidth - aInner.Left() );
156  if ( bClip )
157  {
158  if (pDev->IsClipRegion())
159  {
160  bWasClip = true;
161  aOldClip = pDev->GetActiveClipRegion();
162  }
163  tools::Long nClipStartX = bLayoutRTL ? aOuter.Left() + nBWidth : aInner.Left();
164  tools::Long nClipEndX = bLayoutRTL ? aInner.Right() : aOuter.Right() - nBWidth;
165  pDev->SetClipRegion( vcl::Region(tools::Rectangle( nClipStartX, nButtonY + nVer/2,
166  nClipEndX, nButtonY + nVer/2 + aTextSize.Height())) );
167  }
168 
169  pDev->DrawText( Point( nTextStart, nButtonY + nVer/2 ), rTitle );
170 
171  if ( bClip )
172  {
173  if ( bWasClip )
174  pDev->SetClipRegion(aOldClip);
175  else
176  pDev->SetClipRegion();
177  }
178 
179  pDev->SetFillColor();
180  pDev->SetLineColor( COL_BLACK );
181  pDev->DrawRect( aInner );
182  pDev->DrawRect( aOuter );
183 }
184 
185 static void lcl_DrawScenarioFrames( OutputDevice* pDev, ScViewData& rViewData, ScSplitPos eWhich,
186  SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 )
187 {
188  ScDocument& rDoc = rViewData.GetDocument();
189  SCTAB nTab = rViewData.GetTabNo();
190  SCTAB nTabCount = rDoc.GetTableCount();
191  if ( nTab+1 >= nTabCount || !rDoc.IsScenario(nTab+1) || rDoc.IsScenario(nTab) )
192  return;
193 
194  if ( nX1 > 0 ) --nX1;
195  if ( nY1>=2 ) nY1 -= 2; // Hack: Header row affects two cells
196  else if ( nY1 > 0 ) --nY1;
197  if ( nX2 < rDoc.MaxCol() ) ++nX2;
198  if ( nY2 < rDoc.MaxRow()-1 ) nY2 += 2; // Hack: Header row affects two cells
199  else if ( nY2 < rDoc.MaxRow() ) ++nY2;
200  ScRange aViewRange( nX1,nY1,nTab, nX2,nY2,nTab );
201 
203 
204  ScMarkData aMarks(rDoc.GetSheetLimits());
205  for (SCTAB i=nTab+1; i<nTabCount && rDoc.IsScenario(i); i++)
206  rDoc.MarkScenario( i, nTab, aMarks, false, ScScenarioFlags::ShowFrame );
207  ScRangeListRef xRanges = new ScRangeList;
208  aMarks.FillRangeListWithMarks( xRanges.get(), false );
209 
210  bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
211  tools::Long nLayoutSign = bLayoutRTL ? -1 : 1;
212 
213  for (size_t j = 0, n = xRanges->size(); j < n; ++j)
214  {
215  ScRange aRange = (*xRanges)[j];
216  // Always extend scenario frame to merged cells where no new non-covered cells
217  // are framed
218  rDoc.ExtendTotalMerge( aRange );
219 
221 
222  if ( aRange.Intersects( aViewRange ) )
223  {
224  Point aStartPos = rViewData.GetScrPos(
225  aRange.aStart.Col(), aRange.aStart.Row(), eWhich, true );
226  Point aEndPos = rViewData.GetScrPos(
227  aRange.aEnd.Col()+1, aRange.aEnd.Row()+1, eWhich, true );
228  // on the grid:
229  aStartPos.AdjustX( -nLayoutSign );
230  aStartPos.AdjustY( -1 );
231  aEndPos.AdjustX( -nLayoutSign );
232  aEndPos.AdjustY( -1 );
233 
234  bool bTextBelow = ( aRange.aStart.Row() == 0 );
235 
236  OUString aCurrent;
237  Color aColor( COL_LIGHTGRAY );
238  for (SCTAB nAct=nTab+1; nAct<nTabCount && rDoc.IsScenario(nAct); nAct++)
239  if ( rDoc.IsActiveScenario(nAct) && rDoc.HasScenarioRange(nAct,aRange) )
240  {
241  OUString aDummyComment;
242  ScScenarioFlags nDummyFlags;
243  rDoc.GetName( nAct, aCurrent );
244  rDoc.GetScenarioData( nAct, aDummyComment, aColor, nDummyFlags );
245  }
246 
247  if (aCurrent.isEmpty())
248  aCurrent = ScResId( STR_EMPTYDATA );
249 
251 
252  lcl_DrawOneFrame( pDev, tools::Rectangle( aStartPos, aEndPos ),
253  aCurrent, aColor, bTextBelow,
254  rViewData.GetPPTX(), rViewData.GetPPTY(), rViewData.GetZoomY(),
255  rDoc, rViewData, bLayoutRTL );
256  }
257  }
258 }
259 
260 static void lcl_DrawHighlight( ScOutputData& rOutputData, const ScViewData& rViewData,
261  const std::vector<ScHighlightEntry>& rHighlightRanges )
262 {
263  SCTAB nTab = rViewData.GetTabNo();
264  for ( const auto& rHighlightRange : rHighlightRanges)
265  {
266  ScRange aRange = rHighlightRange.aRef;
267  if ( nTab >= aRange.aStart.Tab() && nTab <= aRange.aEnd.Tab() )
268  {
269  rOutputData.DrawRefMark(
270  aRange.aStart.Col(), aRange.aStart.Row(),
271  aRange.aEnd.Col(), aRange.aEnd.Row(),
272  rHighlightRange.aColor, false );
273  }
274  }
275 }
276 
278 {
279  if ( rPixel == aInvertRect )
280  aInvertRect = tools::Rectangle(); // Cancel
281  else
282  {
283  OSL_ENSURE( aInvertRect.IsEmpty(), "DoInvertRect no pairs" );
284 
285  aInvertRect = rPixel; // Mark new rectangle
286  }
287 
288  UpdateHeaderOverlay(); // uses aInvertRect
289 }
290 
292 {
293  // forward PrePaint to DrawingLayer
294  ScTabViewShell* pTabViewShell = mrViewData.GetViewShell();
295 
296  if(pTabViewShell)
297  {
298  SdrView* pDrawView = pTabViewShell->GetScDrawView();
299 
300  if (pDrawView)
301  {
302  pDrawView->PrePaint();
303  }
304  }
305 }
306 
308  const Fraction aScaleX, const Fraction aScaleY)
309 {
310  // Don't see the need for a map as there will be only a few zoom levels
311  // and as of now X and Y zooms in online are the same.
312  for (auto& rEntry : maLOKLastCursor)
313  {
314  if (aScaleX == rEntry.aScaleX && aScaleY == rEntry.aScaleY)
315  {
316  if (rCursorRect == rEntry.aRect)
317  return false; // No change
318 
319  // Update and allow invalidate.
320  rEntry.aRect = rCursorRect;
321  return true;
322  }
323  }
324 
325  maLOKLastCursor.push_back(LOKCursorEntry{aScaleX, aScaleY, rCursorRect});
326  return true;
327 }
328 
330  const Fraction aScaleX, const Fraction aScaleY)
331 {
332  if (!NeedLOKCursorInvalidation(rCursorRect, aScaleX, aScaleY))
333  return;
334 
335  ScTabViewShell* pThisViewShell = mrViewData.GetViewShell();
336  SfxViewShell* pViewShell = SfxViewShell::GetFirst();
337 
338  while (pViewShell)
339  {
340  if (pViewShell != pThisViewShell && pViewShell->GetDocId() == pThisViewShell->GetDocId())
341  {
342  ScTabViewShell* pOtherViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
343  if (pOtherViewShell)
344  {
345  ScViewData& rOtherViewData = pOtherViewShell->GetViewData();
346  Fraction aZoomX = rOtherViewData.GetZoomX();
347  Fraction aZoomY = rOtherViewData.GetZoomY();
348  if (aZoomX == aScaleX && aZoomY == aScaleY)
349  {
350  SfxLokHelper::notifyOtherView(pThisViewShell, pOtherViewShell,
351  LOK_CALLBACK_INVALIDATE_VIEW_CURSOR, "rectangle", rCursorRect.toString());
352  }
353  }
354  }
355 
356  pViewShell = SfxViewShell::GetNext(*pViewShell);
357  }
358 }
359 
360 void ScGridWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const tools::Rectangle& rRect )
361 {
363  if ( rDoc.IsInInterpreter() )
364  {
365  // Via Reschedule, interpreted cells do not trigger Invalidate again,
366  // otherwise for instance an error box would never appear (bug 36381).
367  // Later, through bNeedsRepaint everything is painted again.
368  if ( bNeedsRepaint )
369  {
371  aRepaintPixel = tools::Rectangle(); // multiple -> paint all
372  }
373  else
374  {
375  bNeedsRepaint = true;
376  aRepaintPixel = LogicToPixel(rRect); // only affected ranges
377  }
378  return;
379  }
380 
381  // #i117893# If GetSizePixel needs to call the resize handler, the resulting nested Paint call
382  // (possibly for a larger rectangle) has to be allowed. Call GetSizePixel before setting bIsInPaint.
383  GetSizePixel();
384 
385  if (bIsInPaint)
386  return;
387 
388  bIsInPaint = true;
389 
390  tools::Rectangle aPixRect = LogicToPixel( rRect );
391 
394 
395  SCTAB nTab = mrViewData.GetTabNo();
396 
397  double nPPTX = mrViewData.GetPPTX();
398  double nPPTY = mrViewData.GetPPTY();
399 
400  tools::Rectangle aMirroredPixel = aPixRect;
401  if ( rDoc.IsLayoutRTL( nTab ) )
402  {
403  // mirror and swap
404  tools::Long nWidth = GetSizePixel().Width();
405  aMirroredPixel.SetLeft( nWidth - 1 - aPixRect.Right() );
406  aMirroredPixel.SetRight( nWidth - 1 - aPixRect.Left() );
407  }
408 
409  tools::Long nScrX = ScViewData::ToPixel( rDoc.GetColWidth( nX1, nTab ), nPPTX );
410  while ( nScrX <= aMirroredPixel.Left() && nX1 < rDoc.MaxCol() )
411  {
412  ++nX1;
413  nScrX += ScViewData::ToPixel( rDoc.GetColWidth( nX1, nTab ), nPPTX );
414  }
415  SCCOL nX2 = nX1;
416  while ( nScrX <= aMirroredPixel.Right() && nX2 < rDoc.MaxCol() )
417  {
418  ++nX2;
419  nScrX += ScViewData::ToPixel( rDoc.GetColWidth( nX2, nTab ), nPPTX );
420  }
421 
422  tools::Long nScrY = 0;
423  ScViewData::AddPixelsWhile( nScrY, aPixRect.Top(), nY1, rDoc.MaxRow(), nPPTY, &rDoc, nTab);
424  SCROW nY2 = nY1;
425  if (nScrY <= aPixRect.Bottom() && nY2 < rDoc.MaxRow())
426  {
427  ++nY2;
428  ScViewData::AddPixelsWhile( nScrY, aPixRect.Bottom(), nY2, rDoc.MaxRow(), nPPTY, &rDoc, nTab);
429  }
430 
431  Draw( nX1,nY1,nX2,nY2, ScUpdateMode::Marks ); // don't continue with painting
432 
433  bIsInPaint = false;
434 }
435 
436 void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMode eMode )
437 {
439 
440  // let's ignore the normal Draw() attempts when doing the tiled rendering,
441  // all the rendering should go through PaintTile() in that case.
442  // TODO revisit if we can actually turn this into an assert(), and clean
443  // up the callers
445  return;
446 
447  ScModule* pScMod = SC_MOD();
448  bool bTextWysiwyg = pScMod->GetInputOptions().GetTextWysiwyg();
449 
450  if (mrViewData.IsMinimized())
451  return;
452 
453  PutInOrder( nX1, nX2 );
454  PutInOrder( nY1, nY2 );
455 
456  OSL_ENSURE( rDoc.ValidCol(nX2) && rDoc.ValidRow(nY2), "GridWin Draw area too big" );
457 
459 
460  if (nX2 < maVisibleRange.mnCol1 || nY2 < maVisibleRange.mnRow1)
461  return;
462  // invisible
463  if (nX1 < maVisibleRange.mnCol1)
464  nX1 = maVisibleRange.mnCol1;
465  if (nY1 < maVisibleRange.mnRow1)
466  nY1 = maVisibleRange.mnRow1;
467 
468  if (nX1 > maVisibleRange.mnCol2 || nY1 > maVisibleRange.mnRow2)
469  return;
470 
471  if (nX2 > maVisibleRange.mnCol2)
472  nX2 = maVisibleRange.mnCol2;
473  if (nY2 > maVisibleRange.mnRow2)
474  nY2 = maVisibleRange.mnRow2;
475 
476  if ( eMode != ScUpdateMode::Marks && nX2 < maVisibleRange.mnCol2)
477  nX2 = maVisibleRange.mnCol2; // to continue painting
478 
479  // point of no return
480 
481  ++nPaintCount; // mark that painting is in progress
482 
483  SCTAB nTab = mrViewData.GetTabNo();
484  rDoc.ExtendHidden( nX1, nY1, nX2, nY2, nTab );
485 
486  Point aScrPos = mrViewData.GetScrPos( nX1, nY1, eWhich );
487  tools::Long nMirrorWidth = GetSizePixel().Width();
488  bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
489  if ( bLayoutRTL )
490  {
491  tools::Long nEndPixel = mrViewData.GetScrPos( nX2+1, maVisibleRange.mnRow1, eWhich ).X();
492  nMirrorWidth = aScrPos.X() - nEndPixel;
493  aScrPos.setX( nEndPixel + 1 );
494  }
495 
496  tools::Long nScrX = aScrPos.X();
497  tools::Long nScrY = aScrPos.Y();
498 
499  SCCOL nCurX = mrViewData.GetCurX();
500  SCROW nCurY = mrViewData.GetCurY();
501  SCCOL nCurEndX = nCurX;
502  SCROW nCurEndY = nCurY;
503  rDoc.ExtendMerge( nCurX, nCurY, nCurEndX, nCurEndY, nTab );
504  bool bCurVis = nCursorHideCount==0 &&
505  ( nCurEndX+1 >= nX1 && nCurX <= nX2+1 && nCurEndY+1 >= nY1 && nCurY <= nY2+1 );
506 
507  // AutoFill Handles
508  if ( !bCurVis && nCursorHideCount==0 && bAutoMarkVisible && aAutoMarkPos.Tab() == nTab &&
509  ( aAutoMarkPos.Col() != nCurX || aAutoMarkPos.Row() != nCurY ) )
510  {
511  SCCOL nHdlX = aAutoMarkPos.Col();
512  SCROW nHdlY = aAutoMarkPos.Row();
513  rDoc.ExtendMerge( nHdlX, nHdlY, nHdlX, nHdlY, nTab );
514  // left and top is unaffected
515 
517  }
518 
519  double nPPTX = mrViewData.GetPPTX();
520  double nPPTY = mrViewData.GetPPTY();
521 
522  const ScViewOptions& rOpts = mrViewData.GetOptions();
523 
524  // data block
525 
526  ScTableInfo aTabInfo;
527  rDoc.FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab,
528  nPPTX, nPPTY, false, rOpts.GetOption(VOPT_FORMULAS),
529  &mrViewData.GetMarkData() );
530 
531  Fraction aZoomX = mrViewData.GetZoomX();
532  Fraction aZoomY = mrViewData.GetZoomY();
533  ScOutputData aOutputData( this, OUTTYPE_WINDOW, aTabInfo, &rDoc, nTab,
534  nScrX, nScrY, nX1, nY1, nX2, nY2, nPPTX, nPPTY,
535  &aZoomX, &aZoomY );
536 
537  aOutputData.SetMirrorWidth( nMirrorWidth ); // needed for RTL
538  aOutputData.SetSpellCheckContext(mpSpellCheckCxt.get());
539 
540  ScopedVclPtr< VirtualDevice > xFmtVirtDev;
541  bool bLogicText = bTextWysiwyg; // call DrawStrings in logic MapMode?
542 
543  if ( bTextWysiwyg )
544  {
545  // use printer for text formatting
546 
547  OutputDevice* pFmtDev = rDoc.GetPrinter();
549  aOutputData.SetFmtDevice( pFmtDev );
550  }
551  else if ( aZoomX != aZoomY && mrViewData.IsOle() )
552  {
553  // #i45033# For OLE inplace editing with different zoom factors,
554  // use a virtual device with 1/100th mm as text formatting reference
555 
557  xFmtVirtDev->SetMapMode(MapMode(MapUnit::Map100thMM));
558  aOutputData.SetFmtDevice( xFmtVirtDev.get() );
559 
560  bLogicText = true; // use logic MapMode
561  }
562 
563  DrawContent(*this, aTabInfo, aOutputData, bLogicText);
564 
565  // If something was inverted during the Paint (selection changed from Basic Macro)
566  // then this is now mixed up and has to be repainted
567  OSL_ENSURE(nPaintCount, "Wrong nPaintCount");
568  --nPaintCount;
569  if (!nPaintCount)
571 
572  // Flag drawn formula cells "unchanged".
573  rDoc.ResetChanged(ScRange(nX1, nY1, nTab, nX2, nY2, nTab));
574  rDoc.PrepareFormulaCalc();
575 }
576 
577 namespace {
578 
579 class SuppressEditViewMessagesGuard
580 {
581 public:
582  SuppressEditViewMessagesGuard(EditView& rEditView) :
583  mrEditView(rEditView),
584  mbOrigSuppressFlag(rEditView.IsSuppressLOKMessages())
585  {
586  if (!mbOrigSuppressFlag)
587  mrEditView.SuppressLOKMessages(true);
588  }
589 
590  ~SuppressEditViewMessagesGuard()
591  {
592  if (mrEditView.IsSuppressLOKMessages() != mbOrigSuppressFlag)
593  mrEditView.SuppressLOKMessages(mbOrigSuppressFlag);
594  }
595 
596 private:
597  EditView& mrEditView;
598  const bool mbOrigSuppressFlag;
599 };
600 
601 }
602 
603 void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableInfo, ScOutputData& aOutputData,
604  bool bLogicText)
605 {
606  ScModule* pScMod = SC_MOD();
608  const ScViewOptions& rOpts = mrViewData.GetOptions();
609  bool bIsTiledRendering = comphelper::LibreOfficeKit::isActive();
610  bool bNoBackgroundAndGrid = bIsTiledRendering
612  comphelper::LibreOfficeKit::Compat::scNoGridBackground);
613 
614  SCTAB nTab = aOutputData.nTab;
615  SCCOL nX1 = aOutputData.nX1;
616  SCROW nY1 = aOutputData.nY1;
617  SCCOL nX2 = aOutputData.nX2;
618  SCROW nY2 = aOutputData.nY2;
619  tools::Long nScrX = aOutputData.nScrX;
620  tools::Long nScrY = aOutputData.nScrY;
621 
622  const svtools::ColorConfig& rColorCfg = pScMod->GetColorConfig();
623  Color aGridColor( rColorCfg.GetColorValue( svtools::CALCGRID, false ).nColor );
624  if ( aGridColor == COL_TRANSPARENT )
625  {
626  // use view options' grid color only if color config has "automatic" color
627  aGridColor = rOpts.GetGridColor();
628  }
629 
630  aOutputData.SetSyntaxMode ( mrViewData.IsSyntaxMode() );
631  aOutputData.SetGridColor ( aGridColor );
632  aOutputData.SetShowNullValues ( rOpts.GetOption( VOPT_NULLVALS ) );
633  aOutputData.SetShowFormulas ( rOpts.GetOption( VOPT_FORMULAS ) );
634  aOutputData.SetShowSpellErrors ( rDoc.GetDocOptions().IsAutoSpell() );
635  aOutputData.SetMarkClipped ( rOpts.GetOption( VOPT_CLIPMARKS ) );
636 
637  aOutputData.SetUseStyleColor( true ); // always set in table view
638 
639  aOutputData.SetViewShell( mrViewData.GetViewShell() );
640 
641  bool bGrid = rOpts.GetOption( VOPT_GRID ) && mrViewData.GetShowGrid();
642  bool bGridFirst = !rOpts.GetOption( VOPT_GRID_ONTOP );
643 
644  bool bPage = rOpts.GetOption( VOPT_PAGEBREAKS ) && !bIsTiledRendering;
645 
646  bool bPageMode = mrViewData.IsPagebreakMode();
647  if (bPageMode) // after FindChanged
648  {
649  // SetPagebreakMode also initializes bPrinted Flags
651  }
652 
653  EditView* pEditView = nullptr;
654  bool bEditMode = mrViewData.HasEditView(eWhich);
655  if ( bEditMode && mrViewData.GetRefTabNo() == nTab )
656  {
657  SCCOL nEditCol;
658  SCROW nEditRow;
659  mrViewData.GetEditView( eWhich, pEditView, nEditCol, nEditRow );
660  SCCOL nEditEndCol = mrViewData.GetEditEndCol();
661  SCROW nEditEndRow = mrViewData.GetEditEndRow();
662 
663  if ( nEditEndCol >= nX1 && nEditCol <= nX2 && nEditEndRow >= nY1 && nEditRow <= nY2 )
664  aOutputData.SetEditCell( nEditCol, nEditRow );
665  else
666  bEditMode = false;
667  }
668 
669  const MapMode aOriginalMode = rDevice.GetMapMode();
670 
671  // define drawing layer map mode and paint rectangle
672  MapMode aDrawMode = GetDrawMapMode();
673  if (bIsTiledRendering)
674  {
675  // FIXME this shouldn't be necessary once we change the entire Calc to
676  // work in the logic coordinates (ideally 100ths of mm - so that it is
677  // the same as editeng and drawinglayer), and get rid of all the
678  // SetMapMode's and other unnecessary fun we have with pixels
679  // See also ScGridWindow::GetDrawMapMode() for the rest of this hack
680  aDrawMode.SetOrigin(PixelToLogic(Point(nScrX, nScrY), aDrawMode));
681  }
682  tools::Rectangle aDrawingRectLogic;
683  bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
684 
685  {
686  // get drawing pixel rect
687  tools::Rectangle aDrawingRectPixel(Point(nScrX, nScrY), Size(aOutputData.GetScrW(), aOutputData.GetScrH()));
688 
689  // correct for border (left/right)
690  if(rDoc.MaxCol() == nX2)
691  {
692  if(bLayoutRTL)
693  {
694  aDrawingRectPixel.SetLeft( 0 );
695  }
696  else
697  {
698  aDrawingRectPixel.SetRight( GetOutputSizePixel().getWidth() );
699  }
700  }
701 
702  // correct for border (bottom)
703  if(rDoc.MaxRow() == nY2)
704  {
705  aDrawingRectPixel.SetBottom( GetOutputSizePixel().getHeight() );
706  }
707 
708  // get logic positions
709  aDrawingRectLogic = PixelToLogic(aDrawingRectPixel, aDrawMode);
710  }
711 
712  bool bInPlaceEditing = bEditMode && (mrViewData.GetRefTabNo() == mrViewData.GetTabNo());
713  vcl::Cursor* pInPlaceCrsr = nullptr;
714  bool bInPlaceVisCursor = false;
715  if (bInPlaceEditing)
716  {
717  // toggle the cursor off if its on to ensure the cursor invert
718  // background logic remains valid after the background is cleared on
719  // the next cursor flash
720  pInPlaceCrsr = pEditView->GetCursor();
721  bInPlaceVisCursor = pInPlaceCrsr && pInPlaceCrsr->IsVisible();
722  if (bInPlaceVisCursor)
723  pInPlaceCrsr->Hide();
724  }
725 
726  OutputDevice* pContentDev = &rDevice; // device for document content, used by overlay manager
727  SdrPaintWindow* pTargetPaintWindow = nullptr; // #i74769# work with SdrPaintWindow directly
728 
729  {
730  // init redraw
731  ScTabViewShell* pTabViewShell = mrViewData.GetViewShell();
732 
733  if(pTabViewShell)
734  {
735  MapMode aCurrentMapMode(pContentDev->GetMapMode());
736  pContentDev->SetMapMode(aDrawMode);
737  SdrView* pDrawView = pTabViewShell->GetScDrawView();
738 
739  if(pDrawView)
740  {
741  // #i74769# Use new BeginDrawLayers() interface
742  vcl::Region aDrawingRegion(aDrawingRectLogic);
743  pTargetPaintWindow = pDrawView->BeginDrawLayers(pContentDev, aDrawingRegion);
744  OSL_ENSURE(pTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
745 
746  if (!bIsTiledRendering)
747  {
748  // #i74769# get target device from SdrPaintWindow, this may be the prerender
749  // device now, too.
750  pContentDev = &(pTargetPaintWindow->GetTargetOutputDevice());
751  aOutputData.SetContentDevice(pContentDev);
752  }
753  }
754 
755  pContentDev->SetMapMode(aCurrentMapMode);
756  }
757  }
758 
759  // edge (area) (Pixel)
760  if ( nX2==rDoc.MaxCol() || nY2==rDoc.MaxRow() )
761  {
762  // save MapMode and set to pixel
763  MapMode aCurrentMapMode(pContentDev->GetMapMode());
764  pContentDev->SetMapMode(MapMode(MapUnit::MapPixel));
765 
766  tools::Rectangle aPixRect( Point(), GetOutputSizePixel() );
767  pContentDev->SetFillColor( rColorCfg.GetColorValue(svtools::APPBACKGROUND).nColor );
768  pContentDev->SetLineColor();
769  if ( nX2==rDoc.MaxCol() )
770  {
771  tools::Rectangle aDrawRect( aPixRect );
772  if ( bLayoutRTL )
773  aDrawRect.SetRight( nScrX - 1 );
774  else
775  aDrawRect.SetLeft( nScrX + aOutputData.GetScrW() );
776  if (aDrawRect.Right() >= aDrawRect.Left())
777  pContentDev->DrawRect( aDrawRect );
778  }
779  if ( nY2==rDoc.MaxRow() )
780  {
781  tools::Rectangle aDrawRect( aPixRect );
782  aDrawRect.SetTop( nScrY + aOutputData.GetScrH() );
783  if ( nX2==rDoc.MaxCol() )
784  {
785  // no double painting of the corner
786  if ( bLayoutRTL )
787  aDrawRect.SetLeft( nScrX );
788  else
789  aDrawRect.SetRight( nScrX + aOutputData.GetScrW() - 1 );
790  }
791  if (aDrawRect.Bottom() >= aDrawRect.Top())
792  pContentDev->DrawRect( aDrawRect );
793  }
794 
795  // restore MapMode
796  pContentDev->SetMapMode(aCurrentMapMode);
797  }
798 
799  if ( rDoc.HasBackgroundDraw( nTab, aDrawingRectLogic ) )
800  {
801  pContentDev->SetMapMode(MapMode(MapUnit::MapPixel));
802  aOutputData.DrawClear();
803 
804  // drawing background
805 
806  pContentDev->SetMapMode(aDrawMode);
807  DrawRedraw( aOutputData, SC_LAYER_BACK );
808  }
809  else
810  aOutputData.SetSolidBackground(!bNoBackgroundAndGrid);
811 
812  aOutputData.DrawDocumentBackground();
813 
814  if (bGridFirst && (bGrid || bPage) && !bNoBackgroundAndGrid)
815  aOutputData.DrawGrid(*pContentDev, bGrid, bPage);
816 
817  aOutputData.DrawBackground(*pContentDev);
818 
819  if (!bGridFirst && (bGrid || bPage) && !bNoBackgroundAndGrid)
820  aOutputData.DrawGrid(*pContentDev, bGrid, bPage);
821 
822  pContentDev->SetMapMode(MapMode(MapUnit::MapPixel));
823 
824  if ( bPageMode )
825  {
826  // DrawPagePreview draws complete lines/page numbers, must always be clipped
827  if ( aOutputData.SetChangedClip() )
828  {
829  DrawPagePreview(nX1,nY1,nX2,nY2, *pContentDev);
830  pContentDev->SetClipRegion();
831  }
832  }
833 
834  aOutputData.DrawShadow();
835  aOutputData.DrawFrame(*pContentDev);
836 
837  // Show Note Mark
838  if ( rOpts.GetOption( VOPT_NOTES ) )
839  aOutputData.DrawNoteMarks(*pContentDev);
840 
841  if ( !bLogicText )
842  aOutputData.DrawStrings(); // in pixel MapMode
843 
844  // edit cells and printer-metrics text must be before the buttons
845  // (DataPilot buttons contain labels in UI font)
846 
847  pContentDev->SetMapMode(mrViewData.GetLogicMode(eWhich));
848  if ( bLogicText )
849  aOutputData.DrawStrings(true); // in logic MapMode if bLogicText is set
850  aOutputData.DrawEdit(true);
851 
852  // the buttons are painted in absolute coordinates
853  if (bIsTiledRendering)
854  {
855  // Tiled offset nScrX, nScrY
856  MapMode aMap( MapUnit::MapPixel );
857  Point aOrigin = aOriginalMode.GetOrigin();
858  aOrigin.setX(aOrigin.getX() / TWIPS_PER_PIXEL + nScrX);
859  aOrigin.setY(aOrigin.getY() / TWIPS_PER_PIXEL + nScrY);
860  aMap.SetOrigin(aOrigin);
861  pContentDev->SetMapMode(aMap);
862  }
863  else
864  pContentDev->SetMapMode(MapMode(MapUnit::MapPixel));
865 
866  // Autofilter- and Pivot-Buttons
867 
868  DrawButtons(nX1, nX2, rTableInfo, pContentDev); // Pixel
869 
870  pContentDev->SetMapMode(MapMode(MapUnit::MapPixel));
871 
872  aOutputData.DrawClipMarks();
873 
874  // In any case, Scenario / ChangeTracking must happen after DrawGrid, also for !bGridFirst
875 
878 
879  SCTAB nTabCount = rDoc.GetTableCount();
880  const std::vector<ScHighlightEntry> &rHigh = mrViewData.GetView()->GetHighlightRanges();
881  bool bHasScenario = ( nTab+1<nTabCount && rDoc.IsScenario(nTab+1) && !rDoc.IsScenario(nTab) );
882  bool bHasChange = ( rDoc.GetChangeTrack() != nullptr );
883 
884  if ( bHasChange || bHasScenario || !rHigh.empty() )
885  {
887 
888  if ( bHasChange )
889  aOutputData.DrawChangeTrack();
890 
891  if ( bHasScenario )
892  lcl_DrawScenarioFrames( pContentDev, mrViewData, eWhich, nX1,nY1,nX2,nY2 );
893 
894  lcl_DrawHighlight( aOutputData, mrViewData, rHigh );
895  }
896 
897  // Drawing foreground
898 
899  pContentDev->SetMapMode(aDrawMode);
900 
901  // Bitmaps and buttons are in absolute pixel coordinates.
902  const MapMode aOrig = pContentDev->GetMapMode();
903  if (bIsTiledRendering)
904  {
905  Point aOrigin = aOriginalMode.GetOrigin();
906  Size aPixelOffset(aOrigin.getX() / TWIPS_PER_PIXEL, aOrigin.getY() / TWIPS_PER_PIXEL);
907  pContentDev->SetPixelOffset(aPixelOffset);
909  }
910 
911  DrawRedraw( aOutputData, SC_LAYER_FRONT );
912  DrawRedraw( aOutputData, SC_LAYER_INTERN );
913  DrawSdrGrid( aDrawingRectLogic, pContentDev );
914 
915  if (bIsTiledRendering)
916  {
917  pContentDev->SetPixelOffset(Size());
918  pContentDev->SetMapMode(aOrig);
919  }
920 
921  pContentDev->SetMapMode(MapMode(MapUnit::MapPixel));
922 
923  if ( mrViewData.IsRefMode() && nTab >= mrViewData.GetRefStartZ() && nTab <= mrViewData.GetRefEndZ() )
924  {
925  Color aRefColor( rColorCfg.GetColorValue(svtools::CALCREFERENCE).nColor );
928  aRefColor, false );
929  }
930 
931  // range finder
932 
933  ScInputHandler* pHdl = pScMod->GetInputHdl( mrViewData.GetViewShell() );
934  if (pHdl)
935  {
936  ScDocShell* pDocSh = mrViewData.GetDocShell();
937  ScRangeFindList* pRangeFinder = pHdl->GetRangeFindList();
938  if ( pRangeFinder && !pRangeFinder->IsHidden() &&
939  pRangeFinder->GetDocName() == pDocSh->GetTitle() )
940  {
941  sal_uInt16 nCount = static_cast<sal_uInt16>(pRangeFinder->Count());
942  for (sal_uInt16 i=0; i<nCount; i++)
943  {
944  ScRangeFindData& rData = pRangeFinder->GetObject(i);
945 
946  ScRange aRef = rData.aRef;
947  aRef.PutInOrder();
948  if ( aRef.aStart.Tab() >= nTab && aRef.aEnd.Tab() <= nTab )
949  aOutputData.DrawRefMark( aRef.aStart.Col(), aRef.aStart.Row(),
950  aRef.aEnd.Col(), aRef.aEnd.Row(),
951  rData.nColor,
952  true );
953  }
954  }
955  }
956 
957  {
958  // end redraw
959  ScTabViewShell* pTabViewShell = mrViewData.GetViewShell();
960 
961  if(pTabViewShell)
962  {
963  MapMode aCurrentMapMode(pContentDev->GetMapMode());
964  pContentDev->SetMapMode(aDrawMode);
965 
966  if (bIsTiledRendering)
967  {
968  Point aOrigin = aOriginalMode.GetOrigin();
969  aOrigin.setX(aOrigin.getX() / TWIPS_PER_PIXEL + aOutputData.nScrX);
970  aOrigin.setY(aOrigin.getY() / TWIPS_PER_PIXEL + aOutputData.nScrY);
971  const double twipFactor = 15 * 1.76388889; // 26.45833335
972  aOrigin = Point(aOrigin.getX() * twipFactor,
973  aOrigin.getY() * twipFactor);
974  MapMode aNew = rDevice.GetMapMode();
975  aNew.SetOrigin(aOrigin);
976  rDevice.SetMapMode(aNew);
977  }
978 
979  SdrView* pDrawView = pTabViewShell->GetScDrawView();
980 
981  if(pDrawView)
982  {
983  // #i74769# work with SdrPaintWindow directly
984  pDrawView->EndDrawLayers(*pTargetPaintWindow, true);
985  }
986 
987  pContentDev->SetMapMode(aCurrentMapMode);
988  }
989  }
990 
991  // paint in-place editing on other views
992  if (bIsTiledRendering)
993  {
994  ScTabViewShell* pThisViewShell = mrViewData.GetViewShell();
995  SfxViewShell* pViewShell = SfxViewShell::GetFirst();
996 
997  while (pViewShell)
998  {
999  if (pViewShell != pThisViewShell && pViewShell->GetDocId() == pThisViewShell->GetDocId())
1000  {
1001  ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
1002  if (pTabViewShell)
1003  {
1004  ScViewData& rOtherViewData = pTabViewShell->GetViewData();
1005  ScSplitPos eOtherWhich = rOtherViewData.GetEditActivePart();
1006 
1007  bool bOtherEditMode = rOtherViewData.HasEditView(eOtherWhich);
1008  SCCOL nCol1 = rOtherViewData.GetEditStartCol();
1009  SCROW nRow1 = rOtherViewData.GetEditStartRow();
1010  SCCOL nCol2 = rOtherViewData.GetEditEndCol();
1011  SCROW nRow2 = rOtherViewData.GetEditEndRow();
1012  bOtherEditMode = bOtherEditMode
1013  && ( nCol2 >= nX1 && nCol1 <= nX2 && nRow2 >= nY1 && nRow1 <= nY2 );
1014  if (bOtherEditMode && rOtherViewData.GetRefTabNo() == nTab)
1015  {
1016  EditView* pOtherEditView = rOtherViewData.GetEditView(eOtherWhich);
1017  if (pOtherEditView)
1018  {
1019  tools::Long nScreenX = aOutputData.nScrX;
1020  tools::Long nScreenY = aOutputData.nScrY;
1021 
1022  rDevice.SetLineColor();
1023  rDevice.SetFillColor(pOtherEditView->GetBackgroundColor());
1024  Point aStart = mrViewData.GetScrPos( nCol1, nRow1, eOtherWhich );
1025  Point aEnd = mrViewData.GetScrPos( nCol2+1, nRow2+1, eOtherWhich );
1026 
1027  // don't overwrite grid
1028  tools::Long nLayoutSign = bLayoutRTL ? -1 : 1;
1029  aEnd.AdjustX( -(2 * nLayoutSign) );
1030  aEnd.AdjustY( -2 );
1031 
1032  tools::Rectangle aBackground(aStart, aEnd);
1033 
1034  // Need to draw the background in absolute coords.
1035  Point aOrigin = aOriginalMode.GetOrigin();
1036  aOrigin.setX(aOrigin.getX() / TWIPS_PER_PIXEL + nScreenX);
1037  aOrigin.setY(aOrigin.getY() / TWIPS_PER_PIXEL + nScreenY);
1038  aBackground += aOrigin;
1039  rDevice.SetMapMode(aDrawMode);
1040 
1041  static const double twipFactor = 15 * 1.76388889; // 26.45833335
1042  // keep into account the zoom factor
1043  aOrigin = Point((aOrigin.getX() * twipFactor) / static_cast<double>(aDrawMode.GetScaleX()),
1044  (aOrigin.getY() * twipFactor) / static_cast<double>(aDrawMode.GetScaleY()));
1045 
1046  MapMode aNew = rDevice.GetMapMode();
1047  aNew.SetOrigin(aOrigin);
1048  rDevice.SetMapMode(aNew);
1049 
1050  // paint the background
1051  rDevice.DrawRect(rDevice.PixelToLogic(aBackground));
1052 
1053  tools::Rectangle aEditRect(aBackground);
1054  aEditRect.AdjustLeft(1);
1055  aEditRect.AdjustTop(1);
1056 
1057  // EditView has an 'output area' which is used to clip the 'paint area' we provide below.
1058  // So they need to be in the same coordinates/units. This is tied to the mapmode of the gridwin
1059  // attached to the EditView, so we have to change its mapmode too (temporarily). We save the
1060  // original mapmode and 'output area' and roll them back when we finish painting to rDevice.
1061  vcl::Window* pOtherWin = pOtherEditView->GetWindow();
1062  const tools::Rectangle aOrigOutputArea(pOtherEditView->GetOutputArea()); // Not in pixels.
1063  const MapMode aOrigMapMode = pOtherWin->GetMapMode();
1064  pOtherWin->SetMapMode(rDevice.GetMapMode());
1065 
1066  // Avoid sending wrong cursor/selection messages by the 'other' view, as the output-area is going
1067  // to be tweaked temporarily to match the current view's zoom.
1068  SuppressEditViewMessagesGuard aGuard(*pOtherEditView);
1069 
1070  pOtherEditView->SetOutputArea(rDevice.PixelToLogic(aEditRect));
1071  pOtherEditView->Paint(rDevice.PixelToLogic(aEditRect), &rDevice);
1072 
1073  // Rollback the mapmode and 'output area'.
1074  pOtherWin->SetMapMode(aOrigMapMode);
1075  pOtherEditView->SetOutputArea(aOrigOutputArea);
1076  rDevice.SetMapMode(MapMode(MapUnit::MapPixel));
1077  }
1078  }
1079  }
1080  }
1081 
1082  pViewShell = SfxViewShell::GetNext(*pViewShell);
1083  }
1084 
1085  }
1086 
1087  // In-place editing - when the user is typing, we need to paint the text
1088  // using the editeng.
1089  // It's being done after EndDrawLayers() to get it outside the overlay
1090  // buffer and on top of everything.
1091  if (bInPlaceEditing)
1092  {
1093  // get the coordinates of the area we need to clear (overpaint by
1094  // the background)
1095  SCCOL nCol1 = mrViewData.GetEditStartCol();
1096  SCROW nRow1 = mrViewData.GetEditStartRow();
1097  SCCOL nCol2 = mrViewData.GetEditEndCol();
1098  SCROW nRow2 = mrViewData.GetEditEndRow();
1099  rDevice.SetLineColor();
1100  rDevice.SetFillColor(pEditView->GetBackgroundColor());
1101  Point aStart = mrViewData.GetScrPos( nCol1, nRow1, eWhich );
1102  Point aEnd = mrViewData.GetScrPos( nCol2+1, nRow2+1, eWhich );
1103 
1104  // don't overwrite grid
1105  tools::Long nLayoutSign = bLayoutRTL ? -1 : 1;
1106  aEnd.AdjustX( -(2 * nLayoutSign) );
1107  aEnd.AdjustY( -2 );
1108 
1109  // set the correct mapmode
1110  tools::Rectangle aBackground(aStart, aEnd);
1111  tools::Rectangle aBGAbs(aStart, aEnd);
1112 
1113  if (bIsTiledRendering)
1114  {
1115  // Need to draw the background in absolute coords.
1116  Point aOrigin = aOriginalMode.GetOrigin();
1117  aOrigin.setX(aOrigin.getX() / TWIPS_PER_PIXEL + nScrX);
1118  aOrigin.setY(aOrigin.getY() / TWIPS_PER_PIXEL + nScrY);
1119  aBackground += aOrigin;
1120  rDevice.SetMapMode(aDrawMode);
1121  }
1122  else
1123  rDevice.SetMapMode(mrViewData.GetLogicMode());
1124 
1125  if (bIsTiledRendering)
1126  {
1127  Point aOrigin = aOriginalMode.GetOrigin();
1128  aOrigin.setX(aOrigin.getX() / TWIPS_PER_PIXEL + nScrX);
1129  aOrigin.setY(aOrigin.getY() / TWIPS_PER_PIXEL + nScrY);
1130  static const double twipFactor = 15 * 1.76388889; // 26.45833335
1131  // keep into account the zoom factor
1132  aOrigin = Point((aOrigin.getX() * twipFactor) / static_cast<double>(aDrawMode.GetScaleX()),
1133  (aOrigin.getY() * twipFactor) / static_cast<double>(aDrawMode.GetScaleY()));
1134  MapMode aNew = rDevice.GetMapMode();
1135  aNew.SetOrigin(aOrigin);
1136  rDevice.SetMapMode(aNew);
1137  }
1138 
1139  // paint the background
1140  tools::Rectangle aLogicRect(rDevice.PixelToLogic(aBackground));
1141  //tdf#100925, rhbz#1283420, Draw some text here, to get
1142  //X11CairoTextRender::getCairoContext called, so that the forced read
1143  //from the underlying X Drawable gets it to sync.
1144  rDevice.DrawText(aLogicRect.BottomLeft(), " ");
1145  rDevice.DrawRect(aLogicRect);
1146 
1147  // paint the editeng text
1148  if (bIsTiledRendering)
1149  {
1150  tools::Rectangle aEditRect(aBackground);
1151  aEditRect.AdjustLeft(1);
1152  aEditRect.AdjustTop(1);
1153  // EditView has an 'output area' which is used to clip the paint area we provide below.
1154  // So they need to be in the same coordinates/units. This is tied to the mapmode of the gridwin
1155  // attached to the EditView, so we have to change its mapmode too (temporarily). We save the
1156  // original mapmode and 'output area' and roll them back when we finish painting to rDevice.
1157  const tools::Rectangle aOrigOutputArea(pEditView->GetOutputArea()); // Not in pixels.
1158  const MapMode aOrigMapMode = GetMapMode();
1159  SetMapMode(rDevice.GetMapMode());
1160 
1161  // Avoid sending wrong cursor/selection messages by the current view, as the output-area is going
1162  // to be tweaked temporarily to match other view's zoom. (This does not affect the manual
1163  // cursor-messaging done in the non print-twips mode)
1164  SuppressEditViewMessagesGuard aGuard(*pEditView);
1165 
1166  pEditView->SetOutputArea(rDevice.PixelToLogic(aEditRect));
1167  pEditView->Paint(rDevice.PixelToLogic(aEditRect), &rDevice);
1168 
1169  // EditView will do the cursor notifications correctly if we're in
1170  // print-twips messaging mode.
1171  if (!comphelper::LibreOfficeKit::isCompatFlagSet(
1172  comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs))
1173  {
1174  // Now we need to get relative cursor position within the editview.
1175  // This is for sending the pixel-aligned twips position of the cursor to the specific views with
1176  // the same given zoom level.
1177  tools::Rectangle aCursorRect = pEditView->GetEditCursor();
1178  Point aCursPos = OutputDevice::LogicToLogic(aCursorRect.TopLeft(),
1179  MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
1180 
1181  const MapMode& rDevMM = rDevice.GetMapMode();
1182  MapMode aMM(MapUnit::MapTwip);
1183  aMM.SetScaleX(rDevMM.GetScaleX());
1184  aMM.SetScaleY(rDevMM.GetScaleY());
1185 
1186  aBGAbs.AdjustLeft(1);
1187  aBGAbs.AdjustTop(1);
1188  aCursorRect = OutputDevice::PixelToLogic(aBGAbs, aMM);
1189  aCursorRect.setWidth(0);
1190  aCursorRect.Move(aCursPos.getX(), 0);
1191  // Sends view cursor position to views of all matching zooms if needed (avoids duplicates).
1192  InvalidateLOKViewCursor(aCursorRect, aMM.GetScaleX(), aMM.GetScaleY());
1193  }
1194 
1195  // Rollback the mapmode and 'output area'.
1196  SetMapMode(aOrigMapMode);
1197  pEditView->SetOutputArea(aOrigOutputArea);
1198  }
1199  else
1200  {
1201  tools::Rectangle aEditRect(Point(nScrX, nScrY), Size(aOutputData.GetScrW(), aOutputData.GetScrH()));
1202  pEditView->Paint(rDevice.PixelToLogic(aEditRect), &rDevice);
1203  }
1204 
1205  rDevice.SetMapMode(MapMode(MapUnit::MapPixel));
1206 
1207  // restore the cursor it was originally visible
1208  if (bInPlaceVisCursor)
1209  pInPlaceCrsr->Show();
1210  }
1211 
1213  {
1214  // flush OverlayManager before changing the MapMode
1216 
1217  // set MapMode for text edit
1218  rDevice.SetMapMode(mrViewData.GetLogicMode());
1219  }
1220  else
1221  rDevice.SetMapMode(aDrawMode);
1222 
1223  if (mpNoteMarker)
1224  mpNoteMarker->Draw(); // Above the cursor, in drawing map mode
1225 }
1226 
1227 namespace
1228 {
1229  template<typename IndexType>
1230  void lcl_getBoundingRowColumnforTile(ScViewData& rViewData,
1231  tools::Long nTileStartPosPx, tools::Long nTileEndPosPx,
1232  sal_Int32& nTopLeftTileOffset, sal_Int32& nTopLeftTileOrigin,
1233  sal_Int32& nTopLeftTileIndex, sal_Int32& nBottomRightTileIndex)
1234  {
1235  const bool bColumnHeader = std::is_same<IndexType, SCCOL>::value;
1236 
1237  SCTAB nTab = rViewData.GetTabNo();
1238 
1239  IndexType nStartIndex = -1;
1240  IndexType nEndIndex = -1;
1241  tools::Long nStartPosPx = 0;
1242  tools::Long nEndPosPx = 0;
1243 
1244  ScPositionHelper& rPositionHelper =
1245  bColumnHeader ? rViewData.GetLOKWidthHelper() : rViewData.GetLOKHeightHelper();
1246  const auto& rStartNearest = rPositionHelper.getNearestByPosition(nTileStartPosPx);
1247  const auto& rEndNearest = rPositionHelper.getNearestByPosition(nTileEndPosPx);
1248 
1249  ScBoundsProvider aBoundsProvider(rViewData, nTab, bColumnHeader);
1250  aBoundsProvider.Compute(rStartNearest, rEndNearest, nTileStartPosPx, nTileEndPosPx);
1251  aBoundsProvider.GetStartIndexAndPosition(nStartIndex, nStartPosPx); ++nStartIndex;
1252  aBoundsProvider.GetEndIndexAndPosition(nEndIndex, nEndPosPx);
1253 
1254  nTopLeftTileOffset = nTileStartPosPx - nStartPosPx;
1255  nTopLeftTileOrigin = nStartPosPx;
1256  nTopLeftTileIndex = nStartIndex;
1257  nBottomRightTileIndex = nEndIndex;
1258  }
1259 
1260  class ScLOKProxyObjectContact final : public sdr::contact::ObjectContactOfPageView
1261  {
1262  private:
1263  sdr::contact::ObjectContact& mrRealObjectContact;
1264 
1265  public:
1266  explicit ScLOKProxyObjectContact(
1267  sdr::contact::ObjectContact& rRealOC,
1268  SdrPageWindow& rPageWindow,
1269  const char* pDebugName) :
1270  ObjectContactOfPageView(rPageWindow, pDebugName),
1271  mrRealObjectContact(rRealOC)
1272  {
1273  }
1274 
1275  virtual bool supportsGridOffsets() const override { return true; }
1276 
1278  basegfx::B2DVector& rTarget,
1279  const sdr::contact::ViewObjectContact& rClient) const override
1280  {
1281  SdrObject* pTargetSdrObject(rClient.GetViewContact().TryToGetSdrObject());
1282  if (pTargetSdrObject)
1283  rTarget = pTargetSdrObject->GetViewContact().GetViewObjectContact(mrRealObjectContact).getGridOffset();
1284  }
1285  };
1286 
1287  class ScLOKDrawView : public FmFormView
1288  {
1289  public:
1290  ScLOKDrawView(OutputDevice* pOut, ScViewData& rData) :
1291  FmFormView(*rData.GetDocument().GetDrawLayer(), pOut),
1292  pScDrawView(rData.GetScDrawView())
1293  {
1294  }
1295 
1297  SdrPageWindow& rPageWindow, const char* pDebugName) const override
1298  {
1299  if (!pScDrawView)
1300  return SdrView::createViewSpecificObjectContact(rPageWindow, pDebugName);
1301 
1302  SdrPageView* pPageView(pScDrawView->GetSdrPageView());
1303  if (!pPageView)
1304  return SdrView::createViewSpecificObjectContact(rPageWindow, pDebugName);
1305 
1306  SdrPageWindow* pSdrPageWindow = pPageView->GetPageWindow(0);
1307  if (!pSdrPageWindow)
1308  return SdrView::createViewSpecificObjectContact(rPageWindow, pDebugName);
1309 
1310  return new ScLOKProxyObjectContact(pSdrPageWindow->GetObjectContact(), rPageWindow, pDebugName);
1311  }
1312 
1313  private:
1314  ScDrawView* pScDrawView;
1315  };
1316 } // anonymous namespace
1317 
1319  int nOutputWidth, int nOutputHeight,
1320  int nTilePosX, int nTilePosY,
1321  tools::Long nTileWidth, tools::Long nTileHeight )
1322 {
1323  Fraction origZoomX = mrViewData.GetZoomX();
1324  Fraction origZoomY = mrViewData.GetZoomY();
1325 
1326  // Output size is in pixels while tile position and size are in logical units (twips).
1327 
1328  // Assumption: always paint the whole sheet i.e. "visible" range is always
1329  // from (0,0) to last data position.
1330 
1331  // Tile geometry is independent of the zoom level, but the output size is
1332  // dependent of the zoom level. Determine the correct zoom level before
1333  // we start.
1334 
1335  // FIXME the painting works using a mixture of drawing with coordinates in
1336  // pixels and in logic coordinates; it should be cleaned up to use logic
1337  // coords only, and avoid all the SetMapMode()'s.
1338  // Similarly to Writer, we should set the mapmode once on the rDevice, and
1339  // not care about any zoom settings.
1340 
1341  Fraction aFracX(tools::Long(nOutputWidth * TWIPS_PER_PIXEL), nTileWidth);
1342  Fraction aFracY(tools::Long(nOutputHeight * TWIPS_PER_PIXEL), nTileHeight);
1343 
1344  const bool bChangeZoom = (aFracX != origZoomX || aFracY != origZoomY);
1345 
1346  // page break zoom, and aLogicMode in ScViewData
1347  // FIXME: there are issues when SetZoom is called conditionally.
1348  mrViewData.SetZoom(aFracX, aFracY, true);
1349  if (bChangeZoom)
1350  {
1351  if (ScDrawView* pDrawView = mrViewData.GetScDrawView())
1352  pDrawView->resetGridOffsetsForAllSdrPageViews();
1353  }
1354 
1355  const double fTilePosXPixel = static_cast<double>(nTilePosX) * nOutputWidth / nTileWidth;
1356  const double fTilePosYPixel = static_cast<double>(nTilePosY) * nOutputHeight / nTileHeight;
1357  const double fTileBottomPixel = static_cast<double>(nTilePosY + nTileHeight) * nOutputHeight / nTileHeight;
1358  const double fTileRightPixel = static_cast<double>(nTilePosX + nTileWidth) * nOutputWidth / nTileWidth;
1359 
1360  SCTAB nTab = mrViewData.GetTabNo();
1361  ScDocument& rDoc = mrViewData.GetDocument();
1362 
1363  const double fPPTX = mrViewData.GetPPTX();
1364  const double fPPTY = mrViewData.GetPPTY();
1365 
1366  // find approximate col/row offsets of nearby.
1367  sal_Int32 nTopLeftTileRowOffset = 0;
1368  sal_Int32 nTopLeftTileColOffset = 0;
1369  sal_Int32 nTopLeftTileRowOrigin = 0;
1370  sal_Int32 nTopLeftTileColOrigin = 0;
1371 
1372  sal_Int32 nTopLeftTileRow = 0;
1373  sal_Int32 nTopLeftTileCol = 0;
1374  sal_Int32 nBottomRightTileRow = 0;
1375  sal_Int32 nBottomRightTileCol = 0;
1376 
1377  lcl_getBoundingRowColumnforTile<SCROW>(mrViewData,
1378  fTilePosYPixel, fTileBottomPixel,
1379  nTopLeftTileRowOffset, nTopLeftTileRowOrigin,
1380  nTopLeftTileRow, nBottomRightTileRow);
1381 
1382  lcl_getBoundingRowColumnforTile<SCCOL>(mrViewData,
1383  fTilePosXPixel, fTileRightPixel,
1384  nTopLeftTileColOffset, nTopLeftTileColOrigin,
1385  nTopLeftTileCol, nBottomRightTileCol);
1386 
1387  // Enlarge
1388  nBottomRightTileCol++;
1389  nBottomRightTileRow++;
1390 
1391  if (nBottomRightTileCol > rDoc.MaxCol())
1392  nBottomRightTileCol = rDoc.MaxCol();
1393 
1394  if (nBottomRightTileRow > MAXTILEDROW)
1395  nBottomRightTileRow = MAXTILEDROW;
1396 
1397  // size of the document including drawings, charts, etc.
1398  SCCOL nEndCol = 0;
1399  SCROW nEndRow = 0;
1400  rDoc.GetTiledRenderingArea(nTab, nEndCol, nEndRow);
1401 
1402  if (nEndCol < nBottomRightTileCol)
1403  nEndCol = nBottomRightTileCol;
1404 
1405  if (nEndRow < nBottomRightTileRow)
1406  nEndRow = nBottomRightTileRow;
1407 
1408  nTopLeftTileCol = std::max<sal_Int32>(nTopLeftTileCol, 0);
1409  nTopLeftTileRow = std::max<sal_Int32>(nTopLeftTileRow, 0);
1410  nTopLeftTileColOrigin = nTopLeftTileColOrigin * TWIPS_PER_PIXEL;
1411  nTopLeftTileRowOrigin = nTopLeftTileRowOrigin * TWIPS_PER_PIXEL;
1412 
1413  // Checkout -> 'rDoc.ExtendMerge' ... if we miss merged cells.
1414 
1415  // Origin must be the offset of the first col and row
1416  // containing our top-left pixel.
1417  const MapMode aOriginalMode = rDevice.GetMapMode();
1418  MapMode aAbsMode = aOriginalMode;
1419  const Point aOrigin(-nTopLeftTileColOrigin, -nTopLeftTileRowOrigin);
1420  aAbsMode.SetOrigin(aOrigin);
1421  rDevice.SetMapMode(aAbsMode);
1422 
1423  ScTableInfo aTabInfo(nEndRow + 3);
1424  rDoc.FillInfo(aTabInfo, nTopLeftTileCol, nTopLeftTileRow,
1425  nBottomRightTileCol, nBottomRightTileRow,
1426  nTab, fPPTX, fPPTY, false, false);
1427 
1428 // FIXME: is this called some
1429 // Point aScrPos = mrViewData.GetScrPos( nX1, nY1, eWhich );
1430 
1431  ScOutputData aOutputData(&rDevice, OUTTYPE_WINDOW, aTabInfo, &rDoc, nTab,
1432  -nTopLeftTileColOffset,
1433  -nTopLeftTileRowOffset,
1434  nTopLeftTileCol, nTopLeftTileRow,
1435  nBottomRightTileCol, nBottomRightTileRow,
1436  fPPTX, fPPTY, nullptr, nullptr);
1437 
1438  // setup the SdrPage so that drawinglayer works correctly
1439  ScDrawLayer* pModel = rDoc.GetDrawLayer();
1440  if (pModel)
1441  {
1442  bool bPrintTwipsMsgs = comphelper::LibreOfficeKit::isCompatFlagSet(
1443  comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs);
1444  mpLOKDrawView.reset(bPrintTwipsMsgs ?
1445  new ScLOKDrawView(
1446  &rDevice,
1447  mrViewData) :
1448  new FmFormView(
1449  *pModel,
1450  &rDevice));
1451  mpLOKDrawView->ShowSdrPage(mpLOKDrawView->GetModel()->GetPage(nTab));
1452  aOutputData.SetDrawView(mpLOKDrawView.get());
1453  aOutputData.SetSpellCheckContext(mpSpellCheckCxt.get());
1454  }
1455 
1456  // draw the content
1457  DrawContent(rDevice, aTabInfo, aOutputData, true);
1458  rDevice.SetMapMode(aOriginalMode);
1459 
1460  // Flag drawn formula cells "unchanged".
1461  rDoc.ResetChanged(ScRange(nTopLeftTileCol, nTopLeftTileRow, nTab, nBottomRightTileCol, nBottomRightTileRow, nTab));
1462  rDoc.PrepareFormulaCalc();
1463 
1464  mrViewData.SetZoom(origZoomX, origZoomY, true);
1465  if (bChangeZoom)
1466  {
1467  if (ScDrawView* pDrawView = mrViewData.GetScDrawView())
1468  pDrawView->resetGridOffsetsForAllSdrPageViews();
1469  }
1470 }
1471 
1473 {
1474  OString sRectangle;
1475  if (!pRectangle)
1476  sRectangle = "EMPTY";
1477  else
1478  {
1479  tools::Rectangle aRectangle(*pRectangle);
1480  // When dragging shapes the map mode is disabled.
1481  if (IsMapModeEnabled())
1482  {
1483  if (GetMapMode().GetMapUnit() == MapUnit::Map100thMM)
1484  aRectangle = OutputDevice::LogicToLogic(aRectangle, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
1485  }
1486  else
1487  aRectangle = PixelToLogic(aRectangle, MapMode(MapUnit::MapTwip));
1488  sRectangle = aRectangle.toString();
1489  }
1490 
1491  ScTabViewShell* pViewShell = mrViewData.GetViewShell();
1492  SfxLokHelper::notifyInvalidation(pViewShell, sRectangle);
1493 }
1494 
1495 void ScGridWindow::SetCellSelectionPixel(int nType, int nPixelX, int nPixelY)
1496 {
1497  ScTabView* pTabView = mrViewData.GetView();
1498  ScTabViewShell* pViewShell = mrViewData.GetViewShell();
1499  ScInputHandler* pInputHandler = SC_MOD()->GetInputHdl(pViewShell);
1500 
1501  if (pInputHandler && pInputHandler->IsInputMode())
1502  {
1503  // we need to switch off the editeng
1505  pViewShell->UpdateInputHandler();
1506  }
1507 
1508  if (nType == LOK_SETTEXTSELECTION_RESET)
1509  {
1510  pTabView->DoneBlockMode();
1511  return;
1512  }
1513 
1514  // obtain the current selection
1516 
1517  SCCOL nCol1, nCol2;
1518  SCROW nRow1, nRow2;
1519  SCTAB nTab1, nTab2;
1520 
1521  bool bWasEmpty = false;
1522  if (aRangeList.empty())
1523  {
1524  nCol1 = nCol2 = mrViewData.GetCurX();
1525  nRow1 = nRow2 = mrViewData.GetCurY();
1526  bWasEmpty = true;
1527  }
1528  else
1529  aRangeList.Combine().GetVars(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
1530 
1531  // convert the coordinates to column/row
1532  SCCOL nNewPosX;
1533  SCROW nNewPosY;
1534  SCTAB nTab = mrViewData.GetTabNo();
1535  mrViewData.GetPosFromPixel(nPixelX, nPixelY, eWhich, nNewPosX, nNewPosY);
1536 
1537  // change the selection
1538  switch (nType)
1539  {
1540  case LOK_SETTEXTSELECTION_START:
1541  if (nNewPosX != nCol1 || nNewPosY != nRow1 || bWasEmpty)
1542  {
1543  pTabView->SetCursor(nNewPosX, nNewPosY);
1544  pTabView->DoneBlockMode();
1545  pTabView->InitBlockMode(nNewPosX, nNewPosY, nTab, true);
1546  pTabView->MarkCursor(nCol2, nRow2, nTab);
1547  }
1548  break;
1549  case LOK_SETTEXTSELECTION_END:
1550  if (nNewPosX != nCol2 || nNewPosY != nRow2 || bWasEmpty)
1551  {
1552  pTabView->SetCursor(nCol1, nRow1);
1553  pTabView->DoneBlockMode();
1554  pTabView->InitBlockMode(nCol1, nRow1, nTab, true);
1555  pTabView->MarkCursor(nNewPosX, nNewPosY, nTab);
1556  }
1557  break;
1558  default:
1559  assert(false);
1560  break;
1561  }
1562 }
1563 
1565 {
1566  // called at the end of painting, and from timer after background text width calculation
1567 
1568  if (!bNeedsRepaint)
1569  return;
1570 
1571  bNeedsRepaint = false;
1572  if (aRepaintPixel.IsEmpty())
1573  Invalidate();
1574  else
1577 
1578  // selection function in status bar might also be invalid
1579  SfxBindings& rBindings = mrViewData.GetBindings();
1580  rBindings.Invalidate( SID_STATUS_SUM );
1581  rBindings.Invalidate( SID_ATTR_SIZE );
1582  rBindings.Invalidate( SID_TABLE_CELL );
1583 }
1584 
1585 void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, vcl::RenderContext& rRenderContext)
1586 {
1588  if (!pPageData)
1589  return;
1590 
1591  ScDocument& rDoc = mrViewData.GetDocument();
1592  SCTAB nTab = mrViewData.GetTabNo();
1593  Size aWinSize = GetOutputSizePixel();
1594  const svtools::ColorConfig& rColorCfg = SC_MOD()->GetColorConfig();
1596  Color aAutomatic( rColorCfg.GetColorValue(svtools::CALCPAGEBREAK).nColor );
1597 
1598  OUString aPageStr = ScResId( STR_PGNUM );
1599  if ( nPageScript == SvtScriptType::NONE )
1600  {
1601  // get script type of translated "Page" string only once
1602  nPageScript = rDoc.GetStringScriptType( aPageStr );
1603  if (nPageScript == SvtScriptType::NONE)
1605  }
1606 
1607  vcl::Font aFont;
1608  std::unique_ptr<ScEditEngineDefaulter> pEditEng;
1609  const ScPatternAttr& rDefPattern = rDoc.GetPool()->GetDefaultItem(ATTR_PATTERN);
1610  if ( nPageScript == SvtScriptType::LATIN )
1611  {
1612  // use single font and call DrawText directly
1613  rDefPattern.GetFont( aFont, SC_AUTOCOL_BLACK );
1614  aFont.SetColor( COL_LIGHTGRAY );
1615  // font size is set as needed
1616  }
1617  else
1618  {
1619  // use EditEngine to draw mixed-script string
1620  pEditEng.reset(new ScEditEngineDefaulter( EditEngine::CreatePool(), true ));
1621  pEditEng->SetRefMapMode(rRenderContext.GetMapMode());
1622  auto pEditDefaults = std::make_unique<SfxItemSet>( pEditEng->GetEmptyItemSet() );
1623  rDefPattern.FillEditItemSet( pEditDefaults.get() );
1624  pEditDefaults->Put( SvxColorItem( COL_LIGHTGRAY, EE_CHAR_COLOR ) );
1625  pEditEng->SetDefaults( std::move(pEditDefaults) );
1626  }
1627 
1628  sal_uInt16 nCount = sal::static_int_cast<sal_uInt16>( pPageData->GetCount() );
1629  for (sal_uInt16 nPos=0; nPos<nCount; nPos++)
1630  {
1631  ScPrintRangeData& rData = pPageData->GetData(nPos);
1632  ScRange aRange = rData.GetPrintRange();
1633  if ( aRange.aStart.Col() <= nX2+1 && aRange.aEnd.Col()+1 >= nX1 &&
1634  aRange.aStart.Row() <= nY2+1 && aRange.aEnd.Row()+1 >= nY1 )
1635  {
1636  // 3 pixel frame around the print area
1637  // (middle pixel on the grid lines)
1638 
1639  rRenderContext.SetLineColor();
1640  if (rData.IsAutomatic())
1641  rRenderContext.SetFillColor( aAutomatic );
1642  else
1643  rRenderContext.SetFillColor( aManual );
1644 
1645  Point aStart = mrViewData.GetScrPos(
1646  aRange.aStart.Col(), aRange.aStart.Row(), eWhich, true );
1647  Point aEnd = mrViewData.GetScrPos(
1648  aRange.aEnd.Col() + 1, aRange.aEnd.Row() + 1, eWhich, true );
1649  aStart.AdjustX( -2 );
1650  aStart.AdjustY( -2 );
1651 
1652  // Prevent overflows:
1653  if ( aStart.X() < -10 ) aStart.setX( -10 );
1654  if ( aStart.Y() < -10 ) aStart.setY( -10 );
1655  if ( aEnd.X() > aWinSize.Width() + 10 )
1656  aEnd.setX( aWinSize.Width() + 10 );
1657  if ( aEnd.Y() > aWinSize.Height() + 10 )
1658  aEnd.setY( aWinSize.Height() + 10 );
1659 
1660  rRenderContext.DrawRect( tools::Rectangle( aStart, Point(aEnd.X(),aStart.Y()+2) ) );
1661  rRenderContext.DrawRect( tools::Rectangle( aStart, Point(aStart.X()+2,aEnd.Y()) ) );
1662  rRenderContext.DrawRect( tools::Rectangle( Point(aStart.X(),aEnd.Y()-2), aEnd ) );
1663  rRenderContext.DrawRect( tools::Rectangle( Point(aEnd.X()-2,aStart.Y()), aEnd ) );
1664 
1665  // Page breaks
1667 
1668  size_t nColBreaks = rData.GetPagesX();
1669  const SCCOL* pColEnd = rData.GetPageEndX();
1670  size_t nColPos;
1671  for (nColPos=0; nColPos+1<nColBreaks; nColPos++)
1672  {
1673  SCCOL nBreak = pColEnd[nColPos]+1;
1674  if ( nBreak >= nX1 && nBreak <= nX2+1 )
1675  {
1677  if (rDoc.HasColBreak(nBreak, nTab) & ScBreakType::Manual)
1678  rRenderContext.SetFillColor( aManual );
1679  else
1680  rRenderContext.SetFillColor( aAutomatic );
1681  Point aBreak = mrViewData.GetScrPos(
1682  nBreak, aRange.aStart.Row(), eWhich, true );
1683  rRenderContext.DrawRect( tools::Rectangle( aBreak.X()-1, aStart.Y(), aBreak.X(), aEnd.Y() ) );
1684  }
1685  }
1686 
1687  size_t nRowBreaks = rData.GetPagesY();
1688  const SCROW* pRowEnd = rData.GetPageEndY();
1689  size_t nRowPos;
1690  for (nRowPos=0; nRowPos+1<nRowBreaks; nRowPos++)
1691  {
1692  SCROW nBreak = pRowEnd[nRowPos]+1;
1693  if ( nBreak >= nY1 && nBreak <= nY2+1 )
1694  {
1696  if (rDoc.HasRowBreak(nBreak, nTab) & ScBreakType::Manual)
1697  rRenderContext.SetFillColor( aManual );
1698  else
1699  rRenderContext.SetFillColor( aAutomatic );
1700  Point aBreak = mrViewData.GetScrPos(
1701  aRange.aStart.Col(), nBreak, eWhich, true );
1702  rRenderContext.DrawRect( tools::Rectangle( aStart.X(), aBreak.Y()-1, aEnd.X(), aBreak.Y() ) );
1703  }
1704  }
1705 
1706  // Page numbers
1707 
1708  SCROW nPrStartY = aRange.aStart.Row();
1709  for (nRowPos=0; nRowPos<nRowBreaks; nRowPos++)
1710  {
1711  SCROW nPrEndY = pRowEnd[nRowPos];
1712  if ( nPrEndY >= nY1 && nPrStartY <= nY2 )
1713  {
1714  SCCOL nPrStartX = aRange.aStart.Col();
1715  for (nColPos=0; nColPos<nColBreaks; nColPos++)
1716  {
1717  SCCOL nPrEndX = pColEnd[nColPos];
1718  if ( nPrEndX >= nX1 && nPrStartX <= nX2 )
1719  {
1720  Point aPageStart = mrViewData.GetScrPos(
1721  nPrStartX, nPrStartY, eWhich, true );
1722  Point aPageEnd = mrViewData.GetScrPos(
1723  nPrEndX+1,nPrEndY+1, eWhich, true );
1724 
1725  tools::Long nPageNo = rData.GetFirstPage();
1726  if ( rData.IsTopDown() )
1727  nPageNo += static_cast<tools::Long>(nColPos)*nRowBreaks+nRowPos;
1728  else
1729  nPageNo += static_cast<tools::Long>(nRowPos)*nColBreaks+nColPos;
1730 
1731  OUString aThisPageStr = aPageStr.replaceFirst("%1", OUString::number(nPageNo));
1732 
1733  if ( pEditEng )
1734  {
1735  // find right font size with EditEngine
1736  tools::Long nHeight = 100;
1737  pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
1738  pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
1739  pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
1740  pEditEng->SetTextCurrentDefaults( aThisPageStr );
1741  Size aSize100( pEditEng->CalcTextWidth(), pEditEng->GetTextHeight() );
1742 
1743  // 40% of width or 60% of height
1744  tools::Long nSizeX = 40 * ( aPageEnd.X() - aPageStart.X() ) / aSize100.Width();
1745  tools::Long nSizeY = 60 * ( aPageEnd.Y() - aPageStart.Y() ) / aSize100.Height();
1746  nHeight = std::min(nSizeX,nSizeY);
1747  pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
1748  pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
1749  pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
1750 
1751  // centered output with EditEngine
1752  Size aTextSize( pEditEng->CalcTextWidth(), pEditEng->GetTextHeight() );
1753  Point aPos( (aPageStart.X()+aPageEnd.X()-aTextSize.Width())/2,
1754  (aPageStart.Y()+aPageEnd.Y()-aTextSize.Height())/2 );
1755  pEditEng->Draw( &rRenderContext, aPos );
1756  }
1757  else
1758  {
1759  // find right font size for DrawText
1760  aFont.SetFontSize( Size( 0,100 ) );
1761  rRenderContext.SetFont( aFont );
1762  Size aSize100(rRenderContext.GetTextWidth( aThisPageStr ), rRenderContext.GetTextHeight() );
1763 
1764  // 40% of width or 60% of height
1765  tools::Long nSizeX = 40 * ( aPageEnd.X() - aPageStart.X() ) / aSize100.Width();
1766  tools::Long nSizeY = 60 * ( aPageEnd.Y() - aPageStart.Y() ) / aSize100.Height();
1767  aFont.SetFontSize( Size( 0,std::min(nSizeX,nSizeY) ) );
1768  rRenderContext.SetFont( aFont );
1769 
1770  // centered output with DrawText
1771  Size aTextSize(rRenderContext.GetTextWidth( aThisPageStr ), rRenderContext.GetTextHeight() );
1772  Point aPos( (aPageStart.X()+aPageEnd.X()-aTextSize.Width())/2,
1773  (aPageStart.Y()+aPageEnd.Y()-aTextSize.Height())/2 );
1774  rRenderContext.DrawText( aPos, aThisPageStr );
1775  }
1776  }
1777  nPrStartX = nPrEndX + 1;
1778  }
1779  }
1780  nPrStartY = nPrEndY + 1;
1781  }
1782  }
1783  }
1784 }
1785 
1786 void ScGridWindow::DrawButtons(SCCOL nX1, SCCOL nX2, const ScTableInfo& rTabInfo, OutputDevice* pContentDev)
1787 {
1788  aComboButton.SetOutputDevice( pContentDev );
1789 
1790  ScDocument& rDoc = mrViewData.GetDocument();
1791  ScDPFieldButton aCellBtn(pContentDev, &GetSettings().GetStyleSettings(), &mrViewData.GetZoomY(), &rDoc);
1792 
1793  SCCOL nCol;
1794  SCROW nRow;
1795  SCSIZE nArrY;
1796  SCSIZE nQuery;
1797  SCTAB nTab = mrViewData.GetTabNo();
1798  ScDBData* pDBData = nullptr;
1799  std::unique_ptr<ScQueryParam> pQueryParam;
1800 
1801  RowInfo* pRowInfo = rTabInfo.mpRowInfo.get();
1802  sal_uInt16 nArrCount = rTabInfo.mnArrCount;
1803 
1804  bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
1805 
1806  Point aOldPos = aComboButton.GetPosPixel(); // store state for MouseDown/Up
1807  Size aOldSize = aComboButton.GetSizePixel();
1808 
1809  for (nArrY=1; nArrY+1<nArrCount; nArrY++)
1810  {
1811  if ( pRowInfo[nArrY].bAutoFilter && pRowInfo[nArrY].bChanged )
1812  {
1813  RowInfo* pThisRowInfo = &pRowInfo[nArrY];
1814 
1815  nRow = pThisRowInfo->nRowNo;
1816 
1817  for (nCol=nX1; nCol<=nX2; nCol++)
1818  {
1819  CellInfo* pInfo = &pThisRowInfo->pCellInfo[nCol+1];
1820  //if several columns merged on a row, there should be only one auto button at the end of the columns.
1821  //if several rows merged on a column, the button may be in the middle, so "!pInfo->bVOverlapped" should not be used
1822  if ( pInfo->bAutoFilter && !pInfo->bHOverlapped )
1823  {
1824  if (!pQueryParam)
1825  pQueryParam.reset(new ScQueryParam);
1826 
1827  bool bNewData = true;
1828  if (pDBData)
1829  {
1830  SCCOL nStartCol;
1831  SCROW nStartRow;
1832  SCCOL nEndCol;
1833  SCROW nEndRow;
1834  SCTAB nAreaTab;
1835  pDBData->GetArea( nAreaTab, nStartCol, nStartRow, nEndCol, nEndRow );
1836  if ( nCol >= nStartCol && nCol <= nEndCol &&
1837  nRow >= nStartRow && nRow <= nEndRow )
1838  bNewData = false;
1839  }
1840  if (bNewData)
1841  {
1842  pDBData = rDoc.GetDBAtCursor( nCol, nRow, nTab, ScDBDataPortion::AREA );
1843  if (pDBData)
1844  pDBData->GetQueryParam( *pQueryParam );
1845  else
1846  {
1847  // can also be part of DataPilot table
1848  }
1849  }
1850 
1851  // pQueryParam can only include MAXQUERY entries
1852 
1853  bool bSimpleQuery = true;
1854  bool bColumnFound = false;
1855  if (!pQueryParam->bInplace)
1856  bSimpleQuery = false;
1857  SCSIZE nCount = pQueryParam->GetEntryCount();
1858  for (nQuery = 0; nQuery < nCount && bSimpleQuery; ++nQuery)
1859  if (pQueryParam->GetEntry(nQuery).bDoQuery)
1860  {
1861  // Do no restrict to EQUAL here
1862  // (Column head should become blue also when ">1")
1863 
1864  if (pQueryParam->GetEntry(nQuery).nField == nCol)
1865  bColumnFound = true;
1866  if (nQuery > 0)
1867  if (pQueryParam->GetEntry(nQuery).eConnect != SC_AND)
1868  bSimpleQuery = false;
1869  }
1870 
1871  bool bArrowState = bSimpleQuery && bColumnFound;
1872  tools::Long nSizeX;
1873  tools::Long nSizeY;
1874  SCCOL nStartCol= nCol;
1875  SCROW nStartRow = nRow;
1876  //if address(nCol,nRow) is not the start pos of the merge area, the value of the nSizeX will be incorrect, it will be the length of the cell.
1877  //should first get the start pos of the merge area, then get the nSizeX through the start pos.
1878  rDoc.ExtendOverlapped(nStartCol, nStartRow,nCol, nRow, nTab);//get nStartCol,nStartRow
1879  mrViewData.GetMergeSizePixel( nStartCol, nStartRow, nSizeX, nSizeY );//get nSizeX
1880  nSizeY = ScViewData::ToPixel(rDoc.GetRowHeight(nRow, nTab), mrViewData.GetPPTY());
1881  Point aScrPos = mrViewData.GetScrPos( nCol, nRow, eWhich );
1882 
1883  aCellBtn.setBoundingBox(aScrPos, Size(nSizeX-1, nSizeY-1), bLayoutRTL);
1884  aCellBtn.setPopupLeft(bLayoutRTL); // #i114944# AutoFilter button is left-aligned in RTL
1885  aCellBtn.setDrawBaseButton(false);
1886  aCellBtn.setDrawPopupButton(true);
1887  aCellBtn.setHasHiddenMember(bArrowState);
1888  aCellBtn.draw();
1889  }
1890  }
1891  }
1892 
1893  if ( pRowInfo[nArrY].bPivotButton && pRowInfo[nArrY].bChanged )
1894  {
1895  RowInfo* pThisRowInfo = &pRowInfo[nArrY];
1896  nRow = pThisRowInfo->nRowNo;
1897  for (nCol=nX1; nCol<=nX2; nCol++)
1898  {
1899  CellInfo* pInfo = &pThisRowInfo->pCellInfo[nCol+1];
1900  if (pInfo->bHOverlapped || pInfo->bVOverlapped)
1901  continue;
1902 
1903  Point aScrPos = mrViewData.GetScrPos( nCol, nRow, eWhich );
1904  tools::Long nSizeX;
1905  tools::Long nSizeY;
1906  mrViewData.GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
1907  tools::Long nPosX = aScrPos.X();
1908  tools::Long nPosY = aScrPos.Y();
1909  // bLayoutRTL is handled in setBoundingBox
1910 
1911  OUString aStr = rDoc.GetString(nCol, nRow, nTab);
1912  aCellBtn.setText(aStr);
1913  aCellBtn.setBoundingBox(Point(nPosX, nPosY), Size(nSizeX-1, nSizeY-1), bLayoutRTL);
1914  aCellBtn.setPopupLeft(false); // DataPilot popup is always right-aligned for now
1915  aCellBtn.setDrawBaseButton(pInfo->bPivotButton);
1916  aCellBtn.setDrawPopupButton(pInfo->bPivotPopupButton);
1917  aCellBtn.setHasHiddenMember(pInfo->bFilterActive);
1918  aCellBtn.draw();
1919  }
1920  }
1921 
1922  if ( !comphelper::LibreOfficeKit::isActive() && bListValButton && pRowInfo[nArrY].nRowNo == aListValPos.Row() && pRowInfo[nArrY].bChanged )
1923  {
1925  aComboButton.SetPosPixel( aRect.TopLeft() );
1926  aComboButton.SetSizePixel( aRect.GetSize() );
1927  pContentDev->SetClipRegion(vcl::Region(aRect));
1928  aComboButton.Draw();
1929  pContentDev->SetClipRegion(); // always called from Draw() without clip region
1930  aComboButton.SetPosPixel( aOldPos ); // restore old state
1931  aComboButton.SetSizePixel( aOldSize ); // for MouseUp/Down (AutoFilter)
1932  }
1933  }
1934 
1935  pQueryParam.reset();
1936  aComboButton.SetOutputDevice( this );
1937 }
1938 
1940 {
1941  ScDocument& rDoc = mrViewData.GetDocument();
1942  SCTAB nTab = mrViewData.GetTabNo();
1943  bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
1944  tools::Long nLayoutSign = bLayoutRTL ? -1 : 1;
1945 
1946  ScDDComboBoxButton aButton( this ); // for optimal size
1947  Size aBtnSize = aButton.GetSizePixel();
1948 
1949  SCCOL nCol = rButtonPos.Col();
1950  SCROW nRow = rButtonPos.Row();
1951 
1952  tools::Long nCellSizeX; // width of this cell, including merged
1953  tools::Long nDummy;
1954  mrViewData.GetMergeSizePixel( nCol, nRow, nCellSizeX, nDummy );
1955 
1956  // for height, only the cell's row is used, excluding merged cells
1957  tools::Long nCellSizeY = ScViewData::ToPixel( rDoc.GetRowHeight( nRow, nTab ), mrViewData.GetPPTY() );
1958  tools::Long nAvailable = nCellSizeX;
1959 
1960  // left edge of next cell if there is a non-hidden next column
1961  SCCOL nNextCol = nCol + 1;
1962  const ScMergeAttr* pMerge = rDoc.GetAttr( nCol,nRow,nTab, ATTR_MERGE );
1963  if ( pMerge->GetColMerge() > 1 )
1964  nNextCol = nCol + pMerge->GetColMerge(); // next cell after the merged area
1965  while ( nNextCol <= rDoc.MaxCol() && rDoc.ColHidden(nNextCol, nTab) )
1966  ++nNextCol;
1967  bool bNextCell = ( nNextCol <= rDoc.MaxCol() );
1968  if ( bNextCell )
1969  nAvailable = ScViewData::ToPixel( rDoc.GetColWidth( nNextCol, nTab ), mrViewData.GetPPTX() );
1970 
1971  if ( nAvailable < aBtnSize.Width() )
1972  aBtnSize.setWidth( nAvailable );
1973  if ( nCellSizeY < aBtnSize.Height() )
1974  aBtnSize.setHeight( nCellSizeY );
1975 
1976  Point aPos = mrViewData.GetScrPos( nCol, nRow, eWhich, true );
1977  aPos.AdjustX(nCellSizeX * nLayoutSign ); // start of next cell
1978  if (!bNextCell)
1979  aPos.AdjustX( -(aBtnSize.Width() * nLayoutSign) ); // right edge of cell if next cell not available
1980  aPos.AdjustY(nCellSizeY - aBtnSize.Height() );
1981  // X remains at the left edge
1982 
1983  if ( bLayoutRTL )
1984  aPos.AdjustX( -(aBtnSize.Width()-1) ); // align right edge of button with cell border
1985 
1986  return tools::Rectangle( aPos, aBtnSize );
1987 }
1988 
1990 {
1991  ScDocument& rDoc = mrViewData.GetDocument();
1992  ScDBData* pDBData = rDoc.GetDBAtCursor( nCol, nRow, nTab, ScDBDataPortion::AREA );
1993  ScQueryParam aQueryParam;
1994 
1995  if ( pDBData )
1996  pDBData->GetQueryParam( aQueryParam );
1997  else
1998  {
1999  OSL_FAIL("Auto filter button without DBData");
2000  }
2001 
2002  bool bSimpleQuery = true;
2003  bool bColumnFound = false;
2004  SCSIZE nQuery;
2005 
2006  if ( !aQueryParam.bInplace )
2007  bSimpleQuery = false;
2008 
2009  // aQueryParam can only include MAXQUERY entries
2010 
2011  SCSIZE nCount = aQueryParam.GetEntryCount();
2012  for (nQuery = 0; nQuery < nCount && bSimpleQuery; ++nQuery)
2013  if ( aQueryParam.GetEntry(nQuery).bDoQuery )
2014  {
2015  if (aQueryParam.GetEntry(nQuery).nField == nCol)
2016  bColumnFound = true;
2017 
2018  if (nQuery > 0)
2019  if (aQueryParam.GetEntry(nQuery).eConnect != SC_AND)
2020  bSimpleQuery = false;
2021  }
2022 
2023  return ( bSimpleQuery && bColumnFound );
2024 }
2025 
2026 void ScGridWindow::GetSelectionRects( ::std::vector< tools::Rectangle >& rPixelRects ) const
2027 {
2028  GetPixelRectsFor( mrViewData.GetMarkData(), rPixelRects );
2029 }
2030 
2031 void ScGridWindow::GetSelectionRectsPrintTwips(::std::vector< tools::Rectangle >& rRects) const
2032 {
2033  GetRectsAnyFor(mrViewData.GetMarkData(), rRects, true);
2034 }
2035 
2038  ::std::vector< tools::Rectangle >& rPixelRects ) const
2039 {
2040  GetRectsAnyFor(rMarkData, rPixelRects, false);
2041 }
2042 
2044  ::std::vector< tools::Rectangle >& rRects,
2045  bool bInPrintTwips) const
2046 {
2047  ScMarkData aMultiMark( rMarkData );
2048  aMultiMark.SetMarking( false );
2049  aMultiMark.MarkToMulti();
2050  ScDocument& rDoc = mrViewData.GetDocument();
2051  SCTAB nTab = mrViewData.GetTabNo();
2052 
2053  bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
2054  tools::Long nLayoutSign = bLayoutRTL ? -1 : 1;
2055  if ( !aMultiMark.IsMultiMarked() )
2056  return;
2057  ScRange aMultiRange;
2058  aMultiMark.GetMultiMarkArea( aMultiRange );
2059  SCCOL nX1 = aMultiRange.aStart.Col();
2060  SCROW nY1 = aMultiRange.aStart.Row();
2061  SCCOL nX2 = aMultiRange.aEnd.Col();
2062  SCROW nY2 = aMultiRange.aEnd.Row();
2063 
2064  PutInOrder( nX1, nX2 );
2065  PutInOrder( nY1, nY2 );
2066 
2067  SCCOL nTestX2 = nX2;
2068  SCROW nTestY2 = nY2;
2069 
2070  rDoc.ExtendMerge( nX1,nY1, nTestX2,nTestY2, nTab );
2071 
2072  SCCOL nPosX = mrViewData.GetPosX( eHWhich );
2073  SCROW nPosY = mrViewData.GetPosY( eVWhich );
2074  // is the selection visible at all?
2075  if (nTestX2 < nPosX || nTestY2 < nPosY)
2076  return;
2077  SCCOL nRealX1 = nX1;
2078  if (nX1 < nPosX)
2079  nX1 = nPosX;
2080  if (nY1 < nPosY)
2081  nY1 = nPosY;
2082 
2084  {
2085  // limit the selection to only what is visible on the screen
2086  SCCOL nXRight = nPosX + mrViewData.VisibleCellsX(eHWhich);
2087  if (nXRight > rDoc.MaxCol())
2088  nXRight = rDoc.MaxCol();
2089 
2090  SCROW nYBottom = nPosY + mrViewData.VisibleCellsY(eVWhich);
2091  if (nYBottom > rDoc.MaxRow())
2092  nYBottom = rDoc.MaxRow();
2093 
2094  // is the selection visible at all?
2095  if (nX1 > nXRight || nY1 > nYBottom)
2096  return;
2097 
2098  if (nX2 > nXRight)
2099  nX2 = nXRight;
2100  if (nY2 > nYBottom)
2101  nY2 = nYBottom;
2102  }
2103  else
2104  {
2105  SCCOL nMaxTiledCol;
2106  SCROW nMaxTiledRow;
2107  rDoc.GetTiledRenderingArea(nTab, nMaxTiledCol, nMaxTiledRow);
2108 
2109  if (nX2 > nMaxTiledCol)
2110  nX2 = nMaxTiledCol;
2111  if (nY2 > nMaxTiledRow)
2112  nY2 = nMaxTiledRow;
2113  }
2114 
2115  double nPPTX = mrViewData.GetPPTX();
2116  double nPPTY = mrViewData.GetPPTY();
2117 
2118  ScInvertMerger aInvert( &rRects );
2119 
2120  Point aScrPos = bInPrintTwips ? mrViewData.GetPrintTwipsPos(nX1, nY1) :
2121  mrViewData.GetScrPos(nX1, nY1, eWhich);
2122  tools::Long nScrY = aScrPos.Y();
2123  bool bWasHidden = false;
2124  for (SCROW nY=nY1; nY<=nY2; nY++)
2125  {
2126  bool bFirstRow = ( nY == nPosY ); // first visible row?
2127  bool bDoHidden = false; // repeat hidden ?
2128  sal_uInt16 nHeightTwips = rDoc.GetRowHeight( nY,nTab );
2129  bool bDoRow = ( nHeightTwips != 0 );
2130  if (bDoRow)
2131  {
2132  if (bWasHidden) // test hidden merge
2133  {
2134  bDoHidden = true;
2135  bDoRow = true;
2136  }
2137 
2138  bWasHidden = false;
2139  }
2140  else
2141  {
2142  bWasHidden = true;
2143  if (nY==nY2)
2144  bDoRow = true; // last cell of the block
2145  }
2146 
2147  if ( bDoRow )
2148  {
2149  SCCOL nLoopEndX = nX2;
2150  if (nX2 < nX1) // the rest of the merge
2151  {
2152  SCCOL nStartX = nX1;
2153  while ( rDoc.GetAttr(nStartX,nY,nTab,ATTR_MERGE_FLAG)->IsHorOverlapped() )
2154  --nStartX;
2155  if (nStartX <= nX2)
2156  nLoopEndX = nX1;
2157  }
2158 
2159  const tools::Long nHeight = bInPrintTwips ?
2160  nHeightTwips : ScViewData::ToPixel(nHeightTwips, nPPTY);
2161  tools::Long nEndY = nScrY + nHeight - 1;
2162  tools::Long nScrX = aScrPos.X();
2163  for (SCCOL nX=nX1; nX<=nLoopEndX; nX++)
2164  {
2165  tools::Long nWidth = rDoc.GetColWidth(nX, nTab);
2166  if (!bInPrintTwips)
2167  nWidth = ScViewData::ToPixel(nWidth, nPPTX);
2168 
2169  if ( nWidth > 0 )
2170  {
2171  tools::Long nEndX = nScrX + ( nWidth - 1 ) * nLayoutSign;
2172 
2173  SCROW nThisY = nY;
2174  const ScPatternAttr* pPattern = rDoc.GetPattern( nX, nY, nTab );
2175  const ScMergeFlagAttr* pMergeFlag = &pPattern->GetItem(ATTR_MERGE_FLAG);
2176  if ( pMergeFlag->IsVerOverlapped() && ( bDoHidden || bFirstRow ) )
2177  {
2178  while ( pMergeFlag->IsVerOverlapped() && nThisY > 0 &&
2179  (rDoc.RowHidden(nThisY-1, nTab) || bFirstRow) )
2180  {
2181  --nThisY;
2182  pPattern = rDoc.GetPattern( nX, nThisY, nTab );
2183  pMergeFlag = &pPattern->GetItem(ATTR_MERGE_FLAG);
2184  }
2185  }
2186 
2187  // only the rest of the merged is seen ?
2188  SCCOL nThisX = nX;
2189  if ( pMergeFlag->IsHorOverlapped() && nX == nPosX && nX > nRealX1 )
2190  {
2191  while ( pMergeFlag->IsHorOverlapped() )
2192  {
2193  --nThisX;
2194  pPattern = rDoc.GetPattern( nThisX, nThisY, nTab );
2195  pMergeFlag = &pPattern->GetItem(ATTR_MERGE_FLAG);
2196  }
2197  }
2198 
2199  if ( aMultiMark.IsCellMarked( nThisX, nThisY, true ) )
2200  {
2201  if ( !pMergeFlag->IsOverlapped() )
2202  {
2203  const ScMergeAttr* pMerge = &pPattern->GetItem(ATTR_MERGE);
2204  if (pMerge->GetColMerge() > 0 || pMerge->GetRowMerge() > 0)
2205  {
2206  const SCCOL nEndColMerge = nThisX + pMerge->GetColMerge();
2207  const SCROW nEndRowMerge = nThisY + pMerge->GetRowMerge();
2208  Point aEndPos = bInPrintTwips ?
2209  mrViewData.GetPrintTwipsPos(nEndColMerge, nEndRowMerge) :
2210  mrViewData.GetScrPos(nEndColMerge, nEndRowMerge, eWhich);
2211  if ( aEndPos.X() * nLayoutSign > nScrX * nLayoutSign && aEndPos.Y() > nScrY )
2212  {
2213  aInvert.AddRect( tools::Rectangle( nScrX,nScrY,
2214  aEndPos.X()-nLayoutSign,aEndPos.Y()-1 ) );
2215  }
2216  }
2217  else if ( nEndX * nLayoutSign >= nScrX * nLayoutSign && nEndY >= nScrY )
2218  {
2219  aInvert.AddRect( tools::Rectangle( nScrX,nScrY,nEndX,nEndY ) );
2220  }
2221  }
2222  }
2223 
2224  nScrX = nEndX + nLayoutSign;
2225  }
2226  }
2227  nScrY = nEndY + 1;
2228  }
2229  }
2230 }
2231 
2233 {
2234  Window::DataChanged(rDCEvt);
2235 
2236  if ( !((rDCEvt.GetType() == DataChangedEventType::PRINTER) ||
2237  (rDCEvt.GetType() == DataChangedEventType::DISPLAY) ||
2238  (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
2239  (rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) ||
2240  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
2241  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE))) )
2242  return;
2243 
2244  if ( rDCEvt.GetType() == DataChangedEventType::FONTS && eWhich == mrViewData.GetActivePart() )
2246 
2247  if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
2248  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
2249  {
2250  if ( eWhich == mrViewData.GetActivePart() ) // only once for the view
2251  {
2252  ScTabView* pView = mrViewData.GetView();
2253 
2254  pView->RecalcPPT();
2255 
2256  // RepeatResize in case scroll bar sizes have changed
2257  pView->RepeatResize();
2258  pView->UpdateAllOverlays();
2259 
2260  // invalidate cell attribs in input handler, in case the
2261  // EditEngine BackgroundColor has to be changed
2262  if ( mrViewData.IsActive() )
2263  {
2264  ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
2265  if (pHdl)
2266  pHdl->ForgetLastPattern();
2267  }
2268  }
2269  }
2270 
2271  Invalidate();
2272 }
2273 
2274 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
tools::Long nScrY
Definition: output.hxx:186
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3046
Point TopLeft() const
void SetClipRegion()
const Fraction & GetScaleX() const
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, MetricVector *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
void SetSyntaxMode(bool bNewMode)
Definition: output.cxx:278
void InvalidateLOKViewCursor(const tools::Rectangle &rCursorRect, const Fraction aScaleX, const Fraction aScaleY)
Definition: gridwin4.cxx:329
std::unique_ptr< RowInfo[]> mpRowInfo
Definition: fillinfo.hxx:195
bool IsHidden() const
Definition: rfindlst.hxx:59
void FillInfo(ScTableInfo &rTabInfo, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCTAB nTab, double fColScale, double fRowScale, bool bPageMode, bool bFormulaMode, const ScMarkData *pMarkData=nullptr)
Definition: fillinfo.cxx:346
constexpr double nPPTY
SCCOL GetColMerge() const
Definition: attrib.hxx:69
void SetOutputDevice(OutputDevice *pOutputDevice)
Definition: cbuttonw.cxx:38
void DrawButtons(SCCOL nX1, SCCOL nX2, const ScTableInfo &rTabInfo, OutputDevice *pContentDev)
Definition: gridwin4.cxx:1786
void SetPixelOffset(const Size &rOffset)
std::unique_ptr< ScNoteMarker, o3tl::default_delete< ScNoteMarker > > mpNoteMarker
Definition: gridwin.hxx:155
void ExtendHidden(SCCOL &rX1, SCROW &rY1, SCCOL &rX2, SCROW &rY2, SCTAB nTab)
Definition: document.cxx:4704
void SetFontSize(const Size &)
bool HasScenarioRange(SCTAB nTab, const ScRange &rRange) const
Definition: documen3.cxx:858
ScDocShell * GetDocShell() const
Definition: viewdata.hxx:354
ScAddress aStart
Definition: address.hxx:500
void DrawFrame(vcl::RenderContext &rRenderContext)
Definition: output.cxx:1355
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
SCROW GetRefEndY() const
Definition: viewdata.hxx:519
constexpr TypedWhichId< ScPatternAttr > ATTR_PATTERN(156)
void SetShowNullValues(bool bSet)
Definition: output.cxx:246
bool bPivotButton
Definition: fillinfo.hxx:163
bool IsInInterpreter() const
Definition: document.hxx:2307
ScDDComboBoxButton aComboButton
Definition: gridwin.hxx:193
This class takes care of physically drawing field button controls inside data pilot tables...
Definition: dpcontrol.hxx:36
void flushOverlayManager()
Definition: gridwin.cxx:6630
static void lcl_DrawScenarioFrames(OutputDevice *pDev, ScViewData &rViewData, ScSplitPos eWhich, SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2)
Definition: gridwin4.cxx:185
void EndDrawLayers(SdrPaintWindow &rPaintWindow, bool bPaintFormLayer)
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
MapMode GetDrawMapMode(bool bForce=false)
MapMode for the drawinglayer objects.
Definition: gridwin3.cxx:246
SCROW Row() const
Definition: address.hxx:262
void setWidth(tools::Long nWidth)
void SetUseStyleColor(bool bSet)
Definition: output.hxx:323
OUString GetTitle(sal_uInt16 nMaxLen=0) const
void GetRectsAnyFor(const ScMarkData &rMarkData,::std::vector< tools::Rectangle > &rRects, bool bInPrintTwips) const
Definition: gridwin4.cxx:2043
void MarkToMulti()
Definition: markdata.cxx:224
tools::Rectangle GetListValButtonRect(const ScAddress &rButtonPos)
Definition: gridwin4.cxx:1939
void DrawClipMarks()
Definition: output.cxx:2447
Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
const Fraction & GetZoomX() const
Definition: viewdata.hxx:459
void LogicInvalidate(const tools::Rectangle *pRectangle) override
Definition: gridwin4.cxx:1472
virtual SdrObject * TryToGetSdrObject() const
std::vector< LOKCursorEntry > maLOKLastCursor
Definition: gridwin.hxx:146
SC_DLLPUBLIC bool IsActiveScenario(SCTAB nTab) const
Definition: documen3.cxx:871
const std::vector< ScHighlightEntry > & GetHighlightRanges() const
Definition: tabview.hxx:330
bool bHOverlapped
Definition: fillinfo.hxx:160
ScScenarioFlags
Definition: global.hxx:238
SCCOL nX1
Definition: output.hxx:190
bool IsInputMode() const
Definition: inputhdl.hxx:185
Point GetPrintTwipsPos(SCCOL nCol, SCROW nRow) const
returns the position (top-left corner) of the requested cell in print twips coordinates.
Definition: viewdata.cxx:2465
SC_DLLPUBLIC bool Intersects(const ScRange &rRange) const
Definition: address.cxx:1558
#define TWIPS_PER_PIXEL
Definition: global.hxx:90
SCROW GetRefStartY() const
Definition: viewdata.hxx:516
void RepeatResize(bool bUpdateFix=true)
Definition: tabview.cxx:770
std::unique_ptr< FmFormView > mpLOKDrawView
LibreOfficeKit needs a persistent FmFormView for tiled rendering, otherwise the invalidations from dr...
Definition: gridwin.hxx:114
long Long
virtual void calculateGridOffsetForViewOjectContact(basegfx::B2DVector &rTarget, const ViewObjectContact &rClient) const
const SCCOL * GetPageEndX() const
Definition: pagedata.hxx:51
const StyleSettings & GetStyleSettings() const
SCROW GetCurY() const
Definition: viewdata.hxx:402
svtools::ColorConfig & GetColorConfig()
Definition: scmod.cxx:816
bool IsOverlapped() const
Definition: attrib.hxx:102
void DrawRefMark(SCCOL nRefStartX, SCROW nRefStartY, SCCOL nRefEndX, SCROW nRefEndY, const Color &rColor, bool bHandle)
Draws reference mark and returns its properties.
Definition: output.cxx:1984
SCSIZE mnArrCount
Definition: fillinfo.hxx:196
bool IsMapModeEnabled() const
#define SC_SCENARIO_VSPACE
Definition: output.hxx:56
sal_Int64 n
ScViewData & mrViewData
Definition: gridwin.hxx:150
ViewShellDocId GetDocId() const override
virtual Size GetSizePixel() const
void DrawChangeTrack()
Definition: output.cxx:2229
void AddRect(const tools::Rectangle &rRect)
Definition: invmerge.cxx:123
ScPrintRangeData & GetData(size_t i)
Definition: pagedata.cxx:60
const ContentProperties & rData
double GetPPTX() const
Definition: viewdata.hxx:468
bool HasEditView(ScSplitPos eWhich) const
Definition: viewdata.hxx:564
const MapMode & GetMapMode() const
void SetOptSizePixel()
Definition: cbuttonw.cxx:43
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
constexpr SdrLayerID SC_LAYER_BACK(1)
bool IsSyntaxMode() const
Definition: viewdata.hxx:541
SCCOLROW nField
Definition: queryentry.hxx:51
ScRange Combine() const
Definition: rangelst.cxx:1112
DataChangedEventType GetType() const
ScAddress aEnd
Definition: address.hxx:501
ScSplitPos GetActivePart() const
Definition: viewdata.hxx:398
static void UpdateInputLine()
Definition: tabview3.cxx:3001
void SetSolidBackground(bool bSet)
Definition: output.hxx:322
ScDocument & GetDocument() const
Definition: viewdata.hxx:380
void SetShowFormulas(bool bSet)
Definition: output.cxx:251
void SetCellSelectionPixel(int nType, int nPixelX, int nPixelY)
Update the cell selection according to what handles have been dragged.
Definition: gridwin4.cxx:1495
const tools::Rectangle & GetOutputArea() const
void UpdateAllOverlays()
Definition: tabview2.cxx:999
void SetMarkClipped(bool bSet)
Definition: output.cxx:241
constexpr::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
void SetSizePixel(const Size &rNewSize)
Definition: cbutton.hxx:46
void Invalidate(sal_uInt16 nId)
SC_DLLPUBLIC void SetCursor(SCCOL nPosX, SCROW nPosY, bool bNew=false)
Definition: tabview3.cxx:359
SCCOL GetPosX(ScHSplitPos eWhich, SCTAB nForTab=-1) const
Definition: viewdata.cxx:1341
void SetMapMode()
SCROW GetEditEndRow() const
Definition: viewdata.hxx:590
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
void SetRight(tools::Long v)
SCROW nRowNo
Definition: fillinfo.hxx:182
SC_DLLPUBLIC SvtScriptType GetStringScriptType(const OUString &rString)
Definition: documen6.cxx:76
constexpr TypedWhichId< ScMergeAttr > ATTR_MERGE(144)
SC_DLLPUBLIC ScBreakType HasRowBreak(SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4357
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4159
void SetContentDevice(OutputDevice *pContentDev)
Definition: output.cxx:220
SCROW nY2
Definition: output.hxx:193
ScSplitPos
Definition: viewdata.hxx:45
void DrawPagePreview(SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, vcl::RenderContext &rRenderContext)
Definition: gridwin4.cxx:1585
bool IsCellMarked(SCCOL nCol, SCROW nRow, bool bNoSimple=false) const
Definition: markdata.cxx:285
bool bIsInPaint
Definition: gridwin.hxx:213
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6054
bool IsEmpty() const
HashMap_OWString_Interface aMap
const SCROW * GetPageEndY() const
Definition: pagedata.hxx:53
SfxPrinter * GetPrinter(bool bCreateIfNotExist=true)
Definition: documen8.cxx:112
tools::Rectangle aInvertRect
Definition: gridwin.hxx:203
constexpr::Color COL_TRANSPARENT(0xFF, 0xFF, 0xFF, 0xFF)
void disposeAndReset(VirtualDevice *pBody)
static tools::Long ToPixel(sal_uInt16 nTwips, double nFactor)
Definition: viewdata.hxx:682
static void notifyInvalidation(SfxViewShell const *pThisView, const OString &rPayload)
bool IsOle() const
Definition: viewdata.cxx:3901
void DrawSdrGrid(const tools::Rectangle &rDrawingRect, OutputDevice *pContentDev)
Definition: gridwin3.cxx:228
bool IsAutoFilterActive(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: gridwin4.cxx:1989
ScPageBreakData * GetPageBreakData()
Definition: tabview.hxx:329
tools::Long Left() const
void SetLeft(tools::Long v)
void SetFmtDevice(OutputDevice *pRDev)
Definition: output.hxx:317
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:870
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:45
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
const Fraction & GetScaleY() const
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:312
vcl::Cursor * GetCursor() const
OutputDevice & GetTargetOutputDevice()
void Draw(SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMode eMode)
Definition: gridwin4.cxx:436
SCCOL VisibleCellsX(ScHSplitPos eWhichX) const
Definition: viewdata.cxx:2621
bool IsMultiMarked() const
Definition: markdata.hxx:83
void DrawContent(OutputDevice &rDevice, const ScTableInfo &rTableInfo, ScOutputData &aOutputData, bool bLogicText)
Draw content of the gridwindow; shared between the desktop and the tiled rendering.
Definition: gridwin4.cxx:603
int nCount
static SfxViewShell * GetNext(const SfxViewShell &rPrev, bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
SC_DLLPUBLIC SCSIZE GetEntryCount() const
Definition: queryparam.cxx:119
SC_DLLPUBLIC OUString GetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScInterpreterContext *pContext=nullptr) const
Definition: document.cxx:3484
AllSettingsFlags GetFlags() const
tools::Long Bottom() const
bool isCompatFlagSet(Compat flag)
SC_DLLPUBLIC const ScQueryEntry & GetEntry(SCSIZE n) const
Definition: queryparam.cxx:124
void CheckNeedsRepaint()
Definition: gridwin4.cxx:1564
void UpdateInputHandler(bool bForce=false, bool bStopEditing=true)
Definition: tabvwsha.cxx:653
SCTAB Tab() const
Definition: address.hxx:271
void SetDrawView(FmFormView *pNew)
Definition: output.hxx:320
void GetSelectionRectsPrintTwips(::std::vector< tools::Rectangle > &rRects) const
Definition: gridwin4.cxx:2031
void RecalcPPT()
Definition: tabview3.cxx:2766
void DoneBlockMode(bool bContinue=false)
Definition: tabview2.cxx:408
void PrepareFormulaCalc()
Call this before any operations that might trigger one or more formula cells to get calculated...
Definition: document.cxx:2446
SCROW GetPosY(ScVSplitPos eWhich, SCTAB nForTab=-1) const
Definition: viewdata.cxx:1355
size_t GetCount() const
Definition: pagedata.hxx:74
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
const Fraction & GetZoomY() const
Definition: viewdata.hxx:460
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4733
ScDrawView * GetScDrawView()
Definition: viewdata.cxx:3074
ScViewData & GetViewData()
Definition: tabview.hxx:334
ScAddress aListValPos
Definition: gridwin.hxx:201
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2389
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
Definition: document.cxx:4712
ScVSplitPos eVWhich
Definition: gridwin.hxx:153
void DrawRect(const tools::Rectangle &rRect)
bool GetTextWysiwyg() const
Definition: inputopt.hxx:66
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
Definition: patattr.hxx:71
SCROW VisibleCellsY(ScVSplitPos eWhichY) const
Definition: viewdata.cxx:2626
void PutInOrder(T &nStart, T &nEnd)
Definition: address.hxx:954
bool empty() const
Definition: rangelst.hxx:89
void SetEditCell(SCCOL nCol, SCROW nRow)
Definition: output.cxx:266
SC_DLLPUBLIC const ScDocOptions & GetDocOptions() const
Definition: documen3.cxx:1922
ScTabViewShell * GetViewShell() const
Definition: viewdata.hxx:357
bool bAutoFilter
Definition: fillinfo.hxx:162
constexpr double nPPTX
void SetAlignment(FontAlign)
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1056
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:869
void SetLineColor()
T * get() const
bool IsVerOverlapped() const
Definition: attrib.hxx:101
virtual void PrePaint(vcl::RenderContext &rRenderContext) override
Definition: gridwin4.cxx:291
SC_DLLPUBLIC bool ColHidden(SCCOL nCol, SCTAB nTab, SCCOL *pFirstCol=nullptr, SCCOL *pLastCol=nullptr) const
Definition: document.cxx:4443
void SetScaleX(const Fraction &rScaleX)
static void GetFont(vcl::Font &rFont, const SfxItemSet &rItemSet, ScAutoFontColorMode eAutoMode, const OutputDevice *pOutDev=nullptr, const Fraction *pScale=nullptr, const SfxItemSet *pCondSet=nullptr, SvtScriptType nScript=SvtScriptType::NONE, const Color *pBackConfigColor=nullptr, const Color *pTextConfigColor=nullptr)
Static helper function to fill a font object from the passed item set.
Definition: patattr.cxx:216
SdrPaintWindow * BeginDrawLayers(OutputDevice *pOut, const vcl::Region &rReg, bool bDisableIntersect=false)
SCCOL nX2
Definition: output.hxx:192
SCTAB GetRefEndZ() const
Definition: viewdata.hxx:520
int i
Point GetScrPos(SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, bool bAllowNeg=false, SCTAB nForTab=-1) const
Definition: viewdata.cxx:2313
bool IsClipRegion() const
bool bChanged
Definition: fillinfo.hxx:188
bool bFilterActive
Definition: fillinfo.hxx:165
tools::Long GetFirstPage() const
Definition: pagedata.hxx:56
SfxBindings & GetBindings()
Definition: viewdata.cxx:3034
void GetPosFromPixel(tools::Long nClickX, tools::Long nClickY, ScSplitPos eWhich, SCCOL &rPosX, SCROW &rPosY, bool bTestMerge=true, bool bRepair=false, SCTAB nForTab=-1)
Definition: viewdata.cxx:2694
sal_Int16 SCCOL
Definition: types.hxx:22
bool ValidCol(SCCOL nCol) const
Definition: document.hxx:872
bool HasBackgroundDraw(SCTAB nTab, const tools::Rectangle &rMMRect) const
Definition: documen9.cxx:341
#define SC_MOD()
Definition: scmod.hxx:250
ScSplitPos GetEditActivePart() const
Definition: viewdata.hxx:584
SC_DLLPUBLIC void GetTiledRenderingArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow) const
Return the number of columns / rows that should be visible for the tiled rendering.
Definition: documen2.cxx:663
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
ScSheetLimits & GetSheetLimits() const
Definition: document.hxx:871
void SetOrigin(const Point &rOrigin)
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: gridwin4.cxx:360
void DrawGrid(vcl::RenderContext &rRenderContext, bool bGrid, bool bPage)
Definition: output.cxx:290
bool SetChangedClip()
Definition: output.cxx:1747
const ScRange & GetPrintRange() const
Definition: pagedata.hxx:45
void SetFillColor()
tools::Long Width() const
size_t size() const
Definition: rangelst.hxx:90
void setLocalRendering(bool bLocalRendering=true)
void DrawBackground(vcl::RenderContext &rRenderContext)
Definition: output.cxx:991
void MarkScenario(SCTAB nSrcTab, SCTAB nDestTab, ScMarkData &rDestMark, bool bResetMark=true, ScScenarioFlags nNeededBits=ScScenarioFlags::NONE) const
Definition: documen3.cxx:846
OUString ScResId(const char *pId)
Definition: scdll.cxx:89
bool IsActive() const
Definition: viewdata.hxx:382
void DrawDocumentBackground()
Definition: output.cxx:806
vcl::Window * GetWindow() const
bool GetOption(ScViewOption eOpt) const
Definition: viewopti.hxx:88
void SetScaleY(const Fraction &rScaleY)
const Size & GetFontSize() const
bool bVOverlapped
Definition: fillinfo.hxx:161
void DrawStrings(bool bPixelToLogic=false)
Definition: output2.cxx:1445
SCROW nY1
Definition: output.hxx:191
void SetTop(tools::Long v)
sal_uInt16 nCursorHideCount
Definition: gridwin.hxx:165
void SetBottom(tools::Long v)
const AllSettings & GetSettings() const
Size GetOutputSizePixel() const
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: gridwin4.cxx:2232
void GetVars(SCCOL &nCol1, SCROW &nRow1, SCTAB &nTab1, SCCOL &nCol2, SCROW &nRow2, SCTAB &nTab2) const
Definition: address.hxx:693
void ResetChanged(const ScRange &rRange)
Definition: document.cxx:4069
sal_uInt16 nPaintCount
Definition: gridwin.hxx:197
void GetPixelRectsFor(const ScMarkData &rMarkData,::std::vector< tools::Rectangle > &rPixelRects) const
convert rMarkData into pixel rectangles for this view
Definition: gridwin4.cxx:2037
SCCOL GetRefEndX() const
Definition: viewdata.hxx:518
tools::Long Top() const
const sdr::contact::ObjectContact & GetObjectContact() const
static SfxViewShell * GetFirst(bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
bool UpdateVisibleRange()
Definition: gridwin2.cxx:618
void GetArea(SCTAB &rTab, SCCOL &rCol1, SCROW &rRow1, SCCOL &rCol2, SCROW &rRow2) const
Definition: dbdata.cxx:300
SC_DLLPUBLIC bool ExtendMerge(SCCOL nStartCol, SCROW nStartRow, SCCOL &rEndCol, SCROW &rEndRow, SCTAB nTab, bool bRefresh=false)
Definition: document.cxx:5561
tools::Long nScrX
Definition: output.hxx:185
void DrawClear()
Definition: output.cxx:1295
void SetGridColor(const Color &rColor)
Definition: output.cxx:236
Size GetSize() const
ScSplitPos eWhich
Definition: gridwin.hxx:151
SCCOL Col() const
Definition: address.hxx:267
bool bNeedsRepaint
Definition: gridwin.hxx:214
SCTAB nTab
Definition: output.hxx:184
void SetColor(const Color &)
ScDBFunc * GetView() const
Definition: viewdata.cxx:852
virtual sdr::contact::ObjectContact * createViewSpecificObjectContact(SdrPageWindow &rPageWindow, const char *pDebugName) const
tools::Long AdjustTop(tools::Long nVertMoveDelta)
static SfxItemPool * CreatePool()
SCCOL GetRefStartX() const
Definition: viewdata.hxx:515
MapUnit GetMapUnit()
Point PixelToLogic(const Point &rDevicePt) const
Point LogicToPixel(const Point &rLogicPt) const
void PaintTile(VirtualDevice &rDevice, int nOutputWidth, int nOutputHeight, int nTilePosX, int nTilePosY, tools::Long nTileWidth, tools::Long nTileHeight)
Definition: gridwin4.cxx:1318
SC_DLLPUBLIC void GetScenarioData(SCTAB nTab, OUString &rComment, Color &rColor, ScScenarioFlags &rFlags) const
Definition: documen3.cxx:462
bool IsHorOverlapped() const
Definition: attrib.hxx:100
void SetPosPixel(const Point &rNewPos)
Definition: cbutton.hxx:43
sal_uLong Count() const
Definition: rfindlst.hxx:51
SCTAB GetRefStartZ() const
Definition: viewdata.hxx:517
ScRange aRef
Definition: rfindlst.hxx:31
constexpr TypedWhichId< ScMergeFlagAttr > ATTR_MERGE_FLAG(145)
void DrawRedraw(ScOutputData &rOutputData, SdrLayerID nLayer)
Definition: gridwin3.cxx:203
sal_Int32 SCROW
Definition: types.hxx:18
ALIGN_TOP
SC_DLLPUBLIC void PutInOrder()
Definition: address.cxx:1582
static SC_DLLPUBLIC SvtScriptType GetDefaultScriptType()
Definition: global.cxx:849
VisibleRange maVisibleRange
Definition: gridwin.hxx:135
void SetShowSpellErrors(bool bSet)
Definition: output.cxx:256
double GetPPTY() const
Definition: viewdata.hxx:469
bool ValidRow(SCROW nRow) const
Definition: document.hxx:873
const Point & GetPosPixel() const
Definition: cbutton.hxx:44
bool bPivotPopupButton
Definition: fillinfo.hxx:164
ColorConfigValue GetColorValue(ColorConfigEntry eEntry, bool bSmart=true) const
void Draw(const Point &rAt, const Size &rSize)
Definition: cbuttonw.cxx:49
SC_DLLPUBLIC bool IsScenario(SCTAB nTab) const
Definition: documen3.cxx:426
ScDrawView * GetScDrawView()
Definition: tabview.hxx:342
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CTL(EE_CHAR_START+20)
ScUpdateMode
Definition: viewutil.hxx:39
void PrePaint()
bool IsAutomatic() const
Definition: pagedata.hxx:60
SCCOL GetEditStartCol() const
Definition: viewdata.hxx:587
void setWidth(tools::Long n)
void SetFont(const vcl::Font &rNewFont)
static void lcl_LimitRect(tools::Rectangle &rRect, const tools::Rectangle &rVisible)
Definition: gridwin4.cxx:78
bool GetShowGrid() const
Definition: viewdata.hxx:463
virtual vcl::Region GetActiveClipRegion() const
constexpr SdrLayerID SC_LAYER_FRONT(0)
tools::Long GetTextHeight() const
SC_DLLPUBLIC ScBreakType HasColBreak(SCCOL nCol, SCTAB nTab) const
Definition: document.cxx:4372
SvtScriptType nPageScript
Definition: gridwin.hxx:185
constexpr TypedWhichId< SvxColorItem > EE_CHAR_COLOR(EE_CHAR_START+0)
constexpr SdrLayerID SC_LAYER_INTERN(2)
virtual bool supportsGridOffsets() const
void SetViewShell(ScTabViewShell *pSh)
Definition: output.hxx:318
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
void SetSpellCheckContext(const sc::SpellCheckContext *pCxt)
Definition: output.cxx:215
tools::Long Height() const
const ScViewOptions & GetOptions() const
Definition: viewdata.hxx:537
const value_type & getNearestByPosition(tools::Long nPos) const
Definition: viewdata.cxx:218
void Paint(const tools::Rectangle &rRect, OutputDevice *pTargetDevice=nullptr)
SCCOL GetEditEndCol() const
Definition: viewdata.hxx:589
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:400
SC_DLLPUBLIC const ScInputOptions & GetInputOptions()
Definition: scmod.cxx:776
static void lcl_DrawOneFrame(vcl::RenderContext *pDev, const tools::Rectangle &rInnerPixel, const OUString &rTitle, const Color &rColor, bool bTextBelow, double nPPTX, double nPPTY, const Fraction &rZoomY, ScDocument &rDoc, ScViewData &rButtonViewData, bool bLayoutRTL)
Definition: gridwin4.cxx:88
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
bool IsAutoSpell() const
Definition: docoptio.hxx:54
bool GetMergeSizePixel(SCCOL nX, SCROW nY, tools::Long &rSizeXPix, tools::Long &rSizeYPix) const
Definition: viewdata.cxx:2641
SC_DLLPUBLIC void GetQueryParam(ScQueryParam &rQueryParam) const
Definition: dbdata.cxx:409
const Point & GetOrigin() const
size_t GetPagesX() const
Definition: pagedata.hxx:50
const SCROW MAXTILEDROW
Definition: address.hxx:76
ScQueryConnect eConnect
Definition: queryentry.hxx:53
static void AddPixelsWhile(tools::Long &rScrY, tools::Long nEndPixels, SCROW &rPosY, SCROW nEndRow, double nPPTY, const ScDocument *pDoc, SCTAB nTabNo)
while (rScrY <= nEndPixels && rPosY <= nEndRow) add pixels of row heights converted with nPPTY to rSc...
Definition: viewdata.cxx:4022
SC_DLLPUBLIC void ExtendTotalMerge(ScRange &rRange) const
Definition: document.cxx:5611
ScPositionHelper & GetLOKWidthHelper()
Definition: viewdata.hxx:410
void DrawNoteMarks(vcl::RenderContext &rRenderContext)
Definition: output.cxx:2294
CALCPAGEBREAKMANUAL
const Size & GetSizePixel() const
Definition: cbutton.hxx:47
bool IsTopDown() const
Definition: pagedata.hxx:58
tools::Long GetScrH() const
Definition: output.hxx:335
void SetMarking(bool bFlag)
Definition: markdata.hxx:103
SC_DLLPUBLIC bool IsLayoutRTL(SCTAB nTab) const
Definition: document.cxx:992
Color const & GetGridColor(OUString *pStrName=nullptr) const
Definition: viewopti.cxx:117
bool IsVisible() const
SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
Definition: document.cxx:4427
const vcl::Font & GetAppFont() const
void SetOutputArea(const tools::Rectangle &rRect)
void setHeight(tools::Long nHeight)
ScAddress aAutoMarkPos
Definition: gridwin.hxx:200
void SetZoom(const Fraction &rNewX, const Fraction &rNewY, std::vector< SCTAB > &tabs)
Definition: viewdata.cxx:1024
tools::Long GetScrW() const
Definition: output.hxx:334
ViewContact & GetViewContact() const
void SetMirrorWidth(tools::Long nNew)
Definition: output.cxx:231
void UpdateFontList()
Definition: docsh3.cxx:454
ScRangeFindData & GetObject(sal_uLong nIndex)
Definition: rfindlst.hxx:54
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
SCTAB GetRefTabNo() const
Definition: viewdata.hxx:392
tools::Rectangle GetEditCursor() const
VirtualDevice * get() const
ScRangeList GetMarkedRanges() const
Definition: markdata.cxx:465
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CJK(EE_CHAR_START+19)
SCROW GetRowMerge() const
Definition: attrib.hxx:70
void GetMultiMarkArea(ScRange &rRange) const
Definition: markdata.cxx:117
ScInputHandler * GetInputHdl(ScTabViewShell *pViewSh=nullptr, bool bUseRef=true)
Input-Handler.
Definition: scmod.cxx:1304
void DoInvertRect(const tools::Rectangle &rPixel)
Definition: gridwin4.cxx:277
const MapMode & GetLogicMode(ScSplitPos eWhich)
Definition: viewdata.cxx:2920
CellInfo * pCellInfo
Definition: fillinfo.hxx:179
tools::Rectangle aRepaintPixel
Definition: gridwin.hxx:198
const OUString & GetDocName() const
Definition: rfindlst.hxx:58
ScPositionHelper & GetLOKHeightHelper()
Definition: viewdata.hxx:411
void DrawEdit(bool bPixelToLogic)
Definition: output2.cxx:4245
const ScDBData * GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const
Definition: documen3.cxx:316
void DrawShadow()
Definition: output.cxx:1149
void SetScenButSize(const Size &rNew)
Definition: viewdata.hxx:648
ScRangeFindList * GetRangeFindList()
Definition: inputhdl.hxx:252
SC_DLLPUBLIC void ExtendOverlapped(SCCOL &rStartCol, SCROW &rStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab) const
Definition: document.cxx:5471
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4118
bool IsPagebreakMode() const
Definition: viewdata.hxx:425
bool NeedLOKCursorInvalidation(const tools::Rectangle &rCursorRect, const Fraction aScaleX, const Fraction aScaleY)
Definition: gridwin4.cxx:307
void MarkCursor(SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, bool bCols=false, bool bRows=false, bool bCellSelection=false)
Definition: tabview2.cxx:448
size_t GetPagesY() const
Definition: pagedata.hxx:52
rtl::OString toString() const
ScHSplitPos eHWhich
Definition: gridwin.hxx:152
bool IsRefMode() const
Definition: viewdata.hxx:513
void GetSelectionRects(::std::vector< tools::Rectangle > &rPixelRects) const
Definition: gridwin4.cxx:2026
bool bListValButton
Definition: gridwin.hxx:216
aStr
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
Definition: document.cxx:211
bool bAutoMarkVisible
Definition: gridwin.hxx:215
tools::Long Right() const
Color const & GetBackgroundColor() const
void GetEditView(ScSplitPos eWhich, EditView *&rViewPtr, SCCOL &rCol, SCROW &rRow)
Definition: viewdata.cxx:2219
bool IsMinimized() const
Definition: viewdata.cxx:3080
void UpdateHeaderOverlay()
Definition: gridwin.cxx:6504
void InitBlockMode(SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, bool bTestNeg=false, bool bCols=false, bool bRows=false, bool bForceNeg=false)
Definition: tabview2.cxx:352
std::shared_ptr< sc::SpellCheckContext > mpSpellCheckCxt
Definition: gridwin.hxx:148
void ForgetLastPattern()
Definition: inputhdl.cxx:2226
sal_uInt16 nPos
static void notifyOtherView(const SfxViewShell *pThisView, SfxViewShell const *pOtherView, int nType, std::string_view rKey, const OString &rPayload)
sal_Int16 SCTAB
Definition: types.hxx:23
void SetPagebreakMode(ScPageBreakData *pPageData)
Definition: output.cxx:577
SCCOL GetCurX() const
Definition: viewdata.hxx:401
SCROW GetEditStartRow() const
Definition: viewdata.hxx:588
void FillEditItemSet(SfxItemSet *pEditSet, const SfxItemSet *pCondSet=nullptr) const
Converts all Calc items contained in the own item set to edit engine items and puts them into pEditSe...
Definition: patattr.cxx:776
#define SC_SCENARIO_HSPACE
Definition: output.hxx:55
static void lcl_DrawHighlight(ScOutputData &rOutputData, const ScViewData &rViewData, const std::vector< ScHighlightEntry > &rHighlightRanges)
Definition: gridwin4.cxx:260