From df8f8636b6e28d3a632a83b88d98e66c4470899b Mon Sep 17 00:00:00 2001 From: Svetlana Kulikova Date: Wed, 30 Jul 2025 16:20:57 +0300 Subject: [PATCH] Fix MEOptions to 21 widget and 11 parent --- .../graphics/commands/AnnotField.cpp | 8 ++-- DesktopEditor/graphics/commands/AnnotField.h | 5 ++- .../graphics/pro/js/wasm/js/drawingfile.js | 7 ++-- .../pro/js/wasm/src/drawingfile_test.cpp | 18 ++++++--- PdfFile/PdfWriter.cpp | 18 ++------- PdfFile/SrcReader/PdfAnnot.cpp | 38 ++++++++++--------- PdfFile/SrcReader/PdfAnnot.h | 3 +- PdfFile/SrcWriter/Annotation.cpp | 8 ++-- PdfFile/SrcWriter/Annotation.h | 2 +- 9 files changed, 55 insertions(+), 52 deletions(-) diff --git a/DesktopEditor/graphics/commands/AnnotField.cpp b/DesktopEditor/graphics/commands/AnnotField.cpp index 3b94ed3b3f..fcfab5c9ec 100644 --- a/DesktopEditor/graphics/commands/AnnotField.cpp +++ b/DesktopEditor/graphics/commands/AnnotField.cpp @@ -215,7 +215,6 @@ int CAnnotFieldInfo::GetID() const { return m_nID; } int CAnnotFieldInfo::GetAnnotFlag() const { return m_nAnnotFlag; } int CAnnotFieldInfo::GetPage() const { return m_nPage; } int CAnnotFieldInfo::GetCopyAP() const { return m_nCopyAP; } -int CAnnotFieldInfo::GetMEOptions() const { return m_nMEOptions; } void CAnnotFieldInfo::GetBE(BYTE& nS, double& dI) { nS = m_pBE.first; dI = m_pBE.second; } BYTE* CAnnotFieldInfo::GetRender(LONG& nLen) { @@ -363,8 +362,6 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta m_wsOUserID = pReader->ReadString(); if (nFlags & (1 << 8)) m_nCopyAP = pReader->ReadInt(); - if (nFlags & (1 << 9)) - m_nMEOptions = pReader->ReadInt(); if (IsMarkup()) { @@ -683,6 +680,7 @@ int CAnnotFieldInfo::CWidgetAnnotPr::GetR() const { return m_nR; } int CAnnotFieldInfo::CWidgetAnnotPr::GetFlag() const { return m_nFlag; } int CAnnotFieldInfo::CWidgetAnnotPr::GetFlags() const { return m_nFlags; } int CAnnotFieldInfo::CWidgetAnnotPr::GetParentID() const { return m_nParentID; } +int CAnnotFieldInfo::CWidgetAnnotPr::GetMEOptions() const { return m_nMEOptions; } int CAnnotFieldInfo::CWidgetAnnotPr::GetFontStyle() const { return m_nFontStyle; } double CAnnotFieldInfo::CWidgetAnnotPr::GetFontSize() const { return m_dFS; } double CAnnotFieldInfo::CWidgetAnnotPr::GetFontSizeAP() const { return m_dFSAP; } @@ -895,6 +893,8 @@ void CAnnotFieldInfo::CWidgetAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader m_wsT = pReader->ReadString(); if (nFlags & (1 << 20)) m_wsOMetadata = pReader->ReadString(); + if (nFlags & (1 << 21)) + m_nMEOptions = pReader->ReadInt(); // Action int nAction = pReader->ReadInt(); @@ -1146,6 +1146,8 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil } if (nFlags & (1 << 9)) pParent->nMaxLen = pReader->ReadInt(); + if (nFlags & (1 << 11)) + pParent->nMEOptions = pReader->ReadInt(); m_arrParents.push_back(pParent); } diff --git a/DesktopEditor/graphics/commands/AnnotField.h b/DesktopEditor/graphics/commands/AnnotField.h index 82bc3e1faf..aef7fb7de8 100644 --- a/DesktopEditor/graphics/commands/AnnotField.h +++ b/DesktopEditor/graphics/commands/AnnotField.h @@ -185,6 +185,7 @@ public: int GetFlag() const; int GetFlags() const; int GetParentID() const; + int GetMEOptions() const; int GetFontStyle() const; double GetFontSize() const; double GetFontSizeAP() const; @@ -215,6 +216,7 @@ public: int m_nFlag; int m_nFlags; int m_nParentID; + int m_nMEOptions; int m_nFontStyle; double m_dFS; double m_dFSAP; @@ -466,7 +468,6 @@ public: int GetAnnotFlag() const; int GetPage() const; int GetCopyAP() const; - int GetMEOptions() const; void GetBE(BYTE& nS, double& dI); BYTE* GetRender(LONG& nLen); const std::wstring& GetNM(); @@ -525,7 +526,6 @@ private: int m_nAnnotFlag; int m_nPage; int m_nCopyAP; - int m_nMEOptions; std::wstring m_wsNM; std::wstring m_wsLM; std::wstring m_wsOUserID; @@ -573,6 +573,7 @@ public: int nFlags; int nMaxLen; int nParentID; + int nMEOptions; int nFieldFlag; std::wstring sName; std::wstring sV; diff --git a/DesktopEditor/graphics/pro/js/wasm/js/drawingfile.js b/DesktopEditor/graphics/pro/js/wasm/js/drawingfile.js index 73b1c82b4a..6a509811a1 100644 --- a/DesktopEditor/graphics/pro/js/wasm/js/drawingfile.js +++ b/DesktopEditor/graphics/pro/js/wasm/js/drawingfile.js @@ -546,9 +546,6 @@ function readAnnot(reader, rec, readDoubleFunc, readDouble2Func, readStringFunc, // User ID if (flags & (1 << 8)) rec["AP"]["Copy"] = reader.readInt(); - // MEOptions - if (flags & (1 << 9)) - rec["MEOptions"] = reader.readInt(); } function readAnnotAP(reader, AP) { @@ -1049,6 +1046,8 @@ function readWidgetType(reader, rec, readDoubleFunc, readDouble2Func, readString rec["font"]["AP"] = readStringFunc.call(reader); if (flags & (1 << 20)) rec["meta"] = readStringFunc.call(reader); + if (flags & (1 << 21)) + rec["MEOptions"] = reader.readInt(); // Action let nAction = reader.readInt(); if (nAction > 0) @@ -1320,6 +1319,8 @@ CFile.prototype["getInteractiveFormsInfo"] = function() } if (flags & (1 << 9)) rec["maxLen"] = reader.readInt(); + if (flags & (1 << 11)) + rec["MEOptions"] = reader.readInt(); res["Parents"].push(rec); } diff --git a/DesktopEditor/graphics/pro/js/wasm/src/drawingfile_test.cpp b/DesktopEditor/graphics/pro/js/wasm/src/drawingfile_test.cpp index 5f819e6efa..18f89e9c82 100644 --- a/DesktopEditor/graphics/pro/js/wasm/src/drawingfile_test.cpp +++ b/DesktopEditor/graphics/pro/js/wasm/src/drawingfile_test.cpp @@ -278,12 +278,6 @@ void ReadAnnot(BYTE* pWidgets, int& i) std::cout << "User ID " << std::string((char*)(pWidgets + i), nPathLength) << ", "; i += nPathLength; } - if (nFlags & (1 << 9)) - { - nPathLength = READ_INT(pWidgets + i); - i += 4; - std::cout << "MEOptions " << nPathLength << ", "; - } } void ReadInteractiveForms(BYTE* pWidgets, int& i) @@ -421,6 +415,12 @@ void ReadInteractiveForms(BYTE* pWidgets, int& i) i += 4; std::cout << "MaxLen " << nPathLength << ", "; } + if (nFlags & (1 << 11)) + { + nPathLength = READ_INT(pWidgets + i); + i += 4; + std::cout << "MEOptions " << nPathLength << ", "; + } std::cout << std::endl; } @@ -587,6 +587,12 @@ void ReadInteractiveForms(BYTE* pWidgets, int& i) std::cout << "OMetadata " << std::string((char*)(pWidgets + i), nPathLength) << ", "; i += nPathLength; } + if (nFlags & (1 << 21)) + { + nPathLength = READ_INT(pWidgets + i); + i += 4; + std::cout << "MEOptions " << nPathLength << ", "; + } //Action diff --git a/PdfFile/PdfWriter.cpp b/PdfFile/PdfWriter.cpp index 4adf4f6c89..85897ef36b 100644 --- a/PdfFile/PdfWriter.cpp +++ b/PdfFile/PdfWriter.cpp @@ -1907,9 +1907,6 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF bool bRender = (nFlags >> 6) & 1; if (nFlags & (1 << 7)) pAnnot->SetOUserID(oInfo.GetOUserID()); - bool bRenderCopy = (nFlags >> 8) & 1; - if (nFlags & (1 << 9)) - pAnnot->SetMEOptions(oInfo.GetMEOptions()); if (oInfo.IsMarkup()) { @@ -2216,17 +2213,6 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF pArray->Add(dPageH - dRD2); pStampAnnot->SetAPStream(pAP); } - else if (bRenderCopy) - { - int nID = oInfo.GetCopyAP(); - PdfWriter::CAnnotation* pAnnot2 = m_pDocument->GetAnnot(nID); - if (pAnnot2->GetAnnotationType() == PdfWriter::EAnnotType::AnnotStamp) - { - PdfWriter::CStampAnnotation* pStampAnnot2 = (PdfWriter::CStampAnnotation*)pAnnot2; - PdfWriter::CDictObject* pAPN = (PdfWriter::CDictObject*)pStampAnnot2->GetAPStream(); - pStampAnnot->SetAPStream(pAPN, true); - } - } pStampAnnot->SetRotate(nRotate); } @@ -2293,6 +2279,8 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF pWidgetAnnot->Remove("T"); if (nFlags & (1 << 20)) pWidgetAnnot->SetOMetadata(pPr->GetOMetadata()); + if (nFlags & (1 << 21)) + pWidgetAnnot->SetMEOptions(pPr->GetMEOptions()); const std::vector arrActions = pPr->GetActions(); for (CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget* pAction : arrActions) @@ -2898,6 +2886,8 @@ HRESULT CPdfWriter::EditWidgetParents(NSFonts::IApplicationFonts* pAppFonts, CWi } if (nFlags & (1 << 9)) pParentObj->Add("MaxLen", pParent->nMaxLen); + if (nFlags & (1 << 11)) + pParentObj->Add("MEOptions", pParent->nMEOptions); } std::vector arrBI = pFieldInfo->GetButtonImg(); diff --git a/PdfFile/SrcReader/PdfAnnot.cpp b/PdfFile/SrcReader/PdfAnnot.cpp index 55ff0409fe..00deff45c8 100644 --- a/PdfFile/SrcReader/PdfAnnot.cpp +++ b/PdfFile/SrcReader/PdfAnnot.cpp @@ -1487,6 +1487,14 @@ CAnnotWidget::CAnnotWidget(PDFDoc* pdfDoc, AcroFormField* pField, int nStartRefI // 20 - OO метаданные форм - OMetadata m_sOMetadata = DictLookupString(&oField, "OMetadata", 20); + // 21 - MEOptions + if (oField.dictLookup("MEOptions", &oObj)->isInt()) + { + m_unFlags |= (1 << 21); + m_unMEOptions = oObj.getInt(); + } + oObj.free(); + // Action - A Object oAction; if (oField.dictLookup("A", &oAction)->isDict()) @@ -2721,6 +2729,14 @@ void CAnnots::getParents(PDFDoc* pdfDoc, Object* oFieldRef, int nStartRefID) } oObj.free(); + // 11 - MEOptions + if (oField.dictLookup("MEOptions", &oObj)->isInt()) + { + pAnnotParent->unFlags |= (1 << 11); + pAnnotParent->unMEOptions = oObj.getInt(); + } + oObj.free(); + m_arrParents.push_back(pAnnotParent); Object oParentRefObj; @@ -3146,14 +3162,6 @@ CAnnot::CAnnot(PDFDoc* pdfDoc, AcroFormField* pField, int nStartRefID) delete s; } oObj.free(); - - // 9 - MEOptions - if (pField->fieldLookup("MEOptions", &oObj)->isInt()) - { - m_unAFlags |= (1 << 9); - m_unMEOptions = oObj.getInt(); - } - oObj.free(); } CAnnot::CAnnot(PDFDoc* pdfDoc, Object* oAnnotRef, int nPageIndex, int nStartRefID) { @@ -3281,14 +3289,6 @@ CAnnot::CAnnot(PDFDoc* pdfDoc, Object* oAnnotRef, int nPageIndex, int nStartRefI } oObj.free(); - // 9 - MEOptions - if (oAnnot.dictLookup("MEOptions", &oObj)->isInt()) - { - m_unAFlags |= (1 << 9); - m_unMEOptions = oObj.getInt(); - } - oObj.free(); - oAnnot.free(); } CAnnot::~CAnnot() @@ -3763,6 +3763,8 @@ void CAnnots::CAnnotParent::ToWASM(NSWasm::CData& oRes) } if (unFlags & (1 << 9)) oRes.AddInt(unMaxLen); + if (unFlags & (1 << 11)) + oRes.AddInt(unMEOptions); } void CAnnot::ToWASM(NSWasm::CData& oRes) { @@ -3793,8 +3795,6 @@ void CAnnot::ToWASM(NSWasm::CData& oRes) oRes.WriteString(m_sM); if (m_unAFlags & (1 << 7)) oRes.WriteString(m_sOUserID); - if (m_unAFlags & (1 << 9)) - oRes.AddInt(m_unMEOptions); } void CAnnot::CBorderType::ToWASM(NSWasm::CData& oRes) { @@ -3862,6 +3862,8 @@ void CAnnotWidget::ToWASM(NSWasm::CData& oRes) oRes.WriteString(m_sButtonFontName); if (m_unFlags & (1 << 20)) oRes.WriteString(m_sOMetadata); + if (m_unFlags & (1 << 21)) + oRes.AddInt(m_unMEOptions); oRes.AddInt(m_arrAction.size()); for (int i = 0; i < m_arrAction.size(); ++i) { diff --git a/PdfFile/SrcReader/PdfAnnot.h b/PdfFile/SrcReader/PdfAnnot.h index 68f89ce6c7..feee7aaa17 100644 --- a/PdfFile/SrcReader/PdfAnnot.h +++ b/PdfFile/SrcReader/PdfAnnot.h @@ -199,7 +199,6 @@ private: unsigned int m_unAnnotFlag; // Флаг аннотации - F unsigned int m_unRefNum; // Номер ссылки на объект unsigned int m_unPage; // Страница - unsigned int m_unMEOptions; // MEOptions std::pair m_pBE; // Эффекты границы std::string m_sContents; // Отображаемый текст std::string m_sNM; // Уникальное имя @@ -241,6 +240,7 @@ private: unsigned int m_unR; // Поворот аннотации относительно страницы - R unsigned int m_unRefNumParent; // Номер ссылки на объект родителя unsigned int m_unFontStyle; // Стиль шрифта - из DA + unsigned int m_unMEOptions; // MEOptions double m_dFontSize; // Размер шрифта - из DA std::vector m_arrTC; // Цвет текста - из DA std::vector m_arrBC; // Цвет границ - BC @@ -633,6 +633,7 @@ private: unsigned int unRefNum; // Номер ссылки на объект unsigned int unMaxLen; // Ограничение на максимальную длину text field unsigned int unFieldFlag; // Флаг Ff + unsigned int unMEOptions; // MEOptions unsigned int unRefNumParent; // Номер ссылки на объект родителя std::vector arrI; std::vector arrV; diff --git a/PdfFile/SrcWriter/Annotation.cpp b/PdfFile/SrcWriter/Annotation.cpp index a12d64fcba..ccd66d778f 100644 --- a/PdfFile/SrcWriter/Annotation.cpp +++ b/PdfFile/SrcWriter/Annotation.cpp @@ -240,10 +240,6 @@ namespace PdfWriter { Add("F", nAnnotFlag); } - void CAnnotation::SetMEOptions(const int& nMEOptions) - { - Add("MEOptions", nMEOptions); - } void CAnnotation::SetPage(CPage* pPage, double dW, double dH, double dX, double dY) { Add("P", pPage); @@ -1365,6 +1361,10 @@ namespace PdfWriter { m_nParentID = nParentID; } + void CWidgetAnnotation::SetMEOptions(const int& nMEOptions) + { + Add("MEOptions", nMEOptions); + } void CWidgetAnnotation::SetTU(const std::wstring& wsTU) { std::string sValue = U_TO_UTF8(wsTU); diff --git a/PdfFile/SrcWriter/Annotation.h b/PdfFile/SrcWriter/Annotation.h index cd86418623..d6b906a816 100644 --- a/PdfFile/SrcWriter/Annotation.h +++ b/PdfFile/SrcWriter/Annotation.h @@ -185,7 +185,6 @@ namespace PdfWriter void SetRect(const TRect& oRect); void SetBorder(BYTE nType, double dWidth, const std::vector& arrDash); void SetAnnotFlag(const int& nAnnotFlag); - void SetMEOptions(const int& nMEOptions); void SetPage(CPage* pPage, double dW = 0, double dH = 0, double dX = 0, double dY = 0); void SetBE(BYTE nType, const double& dBE); void SetContents(const std::wstring& wsText); @@ -460,6 +459,7 @@ namespace PdfWriter virtual void SetFlag (const int& nFlag); void SetParent(CDictObject* pParent); void SetParentID(int nParentID); + void SetMEOptions(const int& nMEOptions); void SetTU(const std::wstring& wsTU); void SetDS(const std::wstring& wsDS); void SetDV(const std::wstring& wsDV);