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