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 {
21 
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(), GetOutOffYPixel() - rParent.GetOutOffYPixel());
49  rParent.Push(PushFlags::MAPMODE);
50  rParent.EnableMapMode();
51  aOffset = rParent.PixelToLogic(aOffset);
52  rParent.Pop();
53  aRectangle.Move(aOffset.getX(), aOffset.getY());
54 
55  OString sRectangle = aRectangle.toString();
56  SwWrtShell& rWrtShell = m_rView.GetWrtShell();
57  SfxLokHelper::notifyInvalidation(rWrtShell.GetSfxViewShell(), sRectangle);
58 }
59 
60 void SidebarScrollBar::MouseButtonUp(const MouseEvent& /*rMouseEvent*/)
61 {
62  EndTracking();
63 }
64 
65 void SidebarScrollBar::MouseMove(const MouseEvent& rMouseEvent)
66 {
67  TrackingEvent aEvent(rMouseEvent);
68  Tracking(aEvent);
69 }
70 
72 {
73  disposeOnce();
74 }
75 
76 } // end of namespace sw::sidebarwindows
77 
78 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
long GetOutOffXPixel() const
virtual Size GetSizePixel() const
const MapMode & GetMapMode() const
void EnableMapMode(bool bEnable=true)
SfxViewShell * GetSfxViewShell() const
Definition: viewsh.hxx:444
void SetMapMode()
SwWrtShell & GetWrtShell() const
Definition: view.hxx:400
void Move(long nHorzMoveDelta, long nVertMoveDelta)
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
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
long GetOutOffYPixel() const
rtl::OString toString() const
void Push(PushFlags nFlags=PushFlags::ALL)
virtual void Tracking(const TrackingEvent &rTEvt) override
AnyEventRef aEvent
Definition: view.hxx:146