LibreOffice Module sw (master)  1
SidebarScrollBar.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 
10 #include "SidebarScrollBar.hxx"
11 
12 #include <sfx2/lokhelper.hxx>
13 
14 #include <view.hxx>
15 #include <wrtsh.hxx>
16 #include <edtwin.hxx>
17 #include <AnnotationWin.hxx>
18 
19 namespace sw::sidebarwindows
20 {
22  SwView& rView)
23  : ScrollBar(&rSidebarWin, nStyle)
24  , m_rSidebarWin(rSidebarWin)
25  , m_rView(rView)
26 {
27 }
28 
30 {
31  tools::Rectangle aRectangle;
32 
33  if (!pRectangle)
34  {
35  Push(PushFlags::MAPMODE);
36  EnableMapMode();
37  MapMode aMapMode = GetMapMode();
38  aMapMode.SetMapUnit(MapUnit::MapTwip);
39  SetMapMode(aMapMode);
40  aRectangle = tools::Rectangle(Point(0, 0), PixelToLogic(GetSizePixel()));
41  Pop();
42  }
43  else
44  aRectangle = *pRectangle;
45 
46  // Convert from relative twips to absolute ones.
47  vcl::Window& rParent = m_rSidebarWin.EditWin();
48  Point aOffset(GetOutOffXPixel() - rParent.GetOutOffXPixel(),
49  GetOutOffYPixel() - rParent.GetOutOffYPixel());
50  rParent.Push(PushFlags::MAPMODE);
51  rParent.EnableMapMode();
52  aOffset = rParent.PixelToLogic(aOffset);
53  rParent.Pop();
54  aRectangle.Move(aOffset.getX(), aOffset.getY());
55 
56  OString sRectangle = aRectangle.toString();
57  SwWrtShell& rWrtShell = m_rView.GetWrtShell();
58  SfxLokHelper::notifyInvalidation(rWrtShell.GetSfxViewShell(), sRectangle);
59 }
60 
61 void SidebarScrollBar::MouseButtonUp(const MouseEvent& /*rMouseEvent*/) { EndTracking(); }
62 
63 void SidebarScrollBar::MouseMove(const MouseEvent& rMouseEvent)
64 {
65  TrackingEvent aEvent(rMouseEvent);
66  Tracking(aEvent);
67 }
68 
70 
71 } // end of namespace sw::sidebarwindows
72 
73 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
tools::Long GetOutOffXPixel() const
virtual Size GetSizePixel() const
const MapMode & GetMapMode() const
void EnableMapMode(bool bEnable=true)
SfxViewShell * GetSfxViewShell() const
Definition: viewsh.hxx:441
void SetMapMode()
SwWrtShell & GetWrtShell() const
Definition: view.hxx:398
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
sal_Int64 WinBits
static void notifyInvalidation(SfxViewShell const *pThisView, const OString &rPayload)
void EndTracking(TrackingEventFlags nFlags=TrackingEventFlags::NONE)
void MouseButtonUp(const MouseEvent &rMouseEvent) override
void SetMapUnit(MapUnit eUnit)
void MouseMove(const MouseEvent &rMouseEvent) override
tools::Long GetOutOffYPixel() const
Point PixelToLogic(const Point &rDevicePt) const
SidebarScrollBar(sw::annotation::SwAnnotationWin &rSidebarWin, WinBits nStyle, SwView &rView)
void LogicInvalidate(const tools::Rectangle *pRectangle) override
sw::annotation::SwAnnotationWin & m_rSidebarWin
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
rtl::OString toString() const
void Push(PushFlags nFlags=PushFlags::ALL)
virtual void Tracking(const TrackingEvent &rTEvt) override
AnyEventRef aEvent
Definition: view.hxx:144