Fix bug 72142

This commit is contained in:
Alexey Nagaev
2024-12-17 17:42:42 +03:00
committed by Oleg Korshul
parent 695fd3ba1c
commit 5d83d912fc
2 changed files with 53 additions and 32 deletions

View File

@ -33,6 +33,9 @@ CFormatsList& CFormatsList::operator=(const CFormatsList& list)
for(auto& val : list.m_images)
m_images.push_back(val);
for(auto& val : list.m_draw)
m_draw.push_back(val);
for(auto& val : list.m_crossplatform)
m_crossplatform.push_back(val);
@ -56,6 +59,10 @@ std::vector<std::wstring> CFormatsList::GetCrossplatform() const
{
return m_crossplatform;
}
std::vector<std::wstring> CFormatsList::GetDraw() const
{
return m_draw;
}
std::vector<std::wstring> CFormatsList::GetImages() const
{
return m_images;
@ -81,6 +88,10 @@ bool CFormatsList::IsCrossplatform(const std::wstring& ext) const
{
return std::find(m_crossplatform.begin(), m_crossplatform.end(), ext) != m_crossplatform.end();
}
bool CFormatsList::IsDraw(const std::wstring& ext) const
{
return std::find(m_draw.begin(), m_draw.end(), ext) != m_draw.end();
}
bool CFormatsList::IsImage(const std::wstring& ext) const
{
return std::find(m_images.begin(), m_images.end(), ext) != m_images.end();
@ -91,7 +102,7 @@ bool CFormatsList::IsPdf(const std::wstring& ext) const
}
bool CFormatsList::IsAny(const std::wstring& ext) const
{
return IsDocument(ext) || IsPresentation(ext) || IsSpreadsheet(ext) || IsCrossplatform(ext) || IsImage(ext) || IsPdf(ext);
return IsDocument(ext) || IsPresentation(ext) || IsSpreadsheet(ext) || IsCrossplatform(ext) || IsImage(ext) || IsPdf(ext) || IsDraw(ext);
}
void CFormatsList::AddDocument(const std::wstring& ext)
@ -110,6 +121,10 @@ void CFormatsList::AddCrossplatform(const std::wstring& ext)
{
m_crossplatform.push_back(ext);
}
void CFormatsList::AddDraw(const std::wstring& ext)
{
m_draw.push_back(ext);
}
void CFormatsList::AddImage(const std::wstring& ext)
{
m_images.push_back(ext);
@ -134,6 +149,9 @@ std::vector<std::wstring> CFormatsList::GetAllExts() const
for (const auto& val : m_crossplatform)
all_formats.push_back(val);
for (const auto& val : m_draw)
all_formats.push_back(val);
if (!m_pdf.empty())
all_formats.push_back(m_pdf);
@ -204,8 +222,7 @@ CFormatsList CFormatsList::GetDefaultExts()
list.m_crossplatform.push_back(L"djvu");
list.m_crossplatform.push_back(L"xps");
// list.m_images.push_back(L"jpg");
// list.m_images.push_back(L"png");
list.m_draw.push_back(L"vsdx");
list.m_pdf = L"pdf";
@ -321,12 +338,12 @@ Cx2tTester::Cx2tTester(const std::wstring& configPath)
time_t now = time(0);
std::tm* time = std::localtime(&now);
std::wstring timestamp =
std::to_wstring(time->tm_mday) + L"_" +
std::to_wstring(time->tm_mon + 1) + L"_" +
std::to_wstring(time->tm_year + 1900) + L"_" +
std::to_wstring(time->tm_hour) + L"_" +
std::to_wstring(time->tm_min) + L"_" +
std::to_wstring(time->tm_sec);
std::to_wstring(time->tm_mday) + L"_" +
std::to_wstring(time->tm_mon + 1) + L"_" +
std::to_wstring(time->tm_year + 1900) + L"_" +
std::to_wstring(time->tm_hour) + L"_" +
std::to_wstring(time->tm_min) + L"_" +
std::to_wstring(time->tm_sec);
std::wstring report_ext = NSFile::GetFileExtention(m_reportFile);
m_reportFile = m_reportFile.substr(0, m_reportFile.size() - report_ext.size() - 1);
@ -509,8 +526,8 @@ void Cx2tTester::Start()
// if no format in input formats - skip
if(std::find(m_inputExts.begin(), m_inputExts.end(), input_ext) == m_inputExts.end()
|| (std::find(m_inputFiles.begin(), m_inputFiles.end(), input_filename) == m_inputFiles.end()
&& !m_inputFiles.empty()))
|| (std::find(m_inputFiles.begin(), m_inputFiles.end(), input_filename) == m_inputFiles.end()
&& !m_inputFiles.empty()))
{
files.erase(files.begin() + i);
i--;
@ -607,7 +624,7 @@ void Cx2tTester::Convert(const std::vector<std::wstring>& files, bool bNoDirecto
// takes full directory after input folder
std::wstring input_subfolders = input_file_directory.substr(m_inputDirectory.size(),
input_file_directory.size() - m_inputDirectory.size());
input_file_directory.size() - m_inputDirectory.size());
std::wstring output_files_directory = m_outputDirectory + input_subfolders;
if(!bNoDirectory)
@ -620,22 +637,22 @@ void Cx2tTester::Convert(const std::vector<std::wstring>& files, bool bNoDirecto
{
// documents -> documents
if(((m_outputFormatsList.IsDocument(ext) && m_inputFormatsList.IsDocument(input_ext))
// spreadsheets -> spreadsheets
|| (m_outputFormatsList.IsSpreadsheet(ext) && m_inputFormatsList.IsSpreadsheet(input_ext))
//presentations -> presentations
|| (m_outputFormatsList.IsPresentation(ext) && m_inputFormatsList.IsPresentation(input_ext))
// xps -> docx
|| (ext == L"docx" && input_ext == L"xps")
// pdf -> docx
|| (ext == L"docx" && m_inputFormatsList.IsPdf(input_ext))
// all formats -> images
|| m_outputFormatsList.IsImage(ext)
// all formats -> pdf
|| m_outputFormatsList.IsPdf(ext))
// input format != output format
&& ext != input_ext
// any good input ext
&& m_inputFormatsList.IsAny(input_ext))
// spreadsheets -> spreadsheets
|| (m_outputFormatsList.IsSpreadsheet(ext) && m_inputFormatsList.IsSpreadsheet(input_ext))
//presentations -> presentations
|| (m_outputFormatsList.IsPresentation(ext) && m_inputFormatsList.IsPresentation(input_ext))
// xps -> docx
|| (ext == L"docx" && input_ext == L"xps")
// pdf -> docx
|| (ext == L"docx" && m_inputFormatsList.IsPdf(input_ext))
// all formats -> images
|| m_outputFormatsList.IsImage(ext)
// all formats -> pdf
|| m_outputFormatsList.IsPdf(ext))
// input format != output format
&& ext != input_ext
// any good input ext
&& m_inputFormatsList.IsAny(input_ext))
{
output_file_exts.push_back(ext);
}
@ -653,8 +670,8 @@ void Cx2tTester::Convert(const std::vector<std::wstring>& files, bool bNoDirecto
// setup csv & txt additional params
if(m_bIsFilenameCsvTxtParams
|| input_ext == L"txt"
|| input_ext == L"csv")
|| input_ext == L"txt"
|| input_ext == L"csv")
{
std::wstring find_str = L"[cp";
size_t pos1 = input_filename.find(find_str);
@ -741,7 +758,7 @@ void Cx2tTester::Extract(const std::vector<std::wstring>& files)
std::wstring input_filename = NSFile::GetFileName(input_file);
std::wstring input_file_directory = NSFile::GetDirectoryName(input_file);
std::wstring input_subfolders = input_file_directory.substr(m_inputDirectory.size(),
input_file_directory.size() - m_inputDirectory.size());
input_file_directory.size() - m_inputDirectory.size());
std::wstring output_files_directory = m_outputDirectory + input_subfolders + FILE_SEPARATOR_STR + input_filename;
if(!NSDirectory::Exists(output_files_directory))
@ -972,7 +989,7 @@ DWORD CConverter::ThreadProc()
std::wstring xml_params_file = m_outputFilesDirectory + FILE_SEPARATOR_STR + xml_params_filename;
std::wstring output_file = m_outputFilesDirectory
+ FILE_SEPARATOR_STR + input_filename_no_ext + output_ext;
+ FILE_SEPARATOR_STR + input_filename_no_ext + output_ext;
std::wstring output_filename = NSFile::GetFileName(output_file);

View File

@ -32,6 +32,7 @@ public:
std::vector<std::wstring> GetPresentations() const;
std::vector<std::wstring> GetSpreadsheets() const;
std::vector<std::wstring> GetCrossplatform() const;
std::vector<std::wstring> GetDraw() const;
std::vector<std::wstring> GetImages() const;
std::wstring GetPdf() const;
@ -39,6 +40,7 @@ public:
bool IsPresentation(const std::wstring& ext) const;
bool IsSpreadsheet(const std::wstring& ext) const;
bool IsCrossplatform(const std::wstring& ext) const;
bool IsDraw(const std::wstring& ext) const;
bool IsImage(const std::wstring& ext) const;
bool IsPdf(const std::wstring& ext) const;
bool IsAny(const std::wstring& ext) const;
@ -47,6 +49,7 @@ public:
void AddPresentation(const std::wstring& ext);
void AddSpreadsheet(const std::wstring& ext);
void AddCrossplatform(const std::wstring& ext);
void AddDraw(const std::wstring& ext);
void AddImage(const std::wstring& ext);
std::vector<std::wstring> GetAllExts() const;
@ -66,6 +69,7 @@ private:
std::vector<std::wstring> m_spreadsheets;
std::vector<std::wstring> m_crossplatform;
std::vector<std::wstring> m_images;
std::vector<std::wstring> m_draw;
std::wstring m_pdf;
};