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
20 {
21 namespace sidebarwindows
22 {
23 
25  : ScrollBar(&rSidebarWin, nStyle),
26  m_rSidebarWin(rSidebarWin),
27  m_rView(rView)
28 {
29 }
30 
32 {
33  tools::Rectangle aRectangle;
34 
35  if (!pRectangle)
36  {
37  Push(PushFlags::MAPMODE);
38  EnableMapMode();
39  MapMode aMapMode = GetMapMode();
40  aMapMode.SetMapUnit(MapUnit::MapTwip);
41  SetMapMode(aMapMode);
42  aRectangle = tools::Rectangle(Point(0, 0), PixelToLogic(GetSizePixel()));
43  Pop();
44  }
45  else
46  aRectangle = *pRectangle;
47 
48  // Convert from relative twips to absolute ones.
49  vcl::Window& rParent = m_rSidebarWin.EditWin();
50  Point aOffset(GetOutOffXPixel() - rParent.GetOutOffXPixel(), GetOutOffYPixel() - rParent.GetOutOffYPixel());
51  rParent.Push(PushFlags::MAPMODE);
52  rParent.EnableMapMode();
53  aOffset = rParent.PixelToLogic(aOffset);
54  rParent.Pop();
55  aRectangle.Move(aOffset.getX(), aOffset.getY());
56 
57  OString sRectangle = aRectangle.toString();
58  SwWrtShell& rWrtShell = m_rView.GetWrtShell();
59  SfxLokHelper::notifyInvalidation(rWrtShell.GetSfxViewShell(), sRectangle);
60 }
61 
62 void SidebarScrollBar::MouseButtonUp(const MouseEvent& /*rMouseEvent*/)
63 {
64  EndTracking();
65 }
66 
67 void SidebarScrollBar::MouseMove(const MouseEvent& rMouseEvent)
68 {
69  TrackingEvent aEvent(rMouseEvent);
70  Tracking(aEvent);
71 }
72 
74 {
75  disposeOnce();
76 }
77 
78 }
79 } // end of namespace sw::sidebarwindows
80 
81 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
long GetOutOffXPixel() const
virtual Size GetSizePixel() const
const MapMode & GetMapMode() const
Dialog to specify the properties of date form field.
Definition: accfrmobj.cxx:40
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:88
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
Definition: view.hxx:146