Commit 500f95cf authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov

DocBuilder

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@68603 954022d7-b5bf-4e40-9824-e11837661b57
parent b8fffbf5
This diff is collapsed.
#ifndef DOCBUILDER_H
#define DOCBUILDER_H
#include <string>
#include <vector>
#include "../common/base_export.h"
namespace NSDoctRenderer
{
class CDocBuilder_Private;
class Q_DECL_EXPORT CDocBuilder
{
public:
CDocBuilder();
~CDocBuilder();
public:
bool OpenFile(const std::wstring& path, const std::wstring& params);
bool CreateFile(const int& type);
void SetTmpFolder(const std::wstring& folder);
bool SaveFile(const int& type, const std::wstring& path);
void CloseFile();
bool ExecuteCommand(const std::wstring& command);
private:
CDocBuilder_Private* m_pInternal;
};
}
#endif // DOCBUILDER_H
......@@ -133,6 +133,19 @@ void CreateNativeObject(const v8::FunctionCallbackInfo<v8::Value>& args)
args.GetReturnValue().Set(obj);
}
void CreateNativeObjectBuilder(const v8::FunctionCallbackInfo<v8::Value>& args)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Handle<v8::ObjectTemplate> NativeObjectTemplate = CreateNativeControlTemplateBuilder(isolate);
CNativeControl* pNativeObject = new CNativeControl();
v8::Local<v8::Object> obj = NativeObjectTemplate->NewInstance();
obj->SetInternalField(0, v8::External::New(v8::Isolate::GetCurrent(), pNativeObject));
args.GetReturnValue().Set(obj);
}
void CreateNativeMemoryStream(const v8::FunctionCallbackInfo<v8::Value>& args)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
......
......@@ -3,8 +3,6 @@
#include <string>
#include <vector>
#include "../common/Types.h"
#include "../common/Array.h"
#include "../common/base_export.h"
namespace NSDoctRenderer
......
......@@ -104,6 +104,9 @@ include(../Qt_build/graphics/project/graphics_fonts.pri)
LIB_XML_PRI_PATH = ../xml
include(../xml/build/qt/libxml2.pri)
CONFIG += build_all_zlib build_zlib_as_sources
include(../../OfficeUtils/OfficeUtils.pri)
win32:contains(QMAKE_TARGET.arch, x86_64):{
CONFIG(debug, debug|release) {
......@@ -168,9 +171,18 @@ mac {
}
##################################################
SOURCES += doctrenderer.cpp
SOURCES += \
memorystream.cpp \
nativecontrol.cpp \
doctrenderer.cpp \
docbuilder.cpp
SOURCES += \
../../Common/OfficeFileFormatChecker2.cpp \
../../Common/3dParty/pole/pole.cpp
HEADERS += doctrenderer.h \
docbuilder.h \
memorystream.h \
nativecontrol.h
......
#include "memorystream.h"
// wrap_methods -------------
CMemoryStream* unwrap_memorystream(v8::Handle<v8::Object> obj)
{
v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(obj->GetInternalField(0));
return static_cast<CMemoryStream*>(field->Value());
}
void _ms_write_byte(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
BYTE arg = (BYTE)args[0]->Int32Value();
pNative->WriteBYTE(arg);
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_write_bool(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
BYTE arg = (BYTE)args[0]->BooleanValue();
pNative->WriteBYTE(arg ? 1 : 0);
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_write_long(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
LONG arg = (LONG)args[0]->Int32Value();
pNative->WriteLONG(arg);
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_write_double(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
double arg = (double)args[0]->NumberValue();
pNative->WriteLONG((LONG)(arg * 100000));
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_writestring1(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
v8::String::Value data(args[0]);
pNative->WriteString((wchar_t*)*data, data.length());
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_writestring2(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
v8::String::Value data(args[0]);
pNative->WriteString2((wchar_t*)*data, data.length());
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_copy(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
CMemoryStream* pNative2 = unwrap_memorystream(args[0]->ToObject());
size_t pos = (size_t)args[1]->Uint32Value();
size_t len = (size_t)args[2]->Uint32Value();
pNative->Copy(pNative2, pos, len);
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_clearnoattack(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
pNative->ClearNoAttack();
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_pos(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
{
CMemoryStream* pNative = unwrap_memorystream(info.Holder());
info.GetReturnValue().Set(v8::Integer::New(v8::Isolate::GetCurrent(), pNative->GetSize()));
}
v8::Handle<v8::ObjectTemplate> CreateMemoryStreamTemplate(v8::Isolate* isolate)
{
//v8::HandleScope handle_scope(isolate);
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New();
result->SetInternalFieldCount(1); // отводим в нем место для хранения CNativeControl
v8::Isolate* current = v8::Isolate::GetCurrent();
// property
result->SetAccessor(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), "pos"), _ms_pos); // получить код ошибки
// прописываем функции - методы объекта
result->Set(v8::String::NewFromUtf8(current, "Copy"), v8::FunctionTemplate::New(current, _ms_copy));
result->Set(v8::String::NewFromUtf8(current, "ClearNoAttack"), v8::FunctionTemplate::New(current, _ms_clearnoattack));
result->Set(v8::String::NewFromUtf8(current, "WriteByte"), v8::FunctionTemplate::New(current, _ms_write_byte));
result->Set(v8::String::NewFromUtf8(current, "WriteBool"), v8::FunctionTemplate::New(current, _ms_write_bool));
result->Set(v8::String::NewFromUtf8(current, "WriteLong"), v8::FunctionTemplate::New(current, _ms_write_long));
result->Set(v8::String::NewFromUtf8(current, "WriteDouble"), v8::FunctionTemplate::New(current, _ms_write_double));
result->Set(v8::String::NewFromUtf8(current, "WriteString"), v8::FunctionTemplate::New(current, _ms_writestring1));
result->Set(v8::String::NewFromUtf8(current, "WriteString2"), v8::FunctionTemplate::New(current, _ms_writestring2));
// возвращаем временный хэндл хитрым образом, который переносит наш хэндл в предыдущий HandleScope и не дает ему
// уничтожиться при уничтожении "нашего" HandleScope - handle_scope
//return handle_scope.Close(result);
return result;
}
......@@ -151,118 +151,23 @@ public:
};
// wrap_methods -------------
CMemoryStream* unwrap_memorystream(v8::Handle<v8::Object> obj)
{
v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(obj->GetInternalField(0));
return static_cast<CMemoryStream*>(field->Value());
}
void _ms_write_byte(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
BYTE arg = (BYTE)args[0]->Int32Value();
pNative->WriteBYTE(arg);
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_write_bool(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
BYTE arg = (BYTE)args[0]->BooleanValue();
pNative->WriteBYTE(arg ? 1 : 0);
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_write_long(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
LONG arg = (LONG)args[0]->Int32Value();
pNative->WriteLONG(arg);
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_write_double(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
double arg = (double)args[0]->NumberValue();
pNative->WriteLONG((LONG)(arg * 100000));
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_writestring1(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
v8::String::Value data(args[0]);
pNative->WriteString((wchar_t*)*data, data.length());
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_writestring2(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
v8::String::Value data(args[0]);
pNative->WriteString2((wchar_t*)*data, data.length());
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_copy(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
CMemoryStream* pNative2 = unwrap_memorystream(args[0]->ToObject());
size_t pos = (size_t)args[1]->Uint32Value();
size_t len = (size_t)args[2]->Uint32Value();
pNative->Copy(pNative2, pos, len);
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_clearnoattack(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CMemoryStream* pNative = unwrap_memorystream(args.This());
pNative->ClearNoAttack();
args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
void _ms_pos(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
{
CMemoryStream* pNative = unwrap_memorystream(info.Holder());
info.GetReturnValue().Set(v8::Integer::New(v8::Isolate::GetCurrent(), pNative->GetSize()));
}
v8::Handle<v8::ObjectTemplate> CreateMemoryStreamTemplate(v8::Isolate* isolate)
{
//v8::HandleScope handle_scope(isolate);
CMemoryStream* unwrap_memorystream(v8::Handle<v8::Object> obj);
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New();
result->SetInternalFieldCount(1); // отводим в нем место для хранения CNativeControl
void _ms_write_byte(const v8::FunctionCallbackInfo<v8::Value>& args);
void _ms_write_bool(const v8::FunctionCallbackInfo<v8::Value>& args);
void _ms_write_long(const v8::FunctionCallbackInfo<v8::Value>& args);
void _ms_write_double(const v8::FunctionCallbackInfo<v8::Value>& args);
v8::Isolate* current = v8::Isolate::GetCurrent();
void _ms_writestring1(const v8::FunctionCallbackInfo<v8::Value>& args);
void _ms_writestring2(const v8::FunctionCallbackInfo<v8::Value>& args);
// property
result->SetAccessor(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), "pos"), _ms_pos); // получить код ошибки
void _ms_copy(const v8::FunctionCallbackInfo<v8::Value>& args);
// прописываем функции - методы объекта
result->Set(v8::String::NewFromUtf8(current, "Copy"), v8::FunctionTemplate::New(current, _ms_copy));
result->Set(v8::String::NewFromUtf8(current, "ClearNoAttack"), v8::FunctionTemplate::New(current, _ms_clearnoattack));
result->Set(v8::String::NewFromUtf8(current, "WriteByte"), v8::FunctionTemplate::New(current, _ms_write_byte));
result->Set(v8::String::NewFromUtf8(current, "WriteBool"), v8::FunctionTemplate::New(current, _ms_write_bool));
result->Set(v8::String::NewFromUtf8(current, "WriteLong"), v8::FunctionTemplate::New(current, _ms_write_long));
result->Set(v8::String::NewFromUtf8(current, "WriteDouble"), v8::FunctionTemplate::New(current, _ms_write_double));
result->Set(v8::String::NewFromUtf8(current, "WriteString"), v8::FunctionTemplate::New(current, _ms_writestring1));
result->Set(v8::String::NewFromUtf8(current, "WriteString2"), v8::FunctionTemplate::New(current, _ms_writestring2));
void _ms_clearnoattack(const v8::FunctionCallbackInfo<v8::Value>& args);
// возвращаем временный хэндл хитрым образом, который переносит наш хэндл в предыдущий HandleScope и не дает ему
// уничтожиться при уничтожении "нашего" HandleScope - handle_scope
void _ms_pos(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info);
//return handle_scope.Close(result);
return result;
}
v8::Handle<v8::ObjectTemplate> CreateMemoryStreamTemplate(v8::Isolate* isolate);
#endif // MEMORYSTREAM
This diff is collapsed.
This diff is collapsed.
......@@ -11,15 +11,15 @@ int main(int argc, char *argv[])
#if 1
std::wstring strXml = L"<Settings>\
<SrcFileType>1</SrcFileType>\
<SrcFileType>0</SrcFileType>\
<DstFileType>3</DstFileType>\
<SrcFilePath>D:\\build_doc</SrcFilePath>\
<DstFilePath>D:\\build_doc\\EditorWithChanges.bin</DstFilePath>\
<FontsDirectory>D:\\activex\\AVS\\Sources\\TeamlabOffice\\trunk\\OfficeWeb\\Fonts\\native</FontsDirectory>\
<ImagesDirectory>D:\\build_doc\\media</ImagesDirectory>\
<SrcFilePath>D:\\DE_CAD4</SrcFilePath>\
<DstFilePath>D:\\DE_CAD4\\EditorWithChanges.bin</DstFilePath>\
<FontsDirectory>D:\\activex\\AVS\\Sources\\TeamlabOffice\\trunk\\ServerComponents\\DesktopEditor\\ChromiumBasedEditors2\\app\\test\\src\\build\\win64\\Debug\\Local\\converter\\fonts\\</FontsDirectory>\
<ImagesDirectory>D:\\DE_CAD4\\media</ImagesDirectory>\
<ThemesDirectory>D:\\activex\\AVS\\Sources\\TeamlabOffice\\trunk\\ServerComponents\\Test\\Applications\\TestAVSOfficeDocxFile2\\TestAVSOfficeDocxFile2\\bin\\x86\\presentationthemes</ThemesDirectory>\
<Changes TopItem=\"-1\">\
<Change>D:\\build_doc\\changes\\changes0.json</Change>\
<Change>D:\\DE_CAD4\\changes\\changes0.json</Change>\
</Changes>\
</Settings>";
......@@ -54,7 +54,7 @@ int main(int argc, char *argv[])
#if 1
NSDoctRenderer::CDoctrenderer oRenderer;
NSDoctRenderer::CDoctrenderer oRenderer(L"C:/ProgramData/ONLYOFFICE/webdata/cloud/fonts/AllFonts.js");
std::wstring sError;
oRenderer.Execute(strXml, sError);
......@@ -68,7 +68,7 @@ int main(int argc, char *argv[])
CPdfRenderer oPDF(&oFonts);
oPDF.SetTempFolder(L"D:\\test_pdf");
oPDF.OnlineWordToPdfFromBinary(L"D:\\test_pdf\\pdf.bin", L"D:\\test_pdf\\123.pdf");
oPDF.OnlineWordToPdfFromBinary(L"D:\\DE_CAD4\\EditorWithChanges.bin", L"D:\\test_pdf\\123.pdf");
#endif
......
#-------------------------------------------------
#
# Project created by QtCreator 2015-01-19T14:14:33
#
#-------------------------------------------------
QT -= core
QT -= gui
TARGET = docbuilder
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
CONFIG -= debug_and_release debug_and_release_target
############### destination path ###############
DESTINATION_SDK_PATH = $$PWD/../../../SDK/lib
# WINDOWS
win32:contains(QMAKE_TARGET.arch, x86_64):{
CONFIG(debug, debug|release) {
DESTINATION_SDK_PATH_DOCTRENDERER = $$DESTINATION_SDK_PATH/win_64/DEBUG
} else {
DESTINATION_SDK_PATH_DOCTRENDERER = $$DESTINATION_SDK_PATH/win_64
}
}
win32:!contains(QMAKE_TARGET.arch, x86_64):{
CONFIG(debug, debug|release) {
DESTINATION_SDK_PATH_DOCTRENDERER = $$DESTINATION_SDK_PATH/win_32/DEBUG
} else {
DESTINATION_SDK_PATH_DOCTRENDERER = $$DESTINATION_SDK_PATH/win_32
}
}
linux-g++:contains(QMAKE_HOST.arch, x86_64):{
DESTINATION_SDK_PATH_DOCTRENDERER = $$DESTINATION_SDK_PATH/linux_64
}
linux-g++:!contains(QMAKE_HOST.arch, x86_64):{
DESTINATION_SDK_PATH_DOCTRENDERER = $$DESTINATION_SDK_PATH/linux_32
}
mac {
DESTINATION_SDK_PATH_DOCTRENDERER = $$DESTINATION_SDK_PATH/mac_64
}
CONFIG(debug, debug|release) {
DESTDIR = $$PWD/Debug
} else {
DESTDIR = $$PWD/Release
}
################################################
LIBS += -L$$DESTINATION_SDK_PATH_DOCTRENDERER -ldoctrenderer
SOURCES += main.cpp
#include "../docbuilder.h"
#define AVS_OFFICESTUDIO_FILE_DOCUMENT 0x0040
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0001
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0002
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0003
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_RTF AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0004
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0005
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0006
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0007
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_EPUB AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0008
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_FB2 AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0009
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_MOBI AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x000a
#define AVS_OFFICESTUDIO_FILE_PRESENTATION 0x0080
#define AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x0001
#define AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x0002
#define AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x0003
#define AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSX AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x0004
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET 0x0100
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0001
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0002
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0003
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0004
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM 0x0200
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0001
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_DJVU AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0003
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0004
int main(int argc, char *argv[])
{
NSDoctRenderer::CDocBuilder oBuilder;
// tmpfolder
oBuilder.SetTmpFolder(L"D:/BuilderTest");
#if 1
oBuilder.CreateFile(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX);
oBuilder.ExecuteCommand(L"Add_Text(\"Oleg\");");
#endif
#if 0
oBuilder.OpenFile(L"D:/TESTFILES/images.docx", L"");
#endif
oBuilder.SaveFile(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF, L"D:/TESTFILES/images.pdf");
return 0;
}
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