3.0 source code
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,198 +1,190 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
(function ($, window, undefined) {
|
||||
var asc = window["Asc"];
|
||||
var asc_lastindexof = asc.lastIndexOf;
|
||||
var asc_inherit = asc.inherit;
|
||||
var asc_SR = asc.StringRender;
|
||||
function CharOffset(left, top, height, line) {
|
||||
this.left = left;
|
||||
this.top = top;
|
||||
this.height = height;
|
||||
this.lineIndex = line;
|
||||
}
|
||||
function CellTextRender(drawingCtx) {
|
||||
if (! (this instanceof CellTextRender)) {
|
||||
return new CellTextRender(drawingCtx);
|
||||
}
|
||||
CellTextRender.superclass.constructor.call(this, drawingCtx);
|
||||
return this;
|
||||
}
|
||||
var CellTextRender_methods = {
|
||||
reWordBegining: XRegExp("[^\\p{L}\\p{N}][\\p{L}\\p{N}]", "i"),
|
||||
getLinesCount: function () {
|
||||
return this.lines.length;
|
||||
},
|
||||
getLineInfo: function (index) {
|
||||
return this.lines.length > 0 && index >= 0 && index < this.lines.length ? this.lines[index] : null;
|
||||
},
|
||||
calcLineOffset: function (index) {
|
||||
for (var i = 0, h = 0, l = this.lines; i < index; ++i) {
|
||||
h += l[i].th;
|
||||
}
|
||||
return h;
|
||||
},
|
||||
getPrevChar: function (pos) {
|
||||
return pos <= 0 ? 0 : pos <= this.chars.length ? pos - 1 : this.chars.length;
|
||||
},
|
||||
getNextChar: function (pos) {
|
||||
return pos >= this.chars.length ? this.chars.length : pos >= 0 ? pos + 1 : 0;
|
||||
},
|
||||
getPrevWord: function (pos) {
|
||||
var i = asc_lastindexof(this.chars.slice(0, pos), this.reWordBegining);
|
||||
return i >= 0 ? i + 1 : 0;
|
||||
},
|
||||
getNextWord: function (pos) {
|
||||
var i = this.chars.slice(pos).search(this.reWordBegining);
|
||||
return pos + (i >= 0 ? i + 1 : 0);
|
||||
},
|
||||
getBeginOfLine: function (pos) {
|
||||
pos = pos < 0 ? 0 : Math.min(pos, this.chars.length);
|
||||
for (var l = this.lines, i = 0; i < l.length; ++i) {
|
||||
if (pos >= l[i].beg && pos <= l[i].end) {
|
||||
return l[i].beg;
|
||||
}
|
||||
}
|
||||
var lastLine = l.length - 1;
|
||||
var lastChar = this.chars.length - 1;
|
||||
return this.charWidths[lastChar] !== 0 ? l[lastLine].beg : pos;
|
||||
},
|
||||
getEndOfLine: function (pos) {
|
||||
pos = pos < 0 ? 0 : Math.min(pos, this.chars.length);
|
||||
var l = this.lines;
|
||||
var lastLine = l.length - 1;
|
||||
for (var i = 0; i < lastLine; ++i) {
|
||||
if (pos >= l[i].beg && pos <= l[i].end) {
|
||||
return l[i].end;
|
||||
}
|
||||
}
|
||||
var lastChar = this.chars.length - 1;
|
||||
return pos > lastChar ? pos : lastChar + (this.charWidths[lastChar] !== 0 ? 1 : 0);
|
||||
},
|
||||
getBeginOfText: function (pos) {
|
||||
return 0;
|
||||
},
|
||||
getEndOfText: function (pos) {
|
||||
return this.chars.length;
|
||||
},
|
||||
getPrevLine: function (pos) {
|
||||
pos = pos < 0 ? 0 : Math.min(pos, this.chars.length);
|
||||
for (var l = this.lines, i = 0; i < l.length; ++i) {
|
||||
if (pos >= l[i].beg && pos <= l[i].end) {
|
||||
return i <= 0 ? 0 : Math.min(l[i - 1].beg + pos - l[i].beg, l[i - 1].end);
|
||||
}
|
||||
}
|
||||
var lastLine = l.length - 1;
|
||||
var lastChar = this.chars.length - 1;
|
||||
return this.charWidths[lastChar] === 0 || l.length < 2 ? (0 > lastLine ? 0 : l[lastLine].beg) : lastChar > 0 ? Math.min(l[lastLine - 1].beg + pos - l[lastLine].beg, l[lastLine - 1].end) : 0;
|
||||
},
|
||||
getNextLine: function (pos) {
|
||||
pos = pos < 0 ? 0 : Math.min(pos, this.chars.length);
|
||||
var l = this.lines;
|
||||
var lastLine = l.length - 1;
|
||||
for (var i = 0; i < lastLine; ++i) {
|
||||
if (pos >= l[i].beg && pos <= l[i].end) {
|
||||
return Math.min(l[i + 1].beg + pos - l[i].beg, l[i + 1].end);
|
||||
}
|
||||
}
|
||||
return this.chars.length;
|
||||
},
|
||||
calcCharOffset: function (pos) {
|
||||
var t = this,
|
||||
l = t.lines,
|
||||
i = 0,
|
||||
h = 0,
|
||||
co;
|
||||
function getCharInfo(pos) {
|
||||
for (var p = t.charProps[pos];
|
||||
(!p || !p.font) && pos > 0; --pos) {
|
||||
p = t.charProps[pos - 1];
|
||||
}
|
||||
return {
|
||||
fsz: p.font.FontSize,
|
||||
dh: p && p.lm && p.lm.bl2 > 0 ? p.lm.bl2 - p.lm.bl : 0
|
||||
};
|
||||
}
|
||||
function charOffset(lineIndex) {
|
||||
var ci = getCharInfo(pos);
|
||||
var li = l[lineIndex];
|
||||
return new CharOffset(li.startX + (pos > 0 ? t._calcCharsWidth(li.beg, pos - 1) : 0), h + li.bl - ci.fsz + ci.dh, ci.fsz, lineIndex);
|
||||
}
|
||||
if (l.length < 1) {
|
||||
return null;
|
||||
}
|
||||
if (pos < 0) {
|
||||
pos = 0;
|
||||
}
|
||||
if (pos > t.chars.length) {
|
||||
pos = t.chars.length;
|
||||
}
|
||||
for (i = 0, h = 0; i < l.length; ++i) {
|
||||
if (pos >= l[i].beg && pos <= l[i].end) {
|
||||
return charOffset(i);
|
||||
}
|
||||
if (i !== l.length - 1) {
|
||||
h += l[i].th;
|
||||
}
|
||||
}
|
||||
co = charOffset(i - 1);
|
||||
if (t.charWidths[t.chars.length - 1] === 0) {
|
||||
co.left = null;
|
||||
co.top += l[i - 1].th;
|
||||
co.lineIndex++;
|
||||
}
|
||||
return co;
|
||||
},
|
||||
calcCharHeight: function (pos) {
|
||||
var t = this;
|
||||
for (var p = t.charProps[pos];
|
||||
(!p || !p.font) && pos > 0; --pos) {
|
||||
p = t.charProps[pos - 1];
|
||||
}
|
||||
return t._calcLineMetrics(p.fsz !== undefined ? p.fsz : p.font.FontSize, p.va, p.fm, t.drawingCtx.getPPIY());
|
||||
},
|
||||
getCharsCount: function () {
|
||||
return this.chars.length;
|
||||
},
|
||||
getChars: function (pos, len) {
|
||||
return this.chars.slice(pos, pos + len);
|
||||
},
|
||||
getCharWidth: function (pos) {
|
||||
return this.charWidths[pos];
|
||||
},
|
||||
isLastCharNL: function () {
|
||||
return this.charWidths[this.chars.length - 1] === 0;
|
||||
}
|
||||
};
|
||||
asc_inherit(CellTextRender, asc_SR, CellTextRender_methods);
|
||||
window["Asc"].CellTextRender = CellTextRender;
|
||||
})(jQuery, window);
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2015
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
"use strict";
|
||||
(function (window, undefined) {
|
||||
var asc = window["Asc"];
|
||||
var asc_lastindexof = asc.lastIndexOf;
|
||||
function CharOffset(left, top, height, line) {
|
||||
this.left = left;
|
||||
this.top = top;
|
||||
this.height = height;
|
||||
this.lineIndex = line;
|
||||
}
|
||||
function CellTextRender(drawingCtx) {
|
||||
CellTextRender.superclass.constructor.call(this, drawingCtx);
|
||||
this.reWordBegining = XRegExp("[^\\p{L}\\p{N}][\\p{L}\\p{N}]", "i");
|
||||
return this;
|
||||
}
|
||||
asc.extendClass(CellTextRender, asc.StringRender);
|
||||
CellTextRender.prototype.getLinesCount = function () {
|
||||
return this.lines.length;
|
||||
};
|
||||
CellTextRender.prototype.getLineInfo = function (index) {
|
||||
return this.lines.length > 0 && index >= 0 && index < this.lines.length ? this.lines[index] : null;
|
||||
};
|
||||
CellTextRender.prototype.calcLineOffset = function (index) {
|
||||
for (var i = 0, h = 0, l = this.lines; i < index; ++i) {
|
||||
h += l[i].th;
|
||||
}
|
||||
return h;
|
||||
};
|
||||
CellTextRender.prototype.getPrevChar = function (pos) {
|
||||
return pos <= 0 ? 0 : pos <= this.chars.length ? pos - 1 : this.chars.length;
|
||||
};
|
||||
CellTextRender.prototype.getNextChar = function (pos) {
|
||||
return pos >= this.chars.length ? this.chars.length : pos >= 0 ? pos + 1 : 0;
|
||||
};
|
||||
CellTextRender.prototype.getPrevWord = function (pos) {
|
||||
var i = asc_lastindexof(this.chars.slice(0, pos), this.reWordBegining);
|
||||
return i >= 0 ? i + 1 : 0;
|
||||
};
|
||||
CellTextRender.prototype.getNextWord = function (pos) {
|
||||
var i = this.chars.slice(pos).search(this.reWordBegining);
|
||||
return i >= 0 ? pos + (i + 1) : this.getEndOfLine(pos);
|
||||
};
|
||||
CellTextRender.prototype.getBeginOfLine = function (pos) {
|
||||
pos = pos < 0 ? 0 : Math.min(pos, this.chars.length);
|
||||
for (var l = this.lines, i = 0; i < l.length; ++i) {
|
||||
if (pos >= l[i].beg && pos <= l[i].end) {
|
||||
return l[i].beg;
|
||||
}
|
||||
}
|
||||
var lastLine = l.length - 1;
|
||||
var lastChar = this.chars.length - 1;
|
||||
return this.charWidths[lastChar] !== 0 ? l[lastLine].beg : pos;
|
||||
};
|
||||
CellTextRender.prototype.getEndOfLine = function (pos) {
|
||||
pos = pos < 0 ? 0 : Math.min(pos, this.chars.length);
|
||||
var l = this.lines;
|
||||
var lastLine = l.length - 1;
|
||||
for (var i = 0; i < lastLine; ++i) {
|
||||
if (pos >= l[i].beg && pos <= l[i].end) {
|
||||
return l[i].end;
|
||||
}
|
||||
}
|
||||
var lastChar = this.chars.length - 1;
|
||||
return pos > lastChar ? pos : lastChar + (this.charWidths[lastChar] !== 0 ? 1 : 0);
|
||||
};
|
||||
CellTextRender.prototype.getBeginOfText = function () {
|
||||
return 0;
|
||||
};
|
||||
CellTextRender.prototype.getEndOfText = function () {
|
||||
return this.chars.length;
|
||||
};
|
||||
CellTextRender.prototype.getPrevLine = function (pos) {
|
||||
pos = pos < 0 ? 0 : Math.min(pos, this.chars.length);
|
||||
for (var l = this.lines, i = 0; i < l.length; ++i) {
|
||||
if (pos >= l[i].beg && pos <= l[i].end) {
|
||||
return i <= 0 ? 0 : Math.min(l[i - 1].beg + pos - l[i].beg, l[i - 1].end);
|
||||
}
|
||||
}
|
||||
var lastLine = l.length - 1;
|
||||
var lastChar = this.chars.length - 1;
|
||||
return this.charWidths[lastChar] === 0 || l.length < 2 ? (0 > lastLine ? 0 : l[lastLine].beg) : lastChar > 0 ? Math.min(l[lastLine - 1].beg + pos - l[lastLine].beg, l[lastLine - 1].end) : 0;
|
||||
};
|
||||
CellTextRender.prototype.getNextLine = function (pos) {
|
||||
pos = pos < 0 ? 0 : Math.min(pos, this.chars.length);
|
||||
var l = this.lines;
|
||||
var lastLine = l.length - 1;
|
||||
for (var i = 0; i < lastLine; ++i) {
|
||||
if (pos >= l[i].beg && pos <= l[i].end) {
|
||||
return Math.min(l[i + 1].beg + pos - l[i].beg, l[i + 1].end);
|
||||
}
|
||||
}
|
||||
return this.chars.length;
|
||||
};
|
||||
CellTextRender.prototype.getCharInfo = function (pos) {
|
||||
for (var p = this.charProps[pos];
|
||||
(!p || !p.font) && pos > 0; --pos) {
|
||||
p = this.charProps[pos - 1];
|
||||
}
|
||||
return {
|
||||
fsz: p.font.FontSize,
|
||||
dh: p && p.lm && p.lm.bl2 > 0 ? p.lm.bl2 - p.lm.bl : 0,
|
||||
h: p && p.lm ? p.lm.th : 0
|
||||
};
|
||||
};
|
||||
CellTextRender.prototype.charOffset = function (pos, lineIndex, h) {
|
||||
var li = this.lines[lineIndex];
|
||||
return new CharOffset(li.startX + (pos > 0 ? this._calcCharsWidth(li.beg, pos - 1) : 0), h, li.th, lineIndex);
|
||||
};
|
||||
CellTextRender.prototype.calcCharOffset = function (pos) {
|
||||
var t = this,
|
||||
l = t.lines,
|
||||
i, h, co;
|
||||
if (l.length < 1) {
|
||||
return null;
|
||||
}
|
||||
if (pos < 0) {
|
||||
pos = 0;
|
||||
}
|
||||
if (pos > t.chars.length) {
|
||||
pos = t.chars.length;
|
||||
}
|
||||
for (i = 0, h = 0; i < l.length; ++i) {
|
||||
if (pos >= l[i].beg && pos <= l[i].end) {
|
||||
return this.charOffset(pos, i, h);
|
||||
}
|
||||
if (i !== l.length - 1) {
|
||||
h += l[i].th;
|
||||
}
|
||||
}
|
||||
co = this.charOffset(pos, i - 1, h);
|
||||
if (t.charWidths[t.chars.length - 1] === 0) {
|
||||
co.left = null;
|
||||
co.top += l[i - 1].th;
|
||||
co.lineIndex++;
|
||||
}
|
||||
return co;
|
||||
};
|
||||
CellTextRender.prototype.calcCharHeight = function (pos) {
|
||||
var t = this;
|
||||
for (var p = t.charProps[pos];
|
||||
(!p || !p.font) && pos > 0; --pos) {
|
||||
p = t.charProps[pos - 1];
|
||||
}
|
||||
return t._calcLineMetrics(p.fsz !== undefined ? p.fsz : p.font.FontSize, p.va, p.fm, t.drawingCtx.getPPIY());
|
||||
};
|
||||
CellTextRender.prototype.getCharsCount = function () {
|
||||
return this.chars.length;
|
||||
};
|
||||
CellTextRender.prototype.getChars = function (pos, len) {
|
||||
return this.chars.slice(pos, pos + len);
|
||||
};
|
||||
CellTextRender.prototype.getCharWidth = function (pos) {
|
||||
return this.charWidths[pos];
|
||||
};
|
||||
CellTextRender.prototype.isLastCharNL = function () {
|
||||
return this.charWidths[this.chars.length - 1] === 0;
|
||||
};
|
||||
window["Asc"].CellTextRender = CellTextRender;
|
||||
})(window);
|
||||
450
OfficeWeb/sdk/Excel/view/DrawingObjectsController.js
Normal file
450
OfficeWeb/sdk/Excel/view/DrawingObjectsController.js
Normal file
@@ -0,0 +1,450 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2015
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
"use strict";
|
||||
if (window.editor === "undefined" && window["Asc"]["editor"]) {
|
||||
window.editor = window["Asc"]["editor"];
|
||||
}
|
||||
function CContentChangesElement(Type, Pos, Count, Data) {
|
||||
this.m_nType = Type;
|
||||
this.m_nPos = Pos;
|
||||
this.m_nCount = Count;
|
||||
this.m_pData = Data;
|
||||
this.Refresh_BinaryData = function () {
|
||||
this.m_pData.Pos = this.m_aPositions[0];
|
||||
if (editor && editor.isPresentationEditor) {
|
||||
var Binary_Writer = History.BinaryWriter;
|
||||
var Binary_Pos = Binary_Writer.GetCurPosition();
|
||||
this.m_pData.Data.UseArray = true;
|
||||
this.m_pData.Data.PosArray = this.m_aPositions;
|
||||
Binary_Writer.WriteString2(this.m_pData.Class.Get_Id());
|
||||
this.m_pData.Class.Save_Changes(this.m_pData.Data, Binary_Writer);
|
||||
var Binary_Len = Binary_Writer.GetCurPosition() - Binary_Pos;
|
||||
this.m_pData.Binary.Pos = Binary_Pos;
|
||||
this.m_pData.Binary.Len = Binary_Len;
|
||||
}
|
||||
};
|
||||
this.Check_Changes = function (Type, Pos) {
|
||||
var CurPos = Pos;
|
||||
if (contentchanges_Add === Type) {
|
||||
for (var Index = 0; Index < this.m_nCount; Index++) {
|
||||
if (false !== this.m_aPositions[Index]) {
|
||||
if (CurPos <= this.m_aPositions[Index]) {
|
||||
this.m_aPositions[Index]++;
|
||||
} else {
|
||||
if (contentchanges_Add === this.m_nType) {
|
||||
CurPos++;
|
||||
} else {
|
||||
CurPos--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (var Index = 0; Index < this.m_nCount; Index++) {
|
||||
if (false !== this.m_aPositions[Index]) {
|
||||
if (CurPos < this.m_aPositions[Index]) {
|
||||
this.m_aPositions[Index]--;
|
||||
} else {
|
||||
if (CurPos > this.m_aPositions[Index]) {
|
||||
if (contentchanges_Add === this.m_nType) {
|
||||
CurPos++;
|
||||
} else {
|
||||
CurPos--;
|
||||
}
|
||||
} else {
|
||||
if (contentchanges_Remove === this.m_nType) {
|
||||
this.m_aPositions[Index] = false;
|
||||
return false;
|
||||
} else {
|
||||
CurPos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return CurPos;
|
||||
};
|
||||
this.Make_ArrayOfSimpleActions = function (Type, Pos, Count) {
|
||||
var Positions = [];
|
||||
if (contentchanges_Add === Type) {
|
||||
for (var Index = 0; Index < Count; Index++) {
|
||||
Positions[Index] = Pos + Index;
|
||||
}
|
||||
} else {
|
||||
for (var Index = 0; Index < Count; Index++) {
|
||||
Positions[Index] = Pos;
|
||||
}
|
||||
}
|
||||
return Positions;
|
||||
};
|
||||
this.m_aPositions = this.Make_ArrayOfSimpleActions(Type, Pos, Count);
|
||||
}
|
||||
function CContentChanges() {
|
||||
this.m_aChanges = [];
|
||||
this.Add = function (Changes) {
|
||||
this.m_aChanges.push(Changes);
|
||||
};
|
||||
this.Clear = function () {
|
||||
this.m_aChanges.length = 0;
|
||||
};
|
||||
this.Check = function (Type, Pos) {
|
||||
var CurPos = Pos;
|
||||
var Count = this.m_aChanges.length;
|
||||
for (var Index = 0; Index < Count; Index++) {
|
||||
var NewPos = this.m_aChanges[Index].Check_Changes(Type, CurPos);
|
||||
if (false === NewPos) {
|
||||
return false;
|
||||
}
|
||||
CurPos = NewPos;
|
||||
}
|
||||
return CurPos;
|
||||
};
|
||||
this.Refresh = function () {
|
||||
var Count = this.m_aChanges.length;
|
||||
for (var Index = 0; Index < Count; Index++) {
|
||||
this.m_aChanges[Index].Refresh_BinaryData();
|
||||
}
|
||||
};
|
||||
}
|
||||
function CheckIdSatetShapeAdd(state) {
|
||||
return ! (state instanceof NullState);
|
||||
}
|
||||
DrawingObjectsController.prototype.getTheme = function () {
|
||||
return window["Asc"]["editor"].wbModel.theme;
|
||||
};
|
||||
DrawingObjectsController.prototype.getDrawingArray = function () {
|
||||
var ret = [];
|
||||
var drawing_bases = this.drawingObjects.getDrawingObjects();
|
||||
for (var i = 0; i < drawing_bases.length; ++i) {
|
||||
ret.push(drawing_bases[i].graphicObject);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
DrawingObjectsController.prototype.setTableProps = function (props) {
|
||||
var by_type = this.getSelectedObjectsByTypes();
|
||||
if (by_type.tables.length === 1) {
|
||||
var target_text_object = getTargetTextObject(this);
|
||||
if (target_text_object === by_type.tables[0]) {
|
||||
by_type.tables[0].graphicObject.Set_Props(props);
|
||||
} else {
|
||||
by_type.tables[0].graphicObject.Select_All();
|
||||
by_type.tables[0].graphicObject.Set_Props(props);
|
||||
by_type.tables[0].graphicObject.Selection_Remove();
|
||||
}
|
||||
editor.WordControl.m_oLogicDocument.Check_GraphicFrameRowHeight(by_type.tables[0]);
|
||||
}
|
||||
};
|
||||
DrawingObjectsController.prototype.RefreshAfterChangeColorScheme = function () {
|
||||
var drawings = this.getDrawingArray();
|
||||
for (var i = 0; i < drawings.length; ++i) {
|
||||
if (drawings[i]) {
|
||||
drawings[i].handleUpdateFill();
|
||||
drawings[i].handleUpdateLn();
|
||||
drawings[i].addToRecalculate();
|
||||
}
|
||||
}
|
||||
};
|
||||
DrawingObjectsController.prototype.getLayout = function () {
|
||||
return null;
|
||||
};
|
||||
DrawingObjectsController.prototype.updateOverlay = function () {
|
||||
this.drawingObjects.OnUpdateOverlay();
|
||||
};
|
||||
DrawingObjectsController.prototype.recalculate = function (bAll, Point) {
|
||||
History.Get_RecalcData(Point);
|
||||
if (bAll) {
|
||||
var drawings = this.getDrawingObjects();
|
||||
for (var i = 0; i < drawings.length; ++i) {
|
||||
if (drawings[i].recalcText) {
|
||||
drawings[i].recalcText();
|
||||
}
|
||||
drawings[i].recalculate();
|
||||
}
|
||||
} else {
|
||||
for (var key in this.objectsForRecalculate) {
|
||||
this.objectsForRecalculate[key].recalculate();
|
||||
}
|
||||
}
|
||||
this.objectsForRecalculate = {};
|
||||
};
|
||||
DrawingObjectsController.prototype.recalculate2 = function (bAll) {
|
||||
if (bAll) {
|
||||
var drawings = this.getDrawingObjects();
|
||||
for (var i = 0; i < drawings.length; ++i) {
|
||||
if (drawings[i].recalcText) {
|
||||
drawings[i].recalcText();
|
||||
}
|
||||
drawings[i].recalculate();
|
||||
}
|
||||
} else {
|
||||
for (var key in this.objectsForRecalculate) {
|
||||
this.objectsForRecalculate[key].recalculate();
|
||||
}
|
||||
}
|
||||
this.objectsForRecalculate = {};
|
||||
};
|
||||
DrawingObjectsController.prototype.updateRecalcObjects = function () {};
|
||||
DrawingObjectsController.prototype.getTheme = function () {
|
||||
return window["Asc"]["editor"].wbModel.theme;
|
||||
};
|
||||
DrawingObjectsController.prototype.startRecalculate = function () {
|
||||
this.recalculate();
|
||||
this.drawingObjects.showDrawingObjects(true);
|
||||
};
|
||||
DrawingObjectsController.prototype.getDrawingObjects = function () {
|
||||
var ret = [];
|
||||
var drawing_bases = this.drawingObjects.getDrawingObjects();
|
||||
for (var i = 0; i < drawing_bases.length; ++i) {
|
||||
ret.push(drawing_bases[i].graphicObject);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
DrawingObjectsController.prototype.checkSelectedObjectsForMove = function (group) {
|
||||
var selected_object = group ? group.selectedObjects : this.selectedObjects;
|
||||
for (var i = 0; i < selected_object.length; ++i) {
|
||||
if (selected_object[i].canMove()) {
|
||||
this.arrPreTrackObjects.push(selected_object[i].createMoveTrack());
|
||||
}
|
||||
}
|
||||
};
|
||||
DrawingObjectsController.prototype.checkSelectedObjectsAndFireCallback = function (callback, args) {
|
||||
var selection_state = this.getSelectionState();
|
||||
this.drawingObjects.objectLocker.reset();
|
||||
for (var i = 0; i < this.selectedObjects.length; ++i) {
|
||||
this.drawingObjects.objectLocker.addObjectId(this.selectedObjects[i].Get_Id());
|
||||
}
|
||||
var _this = this;
|
||||
var callback2 = function (bLock, bSync) {
|
||||
if (bLock) {
|
||||
if (bSync !== true) {
|
||||
_this.setSelectionState(selection_state);
|
||||
}
|
||||
callback.apply(_this, args);
|
||||
}
|
||||
};
|
||||
this.drawingObjects.objectLocker.checkObjects(callback2);
|
||||
};
|
||||
DrawingObjectsController.prototype.onMouseDown = function (e, x, y) {
|
||||
e.ShiftKey = e.shiftKey;
|
||||
e.CtrlKey = e.metaKey || e.ctrlKey;
|
||||
e.Button = e.button;
|
||||
e.Type = g_mouse_event_type_down;
|
||||
var ret = this.curState.onMouseDown(e, x, y, 0);
|
||||
if (e.ClickCount < 2) {
|
||||
this.updateOverlay();
|
||||
this.updateSelectionState();
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
DrawingObjectsController.prototype.OnMouseDown = DrawingObjectsController.prototype.onMouseDown;
|
||||
DrawingObjectsController.prototype.onMouseMove = function (e, x, y) {
|
||||
e.ShiftKey = e.shiftKey;
|
||||
e.CtrlKey = e.metaKey || e.ctrlKey;
|
||||
e.Button = e.button;
|
||||
e.Type = g_mouse_event_type_move;
|
||||
this.curState.onMouseMove(e, x, y, 0);
|
||||
};
|
||||
DrawingObjectsController.prototype.OnMouseMove = DrawingObjectsController.prototype.onMouseMove;
|
||||
DrawingObjectsController.prototype.onMouseUp = function (e, x, y) {
|
||||
e.ShiftKey = e.shiftKey;
|
||||
e.CtrlKey = e.metaKey || e.ctrlKey;
|
||||
e.Button = e.button;
|
||||
e.Type = g_mouse_event_type_up;
|
||||
this.curState.onMouseUp(e, x, y, 0);
|
||||
};
|
||||
DrawingObjectsController.prototype.OnMouseUp = DrawingObjectsController.prototype.onMouseUp;
|
||||
DrawingObjectsController.prototype.createGroup = function () {
|
||||
var group = this.getGroup();
|
||||
if (group) {
|
||||
var group_array = this.getArrayForGrouping();
|
||||
for (var i = group_array.length - 1; i > -1; --i) {
|
||||
group_array[i].deleteDrawingBase();
|
||||
}
|
||||
this.resetSelection();
|
||||
this.drawingObjects.getWorksheetModel && group.setWorksheet(this.drawingObjects.getWorksheetModel());
|
||||
group.setDrawingObjects(this.drawingObjects);
|
||||
if (this.drawingObjects && this.drawingObjects.cSld) {
|
||||
group.setParent(this.drawingObjects);
|
||||
}
|
||||
group.addToDrawingObjects();
|
||||
group.checkDrawingBaseCoords();
|
||||
this.selectObject(group, 0);
|
||||
group.addToRecalculate();
|
||||
this.startRecalculate();
|
||||
}
|
||||
};
|
||||
DrawingObjectsController.prototype.handleChartDoubleClick = function () {
|
||||
var drawingObjects = this.drawingObjects;
|
||||
this.checkSelectedObjectsAndFireCallback(function () {
|
||||
drawingObjects.showChartSettings();
|
||||
},
|
||||
[]);
|
||||
};
|
||||
DrawingObjectsController.prototype.addChartDrawingObject = function (options) {
|
||||
History.Create_NewPoint();
|
||||
var chart = this.getChartSpace(this.drawingObjects.getWorksheetModel(), options);
|
||||
if (chart) {
|
||||
chart.setWorksheet(this.drawingObjects.getWorksheetModel());
|
||||
chart.setStyle(2);
|
||||
chart.setBDeleted(false);
|
||||
this.resetSelection();
|
||||
var w, h;
|
||||
if (isRealObject(options) && isRealNumber(options.width) && isRealNumber(options.height)) {
|
||||
w = this.drawingObjects.convertMetric(options.width, 0, 3);
|
||||
h = this.drawingObjects.convertMetric(options.height, 0, 3);
|
||||
} else {
|
||||
w = this.drawingObjects.convertMetric(c_oAscChartDefines.defaultChartWidth, 0, 3);
|
||||
h = this.drawingObjects.convertMetric(c_oAscChartDefines.defaultChartHeight, 0, 3);
|
||||
}
|
||||
var chartLeft, chartTop;
|
||||
if (options && isRealNumber(options.left) && options.left >= 0 && isRealNumber(options.top) && options.top >= 0) {
|
||||
chartLeft = this.drawingObjects.convertMetric(options.left, 0, 3);
|
||||
chartTop = this.drawingObjects.convertMetric(options.top, 0, 3);
|
||||
} else {
|
||||
chartLeft = this.drawingObjects.convertMetric((this.drawingObjects.getContextWidth() - w) / 2, 0, 3);
|
||||
if (chartLeft < 0) {
|
||||
chartLeft = 0;
|
||||
}
|
||||
chartTop = this.drawingObjects.convertMetric((this.drawingObjects.getContextHeight() - h) / 2, 0, 3);
|
||||
if (chartTop < 0) {
|
||||
chartTop = 0;
|
||||
}
|
||||
}
|
||||
chart.setSpPr(new CSpPr());
|
||||
chart.spPr.setParent(chart);
|
||||
chart.spPr.setXfrm(new CXfrm());
|
||||
chart.spPr.xfrm.setParent(chart.spPr);
|
||||
chart.spPr.xfrm.setOffX(chartLeft);
|
||||
chart.spPr.xfrm.setOffY(chartTop);
|
||||
chart.spPr.xfrm.setExtX(w);
|
||||
chart.spPr.xfrm.setExtY(h);
|
||||
chart.setDrawingObjects(this.drawingObjects);
|
||||
chart.setWorksheet(this.drawingObjects.getWorksheetModel());
|
||||
chart.addToDrawingObjects();
|
||||
this.resetSelection();
|
||||
this.selectObject(chart, 0);
|
||||
if (options) {
|
||||
var old_range = options.getRange();
|
||||
options.putRange(null);
|
||||
this.editChartCallback(options);
|
||||
options.putRange(old_range);
|
||||
}
|
||||
chart.addToRecalculate();
|
||||
chart.checkDrawingBaseCoords();
|
||||
this.startRecalculate();
|
||||
this.drawingObjects.sendGraphicObjectProps();
|
||||
}
|
||||
};
|
||||
DrawingObjectsController.prototype.isPointInDrawingObjects = function (x, y, e) {
|
||||
this.handleEventMode = HANDLE_EVENT_MODE_CURSOR;
|
||||
var ret = this.curState.onMouseDown(e || {},
|
||||
x, y, 0);
|
||||
this.handleEventMode = HANDLE_EVENT_MODE_HANDLE;
|
||||
return ret;
|
||||
};
|
||||
DrawingObjectsController.prototype.handleDoubleClickOnChart = function (chart) {
|
||||
this.changeCurrentState(new NullState());
|
||||
};
|
||||
DrawingObjectsController.prototype.addImageFromParams = function (rasterImageId, x, y, extX, extY) {
|
||||
History.Create_NewPoint();
|
||||
var image = this.createImage(rasterImageId, x, y, extX, extY);
|
||||
this.resetSelection();
|
||||
image.setWorksheet(this.drawingObjects.getWorksheetModel());
|
||||
image.setDrawingObjects(this.drawingObjects);
|
||||
image.addToDrawingObjects();
|
||||
image.checkDrawingBaseCoords();
|
||||
this.selectObject(image, 0);
|
||||
image.addToRecalculate();
|
||||
this.startRecalculate();
|
||||
};
|
||||
DrawingObjectsController.prototype.isViewMode = function () {
|
||||
return this.drawingObjects.isViewerMode();
|
||||
};
|
||||
DrawingObjectsController.prototype.getDrawingDocument = function () {
|
||||
return this.drawingObjects.drawingDocument;
|
||||
};
|
||||
DrawingObjectsController.prototype.convertPixToMM = function (pix) {
|
||||
return this.drawingObjects ? this.drawingObjects.convertMetric(pix, 0, 3) : 0;
|
||||
};
|
||||
DrawingObjectsController.prototype.setParagraphNumbering = function (Bullet) {
|
||||
this.applyDocContentFunction(CDocumentContent.prototype.Set_ParagraphPresentationNumbering, [Bullet], CTable.prototype.Set_ParagraphPresentationNumbering);
|
||||
};
|
||||
DrawingObjectsController.prototype.setParagraphIndent = function (Indent) {
|
||||
if (isRealObject(Indent) && isRealNumber(Indent.Left) && Indent.Left < 0) {
|
||||
Indent.Left = 0;
|
||||
}
|
||||
this.applyDocContentFunction(CDocumentContent.prototype.Set_ParagraphIndent, [Indent], CTable.prototype.Set_ParagraphIndent);
|
||||
};
|
||||
DrawingObjectsController.prototype.paragraphIncDecIndent = function (bIncrease) {
|
||||
this.applyDocContentFunction(CDocumentContent.prototype.Increase_ParagraphLevel, [bIncrease], CTable.prototype.Increase_ParagraphLevel);
|
||||
};
|
||||
DrawingObjectsController.prototype.canIncreaseParagraphLevel = function (bIncrease) {
|
||||
var content = this.getTargetDocContent();
|
||||
if (content) {
|
||||
var target_text_object = getTargetTextObject(this);
|
||||
if (target_text_object && target_text_object.getObjectType() === historyitem_type_Shape && (!target_text_object.isPlaceholder() || !target_text_object.getPhType() !== phType_title && target_text_object.getPhType() !== phType_ctrTitle)) {
|
||||
return content.Can_IncreaseParagraphLevel(bIncrease);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
DrawingObjectsController.prototype.onKeyPress = function (e) {
|
||||
if (true === this.isViewMode()) {
|
||||
return false;
|
||||
}
|
||||
if (e.CtrlKey || e.AltKey) {
|
||||
return false;
|
||||
}
|
||||
var Code;
|
||||
if (null != e.Which) {
|
||||
Code = e.Which;
|
||||
} else {
|
||||
if (e.KeyCode) {
|
||||
Code = e.KeyCode;
|
||||
} else {
|
||||
Code = 0;
|
||||
}
|
||||
}
|
||||
var bRetValue = false;
|
||||
if (Code > 32) {
|
||||
this.checkSelectedObjectsAndCallback(function () {
|
||||
this.paragraphAdd(new ParaText(String.fromCharCode(Code)));
|
||||
},
|
||||
[], false, historydescription_Spreadsheet_ParagraphAdd);
|
||||
bRetValue = true;
|
||||
}
|
||||
return bRetValue;
|
||||
};
|
||||
function CheckRightButtonEvent(e) {
|
||||
return e.button === 2;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,103 +1,97 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
(function ($, window, undefined) {
|
||||
var asc = window["Asc"],
|
||||
asc_typeOf = asc.typeOf;
|
||||
function asc_CHandlersList(handlers) {
|
||||
if (! (this instanceof asc_CHandlersList)) {
|
||||
return new asc_CHandlersList(handlers);
|
||||
}
|
||||
this.handlers = handlers || {};
|
||||
return this;
|
||||
}
|
||||
asc_CHandlersList.prototype = {
|
||||
trigger: function (eventName) {
|
||||
var h = this.handlers[eventName],
|
||||
t = asc_typeOf(h),
|
||||
a = Array.prototype.slice.call(arguments, 1),
|
||||
i;
|
||||
if (t === "function") {
|
||||
return h.apply(this, a);
|
||||
}
|
||||
if (t === "array") {
|
||||
for (i = 0; i < h.length; i += 1) {
|
||||
if (asc_typeOf(h[i]) === "function") {
|
||||
h[i].apply(this, a);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
add: function (eventName, eventHandler, replaceOldHandler) {
|
||||
var th = this.handlers,
|
||||
h, old, t;
|
||||
if (replaceOldHandler || !th.hasOwnProperty(eventName)) {
|
||||
th[eventName] = eventHandler;
|
||||
} else {
|
||||
old = h = th[eventName];
|
||||
t = asc_typeOf(old);
|
||||
if (t !== "array") {
|
||||
h = th[eventName] = [];
|
||||
if (t === "function") {
|
||||
h.push(old);
|
||||
}
|
||||
}
|
||||
h.push(eventHandler);
|
||||
}
|
||||
},
|
||||
remove: function (eventName, eventHandler) {
|
||||
var th = this.handlers,
|
||||
h = th[eventName],
|
||||
i;
|
||||
if (th.hasOwnProperty(eventName)) {
|
||||
if (asc_typeOf(h) !== "array" || asc_typeOf(eventHandler) !== "function") {
|
||||
delete th[eventName];
|
||||
return true;
|
||||
}
|
||||
for (i = h.length - 1; i >= 0; i -= 1) {
|
||||
if (h[i] === eventHandler) {
|
||||
delete h[i];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
var prot;
|
||||
window["Asc"]["asc_CHandlersList"] = window["Asc"].asc_CHandlersList = asc_CHandlersList;
|
||||
prot = asc_CHandlersList.prototype;
|
||||
prot["trigger"] = prot.trigger = prot.trigger;
|
||||
prot["add"] = prot.add = prot.add;
|
||||
prot["remove"] = prot.remove = prot.remove;
|
||||
})(jQuery, window);
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2015
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
"use strict";
|
||||
(function (window, undefined) {
|
||||
var asc = window["Asc"],
|
||||
asc_typeOf = asc.typeOf;
|
||||
function asc_CHandlersList(handlers) {
|
||||
this.handlers = handlers || {};
|
||||
return this;
|
||||
}
|
||||
asc_CHandlersList.prototype.hasTrigger = function (eventName) {
|
||||
return null != this.handlers[eventName];
|
||||
};
|
||||
asc_CHandlersList.prototype.trigger = function (eventName) {
|
||||
var h = this.handlers[eventName],
|
||||
t = asc_typeOf(h),
|
||||
a = Array.prototype.slice.call(arguments, 1),
|
||||
i;
|
||||
if (t === "function") {
|
||||
return h.apply(this, a);
|
||||
}
|
||||
if (t === "array") {
|
||||
for (i = 0; i < h.length; i += 1) {
|
||||
if (asc_typeOf(h[i]) === "function") {
|
||||
h[i].apply(this, a);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
asc_CHandlersList.prototype.add = function (eventName, eventHandler, replaceOldHandler) {
|
||||
var th = this.handlers,
|
||||
h, old, t;
|
||||
if (replaceOldHandler || !th.hasOwnProperty(eventName)) {
|
||||
th[eventName] = eventHandler;
|
||||
} else {
|
||||
old = h = th[eventName];
|
||||
t = asc_typeOf(old);
|
||||
if (t !== "array") {
|
||||
h = th[eventName] = [];
|
||||
if (t === "function") {
|
||||
h.push(old);
|
||||
}
|
||||
}
|
||||
h.push(eventHandler);
|
||||
}
|
||||
};
|
||||
asc_CHandlersList.prototype.remove = function (eventName, eventHandler) {
|
||||
var th = this.handlers,
|
||||
h = th[eventName],
|
||||
i;
|
||||
if (th.hasOwnProperty(eventName)) {
|
||||
if (asc_typeOf(h) !== "array" || asc_typeOf(eventHandler) !== "function") {
|
||||
delete th[eventName];
|
||||
return true;
|
||||
}
|
||||
for (i = h.length - 1; i >= 0; i -= 1) {
|
||||
if (h[i] === eventHandler) {
|
||||
delete h[i];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
asc.asc_CHandlersList = asc_CHandlersList;
|
||||
})(window);
|
||||
285
OfficeWeb/sdk/Excel/view/PopUpSelector.js
Normal file
285
OfficeWeb/sdk/Excel/view/PopUpSelector.js
Normal file
@@ -0,0 +1,285 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2015
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
"use strict";
|
||||
(function ($, window, undefined) {
|
||||
var asc = window["Asc"];
|
||||
var asc_HL = asc.HandlersList;
|
||||
function PopUpSelector(element, handlers) {
|
||||
this.handlers = new asc_HL(handlers);
|
||||
this.scrollOptions = {
|
||||
wheelPropagation: false,
|
||||
minScrollbarLength: null,
|
||||
useBothWheelAxes: false,
|
||||
useKeyboard: true,
|
||||
suppressScrollX: false,
|
||||
suppressScrollY: false,
|
||||
scrollXMarginOffset: 5,
|
||||
scrollYMarginOffset: 5,
|
||||
includePadding: false
|
||||
};
|
||||
this.element = element;
|
||||
this.selector = null;
|
||||
this.selectorStyle = null;
|
||||
this.selectorList = null;
|
||||
this.selectorListEl = [];
|
||||
this.selectorListJQ = null;
|
||||
this.selectElement = null;
|
||||
this.firstElement = null;
|
||||
this.isFormula = false;
|
||||
this.isVisible = false;
|
||||
this.skipClose = false;
|
||||
this.fMouseDown = null;
|
||||
this.fMouseDblClick = null;
|
||||
this.fMouseOver = null;
|
||||
this._init();
|
||||
return this;
|
||||
}
|
||||
PopUpSelector.prototype._init = function () {
|
||||
var t = this;
|
||||
if (null != this.element) {
|
||||
this.selector = document.createElement("div");
|
||||
this.selectorStyle = this.selector.style;
|
||||
this.selector.id = "apiPopUpSelector";
|
||||
this.selector.className = "combobox";
|
||||
this.selector.innerHTML = '<ul id="apiPopUpList" class="dropdown-menu"></ul>';
|
||||
this.element.appendChild(this.selector);
|
||||
this.selectorList = document.getElementById("apiPopUpList");
|
||||
this.fMouseDown = function (event) {
|
||||
t._onMouseDown(event);
|
||||
};
|
||||
this.fMouseDblClick = function (event) {
|
||||
t._onMouseDblClick(event);
|
||||
};
|
||||
this.fMouseOver = function (event) {
|
||||
t._onMouseOver(event);
|
||||
};
|
||||
if (this.selector.addEventListener) {
|
||||
this.selector.addEventListener("mousedown", function () {
|
||||
t.skipClose = true;
|
||||
},
|
||||
false);
|
||||
}
|
||||
if (window.addEventListener) {
|
||||
window.addEventListener("mousedown", function () {
|
||||
if (t.skipClose) {
|
||||
t.skipClose = false;
|
||||
return;
|
||||
}
|
||||
t.hide();
|
||||
},
|
||||
false);
|
||||
}
|
||||
this.selectorListJQ = $("#apiPopUpList");
|
||||
if (this.selectorListJQ.perfectScrollbar) {
|
||||
this.selectorListJQ.perfectScrollbar(this.scrollOptions);
|
||||
}
|
||||
this.setAlwaysVisibleY(true);
|
||||
}
|
||||
};
|
||||
PopUpSelector.prototype.show = function (isFormula, arrItems, cellRect) {
|
||||
this._clearList();
|
||||
if (!this.isVisible) {
|
||||
this.selector.className = "combobox open";
|
||||
this.isVisible = true;
|
||||
}
|
||||
this.isFormula = isFormula;
|
||||
var item, isFirst, value, selectElement = null;
|
||||
for (var i = 0; i < arrItems.length; ++i) {
|
||||
item = document.createElement("li");
|
||||
isFirst = (0 === i);
|
||||
if (isFirst) {
|
||||
this.firstElement = item;
|
||||
}
|
||||
if (this.isFormula) {
|
||||
if (isFirst) {
|
||||
selectElement = item;
|
||||
}
|
||||
value = arrItems[i].name;
|
||||
item.setAttribute("title", arrItems[i].arg);
|
||||
} else {
|
||||
value = arrItems[i];
|
||||
}
|
||||
item.innerHTML = "<a>" + value + "</a>";
|
||||
item.setAttribute("val", value);
|
||||
if (item.addEventListener) {
|
||||
item.addEventListener("mousedown", this.fMouseDown, false);
|
||||
item.addEventListener("dblclick", this.fMouseDblClick, false);
|
||||
if (!this.isFormula) {
|
||||
item.addEventListener("mouseover", this.fMouseOver, false);
|
||||
}
|
||||
}
|
||||
this.selectorList.appendChild(item);
|
||||
this.selectorListEl.push(item);
|
||||
}
|
||||
this.setPosition(cellRect);
|
||||
this.selectorListJQ.perfectScrollbar("update");
|
||||
this._onChangeSelection(selectElement);
|
||||
};
|
||||
PopUpSelector.prototype.hide = function () {
|
||||
if (this.isVisible) {
|
||||
this.selectorListJQ.scrollTop(0);
|
||||
this.selector.className = "combobox";
|
||||
this.isVisible = false;
|
||||
this._clearList();
|
||||
}
|
||||
};
|
||||
PopUpSelector.prototype.setPosition = function (cellRect) {
|
||||
var top = cellRect.asc_getY() + cellRect.asc_getHeight(),
|
||||
left = cellRect.asc_getX();
|
||||
var diff = top + this.selectorList.offsetHeight - this.element.offsetHeight;
|
||||
if (0 < diff) {
|
||||
top -= diff;
|
||||
left += cellRect.asc_getWidth();
|
||||
} else {
|
||||
left += 10;
|
||||
}
|
||||
this.selectorStyle["left"] = left + "px";
|
||||
this.selectorStyle["top"] = top + "px";
|
||||
};
|
||||
PopUpSelector.prototype.getVisible = function () {
|
||||
return this.isVisible;
|
||||
};
|
||||
PopUpSelector.prototype._clearList = function () {
|
||||
var i;
|
||||
for (i = 0; i < this.selectorListEl.length; ++i) {
|
||||
this.selectorList.removeChild(this.selectorListEl[i]);
|
||||
}
|
||||
this.selectorListEl.length = 0;
|
||||
this.selectElement = null;
|
||||
this.firstElement = null;
|
||||
this.isFormula = false;
|
||||
};
|
||||
PopUpSelector.prototype.onKeyDown = function (event) {
|
||||
var retVal = false;
|
||||
switch (event.which) {
|
||||
case 9:
|
||||
if (this.isFormula) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
this._onMouseDblClick();
|
||||
} else {
|
||||
retVal = true;
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
if (null !== this.selectElement) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
if (this.isFormula) {
|
||||
this._onMouseDblClick();
|
||||
} else {
|
||||
this._onInsert(this.selectElement.getAttribute("val"));
|
||||
}
|
||||
} else {
|
||||
retVal = true;
|
||||
}
|
||||
break;
|
||||
case 27:
|
||||
this.hide();
|
||||
break;
|
||||
case 38:
|
||||
this._onChangeSelection(null !== this.selectElement ? this.selectElement.previousSibling : this.firstElement);
|
||||
break;
|
||||
case 40:
|
||||
this._onChangeSelection(null !== this.selectElement ? this.selectElement.nextSibling : this.firstElement);
|
||||
break;
|
||||
case 16:
|
||||
break;
|
||||
default:
|
||||
retVal = true;
|
||||
}
|
||||
if (retVal) {
|
||||
this.hide();
|
||||
}
|
||||
return retVal;
|
||||
};
|
||||
PopUpSelector.prototype._onInsert = function (value) {
|
||||
this.hide();
|
||||
this.handlers.trigger("insert", value);
|
||||
};
|
||||
PopUpSelector.prototype._onMouseDown = function (event) {
|
||||
this.skipClose = true;
|
||||
var element = event.currentTarget;
|
||||
if (this.isFormula) {
|
||||
this._onChangeSelection(element);
|
||||
} else {
|
||||
this._onInsert(element.getAttribute("val"));
|
||||
}
|
||||
};
|
||||
PopUpSelector.prototype._onMouseDblClick = function (event) {
|
||||
if (!this.isVisible) {
|
||||
return;
|
||||
}
|
||||
if (!this.isFormula) {
|
||||
this._onMouseDown(event);
|
||||
return;
|
||||
}
|
||||
var elementVal = (event ? event.currentTarget : this.selectElement).getAttribute("val");
|
||||
this._onInsert(elementVal);
|
||||
};
|
||||
PopUpSelector.prototype._onMouseOver = function (event) {
|
||||
if (this.isFormula) {
|
||||
return;
|
||||
}
|
||||
this._onChangeSelection(event.currentTarget);
|
||||
};
|
||||
PopUpSelector.prototype._onChangeSelection = function (newElement) {
|
||||
if (null === newElement || null === newElement.getAttribute("val")) {
|
||||
return;
|
||||
}
|
||||
if (null !== this.selectElement) {
|
||||
this.selectElement.className = "";
|
||||
}
|
||||
this.selectElement = newElement;
|
||||
this.selectElement.className = "selected";
|
||||
this.scrollToRecord();
|
||||
};
|
||||
PopUpSelector.prototype.scrollToRecord = function () {
|
||||
var innerEl = $(this.selectorList);
|
||||
var inner_top = innerEl.offset().top;
|
||||
var div = $(this.selectElement);
|
||||
var div_top = div.offset().top;
|
||||
if (div_top < inner_top || div_top + div.height() > inner_top + innerEl.height()) {
|
||||
this.selectorListJQ.scrollTop(this.selectorListJQ.scrollTop() + div_top - inner_top);
|
||||
}
|
||||
};
|
||||
PopUpSelector.prototype.setAlwaysVisibleY = function (flag) {
|
||||
if (flag) {
|
||||
$(this.selectorList).find(".ps-scrollbar-y-rail").addClass("always-visible-y");
|
||||
$(this.selectorList).find(".ps-scrollbar-y").addClass("always-visible-y");
|
||||
} else {
|
||||
$(this.selectorList).find(".ps-scrollbar-y-rail").removeClass("always-visible-y");
|
||||
$(this.selectorList).find(".ps-scrollbar-y").removeClass("always-visible-y");
|
||||
}
|
||||
};
|
||||
window["Asc"].PopUpSelector = PopUpSelector;
|
||||
})(jQuery, window);
|
||||
181
OfficeWeb/sdk/Excel/view/Private/WorksheetView.js
Normal file
181
OfficeWeb/sdk/Excel/view/Private/WorksheetView.js
Normal file
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2015
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
"use strict";
|
||||
(function ($, window, undefined) {
|
||||
var asc = window["Asc"];
|
||||
var asc_applyFunction = asc.applyFunction;
|
||||
asc.WorksheetView.prototype._isLockedFrozenPane = function (callback) {
|
||||
if (false === this.collaborativeEditing.isCoAuthoringExcellEnable()) {
|
||||
asc_applyFunction(callback, true);
|
||||
return;
|
||||
}
|
||||
var sheetId = this.model.getId();
|
||||
var lockInfo = this.collaborativeEditing.getLockInfo(c_oAscLockTypeElem.Object, null, sheetId, c_oAscLockNameFrozenPane);
|
||||
if (false === this.collaborativeEditing.getCollaborativeEditing()) {
|
||||
asc_applyFunction(callback, true);
|
||||
callback = undefined;
|
||||
}
|
||||
if (false !== this.collaborativeEditing.getLockIntersection(lockInfo, c_oAscLockTypes.kLockTypeMine, false)) {
|
||||
asc_applyFunction(callback, true);
|
||||
return;
|
||||
} else {
|
||||
if (false !== this.collaborativeEditing.getLockIntersection(lockInfo, c_oAscLockTypes.kLockTypeOther, false)) {
|
||||
asc_applyFunction(callback, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.collaborativeEditing.onStartCheckLock();
|
||||
this.collaborativeEditing.addCheckLock(lockInfo);
|
||||
this.collaborativeEditing.onEndCheckLock(callback);
|
||||
};
|
||||
asc.WorksheetView.prototype._isLockedAll = function (callback) {
|
||||
if (false === this.collaborativeEditing.isCoAuthoringExcellEnable()) {
|
||||
asc_applyFunction(callback, true);
|
||||
return;
|
||||
}
|
||||
var sheetId = this.model.getId();
|
||||
var subType = c_oAscLockTypeElemSubType.ChangeProperties;
|
||||
var ar = this.activeRange;
|
||||
var lockInfo = this.collaborativeEditing.getLockInfo(c_oAscLockTypeElem.Range, subType, sheetId, new asc.asc_CCollaborativeRange(ar.c1, ar.r1, ar.c2, ar.r2));
|
||||
if (false === this.collaborativeEditing.getCollaborativeEditing()) {
|
||||
asc_applyFunction(callback, true);
|
||||
callback = undefined;
|
||||
}
|
||||
if (false !== this.collaborativeEditing.getLockIntersection(lockInfo, c_oAscLockTypes.kLockTypeMine, true)) {
|
||||
asc_applyFunction(callback, true);
|
||||
return;
|
||||
} else {
|
||||
if (false !== this.collaborativeEditing.getLockIntersection(lockInfo, c_oAscLockTypes.kLockTypeOther, true)) {
|
||||
asc_applyFunction(callback, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.collaborativeEditing.onStartCheckLock();
|
||||
this.collaborativeEditing.addCheckLock(lockInfo);
|
||||
this.collaborativeEditing.onEndCheckLock(callback);
|
||||
};
|
||||
asc.WorksheetView.prototype._isLockedCells = function (range, subType, callback) {
|
||||
if (false === this.collaborativeEditing.isCoAuthoringExcellEnable()) {
|
||||
asc_applyFunction(callback, true);
|
||||
return true;
|
||||
}
|
||||
var sheetId = this.model.getId();
|
||||
var isIntersection = false;
|
||||
var newCallback = callback;
|
||||
var t = this;
|
||||
this.collaborativeEditing.onStartCheckLock();
|
||||
var isArrayRange = Array.isArray(range);
|
||||
var nLength = isArrayRange ? range.length : 1;
|
||||
var nIndex = 0;
|
||||
var ar = null;
|
||||
for (; nIndex < nLength; ++nIndex) {
|
||||
ar = isArrayRange ? range[nIndex].clone(true) : range.clone(true);
|
||||
if (c_oAscLockTypeElemSubType.InsertColumns !== subType && c_oAscLockTypeElemSubType.InsertRows !== subType) {
|
||||
isIntersection = this._recalcRangeByInsertRowsAndColumns(sheetId, ar);
|
||||
}
|
||||
if (false === isIntersection) {
|
||||
var lockInfo = this.collaborativeEditing.getLockInfo(c_oAscLockTypeElem.Range, subType, sheetId, new asc.asc_CCollaborativeRange(ar.c1, ar.r1, ar.c2, ar.r2));
|
||||
if (false !== this.collaborativeEditing.getLockIntersection(lockInfo, c_oAscLockTypes.kLockTypeOther, false)) {
|
||||
asc_applyFunction(callback, false);
|
||||
return false;
|
||||
} else {
|
||||
if (c_oAscLockTypeElemSubType.InsertColumns === subType) {
|
||||
newCallback = function (isSuccess) {
|
||||
if (isSuccess) {
|
||||
t.collaborativeEditing.addColsRange(sheetId, range.clone(true));
|
||||
t.collaborativeEditing.addCols(sheetId, range.c1, range.c2 - range.c1 + 1);
|
||||
}
|
||||
callback(isSuccess);
|
||||
};
|
||||
} else {
|
||||
if (c_oAscLockTypeElemSubType.InsertRows === subType) {
|
||||
newCallback = function (isSuccess) {
|
||||
if (isSuccess) {
|
||||
t.collaborativeEditing.addRowsRange(sheetId, range.clone(true));
|
||||
t.collaborativeEditing.addRows(sheetId, range.r1, range.r2 - range.r1 + 1);
|
||||
}
|
||||
callback(isSuccess);
|
||||
};
|
||||
} else {
|
||||
if (c_oAscLockTypeElemSubType.DeleteColumns === subType) {
|
||||
newCallback = function (isSuccess) {
|
||||
if (isSuccess) {
|
||||
t.collaborativeEditing.removeColsRange(sheetId, range.clone(true));
|
||||
t.collaborativeEditing.removeCols(sheetId, range.c1, range.c2 - range.c1 + 1);
|
||||
}
|
||||
callback(isSuccess);
|
||||
};
|
||||
} else {
|
||||
if (c_oAscLockTypeElemSubType.DeleteRows === subType) {
|
||||
newCallback = function (isSuccess) {
|
||||
if (isSuccess) {
|
||||
t.collaborativeEditing.removeRowsRange(sheetId, range.clone(true));
|
||||
t.collaborativeEditing.removeRows(sheetId, range.r1, range.r2 - range.r1 + 1);
|
||||
}
|
||||
callback(isSuccess);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.collaborativeEditing.addCheckLock(lockInfo);
|
||||
}
|
||||
} else {
|
||||
if (c_oAscLockTypeElemSubType.InsertColumns === subType) {
|
||||
t.collaborativeEditing.addColsRange(sheetId, range.clone(true));
|
||||
t.collaborativeEditing.addCols(sheetId, range.c1, range.c2 - range.c1 + 1);
|
||||
} else {
|
||||
if (c_oAscLockTypeElemSubType.InsertRows === subType) {
|
||||
t.collaborativeEditing.addRowsRange(sheetId, range.clone(true));
|
||||
t.collaborativeEditing.addRows(sheetId, range.r1, range.r2 - range.r1 + 1);
|
||||
} else {
|
||||
if (c_oAscLockTypeElemSubType.DeleteColumns === subType) {
|
||||
t.collaborativeEditing.removeColsRange(sheetId, range.clone(true));
|
||||
t.collaborativeEditing.removeCols(sheetId, range.c1, range.c2 - range.c1 + 1);
|
||||
} else {
|
||||
if (c_oAscLockTypeElemSubType.DeleteRows === subType) {
|
||||
t.collaborativeEditing.removeRowsRange(sheetId, range.clone(true));
|
||||
t.collaborativeEditing.removeRows(sheetId, range.r1, range.r2 - range.r1 + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (false === this.collaborativeEditing.getCollaborativeEditing()) {
|
||||
newCallback(true);
|
||||
newCallback = undefined;
|
||||
}
|
||||
this.collaborativeEditing.onEndCheckLock(newCallback);
|
||||
return true;
|
||||
};
|
||||
})(jQuery, window);
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user