sw/inc/SidebarWin.hxx | 2 sw/inc/drawdoc.hxx | 2 sw/source/core/draw/drawdoc.cxx | 6 + sw/source/uibase/docvw/SidebarTxtControl.cxx | 26 +++++++ sw/source/uibase/docvw/SidebarTxtControl.hxx | 2 sw/source/uibase/docvw/SidebarWin.cxx | 90 ++++++++++++++++++++------- sw/source/uibase/docvw/edtwin.cxx | 10 +++ 7 files changed, 117 insertions(+), 21 deletions(-)
New commits: commit d78432e9a077725046419902c542ce4e5f515705 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Sat Nov 14 13:39:02 2015 +0100 sw lok comments: fix cursor position of a newly created sidebar window With this, pressing ctrl-alt-c to create a new comment has the correct cursor position. Change-Id: Icb8d708dab015d8ffa9bcfe28de66238a75b50bc diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx index 7449887..22bb863 100644 --- a/sw/source/uibase/docvw/SidebarWin.cxx +++ b/sw/source/uibase/docvw/SidebarWin.cxx @@ -665,7 +665,24 @@ void SwSidebarWin::SetPosAndSize() { bChange = true; SetSizePixel(mPosSize.GetSize()); + + if (comphelper::LibreOfficeKit::isActive()) + { + // Position is not yet set at VCL level, but the map mode should + // contain the right origin to emit the correct cursor position. + mpSidebarTextControl->Push(PushFlags::MAPMODE); + Point aOffset(mPosSize.Left(), mPosSize.Top()); + aOffset = PixelToLogic(aOffset); + MapMode aMapMode(mpSidebarTextControl->GetMapMode()); + aMapMode.SetOrigin(aOffset); + mpSidebarTextControl->SetMapMode(aMapMode); + mpSidebarTextControl->EnableMapMode(false); + } + DoResize(); + + if (comphelper::LibreOfficeKit::isActive()) + mpSidebarTextControl->Pop(); } if (GetPosPixel().X() != mPosSize.TopLeft().X() || (std::abs(GetPosPixel().Y() - mPosSize.TopLeft().Y()) > 5) ) commit dacc616f7020d045a1cfdb3806436e06046dae10 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Sat Nov 14 11:06:08 2015 +0100 sw lok comments: fix callback of newly created outliner views SwPostItMgr::registerLibreOfficeKitCallback() already took care of informing existing outliners, this commit gives a callback to newly registered ones as well. Change-Id: I660dcb54231a9d404bf80b4284003d119dae6a5c diff --git a/sw/inc/drawdoc.hxx b/sw/inc/drawdoc.hxx index 339fbc7..97efdb5 100644 --- a/sw/inc/drawdoc.hxx +++ b/sw/inc/drawdoc.hxx @@ -41,6 +41,8 @@ public: virtual SdrPage* AllocPage(bool bMasterPage) override; virtual css::uno::Reference<css::embed::XStorage> GetDocumentStorage() const override; + /// Get the callback and callback data, previously given to registerLibreOfficeKitCallback(). + void getLibreOfficeKitCallback(LibreOfficeKitCallback& rCallback, void*& rLibreOfficeKitData); protected: /// override of <SdrModel::createUnoModel()> is needed to provide corresponding uno model. diff --git a/sw/source/core/draw/drawdoc.cxx b/sw/source/core/draw/drawdoc.cxx index 786d86f..4e295d7 100644 --- a/sw/source/core/draw/drawdoc.cxx +++ b/sw/source/core/draw/drawdoc.cxx @@ -129,6 +129,12 @@ uno::Reference<embed::XStorage> SwDrawModel::GetDocumentStorage() const return m_pDoc->GetDocStorage(); } +void SwDrawModel::getLibreOfficeKitCallback(LibreOfficeKitCallback& rCallback, void*& rLibreOfficeKitData) +{ + rCallback = mpLibreOfficeKitCallback; + rLibreOfficeKitData = mpLibreOfficeKitData; +} + uno::Reference< uno::XInterface > SwDrawModel::createUnoModel() { uno::Reference< uno::XInterface > xModel; diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx index d1901f6..7449887 100644 --- a/sw/source/uibase/docvw/SidebarWin.cxx +++ b/sw/source/uibase/docvw/SidebarWin.cxx @@ -81,6 +81,8 @@ #include <drawinglayer/primitive2d/shadowprimitive2d.hxx> #include <memory> #include <comphelper/lok.hxx> +#include <IDocumentDrawModelAccess.hxx> +#include <drawdoc.hxx> namespace { @@ -531,6 +533,17 @@ void SwSidebarWin::InitControls() mpOutlinerView->SetAttribs(DefaultItem()); + if (comphelper::LibreOfficeKit::isActive()) + { + // If there is a callback already registered, inform the new outliner view about it. + SwDrawModel* pDrawModel = mrView.GetWrtShellPtr()->getIDocumentDrawModelAccess().GetDrawModel(); + LibreOfficeKitCallback pCallback = 0; + void* pData = 0; + pDrawModel->getLibreOfficeKitCallback(pCallback, pData); + mpOutlinerView->setTiledRendering(mrView.GetWrtShellPtr()->isTiledRendering()); + mpOutlinerView->registerLibreOfficeKitCallback(pCallback, pData); + } + //create Scrollbars mpVScrollbar = VclPtr<ScrollBar>::Create(this, WB_3DLOOK |WB_VSCROLL|WB_DRAG); mpVScrollbar->EnableNativeWidget(false); commit e320d070bb0d4dd0ceb696f2c7cc5afb7c4273c3 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Sat Nov 14 10:37:45 2015 +0100 sw lok comments: implement setTextSelection() API So that it's possible to drag the text selection start/end handles in comment text when there is an existing selection. Change-Id: I3acc4770928d4f385f0ca09a2484a9e112409907 diff --git a/sw/inc/SidebarWin.hxx b/sw/inc/SidebarWin.hxx index cb49140..bda077b 100644 --- a/sw/inc/SidebarWin.hxx +++ b/sw/inc/SidebarWin.hxx @@ -182,6 +182,8 @@ class SwSidebarWin : public vcl::Window void PaintTile(vcl::RenderContext& rRenderContext, const Rectangle& rRect); /// Is there a matching sub-widget inside this sidebar widget for rPointLogic? bool IsHitWindow(const Point& rPointLogic); + /// Allows adjusting the point or mark of the selection to a document coordinate. + void SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark); protected: virtual void DataChanged( const DataChangedEvent& aEvent) override; diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx index 1877e70..d1901f6 100644 --- a/sw/source/uibase/docvw/SidebarWin.cxx +++ b/sw/source/uibase/docvw/SidebarWin.cxx @@ -82,6 +82,32 @@ #include <memory> #include <comphelper/lok.hxx> +namespace +{ + +/// Translate absolute <-> relative twips: LOK wants absolute coordinates as output and gives absolute coordinates as input. +void lcl_translateTwips(vcl::Window& rParent, vcl::Window& rChild, MouseEvent* pMouseEvent) +{ + // Set map mode, so that callback payloads will contain absolute coordinates instead of relative ones. + Point aOffset(rChild.GetOutOffXPixel() - rParent.GetOutOffXPixel(), rChild.GetOutOffYPixel() - rParent.GetOutOffYPixel()); + aOffset = rChild.PixelToLogic(aOffset); + MapMode aMapMode(rChild.GetMapMode()); + aMapMode.SetOrigin(aOffset); + rChild.SetMapMode(aMapMode); + rChild.EnableMapMode(false); + + if (pMouseEvent) + { + // Set event coordinates, so they contain relative coordinates instead of absolute ones. + Point aPos = pMouseEvent->GetPosPixel(); + aPos.Move(-aOffset.getX(), -aOffset.getY()); + MouseEvent aMouseEvent(aPos, pMouseEvent->GetClicks(), pMouseEvent->GetMode(), pMouseEvent->GetButtons(), pMouseEvent->GetModifier()); + *pMouseEvent = aMouseEvent; + } +} + +} + namespace sw { namespace sidebarwindows { #define METABUTTON_WIDTH 16 @@ -289,6 +315,19 @@ bool SwSidebarWin::IsHitWindow(const Point& rPointLogic) return aRectangleLogic.IsInside(rPointLogic); } +void SwSidebarWin::SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark) +{ + mpSidebarTextControl->Push(PushFlags::MAPMODE); + MouseEvent aMouseEvent(rPosition); + lcl_translateTwips(EditWin(), *mpSidebarTextControl, &aMouseEvent); + Point aPosition(aMouseEvent.GetPosPixel()); + + EditView& rEditView = GetOutlinerView()->GetEditView(); + rEditView.SetCursorLogicPosition(aPosition, bPoint, bClearMark); + + mpSidebarTextControl->Pop(); +} + void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, DrawFlags nInFlags) { if (mpMetadataAuthor->IsVisible() ) @@ -357,27 +396,6 @@ void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, D } } -/// Translate absolute <-> relative twips: LOK wants absolute coordinates as output and gives absolute coordinates as input. -static void lcl_translateTwips(vcl::Window& rParent, vcl::Window& rChild, MouseEvent* pMouseEvent) -{ - // Set map mode, so that callback payloads will contain absolute coordinates instead of relative ones. - Point aOffset(rChild.GetOutOffXPixel() - rParent.GetOutOffXPixel(), rChild.GetOutOffYPixel() - rParent.GetOutOffYPixel()); - aOffset = rChild.PixelToLogic(aOffset); - MapMode aMapMode(rChild.GetMapMode()); - aMapMode.SetOrigin(aOffset); - rChild.SetMapMode(aMapMode); - rChild.EnableMapMode(false); - - if (pMouseEvent) - { - // Set event coordinates, so they contain relative coordinates instead of absolute ones. - Point aPos = pMouseEvent->GetPosPixel(); - aPos.Move(-aOffset.getX(), -aOffset.getY()); - MouseEvent aMouseEvent(aPos, pMouseEvent->GetClicks(), pMouseEvent->GetMode(), pMouseEvent->GetButtons(), pMouseEvent->GetModifier()); - *pMouseEvent = aMouseEvent; - } -} - void SwSidebarWin::KeyInput(const KeyEvent& rKeyEvent) { if (mpSidebarTextControl) diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index 676a556..98aac51 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -6331,6 +6331,16 @@ void SwEditWin::SetCursorTwipPosition(const Point& rPosition, bool bPoint, bool } } + if (m_rView.GetPostItMgr()) + { + if (sw::sidebarwindows::SwSidebarWin* pWin = m_rView.GetPostItMgr()->GetActiveSidebarWin()) + { + // Editing postit text. + pWin->SetCursorLogicPosition(rPosition, bPoint, bClearMark); + return; + } + } + // Not an SwWrtShell, as that would make SwCrsrShell::GetCrsr() inaccessible. SwEditShell& rShell = m_rView.GetWrtShell(); commit 4cbbaf571d3982eccd7f7267df3185b3d321d0da Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Sat Nov 14 10:04:38 2015 +0100 sw lok comments: emit invalidation events in SidebarTextControl With this, newly typed characters show up instantly in comments, not only after changing the zoom level. Change-Id: I1470db1ec03cc415917375f1f95434cf0944e559 diff --git a/sw/source/uibase/docvw/SidebarTxtControl.cxx b/sw/source/uibase/docvw/SidebarTxtControl.cxx index 4b1c274..31ac8d0 100644 --- a/sw/source/uibase/docvw/SidebarTxtControl.cxx +++ b/sw/source/uibase/docvw/SidebarTxtControl.cxx @@ -25,6 +25,7 @@ #include <SidebarWin.hxx> #include <PostItMgr.hxx> +#include <edtwin.hxx> #include <cmdid.h> #include <docvw.hrc> @@ -48,6 +49,7 @@ #include <editeng/editeng.hxx> #include <editeng/editview.hxx> #include <editeng/flditem.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <uitool.hxx> #include <view.hxx> @@ -187,6 +189,30 @@ void SidebarTextControl::Paint(vcl::RenderContext& rRenderContext, const Rectang } } +void SidebarTextControl::LogicInvalidate(const Rectangle* pRectangle) +{ + OString sRectangle; + if (!pRectangle) + sRectangle = "EMPTY"; + else + { + // Convert from relative twips to absolute ones. + Rectangle aRectangle(*pRectangle); + vcl::Window& rParent = mrSidebarWin.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()); + + sRectangle = aRectangle.toString(); + } + + SwWrtShell& rWrtShell = mrDocView.GetWrtShell(); + rWrtShell.libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr()); +} + void SidebarTextControl::KeyInput( const KeyEvent& rKeyEvt ) { if (getenv("SW_DEBUG") && rKeyEvt.GetKeyCode().GetCode() == KEY_F12) diff --git a/sw/source/uibase/docvw/SidebarTxtControl.hxx b/sw/source/uibase/docvw/SidebarTxtControl.hxx index 6741019..ca7271a 100644 --- a/sw/source/uibase/docvw/SidebarTxtControl.hxx +++ b/sw/source/uibase/docvw/SidebarTxtControl.hxx @@ -40,6 +40,8 @@ class SidebarTextControl : public Control protected: virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect) override; + /// @see OutputDevice::LogicInvalidate(). + void LogicInvalidate(const Rectangle* pRectangle) override; virtual void MouseMove( const MouseEvent& rMEvt ) override; virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; virtual void Command( const CommandEvent& rCEvt ) override; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits