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-29 10:16:58 +0100
commitd516c5c9819dcd7dc6dded2f8f9d9e44061b23c0 (patch)
tree0304dd3f677801f4d189fd29bc1b9e2b31f2c86a
parentb4487b0fd22ce1fc595851f63a3f7bba36681f2c (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 cf5827ecbebd..ece7600f178d 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1322,16 +1322,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 ...
@@ -2265,7 +2255,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.";
@@ -2443,7 +2433,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.";
@@ -2474,7 +2464,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.";
@@ -3285,7 +3275,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.";
@@ -3313,7 +3303,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.";
@@ -3338,7 +3328,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 d0d68b3b48ae..90ade4ba1463 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -153,7 +153,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;
@@ -222,10 +221,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 f513ea8995eb..a638dfa88f94 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1208,6 +1208,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 9144363f5f0c..ca287c11b398 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 8af06f170e54..2699b62bb97f 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 cae647d2948b..a6431a67975f 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 852dae458f35..26a63eea7870 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 );
@@ -3161,11 +3165,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;