summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2017-11-27 19:23:22 +0100
committerJan Holesovsky <kendy@collabora.com>2017-11-27 19:29:29 +0100
commit6dab8b1a2d706af5bc185d6db419e14271e6f758 (patch)
tree6ee7818a2eb7e58fecf3962f5ef5c51d181acc42
parent1c675d161283ab8302394db428a23f5e261ea310 (diff)
lokdialog: Move the LOKWindowId <-> VclPtr<Window> mapping to Window.
This allows registering & de-registering of non-sfx windows too, and makes the Calc autofilter popup to appear. Change-Id: I7cbbe94d208115aabcb6fa5f964646c7b7ce4c93
-rw-r--r--desktop/source/lib/init.cxx22
-rw-r--r--include/sfx2/viewsh.hxx5
-rw-r--r--include/vcl/ITiledRenderable.hxx6
-rw-r--r--include/vcl/window.hxx6
-rw-r--r--sc/inc/docuno.hxx3
-rw-r--r--sc/source/ui/unoobj/docuno.cxx6
-rw-r--r--sd/source/ui/inc/unomodel.hxx3
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx6
-rw-r--r--sfx2/source/dialog/basedlgs.cxx6
-rw-r--r--sfx2/source/dialog/tabdlg.cxx3
-rw-r--r--sfx2/source/view/viewsh.cxx31
-rw-r--r--sw/inc/unotxdoc.hxx3
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx6
-rw-r--r--vcl/inc/window.h1
-rw-r--r--vcl/source/window/window.cxx31
15 files changed, 43 insertions, 95 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 5e535e4be11d..9a231d0b7597 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1321,16 +1321,6 @@ ITiledRenderable* getTiledRenderable(LibreOfficeKitDocument* pThis)
return dynamic_cast<ITiledRenderable*>(pDocument->mxComponent.get());
}
-VclPtr<Window> findWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId)
-{
- ITiledRenderable* pRenderable = getTiledRenderable(pThis);
-
- if (!pRenderable)
- return VclPtr<Window>();
-
- return pRenderable->findWindow(nLOKWindowId);
-}
-
} // anonymous namespace
// Wonder global state ...
@@ -2264,7 +2254,7 @@ static void doc_postDialogKeyEvent(LibreOfficeKitDocument* pThis, unsigned nLOKW
{
SolarMutexGuard aGuard;
- VclPtr<Window> pWindow = findWindow(pThis, nLOKWindowId);
+ VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
if (!pWindow)
{
gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
@@ -2442,7 +2432,7 @@ static void doc_postDialogMouseEvent(LibreOfficeKitDocument* pThis, unsigned nLO
{
SolarMutexGuard aGuard;
- VclPtr<Window> pWindow = findWindow(pThis, nLOKWindowId);
+ VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
if (!pWindow)
{
gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
@@ -2473,7 +2463,7 @@ static void doc_postDialogChildMouseEvent(LibreOfficeKitDocument* pThis, unsigne
{
SolarMutexGuard aGuard;
- VclPtr<Window> pWindow = findWindow(pThis, nLOKWindowId);
+ VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
if (!pWindow)
{
gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
@@ -3284,7 +3274,7 @@ static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, unsigned nLOKWindow
SolarMutexGuard aGuard;
- VclPtr<Window> pWindow = findWindow(pThis, nLOKWindowId);
+ VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
if (!pWindow)
{
gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
@@ -3312,7 +3302,7 @@ static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId
{
SolarMutexGuard aGuard;
- VclPtr<Window> pWindow = findWindow(pThis, nLOKWindowId);
+ VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
if (!pWindow)
{
gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
@@ -3337,7 +3327,7 @@ static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, unsigne
{
SolarMutexGuard aGuard;
- VclPtr<Window> pWindow = findWindow(pThis, nLOKWindowId);
+ VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
if (!pWindow)
{
gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 75a7fb7dbc41..2ec0b0c24515 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -155,7 +155,6 @@ friend class SfxPrinterController;
VclPtr<vcl::Window> pWindow;
bool bNoNewWindow;
bool mbPrinterSettingsModified;
- std::vector<std::pair<vcl::LOKWindowId, VclPtr<Dialog> > > maOpenedDialogs;
protected:
virtual void Activate(bool IsMDIActivate) override;
@@ -224,10 +223,6 @@ public:
virtual SfxShell* GetFormShell() { return nullptr; };
virtual const SfxShell* GetFormShell() const { return nullptr; };
- void RegisterDlg(vcl::LOKWindowId nDialogId, VclPtr<Dialog> pDlg);
- VclPtr<Dialog> GetOpenedDlg(vcl::LOKWindowId nDialogId);
- void UnregisterDlg(vcl::LOKWindowId nDialogId);
-
// ILibreOfficeKitNotifier
virtual void notifyWindow(vcl::LOKWindowId nLOKWindowId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>()) const override;
virtual void notifyWindowChild(vcl::LOKWindowId nLOKWindowId, const OUString& rAction, const Point& rPos) const override;
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 016704bb09db..7b0720a429b7 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -228,12 +228,6 @@ public:
{
return OUString();
}
-
- /**
- * Find the window/dialog with the right ID for tunneling of windows,
- * dialogs or pop-ups.
- */
- virtual VclPtr<Window> findWindow(vcl::LOKWindowId nLOKWindowId) const = 0;
};
} // namespace vcl
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index c219147c1515..6df774ccde85 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1211,6 +1211,12 @@ public:
const vcl::ILibreOfficeKitNotifier* GetLOKNotifier() const;
vcl::LOKWindowId GetLOKWindowId() const;
+ /// Indicate that LOK is not going to use this dialog any more.
+ void ReleaseLOKNotifier();
+
+ /// Find an existing Window based on the LOKWindowId.
+ static VclPtr<Window> FindLOKWindow(vcl::LOKWindowId nWindowId);
+
/// Dialog / window tunneling related methods.
virtual void paintDialog(VirtualDevice& rDevice);
Size PaintActiveFloatingWindow(VirtualDevice& rDevice) const;
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 01fc9d9be960..67ee07440884 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -363,9 +363,6 @@ public:
/// @see vcl::ITiledRenderable::getPostItsPos().
OUString getPostItsPos() override;
-
- /// @see vcl::ITiledRenderable::findWindow().
- VclPtr<vcl::Window> findWindow(vcl::LOKWindowId nLOKWindowId) const override;
};
class ScDrawPagesObj : public cppu::WeakImplHelper<
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 9ee451923ab8..60bd3239cc27 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1130,12 +1130,6 @@ OUString ScModelObj::getPostItsPos()
return OUString::fromUtf8(aStream.str().c_str());
}
-VclPtr<vcl::Window> ScModelObj::findWindow(vcl::LOKWindowId nLOKWindowId) const
-{
- SfxViewShell* pViewShell = SfxViewShell::Current();
- return pViewShell->GetOpenedDlg(nLOKWindowId);
-}
-
void ScModelObj::initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& /*rArguments*/)
{
SolarMutexGuard aGuard;
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index d93ccdd89da9..404c34c49b72 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -265,9 +265,6 @@ public:
/// @see vcl::ITiledRenderable::getPostIts().
virtual OUString getPostIts() override;
- /// @see vcl::ITiledRenderable::findWindow().
- VclPtr<vcl::Window> findWindow(vcl::LOKWindowId nLOKWindowId) const override;
-
// XComponent
/** This dispose implementation releases the resources held by the
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index ebea82464567..ab16b1b1419f 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2669,12 +2669,6 @@ Pointer SdXImpressDocument::getPointer()
return pWindow->GetPointer();
}
-VclPtr<vcl::Window> SdXImpressDocument::findWindow(vcl::LOKWindowId nLOKWindowId) const
-{
- SfxViewShell* pViewShell = SfxViewShell::Current();
- return pViewShell->GetOpenedDlg(nLOKWindowId);
-}
-
uno::Reference< i18n::XForbiddenCharacters > SdXImpressDocument::getForbiddenCharsTable()
{
uno::Reference< i18n::XForbiddenCharacters > xForb(mxForbiddenCharacters);
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index fba79fdcc1b0..e9cadef82db0 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -165,7 +165,7 @@ void SfxModalDialog::dispose()
if (comphelper::LibreOfficeKit::isActive() && pViewShell)
{
pViewShell->notifyWindow(GetLOKWindowId(), "close");
- pViewShell->UnregisterDlg(GetLOKWindowId());
+ ReleaseLOKNotifier();
}
ModalDialog::dispose();
@@ -177,7 +177,6 @@ short SfxModalDialog::Execute()
if (comphelper::LibreOfficeKit::isActive() && pViewShell)
{
SetLOKNotifier(pViewShell);
- pViewShell->RegisterDlg(GetLOKWindowId(), this);
const Size aSize = GetOptimalSize();
std::vector<vcl::LOKPayloadItem> aItems;
aItems.emplace_back(std::make_pair("size", aSize.toString()));
@@ -249,7 +248,6 @@ void SfxModelessDialog::StateChanged( StateChangedType nStateChange )
if (comphelper::LibreOfficeKit::isActive() && pViewShell)
{
SetLOKNotifier(pViewShell);
- pViewShell->RegisterDlg(GetLOKWindowId(), this);
// Below method doesn't really give the exact dimensions,
// Check GetSizePixel() ?
const Size aOptimalSize = GetOptimalSize();
@@ -394,7 +392,7 @@ void SfxModelessDialog::dispose()
if (comphelper::LibreOfficeKit::isActive() && pViewShell)
{
pViewShell->notifyWindow(GetLOKWindowId(), "close");
- pViewShell->UnregisterDlg(GetLOKWindowId());
+ ReleaseLOKNotifier();
}
ModelessDialog::dispose();
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index 10cacfb0eee2..ce9e1a753984 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -407,7 +407,7 @@ void SfxTabDialog::dispose()
if (comphelper::LibreOfficeKit::isActive() && pViewShell)
{
pViewShell->notifyWindow(GetLOKWindowId(), "close");
- pViewShell->UnregisterDlg(GetLOKWindowId());
+ ReleaseLOKNotifier();
}
TabDialog::dispose();
@@ -522,7 +522,6 @@ short SfxTabDialog::Execute()
if (comphelper::LibreOfficeKit::isActive() && pViewShell)
{
SetLOKNotifier(pViewShell);
- pViewShell->RegisterDlg(GetLOKWindowId(), this);
const Size aSize = GetOptimalSize();
std::vector<vcl::LOKPayloadItem> aItems;
aItems.emplace_back(std::make_pair("size", aSize.toString()));
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index c286992d168e..4f08ef2298d6 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1958,37 +1958,6 @@ void SfxViewShell::notifyWindowChild(vcl::LOKWindowId nDialogId, const OUString&
SfxLokHelper::notifyWindowChild(nDialogId, rAction, rPos);
}
-void SfxViewShell::RegisterDlg(vcl::LOKWindowId nDialogId, VclPtr<Dialog> pDlg)
-{
- if (pDlg)
- maOpenedDialogs.push_back(std::make_pair(nDialogId, pDlg));
-}
-
-VclPtr<Dialog> SfxViewShell::GetOpenedDlg(vcl::LOKWindowId nDialogId)
-{
- const auto it = std::find_if(maOpenedDialogs.begin(),
- maOpenedDialogs.end(),
- [&nDialogId](const std::pair<vcl::LOKWindowId, VclPtr<Dialog>> aItem) {
- return nDialogId == aItem.first;
- });
-
- Dialog* ret = nullptr;
- if (it != maOpenedDialogs.end())
- {
- ret = it->second;
- }
- return ret;
-}
-
-void SfxViewShell::UnregisterDlg(vcl::LOKWindowId nDialogId)
-{
- maOpenedDialogs.erase(std::remove_if(maOpenedDialogs.begin(),
- maOpenedDialogs.end(),
- [&nDialogId](const std::pair<vcl::LOKWindowId, VclPtr<Dialog>> aItem) {
- return aItem.first == nDialogId;
- }));
-}
-
uno::Reference< datatransfer::clipboard::XClipboardNotifier > SfxViewShell::GetClipboardNotifier()
{
uno::Reference< datatransfer::clipboard::XClipboardNotifier > xClipboardNotifier;
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 288f32fa3df7..3f202c88ae54 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -429,9 +429,6 @@ public:
/// @see vcl::ITiledRenderable::getPostIts().
OUString getPostIts() override;
- /// @see vcl::ITiledRenderable::findWindow().
- VclPtr<vcl::Window> findWindow(vcl::LOKWindowId nLOKWindowId) const override;
-
// css::tiledrendering::XTiledRenderable
virtual void SAL_CALL paintTile( const ::css::uno::Any& Parent, ::sal_Int32 nOutputWidth, ::sal_Int32 nOutputHeight, ::sal_Int32 nTilePosX, ::sal_Int32 nTilePosY, ::sal_Int32 nTileWidth, ::sal_Int32 nTileHeight ) override;
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 15e6f72a45bd..0bc48bda8051 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3639,12 +3639,6 @@ void SAL_CALL SwXTextDocument::paintTile( const ::css::uno::Any& Parent, ::sal_I
#endif
}
-VclPtr<vcl::Window> SwXTextDocument::findWindow(vcl::LOKWindowId nLOKWindowId) const
-{
- SfxViewShell* pViewShell = SfxViewShell::Current();
- return pViewShell->GetOpenedDlg(nLOKWindowId);
-}
-
void * SAL_CALL SwXTextDocument::operator new( size_t t) throw()
{
return SwXTextDocumentBaseClass::operator new(t);
diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index 7b2222b3718b..dec452861bb1 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -378,7 +378,6 @@ public:
css::uno::Reference< css::uno::XInterface > mxDNDListenerContainer;
const vcl::ILibreOfficeKitNotifier* mpLOKNotifier; ///< To emit the LOK callbacks eg. for dialog tunneling.
- static vcl::LOKWindowId mnLastWindowId; ///< To be able to have an unique ID for each dealog / window we tunnel.
vcl::LOKWindowId mnLOKWindowId; ///< ID of this specific window.
};
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 3d6fff132ad3..93f554d06dc9 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -84,6 +84,12 @@ using namespace ::com::sun::star::datatransfer::dnd;
namespace vcl {
+/// Counter to be able to have unique id's for each window.
+static vcl::LOKWindowId sLastLOKWindowId = 1;
+
+/// Map to remember the LOKWindowId <-> Window binding.
+static std::map<vcl::LOKWindowId, VclPtr<vcl::Window>> sLOKWindows;
+
Window::Window( WindowType nType ) :
mpWindowImpl(new WindowImpl( nType ))
{
@@ -592,8 +598,6 @@ Window::~Window()
} /* namespace vcl */
-vcl::LOKWindowId WindowImpl::mnLastWindowId = 1;
-
WindowImpl::WindowImpl( WindowType nType )
{
maZoom = Fraction( 1, 1 );
@@ -3177,11 +3181,32 @@ void Window::SetLOKNotifier(const vcl::ILibreOfficeKitNotifier* pNotifier)
assert(pNotifier);
// assign the LOK window id
- mpWindowImpl->mnLOKWindowId = WindowImpl::mnLastWindowId++;
+ assert(mpWindowImpl->mnLOKWindowId == 0);
+ mpWindowImpl->mnLOKWindowId = sLastLOKWindowId++;
+ sLOKWindows.insert(std::map<vcl::LOKWindowId, VclPtr<vcl::Window>>::value_type(mpWindowImpl->mnLOKWindowId, this));
mpWindowImpl->mpLOKNotifier = pNotifier;
}
+VclPtr<Window> Window::FindLOKWindow(vcl::LOKWindowId nWindowId)
+{
+ const auto it = sLOKWindows.find(nWindowId);
+ if (it != sLOKWindows.end())
+ return it->second;
+
+ return VclPtr<Window>();
+}
+
+void Window::ReleaseLOKNotifier()
+{
+ // unregister the LOK window binding
+ if (mpWindowImpl->mnLOKWindowId > 0)
+ sLOKWindows.erase(mpWindowImpl->mnLOKWindowId);
+
+ mpWindowImpl->mpLOKNotifier = nullptr;
+ mpWindowImpl->mnLOKWindowId = 0;
+}
+
const vcl::ILibreOfficeKitNotifier* Window::GetLOKNotifier() const
{
return mpWindowImpl->mpLOKNotifier;