diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2023-02-05 17:47:34 +0100 |
---|---|---|
committer | Marco Cecchetti <marco.cecchetti@collabora.com> | 2023-03-07 19:30:11 +0000 |
commit | 7adfecb0f5947ae258226c8d1652546f81577026 (patch) | |
tree | 722ef84394ffe68f635945d4fc3ebc48e5b0e122 /sd | |
parent | c596fd59dc75823002bdfd3676d600a56e3bfb5e (diff) |
lok: form controls: rendering and mouse event forwarding
What we got
- Most controls rendered on Writer and Impress (on Calc already
implemented by Tomaž Vajngerl)
- Text labels rendered correctly
- Mouse events forwarded to controls
- Control state changed on click for Writer and Calc
- Control invalidation for all apps
- Fixed broken LOK_CALLBACK_MOUSE_POINTER msg
- Correct pointer style when mouse is hovering over a control
Need to be improved
- in impress click method for a control is not executed even if the
mouse event is forwarded correctly
- avoid not needed control invalidations (as the one occurring on
document autosaving)
Change-Id: I4d5012af7f90a2c726b6b6b5b068e2be1ed5568a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146569
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147320
Tested-by: Jenkins
Reviewed-by: Marco Cecchetti <marco.cecchetti@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/inc/Window.hxx | 4 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unomodel.cxx | 28 | ||||
-rw-r--r-- | sd/source/ui/view/sdwindow.cxx | 2 |
3 files changed, 29 insertions, 5 deletions
diff --git a/sd/source/ui/inc/Window.hxx b/sd/source/ui/inc/Window.hxx index 0464ad32e19e..9763f24e8895 100644 --- a/sd/source/ui/inc/Window.hxx +++ b/sd/source/ui/inc/Window.hxx @@ -21,7 +21,7 @@ #include <tools/gen.hxx> #include <tools/long.hxx> -#include <vcl/window.hxx> +#include <vcl/DocWindow.hxx> #include <vcl/transfer.hxx> class OutlinerView; @@ -41,7 +41,7 @@ class ViewShell; member of the <type>OutputDevice</type> base class. It is calculated to be an integer percent value. */ -class Window : public vcl::Window, public ::DropTargetHelper +class Window : public vcl::DocWindow, public ::DropTargetHelper { public: Window(vcl::Window* pParent); diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 230633d66ad1..a955e02e3da6 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -124,6 +124,7 @@ #include <drawinglayer/primitive2d/structuretagprimitive2d.hxx> #include <sfx2/lokcomponenthelpers.hxx> +#include <sfx2/LokControlHandler.hxx> #include <tools/gen.hxx> #include <tools/debug.hxx> #include <comphelper/diagnose_ex.hxx> @@ -2192,6 +2193,9 @@ void SdXImpressDocument::paintTile( VirtualDevice& rDevice, if (!pViewSh) return; + // we need to skip tile invalidation for controls on rendering + comphelper::LibreOfficeKit::setTiledPainting(true); + // Setup drawing layer to work properly. Since we use a custom VirtualDevice // for the drawing, SdrPaintView::BeginCompleteRedraw() will call FindPaintWindow() // unsuccessfully and use a temporary window that doesn't keep state. So patch @@ -2260,6 +2264,17 @@ void SdXImpressDocument::paintTile( VirtualDevice& rDevice, if(patchedPageWindow != nullptr) patchedPageWindow->unpatchPaintWindow(previousPaintWindow); + + // Draw Form controls + SdrView* pDrawView = pViewSh->GetDrawView(); + SdrPageView* pPageView = pDrawView->GetSdrPageView(); + SdrPage* pPage = pPageView->GetPage(); + ::sd::Window* pActiveWin = pViewSh->GetActiveWindow(); + ::tools::Rectangle aTileRect(Point(nTilePosX, nTilePosY), Size(nTileWidth, nTileHeight)); + Size aOutputSize(nOutputWidth, nOutputHeight); + LokControlHandler::paintControlTile(pPage, pDrawView, *pActiveWin, rDevice, aOutputSize, aTileRect); + + comphelper::LibreOfficeKit::setTiledPainting(false); } void SdXImpressDocument::selectPart(int nPart, int nSelect) @@ -2561,8 +2576,17 @@ void SdXImpressDocument::postMouseEvent(int nType, int nX, int nY, int nCount, i pViewShell->GetViewShell(), nType, nX, nY, nCount, nButtons, nModifier, fScale, fScale)) return; - const Point aPos(Point(convertTwipToMm100(nX), convertTwipToMm100(nY))); - LokMouseEventData aMouseEventData(nType, aPos, nCount, MouseEventModifiers::SIMPLECLICK, + // try to forward mouse event to control + const Point aPointTwip(nX, nY); + const Point aPointHMM = o3tl::convert(aPointTwip, o3tl::Length::twip, o3tl::Length::mm100); + SdrView* pDrawView = pViewShell->GetDrawView(); + SdrPageView* pPageView = pDrawView->GetSdrPageView(); + SdrPage* pPage = pPageView->GetPage(); + ::sd::Window* pActiveWin = pViewShell->GetActiveWindow(); + if (LokControlHandler::postMouseEvent(pPage, pDrawView, *pActiveWin, nType, aPointHMM, nCount, nButtons, nModifier)) + return; + + LokMouseEventData aMouseEventData(nType, aPointHMM, nCount, MouseEventModifiers::SIMPLECLICK, nButtons, nModifier); SfxLokHelper::postMouseEventAsync(pViewShell->GetActiveWindow(), aMouseEventData); } diff --git a/sd/source/ui/view/sdwindow.cxx b/sd/source/ui/view/sdwindow.cxx index 1ccd7461d7bc..6d5481318e8e 100644 --- a/sd/source/ui/view/sdwindow.cxx +++ b/sd/source/ui/view/sdwindow.cxx @@ -60,7 +60,7 @@ namespace sd { #define MAX_ZOOM 3000 ///< maximal zoom factor Window::Window(vcl::Window* pParent) - : vcl::Window(pParent, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)), + : vcl::DocWindow(pParent, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)), DropTargetHelper( this ), maWinPos(0, 0), // precautionary; but the values should be set maViewOrigin(0, 0), // again from the owner of the window |