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
0701ee69
Commit
0701ee69
authored
Jun 06, 2016
by
Ilya Kirillov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Сделана поддержка элементов <w:separator> и <w:continuationSeparator>
parent
4eddc27c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
304 additions
and
116 deletions
+304
-116
word/Editor/Document.js
word/Editor/Document.js
+17
-2
word/Editor/Paragraph.js
word/Editor/Paragraph.js
+2
-0
word/Editor/ParagraphContent.js
word/Editor/ParagraphContent.js
+267
-113
word/Editor/Paragraph_Recalculate.js
word/Editor/Paragraph_Recalculate.js
+1
-1
word/Editor/Run.js
word/Editor/Run.js
+17
-0
No files found.
word/Editor/Document.js
View file @
0701ee69
...
...
@@ -4503,6 +4503,9 @@ CDocument.prototype.Paragraph_Add = function(ParaItem, bRecalculate
case
para_PageNum
:
case
para_Field
:
case
para_FootnoteReference
:
case
para_FootnoteRef
:
case
para_Separator
:
case
para_ContinuationSeparator
:
{
// Если у нас что-то заселекчено и мы вводим текст или пробел
// и т.д., тогда сначала удаляем весь селект.
...
...
@@ -11517,6 +11520,18 @@ CDocument.prototype.OnKeyDown = function(e)
// this.Paragraph_Add(new ParaFootnoteReference(oFootnote));
// bRetValue = keydownresult_PreventAll;
// }
// else if (114 === e.KeyCode)
// {
// this.History.Create_NewPoint();
// this.Paragraph_Add(new ParaSeparator());
// bRetValue = keydownresult_PreventAll;
// }
// else if (115 === e.KeyCode)
// {
// this.History.Create_NewPoint();
// this.Paragraph_Add(new ParaContinuationSeparator());
// bRetValue = keydownresult_PreventAll;
// }
// TEST <--
else
if
(
e
.
KeyCode
==
121
&&
true
===
e
.
ShiftKey
)
// Shift + F10 - контекстное меню
{
...
...
word/Editor/Paragraph.js
View file @
0701ee69
...
...
@@ -3030,6 +3030,8 @@ Paragraph.prototype =
case
para_NewLine
:
case
para_FootnoteReference
:
case
para_FootnoteRef
:
case
para_Separator
:
case
para_ContinuationSeparator
:
default
:
{
// Элементы данного типа добавляем во внутренний элемент
...
...
word/Editor/ParagraphContent.js
View file @
0701ee69
...
...
@@ -34,7 +34,7 @@ var c_oAscRelativeFromH = Asc.c_oAscRelativeFromH;
var
c_oAscRelativeFromV
=
Asc
.
c_oAscRelativeFromV
;
var
para_Unknown
=
-
1
;
//
var
para_
Empty
=
0x0000
;
// Пустой элемент (таким элементом должен заканчиваться каждый параграф)
var
para_
RunBase
=
0x0000
;
// Базовый элемент, он не должен использоваться как самостоятельный объект
var
para_Text
=
0x0001
;
// Текст
var
para_Space
=
0x0002
;
// Пробелы
var
para_TextPr
=
0x0003
;
// Свойства текста
...
...
@@ -133,6 +133,61 @@ var PARATEXT_FLAGS_NON_CAPITALS = PARATEXT_FLAGS_MASK ^ PARATEXT_FLAGS
var
TEXTWIDTH_DIVIDER
=
16384
;
/**
* Базовый класс для элементов, лежащих внутри рана.
* @constructor
*/
function
CRunElementBase
()
{
this
.
Width
=
0x00000000
|
0
;
this
.
WidthVisible
=
0x00000000
|
0
;
}
CRunElementBase
.
prototype
.
Type
=
para_RunBase
;
CRunElementBase
.
prototype
.
Get_Type
=
function
()
{
return
para_RunBase
;
};
CRunElementBase
.
prototype
.
Draw
=
function
(
X
,
Y
,
Context
,
PDSE
)
{
};
CRunElementBase
.
prototype
.
Measure
=
function
(
Context
,
TextPr
)
{
this
.
Width
=
0x00000000
|
0
;
this
.
WidthVisible
=
0x00000000
|
0
;
};
CRunElementBase
.
prototype
.
Get_Width
=
function
()
{
return
(
this
.
Width
/
TEXTWIDTH_DIVIDER
);
};
CRunElementBase
.
prototype
.
Get_WidthVisible
=
function
()
{
return
(
this
.
WidthVisible
/
TEXTWIDTH_DIVIDER
);
};
CRunElementBase
.
prototype
.
Set_WidthVisible
=
function
(
WidthVisible
)
{
this
.
WidthVisible
=
(
WidthVisible
*
TEXTWIDTH_DIVIDER
)
|
0
;
};
CRunElementBase
.
prototype
.
Is_RealContent
=
function
()
{
return
true
;
};
CRunElementBase
.
prototype
.
Can_AddNumbering
=
function
()
{
return
true
;
};
CRunElementBase
.
prototype
.
Copy
=
function
()
{
return
new
CRunElementBase
();
};
CRunElementBase
.
prototype
.
Write_ToBinary
=
function
(
Writer
)
{
// Long : Type
Writer
.
WriteLong
(
this
.
Type
);
};
CRunElementBase
.
prototype
.
Read_FromBinary
=
function
(
Reader
)
{
};
// Класс ParaText
function
ParaText
(
value
)
{
...
...
@@ -7466,6 +7521,7 @@ ParaPresentationNumbering.prototype =
* Класс представляющий ссылку на сноску.
* @param {CFootEndnote} Footnote - Ссылка на сноску.
* @constructor
* @extends {CRunElementBase}
*/
function
ParaFootnoteReference
(
Footnote
)
{
...
...
@@ -7475,6 +7531,7 @@ function ParaFootnoteReference(Footnote)
this
.
WidthVisible
=
0
;
this
.
Number
=
1
;
}
AscCommon
.
extendClass
(
ParaFootnoteReference
,
CRunElementBase
);
ParaFootnoteReference
.
prototype
.
Type
=
para_FootnoteReference
;
ParaFootnoteReference
.
prototype
.
Get_Type
=
function
()
{
...
...
@@ -7528,26 +7585,6 @@ ParaFootnoteReference.prototype.Measure = function(Context, TextPr)
this
.
Width
=
ResultWidth
;
this
.
WidthVisible
=
ResultWidth
;
};
ParaFootnoteReference
.
prototype
.
Get_Width
=
function
()
{
return
(
this
.
Width
/
TEXTWIDTH_DIVIDER
);
};
ParaFootnoteReference
.
prototype
.
Get_WidthVisible
=
function
()
{
return
(
this
.
WidthVisible
/
TEXTWIDTH_DIVIDER
);
};
ParaFootnoteReference
.
prototype
.
Set_WidthVisible
=
function
(
WidthVisible
)
{
this
.
WidthVisible
=
(
WidthVisible
*
TEXTWIDTH_DIVIDER
)
|
0
;
};
ParaFootnoteReference
.
prototype
.
Is_RealContent
=
function
()
{
return
true
;
};
ParaFootnoteReference
.
prototype
.
Can_AddNumbering
=
function
()
{
return
true
;
};
ParaFootnoteReference
.
prototype
.
Copy
=
function
()
{
return
new
ParaFootnoteReference
(
this
.
Footnote
);
...
...
@@ -7573,6 +7610,7 @@ ParaFootnoteReference.prototype.Get_Footnote = function()
* Класс представляющий номер сноски внутри сноски.
* @param {CFootEndnote} Footnote - Ссылка на сноску.
* @constructor
* @extends {ParaFootnoteReference}
*/
function
ParaFootnoteRef
(
Footnote
)
{
...
...
@@ -7584,24 +7622,137 @@ ParaFootnoteRef.prototype.Get_Type = function()
{
return
para_FootnoteRef
;
};
ParaFootnoteRef
.
prototype
.
Copy
=
function
()
{
return
new
ParaFootnoteRef
(
this
.
Get_Footnote
());
};
/**
* Класс представляющий собой разделитель (который в основном используется для сносок).
* @constructor
* @extends {CRunElementBase}
*/
function
ParaSeparator
()
{
ParaSeparator
.
superclass
.
constructor
.
call
(
this
);
this
.
LineW
=
0
;
}
AscCommon
.
extendClass
(
ParaSeparator
,
CRunElementBase
);
ParaSeparator
.
prototype
.
Type
=
para_Separator
;
ParaSeparator
.
prototype
.
Get_Type
=
function
()
{
return
para_Separator
;
};
ParaSeparator
.
prototype
.
Draw
=
function
(
X
,
Y
,
Context
,
PDSE
)
{
var
l
=
X
,
t
=
PDSE
.
LineTop
,
r
=
X
+
this
.
Get_Width
(),
b
=
PDSE
.
BaseLine
;
Context
.
drawHorLineExt
(
c_oAscLineDrawingRule
.
Center
,
(
t
+
b
)
/
2
,
l
,
r
,
this
.
LineW
,
0
,
0
);
// TODO: Надо переделать в отдельную функцию отрисовщика
if
(
editor
&&
editor
.
ShowParaMarks
)
{
if
(
Context
.
m_oContext
&&
Context
.
m_oContext
.
setLineDash
)
Context
.
m_oContext
.
setLineDash
([
1
,
1
]);
Context
.
drawHorLineExt
(
c_oAscLineDrawingRule
.
Top
,
t
,
l
,
r
,
0
,
0
,
0
);
Context
.
drawVerLine
(
c_oAscLineDrawingRule
.
Right
,
l
,
t
,
b
,
0
);
Context
.
drawVerLine
(
c_oAscLineDrawingRule
.
Left
,
r
,
t
,
b
,
0
);
Context
.
drawHorLineExt
(
c_oAscLineDrawingRule
.
Top
,
b
,
l
,
r
,
0
,
0
,
0
);
if
(
Context
.
m_oContext
&&
Context
.
m_oContext
.
setLineDash
)
Context
.
m_oContext
.
setLineDash
([]);
}
};
ParaSeparator
.
prototype
.
Measure
=
function
(
Context
,
TextPr
)
{
this
.
Width
=
(
50
*
TEXTWIDTH_DIVIDER
)
|
0
;
this
.
WidthVisible
=
(
50
*
TEXTWIDTH_DIVIDER
)
|
0
;
this
.
LineW
=
(
TextPr
.
FontSize
/
18
)
*
g_dKoef_pt_to_mm
;
};
ParaSeparator
.
prototype
.
Copy
=
function
()
{
return
new
ParaSeparator
();
};
/**
* Класс представляющий собой длинный разделитель (который в основном используется для сносок).
* @constructor
*/
function
ParaContinuationSeparator
()
{
ParaContinuationSeparator
.
superclass
.
constructor
.
call
(
this
);
this
.
LineW
=
0
;
}
AscCommon
.
extendClass
(
ParaContinuationSeparator
,
CRunElementBase
);
ParaContinuationSeparator
.
prototype
.
Type
=
para_ContinuationSeparator
;
ParaContinuationSeparator
.
prototype
.
Get_Type
=
function
()
{
return
para_ContinuationSeparator
;
};
ParaContinuationSeparator
.
prototype
.
Draw
=
function
(
X
,
Y
,
Context
,
PDSE
)
{
var
l
=
X
,
t
=
PDSE
.
LineTop
,
r
=
X
+
this
.
Get_Width
(),
b
=
PDSE
.
BaseLine
;
Context
.
drawHorLineExt
(
c_oAscLineDrawingRule
.
Center
,
(
t
+
b
)
/
2
,
l
,
r
,
this
.
LineW
,
0
,
0
);
// TODO: Надо переделать в отдельную функцию отрисовщика
if
(
editor
&&
editor
.
ShowParaMarks
)
{
if
(
Context
.
m_oContext
&&
Context
.
m_oContext
.
setLineDash
)
Context
.
m_oContext
.
setLineDash
([
1
,
1
]);
Context
.
drawHorLineExt
(
c_oAscLineDrawingRule
.
Top
,
t
,
l
,
r
,
0
,
0
,
0
);
Context
.
drawVerLine
(
c_oAscLineDrawingRule
.
Right
,
l
,
t
,
b
,
0
);
Context
.
drawVerLine
(
c_oAscLineDrawingRule
.
Left
,
r
,
t
,
b
,
0
);
Context
.
drawHorLineExt
(
c_oAscLineDrawingRule
.
Top
,
b
,
l
,
r
,
0
,
0
,
0
);
if
(
Context
.
m_oContext
&&
Context
.
m_oContext
.
setLineDash
)
Context
.
m_oContext
.
setLineDash
([]);
}
};
ParaContinuationSeparator
.
prototype
.
Measure
=
function
(
Context
,
TextPr
)
{
this
.
Width
=
(
50
*
TEXTWIDTH_DIVIDER
)
|
0
;
this
.
WidthVisible
=
(
50
*
TEXTWIDTH_DIVIDER
)
|
0
;
this
.
LineW
=
(
TextPr
.
FontSize
/
18
)
*
g_dKoef_pt_to_mm
;
};
ParaContinuationSeparator
.
prototype
.
Copy
=
function
()
{
return
new
ParaContinuationSeparator
();
};
ParaContinuationSeparator
.
prototype
.
Update_Width
=
function
(
PRS
)
{
var
oPara
=
PRS
.
Paragraph
;
var
nCurPage
=
PRS
.
Page
;
oPara
.
Parent
.
Update_ContentIndexing
();
var
oLimits
=
oPara
.
Parent
.
Get_PageContentStartPos2
(
oPara
.
PageNum
,
oPara
.
ColumnNum
,
nCurPage
,
oPara
.
Index
);
var
nWidth
=
((
oLimits
.
XLimit
-
oLimits
.
X
)
*
TEXTWIDTH_DIVIDER
)
|
0
;
this
.
Width
=
nWidth
;
this
.
WidthVisible
=
nWidth
;
};
function
ParagraphContent_Read_FromBinary
(
Reader
)
{
var
ElementType
=
Reader
.
GetLong
();
var
Element
=
null
;
switch
(
ElementType
)
switch
(
ElementType
)
{
case
para_TextPr
:
case
para_Drawing
:
case
para_HyperlinkStart
:
{
var
ElementId
=
Reader
.
GetString2
();
Element
=
g_oTableId
.
Get_ById
(
ElementId
);
Element
=
g_oTableId
.
Get_ById
(
ElementId
);
return
Element
;
}
case
para_RunBase
:
Element
=
new
CRunElementBase
();
break
;
case
para_Text
:
Element
=
new
ParaText
();
break
;
case
para_Space
:
Element
=
new
ParaSpace
();
break
;
case
para_End
:
Element
=
new
ParaEnd
();
break
;
...
...
@@ -7611,13 +7762,16 @@ function ParagraphContent_Read_FromBinary(Reader)
case
para_PageNum
:
Element
=
new
ParaPageNum
();
break
;
case
para_Math_Placeholder
:
Element
=
new
CMathText
();
break
;
case
para_Math_Text
:
Element
=
new
CMathText
();
break
;
case
para_Math_BreakOperator
:
Element
=
new
CMathText
();
break
;
case
para_Math_BreakOperator
:
Element
=
new
CMathText
();
break
;
case
para_Math_Ampersand
:
Element
=
new
CMathAmp
();
break
;
case
para_PresentationNumbering
:
Element
=
new
ParaPresentationNumbering
();
break
;
case
para_FootnoteReference
:
Element
=
new
ParaFootnoteReference
();
break
;
case
para_FootnoteRef
:
Element
=
new
ParaFootnoteRef
();
break
;
case
para_Separator
:
Element
=
new
ParaSeparator
();
break
;
case
para_ContinuationSeparator
:
Element
=
new
ParaContinuationSeparator
();
break
;
}
if
(
null
!=
Element
)
if
(
null
!=
Element
)
Element
.
Read_FromBinary
(
Reader
);
return
Element
;
...
...
word/Editor/Paragraph_Recalculate.js
View file @
0701ee69
...
...
@@ -717,7 +717,7 @@ Paragraph.prototype.private_RecalculatePageXY = function(CurLine, CurPa
PRS
.
YLimit
=
YLimit
;
PRS
.
Y
=
YStart
;
this
.
Pages
.
length
=
CurPage
+
1
this
.
Pages
.
length
=
CurPage
+
1
;
this
.
Pages
[
CurPage
]
=
new
CParaPage
(
XStart
,
YStart
,
XLimit
,
YLimit
,
CurLine
);
};
...
...
word/Editor/Run.js
View file @
0701ee69
...
...
@@ -2251,10 +2251,15 @@ ParaRun.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
case
para_Text
:
case
para_FootnoteReference
:
case
para_FootnoteRef
:
case
para_Separator
:
case
para_ContinuationSeparator
:
{
// Отмечаем, что началось слово
StartWord
=
true
;
if
(
para_ContinuationSeparator
===
ItemType
)
Item
.
Update_Width
(
PRS
);
// При проверке, убирается ли слово, мы должны учитывать ширину предшествующих пробелов.
var
LetterLen
=
Item
.
Width
/
TEXTWIDTH_DIVIDER
;
//var LetterLen = Item.Get_Width();
...
...
@@ -3098,6 +3103,8 @@ ParaRun.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, _Cur
case
para_PageNum
:
case
para_FootnoteReference
:
case
para_FootnoteRef
:
case
para_Separator
:
case
para_ContinuationSeparator
:
{
UpdateLineMetricsText
=
true
;
break
;
...
...
@@ -3197,6 +3204,8 @@ ParaRun.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRange)
case
para_Text
:
case
para_FootnoteReference
:
case
para_FootnoteRef
:
case
para_Separator
:
case
para_ContinuationSeparator
:
{
PRSC
.
Letters
++
;
...
...
@@ -3349,6 +3358,8 @@ ParaRun.prototype.Recalculate_Range_Spaces = function(PRSA, _CurLine, _CurRange,
case
para_Text
:
case
para_FootnoteReference
:
case
para_FootnoteRef
:
case
para_Separator
:
case
para_ContinuationSeparator
:
{
var
WidthVisible
=
0
;
...
...
@@ -4248,6 +4259,8 @@ ParaRun.prototype.Draw_HighLights = function(PDSH)
case
para_Sym
:
case
para_FootnoteReference
:
case
para_FootnoteRef
:
case
para_Separator
:
case
para_ContinuationSeparator
:
{
if
(
para_Drawing
===
ItemType
&&
!
Item
.
Is_Inline
()
)
break
;
...
...
@@ -4439,6 +4452,8 @@ ParaRun.prototype.Draw_Elements = function(PDSE)
case
para_Sym
:
case
para_FootnoteReference
:
case
para_FootnoteRef
:
case
para_Separator
:
case
para_ContinuationSeparator
:
{
if
(
para_Tab
===
ItemType
)
{
...
...
@@ -4711,6 +4726,8 @@ ParaRun.prototype.Draw_Lines = function(PDSL)
case
para_Sym
:
case
para_FootnoteReference
:
case
para_FootnoteRef
:
case
para_Separator
:
case
para_ContinuationSeparator
:
{
if
(
para_Drawing
!=
ItemType
||
Item
.
Is_Inline
()
)
{
...
...
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