Epub images bug (xml files)

This commit is contained in:
Oleg Korshul
2019-05-08 12:46:09 +03:00
committed by Alexey Golubev
parent ea82bea6f1
commit f86055c713
2 changed files with 34 additions and 4 deletions

View File

@ -51,14 +51,26 @@
#include <stdio.h>
#endif
class CHtmlFile_Private
{
public:
bool m_bIsEpub;
public:
CHtmlFile_Private()
{
m_bIsEpub = false;
}
};
CHtmlFile::CHtmlFile()
{
m_internal = new CHtmlFile_Private();
}
CHtmlFile::~CHtmlFile()
{
RELEASEOBJECT(m_internal);
}
static std::wstring GetSdkPath()
@ -261,7 +273,20 @@ int CHtmlFile::Convert(const std::vector<std::wstring>& arFiles, const std::wstr
oBuilder.WriteEncodeXmlString(CorrectHtmlPath(sFilePath));
else
{
std::wstring sTmpFile = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSDirectory::GetTempPath(), L"HTM");
std::wstring sTmpDir = L"";
if (m_internal->m_bIsEpub)
{
// чтобы ссылки на картинки остались
sTmpDir = NSFile::GetDirectoryName(sFilePath);
if (!NSDirectory::Exists(sTmpDir))
sTmpDir = NSDirectory::GetTempPath();
}
else
{
sTmpDir = NSDirectory::GetTempPath();
}
std::wstring sTmpFile = NSFile::CFileBinary::CreateTempFileWithUniqueName(sTmpDir, L"HTM");
if (NSFile::CFileBinary::Exists(sTmpFile))
NSFile::CFileBinary::Remove(sTmpFile);
@ -665,7 +690,10 @@ int CHtmlFile::ConvertEpub(const std::wstring& sFolder, std::wstring& sMetaInfo,
if (arHtmls.size() == 0)
return 1;
return this->Convert(arHtmls, sDstfolder, sPathInternal);
m_internal->m_bIsEpub = true;
int nErr = this->Convert(arHtmls, sDstfolder, sPathInternal);
m_internal->m_bIsEpub = false;
return nErr;
}
/////////////////////////////////////////////////////////////////