Commit 817ba587 authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov

HtmlFile.Начало

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63734 954022d7-b5bf-4e40-9824-e11837661b57
parent be3bc9cb
......@@ -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
#include "HtmlFile.h"
#include "../DesktopEditor/common/File.h"
#ifdef LINUX
#include <unistd.h>
#include <sys/wait.h>
#include <stdio.h>
#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;
}
#ifndef _HTMLFILE_HTMLFILE_H_
#define _HTMLFILE_HTMLFILE_H_
#include <string>
#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_
#-------------------------------------------------
#
# 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
}
#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;
}
#-------------------------------------------------
#
# 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment