diff options
Diffstat (limited to 'sw')
-rw-r--r-- | sw/Library_sw.mk | 1 | ||||
-rw-r--r-- | sw/source/uibase/docvw/SidebarScrollBar.cxx | 72 | ||||
-rw-r--r-- | sw/source/uibase/docvw/SidebarScrollBar.hxx | 43 | ||||
-rw-r--r-- | sw/source/uibase/docvw/SidebarWin.cxx | 3 |
4 files changed, 118 insertions, 1 deletions
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk index c5004cc2bf9f..b4af6e57c547 100644 --- a/sw/Library_sw.mk +++ b/sw/Library_sw.mk @@ -600,6 +600,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\ sw/source/uibase/docvw/OverlayRanges \ sw/source/uibase/docvw/PostItMgr \ sw/source/uibase/docvw/ShadowOverlayObject \ + sw/source/uibase/docvw/SidebarScrollBar \ sw/source/uibase/docvw/SidebarTxtControl \ sw/source/uibase/docvw/SidebarTxtControlAcc \ sw/source/uibase/docvw/SidebarWin \ diff --git a/sw/source/uibase/docvw/SidebarScrollBar.cxx b/sw/source/uibase/docvw/SidebarScrollBar.cxx new file mode 100644 index 000000000000..909aa763dba1 --- /dev/null +++ b/sw/source/uibase/docvw/SidebarScrollBar.cxx @@ -0,0 +1,72 @@ +/* -*- 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> + +#define LOK_USE_UNSTABLE_API +#include <LibreOfficeKit/LibreOfficeKitEnums.h> + +#include <SidebarWin.hxx> +#include <view.hxx> +#include <wrtsh.hxx> +#include <edtwin.hxx> + +namespace sw +{ +namespace sidebarwindows +{ + +SidebarScrollBar::SidebarScrollBar(SwSidebarWin& rSidebarWin, WinBits nStyle, SwView& rView) + : ScrollBar(&rSidebarWin, nStyle), + m_rSidebarWin(rSidebarWin), + m_rView(rView) +{ +} + +void SidebarScrollBar::LogicInvalidate(const Rectangle* pRectangle) +{ + Rectangle aRectangle; + + if (!pRectangle) + { + Push(PushFlags::MAPMODE); + EnableMapMode(); + MapMode aMapMode = GetMapMode(); + aMapMode.SetMapUnit(MAP_TWIP); + SetMapMode(aMapMode); + aRectangle = 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(); + rWrtShell.libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr()); +} + + +SidebarScrollBar::~SidebarScrollBar() +{ + disposeOnce(); +} + +} +} // end of namespace sw::sidebarwindows + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/docvw/SidebarScrollBar.hxx b/sw/source/uibase/docvw/SidebarScrollBar.hxx new file mode 100644 index 000000000000..9543205387df --- /dev/null +++ b/sw/source/uibase/docvw/SidebarScrollBar.hxx @@ -0,0 +1,43 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_SW_SOURCE_UIBASE_DOCVW_SIDEBARSCROLLBAR_HXX +#define INCLUDED_SW_SOURCE_UIBASE_DOCVW_SIDEBARSCROLLBAR_HXX + +#include <vcl/scrbar.hxx> + +class SwView; + +namespace sw +{ +namespace sidebarwindows +{ + +class SwSidebarWin; + +/// Similar to the VCL scrollbar, but instrumented with Writer-specific details for LOK. +class SidebarScrollBar : public ScrollBar +{ + SwSidebarWin& m_rSidebarWin; + SwView& m_rView; + +protected: + /// @see OutputDevice::LogicInvalidate(). + void LogicInvalidate(const Rectangle* pRectangle) override; +public: + SidebarScrollBar(SwSidebarWin& rSidebarWin, WinBits nStyle, SwView& rView); + virtual ~SidebarScrollBar(); +}; + +} +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx index 01cb771db50c..a9a97c244b0f 100644 --- a/sw/source/uibase/docvw/SidebarWin.cxx +++ b/sw/source/uibase/docvw/SidebarWin.cxx @@ -26,6 +26,7 @@ #include <PostItMgr.hxx> #include <SidebarTxtControl.hxx> +#include <SidebarScrollBar.hxx> #include <AnchorOverlayObject.hxx> #include <ShadowOverlayObject.hxx> #include <OverlayRanges.hxx> @@ -622,7 +623,7 @@ void SwSidebarWin::InitControls() } //create Scrollbars - mpVScrollbar = VclPtr<ScrollBar>::Create(this, WB_3DLOOK |WB_VSCROLL|WB_DRAG); + mpVScrollbar = VclPtr<SidebarScrollBar>::Create(*this, WB_3DLOOK |WB_VSCROLL|WB_DRAG, mrView); mpVScrollbar->EnableNativeWidget(false); mpVScrollbar->EnableRTL( false ); mpVScrollbar->SetScrollHdl(LINK(this, SwSidebarWin, ScrollHdl)); |