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
e74c7f61
Commit
e74c7f61
authored
Sep 16, 2016
by
Ilya Kirillov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test variant of recalculation of footnotes in a table.
parent
8b07eb55
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
12 deletions
+86
-12
word/Editor/Footnotes.js
word/Editor/Footnotes.js
+38
-5
word/Editor/Table/TableRecalculate.js
word/Editor/Table/TableRecalculate.js
+48
-7
No files found.
word/Editor/Footnotes.js
View file @
e74c7f61
...
...
@@ -247,9 +247,23 @@ CFootnotesController.prototype.RecalculateFootnotes = function(nPageAbs, nColumn
if
(
!
oColumn
)
return
true
;
// Если уже есть элементы, которые переносятся, тогда данные сноски точно не убирутся
if
(
oColumn
.
GetContinuesElements
().
length
>
0
)
return
false
;
{
// Если уже есть элементы, которые переносятся, тогда данные сноски точно не убирутся
// Но если пришедший Y выше нашего самого нижнего, тогда мы все пришедшие элементы добавляем в список
// на следующую страницу. Такое возможно в таблицах, когда сноски расположены в разных ячейках одной строки,
// причем вторая сноска выше первой.
if
(
Y
<
oColumn
.
ReferenceY
)
{
oColumn
.
AddContinuesElements
(
arrFootnotes
);
return
true
;
}
else
{
return
false
;
}
}
var
nColumnsCount
=
this
.
Pages
[
nPageAbs
].
Columns
.
length
;
...
...
@@ -259,6 +273,9 @@ CFootnotesController.prototype.RecalculateFootnotes = function(nPageAbs, nColumn
var
_Y
=
oColumn
.
Height
;
var
_YLimit
=
oColumn
.
YLimit
-
Y
;
if
(
Y
<
oColumn
.
ReferenceY
)
_YLimit
=
oColumn
.
YLimit
-
oColumn
.
ReferenceY
;
if
(
oColumn
.
Elements
.
length
<=
0
&&
null
!==
this
.
SeparatorFootnote
)
{
this
.
SeparatorFootnote
.
Prepare_RecalculateObject
();
...
...
@@ -284,7 +301,9 @@ CFootnotesController.prototype.RecalculateFootnotes = function(nPageAbs, nColumn
if
(
recalcresult2_NextPage
===
nRecalcResult
)
{
if
(
0
===
nIndex
&&
true
!==
oFootnote
.
Is_ContentOnFirstPage
())
// Если у нас первая сноска не убирается, тогда мы переносим. Есть исключение, когда мы находимся в таблице
// и у нас уже есть сноски на странице, а ссылка на данную сноску выше чем те, которые мы уже добавили.
if
(
0
===
nIndex
&&
true
!==
oFootnote
.
Is_ContentOnFirstPage
()
&&
(
0
===
oColumn
.
Elements
.
length
||
Y
>
oColumn
.
ReferenceY
))
return
false
;
// Начиная с данной сноски мы все оставшиеся сноски заносим в массив ContinuesElements у данной колонки
...
...
@@ -308,6 +327,9 @@ CFootnotesController.prototype.RecalculateFootnotes = function(nPageAbs, nColumn
oColumn
.
Height
=
Math
.
min
(
_YLimit
,
oColumn
.
Height
);
if
(
oColumn
.
ReferenceY
<
Y
)
oColumn
.
ReferenceY
=
Y
;
return
true
;
};
/**
...
...
@@ -2918,6 +2940,7 @@ function CFootEndnotePageColumn()
this
.
XLimit
=
0
;
this
.
YLimit
=
0
;
this
.
ReferenceY
=
0
;
this
.
Height
=
0
;
this
.
Elements
=
[];
// Элементы, которые пересчитаны на данной странице
this
.
ContinuesElements
=
[];
// Элементы, которые нужно пересчитывать на следующей колонке
...
...
@@ -2928,6 +2951,7 @@ function CFootEndnotePageColumn()
}
CFootEndnotePageColumn
.
prototype
.
Reset
=
function
()
{
this
.
ReferenceY
=
0
;
this
.
Height
=
0
;
this
.
Elements
=
[];
this
.
ContinuesElements
=
[];
...
...
@@ -2944,6 +2968,13 @@ CFootEndnotePageColumn.prototype.SetContinuesElements = function(arrContinuesEle
{
this
.
ContinuesElements
=
arrContinuesElements
;
};
CFootEndnotePageColumn
.
prototype
.
AddContinuesElements
=
function
(
arrElements
)
{
for
(
var
nIndex
=
0
,
nCount
=
arrElements
.
length
;
nIndex
<
nCount
;
++
nIndex
)
{
this
.
ContinuesElements
.
push
(
arrElements
[
nIndex
]);
}
};
CFootEndnotePageColumn
.
prototype
.
SaveRecalculateObject
=
function
()
{
var
oColumn
=
new
CFootEndnotePageColumn
();
...
...
@@ -2953,7 +2984,8 @@ CFootEndnotePageColumn.prototype.SaveRecalculateObject = function()
oColumn
.
XLimit
=
this
.
XLimit
;
oColumn
.
YLimit
=
this
.
YLimit
;
oColumn
.
Height
=
this
.
Height
;
oColumn
.
ReferenceY
=
this
.
ReferenceY
;
oColumn
.
Height
=
this
.
Height
;
for
(
var
nIndex
=
0
,
nCount
=
this
.
Elements
.
length
;
nIndex
<
nCount
;
++
nIndex
)
{
...
...
@@ -2974,7 +3006,8 @@ CFootEndnotePageColumn.prototype.LoadRecalculateObject = function(oObject)
this
.
XLimit
=
oObject
.
XLimit
;
this
.
YLimit
=
oObject
.
YLimit
;
this
.
Height
=
oObject
.
Height
;
this
.
ReferenceY
=
oObject
.
ReferenceY
;
this
.
Height
=
oObject
.
Height
;
this
.
Elements
=
[];
for
(
var
nIndex
=
0
,
nCount
=
oObject
.
Elements
.
length
;
nIndex
<
nCount
;
++
nIndex
)
...
...
word/Editor/Table/TableRecalculate.js
View file @
e74c7f61
...
...
@@ -1623,6 +1623,7 @@ CTable.prototype.private_RecalculatePage = function(CurPage)
var
oTopDocument
=
this
.
Parent
.
Is_TopDocument
(
true
);
var
isTopLogicDocument
=
(
oTopDocument
instanceof
CDocument
?
true
:
false
);
var
oFootnotes
=
(
isTopLogicDocument
?
oTopDocument
.
Footnotes
:
null
);
var
nPageAbs
=
this
.
Get_AbsolutePage
(
CurPage
);
var
nColumnAbs
=
this
.
Get_AbsoluteColumn
(
CurPage
);
...
...
@@ -2103,10 +2104,20 @@ CTable.prototype.private_RecalculatePage = function(CurPage)
this
.
HeaderInfo
.
Pages
[
CurPage
].
Draw
=
false
;
}
var
bResetFootnotes
=
true
;
var
oFootnotesObject
,
nFootnotesHeight
=
0
,
nSavedY
=
0
,
nSavedTableHeight
=
0
;
var
bNextPage
=
false
;
for
(
var
CurRow
=
FirstRow
;
CurRow
<
this
.
Content
.
length
;
++
CurRow
)
{
if
((
0
===
CurRow
&&
true
===
this
.
Check_EmptyPages
(
CurPage
-
1
))
||
CurRow
!=
FirstRow
||
(
CurRow
===
FirstRow
&&
true
===
ResetStartElement
))
if
(
true
===
bResetFootnotes
&&
oFootnotes
)
{
oFootnotesObject
=
oFootnotes
.
SaveRecalculateObject
();
nFootnotesHeight
=
oFootnotes
.
GetHeight
(
nPageAbs
,
nColumnAbs
);
nSavedY
=
Y
;
nSavedTableHeight
=
TableHeight
;
}
if
((
0
===
CurRow
&&
true
===
this
.
Check_EmptyPages
(
CurPage
-
1
))
||
CurRow
!=
FirstRow
||
(
CurRow
===
FirstRow
&&
true
===
ResetStartElement
))
{
this
.
RowsInfo
[
CurRow
]
=
{};
this
.
RowsInfo
[
CurRow
].
Pages
=
1
;
...
...
@@ -2204,6 +2215,9 @@ CTable.prototype.private_RecalculatePage = function(CurPage)
var
VerticallCells
=
[];
var
bAllCellsVertical
=
true
;
var
bNeedRecalcFootnotes
=
false
;
var
nCurFootnotesHeight
=
0
;
for
(
var
CurCell
=
0
;
CurCell
<
CellsCount
;
CurCell
++
)
{
var
Cell
=
Row
.
Get_Cell
(
CurCell
);
...
...
@@ -2219,7 +2233,7 @@ CTable.prototype.private_RecalculatePage = function(CurPage)
var
X_content_end
=
Page
.
X
+
CellMetrics
.
X_content_end
;
var
Y_content_start
=
Y
+
CellMar
.
Top
.
W
;
var
Y_content_end
=
this
.
Pages
[
CurPage
].
YLimit
;
var
Y_content_end
=
this
.
Pages
[
CurPage
].
YLimit
+
nFootnotesHeight
;
// TODO: При расчете YLimit для ячейки сделать учет толщины нижних
// границ ячейки и таблицы
...
...
@@ -2286,11 +2300,11 @@ CTable.prototype.private_RecalculatePage = function(CurPage)
var
Y_content_height_old
=
Cell
.
Content
.
Pages
[
0
].
Bounds
.
Bottom
-
Cell
.
Content
.
Pages
[
0
].
Bounds
.
Top
;
// Проверим по X, Y.
var
nFootnotesHeight
=
0
;
if
(
oTopDocument
&&
isTopLogicDocument
)
nFootnotesHeight
=
oTopDocument
.
Footnotes
.
GetHeight
(
nPageAbs
,
nColumnAbs
);
if
(
Math
.
abs
(
X_content_start
-
X_content_start_old
)
<
0.001
&&
Math
.
abs
(
X_content_end_old
-
X_content_end
)
<
0.001
&&
Y_content_start
+
Y_content_height_old
<
Y_content_end
-
nFootnotesHeight
)
//
var nFootnotesHeight = 0;
//
if (oTopDocument && isTopLogicDocument)
//
nFootnotesHeight = oTopDocument.Footnotes.GetHeight(nPageAbs, nColumnAbs);
//
if
(
Math
.
abs
(
X_content_start
-
X_content_start_old
)
<
0.001
&&
Math
.
abs
(
X_content_end_old
-
X_content_end
)
<
0.001
&&
Y_content_start
+
Y_content_height_old
<
Y_content_end
)
{
bCanShift
=
true
;
ShiftDy
=
-
Cell
.
Content
.
Pages
[
0
].
Y
+
Y_content_start
;
...
...
@@ -2358,9 +2372,36 @@ CTable.prototype.private_RecalculatePage = function(CurPage)
}
}
if
(
oFootnotes
)
{
nCurFootnotesHeight
=
oFootnotes
.
GetHeight
(
nPageAbs
,
nColumnAbs
);
if
(
Math
.
abs
(
nCurFootnotesHeight
-
nFootnotesHeight
)
>
0.001
)
{
bNeedRecalcFootnotes
=
true
;
break
;
}
}
CurGridCol
+=
GridSpan
;
}
if
(
true
===
bNeedRecalcFootnotes
&&
nCurFootnotesHeight
>
nFootnotesHeight
)
{
nFootnotesHeight
=
nCurFootnotesHeight
;
bResetFootnotes
=
false
;
Y
=
nSavedY
;
TableHeight
=
nSavedTableHeight
;
oFootnotes
.
LoadRecalculateObject
(
oFootnotesObject
);
CurRow
--
;
continue
;
}
else
{
bResetFootnotes
=
true
;
}
if
(
undefined
===
this
.
TableRowsBottom
[
CurRow
][
CurPage
])
this
.
TableRowsBottom
[
CurRow
][
CurPage
]
=
Y
;
...
...
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