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
3edb6b4e
Commit
3edb6b4e
authored
Sep 06, 2016
by
Ilya Kirillov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented a recalculation of a simple situation with a footnote with in a table.
parent
63f3f49f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
98 additions
and
50 deletions
+98
-50
word/Editor/Document.js
word/Editor/Document.js
+1
-23
word/Editor/DocumentContent.js
word/Editor/DocumentContent.js
+15
-7
word/Editor/DocumentContentBase.js
word/Editor/DocumentContentBase.js
+22
-0
word/Editor/Paragraph_Recalculate.js
word/Editor/Paragraph_Recalculate.js
+29
-17
word/Editor/Table/TableRecalculate.js
word/Editor/Table/TableRecalculate.js
+31
-3
No files found.
word/Editor/Document.js
View file @
3edb6b4e
...
...
@@ -104,6 +104,7 @@ var recalcresultflags_Footnotes = 0x010000; // Сообщаем, что
// Типы которые возвращают классы CDocument и CDocumentContent после пересчета страницы
var
recalcresult2_End
=
0x00
;
// Документ рассчитан до конца
var
recalcresult2_NextPage
=
0x01
;
// Рассчет нужно продолжить
var
recalcresult2_CurPage
=
0x02
;
// Нужно заново пересчитать данную страницу
var
document_EditingType_Common
=
0x00
;
// Обычный режим редактирования
var
document_EditingType_Review
=
0x01
;
// Режим рецензирования
...
...
@@ -11402,29 +11403,6 @@ CDocument.prototype.Goto_FootnotesOnPage = function(nPageIndex)
return
true
;
};
/**
* Находим отрезок сносок, заданный между сносками.
* @param {?CFootEndnote} oFirstFootnote - если null, то иещм с начала документа
* @param {?CFootEndnote} oLastFootnote - если null, то ищем до конца документа
*/
CDocument
.
prototype
.
Get_FootnotesList
=
function
(
oFirstFootnote
,
oLastFootnote
)
{
var
oEngine
=
new
CDocumentFootnotesRangeEngine
();
oEngine
.
Init
(
oFirstFootnote
,
oLastFootnote
);
var
arrFootnotes
=
[];
var
arrParagraphs
=
this
.
Get_AllParagraphs
({
OnlyMainDocument
:
true
,
All
:
true
});
for
(
var
nIndex
=
0
,
nCount
=
arrParagraphs
.
length
;
nIndex
<
nCount
;
++
nIndex
)
{
var
oParagraph
=
arrParagraphs
[
nIndex
];
if
(
true
===
oParagraph
.
Get_FootnotesList
(
oEngine
))
return
arrFootnotes
;
}
return
oEngine
.
GetRange
();
};
CDocument
.
prototype
.
AddFootnote
=
function
()
{
var
nDocPosType
=
this
.
Get_DocPosType
();
...
...
word/Editor/DocumentContent.js
View file @
3edb6b4e
...
...
@@ -1074,6 +1074,10 @@ CDocumentContent.prototype.Recalculate_Page = function(PageIndex,
if
(
RecalcResult
&
recalcresult_CurPage
)
{
// Такое не должно приходить в автофигурах, только в таблицах основного документа. Проверка на это находится в параграфе.
if
(
RecalcResult
&
recalcresultflags_Footnotes
)
return
recalcresult2_CurPage
|
recalcresultflags_Column
|
recalcresultflags_Footnotes
;
return
this
.
Recalculate_Page
(
PageIndex
,
false
);
}
else
if
(
RecalcResult
&
recalcresult_NextElement
)
...
...
@@ -1430,14 +1434,18 @@ CDocumentContent.prototype.Get_FirstParagraph = function()
return
null
;
};
CDocumentContent
.
prototype
.
Get_AllParagraphs
=
function
(
Props
,
ParaArray
)
CDocumentContent
.
prototype
.
Get_AllParagraphs
=
function
(
Props
,
ParaArray
)
{
var
Count
=
this
.
Content
.
length
;
for
(
var
Index
=
0
;
Index
<
Count
;
Index
++
)
{
var
Element
=
this
.
Content
[
Index
];
Element
.
Get_AllParagraphs
(
Props
,
ParaArray
);
}
var
arrParagraphs
=
(
ParaArray
?
ParaArray
:
[]);
var
Count
=
this
.
Content
.
length
;
for
(
var
Index
=
0
;
Index
<
Count
;
Index
++
)
{
var
Element
=
this
.
Content
[
Index
];
Element
.
Get_AllParagraphs
(
Props
,
arrParagraphs
);
}
return
arrParagraphs
;
};
// Специальная функция, используемая в колонтитулах для добавления номера страницы
// При этом удаляются все параграфы. Добавляются два новых
...
...
word/Editor/DocumentContentBase.js
View file @
3edb6b4e
...
...
@@ -151,7 +151,29 @@ CDocumentContentBase.prototype.Reassign_ImageUrls = function(mapUrls)
oDrawing
.
Reassign_ImageUrls
(
mapUrls
);
}
};
/**
* Находим отрезок сносок, заданный между сносками.
* @param {?CFootEndnote} oFirstFootnote - если null, то иещм с начала документа
* @param {?CFootEndnote} oLastFootnote - если null, то ищем до конца документа
*/
CDocumentContentBase
.
prototype
.
Get_FootnotesList
=
function
(
oFirstFootnote
,
oLastFootnote
)
{
var
oEngine
=
new
CDocumentFootnotesRangeEngine
();
oEngine
.
Init
(
oFirstFootnote
,
oLastFootnote
);
var
arrFootnotes
=
[];
var
arrParagraphs
=
this
.
Get_AllParagraphs
({
OnlyMainDocument
:
true
,
All
:
true
});
for
(
var
nIndex
=
0
,
nCount
=
arrParagraphs
.
length
;
nIndex
<
nCount
;
++
nIndex
)
{
var
oParagraph
=
arrParagraphs
[
nIndex
];
if
(
true
===
oParagraph
.
Get_FootnotesList
(
oEngine
))
return
arrFootnotes
;
}
return
oEngine
.
GetRange
();
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Private area
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
...
...
word/Editor/Paragraph_Recalculate.js
View file @
3edb6b4e
...
...
@@ -348,7 +348,7 @@ Paragraph.prototype.Recalculate_FastRange = function(SimpleChanges)
* Предыдущая страница ДОЛЖНА быть пересчитана, если задано не нулевое значение.
* @returns {*} Возвращается результат пересчета
*/
Paragraph
.
prototype
.
Recalculate_Page
=
function
(
PageIndex
)
Paragraph
.
prototype
.
Recalculate_Page
=
function
(
CurPage
)
{
this
.
Clear_NearestPosArray
();
...
...
@@ -360,7 +360,6 @@ Paragraph.prototype.Recalculate_Page = function(PageIndex)
this
.
Internal_CheckSpelling
();
var
CurPage
=
PageIndex
;
var
RecalcResult
=
this
.
private_RecalculatePage
(
CurPage
);
this
.
private_CheckColumnBreak
(
CurPage
);
...
...
@@ -560,11 +559,7 @@ Paragraph.prototype.private_RecalculateFastRange = function(CurRange, CurL
Paragraph
.
prototype
.
private_RecalculatePage
=
function
(
CurPage
,
bFirstRecalculate
)
{
var
PRS
=
this
.
m_oPRSW
;
PRS
.
Page
=
CurPage
;
PRS
.
RunRecalcInfoLast
=
(
0
===
CurPage
?
null
:
this
.
Pages
[
CurPage
-
1
].
EndInfo
.
RunRecalcInfo
);
PRS
.
RunRecalcInfoBreak
=
PRS
.
RunRecalcInfoLast
;
PRS
.
Reset_Page
(
this
,
CurPage
);
var
Pr
=
this
.
Get_CompiledPr
();
var
ParaPr
=
Pr
.
ParaPr
;
...
...
@@ -1348,11 +1343,9 @@ Paragraph.prototype.private_RecalculateLineBottomBound = function(CurLine, CurPa
var
RealCurPage
=
this
.
private_GetRelativePageIndex
(
CurPage
)
-
this
.
Get_StartPage_Relative
();
// TODO: Здесь надо бы ускорить эту проверку
var
oTopDocument
=
this
.
Parent
.
Get_TopDocumentContent
();
var
oTopDocument
=
PRS
.
TopDocument
;
var
bNoFootnotes
=
true
;
if
(
oTopDocument
instanceof
CDocument
&&
oTopDocument
.
Footnotes
.
GetHeight
(
this
.
Get_AbsolutePage
(
CurPage
),
this
.
Get_AbsoluteColumn
(
CurPage
)
)
>
0.001
)
if
(
oTopDocument
instanceof
CDocument
&&
oTopDocument
.
Footnotes
.
GetHeight
(
PRS
.
PageAbs
,
PRS
.
ColumnAbs
)
>
0.001
)
bNoFootnotes
=
false
;
// Сначала проверяем не нужно ли сделать перенос страницы в данном месте
...
...
@@ -1842,6 +1835,7 @@ Paragraph.prototype.private_RecalculateLineCheckFootnotes = function(CurLine, Cu
if
(
!
((
PRS
.
RecalcResult
&
recalcresult_NextElement
)
||
(
PRS
.
RecalcResult
&
recalcresult_NextLine
)))
return
false
;
var
oTopDocument
=
PRS
.
TopDocument
;
for
(
var
nIndex
=
0
,
nCount
=
PRS
.
Footnotes
.
length
;
nIndex
<
nCount
;
++
nIndex
)
{
var
oFootnote
=
PRS
.
Footnotes
[
nIndex
].
FootnoteReference
.
Get_Footnote
();
...
...
@@ -1852,15 +1846,15 @@ Paragraph.prototype.private_RecalculateLineCheckFootnotes = function(CurLine, Cu
return
true
;
// TODO: Здесь надо разобраться с параграфами внутри таблицы.
if
(
this
.
Par
ent
instanceof
CDocument
)
if
(
oTopDocum
ent
instanceof
CDocument
)
{
var
RecalcInfo
=
this
.
Par
ent
.
RecalcInfo
;
var
nPageAbs
=
this
.
Get_AbsolutePage
(
CurPage
)
;
var
nColumnAbs
=
this
.
Get_AbsoluteColumn
(
CurPage
)
;
var
RecalcInfo
=
oTopDocum
ent
.
RecalcInfo
;
var
nPageAbs
=
PRS
.
PageAbs
;
var
nColumnAbs
=
PRS
.
ColumnAbs
;
if
(
true
===
RecalcInfo
.
Can_RecalcObject
())
{
RecalcInfo
.
Set_FootnoteReference
(
oFootnote
,
nPageAbs
,
nColumnAbs
);
this
.
Par
ent
.
Footnotes
.
AddFootnoteToPage
(
nPageAbs
,
nColumnAbs
,
oFootnote
,
this
.
Pages
[
CurPage
].
Y
+
this
.
Lines
[
CurLine
].
Bottom
);
oTopDocum
ent
.
Footnotes
.
AddFootnoteToPage
(
nPageAbs
,
nColumnAbs
,
oFootnote
,
this
.
Pages
[
CurPage
].
Y
+
this
.
Lines
[
CurLine
].
Bottom
);
PRS
.
RecalcResult
=
recalcresult_CurPage
|
recalcresultflags_Column
|
recalcresultflags_Footnotes
;
return
false
;
}
...
...
@@ -1880,7 +1874,7 @@ Paragraph.prototype.private_RecalculateLineCheckFootnotes = function(CurLine, Cu
{
// TODO: Реализовать
RecalcInfo
.
Set_PageBreakBefore
(
true
);
this
.
Par
ent
.
Footnotes
.
RemoveFootnoteFromPage
(
nPageAbs
,
nColumnAbs
,
oFootnote
);
oTopDocum
ent
.
Footnotes
.
RemoveFootnoteFromPage
(
nPageAbs
,
nColumnAbs
,
oFootnote
);
PRS
.
RecalcResult
=
recalcresult_CurPage
|
recalcresultflags_Column
|
recalcresultflags_Footnotes
;
return
false
;
}
...
...
@@ -2526,8 +2520,14 @@ CParagraphRecalculateTabInfo.prototype =
function
CParagraphRecalculateStateWrap
(
Para
)
{
// Общие параметры, которые заполняются 1 раз на пересчет всей страницы
this
.
Paragraph
=
Para
;
this
.
Parent
=
null
;
this
.
TopDocument
=
null
;
this
.
PageAbs
=
0
;
this
.
ColumnAbs
=
0
;
//
this
.
Page
=
0
;
this
.
Line
=
0
;
this
.
Range
=
0
;
...
...
@@ -2636,6 +2636,18 @@ function CParagraphRecalculateStateWrap(Para)
CParagraphRecalculateStateWrap
.
prototype
=
{
Reset_Page
:
function
(
Paragraph
,
CurPage
)
{
this
.
Paragraph
=
Paragraph
;
this
.
Parent
=
Paragraph
.
Parent
;
this
.
TopDocument
=
Paragraph
.
Parent
.
Get_TopDocumentContent
();
this
.
PageAbs
=
Paragraph
.
Get_AbsolutePage
(
CurPage
);
this
.
ColumnAbs
=
Paragraph
.
Get_AbsoluteColumn
(
CurPage
);
this
.
RunRecalcInfoLast
=
(
0
===
CurPage
?
null
:
Paragraph
.
Pages
[
CurPage
-
1
].
EndInfo
.
RunRecalcInfo
);
this
.
RunRecalcInfoBreak
=
this
.
RunRecalcInfoLast
;
},
// Обнуляем некоторые параметры перед новой строкой
Reset_Line
:
function
()
{
...
...
word/Editor/Table/TableRecalculate.js
View file @
3edb6b4e
...
...
@@ -51,6 +51,8 @@ CTable.prototype.Recalculate_Page = function(PageIndex)
this
.
private_RecalculatePositionX
(
PageIndex
);
var
Result
=
this
.
private_RecalculatePage
(
PageIndex
);
if
(
Result
&
recalcresult_CurPage
)
return
Result
;
this
.
private_RecalculatePositionY
(
PageIndex
);
...
...
@@ -2366,6 +2368,11 @@ CTable.prototype.private_RecalculatePage = function(CurPage)
{
bCanShift
=
true
;
ShiftDy
=
-
Cell
.
Content
.
Pages
[
0
].
Y
+
Y_content_start
;
// Если в ячейке есть ссылки на сноски, тогда такую ячейку нужно пересчитывать
var
arrFootnotes
=
Cell
.
Content
.
Get_FootnotesList
(
null
,
null
);
if
(
arrFootnotes
&&
arrFootnotes
.
length
>
0
)
bCanShift
=
false
;
}
}
...
...
@@ -2385,10 +2392,31 @@ CTable.prototype.private_RecalculatePage = function(CurPage)
Cell
.
Content
.
Shift
(
0
,
ShiftDx
,
ShiftDy
);
Cell
.
Content
.
Update_EndInfo
();
}
else
if
(
recalcresult2_NextPage
===
Cell
.
Content
.
Recalculate_Page
(
CellPageIndex
,
true
)
)
else
{
Cell
.
PagesCount
=
Cell
.
Content
.
Pages
.
length
+
1
;
bNextPage
=
true
;
var
RecalcResult
=
Cell
.
Content
.
Recalculate_Page
(
CellPageIndex
,
true
);
if
(
recalcresult2_CurPage
&
RecalcResult
)
{
var
_RecalcResult
=
recalcresult_CurPage
;
if
(
RecalcResult
&
recalcresultflags_Column
)
_RecalcResult
|=
recalcresultflags_Column
;
if
(
RecalcResult
&
recalcresultflags_Footnotes
)
_RecalcResult
|=
recalcresultflags_Footnotes
;
this
.
TurnOffRecalc
=
false
;
return
_RecalcResult
;
}
else
if
(
recalcresult2_NextPage
&
RecalcResult
)
{
Cell
.
PagesCount
=
Cell
.
Content
.
Pages
.
length
+
1
;
bNextPage
=
true
;
}
else
if
(
recalcresult2_End
&
RecalcResult
)
{
// Ничего не делаем
}
}
var
CellContentBounds
=
Cell
.
Content
.
Get_PageBounds
(
CellPageIndex
,
undefined
,
true
);
...
...
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