From dc47903ceb8be0d081d7231e5a32df62953aa111 Mon Sep 17 00:00:00 2001 From: Kulikova Svetlana Date: Thu, 20 Jul 2023 12:55:31 +0300 Subject: [PATCH] fix CA and without annots --- .../graphics/pro/js/wasm/src/drawingfile.cpp | 119 +++++++++--------- PdfFile/PdfReader.cpp | 6 +- 2 files changed, 64 insertions(+), 61 deletions(-) diff --git a/DesktopEditor/graphics/pro/js/wasm/src/drawingfile.cpp b/DesktopEditor/graphics/pro/js/wasm/src/drawingfile.cpp index c2dd2e8859..8ed72bba5d 100644 --- a/DesktopEditor/graphics/pro/js/wasm/src/drawingfile.cpp +++ b/DesktopEditor/graphics/pro/js/wasm/src/drawingfile.cpp @@ -552,67 +552,70 @@ int main(int argc, char* argv[]) int i = 4; nLength -= 4; - DWORD nCOLength = READ_INT(pWidgets + i); - i += 4; - if (nCOLength > 0) - std::cout << "CO "; - for (int j = 0; j < nCOLength; ++j) + if (i < nLength) { - DWORD nPathLength = READ_INT(pWidgets + i); + DWORD nCOLength = READ_INT(pWidgets + i); i += 4; - std::cout << std::string((char*)(pWidgets + i), nPathLength) << ", "; - i += nPathLength; + if (nCOLength > 0) + std::cout << "CO "; + for (int j = 0; j < nCOLength; ++j) + { + DWORD nPathLength = READ_INT(pWidgets + i); + i += 4; + std::cout << std::string((char*)(pWidgets + i), nPathLength) << ", "; + i += nPathLength; + } + if (nCOLength > 0) + std::cout << std::endl; + + DWORD nParentsLength = READ_INT(pWidgets + i); + i += 4; + if (nParentsLength > 0) + std::cout << "Parents" << std::endl; + for (int j = 0; j < nParentsLength; ++j) + { + DWORD nPathLength = READ_INT(pWidgets + i); + i += 4; + std::cout << "# " << nPathLength << ", "; + + nPathLength = READ_INT(pWidgets + i); + i += 4; + std::cout << "Flags " << nPathLength << ", "; + int nFlags = nPathLength; + + if (nFlags & (1 << 0)) + { + nPathLength = READ_INT(pWidgets + i); + i += 4; + std::cout << "T " << std::string((char*)(pWidgets + i), nPathLength) << ", "; + i += nPathLength; + } + if (nFlags & (1 << 1)) + { + nPathLength = READ_INT(pWidgets + i); + i += 4; + std::cout << "V " << std::string((char*)(pWidgets + i), nPathLength) << ", "; + i += nPathLength; + } + if (nFlags & (1 << 2)) + { + nPathLength = READ_INT(pWidgets + i); + i += 4; + std::cout << "DV " << std::string((char*)(pWidgets + i), nPathLength) << ", "; + i += nPathLength; + } + if (nFlags & (1 << 3)) + { + nPathLength = READ_INT(pWidgets + i); + i += 4; + std::cout << "Parent " << nPathLength; + } + + std::cout << std::endl; + } + if (nParentsLength > 0) + std::cout << std::endl; } - if (nCOLength > 0) - std::cout << std::endl; - - DWORD nParentsLength = READ_INT(pWidgets + i); - i += 4; - if (nParentsLength > 0) - std::cout << "Parents" << std::endl; - for (int j = 0; j < nParentsLength; ++j) - { - DWORD nPathLength = READ_INT(pWidgets + i); - i += 4; - std::cout << "# " << nPathLength << ", "; - - nPathLength = READ_INT(pWidgets + i); - i += 4; - std::cout << "Flags " << nPathLength << ", "; - int nFlags = nPathLength; - - if (nFlags & (1 << 0)) - { - nPathLength = READ_INT(pWidgets + i); - i += 4; - std::cout << "T " << std::string((char*)(pWidgets + i), nPathLength) << ", "; - i += nPathLength; - } - if (nFlags & (1 << 1)) - { - nPathLength = READ_INT(pWidgets + i); - i += 4; - std::cout << "V " << std::string((char*)(pWidgets + i), nPathLength) << ", "; - i += nPathLength; - } - if (nFlags & (1 << 2)) - { - nPathLength = READ_INT(pWidgets + i); - i += 4; - std::cout << "DV " << std::string((char*)(pWidgets + i), nPathLength) << ", "; - i += nPathLength; - } - if (nFlags & (1 << 3)) - { - nPathLength = READ_INT(pWidgets + i); - i += 4; - std::cout << "Parent " << nPathLength; - } - - std::cout << std::endl; - } - if (nParentsLength > 0) - std::cout << std::endl; while (i < nLength) { diff --git a/PdfFile/PdfReader.cpp b/PdfFile/PdfReader.cpp index 9793017d66..7f5feea570 100644 --- a/PdfFile/PdfReader.cpp +++ b/PdfFile/PdfReader.cpp @@ -1191,7 +1191,7 @@ BYTE* CPdfReader::GetWidgets() // Родительские Fields int nParentsPos = oRes.GetSize(); - int nParents = 0; + size_t nParents = 0; oRes.AddInt(nParents); std::vector arrParents; for (int i = 0, nNum = pAcroForms->getNumFields(); i < nNum; ++i) @@ -1568,7 +1568,7 @@ oObj.free();\ } else { - unsigned int nStyle = (oType == acroFormFieldRadioButton ? 3 : 0); + BYTE nStyle = (oType == acroFormFieldRadioButton ? 3 : 0); if (oMK.dictLookup("CA", &oObj)->isString()) { std::string sCA(oObj.getString()->getCString()); @@ -1587,7 +1587,7 @@ oObj.free();\ nStyle = 4; } oObj.free(); - oRes.AddInt(nStyle); + oRes.WriteBYTE(nStyle); } // 14 - Положение заголовка - TP