From cf2443a12681f23850cfe9439a4dec680821c61a Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Fri, 24 Nov 2017 01:20:56 +0530 Subject: lokdialog: Make vcl::DialogID an integer This will help launching multiple instances of dialog from multiple views. The earlier approach of using the UNO command strings as dialog id would not have been useful for multi-view case. Change-Id: I01cfb3c8b204d5654df2417efdac6b50dc920f0e --- sfx2/source/view/lokhelper.cxx | 12 ++++++------ sfx2/source/view/viewsh.cxx | 27 ++++++++++++--------------- 2 files changed, 18 insertions(+), 21 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index d24e0a7a3db6..eea6e2c1cefc 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -132,15 +132,15 @@ void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OS } } -void SfxLokHelper::notifyDialog(const OUString& rDialogID, +void SfxLokHelper::notifyDialog(vcl::DialogID nDialogID, const OUString& rAction, const std::vector& rPayload) { - if (SfxLokHelper::getViewsCount() <= 0 || rDialogID.isEmpty()) + if (SfxLokHelper::getViewsCount() <= 0 || nDialogID == 0) return; SfxViewShell* pViewShell = SfxViewShell::GetFirst(); - OString aPayload = OString("{ \"dialogId\": \"") + OUStringToOString(rDialogID, RTL_TEXTENCODING_UTF8).getStr() + OString("\""); + OString aPayload = OString("{ \"dialogId\": \"") + OString::number(nDialogID) + OString("\""); aPayload += OString(", \"action\": \"") + OUStringToOString(rAction, RTL_TEXTENCODING_UTF8).getStr() + OString("\""); for (const auto& rItem: rPayload) @@ -160,13 +160,13 @@ void SfxLokHelper::notifyDialog(const OUString& rDialogID, } } -void SfxLokHelper::notifyDialogChild(const OUString& rDialogID, const OUString& rAction, const Point& rPos) +void SfxLokHelper::notifyDialogChild(vcl::DialogID nDialogID, const OUString& rAction, const Point& rPos) { - if (SfxLokHelper::getViewsCount() <= 0 || rDialogID.isEmpty()) + if (SfxLokHelper::getViewsCount() <= 0 || nDialogID == 0) return; SfxViewShell* pViewShell = SfxViewShell::GetFirst(); - const OString aPayload = OString("{ \"dialogId\": \"") + OUStringToOString(rDialogID, RTL_TEXTENCODING_UTF8).getStr() + + const OString aPayload = OString("{ \"dialogId\": \"") + OString::number(nDialogID) + OString("\", \"action\": \"") + OUStringToOString(rAction, RTL_TEXTENCODING_UTF8).getStr() + OString("\", \"position\": \"") + OString::number(rPos.getX()) + OString(", ") + OString::number(rPos.getY()) + + "\" }"; diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index c8a0a9000762..a872c7983cf5 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -2036,31 +2036,28 @@ Reference< view::XRenderable > SfxViewShell::GetRenderable() return xRender; } -void SfxViewShell::notifyDialog(const vcl::DialogID& rDialogID, const OUString& rAction, const std::vector& rPayload) +void SfxViewShell::notifyDialog(const vcl::DialogID& rDialogId, const OUString& rAction, const std::vector& rPayload) { - SfxLokHelper::notifyDialog(rDialogID, rAction, rPayload); + SfxLokHelper::notifyDialog(rDialogId, rAction, rPayload); } -void SfxViewShell::notifyDialogChild(const vcl::DialogID& rDialogID, const OUString& rAction, const Point& rPos) +void SfxViewShell::notifyDialogChild(const vcl::DialogID& rDialogId, const OUString& rAction, const Point& rPos) { - SfxLokHelper::notifyDialog(rDialogID, rAction); + SfxLokHelper::notifyDialog(rDialogId, rAction); } -void SfxViewShell::RegisterDlg(const vcl::DialogID& rDialogId, VclPtr pDlg) +void SfxViewShell::RegisterDlg(vcl::DialogID nDialogId, VclPtr pDlg) { if (pDlg) - maOpenedDialogs.push_back(std::make_pair(rName, pDlg)); + maOpenedDialogs.push_back(std::make_pair(nDialogId, pDlg)); } -VclPtr SfxViewShell::GetOpenedDlg(const vcl::DialogID& rDialogId) +VclPtr SfxViewShell::GetOpenedDlg(vcl::DialogID nDialogId) { - if (rName.startsWith(".uno:")) - rName = rName.replaceFirst(".uno:", ""); - const auto it = std::find_if(maOpenedDialogs.begin(), maOpenedDialogs.end(), - [&rDialogId](const std::pair> aItem) { - return rDialogId == aItem.first; + [&nDialogId](const std::pair> aItem) { + return nDialogId == aItem.first; }); Dialog* ret = nullptr; @@ -2071,12 +2068,12 @@ VclPtr SfxViewShell::GetOpenedDlg(const vcl::DialogID& rDialogId) return ret; } -void SfxViewShell::UnregisterDlg(const OUString& rName) +void SfxViewShell::UnregisterDlg(vcl::DialogID nDialogId) { maOpenedDialogs.erase(std::remove_if(maOpenedDialogs.begin(), maOpenedDialogs.end(), - [&rDialogId](const std::pair> aItem) { - return aItem.first == rDialogId; + [&nDialogId](const std::pair> aItem) { + return aItem.first == nDialogId; })); } -- cgit v1.2.3