fix don't makeWritable different files

This commit is contained in:
Kulikova Svetlana
2022-07-29 13:26:46 +03:00
parent 31158a5f5b
commit 2e820186b5
5 changed files with 30 additions and 10 deletions

View File

@ -680,18 +680,25 @@ return 0;
sInfo = XMLConverter::DictToXml(L"Info", &info);
info.free();
std::wstring wsPath = m_pInternal->m_pPdfWriter->GetEditPdfPath();
bool bRes = m_pInternal->m_pPdfWriter->EditClose(sTrailer, sInfo);
GString* owner_pswd = NSStrings::CreateString(sPassword);
GString* user_pswd = NSStrings::CreateString(sPassword);
bRes &= m_pInternal->m_pPDFDocument->makeWritable(false, owner_pswd, user_pswd);
delete owner_pswd;
delete user_pswd;
NSFile::CFileBinary oFile;
if (oFile.OpenFile(m_pInternal->m_wsSrcPath))
std::string sPathUtf8New = U_TO_UTF8(wsPath);
std::string sPathUtf8Old = U_TO_UTF8(m_pInternal->m_wsSrcPath);
if (sPathUtf8Old == sPathUtf8New || NSSystemPath::NormalizePath(sPathUtf8Old) == NSSystemPath::NormalizePath(sPathUtf8New))
{
m_pInternal->m_nFileLength = oFile.GetFileSize();
oFile.CloseFile();
GString* owner_pswd = NSStrings::CreateString(sPassword);
GString* user_pswd = NSStrings::CreateString(sPassword);
bRes &= m_pInternal->m_pPDFDocument->makeWritable(false, owner_pswd, user_pswd);
delete owner_pswd;
delete user_pswd;
NSFile::CFileBinary oFile;
if (oFile.OpenFile(m_pInternal->m_wsSrcPath))
{
m_pInternal->m_nFileLength = oFile.GetFileSize();
oFile.CloseFile();
}
}
return bRes;