Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
onlyoffice_core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
onlyoffice_core
Commits
236e93aa
Commit
236e93aa
authored
Feb 27, 2017
by
Oleg Korshul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add GlobalVariable
parent
164c7faf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
0 deletions
+83
-0
DesktopEditor/doctrenderer/docbuilder_p.h
DesktopEditor/doctrenderer/docbuilder_p.h
+83
-0
No files found.
DesktopEditor/doctrenderer/docbuilder_p.h
View file @
236e93aa
...
...
@@ -85,6 +85,8 @@ public:
int
m_nFileType
;
std
::
string
m_sUtf8ArgumentJSON
;
std
::
string
m_sGlobalVariable
;
public:
CV8RealTimeWorker
()
...
...
@@ -172,6 +174,51 @@ public:
return
true
;
}
std
::
string
GetGlobalVariable
()
{
std
::
string
commandA
=
"JSON.stringify(GlobalVariable);"
;
v8
::
Context
::
Scope
context_scope
(
m_context
);
v8
::
TryCatch
try_catch
;
v8
::
Local
<
v8
::
String
>
source
=
v8
::
String
::
NewFromUtf8
(
m_isolate
,
commandA
.
c_str
());
v8
::
Local
<
v8
::
Script
>
script
=
v8
::
Script
::
Compile
(
source
);
std
::
string
sReturn
=
"{}"
;
if
(
try_catch
.
HasCaught
())
{
std
::
wstring
strCode
=
to_cstring
(
try_catch
.
Message
()
->
GetSourceLine
());
std
::
wstring
strException
=
to_cstring
(
try_catch
.
Message
()
->
Get
());
_LOGGING_ERROR_
(
L"execute_compile_code"
,
strCode
);
_LOGGING_ERROR_
(
L"execute_compile"
,
strException
);
return
false
;
}
else
{
v8
::
Local
<
v8
::
Value
>
_value
=
script
->
Run
();
if
(
try_catch
.
HasCaught
())
{
std
::
wstring
strCode
=
to_cstring
(
try_catch
.
Message
()
->
GetSourceLine
());
std
::
wstring
strException
=
to_cstring
(
try_catch
.
Message
()
->
Get
());
_LOGGING_ERROR_
(
L"execute_run_code"
,
strCode
);
_LOGGING_ERROR_
(
L"execute_run"
,
strException
);
return
false
;
}
if
(
_value
->
IsString
())
sReturn
=
to_cstringA
(
_value
);
}
return
sReturn
;
}
bool
OpenFile
(
const
std
::
wstring
&
sBasePath
,
const
std
::
wstring
&
path
,
const
std
::
string
&
sString
,
const
std
::
wstring
&
sCachePath
)
{
LOGGER_SPEED_START
...
...
@@ -245,6 +292,32 @@ public:
}
}
if
(
true
)
{
std
::
string
sArg
=
m_sGlobalVariable
;
if
(
sArg
.
empty
())
sArg
=
"{}"
;
NSCommon
::
string_replaceA
(
sArg
,
"
\\
"
,
"
\\\\
"
);
NSCommon
::
string_replaceA
(
sArg
,
"
\"
"
,
"
\\\"
"
);
std
::
string
sScriptVar
=
"var GlobalVariable = JSON.parse(
\"
"
+
sArg
+
"
\"
);"
;
v8
::
Local
<
v8
::
String
>
_sourceArg
=
v8
::
String
::
NewFromUtf8
(
m_isolate
,
sScriptVar
.
c_str
());
v8
::
Local
<
v8
::
Script
>
_scriptArg
=
v8
::
Script
::
Compile
(
_sourceArg
);
_scriptArg
->
Run
();
if
(
try_catch
.
HasCaught
())
{
std
::
wstring
strCode
=
to_cstring
(
try_catch
.
Message
()
->
GetSourceLine
());
std
::
wstring
strException
=
to_cstring
(
try_catch
.
Message
()
->
Get
());
_LOGGING_ERROR_
(
L"sdk_global_var_code"
,
strCode
);
_LOGGING_ERROR_
(
L"sdk_global_var"
,
strException
);
return
false
;
}
}
CNativeControl
*
pNative
=
NULL
;
bool
bIsBreak
=
false
;
...
...
@@ -473,6 +546,9 @@ namespace NSDoctRenderer
bool
m_bIsInit
;
bool
m_bIsCacheScript
;
std
::
string
m_sGlobalVariable
;
bool
m_bIsGlobalVariableUse
;
public:
CDocBuilder_Private
()
{
...
...
@@ -489,6 +565,9 @@ namespace NSDoctRenderer
m_pAdditionalData
=
NULL
;
m_bIsInit
=
false
;
m_bIsCacheScript
=
true
;
m_sGlobalVariable
=
""
;
m_bIsGlobalVariableUse
=
false
;
}
void
Init
()
...
...
@@ -935,6 +1014,8 @@ namespace NSDoctRenderer
m_sFileDir
=
L""
;
m_nFileType
=
-
1
;
if
(
m_pWorker
)
m_sGlobalVariable
=
m_pWorker
->
GetGlobalVariable
();
RELEASEOBJECT
(
m_pWorker
);
}
...
...
@@ -1137,6 +1218,7 @@ namespace NSDoctRenderer
m_pWorker
=
new
CV8RealTimeWorker
();
m_pWorker
->
m_nFileType
=
m_nFileType
;
m_pWorker
->
m_sUtf8ArgumentJSON
=
m_oParams
.
m_sArgumentJSON
;
m_pWorker
->
m_sGlobalVariable
=
m_sGlobalVariable
;
std
::
wstring
sCachePath
=
L""
;
if
(
m_bIsCacheScript
)
...
...
@@ -1480,6 +1562,7 @@ namespace NSDoctRenderer
{
//bIsNoError = this->m_pInternal->ExecuteCommand(NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)_data, (LONG)_len));
sJsCommands
+=
command
;
sJsCommands
+=
"
\n
"
;
}
if
(
!
bIsNoError
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment