This commit is contained in:
Alexander Trofimov
2015-06-25 11:27:08 +03:00
parent dbf21ee32f
commit a10605c91f
174 changed files with 24121 additions and 8908 deletions

View File

@@ -50,6 +50,12 @@ function CIdCounter() {
this.Set_Load = function (bValue) {
this.m_bLoad = bValue;
};
this.Clear = function () {
this.m_sUserId = null;
this.m_bLoad = true;
this.m_nIdCounterLoad = 0;
this.m_nIdCounterEdit = 0;
};
}
var g_oIdCounter = new CIdCounter();
function CTableId() {
@@ -567,6 +573,11 @@ function CTableId() {
return true;
};
this.Unlock = function (Data) {};
this.Clear = function () {
this.m_aPairs = {};
this.m_bTurnOff = false;
this.Add(this, g_oIdCounter.Get_NewId());
};
}
var g_oTableId = null;
function CCollaborativeChanges() {

View File

@@ -491,6 +491,7 @@ function CDocument(DrawingDocument) {
}
this.Spelling = new CDocumentSpelling();
this.UseTextShd = true;
this.CheckLanguageOnTextAdd = false;
g_oTableId.Add(this, this.Id);
}
var selected_None = -1;
@@ -6578,7 +6579,9 @@ CDocument.prototype = {
} else {
this.DrawingDocument.TargetStart();
this.DrawingDocument.TargetShow();
this.CheckLanguageOnTextAdd = true;
this.Paragraph_Add(new ParaSpace());
this.CheckLanguageOnTextAdd = false;
}
}
}
@@ -7236,7 +7239,9 @@ CDocument.prototype = {
this.Create_NewHistoryPoint(historydescription_Document_AddLetter);
this.DrawingDocument.TargetStart();
this.DrawingDocument.TargetShow();
this.CheckLanguageOnTextAdd = true;
this.Paragraph_Add(new ParaText(String.fromCharCode(Code)));
this.CheckLanguageOnTextAdd = false;
}
bRetValue = true;
}
@@ -8722,13 +8727,13 @@ CDocument.prototype = {
Create_NewHistoryPoint: function (Description) {
this.History.Create_NewPoint(Description);
},
Document_Undo: function () {
Document_Undo: function (Options) {
if (true === CollaborativeEditing.Get_GlobalLock()) {
return;
}
this.DrawingDocument.EndTrackTable(null, true);
this.DrawingObjects.TurnOffCheckChartSelection();
this.History.Undo();
this.History.Undo(Options);
this.DrawingObjects.TurnOnCheckChartSelection();
this.Recalculate(false, false, this.History.RecalculateData);
this.Document_UpdateSelectionState();

View File

@@ -126,7 +126,7 @@ CHistory.prototype = {
}
return false;
},
Undo: function () {
Undo: function (Options) {
this.Check_UninonLastPoints();
if (true != this.Can_Undo()) {
return null;
@@ -138,14 +138,28 @@ CHistory.prototype = {
this.LastState = this.Document.Get_SelectionState();
}
this.Document.Selection_Remove();
var Point = this.Points[this.Index--];
this.Internal_RecalcData_Clear();
for (var Index = Point.Items.length - 1; Index >= 0; Index--) {
var Item = Point.Items[Index];
Item.Class.Undo(Item.Data);
Item.Class.Refresh_RecalcData(Item.Data);
var Point = null;
if (undefined !== Options && null !== Options && true === Options.All) {
while (this.Index >= 0) {
Point = this.Points[this.Index--];
for (var Index = Point.Items.length - 1; Index >= 0; Index--) {
var Item = Point.Items[Index];
Item.Class.Undo(Item.Data);
Item.Class.Refresh_RecalcData(Item.Data);
}
}
} else {
Point = this.Points[this.Index--];
for (var Index = Point.Items.length - 1; Index >= 0; Index--) {
var Item = Point.Items[Index];
Item.Class.Undo(Item.Data);
Item.Class.Refresh_RecalcData(Item.Data);
}
}
if (null != Point) {
this.Document.Set_SelectionState(Point.State);
}
this.Document.Set_SelectionState(Point.State);
return this.RecalculateData;
},
Redo: function () {

View File

@@ -2834,13 +2834,15 @@ Paragraph.prototype = {
var ContentPos = new CParagraphContentPos();
var CurRange = Class.StartRange;
var CurLine = Class.StartLine;
var StartPos = this.Lines[CurLine].Ranges[CurRange].StartPos;
var EndPos = this.Lines[CurLine].Ranges[CurRange].EndPos;
for (var CurPos = StartPos; CurPos <= EndPos; CurPos++) {
var Element = this.Content[CurPos];
ContentPos.Update(CurPos, 0);
if (true === Element.Get_PosByElement(Class, ContentPos, 1, true, CurRange, CurLine)) {
return ContentPos;
if (undefined !== this.Lines[CurLine] && undefined !== this.Lines[CurLine].Ranges[CurRange]) {
var StartPos = this.Lines[CurLine].Ranges[CurRange].StartPos;
var EndPos = this.Lines[CurLine].Ranges[CurRange].EndPos;
for (var CurPos = StartPos; CurPos <= EndPos; CurPos++) {
var Element = this.Content[CurPos];
ContentPos.Update(CurPos, 0);
if (true === Element.Get_PosByElement(Class, ContentPos, 1, true, CurRange, CurLine)) {
return ContentPos;
}
}
}
var ContentLen = this.Content.length;
@@ -2851,6 +2853,7 @@ Paragraph.prototype = {
return ContentPos;
}
}
return null;
},
Get_RunElementByPos: function (ContentPos) {
var CurPos = ContentPos.Get(0);
@@ -3028,6 +3031,20 @@ Paragraph.prototype = {
this.Content[ContentLen - 1].Get_EndPos(BehindEnd, ContentPos, Depth + 1);
return ContentPos;
},
Get_EndPos2: function (BehindEnd) {
var ContentPos = new CParagraphContentPos();
var Depth = 0;
var ContentLen = this.Content.length;
var Pos;
if (this.Content.length > 1) {
Pos = ContentLen - 2;
} else {
Pos = ContentLen - 1;
}
ContentPos.Update(Pos, Depth);
this.Content[Pos].Get_EndPos(BehindEnd, ContentPos, Depth + 1);
return ContentPos;
},
Get_NextRunElements: function (RunElements) {
var ContentPos = RunElements.ContentPos;
var CurPos = ContentPos.Get(0);
@@ -7021,7 +7038,12 @@ Paragraph.prototype = {
},
Continue: function (NewParagraph) {
this.CopyPr(NewParagraph);
var TextPr = this.Get_TextPr(this.Get_EndPos(false));
var TextPr;
if (this.bFromDocument) {
TextPr = this.Get_TextPr(this.Get_EndPos(false));
} else {
TextPr = this.Get_TextPr(this.Get_EndPos2(false));
}
NewParagraph.Internal_Content_Add(0, new ParaRun(NewParagraph));
NewParagraph.Correct_Content();
NewParagraph.Cursor_MoveToStartPos(false);
@@ -8717,6 +8739,9 @@ CParagraphContentPos.prototype = {
Get_Depth: function () {
return this.Depth - 1;
},
Decrease_Depth: function (nCount) {
this.Depth = Math.max(0, this.Depth - nCount);
},
Copy: function () {
var PRPos = new CParagraphContentPos();
var Count = this.Data.length;

View File

@@ -215,6 +215,41 @@ ParaRun.prototype.Is_StartFromNewLine = function () {
return true;
};
ParaRun.prototype.Add = function (Item, bMath) {
if (this.Paragraph && this.Paragraph.LogicDocument && true === this.Paragraph.LogicDocument.CheckLanguageOnTextAdd && editor && editor.asc_getKeyboardLanguage) {
var nRequiredLanguage = editor.asc_getKeyboardLanguage();
var nCurrentLanguage = this.Get_CompiledPr(false).Lang.Val;
if (-1 !== nRequiredLanguage && nRequiredLanguage !== nCurrentLanguage) {
var NewLang = new CLang();
NewLang.Val = nRequiredLanguage;
if (this.Is_Empty()) {
this.Set_Lang(NewLang);
} else {
var Parent = this.Get_Parent();
var RunPos = this.private_GetPosInParent();
if (null !== Parent && -1 !== RunPos) {
var NewRun = new ParaRun(this.Paragraph, bMath);
NewRun.Set_Pr(this.Pr.Copy());
NewRun.Set_Lang(NewLang);
NewRun.Cursor_MoveToStartPos();
NewRun.Add(Item, bMath);
var CurPos = this.State.ContentPos;
if (0 === CurPos) {
Parent.Add_ToContent(RunPos, NewRun);
} else {
if (this.Content.length === CurPos) {
Parent.Add_ToContent(RunPos + 1, NewRun);
} else {
var RightRun = this.Split2(CurPos);
Parent.Add_ToContent(RunPos + 1, NewRun);
Parent.Add_ToContent(RunPos + 2, RightRun);
}
}
NewRun.Make_ThisElementCurrent();
return;
}
}
}
}
this.Add_ToContent(this.State.ContentPos, Item, true, bMath);
};
ParaRun.prototype.Remove = function (Direction, bOnAddText) {
@@ -5634,6 +5669,39 @@ ParaRun.prototype.Get_RangesByPos = function (Pos) {
}
return Ranges;
};
ParaRun.prototype.Get_Parent = function () {
if (!this.Paragraph) {
return null;
}
var ContentPos = this.Paragraph.Get_PosByElement(this);
if (null == ContentPos || undefined == ContentPos || ContentPos.Get_Depth() < 0) {
return null;
}
ContentPos.Decrease_Depth(1);
return this.Paragraph.Get_ElementByPos(ContentPos);
};
ParaRun.prototype.private_GetPosInParent = function (_Parent) {
var Parent = (_Parent ? _Parent : this.Get_Parent());
if (!Parent) {
return -1;
}
var RunPos = -1;
for (var Pos = 0, Count = Parent.Content.length; Pos < Count; Pos++) {
if (this === Parent.Content[Pos]) {
RunPos = Pos;
break;
}
}
return RunPos;
};
ParaRun.prototype.Make_ThisElementCurrent = function () {
if (this.Paragraph) {
var ContentPos = this.Paragraph.Get_PosByElement(this);
ContentPos.Add(this.State.ContentPos);
this.Paragraph.Set_ParaContentPos(ContentPos, true, -1, -1);
this.Paragraph.Document_SetThisElementCurrent(false);
}
};
function CParaRunStartState(Run) {
this.Paragraph = Run.Paragraph;
this.Pr = Run.Pr.Copy();

View File

@@ -8322,9 +8322,13 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
this.oReadResult.bLastRun = true;
} else {
if (c_oSerRunType.object === type) {
var oDrawing = new Object();
res = this.bcr.Read1(length, function (t, l) {
return oThis.ReadObject(t, l, oParStruct);
return oThis.ReadObject(t, l, oParStruct, oDrawing);
});
if (null != oDrawing.content.GraphicObj) {
oNewElem = oDrawing.content;
}
} else {
res = c_oSerConstants.ReadUnknown;
}
@@ -8378,7 +8382,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
}
oDrawing.content = oParaDrawing;
};
this.ReadObject = function (type, length, oParStruct) {
this.ReadObject = function (type, length, oParStruct, oDrawing) {
var res = c_oSerConstants.ReadOk;
var oThis = this;
if (c_oSerParType.OMath === type) {
@@ -8391,15 +8395,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
}
} else {
if (c_oSerRunType.pptxDrawing === type) {
var oNewElem = null;
var oDrawing = new Object();
this.ReadDrawing(type, length, oParStruct, oDrawing, res);
if (null != oDrawing.content.GraphicObj) {
oNewElem = oDrawing.content;
var oNewRun = new ParaRun(oParStruct.paragraph);
oNewRun.Add_ToContent(0, oNewElem, false);
oParStruct.addToContent(oNewRun);
}
} else {
res = c_oSerConstants.ReadUnknown;
}

View File

@@ -41,6 +41,7 @@ var DOCUMENT_SPELLING_EXCEPTIONAL_WORDS = {
};
function CDocumentSpelling() {
this.Use = true;
this.TurnOn = 1;
this.ErrorsExceed = false;
this.Paragraphs = {};
this.Words = {};
@@ -51,6 +52,12 @@ function CDocumentSpelling() {
this.Words = DOCUMENT_SPELLING_EXCEPTIONAL_WORDS;
}
CDocumentSpelling.prototype = {
TurnOff: function () {
this.TurnOn -= 1;
},
TurnOn: function () {
this.TurnOn += 1;
},
Add_Paragraph: function (Id, Para) {
this.Paragraphs[Id] = Para;
},
@@ -90,6 +97,9 @@ CDocumentSpelling.prototype = {
return Count;
},
Continue_CheckSpelling: function () {
if (0 == this.TurnOn) {
return;
}
if (true === this.ErrorsExceed) {
return;
}
@@ -131,12 +141,19 @@ CDocumentSpelling.prototype = {
Para.SpellChecker.Check(undefined, true);
}
},
Add_WaitingParagraph: function (Para) {
Add_WaitingParagraph: function (Para, RecalcId, Words, Langs) {
var ParaId = Para.Get_Id();
if (undefined === this.WaitingParagraphs[ParaId]) {
this.WaitingParagraphs[Para.Get_Id()] = Para;
var WPara = this.WaitingParagraphs[ParaId];
if (undefined === WPara || RecalcId !== WPara.RecalcId || true !== this.private_CompareWordsAndLangs(WPara.Words, Words, WPara.Langs, Langs)) {
this.WaitingParagraphs[ParaId] = {
Words: Words,
Langs: Langs,
RecalcId: RecalcId
};
this.WaitingParagraphsCount++;
return true;
}
return false;
},
Check_WaitingParagraph: function (Para) {
var ParaId = Para.Get_Id();
@@ -151,6 +168,17 @@ CDocumentSpelling.prototype = {
delete this.WaitingParagraphs[ParaId];
this.WaitingParagraphsCount--;
}
},
private_CompareWordsAndLangs: function (Words1, Words2, Langs1, Langs2) {
if (undefined === Words1 || undefined === Words2 || undefined === Langs1 || undefined === Langs2 || Words1.length !== Words2.length || Words1.length !== Langs1.length || Words1.length !== Langs2.length) {
return false;
}
for (var nIndex = 0, nCount = Words1.length; nIndex < nCount; nIndex++) {
if (Words1[nIndex] !== Words2[nIndex] || Langs1[nIndex] !== Langs2[nIndex]) {
return false;
}
}
return true;
}
};
function CParaSpellChecker(Paragraph) {
@@ -220,16 +248,16 @@ CParaSpellChecker.prototype = {
}
}
if (0 < usrWords.length) {
editor.WordControl.m_oLogicDocument.Spelling.Add_WaitingParagraph(this.Paragraph);
this.RecalcId += "_checked";
spellCheck(editor, {
"type": "spell",
"ParagraphId": this.ParaId,
"RecalcId": this.RecalcId,
"ElementId": 0,
"usrWords": usrWords,
"usrLang": usrLang
});
if (true === editor.WordControl.m_oLogicDocument.Spelling.Add_WaitingParagraph(this.Paragraph, this.RecalcId, usrWords, usrLang)) {
spellCheck(editor, {
"type": "spell",
"ParagraphId": this.ParaId,
"RecalcId": this.RecalcId,
"ElementId": 0,
"usrWords": usrWords,
"usrLang": usrLang
});
} else {}
} else {
if (undefined != ParagraphForceRedraw) {
ParagraphForceRedraw.ReDraw();
@@ -507,9 +535,18 @@ CDocument.prototype.Restart_CheckSpelling = function () {
this.Content[Index].Restart_CheckSpelling();
}
};
CDocument.prototype.Stop_CheckSpelling = function () {
this.Spelling.Reset();
};
CDocument.prototype.Continue_CheckSpelling = function () {
this.Spelling.Continue_CheckSpelling();
};
CDocument.prototype.TurnOff_CheckSpelling = function () {
this.Spelling.TurnOff();
};
CDocument.prototype.TurnOn_CheckSpelling = function () {
this.Spelling.TurnOn();
};
CDocumentContent.prototype.Restart_CheckSpelling = function () {
var Count = this.Content.length;
for (var Index = 0; Index < Count; Index++) {