mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-10 23:03:14 +08:00
45 lines
1.4 KiB
C++
45 lines
1.4 KiB
C++
#include <iostream>
|
|
#include <fstream>
|
|
#include "../../Common/3dParty/html/htmltoxhtml.h"
|
|
#include "../../DesktopEditor/common/File.h"
|
|
#include "../../DesktopEditor/common/Directory.h"
|
|
|
|
void readFile( XmlUtils::CXmlLiteReader& oLightReader)
|
|
{
|
|
int nDepth = oLightReader.GetDepth();
|
|
while(oLightReader.ReadNextSiblingNode(nDepth))
|
|
readFile(oLightReader);
|
|
}
|
|
|
|
int main()
|
|
{
|
|
// Файл, который открываем
|
|
std::wstring sFile = NSFile::GetProcessDirectory() + L"/../../../examples/test2.html";
|
|
|
|
// Директория, где будем создавать xhtml
|
|
std::wstring sOutputDirectory = NSFile::GetProcessDirectory() + L"/res";
|
|
NSDirectory::DeleteDirectory(sOutputDirectory);
|
|
NSDirectory::CreateDirectory(sOutputDirectory);
|
|
|
|
NSFile::CFileBinary oXhtmlWriter;
|
|
if (oXhtmlWriter.CreateFileW(sOutputDirectory + L"/res.xhtml"))
|
|
{
|
|
// htmlToXhtml возвращает текст файла в кодировке UTF-8
|
|
oXhtmlWriter.WriteStringUTF8(htmlToXhtml(sFile));
|
|
oXhtmlWriter.CloseFile();
|
|
}
|
|
|
|
// Проверка на чтение
|
|
XmlUtils::CXmlLiteReader oLightReader;
|
|
bool bRes = oLightReader.FromFile(sOutputDirectory + L"/res.xhtml");
|
|
if(bRes)
|
|
{
|
|
// readFile(oLightReader);
|
|
std::cout << (oLightReader.ReadTillEnd() ? "Success" : "Failure") << std::endl;
|
|
}
|
|
else
|
|
std::cout << "Failure" << std::endl;
|
|
|
|
return 0;
|
|
}
|