From 11397845c4d860d54b8ce7d3bdb270147f76dcdb Mon Sep 17 00:00:00 2001 From: maxkadushkin Date: Wed, 18 Oct 2023 13:12:25 +0300 Subject: [PATCH 1/4] [win-nix] fix bug 64479 --- win-linux/src/windows/ceditorwindow_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win-linux/src/windows/ceditorwindow_p.h b/win-linux/src/windows/ceditorwindow_p.h index c74d022de..1ac656526 100644 --- a/win-linux/src/windows/ceditorwindow_p.h +++ b/win-linux/src/windows/ceditorwindow_p.h @@ -755,7 +755,7 @@ class CEditorWindowPrivate : public CCefEventsGate void onWebAppsFeatures(int, std::wstring f) override { - bool is_read_only = panel()->data()->hasFeature(L"readonly\":"); + bool is_read_only = panel()->data()->hasFeature(L"readonly\":true"); panel()->data()->setFeatures(f); if ( m_panel->data()->hasFeature(L"uitype\":\"fillform") ) { From a017b7eaad7d0ca1f360ccfd560882ff5c207a91 Mon Sep 17 00:00:00 2001 From: SimplestStudio Date: Thu, 19 Oct 2023 17:44:54 +0300 Subject: [PATCH 2/4] [win-linux] fix bug 64729 --- win-linux/src/cprintdata.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/win-linux/src/cprintdata.cpp b/win-linux/src/cprintdata.cpp index 0f68d3a92..ae1f88c6c 100644 --- a/win-linux/src/cprintdata.cpp +++ b/win-linux/src/cprintdata.cpp @@ -135,6 +135,9 @@ class CPrintData::CPrintDataPrivate pages_count = data->get_PagesCount(); current_page = data->get_CurrentPage(); + print_range = QPrintDialog::AllPages; + page_from = 1; + page_to = pages_count; parseJsonOptions(data->get_Options()); } From f67621ebf15db04a40c7f719f20a1ebc4f0eb7ac Mon Sep 17 00:00:00 2001 From: SimplestStudio Date: Thu, 19 Oct 2023 18:05:03 +0300 Subject: [PATCH 3/4] [win-linux] printdialog: adjusting page range to prevent errors --- win-linux/src/platform_linux/gtkprintdialog.cpp | 11 ++++++++++- win-linux/src/platform_linux/gtkprintdialog.h | 1 + win-linux/src/platform_win/printdialog.cpp | 10 +++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/win-linux/src/platform_linux/gtkprintdialog.cpp b/win-linux/src/platform_linux/gtkprintdialog.cpp index ca9d84a70..49574f05a 100644 --- a/win-linux/src/platform_linux/gtkprintdialog.cpp +++ b/win-linux/src/platform_linux/gtkprintdialog.cpp @@ -4,6 +4,7 @@ #include "gtkprintdialog.h" #include #include +#include "components/cmessage.h" #define PDF_PRINTER_NAME "Print to File" #define LPR_PRINTER_NAME "Print to LPR" @@ -65,6 +66,7 @@ GtkPrintDialog::GtkPrintDialog(QPrinter *printer, QWidget *parent) : if (m_printer->collateCopies()) m_options |= PrintOption::PrintCollateCopies; m_page_ranges.append(PageRanges(m_printer->fromPage(), m_printer->toPage())); + m_pages_count = m_printer->toPage(); } GtkPrintDialog::~GtkPrintDialog() @@ -445,7 +447,14 @@ int GtkPrintDialog::toPage() void GtkPrintDialog::setFromTo(int from, int to) { - m_printer->setFromTo(from, to); + from < 1 && (from = 1); to < 1 && (to = 1); + if (m_pages_count < from || m_pages_count < to) { + CMessage::warning(m_parent, QObject::tr("Specified range %1-%2 exceeds document limits: maximum number of pages is %3") + .arg(QString::number(from), QString::number(to), QString::number(m_pages_count))); + } + from > m_pages_count && (from = m_pages_count); + to > m_pages_count && (to = m_pages_count); + m_printer->setFromTo(from > to ? to : from, from > to ? from : to); if (!m_page_ranges.isEmpty()) m_page_ranges.clear(); m_page_ranges.append(PageRanges(m_printer->fromPage(), m_printer->toPage())); diff --git a/win-linux/src/platform_linux/gtkprintdialog.h b/win-linux/src/platform_linux/gtkprintdialog.h index f88d0de81..4476d558e 100644 --- a/win-linux/src/platform_linux/gtkprintdialog.h +++ b/win-linux/src/platform_linux/gtkprintdialog.h @@ -39,6 +39,7 @@ class GtkPrintDialog PrintOptions m_options; PrintRange m_print_range; QVector m_page_ranges; + int m_pages_count; }; #endif // GTKPRINTDIALOG_H diff --git a/win-linux/src/platform_win/printdialog.cpp b/win-linux/src/platform_win/printdialog.cpp index 31068f830..70dd05187 100644 --- a/win-linux/src/platform_win/printdialog.cpp +++ b/win-linux/src/platform_win/printdialog.cpp @@ -34,6 +34,7 @@ #include #include "printdialog.h" #include "utils.h" +#include "components/cmessage.h" #define MAXPAGERANGES 32 #define PRINT_DIALOG_REG_KEY L"Software\\Microsoft\\Print\\UnifiedPrintDialog\0" @@ -448,7 +449,14 @@ int PrintDialog::toPage() void PrintDialog::setFromTo(int from, int to) { - m_printer->setFromTo(from, to); + from < 1 && (from = 1); to < 1 && (to = 1); + if (m_pages_count < from || m_pages_count < to) { + CMessage::warning(m_parent, QObject::tr("Specified range %1-%2 exceeds document limits: maximum number of pages is %3") + .arg(QString::number(from), QString::number(to), QString::number(m_pages_count))); + } + from > m_pages_count && (from = m_pages_count); + to > m_pages_count && (to = m_pages_count); + m_printer->setFromTo(from > to ? to : from, from > to ? from : to); if (!m_page_ranges.isEmpty()) m_page_ranges.clear(); m_page_ranges.append(PageRanges(m_printer->fromPage(), m_printer->toPage())); From 085d5c8a062c586564a91584bd37ab8860e35885 Mon Sep 17 00:00:00 2001 From: SimplestStudio Date: Thu, 19 Oct 2023 18:21:49 +0300 Subject: [PATCH 4/4] [win-linux] additional print settings error messages --- win-linux/src/platform_win/printdialog.cpp | 7 ++++++- win-linux/src/windows/ceditorwindow_p.h | 6 ++++-- win-linux/src/windows/cmainwindow.cpp | 6 ++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/win-linux/src/platform_win/printdialog.cpp b/win-linux/src/platform_win/printdialog.cpp index 70dd05187..6d788a832 100644 --- a/win-linux/src/platform_win/printdialog.cpp +++ b/win-linux/src/platform_win/printdialog.cpp @@ -32,6 +32,7 @@ #include #include +#include #include "printdialog.h" #include "utils.h" #include "components/cmessage.h" @@ -353,7 +354,8 @@ QDialog::DialogCode PrintDialog::exec() dlg.lpCallback = static_cast(&clb); QDialog::DialogCode exit_code = QDialog::DialogCode::Rejected; - if (PrintDlgEx(&dlg) == S_OK) { + HRESULT hr = PrintDlgEx(&dlg); + if (hr == S_OK) { switch (dlg.dwResultAction) { case PD_RESULT_PRINT: { LPDEVMODE pDevmode = (LPDEVMODE)GlobalLock(dlg.hDevMode); @@ -411,6 +413,9 @@ QDialog::DialogCode PrintDialog::exec() #endif if (pDevMode) GlobalFree(pDevMode); + + const wchar_t *err = _com_error(hr).ErrorMessage(); + CMessage::error(m_parent, QObject::tr("Unable to open print dialog:
%1").arg(QString::fromStdWString(err))); } GlobalFree(page_ranges); diff --git a/win-linux/src/windows/ceditorwindow_p.h b/win-linux/src/windows/ceditorwindow_p.h index 1ac656526..7c4a0f16a 100644 --- a/win-linux/src/windows/ceditorwindow_p.h +++ b/win-linux/src/windows/ceditorwindow_p.h @@ -477,8 +477,9 @@ class CEditorWindowPrivate : public CCefEventsGate if ( isPrinting ) return; isPrinting = true; + QWidget *parent = window->handle(); #ifdef Q_OS_LINUX - WindowHelper::CParentDisable oDisabler(window->handle()); + WindowHelper::CParentDisable oDisabler(parent); #endif if ( !(pagescount < 1) ) { CAscMenuEvent * pEvent; @@ -583,7 +584,8 @@ class CEditorWindowPrivate : public CCefEventsGate #ifndef _WIN32 RELEASEOBJECT(dialog) #endif - } + } else + CMessage::warning(parent, tr("There are no pages set to print.")); isPrinting = false; } diff --git a/win-linux/src/windows/cmainwindow.cpp b/win-linux/src/windows/cmainwindow.cpp index 43b675d7f..9daf52c7d 100644 --- a/win-linux/src/windows/cmainwindow.cpp +++ b/win-linux/src/windows/cmainwindow.cpp @@ -1063,8 +1063,9 @@ void CMainWindow::onDocumentPrint(void * opts) printInProcess = true; else return; + QWidget *parent = qobject_cast(this); #ifdef Q_OS_LINUX - WindowHelper::CParentDisable disabler(qobject_cast(this)); + WindowHelper::CParentDisable disabler(parent); #endif CCefView * pView = AscAppManager::getInstance().GetViewById(AscAppManager::printData().viewId()); @@ -1177,7 +1178,8 @@ void CMainWindow::onDocumentPrint(void * opts) #ifndef _WIN32 RELEASEOBJECT(dialog) #endif - } + } else + CMessage::warning(parent, tr("There are no pages set to print.")); printInProcess = false; // RELEASEINTERFACE(pData)