Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
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
sdkjs
Commits
6a1945cd
Commit
6a1945cd
authored
May 02, 2017
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add function for convert formula to text
parent
426dcff6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
139 additions
and
0 deletions
+139
-0
common/wordcopypaste.js
common/wordcopypaste.js
+3
-0
word/Math/mathContent.js
word/Math/mathContent.js
+136
-0
No files found.
common/wordcopypaste.js
View file @
6a1945cd
...
@@ -2501,6 +2501,9 @@ PasteProcessor.prototype =
...
@@ -2501,6 +2501,9 @@ PasteProcessor.prototype =
_convertParaMathToText
:
function
(
paraMath
)
_convertParaMathToText
:
function
(
paraMath
)
{
{
//TODO пока добавляю функцию здесь. должна она находиться в Math.js
//TODO пока добавляю функцию здесь. должна она находиться в Math.js
var
res
=
paraMath
.
Root
.
GetTextContent
();
console
.
log
(
res
);
return
res
;
},
},
_convertTableToText
:
function
(
table
,
obj
,
newParagraph
)
_convertTableToText
:
function
(
table
,
obj
,
newParagraph
)
...
...
word/Math/mathContent.js
View file @
6a1945cd
...
@@ -7239,6 +7239,142 @@ CMathContent.prototype.ReplaceAutoCorrect = function(AutoCorrectEngine, bCursorS
...
@@ -7239,6 +7239,142 @@ CMathContent.prototype.ReplaceAutoCorrect = function(AutoCorrectEngine, bCursorS
}
}
};
};
CMathContent
.
prototype
.
GetTextContent
=
function
(
arr
,
str
)
{
if
(
!
arr
)
{
arr
=
[];
}
if
(
!
str
)
{
str
=
""
;
}
var
getMathSymbol
=
function
(
elem
)
{
var
res
=
""
;
if
(
elem
instanceof
CDegree
)
{
res
=
"
^
"
;
}
else
if
(
elem
instanceof
CDelimiter
)
{
res
=
"
Delimiter
"
;
}
else
if
(
elem
instanceof
CNary
)
{
res
=
"
CNary
"
;
}
else
if
(
elem
instanceof
CFraction
)
{
res
=
"
/
"
;
}
else
if
(
elem
instanceof
CRadical
)
{
res
=
"
√
"
;
//8730
}
return
res
;
};
for
(
var
i
=
0
;
i
<
this
.
Content
.
length
;
i
++
)
{
switch
(
this
.
Content
[
i
].
Type
)
{
case
para_Math_Run
:
{
for
(
var
j
=
0
;
j
<
this
.
Content
[
i
].
Content
.
length
;
j
++
)
{
if
(
para_Math_Content
===
this
.
Content
[
i
].
Content
[
j
].
Type
)
{
str
=
this
.
Content
[
i
].
Content
[
j
].
GetTextContent
(
arr
,
str
);
}
else
if
(
para_Math_Text
===
this
.
Content
[
i
].
Content
[
j
].
Type
)
{
arr
.
push
(
String
.
fromCharCode
(
this
.
Content
[
i
].
Content
[
j
].
value
));
str
+=
String
.
fromCharCode
(
this
.
Content
[
i
].
Content
[
j
].
value
);
}
else
if
(
para_Math_BreakOperator
===
this
.
Content
[
i
].
Content
[
j
].
Type
)
{
arr
.
push
(
String
.
fromCharCode
(
this
.
Content
[
i
].
Content
[
j
].
value
));
str
+=
String
.
fromCharCode
(
this
.
Content
[
i
].
Content
[
j
].
value
);
}
}
break
;
}
case
para_Math_Composition
:
{
var
symbol
=
getMathSymbol
(
this
.
Content
[
i
]);
for
(
var
j
=
0
;
j
<
this
.
Content
[
i
].
Content
.
length
;
j
++
)
{
if
(
para_Math_Content
===
this
.
Content
[
i
].
Content
[
j
].
Type
)
{
if
(
this
.
Content
[
i
].
Content
.
length
>
1
)
{
arr
.
push
(
"
(
"
);
str
+=
"
(
"
;
}
str
=
this
.
Content
[
i
].
Content
[
j
].
GetTextContent
(
arr
,
str
);
if
(
this
.
Content
[
i
].
Content
.
length
>
1
)
{
arr
.
push
(
"
)
"
);
str
+=
"
)
"
;
}
if
(
j
!==
this
.
Content
[
i
].
Content
.
length
-
1
)
{
/*if(this.Content[i].Content.length > 1)
{
arr.push(")");
str += ")";
}*/
arr
.
push
(
symbol
);
str
+=
symbol
;
/*if(this.Content[i].Content.length > 1)
{
arr.push("(");
str += "(";
}*/
}
}
else
if
(
para_Math_Text
===
this
.
Content
[
i
].
Content
[
j
].
Type
)
{
arr
.
push
(
String
.
fromCharCode
(
this
.
Content
[
i
].
Content
[
j
].
value
));
str
+=
String
.
fromCharCode
(
this
.
Content
[
i
].
Content
[
j
].
value
);
}
else
if
(
para_Math_BreakOperator
===
this
.
Content
[
i
].
Content
[
j
].
Type
)
{
arr
.
push
(
String
.
fromCharCode
(
this
.
Content
[
i
].
Content
[
j
].
value
));
str
+=
String
.
fromCharCode
(
this
.
Content
[
i
].
Content
[
j
].
value
);
}
}
/*if(this.Content[i].Content.length > 1)
{
arr.push(")");
str += ")";
}*/
break
;
}
case
para_Math_Text
:
{
arr
.
push
(
String
.
fromCharCode
(
this
.
Content
[
i
].
value
));
str
+=
String
.
fromCharCode
(
this
.
Content
[
i
].
value
);
break
;
}
}
}
return
str
;
};
function
CMathBracketAcc
()
function
CMathBracketAcc
()
{
{
...
...
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