From df22bd041560bca27b1b7ca17a9557354bbf38ce Mon Sep 17 00:00:00 2001 From: SimplestStudio Date: Fri, 21 Feb 2025 15:24:33 +0200 Subject: [PATCH] [win-linux] fix bug 58026 --- .../src/cascapplicationmanagerwrapper_private.h | 7 ++----- win-linux/src/components/asctabwidget.cpp | 2 +- win-linux/src/defines.h | 1 + win-linux/src/utils.cpp | 13 +++++++++++++ win-linux/src/utils.h | 1 + win-linux/src/windows/ceditorwindow.cpp | 3 ++- 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/win-linux/src/cascapplicationmanagerwrapper_private.h b/win-linux/src/cascapplicationmanagerwrapper_private.h index 082d0721d..4aef62ac9 100644 --- a/win-linux/src/cascapplicationmanagerwrapper_private.h +++ b/win-linux/src/cascapplicationmanagerwrapper_private.h @@ -217,11 +217,8 @@ public: opts.parent_id = event.m_nSenderId; opts.name = QString::fromStdWString(data.get_Name()); - // TODO: remove for ver 8.2 if unused - // if ( CCefView * _v = m_appmanager.GetViewById(opts.id) ) { - // bringEditorToFront(_v->GetId()); - // } else openDocument(opts); - openDocument(opts); + if ( !bringEditorToFront(QString::fromStdWString(opts.wurl)) ) + openDocument(opts); return true; } diff --git a/win-linux/src/components/asctabwidget.cpp b/win-linux/src/components/asctabwidget.cpp index 4470fe2f5..8c4bde318 100644 --- a/win-linux/src/components/asctabwidget.cpp +++ b/win-linux/src/components/asctabwidget.cpp @@ -680,7 +680,7 @@ int CAscTabWidget::tabIndexByUrl(const wstring& url) for (int i(count()); !(--i < 0);) { doc = panel(i)->data(); - if (doc && doc->url().compare(url) == 0) + if (doc && Utils::normalizeAppProtocolUrl(doc->url()).compare(Utils::normalizeAppProtocolUrl(url)) == 0) return i; } } diff --git a/win-linux/src/defines.h b/win-linux/src/defines.h index 55e19cd2a..cba03de84 100644 --- a/win-linux/src/defines.h +++ b/win-linux/src/defines.h @@ -66,6 +66,7 @@ #define APP_DEFAULT_SYSTEM_LOCALE 1 #define APP_USER_MODEL_ID "ASC.Documents.5" #define APP_SIMPLE_WINDOW_TITLE "ONLYOFFICE Editor" +#define APP_PROTOCOL "oo-office" #define FILE_PREFIX "onlyoffice_" #define URL_SITE "http://www.onlyoffice.com" diff --git a/win-linux/src/utils.cpp b/win-linux/src/utils.cpp index 17e10e56d..31f8f30e8 100644 --- a/win-linux/src/utils.cpp +++ b/win-linux/src/utils.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -856,6 +857,18 @@ QString Utils::replaceBackslash(const QString& path) return QString(path).replace(QRegularExpression("\\\\"), "/"); } +std::wstring Utils::normalizeAppProtocolUrl(const std::wstring &url) +{ + QUrl _url(QString::fromStdWString(url)); + if (_url.scheme() == APP_PROTOCOL) { + QUrlQuery query(_url); + query.addQueryItem("placement", "desktop"); + _url.setQuery(query); + return _url.toString(QUrl::RemoveScheme).toStdWString(); + } + return url; +} + void Utils::replaceAll(std::wstring& subject, const std::wstring& search, const std::wstring& replace) { size_t pos = 0; diff --git a/win-linux/src/utils.h b/win-linux/src/utils.h index 20e21d3aa..184870a7b 100644 --- a/win-linux/src/utils.h +++ b/win-linux/src/utils.h @@ -103,6 +103,7 @@ public: static double getScreenDpiRatioByWidget(QWidget*); static QScreen * screenAt(const QPoint&); static QString replaceBackslash(const QString&); + static std::wstring normalizeAppProtocolUrl(const std::wstring &url); static void replaceAll(std::wstring& subject, const std::wstring& search, const std::wstring& replace); static bool isFileLocal(const QString&); static QString uniqFileName(const QString& path); diff --git a/win-linux/src/windows/ceditorwindow.cpp b/win-linux/src/windows/ceditorwindow.cpp index 8028d7b92..c9ead2ce4 100644 --- a/win-linux/src/windows/ceditorwindow.cpp +++ b/win-linux/src/windows/ceditorwindow.cpp @@ -164,7 +164,8 @@ bool CEditorWindow::modified() const bool CEditorWindow::holdView(const std::wstring& portal) const { - return qobject_cast(m_pMainView)->data()->url().find(portal) != std::wstring::npos; + auto url = qobject_cast(m_pMainView)->data()->url(); + return Utils::normalizeAppProtocolUrl(url).find(Utils::normalizeAppProtocolUrl(portal)) != std::wstring::npos; } void CEditorWindow::undock(bool maximized)