mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Revert "Merge pull request #528 from ONLYOFFICE/feature/ppt_4"
This reverts commitff0f58cc3c, reversing changes made tocb6c9838d3.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -16,11 +16,7 @@ struct CFb2Params
|
||||
bool bNeedDocx;
|
||||
bool bNeedContents;
|
||||
|
||||
CFb2Params()
|
||||
{
|
||||
bNeedDocx = false;
|
||||
bNeedContents = false;
|
||||
}
|
||||
CFb2Params() : bNeedDocx(false), bNeedContents(false) {}
|
||||
};
|
||||
|
||||
class CFb2File_Private;
|
||||
@ -35,6 +31,7 @@ public:
|
||||
bool IsFb2File(const std::wstring& sFile);
|
||||
void SetTmpDirectory(const std::wstring& sFolder);
|
||||
HRESULT Open(const std::wstring& sPath, const std::wstring& sDirectory, CFb2Params* oParams = NULL);
|
||||
HRESULT FromHtml(const std::wstring& sHtmlFile, const std::wstring& sCoreFile, const std::wstring& sDst);
|
||||
};
|
||||
|
||||
#endif // _FB2FILE_FB2FILE_H
|
||||
|
||||
@ -7,7 +7,6 @@ TEMPLATE = lib
|
||||
|
||||
CONFIG += shared
|
||||
CONFIG += plugin
|
||||
|
||||
CONFIG += core_static_link_libstd
|
||||
|
||||
DEFINES += FB2FILE_USE_DYNAMIC_LIBRARY
|
||||
@ -16,6 +15,8 @@ CORE_ROOT_DIR = $$PWD/..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/html/gumbo.pri)
|
||||
|
||||
ADD_DEPENDENCY(kernel, UnicodeConverter, graphics)
|
||||
|
||||
SOURCES += Fb2File.cpp
|
||||
|
||||
@ -9,14 +9,15 @@
|
||||
void getDirectories(const std::wstring& sDirectory, std::vector<std::wstring>& arrDirectory)
|
||||
{
|
||||
arrDirectory.push_back(sDirectory);
|
||||
for(const std::wstring& sT : NSDirectory::GetDirectories(sDirectory))
|
||||
for (const std::wstring& sT : NSDirectory::GetDirectories(sDirectory))
|
||||
getDirectories(sT, arrDirectory);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
bool bBatchMode = false;
|
||||
if(bBatchMode)
|
||||
bool bFromHtml = false;
|
||||
if (bBatchMode)
|
||||
{
|
||||
// Директория файлов
|
||||
std::wstring sDirectory = NSFile::GetProcessDirectory() + L"/../../../examples/fb2";
|
||||
@ -37,40 +38,46 @@ int main()
|
||||
int nErrorCol = 0;
|
||||
std::vector<std::wstring> arrError;
|
||||
|
||||
for(const std::wstring& sD : arrDirectory)
|
||||
for (std::wstring sD : arrDirectory)
|
||||
{
|
||||
std::vector<std::wstring> arrFiles = NSDirectory::GetFiles(sD);
|
||||
|
||||
// Директория, где будем создавать docx
|
||||
size_t nPos = sD.find(L"/fb2");
|
||||
std::wstring sOutputDirectory = sD.insert(nPos + 4, L"-res");
|
||||
NSDirectory::DeleteDirectory(sOutputDirectory);
|
||||
NSDirectory::CreateDirectory(sOutputDirectory);
|
||||
|
||||
for(const std::wstring& sFile : arrFiles)
|
||||
if (bFromHtml)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<std::wstring> arrFiles = NSDirectory::GetFiles(sD);
|
||||
|
||||
if(oFile.Open(sFile, sTmp, &oParams) == S_OK)
|
||||
// Директория, где будем создавать 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)
|
||||
{
|
||||
std::cout << "Success" << std::endl;
|
||||
oZip.CompressFileOrDirectory(sTmp, sOutputDirectory + L"/" + sFileName + L".docx");
|
||||
NSDirectory::DeleteDirectory(sTmp + L"/word/media");
|
||||
}
|
||||
else
|
||||
{
|
||||
nErrorCol++;
|
||||
arrError.push_back(sFileName);
|
||||
std::cout << "Failure" << std::endl;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -84,13 +91,21 @@ int main()
|
||||
CFb2File oFile;
|
||||
|
||||
// Файл, который открываем
|
||||
std::wstring sFile = NSFile::GetProcessDirectory() + L"/../../../examples/test2.fb2";
|
||||
std::wstring sFile = NSFile::GetProcessDirectory() + L"/../../../examples/8-sezon-groz.fb2";
|
||||
|
||||
// Директория, где будем создавать docx
|
||||
std::wstring sOutputDirectory = NSFile::GetProcessDirectory() + L"/res";
|
||||
NSDirectory::DeleteDirectory(sOutputDirectory);
|
||||
NSDirectory::CreateDirectory(sOutputDirectory);
|
||||
|
||||
|
||||
if (bFromHtml)
|
||||
{
|
||||
sFile = NSFile::GetProcessDirectory() + L"/../../../examples/test3";
|
||||
oFile.FromHtml(sFile, sOutputDirectory + L"/res.fb2");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!oFile.IsFb2File(sFile))
|
||||
{
|
||||
std::cout << "This isn't a fb2 file" << std::endl;
|
||||
@ -101,7 +116,7 @@ int main()
|
||||
oParams.bNeedDocx = true;
|
||||
oParams.bNeedContents = true;
|
||||
|
||||
std::cout << oFile.Open(sFile, sOutputDirectory, &oParams) == S_OK ? "Success" : "Failure" << std::endl;
|
||||
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