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
0f742b18
Commit
0f742b18
authored
Jun 10, 2016
by
Alexander.Trofimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update changeOffset and assemble functions
parent
b388cd4c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
88 deletions
+90
-88
cell/model/FormulaObjects/parserFormula.js
cell/model/FormulaObjects/parserFormula.js
+90
-88
No files found.
cell/model/FormulaObjects/parserFormula.js
View file @
0f742b18
...
...
@@ -4301,70 +4301,71 @@ parserFormula.prototype.getRef = function() {
return
aOutRef
;
};
/* Для обратной сборки функции иногда необходимо поменять ссылки на ячейки */
parserFormula
.
prototype
.
changeOffset
=
function
(
offset
)
{
//offset = {offsetCol:intNumber, offsetRow:intNumber}
for
(
var
i
=
0
;
i
<
this
.
outStack
.
length
;
i
++
)
{
if
(
this
.
outStack
[
i
]
instanceof
cRef
||
this
.
outStack
[
i
]
instanceof
cRef3D
||
this
.
outStack
[
i
]
instanceof
cArea
)
{
var
r
=
this
.
outStack
[
i
].
getRange
();
if
(
!
r
)
{
break
;
}
if
(
this
.
outStack
[
i
].
isAbsolute
)
{
this
.
_changeOffsetHelper
(
this
.
outStack
[
i
],
offset
);
}
else
{
var
a
,
b
;
if
(
this
.
outStack
[
i
]
instanceof
cArea
&&
(
r
.
isColumn
()
&&
offset
.
offsetRow
!=
0
||
r
.
isRow
()
&&
offset
.
offsetCol
!=
0
))
{
continue
;
}
r
.
setOffset
(
offset
);
if
(
r
.
isColumn
())
{
a
=
r
.
first
.
getColLetter
();
b
=
r
.
last
.
getColLetter
();
}
else
if
(
r
.
isRow
())
{
a
=
r
.
first
.
getRow
();
b
=
r
.
last
.
getRow
();
}
else
{
a
=
r
.
first
.
getID
();
b
=
r
.
last
.
getID
();
}
/* Для обратной сборки функции иногда необходимо поменять ссылки на ячейки */
parserFormula
.
prototype
.
changeOffset
=
function
(
offset
)
{
//offset = AscCommonExcel.CRangeOffset
var
elem
,
r
,
a
,
b
;
for
(
var
i
=
0
;
i
<
this
.
outStack
.
length
;
i
++
)
{
elem
=
this
.
outStack
[
i
];
if
(
cElementType
.
cell
===
elem
.
type
||
cElementType
.
cell3D
===
elem
.
type
||
cElementType
.
cellsRange
===
elem
.
type
)
{
r
=
elem
.
getRange
();
if
(
!
r
)
{
break
;
}
if
(
a
!=
b
||
this
.
outStack
[
i
]
instanceof
cArea
)
{
this
.
outStack
[
i
].
value
=
this
.
outStack
[
i
].
_cells
=
a
+
"
:
"
+
b
;
}
else
{
this
.
outStack
[
i
].
value
=
this
.
outStack
[
i
].
_cells
=
a
;
}
}
continue
;
}
if
(
this
.
outStack
[
i
]
instanceof
cArea3D
)
{
var
r
=
this
.
outStack
[
i
].
_cells
.
indexOf
(
"
:
"
)
>
-
1
?
(
new
cArea
(
this
.
outStack
[
i
].
_cells
,
this
.
ws
))
:
(
new
cRef
(
this
.
outStack
[
i
].
_cells
,
this
.
ws
));
var
_r
=
r
.
getRange
();
if
(
elem
.
isAbsolute
)
{
this
.
_changeOffsetHelper
(
elem
,
offset
);
}
else
{
if
(
cElementType
.
cellsRange
===
elem
.
type
&&
(
r
.
isColumn
()
&&
offset
.
offsetRow
!=
0
||
r
.
isRow
()
&&
offset
.
offsetCol
!=
0
))
{
continue
;
}
r
.
setOffset
(
offset
);
if
(
r
.
isColumn
())
{
a
=
r
.
first
.
getColLetter
();
b
=
r
.
last
.
getColLetter
();
}
else
if
(
r
.
isRow
())
{
a
=
r
.
first
.
getRow
();
b
=
r
.
last
.
getRow
();
}
else
{
a
=
r
.
first
.
getID
();
b
=
r
.
last
.
getID
();
}
if
(
a
!=
b
||
cElementType
.
cellsRange
===
elem
.
type
)
{
elem
.
value
=
elem
.
_cells
=
a
+
"
:
"
+
b
;
}
else
{
elem
.
value
=
elem
.
_cells
=
a
;
}
}
continue
;
}
if
(
cElementType
.
cellsRange3D
===
elem
.
type
)
{
r
=
elem
.
_cells
.
indexOf
(
"
:
"
)
>
-
1
?
(
new
cArea
(
elem
.
_cells
,
this
.
ws
))
:
(
new
cRef
(
elem
.
_cells
,
this
.
ws
));
var
_r
=
r
.
getRange
();
if
(
!
_r
)
{
break
;
}
if
(
!
_r
)
{
break
;
}
if
(
this
.
outStack
[
i
].
isAbsolute
)
{
this
.
_changeOffsetHelper
(
r
,
offset
);
}
else
{
_r
.
setOffset
(
offset
);
var
a
=
_r
.
first
.
getID
(),
b
=
_r
.
last
.
getID
();
if
(
a
!=
b
)
{
r
.
value
=
r
.
_cells
=
a
+
"
:
"
+
b
;
}
else
{
r
.
value
=
r
.
_cells
=
a
;
}
}
this
.
outStack
[
i
].
_cells
=
r
.
_cells
;
}
}
return
this
;
};
if
(
elem
.
isAbsolute
)
{
this
.
_changeOffsetHelper
(
r
,
offset
);
}
else
{
_r
.
setOffset
(
offset
);
a
=
_r
.
first
.
getID
();
b
=
_r
.
last
.
getID
();
if
(
a
!=
b
)
{
r
.
value
=
r
.
_cells
=
a
+
"
:
"
+
b
;
}
else
{
r
.
value
=
r
.
_cells
=
a
;
}
}
elem
.
_cells
=
r
.
_cells
;
}
}
return
this
;
};
parserFormula
.
prototype
.
setRefError
=
function
(
node
)
{
//когда выставляется setRefError node не сдвигаются, поэтому node.cellId совпадает с elem._cells
...
...
@@ -4469,33 +4470,34 @@ parserFormula.prototype.changeSheet = function(lastName, newName) {
return
this
;
};
/* Сборка функции в инфиксную форму */
parserFormula
.
prototype
.
assemble
=
function
(
rFormula
)
{
if
(
!
rFormula
&&
this
.
outStack
.
length
==
1
&&
this
.
outStack
[
this
.
outStack
.
length
-
1
]
instanceof
cError
)
{
return
this
.
Formula
;
}
var
currentElement
=
null
,
_count
=
this
.
outStack
.
length
,
elemArr
=
new
Array
(
_count
),
res
=
undefined
,
_count_arg
;
for
(
var
i
=
0
,
j
=
0
;
i
<
_count
;
i
++
,
j
++
)
{
currentElement
=
this
.
outStack
[
i
];
if
(
currentElement
.
type
==
cElementType
.
operator
||
currentElement
.
type
==
cElementType
.
func
)
{
_count_arg
=
currentElement
.
getArguments
();
res
=
currentElement
.
Assemble2
(
elemArr
,
j
-
_count_arg
,
_count_arg
);
j
-=
_count_arg
;
elemArr
[
j
]
=
res
;
}
else
{
if
(
currentElement
instanceof
cString
)
{
currentElement
=
new
cString
(
"
\"
"
+
currentElement
.
toString
()
+
"
\"
"
);
}
res
=
currentElement
;
elemArr
[
j
]
=
res
;
}
}
if
(
res
!=
undefined
&&
res
!=
null
)
{
return
res
.
toString
();
}
else
{
return
this
.
Formula
;
}
};
/* Сборка функции в инфиксную форму */
parserFormula
.
prototype
.
assemble
=
function
(
rFormula
)
{
if
(
!
rFormula
&&
this
.
outStack
.
length
==
1
&&
this
.
outStack
[
this
.
outStack
.
length
-
1
]
instanceof
cError
)
{
return
this
.
Formula
;
}
var
currentElement
=
null
,
_count
=
this
.
outStack
.
length
,
elemArr
=
new
Array
(
_count
),
res
=
undefined
,
_count_arg
;
for
(
var
i
=
0
,
j
=
0
;
i
<
_count
;
i
++
,
j
++
)
{
currentElement
=
this
.
outStack
[
i
];
if
(
cElementType
.
operator
===
currentElement
.
type
||
cElementType
.
func
===
currentElement
.
type
)
{
_count_arg
=
currentElement
.
getArguments
();
res
=
currentElement
.
Assemble2
(
elemArr
,
j
-
_count_arg
,
_count_arg
);
j
-=
_count_arg
;
elemArr
[
j
]
=
res
;
}
else
{
if
(
cElementType
.
string
===
currentElement
.
type
)
{
currentElement
=
new
cString
(
"
\"
"
+
currentElement
.
toString
()
+
"
\"
"
);
}
res
=
currentElement
;
elemArr
[
j
]
=
res
;
}
}
if
(
res
!=
undefined
&&
res
!=
null
)
{
return
res
.
toString
();
}
else
{
return
this
.
Formula
;
}
};
/* Сборка функции в инфиксную форму */
parserFormula
.
prototype
.
assembleLocale
=
function
(
locale
,
digitDelim
)
{
...
...
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