From 34d689e6854665449e95fa5bf43d479dbb2caf35 Mon Sep 17 00:00:00 2001 From: SimplestStudio Date: Wed, 18 Dec 2024 11:29:54 +0200 Subject: [PATCH] [win-linux] add visio support --- win-linux/src/cascapplicationmanagerwrapper.cpp | 2 ++ .../src/cascapplicationmanagerwrapper_private.h | 1 + win-linux/src/casctabdata.cpp | 1 + win-linux/src/ceditortools.cpp | 3 +++ win-linux/src/components/asctabwidget.cpp | 14 ++++++++++++++ win-linux/src/platform_win/association.cpp | 3 +++ win-linux/src/windows/ceditorwindow_p.h | 6 ++++++ win-linux/src/windows/cmainwindow.cpp | 6 ++++-- 8 files changed, 34 insertions(+), 2 deletions(-) diff --git a/win-linux/src/cascapplicationmanagerwrapper.cpp b/win-linux/src/cascapplicationmanagerwrapper.cpp index edc090d2a..88eb068df 100644 --- a/win-linux/src/cascapplicationmanagerwrapper.cpp +++ b/win-linux/src/cascapplicationmanagerwrapper.cpp @@ -926,6 +926,7 @@ void CAscApplicationManagerWrapper::handleInputCmd(const std::vector& v open_opts.srctype = etNewFile; open_opts.format = arg.rfind(L"cell") != wstring::npos ? AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX : arg.rfind(L"slide") != wstring::npos ? AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX : + arg.rfind(L"draw") != wstring::npos ? AVS_OFFICESTUDIO_FILE_DRAW_VSDX : arg.rfind(L"form") != wstring::npos ? AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCXF : /*if ( line.rfind(L"word") != wstring::npos )*/ AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX; @@ -2253,6 +2254,7 @@ QString CAscApplicationManagerWrapper::newFileName(const std::wstring& format) int _f = format == L"word" ? AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX : format == L"cell" ? AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX : format == L"form" ? AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCXF : + format == L"draw" ? AVS_OFFICESTUDIO_FILE_DRAW_VSDX : format == L"slide" ? AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX : AVS_OFFICESTUDIO_FILE_UNKNOWN; return newFileName(_f); diff --git a/win-linux/src/cascapplicationmanagerwrapper_private.h b/win-linux/src/cascapplicationmanagerwrapper_private.h index 953367fca..0a12dbd72 100644 --- a/win-linux/src/cascapplicationmanagerwrapper_private.h +++ b/win-linux/src/cascapplicationmanagerwrapper_private.h @@ -332,6 +332,7 @@ class CAscApplicationManagerWrapper_Private int _f = format == L"word" ? AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX : format == L"cell" ? AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX : format == L"form" ? AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCXF : + format == L"draw" ? AVS_OFFICESTUDIO_FILE_DRAW_VSDX : format == L"slide" ? AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX : AVS_OFFICESTUDIO_FILE_UNKNOWN; COpenOptions opts{m_appmanager.newFileName(_f), etNewFile}; diff --git a/win-linux/src/casctabdata.cpp b/win-linux/src/casctabdata.cpp index 13fcc3518..cd1d9a865 100644 --- a/win-linux/src/casctabdata.cpp +++ b/win-linux/src/casctabdata.cpp @@ -55,6 +55,7 @@ CAscTabData::CAscTabData(const QString& t, AscEditorType ct) case AscEditorType::etSpreadsheet: case AscEditorType::etPresentation: case AscEditorType::etPdf: + case AscEditorType::etDraw: _vtype = cvwtEditor; break; default: diff --git a/win-linux/src/ceditortools.cpp b/win-linux/src/ceditortools.cpp index 6bfe196ed..5e73e0ebb 100644 --- a/win-linux/src/ceditortools.cpp +++ b/win-linux/src/ceditortools.cpp @@ -370,6 +370,9 @@ namespace CEditorTools else if (format > AVS_OFFICESTUDIO_FILE_CROSSPLATFORM && format < AVS_OFFICESTUDIO_FILE_IMAGE ) return AscEditorType::etPdf; + else + if (format & AVS_OFFICESTUDIO_FILE_DRAW ) + return AscEditorType::etDraw; return AscEditorType::etUndefined; } diff --git a/win-linux/src/components/asctabwidget.cpp b/win-linux/src/components/asctabwidget.cpp index 6c21eeca0..3ec482525 100644 --- a/win-linux/src/components/asctabwidget.cpp +++ b/win-linux/src/components/asctabwidget.cpp @@ -506,6 +506,9 @@ int CAscTabWidget::insertPanel(QWidget * panel, int index) case AscEditorType::etPdf: tabcolor = QString::fromStdWString(ui_theme.value(CTheme::ColorRole::ecrTabViewerActive)); break; + case AscEditorType::etDraw: + tabcolor = QString::fromStdWString(ui_theme.value(CTheme::ColorRole::ecrTabDrawActive)); + break; case etPortal: tabcolor = QString::fromStdWString(ui_theme.value(CTheme::ColorRole::ecrTabSimpleActiveBackground)); m_pBar->setTabThemeType(tabindex, /*ui_theme.isDark() ? CTabBar::DarkTab :*/ CTabBar::LightTab); @@ -521,6 +524,7 @@ int CAscTabWidget::insertPanel(QWidget * panel, int index) case AscEditorType::etDocumentMasterForm: case AscEditorType::etPdf: case AscEditorType::etDocument: + case AscEditorType::etDraw: m_pBar->setTabThemeType(tabindex, ui_theme.value(CTheme::ColorRole::ecrTabThemeType, L"dark") == L"dark" ? CTabBar::DarkTab : CTabBar::LightTab); break; @@ -569,6 +573,7 @@ void CAscTabWidget::reloadTabIcons() {AscEditorType::etDocumentMasterForm, std::make_pair(icons[3], icons[3])}, {AscEditorType::etSpreadsheet, std::make_pair(icons[4], icons[4])}, {AscEditorType::etPdf, std::make_pair(icons[7], icons[7])}, + {AscEditorType::etDraw, std::make_pair(icons[8], icons[8])}, {etPortal, std::make_pair(icons[portal_icon], icons[6])}, {etNewPortal, std::make_pair(icons[portal_icon], icons[6])} }); @@ -853,6 +858,11 @@ void CAscTabWidget::applyDocumentChanging(int id, int type) m_pBar->setActiveTabColor(tabIndex, QString::fromStdWString(ui_theme.value(CTheme::ColorRole::ecrTabViewerActive))); break; + case AscEditorType::etDraw: + panel(tabIndex)->applyLoader("loader:style", "draw"); + m_pBar->setActiveTabColor(tabIndex, + QString::fromStdWString(ui_theme.value(CTheme::ColorRole::ecrTabDrawActive))); + break; default: break; } @@ -1267,6 +1277,9 @@ void CAscTabWidget::applyUITheme(const std::wstring& theme) case AscEditorType::etPdf: m_pBar->setActiveTabColor(i, QString::fromStdWString(ui_theme.value(CTheme::ColorRole::ecrTabViewerActive))); break; + case AscEditorType::etDraw: + m_pBar->setActiveTabColor(i, QString::fromStdWString(ui_theme.value(CTheme::ColorRole::ecrTabDrawActive))); + break; case etPortal: m_pBar->setTabThemeType(i, ui_theme.isDark() ? CTabBar::DarkTab : CTabBar::LightTab); m_pBar->setActiveTabColor(i, QString::fromStdWString(ui_theme.value(CTheme::ColorRole::ecrTabSimpleActiveBackground))); @@ -1283,6 +1296,7 @@ void CAscTabWidget::applyUITheme(const std::wstring& theme) case AscEditorType::etDocumentMasterForm: case AscEditorType::etPdf: case AscEditorType::etDocument: + case AscEditorType::etDraw: m_pBar->setTabThemeType(i, tab_theme); break; default: break; diff --git a/win-linux/src/platform_win/association.cpp b/win-linux/src/platform_win/association.cpp index 4e15861b7..b6f206faf 100644 --- a/win-linux/src/platform_win/association.cpp +++ b/win-linux/src/platform_win/association.cpp @@ -350,6 +350,9 @@ void Association::chekForAssociations(int uid) case AscEditorType::etPdf: fileExt = L".pdf"; break; + case AscEditorType::etDraw: + fileExt = L".vsdx"; + break; default: break; } diff --git a/win-linux/src/windows/ceditorwindow_p.h b/win-linux/src/windows/ceditorwindow_p.h index d8be272fe..24808f61c 100644 --- a/win-linux/src/windows/ceditorwindow_p.h +++ b/win-linux/src/windows/ceditorwindow_p.h @@ -73,6 +73,7 @@ auto prepare_editor_css(AscEditorType type, const CTheme& theme) -> QString { case AscEditorType::etPresentation: c = theme.value(CTheme::ColorRole::ecrTabSlideActive); break; case AscEditorType::etSpreadsheet: c = theme.value(CTheme::ColorRole::ecrTabCellActive); break; case AscEditorType::etPdf: c = theme.value(CTheme::ColorRole::ecrTabViewerActive); break; + case AscEditorType::etDraw: c = theme.value(CTheme::ColorRole::ecrTabDrawActive); break; } QString g_css(Utils::readStylesheets(":/styles/editor.qss")); #ifdef __linux__ @@ -87,6 +88,7 @@ auto editor_color(AscEditorType type) -> QColor { case AscEditorType::etPresentation: return GetColorByRole(ecrTabSlideActive); case AscEditorType::etSpreadsheet: return GetColorByRole(ecrTabCellActive); case AscEditorType::etPdf: return GetColorByRole(ecrTabViewerActive); + case AscEditorType::etDraw: return GetColorByRole(ecrTabDrawActive); default: return GetColorByRole(ecrTabWordActive); } } @@ -505,6 +507,10 @@ class CEditorWindowPrivate : public CCefEventsGate background = GetColorValueByRole(ecrTabViewerActive); border = background; break; + case AscEditorType::etDraw: + background = GetColorValueByRole(ecrTabDrawActive); + border = background; + break; default: background = GetColorValueByRole(ecrWindowBackground); border = GetColorValueByRole(ecrWindowBorder); diff --git a/win-linux/src/windows/cmainwindow.cpp b/win-linux/src/windows/cmainwindow.cpp index 933de2e44..188d3bae5 100644 --- a/win-linux/src/windows/cmainwindow.cpp +++ b/win-linux/src/windows/cmainwindow.cpp @@ -814,13 +814,15 @@ void CMainWindow::setTabMenu(int index, CTabPanel *panel) actCreateNew->setIcon(IconFactory::icon(IconFactory::CreateNew, SMALL_ICON * m_dpiRatio)); AscEditorType etype = panel->data()->contentType(); actCreateNew->setEnabled(panel->isReady() && (etype == AscEditorType::etDocument || etype == AscEditorType::etPresentation || - etype == AscEditorType::etSpreadsheet || etype == AscEditorType::etPdf)); + etype == AscEditorType::etSpreadsheet || etype == AscEditorType::etPdf || + etype == AscEditorType::etDraw)); connect(actCreateNew, &QAction::triggered, this, [=]() { int index = m_pTabs->tabBar()->tabMenuIndex(menu); AscEditorType etype = m_pTabs->panel(index)->data()->contentType(); std::wstring cmd = etype == AscEditorType::etDocument ? L"--new:word" : etype == AscEditorType::etPresentation ? L"--new:slide" : etype == AscEditorType::etSpreadsheet ? L"--new:cell" : + etype == AscEditorType::etDraw ? L"--new:draw" : etype == AscEditorType::etPdf ? L"--new:form" : L""; if (!cmd.empty()) AscAppManager::handleInputCmd({cmd}); @@ -1158,7 +1160,7 @@ void CMainWindow::onDocumentReady(int uid) if (CMenu *menu = m_pTabs->tabBar()->tabMenu(index)) { AscEditorType etype = m_pTabs->panel(index)->data()->contentType(); if (etype == AscEditorType::etDocument || etype == AscEditorType::etPresentation || - etype == AscEditorType::etSpreadsheet || etype == AscEditorType::etPdf) { + etype == AscEditorType::etSpreadsheet || etype == AscEditorType::etPdf || etype == AscEditorType::etDraw) { menu->setSectionEnabled(CMenu::ActionCreateNew, true); } }