summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 2770575a9e0d..8d61d405f501 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1342,16 +1342,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 ...
@@ -2285,7 +2275,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.";
@@ -2463,7 +2453,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.";
@@ -2494,7 +2484,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.";
@@ -3305,7 +3295,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.";
@@ -3333,7 +3323,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.";
@@ -3358,7 +3348,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 e37c5137e381..5bfea3a81dcf 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -157,7 +157,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;
@@ -227,10 +226,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 b57ed35ae7e9..ae3ba9e76c3c 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -241,12 +241,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 f4e154816f3d..fa75822c563e 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1209,6 +1209,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 6bc2c5da7ae8..917b211a82a1 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -432,9 +432,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 629c203399ad..473a8dcb17ac 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 ee1cb5687dd1..087fa521ca9e 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -268,9 +268,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 c902e2dc5104..6b852e2cb5bb 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2705,12 +2705,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(mxForbidenCharacters);
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index e1afc854afd5..ce028f908472 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -171,7 +171,7 @@ void SfxModalDialog::dispose()
if (comphelper::LibreOfficeKit::isActive() && pViewShell)
{
pViewShell->notifyWindow(GetLOKWindowId(), "close");
- pViewShell->UnregisterDlg(GetLOKWindowId());
+ ReleaseLOKNotifier();
}
ModalDialog::dispose();
@@ -183,7 +183,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()));
@@ -255,7 +254,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();
@@ -398,7 +396,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 64bbc97727f9..23113c7836ea 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -409,7 +409,7 @@ void SfxTabDialog::dispose()
if (comphelper::LibreOfficeKit::isActive() && pViewShell)
{
pViewShell->notifyWindow(GetLOKWindowId(), "close");
- pViewShell->UnregisterDlg(GetLOKWindowId());
+ ReleaseLOKNotifier();
}
TabDialog::dispose();
@@ -524,7 +524,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 36229bd51ef4..78c43ed863f2 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -2046,37 +2046,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 f8865610db15..1de906c338b5 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -450,9 +450,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 ) throw (::css::uno::RuntimeException, std::exception) override;
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index f92e720a34e8..4390c78a9111 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3711,12 +3711,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 4f247162bcef..faf9e5162794 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -354,7 +354,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 b0d87fdef301..3a8444f80c59 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -85,6 +85,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 ))
{
@@ -598,8 +604,6 @@ Window::~Window()
} /* namespace vcl */
-vcl::LOKWindowId WindowImpl::mnLastWindowId = 1;
-
WindowImpl::WindowImpl( WindowType nType )
{
maZoom = Fraction( 1, 1 );
@@ -3198,11 +3202,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;