summaryrefslogtreecommitdiffstats
path: root/sw/source/uibase/docvw/SidebarScrollBar.cxx
blob: c7e2978afe4dacae6e8b53020b1337886f2af935 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include "SidebarScrollBar.hxx"

#include <sfx2/lokhelper.hxx>

#include <view.hxx>
#include <wrtsh.hxx>
#include <edtwin.hxx>
#include <AnnotationWin.hxx>

namespace sw::sidebarwindows
{
SidebarScrollBar::SidebarScrollBar(sw::annotation::SwAnnotationWin& rSidebarWin, WinBits nStyle,
                                   SwView& rView)
    : ScrollBar(&rSidebarWin, nStyle)
    , m_rSidebarWin(rSidebarWin)
    , m_rView(rView)
{
}

void SidebarScrollBar::LogicInvalidate(const tools::Rectangle* pRectangle)
{
    tools::Rectangle aRectangle;

    if (!pRectangle)
    {
        Push(PushFlags::MAPMODE);
        EnableMapMode();
        MapMode aMapMode = GetMapMode();
        aMapMode.SetMapUnit(MapUnit::MapTwip);
        SetMapMode(aMapMode);
        aRectangle = tools::Rectangle(Point(0, 0), PixelToLogic(GetSizePixel()));
        Pop();
    }
    else
        aRectangle = *pRectangle;

    // Convert from relative twips to absolute ones.
    vcl::Window& rParent = m_rSidebarWin.EditWin();
    Point aOffset(GetOutOffXPixel() - rParent.GetOutOffXPixel(),
                  GetOutOffYPixel() - rParent.GetOutOffYPixel());
    rParent.Push(PushFlags::MAPMODE);
    rParent.EnableMapMode();
    aOffset = rParent.PixelToLogic(aOffset);
    rParent.Pop();
    aRectangle.Move(aOffset.getX(), aOffset.getY());

    OString sRectangle = aRectangle.toString();
    SwWrtShell& rWrtShell = m_rView.GetWrtShell();
    SfxLokHelper::notifyInvalidation(rWrtShell.GetSfxViewShell(), sRectangle);
}

void SidebarScrollBar::MouseButtonUp(const MouseEvent& /*rMouseEvent*/) { EndTracking(); }

void SidebarScrollBar::MouseMove(const MouseEvent& rMouseEvent)
{
    TrackingEvent aEvent(rMouseEvent);
    Tracking(aEvent);
}

SidebarScrollBar::~SidebarScrollBar() { disposeOnce(); }

} // end of namespace sw::sidebarwindows

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */