From fc7891b1760c68dcbd5591fdf0e09663bf35d617 Mon Sep 17 00:00:00 2001 From: Kulikova Svetlana Date: Thu, 29 Oct 2020 18:03:32 +0300 Subject: [PATCH] first test --- DesktopEditor/doctrenderer/docbuilder_p.cpp | 4 ++ DesktopEditor/doctrenderer/docbuilder_p.h | 1 - DesktopEditor/doctrenderer/doctrenderer.cpp | 7 +++- .../doctrenderer/js/NativeGraphics.js | 39 ++++++++++++------- DesktopEditor/doctrenderer/js/test.js | 11 ++++++ 5 files changed, 47 insertions(+), 15 deletions(-) create mode 100644 DesktopEditor/doctrenderer/js/test.js diff --git a/DesktopEditor/doctrenderer/docbuilder_p.cpp b/DesktopEditor/doctrenderer/docbuilder_p.cpp index b115eacd38..f169879739 100644 --- a/DesktopEditor/doctrenderer/docbuilder_p.cpp +++ b/DesktopEditor/doctrenderer/docbuilder_p.cpp @@ -199,6 +199,10 @@ bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstri pNative->m_strFontsDirectory = sBasePath + L"/sdkjs/common"; pNative->m_strImagesDirectory = path + L"/media"; + NSGraphics::CGraphics::m_sApplicationFontsDirectory = pNative->m_strFontsDirectory; + NSGraphics::CGraphics::m_sApplicationImagesDirectory = pNative->m_strImagesDirectory; + NSGraphics::CGraphics::m_sApplicationThemesDirectory = sBasePath + L"/sdkjs/slide/themes"; + pNative->CheckFonts(); if (0 == m_nFileType) diff --git a/DesktopEditor/doctrenderer/docbuilder_p.h b/DesktopEditor/doctrenderer/docbuilder_p.h index 245e9e93a0..a0e3f2ae2b 100644 --- a/DesktopEditor/doctrenderer/docbuilder_p.h +++ b/DesktopEditor/doctrenderer/docbuilder_p.h @@ -318,7 +318,6 @@ namespace NSDoctRenderer oWorker.m_bIsUseSystemFonts = bIsCheckSystemFonts; oWorker.m_bIsNeedThumbnails = false; oWorker.m_sDirectory = sDirectory; - NSGraphics::CGraphics::m_sApplicationFontsDirectory = sDirectory; NSFonts::IApplicationFonts* pFonts = oWorker.Check(); if(pFonts) pFonts->Release(); diff --git a/DesktopEditor/doctrenderer/doctrenderer.cpp b/DesktopEditor/doctrenderer/doctrenderer.cpp index ff0b60ca5a..49fdad9777 100644 --- a/DesktopEditor/doctrenderer/doctrenderer.cpp +++ b/DesktopEditor/doctrenderer/doctrenderer.cpp @@ -635,13 +635,18 @@ namespace NSDoctRenderer LOGGER_SPEED_LAP("compile") - context->runScript(strScript, try_catch, sCachePath); + JSSmart res = context->runScript(strScript, try_catch, sCachePath); if(try_catch->Check()) { strError = L"code=\"run\""; bIsBreak = true; } +#ifdef _DEBUG + std::string sRes = res->toStringA(); + std::cout << sRes << std::endl; +#endif + LOGGER_SPEED_LAP("run") //--------------------------------------------------------------- diff --git a/DesktopEditor/doctrenderer/js/NativeGraphics.js b/DesktopEditor/doctrenderer/js/NativeGraphics.js index e7322c6698..7f67b5ccdb 100644 --- a/DesktopEditor/doctrenderer/js/NativeGraphics.js +++ b/DesktopEditor/doctrenderer/js/NativeGraphics.js @@ -12,18 +12,18 @@ function CNativeGraphics(_writer) this.m_dDpiY = 96.0; this.m_bIsBreak = false; - this.m_oPen = new AscCommon.CPen(); + //this.m_oPen = new AscCommon.CPen(); this.m_bPenColorInit = false; - this.m_oBrush = new AscCommon.CBrush(); + //this.m_oBrush = new AscCommon.CBrush(); this.m_bBrushColorInit = false; this.m_oFontManager = null; - this.m_oCoordTransform = new AscCommon.CMatrixL(); - this.m_oBaseTransform = new AscCommon.CMatrixL(); - this.m_oTransform = new AscCommon.CMatrixL(); - this.m_oFullTransform = new AscCommon.CMatrixL(); - this.m_oInvertFullTransform = new AscCommon.CMatrixL(); + //this.m_oCoordTransform = new AscCommon.CMatrixL(); + //this.m_oBaseTransform = new AscCommon.CMatrixL(); + //this.m_oTransform = new AscCommon.CMatrixL(); + //this.m_oFullTransform = new AscCommon.CMatrixL(); + //this.m_oInvertFullTransform = new AscCommon.CMatrixL(); this.ArrayPoints = null; @@ -37,15 +37,15 @@ function CNativeGraphics(_writer) // RFonts this.m_oTextPr = null; - this.m_oGrFonts = new AscCommon.CGrRFonts(); - this.m_oLastFont = new AscCommon.CFontSetup(); + //this.m_oGrFonts = new AscCommon.CGrRFonts(); + //this.m_oLastFont = new AscCommon.CFontSetup(); this.LastFontOriginInfo = { Name : "", Replace : null }; this.m_bIntegerGrid = true; - this.ClipManager = new AscCommon.CClipManager(); - this.ClipManager.BaseObject = this; + //this.ClipManager = new AscCommon.CClipManager(); + //this.ClipManager.BaseObject = this; this.TextureFillTransformScaleX = 1; this.TextureFillTransformScaleY = 1; @@ -53,8 +53,8 @@ function CNativeGraphics(_writer) this.IsDemonstrationMode = false; - this.GrState = new AscCommon.CGrState(); - this.GrState.Parent = this; + //this.GrState = new AscCommon.CGrState(); + //this.GrState.Parent = this; this.globalAlpha = 1; @@ -1349,3 +1349,16 @@ CNativeGraphics.prototype = this.Native["DrawFootnoteRect"](x, y, w, h); } }; + +function CTest() +{ + this.a = 10; +} + +CTest.prototype = +{ + getA : function() + { + return this.a; + } +} diff --git a/DesktopEditor/doctrenderer/js/test.js b/DesktopEditor/doctrenderer/js/test.js new file mode 100644 index 0000000000..31d0adeabc --- /dev/null +++ b/DesktopEditor/doctrenderer/js/test.js @@ -0,0 +1,11 @@ + +var MyTest = new CTest(); // It's work +// MyTest.getA(); // It's work + + +var MyGraphics = new CNativeGraphics(null); // It's doesn't work. only works with comments + +// var MyNativeGraphics = CreateNativeGraphics(); // It's work. This is CGraphicsEmbed::CreateObjectInContext("CreateNativeGraphics", context); +// var MyGraphics2 = new CNativeGraphics(MyNativeGraphics); // It's doesn't work either + +MyGraphics.GetIntegerGrid();