LibreOffice Module sc (master)  1
tabview5.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 <svx/fmshell.hxx>
21 #include <svx/svdobj.hxx>
22 #include <svx/svdocapt.hxx>
23 #include <svx/svdoutl.hxx>
24 #include <sfx2/bindings.hxx>
25 #include <sfx2/dispatch.hxx>
26 #include <sfx2/lokhelper.hxx>
27 #include <sfx2/objsh.hxx>
28 #include <sfx2/viewfrm.hxx>
29 #include <osl/diagnose.h>
30 
31 #include <tabview.hxx>
32 #include <tabvwsh.hxx>
33 #include <document.hxx>
34 #include <gridwin.hxx>
35 #include <olinewin.hxx>
36 #include <tabsplit.hxx>
37 #include <colrowba.hxx>
38 #include <tabcont.hxx>
39 #include <sc.hrc>
40 #include <pagedata.hxx>
41 #include <hiranges.hxx>
42 #include <drawview.hxx>
43 #include <drwlayer.hxx>
44 #include <fusel.hxx>
45 #include <seltrans.hxx>
46 #include <scmod.hxx>
47 #include <docsh.hxx>
48 #include <viewuno.hxx>
49 #include <postit.hxx>
50 #include <spellcheckcontext.hxx>
51 
52 #include <vcl/settings.hxx>
53 
54 #include <comphelper/lok.hxx>
55 #include <officecfg/Office/Calc.hxx>
56 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
57 
58 using namespace com::sun::star;
59 
61 {
62  /* RTL layout of the view windows is done manually, because it depends on
63  the sheet orientation, not the UI setting. Note: controls that are
64  already constructed (e.g. scroll bars) have the RTL setting of the GUI.
65  Eventually this has to be disabled manually (see below). */
66  pFrameWin->EnableRTL( false );
67 
68  sal_uInt16 i;
69 
70  mbInlineWithScrollbar = officecfg::Office::Calc::Layout::Other::TabbarInlineWithScrollbar::get();
71 
72  aScrollTimer.SetTimeout(10);
73  aScrollTimer.SetInvokeHandler( LINK( this, ScTabView, TimerHdl ) );
74 
75  for (i=0; i<4; i++)
76  pGridWin[i] = nullptr;
77  pGridWin[SC_SPLIT_BOTTOMLEFT] = VclPtr<ScGridWindow>::Create( pFrameWin, aViewData, SC_SPLIT_BOTTOMLEFT );
78 
79  pSelEngine.reset( new ScViewSelectionEngine( pGridWin[SC_SPLIT_BOTTOMLEFT], this,
80  SC_SPLIT_BOTTOMLEFT ) );
81  aFunctionSet.SetSelectionEngine( pSelEngine.get() );
82 
83  pHdrSelEng.reset( new ScHeaderSelectionEngine( pFrameWin, &aHdrFunc ) );
84 
86  &aHdrFunc, pHdrSelEng.get(), this );
87  pColBar[SC_SPLIT_RIGHT] = nullptr;
89  &aHdrFunc, pHdrSelEng.get(), this );
90  pRowBar[SC_SPLIT_TOP] = nullptr;
91  for (i=0; i<2; i++)
92  pColOutline[i] = pRowOutline[i] = nullptr;
93 
94  pHSplitter = VclPtr<ScTabSplitter>::Create( pFrameWin, WinBits( WB_HSCROLL ), &aViewData );
95  pVSplitter = VclPtr<ScTabSplitter>::Create( pFrameWin, WinBits( WB_VSCROLL ), &aViewData );
96 
97  // SSA: override default keyboard step size to allow snap to row/column
98  pHSplitter->SetKeyboardStepSize( 1 );
99  pVSplitter->SetKeyboardStepSize( 1 );
100 
101  pTabControl = VclPtr<ScTabControl>::Create(pFrameWin, &aViewData);
102  if (mbInlineWithScrollbar)
103  pTabControl->SetStyle(pTabControl->GetStyle() | WB_SIZEABLE);
104 
105  /* #i97900# The tab control has to remain in RTL mode if GUI is RTL, this
106  is needed to draw the 3D effect correctly. The base TabBar implements
107  mirroring independent from the GUI direction. Have to set RTL mode
108  explicitly because the parent frame window is already RTL disabled. */
109  pTabControl->EnableRTL( AllSettings::GetLayoutRTL() );
110 
111  InitScrollBar( *aHScrollLeft, aViewData.GetDocument().MaxCol()+1 );
112  InitScrollBar( *aHScrollRight, aViewData.GetDocument().MaxCol()+1 );
113  InitScrollBar( *aVScrollTop, aViewData.GetDocument().MaxRow()+1 );
114  InitScrollBar( *aVScrollBottom, aViewData.GetDocument().MaxRow()+1 );
115  /* #i97900# scrollbars remain in correct RTL mode, needed mirroring etc.
116  is now handled correctly at the respective places. */
117 
118  // Don't show anything here, because still in wrong order
119  // Show is received from UpdateShow during first resize
120  // pTabControl, pGridWin, aHScrollLeft, aVScrollBottom,
121  // aCornerButton, aScrollBarBox, pHSplitter, pVSplitter
122 
123  // fragment
124 
125  pHSplitter->SetSplitHdl( LINK( this, ScTabView, SplitHdl ) );
126  pVSplitter->SetSplitHdl( LINK( this, ScTabView, SplitHdl ) );
127 
128  // UpdateShow is done during resize or a copy of an existing view from ctor
129 
130  pDrawActual = nullptr;
131  pDrawOld = nullptr;
132 
133  // DrawView cannot be create in the TabView - ctor
134  // when the ViewShell isn't constructed yet...
135  // The also applies to ViewOptionsHasChanged()
136 
137  TestHintWindow();
138 }
139 
141 {
142  sal_uInt16 i;
143 
144  // remove selection object
145  ScModule* pScMod = SC_MOD();
147  if ( pOld && pOld->GetView() == this )
148  {
149  pOld->ForgetView();
150  pScMod->SetSelectionTransfer( nullptr );
151  TransferableHelper::ClearPrimarySelection(); // may delete pOld
152  }
153 
154  pBrushDocument.reset();
155  pDrawBrushSet.reset();
156 
157  pPageBreakData.reset();
158 
159  delete pDrawActual;
160  pDrawActual = nullptr;
161  delete pDrawOld;
162  pDrawOld = nullptr;
163 
165  {
166  ScTabViewShell* pThisViewShell = GetViewData().GetViewShell();
167 
168  auto lRemoveWindows =
169  [pThisViewShell] (ScTabViewShell* pOtherViewShell)
170  {
171  ScViewData& rOtherViewData = pOtherViewShell->GetViewData();
172  for (int k = 0; k < 4; ++k)
173  {
174  if (rOtherViewData.HasEditView(static_cast<ScSplitPos>(k)))
175  pThisViewShell->RemoveWindowFromForeignEditView(pOtherViewShell, static_cast<ScSplitPos>(k));
176  }
177  };
178 
179  SfxLokHelper::forEachOtherView(pThisViewShell, lRemoveWindows);
180  }
181 
182  aViewData.KillEditView(); // as long as GridWins still exist
183 
184  if (pDrawView)
185  {
186  for (i=0; i<4; i++)
187  if (pGridWin[i])
188  {
189  pDrawView->DeleteWindowFromPaintView(pGridWin[i]->GetOutDev());
190  }
191 
192  pDrawView->HideSdrPage();
193  pDrawView.reset();
194  }
195 
196  pSelEngine.reset();
197 
198  if (mpSpellCheckCxt)
199  mpSpellCheckCxt->dispose();
200  mpSpellCheckCxt.reset();
201 
202  mxInputHintOO.reset();
203  for (i=0; i<4; i++)
204  pGridWin[i].disposeAndClear();
205 
206  pHdrSelEng.reset();
207 
208  for (i=0; i<2; i++)
209  {
210  pColBar[i].disposeAndClear();
211  pRowBar[i].disposeAndClear();
212  pColOutline[i].disposeAndClear();
213  pRowOutline[i].disposeAndClear();
214  }
215 
216  aScrollBarBox.disposeAndClear();
217  aCornerButton.disposeAndClear();
218  aTopButton.disposeAndClear();
219  aHScrollLeft.disposeAndClear();
220  aHScrollRight.disposeAndClear();
221  aVScrollTop.disposeAndClear();
222  aVScrollBottom.disposeAndClear();
223 
224  pHSplitter.disposeAndClear();
225  pVSplitter.disposeAndClear();
226  pTabControl.disposeAndClear();
227 }
228 
229 void ScTabView::MakeDrawView( TriState nForceDesignMode )
230 {
231  if (pDrawView)
232  return;
233 
234  ScDrawLayer* pLayer = aViewData.GetDocument().GetDrawLayer();
235  OSL_ENSURE(pLayer, "Where is the Draw Layer ??");
236 
237  sal_uInt16 i;
238  pDrawView.reset( new ScDrawView( pGridWin[SC_SPLIT_BOTTOMLEFT]->GetOutDev(), &aViewData ) );
239  for (i=0; i<4; i++)
240  if (pGridWin[i])
241  {
242  if ( SC_SPLIT_BOTTOMLEFT != static_cast<ScSplitPos>(i) )
243  pDrawView->AddWindowToPaintView(pGridWin[i]->GetOutDev(), nullptr);
244  }
245  pDrawView->RecalcScale();
246  for (i=0; i<4; i++)
247  if (pGridWin[i])
248  {
249  pGridWin[i]->SetMapMode(pGridWin[i]->GetDrawMapMode());
250 
251  pGridWin[i]->PaintImmediately(); // because of Invalidate in DrawView ctor (ShowPage),
252  // so that immediately can be drawn
253  }
254  SfxRequest aSfxRequest(SID_OBJECT_SELECT, SfxCallMode::SLOT, aViewData.GetViewShell()->GetPool());
255  SetDrawFuncPtr(new FuSelection(*aViewData.GetViewShell(), GetActiveWin(), pDrawView.get(),
256  pLayer,aSfxRequest));
257 
258  // used when switching back from page preview: restore saved design mode state
259  // (otherwise, keep the default from the draw view ctor)
260  if ( nForceDesignMode != TRISTATE_INDET )
261  pDrawView->SetDesignMode( nForceDesignMode != TRISTATE_FALSE );
262 
263  // register at FormShell
264  FmFormShell* pFormSh = aViewData.GetViewShell()->GetFormShell();
265  if (pFormSh)
266  pFormSh->SetView(pDrawView.get());
267 
268  if (aViewData.GetViewShell()->HasAccessibilityObjects())
269  aViewData.GetViewShell()->BroadcastAccessibility(SfxHint(SfxHintId::ScAccMakeDrawLayer));
270 }
271 
273 {
274  if (pDrawView)
275  {
276  pDrawView->AddWindowToPaintView(pWin->GetOutDev(), nullptr);
277  pWin->DrawLayerCreated();
278  }
279  pWin->SetAutoSpellContext(mpSpellCheckCxt);
280 }
281 
282 void ScTabView::TabChanged( bool bSameTabButMoved )
283 {
284  if (pDrawView)
285  {
286  DrawDeselectAll(); // end also text edit mode
287 
288  SCTAB nTab = aViewData.GetTabNo();
289  pDrawView->HideSdrPage();
290  pDrawView->ShowSdrPage(pDrawView->GetModel()->GetPage(nTab));
291 
292  UpdateLayerLocks();
293 
294  pDrawView->RecalcScale();
295  pDrawView->UpdateWorkArea(); // PageSize is different per page
296  }
297 
298  SfxBindings& rBindings = aViewData.GetBindings();
299 
300  // There is no easy way to invalidate all slots of the FormShell
301  // (for disabled slots on protected tables), therefore simply everything...
302  rBindings.InvalidateAll(false);
303 
304  if (aViewData.GetViewShell()->HasAccessibilityObjects())
305  {
306  SfxHint aAccHint(SfxHintId::ScAccTableChanged);
307  aViewData.GetViewShell()->BroadcastAccessibility(aAccHint);
308  }
309 
310  // notification for XActivationBroadcaster
311  SfxViewFrame* pViewFrame = aViewData.GetViewShell()->GetViewFrame();
312  if (pViewFrame)
313  {
314  uno::Reference<frame::XController> xController = pViewFrame->GetFrame().GetController();
315  if (xController.is())
316  {
317  ScTabViewObj* pImp = comphelper::getUnoTunnelImplementation<ScTabViewObj>( xController );
318  if (pImp)
319  pImp->SheetChanged( bSameTabButMoved );
320  }
321  }
322 
323  for (int i = 0; i < 4; i++)
324  if (pGridWin[i])
325  {
326  pGridWin[i]->initiatePageBreaks();
327  }
328 
329 
331  return;
332 
333  ScDocShell* pDocSh = GetViewData().GetDocShell();
334  ScModelObj* pModelObj = pDocSh ? comphelper::getUnoTunnelImplementation<ScModelObj>( pDocSh->GetModel()) : nullptr;
335 
336  if (!pModelObj)
337  return;
338 
339  Size aDocSize = pModelObj->getDocumentSize();
340  std::stringstream ss;
341  ss << aDocSize.Width() << ", " << aDocSize.Height();
342  OString sRect = ss.str().c_str();
343  ScTabViewShell* pViewShell = aViewData.GetViewShell();
344 
345  // Invalidate first
346  tools::Rectangle aRectangle(0, 0, 1000000000, 1000000000);
347  OString sPayload = aRectangle.toString() + ", " + OString::number(aViewData.GetTabNo());
348  pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_TILES, sPayload.getStr());
349 
350  ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(pViewShell->GetCurrentDocument());
351  SfxLokHelper::notifyDocumentSizeChanged(pViewShell, sRect, pModel, false);
352 }
353 
355 {
356  if (!pDrawView)
357  return;
358 
359  SCTAB nTab = aViewData.GetTabNo();
360  bool bEx = aViewData.GetViewShell()->IsDrawSelMode();
361  bool bProt = aViewData.GetDocument().IsTabProtected( nTab ) ||
362  aViewData.GetSfxDocShell()->IsReadOnly();
363  bool bShared = aViewData.GetDocShell()->IsDocShared();
364 
365  SdrLayer* pLayer;
366  SdrLayerAdmin& rAdmin = pDrawView->GetModel()->GetLayerAdmin();
367  pLayer = rAdmin.GetLayerPerID(SC_LAYER_BACK);
368  if (pLayer)
369  pDrawView->SetLayerLocked( pLayer->GetName(), bProt || !bEx || bShared );
370  pLayer = rAdmin.GetLayerPerID(SC_LAYER_INTERN);
371  if (pLayer)
372  pDrawView->SetLayerLocked( pLayer->GetName() );
373  pLayer = rAdmin.GetLayerPerID(SC_LAYER_FRONT);
374  if (pLayer)
375  pDrawView->SetLayerLocked( pLayer->GetName(), bProt || bShared );
376  pLayer = rAdmin.GetLayerPerID(SC_LAYER_CONTROLS);
377  if (pLayer)
378  pDrawView->SetLayerLocked( pLayer->GetName(), bProt || bShared );
379  pLayer = rAdmin.GetLayerPerID(SC_LAYER_HIDDEN);
380  if (pLayer)
381  {
382  pDrawView->SetLayerLocked( pLayer->GetName(), bProt || bShared );
383  pDrawView->SetLayerVisible( pLayer->GetName(), false);
384  }
385 }
386 
388 {
389  if (!pDrawView)
390  return;
391 
392  ScTabViewShell* pViewSh = aViewData.GetViewShell();
393  if ( pDrawActual &&
394  ( pViewSh->IsDrawTextShell() || pDrawActual->GetSlotID() == SID_DRAW_NOTEEDIT ) )
395  {
396  // end text edit (as if escape pressed, in FuDraw)
397  aViewData.GetDispatcher().Execute( pDrawActual->GetSlotID(),
398  SfxCallMode::SLOT | SfxCallMode::RECORD );
399  }
400 
401  pDrawView->ScEndTextEdit();
402  pDrawView->UnmarkAll();
403 
404  if (!pViewSh->IsDrawSelMode())
405  pViewSh->SetDrawShell( false );
406 }
407 
409 {
410  if (pDrawView)
411  return pDrawView->IsTextEdit();
412  else
413  return false;
414 }
415 
417 {
418  return aViewData.GetZoomType();
419 }
420 
421 void ScTabView::SetZoomType( SvxZoomType eNew, bool bAll )
422 {
423  aViewData.SetZoomType( eNew, bAll );
424 }
425 
426 void ScTabView::SetZoom( const Fraction& rNewX, const Fraction& rNewY, bool bAll )
427 {
428  aViewData.SetZoom( rNewX, rNewY, bAll );
429  if (pDrawView)
430  pDrawView->RecalcScale();
431  ZoomChanged();
432 }
433 
435 {
436  aViewData.RefreshZoom();
437  if (pDrawView)
438  pDrawView->RecalcScale();
439  ZoomChanged();
440 }
441 
443 {
444  aViewData.SetPagebreakMode(bSet);
445  if (pDrawView)
446  pDrawView->RecalcScale();
447  ZoomChanged();
448 }
449 
451 {
452  if (pDrawView)
453  pDrawView->SetDragMode( SdrDragMode::Move );
454 }
455 
456 void ScTabView::ViewOptionsHasChanged( bool bHScrollChanged, bool bGraphicsChanged )
457 {
458  // create DrawView when grid should be displayed
459  if ( !pDrawView && aViewData.GetOptions().GetGridOptions().GetGridVisible() )
460  MakeDrawLayer();
461 
462  if (pDrawView)
463  pDrawView->UpdateUserViewOptions();
464 
465  if (bGraphicsChanged)
466  DrawEnableAnim(true); // DrawEnableAnim checks the options state
467 
468  // if TabBar is set to visible, make sure its size is not 0
469  bool bGrow = ( aViewData.IsTabMode() && pTabControl->GetSizePixel().Width() <= 0 );
470 
471  // if ScrollBar is set to visible, TabBar must make room
472  bool bShrink = ( bHScrollChanged && aViewData.IsTabMode() && aViewData.IsHScrollMode() &&
473  pTabControl->GetSizePixel().Width() > SC_TABBAR_DEFWIDTH );
474 
475  if ( bGrow || bShrink )
476  {
477  Size aSize = pTabControl->GetSizePixel();
478  aSize.setWidth( SC_TABBAR_DEFWIDTH ); // initial size
479  pTabControl->SetSizePixel(aSize); // DoResize is called later...
480  }
481 }
482 
483 // helper function against including the drawing layer
484 
486 {
487  if ( pDrawView )
488  pDrawView->MarkListHasChanged();
489 }
490 
492 {
493  if ( pDrawView )
494  pDrawView->AdjustMarkHdl();
495 }
496 
498 {
499  if ( pDrawView )
500  pDrawView->UpdateIMap( pObj );
501 }
502 
504 {
505  sal_uInt16 i;
506  if ( !pDrawView )
507  return;
508 
509  // don't start animations if display of graphics is disabled
510  // graphics are controlled by VOBJ_TYPE_OLE
511  if ( bSet && aViewData.GetOptions().GetObjMode(VOBJ_TYPE_OLE) == VOBJ_MODE_SHOW )
512  {
513  if ( !pDrawView->IsAnimationEnabled() )
514  {
515  pDrawView->SetAnimationEnabled();
516 
517  // animated GIFs must be restarted:
518  ScDocument& rDoc = aViewData.GetDocument();
519  for (i=0; i<4; i++)
520  if ( pGridWin[i] && pGridWin[i]->IsVisible() )
521  rDoc.StartAnimations( aViewData.GetTabNo() );
522  }
523  }
524  else
525  {
526  pDrawView->SetAnimationEnabled(false);
527  }
528 }
529 
531 {
532  if ( pDrawView )
533  {
534  Outliner* pOL = pDrawView->GetTextEditOutliner();
535  if (pOL)
536  aViewData.UpdateOutlinerFlags( *pOL );
537  }
538 }
539 
541 {
542  LanguageType eNewLang = SC_MOD()->GetOptDigitLanguage();
543  for (VclPtr<ScGridWindow> & pWin : pGridWin)
544  if ( pWin )
545  pWin->GetOutDev()->SetDigitLanguage( eNewLang );
546 }
547 
548 void ScTabView::ScrollToObject( const SdrObject* pDrawObj )
549 {
550  if ( pDrawObj )
551  {
552  // #i118524# use the BoundRect, this defines the visible area
553  MakeVisible(pDrawObj->GetCurrentBoundRect());
554  }
555 }
556 
558 {
559  vcl::Window* pWin = GetActiveWin();
560  Size aWinSize = pWin->GetOutputSizePixel();
561  SCTAB nTab = aViewData.GetTabNo();
562 
563  tools::Rectangle aRect = pWin->LogicToPixel( rHMMRect );
564 
565  tools::Long nScrollX=0, nScrollY=0; // pixel
566 
567  if ( aRect.Right() >= aWinSize.Width() ) // right out
568  {
569  nScrollX = aRect.Right() - aWinSize.Width() + 1; // right border visible
570  if ( aRect.Left() < nScrollX )
571  nScrollX = aRect.Left(); // left visible (if too big)
572  }
573  if ( aRect.Bottom() >= aWinSize.Height() ) // bottom out
574  {
575  nScrollY = aRect.Bottom() - aWinSize.Height() + 1; // bottom border visible
576  if ( aRect.Top() < nScrollY )
577  nScrollY = aRect.Top(); // top visible (if too big)
578  }
579 
580  if ( aRect.Left() < 0 ) // left out
581  nScrollX = aRect.Left(); // left border visible
582  if ( aRect.Top() < 0 ) // top out
583  nScrollY = aRect.Top(); // top border visible
584 
585  if (!(nScrollX || nScrollY))
586  return;
587 
588  ScDocument& rDoc = aViewData.GetDocument();
589  if ( rDoc.IsNegativePage( nTab ) )
590  nScrollX = -nScrollX;
591 
592  double nPPTX = aViewData.GetPPTX();
593  double nPPTY = aViewData.GetPPTY();
594  ScSplitPos eWhich = aViewData.GetActivePart();
595  SCCOL nPosX = aViewData.GetPosX(WhichH(eWhich));
596  SCROW nPosY = aViewData.GetPosY(WhichV(eWhich));
597 
598  tools::Long nLinesX=0, nLinesY=0; // columns/rows - scroll at least nScrollX/Y
599 
600  if (nScrollX > 0)
601  while (nScrollX > 0 && nPosX < rDoc.MaxCol())
602  {
603  nScrollX -= static_cast<tools::Long>( rDoc.GetColWidth(nPosX, nTab) * nPPTX );
604  ++nPosX;
605  ++nLinesX;
606  }
607  else if (nScrollX < 0)
608  while (nScrollX < 0 && nPosX > 0)
609  {
610  --nPosX;
611  nScrollX += static_cast<tools::Long>( rDoc.GetColWidth(nPosX, nTab) * nPPTX );
612  --nLinesX;
613  }
614 
615  if (nScrollY > 0)
616  while (nScrollY > 0 && nPosY < rDoc.MaxRow())
617  {
618  nScrollY -= static_cast<tools::Long>( rDoc.GetRowHeight(nPosY, nTab) * nPPTY );
619  ++nPosY;
620  ++nLinesY;
621  }
622  else if (nScrollY < 0)
623  while (nScrollY < 0 && nPosY > 0)
624  {
625  --nPosY;
626  nScrollY += static_cast<tools::Long>( rDoc.GetRowHeight(nPosY, nTab) * nPPTY );
627  --nLinesY;
628  }
629 
630  ScrollLines( nLinesX, nLinesY ); // execute
631 }
632 
634 {
635  pDrawBrushSet.reset();
636  pBrushDocument = std::move(pNew);
637 
638  bLockPaintBrush = bLock;
639 
640  aViewData.GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
641 }
642 
643 void ScTabView::SetDrawBrushSet( std::unique_ptr<SfxItemSet> pNew, bool bLock )
644 {
645  pBrushDocument.reset();
646  pDrawBrushSet = std::move(pNew);
647 
648  bLockPaintBrush = bLock;
649 
650  aViewData.GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
651 }
652 
654 {
655  if ( HasPaintBrush() )
656  {
657  SetBrushDocument( nullptr, false );
658  SetActivePointer( aViewData.IsThemedCursor() ? PointerStyle::FatCross : PointerStyle::Arrow ); // switch pointers also when ended with escape key
659  }
660 }
661 
663 {
665  return;
666 
667  const SdrCaptionObj* pCaption = pNote->GetCaption();
668  if (!pCaption) return;
669 
670  tools::Rectangle aRect = pCaption->GetLogicRect();
671  basegfx::B2DRange aTailRange = pCaption->getTailPolygon().getB2DRange();
672  tools::Rectangle aTailRect(aTailRange.getMinX(), aTailRange.getMinY(),
673  aTailRange.getMaxX(), aTailRange.getMaxY());
674  aRect.Union( aTailRect );
675 
676  // This is a temporary workaround: sometime in tiled rendering mode
677  // the tip of the note arrow is misplaced by a fixed offset.
678  // The value used below is enough to get the tile, where the arrow tip is
679  // placed, invalidated.
680  const int nBorderSize = 200;
681  tools::Rectangle aInvalidRect = aRect;
682  aInvalidRect.AdjustLeft( -nBorderSize );
683  aInvalidRect.AdjustRight( nBorderSize );
684  aInvalidRect.AdjustTop( -nBorderSize );
685  aInvalidRect.AdjustBottom( nBorderSize );
686 
687  SfxViewShell* pCurrentViewShell = SfxViewShell::Current();
688  SfxViewShell* pViewShell = SfxViewShell::GetFirst();
689  while (pViewShell)
690  {
691  ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
692  if (pTabViewShell && pViewShell->GetDocId() == pCurrentViewShell->GetDocId())
693  {
694  for (auto& pWin: pTabViewShell->pGridWin)
695  {
696  if (pWin && pWin->IsVisible())
697  {
698  pWin->Invalidate(aInvalidRect);
699  }
700  }
701  }
702  pViewShell = SfxViewShell::GetNext(*pViewShell);
703  }
704 }
705 
706 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetAutoSpellContext(const std::shared_ptr< sc::SpellCheckContext > &ctx)
Definition: gridwin.cxx:5673
SfxViewFrame * GetViewFrame() const
SvxZoomType GetZoomType() const
Definition: tabview5.cxx:416
constexpr double nPPTY
void ResetBrushDocument()
Definition: tabview5.cxx:653
bool IsDrawSelMode() const
Definition: tabview.hxx:316
static void notifyDocumentSizeChanged(SfxViewShell const *pThisView, const OString &rPayload, vcl::ITiledRenderable *pDoc, bool bInvalidateAll=true)
virtual const tools::Rectangle & GetCurrentBoundRect() const
#define SC_TABBAR_DEFWIDTH
Definition: tabcont.hxx:29
ScVSplitPos WhichV(ScSplitPos ePos)
Definition: viewdata.hxx:718
void RemoveWindowFromForeignEditView(SfxViewShell *pViewShell, ScSplitPos eWhich)
Definition: tabview3.cxx:2043
SC_DLLPUBLIC void RefreshZoom()
Definition: tabview5.cxx:434
SC_DLLPUBLIC bool IsNegativePage(SCTAB nTab) const
Definition: document.cxx:993
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
void setWidth(tools::Long nWidth)
void SetBrushDocument(ScDocumentUniquePtr pNew, bool bLock)
Definition: tabview5.cxx:633
void SetPagebreakMode(bool bSet)
Definition: tabview5.cxx:442
long Long
ScHSplitPos WhichH(ScSplitPos ePos)
Definition: viewdata.hxx:712
virtual const tools::Rectangle & GetLogicRect() const override
css::uno::Reference< css::frame::XModel3 > GetModel() const
ViewShellDocId GetDocId() const override
void DrawLayerCreated()
Definition: gridwin.cxx:5665
bool HasEditView(ScSplitPos eWhich) const
Definition: viewdata.hxx:572
constexpr SdrLayerID SC_LAYER_BACK(1)
void ViewOptionsHasChanged(bool bHScrollChanged, bool bGraphicsChanged)
Definition: tabview5.cxx:456
void UpdateIMap(SdrObject *pObj)
Definition: tabview5.cxx:497
::basegfx::B2DPolygon getTailPolygon() const
void SheetChanged(bool bSameTabButMoved)
Definition: viewuno.cxx:534
WinBits const WB_VSCROLL
Base class for all functions.
Definition: fusel.hxx:27
void TabChanged(bool bSameTabButMoved=false)
Called after moving, copying, inserting or deleting a sheet.
Definition: tabview5.cxx:282
static void forEachOtherView(ViewShellType *pThisViewShell, FunctionType f)
double getMaxX() const
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4192
void StartAnimations(SCTAB nTab)
Definition: documen9.cxx:319
ScSplitPos
Definition: viewdata.hxx:44
constexpr tools::Long Width() const
sal_Int64 WinBits
Reference< XController > xController
tools::Long Left() const
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:872
Additional class containing cell annotation data.
Definition: postit.hxx:159
WinBits const WB_HSCROLL
SfxFrame & GetFrame() const
static SfxViewShell * GetNext(const SfxViewShell &rPrev, bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
tools::Long Bottom() const
static SfxViewShell * Current()
void libreOfficeKitViewCallback(int nType, const char *pPayload) const override
bool IsDrawTextShell() const
Definition: tabvwsh4.cxx:1006
void DrawMarkListHasChanged()
Definition: tabview5.cxx:485
const tools::Long nScrollY
double getMaxY() const
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
TRISTATE_INDET
void SetView(FmFormView *pView)
void ScrollToObject(const SdrObject *pDrawObj)
Definition: tabview5.cxx:548
const tools::Long nScrollX
constexpr double nPPTX
ScDocument * GetDocument() const
Definition: drwlayer.hxx:129
void SetZoom(const Fraction &rNewX, const Fraction &rNewY, bool bAll)
Definition: tabview5.cxx:426
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1058
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:871
Point LogicToPixel(const Point &rLogicPt) const
SfxDispatcher * GetDispatcher() const
int i
void DoAddWin(ScGridWindow *pWin)
Definition: tabview5.cxx:272
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
Definition: document.hxx:2621
sal_Int16 SCCOL
Definition: types.hxx:21
#define SC_MOD()
Definition: scmod.hxx:250
TRISTATE_FALSE
void DrawEnableAnim(bool bSet)
Definition: tabview5.cxx:503
void SetDrawShell(bool bActive)
Definition: tabvwsh4.cxx:611
const OUString & GetName() const
static bool GetLayoutRTL()
virtual css::uno::Reference< css::frame::XModel > GetCurrentDocument() const
SdrLayer * GetLayerPerID(SdrLayerID nID)
void MakeVisible(const tools::Rectangle &rHMMRect)
Definition: tabview5.cxx:557
void ResetDrawDragMode()
Definition: tabview5.cxx:450
tools::Long Top() const
static SfxViewShell * GetFirst(bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
SfxViewShell * GetViewShell() const
ScSelectionTransferObj * GetSelectionTransfer() const
Definition: scmod.hxx:152
tools::Long AdjustTop(tools::Long nVertMoveDelta)
void DigitLanguageChanged()
Definition: tabview5.cxx:540
WinBits const WB_SIZEABLE
B2DRange const & getB2DRange() const
sal_Int32 SCROW
Definition: types.hxx:17
SdrCaptionObj * GetCaption() const
Returns an existing note caption object.
Definition: postit.hxx:236
double getMinY() const
constexpr SdrLayerID SC_LAYER_HIDDEN(4)
tools::Rectangle & Union(const tools::Rectangle &rRect)
void DrawDeselectAll()
Definition: tabview5.cxx:387
constexpr tools::Long Height() const
virtual void Invalidate(sal_uInt16 nId=0)
constexpr SdrLayerID SC_LAYER_FRONT(0)
bool IsDrawTextEdit() const
Definition: tabview5.cxx:408
css::uno::Reference< css::frame::XController > GetController() const
::OutputDevice const * GetOutDev() const
constexpr SdrLayerID SC_LAYER_INTERN(2)
static VclPtr< reference_type > Create(Arg &&...arg)
static void OnLOKNoteStateChanged(const ScPostIt *pNote)
Definition: tabview5.cxx:662
Size GetOutputSizePixel() const
void UpdateAnchorHandles()
Definition: tabview5.cxx:491
void SetSelectionTransfer(ScSelectionTransferObj *pNew)
Definition: scmod.cxx:645
void SetZoomType(SvxZoomType eNew, bool bAll)
Definition: tabview5.cxx:421
void InvalidateAll(bool bWithMsg)
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
double getMinX() const
void UpdateDrawTextOutliner()
Definition: tabview5.cxx:530
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
SvxZoomType
void UpdateLayerLocks()
Definition: tabview5.cxx:354
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4151
TriState
rtl::OString toString() const
static void ClearPrimarySelection()
constexpr SdrLayerID SC_LAYER_CONTROLS(3)
void SetDrawBrushSet(std::unique_ptr< SfxItemSet > pNew, bool bLock)
Definition: tabview5.cxx:643
tools::Long Right() const
sal_Int16 SCTAB
Definition: types.hxx:22
virtual Size getDocumentSize() override
Definition: docuno.cxx:654
void MakeDrawView(TriState nForceDesignMode)
Definition: tabview5.cxx:229
ScTabView * GetView() const
Definition: seltrans.hxx:61
void Init()
Definition: tabview5.cxx:60