diff --git a/.gitattributes b/.gitattributes index c6a1eb772a..ea9cf21532 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7471,6 +7471,9 @@ DoctRenderer/COMMON/Joiner/bin/Debug/Joiner.exe svn_mime_002dtype=application%2F DoctRenderer/COMMON/JoinerPPT/bin/Debug/Joiner.exe svn_mime_002dtype=application%2Foctet-stream DoctRenderer/COMMON/JoinerXLS/bin/Debug/Joiner.exe svn_mime_002dtype=application%2Foctet-stream DoctRenderer/COMMON/TestConsole/Ionic.Zip.Reduced.dll svn_mime_002dtype=application%2Foctet-stream +/HtmlFile svnc_tsvn_003alogminsize=5 +HtmlFile/Internal svnc_tsvn_003alogminsize=5 +HtmlFile/test svnc_tsvn_003alogminsize=5 /HtmlRenderer svnc_tsvn_003alogminsize=5 HtmlRenderer/include svnc_tsvn_003alogminsize=5 HtmlRenderer/src svnc_tsvn_003alogminsize=5 diff --git a/HtmlFile/HtmlFile.cpp b/HtmlFile/HtmlFile.cpp new file mode 100644 index 0000000000..9ebf9ad799 --- /dev/null +++ b/HtmlFile/HtmlFile.cpp @@ -0,0 +1,102 @@ +#include "HtmlFile.h" +#include "../DesktopEditor/common/File.h" + +#ifdef LINUX +#include +#include +#include +#endif + +CHtmlFile::CHtmlFile() +{ + +} + +CHtmlFile::~CHtmlFile() +{ + +} + +int CHtmlFile::Convert(const std::wstring& sXml, const std::wstring& sPathInternal) +{ + std::wstring sInternal = sPathInternal; + if (sInternal.empty()) + sInternal = NSFile::GetProcessDirectory() + L"/HtmlFileInternal/"; + + sInternal += L"HtmlFileInternal"; + +#ifdef WIN32 + sInternal += L".exe"; +#endif + + int nReturnCode = 0; + +#ifdef WIN32 + STARTUPINFO sturtupinfo; + ZeroMemory(&sturtupinfo,sizeof(STARTUPINFO)); + sturtupinfo.cb = sizeof(STARTUPINFO); + + wchar_t* pCommandLine = NULL; + if (!sXml.empty()) + { + pCommandLine = new wchar_t[sXml.length() + 1]; + memcpy(pCommandLine, sXml.c_str(), sXml.length() * sizeof(wchar_t)); + pCommandLine[sXml.length()] = (wchar_t)'\0'; + } + + PROCESS_INFORMATION processinfo; + ZeroMemory(&processinfo,sizeof(PROCESS_INFORMATION)); + BOOL bResult = CreateProcessW(sInternal.c_str(), pCommandLine, + NULL, NULL, TRUE, NULL, NULL, NULL, &sturtupinfo, &processinfo); + + ::WaitForSingleObject(processinfo.hProcess, INFINITE); + + RELEASEARRAYOBJECTS(pCommandLine); + + //get exit code + DWORD dwExitCode = 0; + if (GetExitCodeProcess(processinfo.hProcess, &dwExitCode)) + { + nReturnCode = (int)dwExitCode; + } + + CloseHandle(processinfo.hProcess); + CloseHandle(processinfo.hThread); +#endif + +#ifdef LINUX + pid_t pid = fork(); // create child process + int status; + + std::string sProgramm = U_TO_UTF8(sInternal); + std::string sXmlA = ""; + if (!sXml.empty()) + sXmlA = U_TO_UTF8(sXml); + + FILE* f = fopen("/home/oleg/a.txt", "a+"); + fprintf(f, "HtmlCodeAfterFork\n"); + fclose(f); + + switch (pid) + { + case -1: // error + break; + + case 0: // child process + { + execl(sProgramm.c_str(), sXmlA.empty() ? NULL : sXmlA.c_str(), 0); // run the command + exit(EXIT_SUCCESS); + break; + } + default: // parent process, pid now contains the child pid + while (-1 == waitpid(pid, &status, 0)); // wait for child to complete + if (WIFEXITED(status)) + { + nReturnCode = WEXITSTATUS(status); + } + break; + } +#endif + + return nReturnCode; +} diff --git a/HtmlFile/HtmlFile.h b/HtmlFile/HtmlFile.h new file mode 100644 index 0000000000..18e485a9c8 --- /dev/null +++ b/HtmlFile/HtmlFile.h @@ -0,0 +1,25 @@ +#ifndef _HTMLFILE_HTMLFILE_H_ +#define _HTMLFILE_HTMLFILE_H_ + +#include + +#ifndef HTMLFILE_USE_DYNAMIC_LIBRARY +#define HTMLFILE_DECL_EXPORT +#else +#include "../DesktopEditor/common/base_export.h" +#define HTMLFILE_DECL_EXPORT Q_DECL_EXPORT +#endif + +class HTMLFILE_DECL_EXPORT CHtmlFile +{ +private: + +public: + + CHtmlFile(); + ~CHtmlFile(); + + int Convert(const std::wstring& sXml, const std::wstring& sPathInternal = L""); +}; + +#endif // _HTMLFILE_HTMLFILE_H_ diff --git a/HtmlFile/HtmlFile.pro b/HtmlFile/HtmlFile.pro new file mode 100644 index 0000000000..96173eae4f --- /dev/null +++ b/HtmlFile/HtmlFile.pro @@ -0,0 +1,88 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2015-05-18T16:30:42 +# +#------------------------------------------------- + +QT -= core gui + +VERSION = 1.0.0.1 +TARGET = HtmlFile +TEMPLATE = lib + +#CONFIG += staticlib +CONFIG += shared + +############### destination path ############### +DESTINATION_SDK_PATH = $$PWD/../SDK/lib + +# WINDOWS +win32:contains(QMAKE_TARGET.arch, x86_64):{ +CONFIG(debug, debug|release) { + DESTDIR = $$DESTINATION_SDK_PATH/win_64/DEBUG +} else { + DESTDIR = $$DESTINATION_SDK_PATH/win_64 +} +} +win32:!contains(QMAKE_TARGET.arch, x86_64):{ +CONFIG(debug, debug|release) { + DESTDIR = $$DESTINATION_SDK_PATH/win_32/DEBUG +} else { + DESTDIR = $$DESTINATION_SDK_PATH/win_32 +} +} + +linux-g++:contains(QMAKE_HOST.arch, x86_64):{ + DESTDIR = $$DESTINATION_SDK_PATH/linux_64 +} +linux-g++:!contains(QMAKE_HOST.arch, x86_64):{ + DESTDIR = $$DESTINATION_SDK_PATH/linux_32 +} + +################################################ + +############# dynamic dependencies ############# +shared { + DEFINES += HTMLFILE_USE_DYNAMIC_LIBRARY + + LIBS += -L$$DESTDIR -llibxml + + message(dynamic) + + win32 { + TARGET_EXT = .dll + } + + linux-g++ | linux-g++-64 | linux-g++-32 { + CONFIG += plugin + TARGET_EXT = .so + } +} +################################################ + +CONFIG += c++11 + +DEFINES += \ + _QT + +linux-g++ | linux-g++-64 | linux-g++-32 { + DEFINES += \ + LINUX \ + _LINUX \ + _LINUX_QT +} + +win32 { + DEFINES += \ + WIN32 \ + NOMINMAX +} + +SOURCES += HtmlFile.cpp + +HEADERS += HtmlFile.h + +unix { + target.path = /usr/lib + INSTALLS += target +} diff --git a/HtmlFile/test/main.cpp b/HtmlFile/test/main.cpp new file mode 100644 index 0000000000..5f08a51b04 --- /dev/null +++ b/HtmlFile/test/main.cpp @@ -0,0 +1,13 @@ +#include "../HtmlFile.h" +#include "../../DesktopEditor/common/File.h" + +int main(int argc, char *argv[]) +{ + std::wstring sPath = NSFile::GetProcessDirectory() + L"/../../Internal/Debug/"; + + CHtmlFile oFile; + + int nResult = oFile.Convert(L"xml", sPath); + + return 0; +} diff --git a/HtmlFile/test/test.pro b/HtmlFile/test/test.pro new file mode 100644 index 0000000000..30eb815692 --- /dev/null +++ b/HtmlFile/test/test.pro @@ -0,0 +1,59 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2015-07-21T18:28:42 +# +#------------------------------------------------- + +QT -= core +QT -= gui + +TARGET = test +CONFIG += console +CONFIG -= app_bundle + +DEFINES += HTMLFILE_USE_DYNAMIC_LIBRARY + +CONFIG(debug, debug|release) { + DESTDIR = $$PWD/Debug +} else { + DESTDIR = $$PWD/Release +} + +CONFIG += c++11 +TEMPLATE = app + +############### destination path ############### +DESTINATION_SDK_PATH = $$PWD/../../SDK/lib + +# WINDOWS +win32:contains(QMAKE_TARGET.arch, x86_64):{ +CONFIG(debug, debug|release) { + DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/win_64/DEBUG +} else { + DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/win_64 +} +} +win32:!contains(QMAKE_TARGET.arch, x86_64):{ +CONFIG(debug, debug|release) { + DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/win_32/DEBUG +} else { + DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/win_32 +} +} + +linux-g++:contains(QMAKE_HOST.arch, x86_64):{ + DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/linux_64 +} +linux-g++:!contains(QMAKE_HOST.arch, x86_64):{ + DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/linux_32 +} + +LIBS += -L$$DESTINATION_SDK_PATH -lHtmlFile + +win32 { +LIBS += -ladvapi32 \ + -luser32 \ + -lshell32 +} + +SOURCES += main.cpp