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::getFromUnoTunnel<ScTabViewObj>( xController );
318  if (pImp)
319  pImp->SheetChanged( bSameTabButMoved );
320  }
321  }
322 
323  for (int i = 0; i < 4; i++)
324  {
325  if (pGridWin[i])
326  {
327  pGridWin[i]->initiatePageBreaks();
328  // Trigger calculating page breaks only once.
329  break;
330  }
331  }
332 
334  return;
335 
336  ScDocShell* pDocSh = GetViewData().GetDocShell();
337  ScModelObj* pModelObj = pDocSh ? comphelper::getFromUnoTunnel<ScModelObj>( pDocSh->GetModel()) : nullptr;
338 
339  if (!pModelObj)
340  return;
341 
342  Size aDocSize = pModelObj->getDocumentSize();
343  std::stringstream ss;
344  ss << aDocSize.Width() << ", " << aDocSize.Height();
345  OString sRect = ss.str().c_str();
346  ScTabViewShell* pViewShell = aViewData.GetViewShell();
347 
348  // Invalidate first
349  tools::Rectangle aRectangle(0, 0, 1000000000, 1000000000);
350  pViewShell->libreOfficeKitViewInvalidateTilesCallback(&aRectangle, aViewData.GetTabNo());
351 
352  ScModelObj* pModel = comphelper::getFromUnoTunnel<ScModelObj>(pViewShell->GetCurrentDocument());
353  SfxLokHelper::notifyDocumentSizeChanged(pViewShell, sRect, pModel, false);
354 }
355 
357 {
358  if (!pDrawView)
359  return;
360 
361  SCTAB nTab = aViewData.GetTabNo();
362  bool bEx = aViewData.GetViewShell()->IsDrawSelMode();
363  bool bProt = aViewData.GetDocument().IsTabProtected( nTab ) ||
364  aViewData.GetSfxDocShell()->IsReadOnly();
365  bool bShared = aViewData.GetDocShell()->IsDocShared();
366 
367  SdrLayer* pLayer;
368  SdrLayerAdmin& rAdmin = pDrawView->GetModel()->GetLayerAdmin();
369  pLayer = rAdmin.GetLayerPerID(SC_LAYER_BACK);
370  if (pLayer)
371  pDrawView->SetLayerLocked( pLayer->GetName(), bProt || !bEx || bShared );
372  pLayer = rAdmin.GetLayerPerID(SC_LAYER_INTERN);
373  if (pLayer)
374  pDrawView->SetLayerLocked( pLayer->GetName() );
375  pLayer = rAdmin.GetLayerPerID(SC_LAYER_FRONT);
376  if (pLayer)
377  pDrawView->SetLayerLocked( pLayer->GetName(), bProt || bShared );
378  pLayer = rAdmin.GetLayerPerID(SC_LAYER_CONTROLS);
379  if (pLayer)
380  pDrawView->SetLayerLocked( pLayer->GetName(), bProt || bShared );
381  pLayer = rAdmin.GetLayerPerID(SC_LAYER_HIDDEN);
382  if (pLayer)
383  {
384  pDrawView->SetLayerLocked( pLayer->GetName(), bProt || bShared );
385  pDrawView->SetLayerVisible( pLayer->GetName(), false);
386  }
387 }
388 
390 {
391  if (!pDrawView)
392  return;
393 
394  ScTabViewShell* pViewSh = aViewData.GetViewShell();
395  if ( pDrawActual &&
396  ( pViewSh->IsDrawTextShell() || pDrawActual->GetSlotID() == SID_DRAW_NOTEEDIT ) )
397  {
398  // end text edit (as if escape pressed, in FuDraw)
399  aViewData.GetDispatcher().Execute( pDrawActual->GetSlotID(),
400  SfxCallMode::SLOT | SfxCallMode::RECORD );
401  }
402 
403  pDrawView->ScEndTextEdit();
404  pDrawView->UnmarkAll();
405 
406  if (!pViewSh->IsDrawSelMode())
407  pViewSh->SetDrawShell( false );
408 }
409 
411 {
412  if (pDrawView)
413  return pDrawView->IsTextEdit();
414  else
415  return false;
416 }
417 
419 {
420  return aViewData.GetZoomType();
421 }
422 
423 void ScTabView::SetZoomType( SvxZoomType eNew, bool bAll )
424 {
425  aViewData.SetZoomType( eNew, bAll );
426 }
427 
428 void ScTabView::SetZoom( const Fraction& rNewX, const Fraction& rNewY, bool bAll )
429 {
430  aViewData.SetZoom( rNewX, rNewY, bAll );
431  if (pDrawView)
432  pDrawView->RecalcScale();
433  ZoomChanged();
434 }
435 
437 {
438  aViewData.RefreshZoom();
439  if (pDrawView)
440  pDrawView->RecalcScale();
441  ZoomChanged();
442 }
443 
445 {
446  aViewData.SetPagebreakMode(bSet);
447  if (pDrawView)
448  pDrawView->RecalcScale();
449  ZoomChanged();
450 }
451 
453 {
454  if (pDrawView)
455  pDrawView->SetDragMode( SdrDragMode::Move );
456 }
457 
458 void ScTabView::ViewOptionsHasChanged( bool bHScrollChanged, bool bGraphicsChanged )
459 {
460  // create DrawView when grid should be displayed
461  if ( !pDrawView && aViewData.GetOptions().GetGridOptions().GetGridVisible() )
462  MakeDrawLayer();
463 
464  if (pDrawView)
465  pDrawView->UpdateUserViewOptions();
466 
467  if (bGraphicsChanged)
468  DrawEnableAnim(true); // DrawEnableAnim checks the options state
469 
470  // if TabBar is set to visible, make sure its size is not 0
471  bool bGrow = ( aViewData.IsTabMode() && pTabControl->GetSizePixel().Width() <= 0 );
472 
473  // if ScrollBar is set to visible, TabBar must make room
474  bool bShrink = ( bHScrollChanged && aViewData.IsTabMode() && aViewData.IsHScrollMode() &&
475  pTabControl->GetSizePixel().Width() > SC_TABBAR_DEFWIDTH );
476 
477  if ( bGrow || bShrink )
478  {
479  Size aSize = pTabControl->GetSizePixel();
480  aSize.setWidth( SC_TABBAR_DEFWIDTH ); // initial size
481  pTabControl->SetSizePixel(aSize); // DoResize is called later...
482  }
483 }
484 
485 // helper function against including the drawing layer
486 
488 {
489  if ( pDrawView )
490  pDrawView->MarkListHasChanged();
491 }
492 
494 {
495  if ( pDrawView )
496  pDrawView->AdjustMarkHdl();
497 }
498 
500 {
501  if ( pDrawView )
502  pDrawView->UpdateIMap( pObj );
503 }
504 
506 {
507  sal_uInt16 i;
508  if ( !pDrawView )
509  return;
510 
511  // don't start animations if display of graphics is disabled
512  // graphics are controlled by VOBJ_TYPE_OLE
513  if ( bSet && aViewData.GetOptions().GetObjMode(VOBJ_TYPE_OLE) == VOBJ_MODE_SHOW )
514  {
515  if ( !pDrawView->IsAnimationEnabled() )
516  {
517  pDrawView->SetAnimationEnabled();
518 
519  // animated GIFs must be restarted:
520  ScDocument& rDoc = aViewData.GetDocument();
521  for (i=0; i<4; i++)
522  if ( pGridWin[i] && pGridWin[i]->IsVisible() )
523  rDoc.StartAnimations( aViewData.GetTabNo() );
524  }
525  }
526  else
527  {
528  pDrawView->SetAnimationEnabled(false);
529  }
530 }
531 
533 {
534  if ( pDrawView )
535  {
536  Outliner* pOL = pDrawView->GetTextEditOutliner();
537  if (pOL)
538  aViewData.UpdateOutlinerFlags( *pOL );
539  }
540 }
541 
543 {
544  LanguageType eNewLang = SC_MOD()->GetOptDigitLanguage();
545  for (VclPtr<ScGridWindow> & pWin : pGridWin)
546  if ( pWin )
547  pWin->GetOutDev()->SetDigitLanguage( eNewLang );
548 }
549 
550 void ScTabView::ScrollToObject( const SdrObject* pDrawObj )
551 {
552  if ( pDrawObj )
553  {
554  // #i118524# use the BoundRect, this defines the visible area
555  MakeVisible(pDrawObj->GetCurrentBoundRect());
556  }
557 }
558 
560 {
561  vcl::Window* pWin = GetActiveWin();
562  Size aWinSize = pWin->GetOutputSizePixel();
563  SCTAB nTab = aViewData.GetTabNo();
564 
565  tools::Rectangle aRect = pWin->LogicToPixel( rHMMRect );
566 
567  tools::Long nScrollX=0, nScrollY=0; // pixel
568 
569  if ( aRect.Right() >= aWinSize.Width() ) // right out
570  {
571  nScrollX = aRect.Right() - aWinSize.Width() + 1; // right border visible
572  if ( aRect.Left() < nScrollX )
573  nScrollX = aRect.Left(); // left visible (if too big)
574  }
575  if ( aRect.Bottom() >= aWinSize.Height() ) // bottom out
576  {
577  nScrollY = aRect.Bottom() - aWinSize.Height() + 1; // bottom border visible
578  if ( aRect.Top() < nScrollY )
579  nScrollY = aRect.Top(); // top visible (if too big)
580  }
581 
582  if ( aRect.Left() < 0 ) // left out
583  nScrollX = aRect.Left(); // left border visible
584  if ( aRect.Top() < 0 ) // top out
585  nScrollY = aRect.Top(); // top border visible
586 
587  if (!(nScrollX || nScrollY))
588  return;
589 
590  ScDocument& rDoc = aViewData.GetDocument();
591  if ( rDoc.IsNegativePage( nTab ) )
592  nScrollX = -nScrollX;
593 
594  double nPPTX = aViewData.GetPPTX();
595  double nPPTY = aViewData.GetPPTY();
596  ScSplitPos eWhich = aViewData.GetActivePart();
597  SCCOL nPosX = aViewData.GetPosX(WhichH(eWhich));
598  SCROW nPosY = aViewData.GetPosY(WhichV(eWhich));
599 
600  tools::Long nLinesX=0, nLinesY=0; // columns/rows - scroll at least nScrollX/Y
601 
602  if (nScrollX > 0)
603  while (nScrollX > 0 && nPosX < rDoc.MaxCol())
604  {
605  nScrollX -= static_cast<tools::Long>( rDoc.GetColWidth(nPosX, nTab) * nPPTX );
606  ++nPosX;
607  ++nLinesX;
608  }
609  else if (nScrollX < 0)
610  while (nScrollX < 0 && nPosX > 0)
611  {
612  --nPosX;
613  nScrollX += static_cast<tools::Long>( rDoc.GetColWidth(nPosX, nTab) * nPPTX );
614  --nLinesX;
615  }
616 
617  if (nScrollY > 0)
618  while (nScrollY > 0 && nPosY < rDoc.MaxRow())
619  {
620  nScrollY -= static_cast<tools::Long>( rDoc.GetRowHeight(nPosY, nTab) * nPPTY );
621  ++nPosY;
622  ++nLinesY;
623  }
624  else if (nScrollY < 0)
625  while (nScrollY < 0 && nPosY > 0)
626  {
627  --nPosY;
628  nScrollY += static_cast<tools::Long>( rDoc.GetRowHeight(nPosY, nTab) * nPPTY );
629  --nLinesY;
630  }
631 
632  ScrollLines( nLinesX, nLinesY ); // execute
633 }
634 
636 {
637  pDrawBrushSet.reset();
638  pBrushDocument = std::move(pNew);
639 
640  bLockPaintBrush = bLock;
641 
642  aViewData.GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
643 }
644 
645 void ScTabView::SetDrawBrushSet( std::unique_ptr<SfxItemSet> pNew, bool bLock )
646 {
647  pBrushDocument.reset();
648  pDrawBrushSet = std::move(pNew);
649 
650  bLockPaintBrush = bLock;
651 
652  aViewData.GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
653 }
654 
656 {
657  if ( HasPaintBrush() )
658  {
659  SetBrushDocument( nullptr, false );
660  SetActivePointer( aViewData.IsThemedCursor() ? PointerStyle::FatCross : PointerStyle::Arrow ); // switch pointers also when ended with escape key
661  }
662 }
663 
665 {
667  return;
668 
669  const SdrCaptionObj* pCaption = pNote->GetCaption();
670  if (!pCaption) return;
671 
672  tools::Rectangle aRect = pCaption->GetLogicRect();
673  basegfx::B2DRange aTailRange = pCaption->getTailPolygon().getB2DRange();
674  tools::Rectangle aTailRect(aTailRange.getMinX(), aTailRange.getMinY(),
675  aTailRange.getMaxX(), aTailRange.getMaxY());
676  aRect.Union( aTailRect );
677 
678  // This is a temporary workaround: sometime in tiled rendering mode
679  // the tip of the note arrow is misplaced by a fixed offset.
680  // The value used below is enough to get the tile, where the arrow tip is
681  // placed, invalidated.
682  const int nBorderSize = 200;
683  tools::Rectangle aInvalidRect = aRect;
684  aInvalidRect.AdjustLeft( -nBorderSize );
685  aInvalidRect.AdjustRight( nBorderSize );
686  aInvalidRect.AdjustTop( -nBorderSize );
687  aInvalidRect.AdjustBottom( nBorderSize );
688 
689  SfxViewShell* pCurrentViewShell = SfxViewShell::Current();
690  SfxViewShell* pViewShell = SfxViewShell::GetFirst();
691  while (pViewShell)
692  {
693  ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
694  if (pTabViewShell && pViewShell->GetDocId() == pCurrentViewShell->GetDocId())
695  {
696  for (auto& pWin: pTabViewShell->pGridWin)
697  {
698  if (pWin && pWin->IsVisible())
699  {
700  pWin->Invalidate(aInvalidRect);
701  }
702  }
703  }
704  pViewShell = SfxViewShell::GetNext(*pViewShell);
705  }
706 }
707 
708 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetAutoSpellContext(const std::shared_ptr< sc::SpellCheckContext > &ctx)
Definition: gridwin.cxx:5690
SfxViewFrame * GetViewFrame() const
SvxZoomType GetZoomType() const
Definition: tabview5.cxx:418
constexpr double nPPTY
void ResetBrushDocument()
Definition: tabview5.cxx:655
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:436
SC_DLLPUBLIC bool IsNegativePage(SCTAB nTab) const
Definition: document.cxx:994
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
void setWidth(tools::Long nWidth)
void SetBrushDocument(ScDocumentUniquePtr pNew, bool bLock)
Definition: tabview5.cxx:635
constexpr tools::Long Left() const
void SetPagebreakMode(bool bSet)
Definition: tabview5.cxx:444
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:5682
bool HasEditView(ScSplitPos eWhich) const
Definition: viewdata.hxx:572
constexpr SdrLayerID SC_LAYER_BACK(1)
void ViewOptionsHasChanged(bool bHScrollChanged, bool bGraphicsChanged)
Definition: tabview5.cxx:458
void UpdateIMap(SdrObject *pObj)
Definition: tabview5.cxx:499
::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
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:872
Additional class containing cell annotation data.
Definition: postit.hxx:161
WinBits const WB_HSCROLL
SfxFrame & GetFrame() const
static SfxViewShell * GetNext(const SfxViewShell &rPrev, bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
static SfxViewShell * Current()
bool IsDrawTextShell() const
Definition: tabvwsh4.cxx:1006
void DrawMarkListHasChanged()
Definition: tabview5.cxx:487
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:550
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:428
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:2622
sal_Int16 SCCOL
Definition: types.hxx:21
#define SC_MOD()
Definition: scmod.hxx:250
TRISTATE_FALSE
void DrawEnableAnim(bool bSet)
Definition: tabview5.cxx:505
constexpr tools::Long Right() const
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)
constexpr tools::Long Top() const
void MakeVisible(const tools::Rectangle &rHMMRect)
Definition: tabview5.cxx:559
void ResetDrawDragMode()
Definition: tabview5.cxx:452
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:542
constexpr tools::Long Bottom() const
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:238
double getMinY() const
constexpr SdrLayerID SC_LAYER_HIDDEN(4)
tools::Rectangle & Union(const tools::Rectangle &rRect)
void DrawDeselectAll()
Definition: tabview5.cxx:389
constexpr tools::Long Height() const
virtual void Invalidate(sal_uInt16 nId=0)
constexpr SdrLayerID SC_LAYER_FRONT(0)
bool IsDrawTextEdit() const
Definition: tabview5.cxx:410
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:664
virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle *pRect, int nPart) const override
Size GetOutputSizePixel() const
void UpdateAnchorHandles()
Definition: tabview5.cxx:493
void SetSelectionTransfer(ScSelectionTransferObj *pNew)
Definition: scmod.cxx:645
void SetZoomType(SvxZoomType eNew, bool bAll)
Definition: tabview5.cxx:423
void InvalidateAll(bool bWithMsg)
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
double getMinX() const
void UpdateDrawTextOutliner()
Definition: tabview5.cxx:532
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:356
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4151
TriState
static void ClearPrimarySelection()
constexpr SdrLayerID SC_LAYER_CONTROLS(3)
void SetDrawBrushSet(std::unique_ptr< SfxItemSet > pNew, bool bLock)
Definition: tabview5.cxx:645
sal_Int16 SCTAB
Definition: types.hxx:22
virtual Size getDocumentSize() override
Definition: docuno.cxx:655
void MakeDrawView(TriState nForceDesignMode)
Definition: tabview5.cxx:229
ScTabView * GetView() const
Definition: seltrans.hxx:61
void Init()
Definition: tabview5.cxx:60