diff --git a/Test/Applications/x2tTester/README.md b/Test/Applications/x2tTester/README.md
index 9cc8babc57..0fc7d3c21b 100644
--- a/Test/Applications/x2tTester/README.md
+++ b/Test/Applications/x2tTester/README.md
@@ -27,6 +27,9 @@ You need to create an xml configuration file. It must contain:
# (non-required) is delete successful conversions files (default - 0)
+ # (non-required) trough conversion (format) -> (*t format) -> (output formats) (default - 0). Directory with *t files - outputDirectory/_t.
+
+
# (non-required) timestamp in report file name (default - 1)
diff --git a/Test/Applications/x2tTester/x2tTester.cpp b/Test/Applications/x2tTester/x2tTester.cpp
index 3969256cbc..3eef2e3b27 100644
--- a/Test/Applications/x2tTester/x2tTester.cpp
+++ b/Test/Applications/x2tTester/x2tTester.cpp
@@ -8,189 +8,126 @@ class CConverter;
CFormatsList::CFormatsList()
{
}
+CFormatsList::CFormatsList(const CFormatsList& list)
+{
+ *this = list;
+}
-std::vector CFormatsList::GetDocuments() const
+CFormatsList& CFormatsList::operator=(const CFormatsList& list)
+{
+ m_documents.clear();
+ m_presentations.clear();
+ m_spreadsheets.clear();
+ m_images.clear();
+ m_crossplatform.clear();
+
+ for(auto& val : list.m_documents)
+ m_documents.push_back(val);
+
+ for(auto& val : list.m_presentations)
+ m_presentations.push_back(val);
+
+ for(auto& val : list.m_spreadsheets)
+ m_spreadsheets.push_back(val);
+
+ for(auto& val : list.m_images)
+ m_images.push_back(val);
+
+ for(auto& val : list.m_crossplatform)
+ m_crossplatform.push_back(val);
+
+ m_pdf = list.m_pdf;
+ return *this;
+}
+
+std::vector CFormatsList::GetDocuments() const
{
return m_documents;
}
-std::vector CFormatsList::GetPresentations() const
+std::vector CFormatsList::GetPresentations() const
{
return m_presentations;
}
-std::vector CFormatsList::GetSpreadsheets() const
+std::vector CFormatsList::GetSpreadsheets() const
{
return m_spreadsheets;
}
-std::vector CFormatsList::GetCrossplatform() const
+std::vector CFormatsList::GetCrossplatform() const
{
return m_crossplatform;
}
-std::vector CFormatsList::GetImages() const
+std::vector CFormatsList::GetImages() const
{
return m_images;
}
-int CFormatsList::GetPdf() const
+std::wstring CFormatsList::GetPdf() const
{
return m_pdf;
}
-bool CFormatsList::IsDocument(int format) const
+bool CFormatsList::IsDocument(const std::wstring& ext) const
{
- return std::find(m_documents.begin(), m_documents.end(), format) != m_documents.end();
+ return std::find(m_documents.begin(), m_documents.end(), ext) != m_documents.end();
}
-bool CFormatsList::IsPresentation(int format) const
+bool CFormatsList::IsPresentation(const std::wstring& ext) const
{
- return std::find(m_presentations.begin(), m_presentations.end(), format) != m_presentations.end();
+ return std::find(m_presentations.begin(), m_presentations.end(), ext) != m_presentations.end();
}
-bool CFormatsList::IsSpreadsheet(int format) const
+bool CFormatsList::IsSpreadsheet(const std::wstring& ext) const
{
- return std::find(m_spreadsheets.begin(), m_spreadsheets.end(), format) != m_spreadsheets.end();
+ return std::find(m_spreadsheets.begin(), m_spreadsheets.end(), ext) != m_spreadsheets.end();
}
-bool CFormatsList::IsCrossplatform(int format) const
+bool CFormatsList::IsCrossplatform(const std::wstring& ext) const
{
- return std::find(m_crossplatform.begin(), m_crossplatform.end(), format) != m_crossplatform.end();
+ return std::find(m_crossplatform.begin(), m_crossplatform.end(), ext) != m_crossplatform.end();
}
-bool CFormatsList::IsImage(int format) const
+bool CFormatsList::IsImage(const std::wstring& ext) const
{
- return std::find(m_images.begin(), m_images.end(), format) != m_images.end();
+ return std::find(m_images.begin(), m_images.end(), ext) != m_images.end();
}
-bool CFormatsList::IsPdf(int format) const
+bool CFormatsList::IsPdf(const std::wstring& ext) const
{
- return format == m_pdf;
+ return ext == m_pdf;
}
-void CFormatsList::SetDefault()
+void CFormatsList::AddDocument(const std::wstring& ext)
{
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_RTF);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_EPUB);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_FB2);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_MOBI);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTX);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTM);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT_FLAT);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC_FLAT);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX_FLAT);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML_IN_CONTAINER);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX_PACKAGE);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_OTT);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCXF);
-
- m_presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX);
- m_presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT);
- m_presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP);
- m_presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSX);
- m_presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTM);
- m_presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSM);
- m_presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_POTX);
- m_presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_POTM);
- m_presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP_FLAT);
- m_presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_OTP);
- m_presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX_PACKAGE);
-
- m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX);
- m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS);
- m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS);
- m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV);
- m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM);
- m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTX);
- m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTM);
- m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSB);
- m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS_FLAT);
- m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS);
- m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_FLAT);
- m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_PACKAGE);
-
- m_crossplatform.push_back(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_DJVU);
- m_crossplatform.push_back(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS);
-
- m_images.push_back(AVS_OFFICESTUDIO_FILE_IMAGE_JPG);
- m_images.push_back(AVS_OFFICESTUDIO_FILE_IMAGE_PNG);
-
- m_pdf = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF;
+ m_documents.push_back(ext);
+}
+void CFormatsList::AddPresentation(const std::wstring& ext)
+{
+ m_presentations.push_back(ext);
+}
+void CFormatsList::AddSpreadsheet(const std::wstring& ext)
+{
+ m_spreadsheets.push_back(ext);
+}
+void CFormatsList::AddCrossplatform(const std::wstring& ext)
+{
+ m_crossplatform.push_back(ext);
+}
+void CFormatsList::AddImage(const std::wstring& ext)
+{
+ m_images.push_back(ext);
}
-void CFormatsList::SetOutput()
+std::vector CFormatsList::GetAllExts() const
{
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX);
-// m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_RTF);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML);
-// m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_EPUB);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_FB2);
-// m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_MOBI);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTX);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTM);
-// m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT_FLAT);
-// m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC_FLAT);
-// m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX_FLAT);
-// m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML_IN_CONTAINER);
-// m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX_PACKAGE);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_OTT);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM);
- m_documents.push_back(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCXF);
+ std::vector all_formats;
- m_presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX);
-// m_presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT);
- m_presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP);
- m_presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSX);
- m_presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTM);
- m_presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSM);
- m_presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_POTX);
- m_presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_POTM);
-// m_presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP_FLAT);
- m_presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_OTP);
-// presentations.push_back(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX_PACKAGE);
-
- m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX);
-// m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS);
- m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS);
- m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV);
- m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM);
- m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTX);
- m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTM);
-// m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSB);
-// m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS_FLAT);
- m_spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS);
-// spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_FLAT);
-// spreadsheets.push_back(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_PACKAGE);
-
- m_crossplatform.push_back(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_DJVU);
- m_crossplatform.push_back(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS);
-
- m_images.push_back(AVS_OFFICESTUDIO_FILE_IMAGE_JPG);
- m_images.push_back(AVS_OFFICESTUDIO_FILE_IMAGE_PNG);
-
- m_pdf = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF;
-}
-std::vector CFormatsList::AllFormats() const
-{
- std::vector all_formats;
-
- for(auto val : m_documents)
+ for(auto& val : m_documents)
all_formats.push_back(val);
- for(auto val : m_presentations)
+ for(auto& val : m_presentations)
all_formats.push_back(val);
- for(auto val : m_spreadsheets)
+ for(auto& val : m_spreadsheets)
all_formats.push_back(val);
- for(auto val : m_images)
+ for(auto& val : m_images)
all_formats.push_back(val);
- for(auto val : m_crossplatform)
+ for(auto& val : m_crossplatform)
all_formats.push_back(val);
all_formats.push_back(m_pdf);
@@ -198,6 +135,126 @@ std::vector CFormatsList::AllFormats() const
return all_formats;
}
+CFormatsList CFormatsList::GetDefaultExts()
+{
+ CFormatsList list;
+
+ list.m_documents.push_back(L"doct");
+ list.m_documents.push_back(L"doc");
+ list.m_documents.push_back(L"docm");
+ list.m_documents.push_back(L"docx");
+ list.m_documents.push_back(L"docxf");
+ list.m_documents.push_back(L"dot");
+ list.m_documents.push_back(L"dotm");
+ list.m_documents.push_back(L"dotx");
+ list.m_documents.push_back(L"epub");
+ list.m_documents.push_back(L"fb2");
+ list.m_documents.push_back(L"fodt");
+ list.m_documents.push_back(L"htm");
+ list.m_documents.push_back(L"html");
+ list.m_documents.push_back(L"mht");
+ list.m_documents.push_back(L"odt");
+ list.m_documents.push_back(L"ott");
+ list.m_documents.push_back(L"oxps");
+ list.m_documents.push_back(L"rtf");
+ list.m_documents.push_back(L"stw");
+ list.m_documents.push_back(L"sxw");
+ list.m_documents.push_back(L"txt");
+ list.m_documents.push_back(L"wps");
+ list.m_documents.push_back(L"wpt");
+
+ list.m_presentations.push_back(L"pptt");
+ list.m_presentations.push_back(L"dps");
+ list.m_presentations.push_back(L"dpt");
+ list.m_presentations.push_back(L"fodp");
+ list.m_presentations.push_back(L"odp");
+ list.m_presentations.push_back(L"otp");
+ list.m_presentations.push_back(L"pot");
+ list.m_presentations.push_back(L"potm");
+ list.m_presentations.push_back(L"potx");
+ list.m_presentations.push_back(L"pps");
+ list.m_presentations.push_back(L"ppsm");
+ list.m_presentations.push_back(L"ppsx");
+ list.m_presentations.push_back(L"ppt");
+ list.m_presentations.push_back(L"pptm");
+ list.m_presentations.push_back(L"pptx");
+ list.m_presentations.push_back(L"sxi");
+
+ list.m_spreadsheets.push_back(L"xlst");
+ list.m_spreadsheets.push_back(L"csv");
+ list.m_spreadsheets.push_back(L"et");
+ list.m_spreadsheets.push_back(L"ett");
+ list.m_spreadsheets.push_back(L"fods");
+ list.m_spreadsheets.push_back(L"ods");
+ list.m_spreadsheets.push_back(L"ots");
+ list.m_spreadsheets.push_back(L"sxc");
+ list.m_spreadsheets.push_back(L"xls");
+ list.m_spreadsheets.push_back(L"xlsb");
+ list.m_spreadsheets.push_back(L"xlsm");
+ list.m_spreadsheets.push_back(L"xlsx");
+ list.m_spreadsheets.push_back(L"xlt");
+ list.m_spreadsheets.push_back(L"xltm");
+ list.m_spreadsheets.push_back(L"xltx");
+
+ 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_pdf = L"pdf";
+
+ return list;
+}
+
+CFormatsList CFormatsList::GetOutputExts()
+{
+ CFormatsList list;
+
+ list.m_documents.push_back(L"doct");
+ list.m_documents.push_back(L"docm");
+ list.m_documents.push_back(L"docx");
+ list.m_documents.push_back(L"docxf");
+ list.m_documents.push_back(L"dotm");
+ list.m_documents.push_back(L"dotx");
+ list.m_documents.push_back(L"epub");
+ list.m_documents.push_back(L"fb2");
+ list.m_documents.push_back(L"html");
+ list.m_documents.push_back(L"odt");
+ list.m_documents.push_back(L"ott");
+ list.m_documents.push_back(L"rtf");
+ list.m_documents.push_back(L"txt");
+
+ list.m_presentations.push_back(L"pptt");
+ list.m_presentations.push_back(L"odp");
+ list.m_presentations.push_back(L"otp");
+ list.m_presentations.push_back(L"potm");
+ list.m_presentations.push_back(L"potx");
+ list.m_presentations.push_back(L"ppsm");
+ list.m_presentations.push_back(L"ppsx");
+ list.m_presentations.push_back(L"pptm");
+ list.m_presentations.push_back(L"pptx");
+
+ list.m_spreadsheets.push_back(L"xlst");
+ list.m_spreadsheets.push_back(L"csv");
+ list.m_spreadsheets.push_back(L"ods");
+ list.m_spreadsheets.push_back(L"ots");
+ list.m_spreadsheets.push_back(L"xlsm");
+ list.m_spreadsheets.push_back(L"xlsx");
+ list.m_spreadsheets.push_back(L"xltm");
+ list.m_spreadsheets.push_back(L"xltx");
+
+ 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_pdf = L"pdf";
+
+ return list;
+}
+
Cx2tTester::Cx2tTester(const std::wstring& configPath)
{
m_bIsUseSystemFonts = true;
@@ -206,13 +263,16 @@ Cx2tTester::Cx2tTester(const std::wstring& configPath)
m_bIsDeleteOk = false;
m_bIsFilenameCsvTxtParams = true;
m_bIsFilenamePassword = true;
+ m_bTroughConversion = false;
m_defaultCsvDelimiter = L";";
m_defaultCsvTxtEndcoding = L"UTF-8";
- m_inputFormatsList.SetDefault();
- m_outputFormatsList.SetOutput();
+ m_inputFormatsList = CFormatsList::GetDefaultExts();
+ m_outputFormatsList = CFormatsList::GetOutputExts();
m_timeout = 5 * 60; // 5 min
SetConfig(configPath);
m_errorsXmlDirectory = m_outputDirectory + FILE_SEPARATOR_STR + L"_errors";
+ m_troughConversionDirectory = m_outputDirectory + FILE_SEPARATOR_STR + L"_t";
+ m_fontsDirectory = NSFile::GetProcessDirectory() + FILE_SEPARATOR_STR + L"fonts";
// CorrectPathW works strange with directories starts with "./"
@@ -298,6 +358,7 @@ void Cx2tTester::SetConfig(const std::wstring& configPath)
else if(name == L"timeout" && !node.GetText().empty()) m_timeout = std::stoi(node.GetText());
else if(name == L"filenameCsvTxtParams" && !node.GetText().empty()) m_bIsFilenameCsvTxtParams = std::stoi(node.GetText());
else if(name == L"filenamePassword" && !node.GetText().empty()) m_bIsFilenamePassword = std::stoi(node.GetText());
+ else if(name == L"troughConversion" && !node.GetText().empty()) m_bTroughConversion = std::stoi(node.GetText());
else if(name == L"defaultCsvTxtEncoding" && !node.GetText().empty()) m_defaultCsvTxtEndcoding = node.GetText();
else if(name == L"defaultCsvDelimiter" && !node.GetText().empty()) m_defaultCsvDelimiter = (wchar_t)std::stoi(node.GetText(), nullptr, 16);
else if(name == L"inputFilesList" && !node.GetText().empty())
@@ -324,14 +385,14 @@ void Cx2tTester::SetConfig(const std::wstring& configPath)
default_input_formats = false;
std::wstring extensions = node.GetText();
extensions += L' ';
- m_inputFormats = ParseExtensionsString(extensions, m_inputFormatsList);
+ m_inputExts = ParseExtensionsString(extensions, m_inputFormatsList);
}
else if(name == L"output" && !node.GetText().empty())
{
default_output_formats = false;
std::wstring extensions = node.GetText();
extensions += L' ';
- m_outputFormats = ParseExtensionsString(extensions, m_outputFormatsList);
+ m_outputExts = ParseExtensionsString(extensions, m_outputFormatsList);
}
else if (name == L"fonts")
{
@@ -352,12 +413,10 @@ void Cx2tTester::SetConfig(const std::wstring& configPath)
}
if(default_input_formats)
- m_inputFormats = m_inputFormatsList.AllFormats();
+ m_inputExts = m_inputFormatsList.GetAllExts();
if(default_output_formats)
- m_outputFormats = m_outputFormatsList.AllFormats();
-
-
+ m_outputExts = m_outputFormatsList.GetAllExts();
}
void Cx2tTester::Start()
{
@@ -365,9 +424,8 @@ void Cx2tTester::Start()
m_timeStart = NSTimers::GetTickCount();
// check fonts
- std::wstring fonts_directory = NSFile::GetProcessDirectory() + FILE_SEPARATOR_STR + L"fonts";
CApplicationFontsWorker fonts_worker;
- fonts_worker.m_sDirectory = fonts_directory;
+ fonts_worker.m_sDirectory = m_fontsDirectory;
if (!NSDirectory::Exists(fonts_worker.m_sDirectory))
NSDirectory::CreateDirectory(fonts_worker.m_sDirectory);
@@ -387,6 +445,7 @@ void Cx2tTester::Start()
m_outputDirectory = CorrectPathW(m_outputDirectory);
m_errorsXmlDirectory = CorrectPathW(m_errorsXmlDirectory);
+ m_troughConversionDirectory = CorrectPathW(m_troughConversionDirectory);
// setup & clear output folder
if(NSDirectory::Exists(m_outputDirectory))
@@ -406,12 +465,10 @@ void Cx2tTester::Start()
{
std::wstring& input_file = files[i];
std::wstring input_filename = NSFile::GetFileName(input_file);
-
std::wstring input_ext = NSFile::GetFileExtention(input_file);
- int input_format = COfficeFileFormatChecker::GetFormatByExtension(L'.' + input_ext);
// if no format in input formats - skip
- if(std::find(m_inputFormats.begin(), m_inputFormats.end(), input_format) == m_inputFormats.end()
+ 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()))
{
@@ -423,49 +480,77 @@ void Cx2tTester::Start()
if(files.size() < m_maxProc)
m_maxProc = files.size();
+ // conversion in _t directory -> _t directory to output
+ if(m_bTroughConversion)
+ {
+ if(NSDirectory::Exists(m_troughConversionDirectory))
+ NSDirectory::DeleteDirectory(m_troughConversionDirectory);
+
+ NSDirectory::CreateDirectory(m_troughConversionDirectory);
+
+ auto copy_outputDirectory = m_outputDirectory;
+ auto copy_outputExts = m_outputExts;
+
+ m_outputDirectory = m_troughConversionDirectory;
+ m_outputExts = {L"doct", L"xlst", L"pptt"};
+
+ Convert(files, true);
+
+ m_outputDirectory = copy_outputDirectory;
+ m_outputExts = copy_outputExts;
+ m_inputDirectory = m_troughConversionDirectory;
+
+ files = NSDirectory::GetFiles(m_troughConversionDirectory, true);
+ }
+
+ Convert(files);
+ WriteTime();
+}
+
+void Cx2tTester::Convert(const std::vector& files, bool bNoDirectory)
+{
for(int i = 0; i < files.size(); i++)
{
- std::wstring& input_file = files[i];
+ const std::wstring& input_file = files[i];
std::wstring input_filename = NSFile::GetFileName(input_file);
-
- std::wstring input_ext = L'.' + NSFile::GetFileExtention(input_file);
- int input_format = COfficeFileFormatChecker::GetFormatByExtension(input_ext);
-
+ std::wstring input_ext = NSFile::GetFileExtention(input_file);
std::wstring input_file_directory = NSFile::GetDirectoryName(input_file);
// takes full directory after input folder
std::wstring input_subfolders = input_file_directory.substr(m_inputDirectory.size(),
input_file_directory.size() - m_inputDirectory.size());
- std::wstring output_files_directory = m_outputDirectory + input_subfolders + FILE_SEPARATOR_STR + input_filename;
+ std::wstring output_files_directory = m_outputDirectory + input_subfolders;
+ if(!bNoDirectory)
+ output_files_directory += FILE_SEPARATOR_STR + input_filename;
// setup output_formats for file
- std::vector output_file_formats;
+ std::vector output_file_exts;
- for(auto format : m_outputFormats)
+ for(auto& ext : m_outputExts)
{
// documents -> documents
- if(((m_outputFormatsList.IsDocument(format) && m_inputFormatsList.IsDocument(input_format))
+ if(((m_outputFormatsList.IsDocument(ext) && m_inputFormatsList.IsDocument(input_ext))
// spreadsheets -> spreadsheets
- || (m_outputFormatsList.IsSpreadsheet(format) && m_inputFormatsList.IsSpreadsheet(input_format))
+ || (m_outputFormatsList.IsSpreadsheet(ext) && m_inputFormatsList.IsSpreadsheet(input_ext))
//presentations -> presentations
- || (m_outputFormatsList.IsPresentation(format) && m_inputFormatsList.IsPresentation(input_format))
+ || (m_outputFormatsList.IsPresentation(ext) && m_inputFormatsList.IsPresentation(input_ext))
// xps -> docx
- || (format == AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX && input_format == AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS)
+ || (ext == L"docx" && input_ext == L"xps")
// pdf -> docx
- || (format == AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX && m_inputFormatsList.IsPdf(input_format))
+ || (ext == L"docx" && m_inputFormatsList.IsPdf(input_ext))
// all formats -> images
- || m_outputFormatsList.IsImage(format)
+ || m_outputFormatsList.IsImage(ext)
// all formats -> pdf
- || m_outputFormatsList.IsPdf(format))
+ || m_outputFormatsList.IsPdf(ext))
// input format != output format
- && format != input_format)
+ && ext != input_ext)
{
- output_file_formats.push_back(format);
+ output_file_exts.push_back(ext);
}
}
- if(output_file_formats.empty())
+ if(output_file_exts.empty())
continue;
// setup & clear output subfolder
@@ -477,8 +562,8 @@ void Cx2tTester::Start()
// setup csv & txt additional params
if(m_bIsFilenameCsvTxtParams
- || input_format == AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT
- || input_format == AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV)
+ || input_ext == L"txt"
+ || input_ext == L"csv")
{
std::wstring find_str = L"[cp";
size_t pos1 = input_filename.find(find_str);
@@ -495,7 +580,7 @@ void Cx2tTester::Start()
break;
}
- if(m_bIsFilenameCsvTxtParams || input_format == AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV)
+ if(m_bIsFilenameCsvTxtParams || input_ext == L"csv")
{
std::wstring find_str = L"[del%";
size_t pos1 = input_filename.find(find_str);
@@ -525,10 +610,10 @@ void Cx2tTester::Start()
// setup & start new coverter
CConverter *converter = new CConverter(this);
converter->SetInputFile(input_file);
- converter->SetInputFormat(input_format);
+ converter->SetInputExt(input_ext);
converter->SetOutputFilesDirectory(output_files_directory);
- converter->SetOutputFormats(output_file_formats);
- converter->SetFontsDirectory(fonts_directory);
+ converter->SetOutputExts(output_file_exts);
+ converter->SetFontsDirectory(m_fontsDirectory);
converter->SetX2tPath(m_x2tPath);
converter->SetErrorsOnly(m_bIsErrorsOnly);
converter->SetDeleteOk(m_bIsDeleteOk);
@@ -549,8 +634,6 @@ void Cx2tTester::Start()
// waiting all procs end
while(!IsAllFree())
NSThreads::Sleep(150);
-
- WriteTime();
}
void Cx2tTester::WriteReportHeader()
{
@@ -610,31 +693,29 @@ bool Cx2tTester::IsAllFree()
return m_currentProc == 0;
}
-std::vector Cx2tTester::ParseExtensionsString(std::wstring extensions, const CFormatsList& fl)
+std::vector Cx2tTester::ParseExtensionsString(std::wstring extensions, const CFormatsList& fl)
{
- std::vector formats;
+ std::vector exts;
int pos = 0;
while ((pos = extensions.find(' ')) != std::wstring::npos)
{
std::wstring ext = extensions.substr(0, pos);
if(ext == L"documents")
- formats = fl.GetDocuments();
+ exts = fl.GetDocuments();
else if(ext == L"presentations")
- formats = fl.GetPresentations();
+ exts = fl.GetPresentations();
else if(ext == L"spreadsheets")
- formats = fl.GetSpreadsheets();
+ exts = fl.GetSpreadsheets();
+
+ else if (pos != 0)
+ exts.push_back(ext);
- else
- {
- int format = COfficeFileFormatChecker::GetFormatByExtension(L'.' + ext);
- formats.push_back(format);
- }
extensions.erase(0, pos + 1);
}
- return formats;
+ return exts;
}
CConverter::CConverter(Cx2tTester* internal) : m_internal(internal)
@@ -649,17 +730,17 @@ void CConverter::SetInputFile(const std::wstring& inputFile)
{
m_inputFile = inputFile;
}
-void CConverter::SetInputFormat(int inputFormat)
+void CConverter::SetInputExt(const std::wstring& inputExt)
{
- m_inputFormat = inputFormat;
+ m_inputExt = inputExt;
}
void CConverter::SetOutputFilesDirectory(const std::wstring& outputFilesDirectory)
{
m_outputFilesDirectory = outputFilesDirectory;
}
-void CConverter::SetOutputFormats(const std::vector outputFormats)
+void CConverter::SetOutputExts(const std::vector& outputExts)
{
- m_outputFormats = outputFormats;
+ m_outputExts = outputExts;
}
void CConverter::SetFontsDirectory(const std::wstring& fontsDirectory)
{
@@ -725,11 +806,11 @@ DWORD CConverter::ThreadProc()
#endif // WIN32
// input_format in many output exts
- for(int i = 0; i < m_outputFormats.size(); i++)
+ for(int i = 0; i < m_outputExts.size(); i++)
{
- int& output_format = m_outputFormats[i];
+ std::wstring output_ext = L"."+ m_outputExts[i];
+ int output_format = checker.GetFormatByExtension(output_ext);
- std::wstring output_ext = checker.GetExtensionByType(output_format);
std::wstring xml_params_filename = input_filename + L"_" + output_ext + L".xml";
std::wstring xml_params_file = m_outputFilesDirectory + FILE_SEPARATOR_STR + xml_params_filename;
@@ -784,7 +865,7 @@ DWORD CConverter::ThreadProc()
}
// csv & txt needs encoding param
- if(m_inputFormat == AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT || m_inputFormat == AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV)
+ if(m_inputExt == L"txt" || m_inputExt == L"csv")
{
builder.WriteString(L"");
builder.WriteEncodeXmlString(std::to_wstring(m_csvTxtEncoding));
@@ -792,7 +873,7 @@ DWORD CConverter::ThreadProc()
}
// csv needs delimiter param
- if(m_inputFormat == AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV)
+ if(m_inputExt == L"csv")
{
builder.WriteString(L"");
builder.WriteEncodeXmlString(m_csvDelimiter);
@@ -911,7 +992,7 @@ DWORD CConverter::ThreadProc()
// output_CS start
m_internal->m_outputCS.Enter();
- std::cout << "[" << m_currFile << "/" << m_totalFiles << "](" << i + 1 << "/" << m_outputFormats.size() << ") ";
+ std::cout << "[" << m_currFile << "/" << m_totalFiles << "](" << i + 1 << "/" << m_outputExts.size() << ") ";
std::cout << "(" << m_internal->m_currentProc << " processes now) ";
std::cout << input_file_UTF8 << " to " << output_file_UTF8 << " ";
diff --git a/Test/Applications/x2tTester/x2tTester.h b/Test/Applications/x2tTester/x2tTester.h
index 12d7074667..d01badb32d 100644
--- a/Test/Applications/x2tTester/x2tTester.h
+++ b/Test/Applications/x2tTester/x2tTester.h
@@ -25,36 +25,44 @@ class CFormatsList
{
public:
CFormatsList();
+ CFormatsList(const CFormatsList& list);
+ CFormatsList& operator=(const CFormatsList& list);
- std::vector GetDocuments() const;
- std::vector GetPresentations() const;
- std::vector GetSpreadsheets() const;
- std::vector GetCrossplatform() const;
- std::vector GetImages() const;
- int GetPdf() const;
+ std::vector GetDocuments() const;
+ std::vector GetPresentations() const;
+ std::vector GetSpreadsheets() const;
+ std::vector GetCrossplatform() const;
+ std::vector GetImages() const;
+ std::wstring GetPdf() const;
- bool IsDocument(int format) const;
- bool IsPresentation(int format) const;
- bool IsSpreadsheet(int format) const;
- bool IsCrossplatform(int format) const;
- bool IsImage(int format) const;
- bool IsPdf(int format) const;
+ bool IsDocument(const std::wstring& ext) const;
+ bool IsPresentation(const std::wstring& ext) const;
+ bool IsSpreadsheet(const std::wstring& ext) const;
+ bool IsCrossplatform(const std::wstring& ext) const;
+ bool IsImage(const std::wstring& ext) const;
+ bool IsPdf(const std::wstring& ext) const;
- // all formats
- void SetDefault();
+ void AddDocument(const std::wstring& ext);
+ void AddPresentation(const std::wstring& ext);
+ void AddSpreadsheet(const std::wstring& ext);
+ void AddCrossplatform(const std::wstring& ext);
+ void AddImage(const std::wstring& ext);
- // all writable formats
- void SetOutput();
+ std::vector GetAllExts() const;
- std::vector AllFormats() const;
+ // all supported exts
+ static CFormatsList GetDefaultExts();
+
+ // all writable exts
+ static CFormatsList GetOutputExts();
private:
- std::vector m_documents;
- std::vector m_presentations;
- std::vector m_spreadsheets;
- std::vector m_crossplatform;
- std::vector m_images;
- int m_pdf;
+ std::vector m_documents;
+ std::vector m_presentations;
+ std::vector m_spreadsheets;
+ std::vector m_crossplatform;
+ std::vector m_images;
+ std::wstring m_pdf;
};
@@ -96,8 +104,9 @@ public:
int m_maxProc;
private:
- // parse string like "docx txt" into vector of formats
- std::vector ParseExtensionsString(std::wstring extensions, const CFormatsList& fl);
+ // parse string like "docx txt" into vector
+ std::vector ParseExtensionsString(std::wstring extensions, const CFormatsList& fl);
+ void Convert(const std::vector& files, bool bNoDirectory = false);
// takes from config
std::wstring m_reportFile;
@@ -106,6 +115,8 @@ private:
std::wstring m_x2tPath;
std::wstring m_errorsXmlDirectory;
+ std::wstring m_troughConversionDirectory;
+ std::wstring m_fontsDirectory;
// fonts
bool m_bIsUseSystemFonts;
@@ -114,12 +125,12 @@ private:
NSFile::CFileBinary m_reportStream;
// takes from config or sets all
- std::vector m_inputFormats;
- std::vector m_outputFormats;
+ std::vector m_inputExts;
+ std::vector m_outputExts;
std::vector m_inputFiles;
- // list of formats
+ // lists
CFormatsList m_inputFormatsList;
CFormatsList m_outputFormatsList;
@@ -135,6 +146,9 @@ private:
unsigned long m_timeout;
unsigned long m_timeStart;
+
+ // format -> *t format -> all formats
+ bool m_bTroughConversion;
};
// generates temp xml, convert, calls m_internal->writeReport
@@ -145,9 +159,9 @@ public:
virtual ~CConverter();
void SetInputFile(const std::wstring& inputFile);
- void SetInputFormat(int inputFormat);
+ void SetInputExt(const std::wstring& inputExt);
void SetOutputFilesDirectory(const std::wstring& outputFilesDirectory);
- void SetOutputFormats(const std::vector outputFormats);
+ void SetOutputExts(const std::vector& outputExts);
void SetFontsDirectory(const std::wstring& fontsDirectory);
void SetX2tPath(const std::wstring& x2tPath);
void SetErrorsOnly(bool bIsErrorsOnly);
@@ -163,12 +177,11 @@ public:
private:
Cx2tTester* m_internal;
-
std::wstring m_inputFile;
- int m_inputFormat;
std::wstring m_outputFilesDirectory;
- std::vector m_outputFormats;
+ std::vector m_outputExts;
+ std::wstring m_inputExt;
std::wstring m_fontsDirectory;
COfficeFileFormatChecker checker;