From 03809c0a1c6930ca09ca87034632aa1b6a2eac55 Mon Sep 17 00:00:00 2001 From: Svetlana Kulikova Date: Thu, 28 Aug 2025 13:45:56 +0300 Subject: [PATCH] Add SetEditType --- PdfFile/OnlineOfficeBinToPdf.cpp | 9 ++++++++- PdfFile/PdfFile.cpp | 9 ++++++++- PdfFile/PdfFile.h | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/PdfFile/OnlineOfficeBinToPdf.cpp b/PdfFile/OnlineOfficeBinToPdf.cpp index 080da23599..77a6f2cc60 100644 --- a/PdfFile/OnlineOfficeBinToPdf.cpp +++ b/PdfFile/OnlineOfficeBinToPdf.cpp @@ -152,6 +152,7 @@ namespace NSOnlineOfficeBinToPdf WidgetInfo = 3, MovePage = 4, MergePages = 5, + SetType = 6, Undefined = 255 }; @@ -176,7 +177,7 @@ namespace NSOnlineOfficeBinToPdf int nLen = oReader.ReadInt(); AddCommandType CommandType = (AddCommandType)oReader.ReadByte(); int nPageNum = 0; - if (CommandType != AddCommandType::WidgetInfo && CommandType != AddCommandType::MergePages) + if (CommandType != AddCommandType::WidgetInfo && CommandType != AddCommandType::MergePages && CommandType != AddCommandType::SetType) nPageNum = oReader.ReadInt(); if (nPageNum < 0) @@ -244,6 +245,12 @@ namespace NSOnlineOfficeBinToPdf oReader.Skip(nLen - 5); break; } + case AddCommandType::SetType: + { + int nType = oReader.ReadInt(); + pPdf->SetEditType(nType); + break; + } default: return false; } diff --git a/PdfFile/PdfFile.cpp b/PdfFile/PdfFile.cpp index 1022d96e57..289b85e423 100644 --- a/PdfFile/PdfFile.cpp +++ b/PdfFile/PdfFile.cpp @@ -115,9 +115,16 @@ bool CPdfFile::EditPdf(const std::wstring& wsDstFile) m_pInternal->pWriter = new CPdfWriter(m_pInternal->pAppFonts, false, this, true, m_pInternal->wsTempFolder); RELEASEOBJECT(m_pInternal->pEditor); - m_pInternal->pEditor = new CPdfEditor(m_pInternal->wsSrcFile, m_pInternal->wsPassword, wsDstFile, m_pInternal->pReader, m_pInternal->pWriter, CPdfEditor::Mode::WriteNew); + m_pInternal->pEditor = new CPdfEditor(m_pInternal->wsSrcFile, m_pInternal->wsPassword, wsDstFile, m_pInternal->pReader, m_pInternal->pWriter); return m_pInternal->pEditor->GetError() == 0; } +void CPdfFile::SetEditType(int nType) +{ + if (!m_pInternal->pEditor) + return; + if (nType == 1) + m_pInternal->pEditor->SetMode(CPdfEditor::Mode::WriteNew); +} bool CPdfFile::EditPage(int nPageIndex) { if (!m_pInternal->pEditor) diff --git a/PdfFile/PdfFile.h b/PdfFile/PdfFile.h index ffbbc89521..74bb4e545d 100644 --- a/PdfFile/PdfFile.h +++ b/PdfFile/PdfFile.h @@ -92,6 +92,7 @@ public: // --- EDIT --- // Переходит в режим редактирования. Pdf уже должен быть открыт на чтение - LoadFromFile/LoadFromMemory bool EditPdf(const std::wstring& wsDstFile = L""); + void SetEditType(int nType); // Манипуляции со страницами возможны в режиме редактирования bool EditPage (int nPageIndex); bool DeletePage(int nPageIndex);