problem pasting to calc an image copied from firefox (windows)
[LibreOffice.git] / sc / source / ui / view / tabview5.cxx
blob5e6d7be6d3925352935dfeedfc565258c97dbcd3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
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>
52 #include <vcl/settings.hxx>
54 #include <comphelper/lok.hxx>
55 #include <officecfg/Office/Calc.hxx>
56 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
58 using namespace com::sun::star;
60 void ScTabView::Init()
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 );
68 sal_uInt16 i;
70 mbInlineWithScrollbar = officecfg::Office::Calc::Layout::Other::TabbarInlineWithScrollbar::get();
72 aScrollTimer.SetTimeout(10);
73 aScrollTimer.SetInvokeHandler( LINK( this, ScTabView, TimerHdl ) );
75 for (i=0; i<4; i++)
76 pGridWin[i] = nullptr;
77 pGridWin[SC_SPLIT_BOTTOMLEFT] = VclPtr<ScGridWindow>::Create( pFrameWin, aViewData, SC_SPLIT_BOTTOMLEFT );
79 pSelEngine.reset( new ScViewSelectionEngine( pGridWin[SC_SPLIT_BOTTOMLEFT], this,
80 SC_SPLIT_BOTTOMLEFT ) );
81 aFunctionSet.SetSelectionEngine( pSelEngine.get() );
83 pHdrSelEng.reset( new ScHeaderSelectionEngine( pFrameWin, &aHdrFunc ) );
85 pColBar[SC_SPLIT_LEFT] = VclPtr<ScColBar>::Create( pFrameWin, SC_SPLIT_LEFT,
86 &aHdrFunc, pHdrSelEng.get(), this );
87 pColBar[SC_SPLIT_RIGHT] = nullptr;
88 pRowBar[SC_SPLIT_BOTTOM] = VclPtr<ScRowBar>::Create( pFrameWin, SC_SPLIT_BOTTOM,
89 &aHdrFunc, pHdrSelEng.get(), this );
90 pRowBar[SC_SPLIT_TOP] = nullptr;
91 for (i=0; i<2; i++)
92 pColOutline[i] = pRowOutline[i] = nullptr;
94 pHSplitter = VclPtr<ScTabSplitter>::Create( pFrameWin, WinBits( WB_HSCROLL ), &aViewData );
95 pVSplitter = VclPtr<ScTabSplitter>::Create( pFrameWin, WinBits( WB_VSCROLL ), &aViewData );
97 // SSA: override default keyboard step size to allow snap to row/column
98 pHSplitter->SetKeyboardStepSize( 1 );
99 pVSplitter->SetKeyboardStepSize( 1 );
101 pTabControl = VclPtr<ScTabControl>::Create(pFrameWin, &aViewData);
102 if (mbInlineWithScrollbar)
103 pTabControl->SetStyle(pTabControl->GetStyle() | WB_SIZEABLE);
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() );
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. */
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
123 // fragment
125 pHSplitter->SetSplitHdl( LINK( this, ScTabView, SplitHdl ) );
126 pVSplitter->SetSplitHdl( LINK( this, ScTabView, SplitHdl ) );
128 // UpdateShow is done during resize or a copy of an existing view from ctor
130 pDrawActual = nullptr;
131 pDrawOld = nullptr;
133 // DrawView cannot be create in the TabView - ctor
134 // when the ViewShell isn't constructed yet...
135 // The also applies to ViewOptionsHasChanged()
137 TestHintWindow();
140 ScTabView::~ScTabView()
142 sal_uInt16 i;
144 // remove selection object
145 ScModule* pScMod = SC_MOD();
146 ScSelectionTransferObj* pOld = pScMod->GetSelectionTransfer();
147 if ( pOld && pOld->GetView() == this )
149 pOld->ForgetView();
150 pScMod->SetSelectionTransfer( nullptr );
151 TransferableHelper::ClearPrimarySelection(); // may delete pOld
154 pBrushDocument.reset();
155 pDrawBrushSet.reset();
157 pPageBreakData.reset();
159 delete pDrawActual;
160 pDrawActual = nullptr;
161 delete pDrawOld;
162 pDrawOld = nullptr;
164 if (comphelper::LibreOfficeKit::isActive())
166 ScTabViewShell* pThisViewShell = GetViewData().GetViewShell();
168 auto lRemoveWindows =
169 [pThisViewShell] (ScTabViewShell* pOtherViewShell)
171 ScViewData& rOtherViewData = pOtherViewShell->GetViewData();
172 for (int k = 0; k < 4; ++k)
174 if (rOtherViewData.HasEditView(static_cast<ScSplitPos>(k)))
175 pThisViewShell->RemoveWindowFromForeignEditView(pOtherViewShell, static_cast<ScSplitPos>(k));
179 SfxLokHelper::forEachOtherView(pThisViewShell, lRemoveWindows);
182 aViewData.KillEditView(); // as long as GridWins still exist
184 if (pDrawView)
186 for (i=0; i<4; i++)
187 if (pGridWin[i])
189 pDrawView->DeleteWindowFromPaintView(pGridWin[i]->GetOutDev());
192 pDrawView->HideSdrPage();
193 pDrawView.reset();
196 pSelEngine.reset();
198 if (mpSpellCheckCxt)
199 mpSpellCheckCxt->dispose();
200 mpSpellCheckCxt.reset();
202 mxInputHintOO.reset();
203 for (i=0; i<4; i++)
204 pGridWin[i].disposeAndClear();
206 pHdrSelEng.reset();
208 for (i=0; i<2; i++)
210 pColBar[i].disposeAndClear();
211 pRowBar[i].disposeAndClear();
212 pColOutline[i].disposeAndClear();
213 pRowOutline[i].disposeAndClear();
216 aScrollBarBox.disposeAndClear();
217 aCornerButton.disposeAndClear();
218 aTopButton.disposeAndClear();
219 aHScrollLeft.disposeAndClear();
220 aHScrollRight.disposeAndClear();
221 aVScrollTop.disposeAndClear();
222 aVScrollBottom.disposeAndClear();
224 pHSplitter.disposeAndClear();
225 pVSplitter.disposeAndClear();
226 pTabControl.disposeAndClear();
229 void ScTabView::MakeDrawView( TriState nForceDesignMode )
231 if (pDrawView)
232 return;
234 ScDrawLayer* pLayer = aViewData.GetDocument().GetDrawLayer();
235 OSL_ENSURE(pLayer, "Where is the Draw Layer ??");
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])
242 if ( SC_SPLIT_BOTTOMLEFT != static_cast<ScSplitPos>(i) )
243 pDrawView->AddWindowToPaintView(pGridWin[i]->GetOutDev(), nullptr);
245 pDrawView->RecalcScale();
246 for (i=0; i<4; i++)
247 if (pGridWin[i])
249 pGridWin[i]->SetMapMode(pGridWin[i]->GetDrawMapMode());
251 pGridWin[i]->PaintImmediately(); // because of Invalidate in DrawView ctor (ShowPage),
252 // so that immediately can be drawn
254 SfxRequest aSfxRequest(SID_OBJECT_SELECT, SfxCallMode::SLOT, aViewData.GetViewShell()->GetPool());
255 SetDrawFuncPtr(new FuSelection(*aViewData.GetViewShell(), GetActiveWin(), pDrawView.get(),
256 pLayer,aSfxRequest));
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 );
263 // register at FormShell
264 FmFormShell* pFormSh = aViewData.GetViewShell()->GetFormShell();
265 if (pFormSh)
266 pFormSh->SetView(pDrawView.get());
268 if (aViewData.GetViewShell()->HasAccessibilityObjects())
269 aViewData.GetViewShell()->BroadcastAccessibility(SfxHint(SfxHintId::ScAccMakeDrawLayer));
272 void ScTabView::DoAddWin( ScGridWindow* pWin )
274 if (pDrawView)
276 pDrawView->AddWindowToPaintView(pWin->GetOutDev(), nullptr);
277 pWin->DrawLayerCreated();
279 pWin->SetAutoSpellContext(mpSpellCheckCxt);
282 void ScTabView::TabChanged( bool bSameTabButMoved )
284 if (pDrawView)
286 DrawDeselectAll(); // end also text edit mode
288 SCTAB nTab = aViewData.GetTabNo();
289 pDrawView->HideSdrPage();
290 pDrawView->ShowSdrPage(pDrawView->GetModel()->GetPage(nTab));
292 UpdateLayerLocks();
294 pDrawView->RecalcScale();
295 pDrawView->UpdateWorkArea(); // PageSize is different per page
298 SfxBindings& rBindings = aViewData.GetBindings();
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);
304 if (aViewData.GetViewShell()->HasAccessibilityObjects())
306 SfxHint aAccHint(SfxHintId::ScAccTableChanged);
307 aViewData.GetViewShell()->BroadcastAccessibility(aAccHint);
310 // notification for XActivationBroadcaster
311 SfxViewFrame* pViewFrame = aViewData.GetViewShell()->GetViewFrame();
312 if (pViewFrame)
314 uno::Reference<frame::XController> xController = pViewFrame->GetFrame().GetController();
315 if (xController.is())
317 ScTabViewObj* pImp = comphelper::getFromUnoTunnel<ScTabViewObj>( xController );
318 if (pImp)
319 pImp->SheetChanged( bSameTabButMoved );
323 for (int i = 0; i < 4; i++)
325 if (pGridWin[i])
327 pGridWin[i]->initiatePageBreaks();
328 // Trigger calculating page breaks only once.
329 break;
333 if (!comphelper::LibreOfficeKit::isActive())
334 return;
336 ScDocShell* pDocSh = GetViewData().GetDocShell();
337 ScModelObj* pModelObj = pDocSh ? comphelper::getFromUnoTunnel<ScModelObj>( pDocSh->GetModel()) : nullptr;
339 if (!pModelObj)
340 return;
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();
348 // Invalidate first
349 tools::Rectangle aRectangle(0, 0, 1000000000, 1000000000);
350 pViewShell->libreOfficeKitViewInvalidateTilesCallback(&aRectangle, aViewData.GetTabNo());
352 ScModelObj* pModel = comphelper::getFromUnoTunnel<ScModelObj>(pViewShell->GetCurrentDocument());
353 SfxLokHelper::notifyDocumentSizeChanged(pViewShell, sRect, pModel, false);
356 void ScTabView::UpdateLayerLocks()
358 if (!pDrawView)
359 return;
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();
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)
384 pDrawView->SetLayerLocked( pLayer->GetName(), bProt || bShared );
385 pDrawView->SetLayerVisible( pLayer->GetName(), false);
389 void ScTabView::DrawDeselectAll()
391 if (!pDrawView)
392 return;
394 ScTabViewShell* pViewSh = aViewData.GetViewShell();
395 if ( pDrawActual &&
396 ( pViewSh->IsDrawTextShell() || pDrawActual->GetSlotID() == SID_DRAW_NOTEEDIT ) )
398 // end text edit (as if escape pressed, in FuDraw)
399 aViewData.GetDispatcher().Execute( pDrawActual->GetSlotID(),
400 SfxCallMode::SLOT | SfxCallMode::RECORD );
403 pDrawView->ScEndTextEdit();
404 pDrawView->UnmarkAll();
406 if (!pViewSh->IsDrawSelMode())
407 pViewSh->SetDrawShell( false );
410 bool ScTabView::IsDrawTextEdit() const
412 if (pDrawView)
413 return pDrawView->IsTextEdit();
414 else
415 return false;
418 SvxZoomType ScTabView::GetZoomType() const
420 return aViewData.GetZoomType();
423 void ScTabView::SetZoomType( SvxZoomType eNew, bool bAll )
425 aViewData.SetZoomType( eNew, bAll );
428 void ScTabView::SetZoom( const Fraction& rNewX, const Fraction& rNewY, bool bAll )
430 aViewData.SetZoom( rNewX, rNewY, bAll );
431 if (pDrawView)
432 pDrawView->RecalcScale();
433 ZoomChanged();
436 void ScTabView::RefreshZoom()
438 aViewData.RefreshZoom();
439 if (pDrawView)
440 pDrawView->RecalcScale();
441 ZoomChanged();
444 void ScTabView::SetPagebreakMode( bool bSet )
446 aViewData.SetPagebreakMode(bSet);
447 if (pDrawView)
448 pDrawView->RecalcScale();
449 ZoomChanged();
452 void ScTabView::ResetDrawDragMode()
454 if (pDrawView)
455 pDrawView->SetDragMode( SdrDragMode::Move );
458 void ScTabView::ViewOptionsHasChanged( bool bHScrollChanged, bool bGraphicsChanged )
460 // create DrawView when grid should be displayed
461 if ( !pDrawView && aViewData.GetOptions().GetGridOptions().GetGridVisible() )
462 MakeDrawLayer();
464 if (pDrawView)
465 pDrawView->UpdateUserViewOptions();
467 if (bGraphicsChanged)
468 DrawEnableAnim(true); // DrawEnableAnim checks the options state
470 // if TabBar is set to visible, make sure its size is not 0
471 bool bGrow = ( aViewData.IsTabMode() && pTabControl->GetSizePixel().Width() <= 0 );
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 );
477 if ( bGrow || bShrink )
479 Size aSize = pTabControl->GetSizePixel();
480 aSize.setWidth( SC_TABBAR_DEFWIDTH ); // initial size
481 pTabControl->SetSizePixel(aSize); // DoResize is called later...
485 // helper function against including the drawing layer
487 void ScTabView::DrawMarkListHasChanged()
489 if ( pDrawView )
490 pDrawView->MarkListHasChanged();
493 void ScTabView::UpdateAnchorHandles()
495 if ( pDrawView )
496 pDrawView->AdjustMarkHdl();
499 void ScTabView::UpdateIMap( SdrObject* pObj )
501 if ( pDrawView )
502 pDrawView->UpdateIMap( pObj );
505 void ScTabView::DrawEnableAnim(bool bSet)
507 sal_uInt16 i;
508 if ( !pDrawView )
509 return;
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 )
515 if ( !pDrawView->IsAnimationEnabled() )
517 pDrawView->SetAnimationEnabled();
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() );
526 else
528 pDrawView->SetAnimationEnabled(false);
532 void ScTabView::UpdateDrawTextOutliner()
534 if ( pDrawView )
536 Outliner* pOL = pDrawView->GetTextEditOutliner();
537 if (pOL)
538 aViewData.UpdateOutlinerFlags( *pOL );
542 void ScTabView::DigitLanguageChanged()
544 LanguageType eNewLang = SC_MOD()->GetOptDigitLanguage();
545 for (VclPtr<ScGridWindow> & pWin : pGridWin)
546 if ( pWin )
547 pWin->GetOutDev()->SetDigitLanguage( eNewLang );
550 void ScTabView::ScrollToObject( const SdrObject* pDrawObj )
552 if ( pDrawObj )
554 // #i118524# use the BoundRect, this defines the visible area
555 MakeVisible(pDrawObj->GetCurrentBoundRect());
559 void ScTabView::MakeVisible( const tools::Rectangle& rHMMRect )
561 vcl::Window* pWin = GetActiveWin();
562 Size aWinSize = pWin->GetOutputSizePixel();
563 SCTAB nTab = aViewData.GetTabNo();
565 tools::Rectangle aRect = pWin->LogicToPixel( rHMMRect );
567 tools::Long nScrollX=0, nScrollY=0; // pixel
569 if ( aRect.Right() >= aWinSize.Width() ) // right out
571 nScrollX = aRect.Right() - aWinSize.Width() + 1; // right border visible
572 if ( aRect.Left() < nScrollX )
573 nScrollX = aRect.Left(); // left visible (if too big)
575 if ( aRect.Bottom() >= aWinSize.Height() ) // bottom out
577 nScrollY = aRect.Bottom() - aWinSize.Height() + 1; // bottom border visible
578 if ( aRect.Top() < nScrollY )
579 nScrollY = aRect.Top(); // top visible (if too big)
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
587 if (!(nScrollX || nScrollY))
588 return;
590 ScDocument& rDoc = aViewData.GetDocument();
591 if ( rDoc.IsNegativePage( nTab ) )
592 nScrollX = -nScrollX;
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));
600 tools::Long nLinesX=0, nLinesY=0; // columns/rows - scroll at least nScrollX/Y
602 if (nScrollX > 0)
603 while (nScrollX > 0 && nPosX < rDoc.MaxCol())
605 nScrollX -= static_cast<tools::Long>( rDoc.GetColWidth(nPosX, nTab) * nPPTX );
606 ++nPosX;
607 ++nLinesX;
609 else if (nScrollX < 0)
610 while (nScrollX < 0 && nPosX > 0)
612 --nPosX;
613 nScrollX += static_cast<tools::Long>( rDoc.GetColWidth(nPosX, nTab) * nPPTX );
614 --nLinesX;
617 if (nScrollY > 0)
618 while (nScrollY > 0 && nPosY < rDoc.MaxRow())
620 nScrollY -= static_cast<tools::Long>( rDoc.GetRowHeight(nPosY, nTab) * nPPTY );
621 ++nPosY;
622 ++nLinesY;
624 else if (nScrollY < 0)
625 while (nScrollY < 0 && nPosY > 0)
627 --nPosY;
628 nScrollY += static_cast<tools::Long>( rDoc.GetRowHeight(nPosY, nTab) * nPPTY );
629 --nLinesY;
632 ScrollLines( nLinesX, nLinesY ); // execute
635 void ScTabView::SetBrushDocument( ScDocumentUniquePtr pNew, bool bLock )
637 pDrawBrushSet.reset();
638 pBrushDocument = std::move(pNew);
640 bLockPaintBrush = bLock;
642 aViewData.GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
645 void ScTabView::SetDrawBrushSet( std::unique_ptr<SfxItemSet> pNew, bool bLock )
647 pBrushDocument.reset();
648 pDrawBrushSet = std::move(pNew);
650 bLockPaintBrush = bLock;
652 aViewData.GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
655 void ScTabView::ResetBrushDocument()
657 if ( HasPaintBrush() )
659 SetBrushDocument( nullptr, false );
660 SetActivePointer( aViewData.IsThemedCursor() ? PointerStyle::FatCross : PointerStyle::Arrow ); // switch pointers also when ended with escape key
664 void ScTabView::OnLOKNoteStateChanged(const ScPostIt* pNote)
666 if (!comphelper::LibreOfficeKit::isActive())
667 return;
669 const SdrCaptionObj* pCaption = pNote->GetCaption();
670 if (!pCaption) return;
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 );
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 );
689 SfxViewShell* pCurrentViewShell = SfxViewShell::Current();
690 SfxViewShell* pViewShell = SfxViewShell::GetFirst();
691 while (pViewShell)
693 ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
694 if (pTabViewShell && pViewShell->GetDocId() == pCurrentViewShell->GetDocId())
696 for (auto& pWin: pTabViewShell->pGridWin)
698 if (pWin && pWin->IsVisible())
700 pWin->Invalidate(aInvalidRect);
704 pViewShell = SfxViewShell::GetNext(*pViewShell);
708 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */