Skip to content

Commit

Permalink
Merge pull request #1012 from ONLYOFFICE/feature/hotfix-7-5-1
Browse files Browse the repository at this point in the history
Feature/hotfix 7 5 1
  • Loading branch information
maxkadushkin authored Oct 24, 2023
2 parents 7bc7381 + 58e9e78 commit b19ed70
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 8 deletions.
3 changes: 3 additions & 0 deletions win-linux/src/cprintdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
11 changes: 10 additions & 1 deletion win-linux/src/platform_linux/gtkprintdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "gtkprintdialog.h"
#include <gdk/gdkx.h>
#include <gtk/gtkunixprint.h>
#include "components/cmessage.h"

#define PDF_PRINTER_NAME "Print to File"
#define LPR_PRINTER_NAME "Print to LPR"
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()));
Expand Down
1 change: 1 addition & 0 deletions win-linux/src/platform_linux/gtkprintdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class GtkPrintDialog
PrintOptions m_options;
PrintRange m_print_range;
QVector<PageRanges> m_page_ranges;
int m_pages_count;
};

#endif // GTKPRINTDIALOG_H
17 changes: 15 additions & 2 deletions win-linux/src/platform_win/printdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@

#include <windows.h>
#include <commdlg.h>
#include <comdef.h>
#include "printdialog.h"
#include "utils.h"
#include "components/cmessage.h"

#define MAXPAGERANGES 32
#define PRINT_DIALOG_REG_KEY L"Software\\Microsoft\\Print\\UnifiedPrintDialog\0"
Expand Down Expand Up @@ -352,7 +354,8 @@ QDialog::DialogCode PrintDialog::exec()
dlg.lpCallback = static_cast<IPrintDialogCallback*>(&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);
Expand Down Expand Up @@ -410,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:<br>%1").arg(QString::fromStdWString(err)));
}
GlobalFree(page_ranges);

Expand Down Expand Up @@ -448,7 +454,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()));
Expand Down
8 changes: 5 additions & 3 deletions win-linux/src/windows/ceditorwindow_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -755,7 +757,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") ) {
Expand Down
6 changes: 4 additions & 2 deletions win-linux/src/windows/cmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1063,8 +1063,9 @@ void CMainWindow::onDocumentPrint(void * opts)
printInProcess = true; else
return;

QWidget *parent = qobject_cast<QWidget*>(this);
#ifdef Q_OS_LINUX
WindowHelper::CParentDisable disabler(qobject_cast<QWidget*>(this));
WindowHelper::CParentDisable disabler(parent);
#endif

CCefView * pView = AscAppManager::getInstance().GetViewById(AscAppManager::printData().viewId());
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b19ed70

Please sign in to comment.