diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2017-12-01 13:54:45 +0530 |
---|---|---|
committer | Pranav Kant <pranavk@collabora.co.uk> | 2017-12-04 17:14:02 +0530 |
commit | b5e27fd809845577a90cc1811de062c070110078 (patch) | |
tree | 679cb1c3712b6b0a5b693dfa9990e6de8592cc62 /vcl | |
parent | 3d8154ec427777eadf5719f194662e5ade78fae5 (diff) |
lokdialog: Simplify; make the LOK dialog API more generic
Merge the dialog floating window callbacks and function calls into one.
Unique window ids across vcl::Window is enough to distinguish between
them.
Floating windows don't have a LOK notifier as they are created in the
vcl itself (so we can't access them from sfx2). Use the parent LOK
notifier in that case (which would be a dialog).
This API should also help in autopopup filter tunneling later.
Change-Id: I63a2c97ffdd84695dc967e14c793089a7c50b41b
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/control/ctrl.cxx | 22 | ||||
-rw-r--r-- | vcl/source/window/dialog.cxx | 12 | ||||
-rw-r--r-- | vcl/source/window/floatwin.cxx | 39 | ||||
-rw-r--r-- | vcl/source/window/window.cxx | 47 |
4 files changed, 40 insertions, 80 deletions
diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx index b62c90563d46..37dc3dcdad8a 100644 --- a/vcl/source/control/ctrl.cxx +++ b/vcl/source/control/ctrl.cxx @@ -421,25 +421,15 @@ void Control::LogicInvalidate(const tools::Rectangle* /*pRectangle*/) // ignore all of those if (comphelper::LibreOfficeKit::isActive() && !comphelper::LibreOfficeKit::isDialogPainting()) { - // If parent is a floating window, trigger an invalidate there - vcl::Window* pWindow = this; - while (pWindow) + if (vcl::Window* pParent = GetParentWithLOKNotifier()) { - if (pWindow->ImplIsFloatingWindow()) - { - static_cast<FloatingWindow*>(pWindow)->LogicInvalidate(nullptr); - return; - } + // invalidate the complete floating window for now + if (pParent->ImplIsFloatingWindow()) + return pParent->LogicInvalidate(nullptr); - pWindow = pWindow->GetParent(); + const tools::Rectangle aRect(Point(GetOutOffXPixel(), GetOutOffYPixel()), Size(GetOutputWidthPixel(), GetOutputHeightPixel())); + pParent->LogicInvalidate(&aRect); } - - // otherwise, for now, just invalidate the whole dialog - Dialog* pParentDlg = GetParentDialog(); - - const tools::Rectangle aRect(Point(GetOutOffXPixel(), GetOutOffYPixel()), Size(GetOutputWidthPixel(), GetOutputHeightPixel())); - if (pParentDlg) - pParentDlg->LogicInvalidate(&aRect); } } diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 5ef3c0fb0238..e7d9b3188520 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -882,18 +882,6 @@ bool Dialog::selectPageByUIXMLDescription(const OString& /*rUIXMLDescription*/) return true; } -void Dialog::InvalidateFloatingWindow(const Point& rPos) -{ - if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) - pNotifier->notifyWindowChild(GetLOKWindowId(), "invalidate", rPos); -} - -void Dialog::CloseFloatingWindow() -{ - if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) - pNotifier->notifyWindowChild(GetLOKWindowId(), "close", Point(0, 0)); -} - void Dialog::ensureRepaint() { // ensure repaint diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx index f5d9927a2482..57021be2f8cd 100644 --- a/vcl/source/window/floatwin.cxx +++ b/vcl/source/window/floatwin.cxx @@ -587,10 +587,10 @@ bool FloatingWindow::EventNotify( NotifyEvent& rNEvt ) void FloatingWindow::LogicInvalidate(const tools::Rectangle* /*pRectangle*/) { - Dialog* pParentDlg = GetParentDialog(); - if (pParentDlg) + if (vcl::Window* pParent = GetParentWithLOKNotifier()) { - pParentDlg->InvalidateFloatingWindow(mpImplData->maPos); + const vcl::ILibreOfficeKitNotifier* pNotifier = pParent->GetLOKNotifier(); + pNotifier->notifyWindow(GetLOKWindowId(), "invalidate"); } } @@ -602,14 +602,26 @@ void FloatingWindow::StateChanged( StateChangedType nType ) } SystemWindow::StateChanged( nType ); - Dialog* pParentDlg = GetParentDialog(); - if (pParentDlg && nType == StateChangedType::InitShow && IsVisible()) - { - pParentDlg->InvalidateFloatingWindow(mpImplData->maPos); - } - else if (pParentDlg && !IsVisible()) + + if (vcl::Window* pParent = GetParentWithLOKNotifier()) { - pParentDlg->CloseFloatingWindow(); + const vcl::ILibreOfficeKitNotifier* pNotifier = pParent->GetLOKNotifier(); + if (nType == StateChangedType::InitShow && IsVisible()) + { + SetLOKNotifier(pNotifier); + + std::vector<vcl::LOKPayloadItem> aItems; + aItems.emplace_back(std::make_pair("type", "child")); + aItems.emplace_back(std::make_pair("parentId", OString::number(pParent->GetLOKWindowId()))); + aItems.emplace_back(std::make_pair("size", GetSizePixel().toString())); + aItems.emplace_back(std::make_pair("position", mpImplData->maPos.toString())); + pNotifier->notifyWindow(GetLOKWindowId(), "created", aItems); + } + else if (!IsVisible()) + { + pNotifier->notifyWindow(GetLOKWindowId(), "close"); + ReleaseLOKNotifier(); + } } if ( nType == StateChangedType::ControlBackground ) @@ -720,13 +732,6 @@ void FloatingWindow::StartPopupMode( const tools::Rectangle& rRect, FloatWinPopu GrabFocus(); } Show( true, ShowFlags::NoActivate ); - - if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) - { - std::vector<vcl::LOKPayloadItem> aItems; - aItems.emplace_back(std::make_pair("size", rRect.GetSize().toString())); - pNotifier->notifyWindow(GetLOKWindowId(), "created", aItems); - } } void FloatingWindow::StartPopupMode( ToolBox* pBox, FloatWinPopupFlags nFlags ) diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 2e6669e46904..dcc91fda85de 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -3203,27 +3203,19 @@ vcl::LOKWindowId Window::GetLOKWindowId() const return mpWindowImpl->mnLOKWindowId; } -Size Window::PaintActiveFloatingWindow(VirtualDevice& rDevice) const +vcl::Window* Window::GetParentWithLOKNotifier() { - Size aRet; - ImplSVData* pSVData = ImplGetSVData(); - FloatingWindow* pFirstFloat = pSVData->maWinData.mpFirstFloat; - if (pFirstFloat) + vcl::Window* pWindow = this; + bool found = false; + while (pWindow && !found) { - // TODO:: run a while loop here and check all the active floating - // windows ( chained together, cf. pFirstFloat->mpNextFloat ) - // For now just assume that the active floating window is the one we - // want to render - if (pFirstFloat->GetParentDialog() == this) - { - pFirstFloat->PaintToDevice(&rDevice, Point(0, 0), Size()); - aRet = pFirstFloat->GetSizePixel(); - } - - pFirstFloat = nullptr; + if (pWindow->GetLOKNotifier()) + found = true; + else + pWindow = pWindow->GetParent(); } - return aRet; + return found ? pWindow : nullptr; } void Window::LogicMouseButtonDown(const MouseEvent& rMouseEvent) @@ -3254,36 +3246,21 @@ void Window::LogicMouseButtonDownChild(const MouseEvent& rMouseEvent) { assert(comphelper::LibreOfficeKit::isActive()); - ImplSVData* pSVData = ImplGetSVData(); - FloatingWindow* pFirstFloat = pSVData->maWinData.mpFirstFloat; - if (pFirstFloat && pFirstFloat->GetParentDialog() == this) - { - ImplWindowFrameProc(pFirstFloat->ImplGetBorderWindow(), SalEvent::ExternalMouseButtonDown, &rMouseEvent); - } + ImplWindowFrameProc(ImplGetBorderWindow(), SalEvent::ExternalMouseButtonDown, &rMouseEvent); } void Window::LogicMouseButtonUpChild(const MouseEvent& rMouseEvent) { assert(comphelper::LibreOfficeKit::isActive()); - ImplSVData* pSVData = ImplGetSVData(); - FloatingWindow* pFirstFloat = pSVData->maWinData.mpFirstFloat; - if (pFirstFloat && pFirstFloat->GetParentDialog() == this) - { - ImplWindowFrameProc(pFirstFloat->ImplGetBorderWindow(), SalEvent::ExternalMouseButtonUp, &rMouseEvent); - } + ImplWindowFrameProc(ImplGetBorderWindow(), SalEvent::ExternalMouseButtonUp, &rMouseEvent); } void Window::LogicMouseMoveChild(const MouseEvent& rMouseEvent) { assert(comphelper::LibreOfficeKit::isActive()); - ImplSVData* pSVData = ImplGetSVData(); - FloatingWindow* pFirstFloat = pSVData->maWinData.mpFirstFloat; - if (pFirstFloat && pFirstFloat->GetParentDialog() == this) - { - ImplWindowFrameProc(pFirstFloat->ImplGetBorderWindow(), SalEvent::ExternalMouseMove, &rMouseEvent); - } + ImplWindowFrameProc(ImplGetBorderWindow(), SalEvent::ExternalMouseMove, &rMouseEvent); } void Window::LOKKeyInput(const KeyEvent& rKeyEvent) |