mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Fix spaces replaced with tabs for Fb2File
This commit is contained in:
3774
Fb2File/Fb2File.cpp
3774
Fb2File/Fb2File.cpp
File diff suppressed because it is too large
Load Diff
@ -8,115 +8,115 @@
|
||||
|
||||
void getDirectories(const std::wstring& sDirectory, std::vector<std::wstring>& arrDirectory)
|
||||
{
|
||||
arrDirectory.push_back(sDirectory);
|
||||
for (const std::wstring& sT : NSDirectory::GetDirectories(sDirectory))
|
||||
getDirectories(sT, arrDirectory);
|
||||
arrDirectory.push_back(sDirectory);
|
||||
for (const std::wstring& sT : NSDirectory::GetDirectories(sDirectory))
|
||||
getDirectories(sT, arrDirectory);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
bool bBatchMode = false;
|
||||
bool bBatchMode = false;
|
||||
bool bFromHtml = false;
|
||||
if (bBatchMode)
|
||||
{
|
||||
// Директория файлов
|
||||
std::wstring sDirectory = NSFile::GetProcessDirectory() + L"/../../../examples/fb2";
|
||||
// Вложенные директории
|
||||
std::vector<std::wstring> arrDirectory;
|
||||
getDirectories(sDirectory, arrDirectory);
|
||||
if (bBatchMode)
|
||||
{
|
||||
// Директория файлов
|
||||
std::wstring sDirectory = NSFile::GetProcessDirectory() + L"/../../../examples/fb2";
|
||||
// Вложенные директории
|
||||
std::vector<std::wstring> arrDirectory;
|
||||
getDirectories(sDirectory, arrDirectory);
|
||||
|
||||
// Параметры конвертации
|
||||
CFb2Params oParams;
|
||||
oParams.bNeedDocx = false;
|
||||
oParams.bNeedContents = true;
|
||||
COfficeUtils oZip;
|
||||
// Выставляем временную директорию
|
||||
std::wstring sTmp = NSFile::GetProcessDirectory() + L"/tmp";
|
||||
NSDirectory::DeleteDirectory(sTmp);
|
||||
NSDirectory::CreateDirectory(sTmp);
|
||||
// Параметры конвертации
|
||||
CFb2Params oParams;
|
||||
oParams.bNeedDocx = false;
|
||||
oParams.bNeedContents = true;
|
||||
COfficeUtils oZip;
|
||||
// Выставляем временную директорию
|
||||
std::wstring sTmp = NSFile::GetProcessDirectory() + L"/tmp";
|
||||
NSDirectory::DeleteDirectory(sTmp);
|
||||
NSDirectory::CreateDirectory(sTmp);
|
||||
|
||||
int nErrorCol = 0;
|
||||
std::vector<std::wstring> arrError;
|
||||
int nErrorCol = 0;
|
||||
std::vector<std::wstring> arrError;
|
||||
|
||||
for (std::wstring sD : arrDirectory)
|
||||
{
|
||||
if (bFromHtml)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<std::wstring> arrFiles = NSDirectory::GetFiles(sD);
|
||||
for (std::wstring sD : arrDirectory)
|
||||
{
|
||||
if (bFromHtml)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<std::wstring> arrFiles = NSDirectory::GetFiles(sD);
|
||||
|
||||
// Директория, где будем создавать docx
|
||||
size_t nPos = sD.find(L"/fb2");
|
||||
sD.insert(nPos + 4, L"-res");
|
||||
NSDirectory::DeleteDirectory(sD);
|
||||
NSDirectory::CreateDirectory(sD);
|
||||
// Директория, где будем создавать docx
|
||||
size_t nPos = sD.find(L"/fb2");
|
||||
sD.insert(nPos + 4, L"-res");
|
||||
NSDirectory::DeleteDirectory(sD);
|
||||
NSDirectory::CreateDirectory(sD);
|
||||
|
||||
for(const std::wstring& sFile : arrFiles)
|
||||
{
|
||||
CFb2File oFile;
|
||||
std::wstring sFileName = NSFile::GetFileName(sFile);
|
||||
std::wcout << sFileName << std::endl;
|
||||
if(!oFile.IsFb2File(sFile))
|
||||
{
|
||||
nErrorCol++;
|
||||
arrError.push_back(sFileName);
|
||||
std::cout << "This isn't a fb2 file" << std::endl;
|
||||
continue;
|
||||
}
|
||||
for(const std::wstring& sFile : arrFiles)
|
||||
{
|
||||
CFb2File oFile;
|
||||
std::wstring sFileName = NSFile::GetFileName(sFile);
|
||||
std::wcout << sFileName << std::endl;
|
||||
if(!oFile.IsFb2File(sFile))
|
||||
{
|
||||
nErrorCol++;
|
||||
arrError.push_back(sFileName);
|
||||
std::cout << "This isn't a fb2 file" << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(oFile.Open(sFile, sTmp, &oParams) == S_OK)
|
||||
{
|
||||
std::cout << "Success" << std::endl;
|
||||
oZip.CompressFileOrDirectory(sTmp, sD + L"/" + sFileName + L".docx");
|
||||
NSDirectory::DeleteDirectory(sTmp + L"/word/media");
|
||||
}
|
||||
else
|
||||
{
|
||||
nErrorCol++;
|
||||
arrError.push_back(sFileName);
|
||||
std::cout << "Failure" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(oFile.Open(sFile, sTmp, &oParams) == S_OK)
|
||||
{
|
||||
std::cout << "Success" << std::endl;
|
||||
oZip.CompressFileOrDirectory(sTmp, sD + L"/" + sFileName + L".docx");
|
||||
NSDirectory::DeleteDirectory(sTmp + L"/word/media");
|
||||
}
|
||||
else
|
||||
{
|
||||
nErrorCol++;
|
||||
arrError.push_back(sFileName);
|
||||
std::cout << "Failure" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "ERRORS - "<< nErrorCol << std::endl;
|
||||
for(const std::wstring& sError : arrError)
|
||||
std::wcout << sError << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
CFb2File oFile;
|
||||
std::cout << "ERRORS - "<< nErrorCol << std::endl;
|
||||
for(const std::wstring& sError : arrError)
|
||||
std::wcout << sError << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
CFb2File oFile;
|
||||
|
||||
// Файл, который открываем
|
||||
std::wstring sFile = NSFile::GetProcessDirectory() + L"/res.fb2";
|
||||
// Файл, который открываем
|
||||
std::wstring sFile = NSFile::GetProcessDirectory() + L"/res.fb2";
|
||||
|
||||
// Директория, где будем создавать docx
|
||||
std::wstring sOutputDirectory = NSFile::GetProcessDirectory() + L"/res";
|
||||
NSDirectory::DeleteDirectory(sOutputDirectory);
|
||||
NSDirectory::CreateDirectory(sOutputDirectory);
|
||||
// Директория, где будем создавать docx
|
||||
std::wstring sOutputDirectory = NSFile::GetProcessDirectory() + L"/res";
|
||||
NSDirectory::DeleteDirectory(sOutputDirectory);
|
||||
NSDirectory::CreateDirectory(sOutputDirectory);
|
||||
|
||||
if (bFromHtml)
|
||||
{
|
||||
sFile = NSFile::GetProcessDirectory() + L"/test.html";
|
||||
oFile.FromHtml(sFile, sOutputDirectory + L"/res.fb2", L"Test Title");
|
||||
return 0;
|
||||
}
|
||||
if (bFromHtml)
|
||||
{
|
||||
sFile = NSFile::GetProcessDirectory() + L"/test.html";
|
||||
oFile.FromHtml(sFile, sOutputDirectory + L"/res.fb2", L"Test Title");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!oFile.IsFb2File(sFile))
|
||||
{
|
||||
std::cout << "This isn't a fb2 file" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
if (!oFile.IsFb2File(sFile))
|
||||
{
|
||||
std::cout << "This isn't a fb2 file" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
CFb2Params oParams;
|
||||
oParams.bNeedDocx = true;
|
||||
CFb2Params oParams;
|
||||
oParams.bNeedDocx = true;
|
||||
oParams.bNeedContents = false;
|
||||
|
||||
std::cout << (oFile.Open(sFile, sOutputDirectory, &oParams) == S_OK ? "Success" : "Failure") << std::endl;
|
||||
}
|
||||
std::cout << "THE END" << std::endl;
|
||||
return 0;
|
||||
std::cout << (oFile.Open(sFile, sOutputDirectory, &oParams) == S_OK ? "Success" : "Failure") << std::endl;
|
||||
}
|
||||
std::cout << "THE END" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user