diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-12-26 14:08:07 +0600 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-01-04 14:12:23 +0100 |
commit | 06ff6370a4ba8084890274418eec355e8468573f (patch) | |
tree | a90e248567bae8d4173b95399557310c1b462f0d /sw/source/uibase/docvw | |
parent | a5a0bb0c6577c82f5e31f1a81e31381fdf6c0c2e (diff) |
Send tooltip text to LOK
Call vcl::Window::RequestHelp from LOKPostAsyncEvent for
mouse movement. Introduce LOK_CALLBACK_TOOLTIP callback
type, and send it from SwEditWin::RequestHelp.
Intention is, that the tooltip is shown by client at the
current mouse pointer position, which is hopefully not
far away from the point that generated the mouse event.
On the next movement, the client starts a timer to hide
the tooltip. If the next tooltip message arrives, the
tooltip would be updated in the new place.
Alternatively, the payload could contain the coordinates
from the HelpEvent.
Change-Id: I8e96eb6e6983ad8d13b4c5d7be4d51ff3fd11893
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161302
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw/source/uibase/docvw')
-rw-r--r-- | sw/source/uibase/docvw/edtwin2.cxx | 60 |
1 files changed, 40 insertions, 20 deletions
diff --git a/sw/source/uibase/docvw/edtwin2.cxx b/sw/source/uibase/docvw/edtwin2.cxx index 0c47b2ec5540..b6dcfdbeb70e 100644 --- a/sw/source/uibase/docvw/edtwin2.cxx +++ b/sw/source/uibase/docvw/edtwin2.cxx @@ -21,6 +21,7 @@ #include <osl/diagnose.h> #include <osl/thread.h> #include <vcl/help.hxx> +#include <tools/json_writer.hxx> #include <tools/urlobj.hxx> #include <fmtrfmrk.hxx> #include <svl/urihelper.hxx> @@ -62,6 +63,7 @@ #include <rootfrm.hxx> #include <unomap.hxx> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> namespace { @@ -309,6 +311,16 @@ OUString SwEditWin::ClipLongToolTip(const OUString& rText) return sDisplayText; } +static OString getTooltipPayload(const OUString& tooltip, const SwRect& rect) +{ + tools::JsonWriter writer; + { + writer.put("text", tooltip); + writer.put("rectangle", rect.SVRect().toString()); + } + return writer.finishAndGetAsOString(); +} + void SwEditWin::RequestHelp(const HelpEvent &rEvt) { SwWrtShell &rSh = m_rView.GetWrtShell(); @@ -615,28 +627,36 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt) } if (!sText.isEmpty()) { - tools::Rectangle aRect( aFieldRect.SVRect() ); - Point aPt( OutputToScreenPixel( LogicToPixel( aRect.TopLeft() ))); - aRect.SetLeft( aPt.X() ); - aRect.SetTop( aPt.Y() ); - aPt = OutputToScreenPixel( LogicToPixel( aRect.BottomRight() )); - aRect.SetRight( aPt.X() ); - aRect.SetBottom( aPt.Y() ); - - // tdf#136336 ensure tooltip area surrounds the current mouse position with at least a pixel margin - aRect.Union(tools::Rectangle(rEvt.GetMousePosPixel(), Size(1, 1))); - aRect.AdjustLeft(-1); - aRect.AdjustRight(1); - aRect.AdjustTop(-1); - aRect.AdjustBottom(1); - - if( bBalloon ) - Help::ShowBalloon( this, rEvt.GetMousePosPixel(), aRect, sText ); + if (comphelper::LibreOfficeKit::isActive()) + { + m_rView.libreOfficeKitViewCallback( + LOK_CALLBACK_TOOLTIP, getTooltipPayload(sText, aFieldRect)); + } else { - // the show the help - OUString sDisplayText(ClipLongToolTip(sText)); - Help::ShowQuickHelp(this, aRect, sDisplayText, nStyle); + tools::Rectangle aRect(aFieldRect.SVRect()); + Point aPt(OutputToScreenPixel(LogicToPixel(aRect.TopLeft()))); + aRect.SetLeft(aPt.X()); + aRect.SetTop(aPt.Y()); + aPt = OutputToScreenPixel(LogicToPixel(aRect.BottomRight())); + aRect.SetRight(aPt.X()); + aRect.SetBottom(aPt.Y()); + + // tdf#136336 ensure tooltip area surrounds the current mouse position with at least a pixel margin + aRect.Union(tools::Rectangle(rEvt.GetMousePosPixel(), Size(1, 1))); + aRect.AdjustLeft(-1); + aRect.AdjustRight(1); + aRect.AdjustTop(-1); + aRect.AdjustBottom(1); + + if (bBalloon) + Help::ShowBalloon(this, rEvt.GetMousePosPixel(), aRect, sText); + else + { + // the show the help + OUString sDisplayText(ClipLongToolTip(sText)); + Help::ShowQuickHelp(this, aRect, sDisplayText, nStyle); + } } } |