creating an instance of a static library class

This commit is contained in:
Svetlana Kulikova
2020-07-29 11:39:43 +03:00
parent 1905155d01
commit 537b268a11
5 changed files with 27 additions and 25 deletions

View File

@ -230,7 +230,7 @@ static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilde
// build attr string
const GumboVector * attribs = &node->v.element.attributes;
for (int i = 0; i < attribs->length; ++i)
for (size_t i = 0; i < attribs->length; ++i)
{
GumboAttribute* at = static_cast<GumboAttribute*>(attribs->data[i]);
build_attributes(at, no_entity_substitution, oBuilder);

View File

@ -6,6 +6,9 @@ TEMPLATE = lib
CONFIG += staticlib
DEFINES += HTMLFILE2_USE_DYNAMIC_LIBRARY
DEFINES += UNICODE \
_UNICODE \
DONT_WRITE_EMBEDDED_FONTS
CORE_ROOT_DIR = $$PWD/../../core
PWD_ROOT_DIR = $$PWD
@ -14,7 +17,7 @@ include($$CORE_ROOT_DIR/Common/base.pri)
#BOOST
include($$CORE_ROOT_DIR/Common/3dParty/boost/boost.pri)
ADD_DEPENDENCY(kernel, UnicodeConverter, graphics, DocxFormatLib)
ADD_DEPENDENCY(kernel, gumbo, UnicodeConverter, graphics, DocxFormatLib)
SOURCES += htmlfile2.cpp

View File

@ -1,7 +1,9 @@
#include <string>
#include "htmlfile2.h"
#include "../Common/3dParty/html/htmltoxhtml.h"
#include "../ASCOfficeDocxFile2/BinReader/FileWriter.h"
#include "../Common/DocxFormat/Source/DocxFormat/Docx.h"
#include "../Common/DocxFormat/Source/DocxFormat/App.h"
#include "../Common/DocxFormat/Source/DocxFormat/Core.h"
#include "../DesktopEditor/common/SystemUtils.h"
@ -117,6 +119,14 @@ void CHtmlFile2::SetTmpDirectory(const std::wstring& sFolder)
HRESULT CHtmlFile2::Open(const std::wstring& sSrc, const std::wstring& sDst, CHtmlParams* oParams)
{
NSFile::CFileBinary oXhtmlWriter;
if (oXhtmlWriter.CreateFileW(sDst + L"/res.xhtml"))
{
// htmlToXhtml возвращает текст файла в кодировке UTF-8
oXhtmlWriter.WriteStringUTF8(htmlToXhtml(sSrc));
oXhtmlWriter.CloseFile();
}
// FileWriter - Писатель docx
// sDst - место создания docx, L"" - директория fontTable для инициализации, true - директория fontTable не требуется,
// 1 - версия стилей, false - не сохранять диаграммы как изображения, NULL - кастомный конвертор связанный с pptx, L"" - пустая тема
@ -124,7 +134,7 @@ HRESULT CHtmlFile2::Open(const std::wstring& sSrc, const std::wstring& sDst, CHt
if (pDocxWriter == NULL)
return S_FALSE;
CreateDocxEmpty(sDst, pDocxWriter);
m_internal->CreateDocxEmpty(sDst, pDocxWriter);
RELEASEOBJECT(pDocxWriter);
return S_FALSE;

View File

@ -1,20 +1,13 @@
#include <iostream>
#include <fstream>
#include "../htmlfile2.h"
#include "../../Common/3dParty/html/htmltoxhtml.h"
#include "../../DesktopEditor/common/File.h"
#include "../../DesktopEditor/common/Directory.h"
#include "../../DesktopEditor/xml/include/xmlutils.h"
void readFile( XmlUtils::CXmlLiteReader& oLightReader)
{
int nDepth = oLightReader.GetDepth();
while(oLightReader.ReadNextSiblingNode(nDepth))
readFile(oLightReader);
}
int main()
{
CHtmlFile2 oFile;
// Файл, который открываем
std::wstring sFile = NSFile::GetProcessDirectory() + L"/../../../examples/test2.html";
@ -23,24 +16,20 @@ int main()
NSDirectory::DeleteDirectory(sOutputDirectory);
NSDirectory::CreateDirectory(sOutputDirectory);
NSFile::CFileBinary oXhtmlWriter;
if (oXhtmlWriter.CreateFileW(sOutputDirectory + L"/res.xhtml"))
bool bCheck = true; //oFile.IsHtmlFile(sFile);
//if (!bCheck)
if (bCheck)
{
// htmlToXhtml возвращает текст файла в кодировке UTF-8
oXhtmlWriter.WriteStringUTF8(htmlToXhtml(sFile));
oXhtmlWriter.CloseFile();
std::cout << "This isn't a html file" << std::endl;
return 1;
}
// Проверка на чтение
XmlUtils::CXmlLiteReader oLightReader;
bool bRes = oLightReader.FromFile(sOutputDirectory + L"/res.xhtml");
if(bRes)
{
readFile(oLightReader);
HRESULT nResConvert = S_OK; //oFile.Open(sFile, sOutputDirectory);
if(nResConvert == S_OK)
std::cout << "Success" << std::endl;
}
else
std::cout << "Failure" << std::endl;
std::cout << "THE END" << std::endl;
return 0;
}

View File

@ -17,6 +17,6 @@ include($$CORE_ROOT_DIR/Common/base.pri)
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lHtmlFile2
ADD_DEPENDENCY(kernel, gumbo, UnicodeConverter)
ADD_DEPENDENCY(kernel, UnicodeConverter)
DESTDIR = $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX