mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-19 05:57:25 +08:00
fix update GetInfo
This commit is contained in:
@ -516,9 +516,16 @@ return 0;
|
||||
std::string sPathUtf8Old = U_TO_UTF8(m_pInternal->m_wsSrcPath);
|
||||
if (sPathUtf8Old == sPathUtf8New || NSSystemPath::NormalizePath(sPathUtf8Old) == NSSystemPath::NormalizePath(sPathUtf8New))
|
||||
{
|
||||
if (!m_pInternal->m_pPDFDocument->makeWritable())
|
||||
if (!m_pInternal->m_pPDFDocument->makeWritable(true))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
if (!oFile.OpenFile(wsPath, true))
|
||||
return false;
|
||||
oFile.CloseFile();
|
||||
}
|
||||
|
||||
m_pInternal->m_pPdfWriter = (CPdfRenderer*)pPdfWriter;
|
||||
m_pInternal->m_pPdfWriter->AddRef();
|
||||
@ -585,11 +592,11 @@ return 0;
|
||||
{
|
||||
Object encrypt, ID, ID1;
|
||||
if (pTrailerDict->dictLookup("Encrypt", &encrypt) && encrypt.isDict())
|
||||
sEncrypt = XMLConverter::DictToXml(L"Encrypt", &encrypt, true);
|
||||
sEncrypt = XMLConverter::DictToXml(L"Encrypt", &encrypt, 0, 0, true);
|
||||
encrypt.free();
|
||||
|
||||
if (pTrailerDict->dictLookup("ID", &ID) && ID.isArray() && ID.arrayGet(0, &ID1) && ID1.isString())
|
||||
sEncrypt += XMLConverter::DictToXml(L"ID", &ID1, true);
|
||||
sEncrypt += XMLConverter::DictToXml(L"ID", &ID1, 0, 0, true);
|
||||
ID.free();
|
||||
ID1.free();
|
||||
}
|
||||
@ -664,7 +671,17 @@ return 0;
|
||||
sInfo = XMLConverter::DictToXml(L"Info", &info);
|
||||
info.free();
|
||||
|
||||
return m_pInternal->m_pPdfWriter->EditClose(sTrailer, sInfo);
|
||||
bool bRes = m_pInternal->m_pPdfWriter->EditClose(sTrailer, sInfo);
|
||||
bRes &= m_pInternal->m_pPDFDocument->makeWritable(false);
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
if (oFile.OpenFile(m_pInternal->m_wsSrcPath))
|
||||
{
|
||||
m_pInternal->m_nFileLength = oFile.GetFileSize();
|
||||
oFile.CloseFile();
|
||||
}
|
||||
|
||||
return bRes;
|
||||
}
|
||||
|
||||
#define DICT_LOOKUP(sName, wsName) \
|
||||
|
||||
@ -672,7 +672,7 @@ char *PDFDoc::getEmbeddedFileMem(int idx, int *size) {
|
||||
return buf;
|
||||
}
|
||||
|
||||
GBool PDFDoc::makeWritable()
|
||||
GBool PDFDoc::makeWritable(bool bWritable)
|
||||
{
|
||||
if (!str || !file)
|
||||
return gFalse;
|
||||
@ -680,10 +680,10 @@ GBool PDFDoc::makeWritable()
|
||||
|
||||
if (optContent)
|
||||
delete optContent;
|
||||
#ifndef DISABLE_OUTLINE
|
||||
#ifndef DISABLE_OUTLINE
|
||||
if (outline)
|
||||
delete outline;
|
||||
#endif
|
||||
#endif
|
||||
if (catalog)
|
||||
delete catalog;
|
||||
if (xref)
|
||||
@ -715,22 +715,28 @@ GBool PDFDoc::makeWritable()
|
||||
// NB: _wfopen is only available in NT
|
||||
version.dwOSVersionInfoSize = sizeof(version);
|
||||
GetVersionEx(&version);
|
||||
if (version.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
||||
{
|
||||
file = _wfopen(fileNameU, L"rb+");
|
||||
}
|
||||
else
|
||||
{
|
||||
file = fopen(fileName->getCString(), "rb+");
|
||||
}
|
||||
#elif defined(VMS)
|
||||
file = fopen(fileName->getCString(), "rb+", "ctx=stm");
|
||||
#else
|
||||
file = fopen(fileName->getCString(), "rb+");
|
||||
#endif
|
||||
|
||||
if (bWritable)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
if (version.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
||||
{
|
||||
file = _wfopen(fileNameU, L"rb+");
|
||||
}
|
||||
else
|
||||
{
|
||||
file = fopen(fileName->getCString(), "rb+");
|
||||
}
|
||||
#elif defined(VMS)
|
||||
file = fopen(fileName->getCString(), "rb+", "ctx=stm");
|
||||
#else
|
||||
file = fopen(fileName->getCString(), "rb+");
|
||||
#endif
|
||||
}
|
||||
|
||||
GBool bRes = gTrue;
|
||||
if (!file)
|
||||
if (!bWritable || !file)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
if (version.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
||||
@ -753,7 +759,7 @@ GBool PDFDoc::makeWritable()
|
||||
errCode = errOpenFile;
|
||||
return gFalse;
|
||||
}
|
||||
bRes = gFalse;
|
||||
bRes = (!bWritable ? gTrue : gFalse);
|
||||
}
|
||||
|
||||
Object obj;
|
||||
|
||||
@ -190,7 +190,7 @@ public:
|
||||
GBool saveEmbeddedFile(int idx, const wchar_t *path, int pathLen);
|
||||
#endif
|
||||
char *getEmbeddedFileMem(int idx, int *size);
|
||||
GBool makeWritable();
|
||||
GBool makeWritable(bool bWritable);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user