init repo
This commit is contained in:
1959
OfficeWeb/sdk/Excel/view/CellEditorView.js
Normal file
1959
OfficeWeb/sdk/Excel/view/CellEditorView.js
Normal file
File diff suppressed because it is too large
Load Diff
198
OfficeWeb/sdk/Excel/view/CellTextRender.js
Normal file
198
OfficeWeb/sdk/Excel/view/CellTextRender.js
Normal file
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
* (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);
|
||||
1344
OfficeWeb/sdk/Excel/view/EventsController.js
Normal file
1344
OfficeWeb/sdk/Excel/view/EventsController.js
Normal file
File diff suppressed because it is too large
Load Diff
103
OfficeWeb/sdk/Excel/view/HandlerList.js
Normal file
103
OfficeWeb/sdk/Excel/view/HandlerList.js
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* (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);
|
||||
842
OfficeWeb/sdk/Excel/view/StringRender.js
Normal file
842
OfficeWeb/sdk/Excel/view/StringRender.js
Normal file
@@ -0,0 +1,842 @@
|
||||
/*
|
||||
* (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_calcnpt = asc.calcNearestPt;
|
||||
var asc_n2css = asc.numberToCSSColor;
|
||||
var asc_debug = asc.outputDebugStr;
|
||||
var asc_typeof = asc.typeOf;
|
||||
var asc_round = asc.round;
|
||||
var asc_clone = asc.clone;
|
||||
var asc_FP = asc.FontProperties;
|
||||
var asc_TM = asc.TextMetrics;
|
||||
function LineInfo(tw, th, bl, a, d) {
|
||||
this.tw = tw !== undefined ? tw : 0;
|
||||
this.th = th !== undefined ? th : 0;
|
||||
this.bl = bl !== undefined ? bl : 0;
|
||||
this.a = a !== undefined ? a : 0;
|
||||
this.d = d !== undefined ? d : 0;
|
||||
this.beg = undefined;
|
||||
this.end = undefined;
|
||||
this.startX = undefined;
|
||||
}
|
||||
LineInfo.prototype = {
|
||||
constructor: LineInfo,
|
||||
assign: function (tw, th, bl, a, d) {
|
||||
if (tw !== undefined) {
|
||||
this.tw = tw;
|
||||
}
|
||||
if (th !== undefined) {
|
||||
this.th = th;
|
||||
}
|
||||
if (bl !== undefined) {
|
||||
this.bl = bl;
|
||||
}
|
||||
if (a !== undefined) {
|
||||
this.a = a;
|
||||
}
|
||||
if (d !== undefined) {
|
||||
this.d = d;
|
||||
}
|
||||
}
|
||||
};
|
||||
function StringRender(drawingCtx) {
|
||||
if (! (this instanceof StringRender)) {
|
||||
return new StringRender(drawingCtx);
|
||||
}
|
||||
this.drawingCtx = drawingCtx;
|
||||
this.defaultFont = undefined;
|
||||
this.fragments = undefined;
|
||||
this.flags = undefined;
|
||||
this.chars = "";
|
||||
this.charWidths = [];
|
||||
this.charProps = [];
|
||||
this.lines = [];
|
||||
this.ratio = 1;
|
||||
this.angle = 0;
|
||||
this.fontNeedUpdate = false;
|
||||
return this;
|
||||
}
|
||||
StringRender.prototype = {
|
||||
constructor: StringRender,
|
||||
reNL: /[\r\n]/,
|
||||
reTab: /[\t\v\f]/,
|
||||
reSpace: /[\n\r\u2028\u2029\t\v\f\u0020\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2008\u2009\u200A\u200B\u205F\u3000]/,
|
||||
reReplaceNL: /\r?\n|\r/g,
|
||||
reReplaceTab : /[\t\v\f]/g,
|
||||
reHypNL: /[\n\r\u2028\u2029]/,
|
||||
reHypSp: /[\t\v\f\u0020\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2008\u2009\u200A\u200B\u205F\u3000]/,
|
||||
reHyphen: /[\u002D\u00AD\u2010\u2012\u2013\u2014]/,
|
||||
setDefaultFont: function (font) {
|
||||
this.defaultFont = font;
|
||||
return this;
|
||||
},
|
||||
setDefaultFontFromFmt: function (fmt) {
|
||||
if (asc_typeof(fmt.fn) !== "string" || !(fmt.fs > 0)) {
|
||||
throw "Can not make font from {fmt.fn=" + fmt.fn + ", fmt.fs=" + fmt.fs + "}";
|
||||
}
|
||||
this.defaultFont = this._makeFont(fmt);
|
||||
return this;
|
||||
},
|
||||
setString: function (str, flags) {
|
||||
this.fragments = [];
|
||||
if (asc_typeof(str) === "string") {
|
||||
this.fragments.push({
|
||||
text: str,
|
||||
format: {}
|
||||
});
|
||||
} else {
|
||||
for (var i = 0, c, fmt; i < str.length; ++i) {
|
||||
fmt = str[i].format;
|
||||
c = fmt.c;
|
||||
if (asc_typeof(c) === "number") {
|
||||
fmt.c = asc_n2css(c);
|
||||
}
|
||||
this.fragments.push({
|
||||
text: str[i].text,
|
||||
format: fmt
|
||||
});
|
||||
}
|
||||
}
|
||||
this.flags = flags;
|
||||
this._reset();
|
||||
this.drawingCtx.setFont(this.defaultFont, this.angle);
|
||||
return this;
|
||||
},
|
||||
rotateAtPoint: function (drawingCtx, angle, x, y, dx, dy) {
|
||||
var m = new asc.Matrix();
|
||||
m.rotate(angle, 0);
|
||||
var mbt = new asc.Matrix();
|
||||
if (null === drawingCtx) {
|
||||
mbt.translate(x + dx, y + dy);
|
||||
this.drawingCtx.setTextTransform(m.sx, m.shy, m.shx, m.sy, m.tx, m.ty);
|
||||
this.drawingCtx.setTransform(mbt.sx, mbt.shy, mbt.shx, mbt.sy, mbt.tx, mbt.ty);
|
||||
this.drawingCtx.updateTransforms();
|
||||
} else {
|
||||
mbt.translate((x + dx) * vector_koef, (y + dy) * vector_koef);
|
||||
mbt.multiply(m, 0);
|
||||
drawingCtx.setTransform(mbt.sx, mbt.shy, mbt.shx, mbt.sy, mbt.tx, mbt.ty);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
resetTransform: function (drawingCtx) {
|
||||
if (null === drawingCtx) {
|
||||
this.drawingCtx.resetTransforms();
|
||||
} else {
|
||||
var m = new asc.Matrix();
|
||||
drawingCtx.setTransform(m.sx, m.shy, m.shx, m.sy, m.tx, m.ty);
|
||||
}
|
||||
this.angle = 0;
|
||||
this.fontNeedUpdate = true;
|
||||
},
|
||||
getTransformBound: function (angle, x, y, w, h, textW, alignHorizontal, alignVertical, maxWidth) {
|
||||
this.angle = 0;
|
||||
this.fontNeedUpdate = true;
|
||||
var dx = 0,
|
||||
dy = 0,
|
||||
sx = 0,
|
||||
sw = 0;
|
||||
var tm = this._doMeasure(maxWidth);
|
||||
var mul = (90 - (Math.abs(angle))) / 90;
|
||||
var posh = (angle === 90 || angle === -90) ? textW : Math.abs(Math.sin(angle * Math.PI / 180) * textW);
|
||||
var posv = (angle === 90 || angle === -90) ? 0 : Math.abs(Math.cos(angle * Math.PI / 180) * textW);
|
||||
if ("bottom" === alignVertical) {
|
||||
if (angle < 0) {
|
||||
if ("left" === alignHorizontal) {
|
||||
dx = (1 - mul) * tm.height;
|
||||
sw = x + posv + (mul * 0.5) * tm.height;
|
||||
} else {
|
||||
if ("center" === alignHorizontal) {
|
||||
dx = (w + tm.height - posv) * 0.5;
|
||||
sx = x + (w - posv) * 0.5 - (mul * 0.5) * tm.height;
|
||||
sw = x + (w + posv) * 0.5 + (mul * 0.5) * tm.height;
|
||||
} else {
|
||||
if ("right" === alignHorizontal) {
|
||||
dx = w - posv;
|
||||
sx = x + dx - (mul * 0.5) * tm.height;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ("left" === alignHorizontal) {
|
||||
sw = x + posv + (mul * 0.5) * tm.height;
|
||||
} else {
|
||||
if ("center" === alignHorizontal) {
|
||||
dx = (w - tm.height - posv) * 0.5;
|
||||
sx = x + (w - posv) * 0.5 - (mul * 0.5) * tm.height;
|
||||
sw = x + (w + posv) * 0.5 + (mul * 0.5) * tm.height;
|
||||
} else {
|
||||
if ("right" === alignHorizontal) {
|
||||
dx = w - posv - (1 - mul) * tm.height;
|
||||
sx = x + dx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (posh < h) {
|
||||
if (angle < 0) {
|
||||
dy = h - (posh + mul * tm.height);
|
||||
} else {
|
||||
dy = h - mul * tm.height;
|
||||
}
|
||||
} else {
|
||||
if (angle > 0) {
|
||||
dy = h - mul * tm.height;
|
||||
} else {}
|
||||
}
|
||||
} else {
|
||||
if ("center" === alignVertical) {
|
||||
if (angle < 0) {
|
||||
if ("left" === alignHorizontal) {
|
||||
dx = (1 - mul * 0.5) * tm.height;
|
||||
sw = x + posv + (mul * 0.5) * tm.height;
|
||||
} else {
|
||||
if ("center" === alignHorizontal) {
|
||||
dx = (w + tm.height - posv) * 0.5;
|
||||
sx = x + (w - posv) * 0.5 - (mul * 0.5) * tm.height;
|
||||
sw = x + (w + posv) * 0.5 + (mul * 0.5) * tm.height;
|
||||
} else {
|
||||
if ("right" === alignHorizontal) {
|
||||
dx = w - (mul * 0.5) * tm.height - posv;
|
||||
sx = x + dx - (mul * 0.5) * tm.height;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ("left" === alignHorizontal) {
|
||||
sw = x + posv + (mul * 0.5) * tm.height;
|
||||
} else {
|
||||
if ("center" == alignHorizontal) {
|
||||
dx = (w - tm.height - posv) * 0.5;
|
||||
sx = x + (w - posv) * 0.5 - (mul * 0.5) * tm.height;
|
||||
sw = x + (w + posv) * 0.5 + (mul * 0.5) * tm.height;
|
||||
} else {
|
||||
if ("right" === alignHorizontal) {
|
||||
dx = w - posv - tm.height;
|
||||
sx = x + dx;
|
||||
sx = x + dx - (mul * 0.5) * tm.height;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (posh < h) {
|
||||
if (angle < 0) {
|
||||
dy = (h - posh) * 0.5;
|
||||
} else {
|
||||
dy = (h + posh) * 0.5;
|
||||
}
|
||||
} else {
|
||||
if (angle > 0) {
|
||||
dy = h - mul * tm.height;
|
||||
} else {}
|
||||
}
|
||||
} else {
|
||||
if ("top" === alignVertical) {
|
||||
if (angle < 0) {
|
||||
if ("left" === alignHorizontal) {
|
||||
dx = (1 - mul * 0.5) * tm.height;
|
||||
sw = x + posv + (mul * 0.5) * tm.height;
|
||||
} else {
|
||||
if ("c" === alignHorizontal) {
|
||||
dx = (w + tm.height - posv) * 0.5;
|
||||
sx = x + (w - posv) * 0.5 - (mul * 0.5) * tm.height;
|
||||
sw = x + (w + posv) * 0.5 + (mul * 0.5) * tm.height;
|
||||
} else {
|
||||
if ("right" === alignHorizontal) {
|
||||
dx = w - (mul * 0.5) * tm.height - posv;
|
||||
sx = x + dx - (mul * 0.5) * tm.height;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ("left" === alignHorizontal) {
|
||||
sw = x + posv + (mul * 0.5) * tm.height;
|
||||
} else {
|
||||
if ("c" === alignHorizontal) {
|
||||
dx = (w - tm.height - posv) * 0.5;
|
||||
sx = x + (w - posv) * 0.5 - (mul * 0.5) * tm.height;
|
||||
sw = x + (w + posv) * 0.5 + (mul * 0.5) * tm.height;
|
||||
} else {
|
||||
if ("right" === alignHorizontal) {
|
||||
dx = w - posv - tm.height;
|
||||
sx = x + dx;
|
||||
sx = x + dx - (mul * 0.5) * tm.height;
|
||||
}
|
||||
}
|
||||
}
|
||||
dy = Math.min(h + tm.height * mul, posh);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var bound = {};
|
||||
bound.dx = dx;
|
||||
bound.dy = dy;
|
||||
bound.x = x;
|
||||
bound.y = y;
|
||||
bound.sx = sx;
|
||||
bound.sw = sw;
|
||||
if (angle === 90 || angle === -90) {
|
||||
bound.height = textW;
|
||||
} else {
|
||||
bound.height = Math.abs(Math.sin(angle / 180 * Math.PI) * textW) + (mul) * tm.height;
|
||||
}
|
||||
return bound;
|
||||
},
|
||||
measure: function (maxWidth) {
|
||||
return this._doMeasure(maxWidth);
|
||||
},
|
||||
render: function (x, y, maxWidth, textColor) {
|
||||
this._doRender(undefined, x, y, maxWidth, textColor);
|
||||
return this;
|
||||
},
|
||||
renderForPrint: function (drawingCtx, x, y, maxWidth, textColor) {
|
||||
this._doRender(drawingCtx, x, y, maxWidth, textColor);
|
||||
return this;
|
||||
},
|
||||
measureString: function (str, flags, maxWidth) {
|
||||
if (str !== undefined) {
|
||||
this.setString(str, flags);
|
||||
}
|
||||
return this._doMeasure(maxWidth);
|
||||
},
|
||||
renderString: function (str, flags, x, y, maxWidth, textColor) {
|
||||
if (str !== undefined) {
|
||||
this.setString(str, flags);
|
||||
}
|
||||
if (this.charWidths.length < 1 && null === this._doMeasure(maxWidth)) {
|
||||
asc_debug("log", "Warning: can not measure '", str, "'");
|
||||
return this;
|
||||
}
|
||||
this._doRender(undefined, x, y, maxWidth, textColor);
|
||||
return this;
|
||||
},
|
||||
getWidestCharWidth: function () {
|
||||
return this.charWidths.reduce(function (p, c) {
|
||||
return p < c ? c : p;
|
||||
},
|
||||
0);
|
||||
},
|
||||
_reset: function () {
|
||||
this.chars = "";
|
||||
this.charWidths = [];
|
||||
this.charProps = [];
|
||||
this.lines = [];
|
||||
this.ratio = 1;
|
||||
},
|
||||
_filterText: function (fragment, wrap) {
|
||||
var s = fragment;
|
||||
if (s.search(this.reNL) >= 0) {
|
||||
s = s.replace(this.reReplaceNL, wrap ? "\n" : "\u00B6");
|
||||
}
|
||||
if (s.search(this.reTab) >= 0) {
|
||||
s = s.replace(this.reReplaceTab, wrap ? " " : "\u2192");
|
||||
}
|
||||
return s;
|
||||
},
|
||||
_makeFont: function (format) {
|
||||
if (format !== undefined && asc_typeof(format.fn) === "string") {
|
||||
var fsz = format.fs > 0 ? format.fs : this.defaultFont.FontSize;
|
||||
return new asc_FP(format.fn, fsz, format.b, format.i, format.u, format.s);
|
||||
}
|
||||
return this.defaultFont;
|
||||
},
|
||||
_calcCharsWidth: function (startCh, endCh) {
|
||||
for (var w = 0, i = startCh; i <= endCh; ++i) {
|
||||
w += this.charWidths[i];
|
||||
}
|
||||
return w * this.ratio;
|
||||
},
|
||||
_calcLineWidth: function (startPos, endPos) {
|
||||
var wrap = this.flags && this.flags.wrapText;
|
||||
var wrapNL = this.flags && this.flags.wrapOnlyNL;
|
||||
var isAtEnd, j, chProp, tw;
|
||||
if (endPos === undefined || endPos < 0) {
|
||||
for (j = startPos + 1; j < this.chars.length; ++j) {
|
||||
chProp = this.charProps[j];
|
||||
if (chProp && (chProp.nl || chProp.hp)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
endPos = j - 1;
|
||||
}
|
||||
for (j = endPos, tw = 0, isAtEnd = true; j >= startPos; --j) {
|
||||
if (isAtEnd) {
|
||||
if ((wrap || wrapNL) && this.reSpace.test(this.chars[j])) {
|
||||
continue;
|
||||
}
|
||||
isAtEnd = false;
|
||||
}
|
||||
tw += this.charWidths[j];
|
||||
}
|
||||
return tw * this.ratio;
|
||||
},
|
||||
_calcLineMetrics: function (f, va, fm, ppi) {
|
||||
var l = {
|
||||
th: 0,
|
||||
bl: 0,
|
||||
bl2: 0,
|
||||
a: 0,
|
||||
d: 0
|
||||
};
|
||||
var hpt = f * 1.275;
|
||||
var fpx = f * ppi / 72;
|
||||
var topt = 72 / ppi;
|
||||
var h = asc_calcnpt(hpt, ppi);
|
||||
var a = asc_round(fpx) * topt;
|
||||
var d = h - a;
|
||||
var a_2 = asc_round(fpx / 2) * topt;
|
||||
var h_2_3 = asc_calcnpt(hpt * 2 / 3, ppi);
|
||||
var a_2_3 = asc_round(fpx * 2 / 3) * topt;
|
||||
var d_2_3 = h_2_3 - a_2_3;
|
||||
var x = a_2 + a_2_3;
|
||||
if (va === "superscript") {
|
||||
l.th = x + d;
|
||||
l.bl = x;
|
||||
l.bl2 = a_2_3;
|
||||
l.a = fm.ascender + a_2;
|
||||
l.d = fm.descender - a_2;
|
||||
} else {
|
||||
if (va === "subscript") {
|
||||
l.th = x + d_2_3;
|
||||
l.bl = a;
|
||||
l.bl2 = x;
|
||||
l.a = fm.ascender + a - x;
|
||||
l.d = fm.descender + x - a;
|
||||
} else {
|
||||
l.th = a + d;
|
||||
l.bl = a;
|
||||
l.a = fm.ascender;
|
||||
l.d = fm.descender;
|
||||
}
|
||||
}
|
||||
return l;
|
||||
},
|
||||
_calcTextMetrics: function (dontCalcRepeatChars) {
|
||||
var self = this,
|
||||
i, p, p_, lm, beg;
|
||||
var l = new LineInfo(),
|
||||
TW = 0,
|
||||
TH = 0,
|
||||
BL = 0,
|
||||
CL = 0;
|
||||
var ppi = this.drawingCtx.getPPIY();
|
||||
function calcDelta(vnew, vold) {
|
||||
return vnew > vold ? vnew - vold : 0;
|
||||
}
|
||||
function addLine(b, e) {
|
||||
l.tw += self._calcLineWidth(b, e - 1);
|
||||
l.beg = b;
|
||||
l.end = e - 1;
|
||||
self.lines.push(l);
|
||||
if (TW < l.tw) {
|
||||
TW = l.tw;
|
||||
}
|
||||
BL = TH + l.bl;
|
||||
TH += l.th;
|
||||
}
|
||||
for (i = 0, beg = 0; i < this.chars.length; ++i) {
|
||||
p = this.charProps[i];
|
||||
if (p && p.font) {
|
||||
lm = this._calcLineMetrics(p.fsz !== undefined ? p.fsz : p.font.FontSize, p.va, p.fm, ppi);
|
||||
if (i === 0) {
|
||||
l.assign(0, lm.th, lm.bl, lm.a, lm.d);
|
||||
} else {
|
||||
l.th += calcDelta(lm.bl, l.bl) + calcDelta(lm.th - lm.bl, l.th - l.bl);
|
||||
l.bl += calcDelta(lm.bl, l.bl);
|
||||
l.a += calcDelta(lm.a, l.a);
|
||||
l.d += calcDelta(lm.d, l.d);
|
||||
}
|
||||
p.lm = lm;
|
||||
p_ = p;
|
||||
}
|
||||
if (dontCalcRepeatChars && p && p.repeat > 0) {
|
||||
l.tw -= this._calcCharsWidth(i, i + p.repeat - 1);
|
||||
}
|
||||
if (p && (p.nl || p.hp)) {
|
||||
addLine(beg, i);
|
||||
beg = i;
|
||||
lm = this._calcLineMetrics(p_.fsz !== undefined ? p_.fsz : p_.font.FontSize, p_.va, p_.fm, ppi);
|
||||
l = new LineInfo(0, lm.th, lm.bl, lm.a, lm.d);
|
||||
}
|
||||
}
|
||||
if (beg < i) {
|
||||
addLine(beg, i);
|
||||
}
|
||||
if (this.lines.length > 0) {
|
||||
CL = (this.lines[0].bl - this.lines[0].a + BL + l.d) / 2;
|
||||
}
|
||||
return new asc_TM(TW, TH, 0, BL, 0, 0, CL);
|
||||
},
|
||||
_insertRepeatChars: function (maxWidth) {
|
||||
var self = this,
|
||||
width, w, pos;
|
||||
function getNextRepeatCharsPos(fromPos) {
|
||||
for (var i = fromPos; i < self.chars.length; ++i) {
|
||||
if (self.charProps[i] && self.charProps[i].repeat > 0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
function calcRepeatCharsWidth(pos) {
|
||||
return self._calcCharsWidth(pos, pos + self.charProps[pos].repeat - 1);
|
||||
}
|
||||
function shiftCharProps(fromPos, delta) {
|
||||
for (var i = self.chars.length - 1; i >= fromPos; --i) {
|
||||
if (self.charProps[i]) {
|
||||
var p = self.charProps[i];
|
||||
delete self.charProps[i];
|
||||
self.charProps[i + delta] = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
function insertRepeatChars(pos) {
|
||||
if (self.charProps[pos].total === undefined) {
|
||||
self.charProps[pos].total = self.charProps[pos].repeat;
|
||||
} else {
|
||||
var repeatCount = self.charProps[pos].repeat,
|
||||
repeatEnd = pos + self.charProps[pos].total;
|
||||
self.chars = "" + self.chars.slice(0, repeatEnd) + self.chars.slice(pos, pos + repeatCount) + self.chars.slice(repeatEnd);
|
||||
self.charWidths = [].concat(self.charWidths.slice(0, repeatEnd), self.charWidths.slice(pos, pos + repeatCount), self.charWidths.slice(repeatEnd));
|
||||
self.charProps[pos].total += repeatCount;
|
||||
shiftCharProps(pos + 1, repeatCount);
|
||||
}
|
||||
}
|
||||
width = this._calcTextMetrics(true).width;
|
||||
pos = 0;
|
||||
while (1) {
|
||||
do {
|
||||
pos = getNextRepeatCharsPos(pos < 0 ? 0 : pos);
|
||||
} while (pos < 0);
|
||||
w = calcRepeatCharsWidth(pos);
|
||||
if (w + width > maxWidth) {
|
||||
break;
|
||||
}
|
||||
insertRepeatChars(pos);
|
||||
width += w;
|
||||
++pos;
|
||||
}
|
||||
this.lines = [];
|
||||
},
|
||||
_measureChars: function (maxWidth) {
|
||||
var self = this;
|
||||
var ctx = this.drawingCtx;
|
||||
var wrap = this.flags && this.flags.wrapText;
|
||||
var wrapNL = this.flags && this.flags.wrapOnlyNL;
|
||||
var hasRepeats = false;
|
||||
var i, j, fr, fmt, text, p, p_ = {},
|
||||
pIndex, va, f, f_, eq, startCh;
|
||||
var tw = 0,
|
||||
nlPos = 0,
|
||||
hpPos = undefined,
|
||||
isSP_ = true,
|
||||
delta = 0;
|
||||
function charPropAt(index) {
|
||||
var prop = self.charProps[index];
|
||||
if (!prop) {
|
||||
prop = self.charProps[index] = {};
|
||||
}
|
||||
return prop;
|
||||
}
|
||||
function measureFragment(s) {
|
||||
var j, ch, chw, chPos, isNL, isSP, isHP, tm;
|
||||
for (chPos = self.chars.length, j = 0; j < s.length; ++j, ++chPos) {
|
||||
ch = s.charAt(j);
|
||||
tm = ctx.measureChar(ch, 1);
|
||||
chw = tm.width;
|
||||
isNL = self.reHypNL.test(ch);
|
||||
isSP = !isNL ? self.reHypSp.test(ch) : false;
|
||||
if (wrap || wrapNL) {
|
||||
isHP = !isSP && !isNL ? self.reHyphen.test(ch) : false;
|
||||
if (isNL) {
|
||||
nlPos = chPos + 1;
|
||||
charPropAt(nlPos).nl = true;
|
||||
charPropAt(nlPos).delta = delta;
|
||||
ch = " ";
|
||||
chw = 0;
|
||||
tw = 0;
|
||||
hpPos = undefined;
|
||||
} else {
|
||||
if (isSP || isHP) {
|
||||
hpPos = chPos + 1;
|
||||
}
|
||||
}
|
||||
if (wrap && tw + chw > maxWidth && chPos !== nlPos && !isSP) {
|
||||
nlPos = hpPos !== undefined ? hpPos : chPos;
|
||||
charPropAt(nlPos).hp = true;
|
||||
charPropAt(nlPos).delta = delta;
|
||||
tw = self._calcCharsWidth(nlPos, chPos - 1);
|
||||
hpPos = undefined;
|
||||
}
|
||||
}
|
||||
if (isSP_ && !isSP && !isNL) {
|
||||
charPropAt(chPos).wrd = true;
|
||||
}
|
||||
tw += chw;
|
||||
self.charWidths.push(chw);
|
||||
self.chars += ch;
|
||||
isSP_ = isSP || isNL;
|
||||
delta = tm.widthBB - tm.width;
|
||||
}
|
||||
}
|
||||
this._reset();
|
||||
for (i = 0, f_ = ctx.getFont(); i < this.fragments.length; ++i) {
|
||||
startCh = this.charWidths.length;
|
||||
fr = this.fragments[i];
|
||||
fmt = fr.format;
|
||||
text = this._filterText(fr.text, wrap || wrapNL);
|
||||
if (text.length < 1) {
|
||||
continue;
|
||||
}
|
||||
f = this._makeFont(fmt);
|
||||
pIndex = this.chars.length;
|
||||
p = asc_clone(this.charProps[pIndex] || {});
|
||||
va = fmt.va !== undefined ? fmt.va.toLowerCase() : "";
|
||||
if (va === "subscript" || va === "superscript") {
|
||||
p.va = va;
|
||||
p.fsz = f.FontSize;
|
||||
f.FontSize *= 2 / 3;
|
||||
p.font = f;
|
||||
}
|
||||
eq = f.isEqual(f_);
|
||||
if (!eq || f.Underline !== f_.Underline || f.Strikeout !== f_.Strikeout || fmt.c !== p_.c) {
|
||||
if (!eq) {
|
||||
ctx.setFont(f, this.angle);
|
||||
}
|
||||
p.font = f;
|
||||
f_ = f;
|
||||
}
|
||||
if (i === 0) {
|
||||
p.font = f;
|
||||
}
|
||||
if (p.font) {
|
||||
p.fm = ctx.getFontMetrics();
|
||||
p.c = fmt.c;
|
||||
this.charProps[pIndex] = p;
|
||||
p_ = p;
|
||||
}
|
||||
if (fmt.skip) {
|
||||
charPropAt(pIndex).skip = text.length;
|
||||
}
|
||||
if (fmt.repeat) {
|
||||
charPropAt(pIndex).repeat = text.length;
|
||||
hasRepeats = true;
|
||||
}
|
||||
measureFragment(text);
|
||||
for (j = startCh; f_.Italic && j < this.charWidths.length; ++j) {
|
||||
if (this.charProps[j] && this.charProps[j].delta && j > 0) {
|
||||
if (this.charWidths[j - 1] > 0) {
|
||||
this.charWidths[j - 1] += this.charProps[j].delta;
|
||||
} else {
|
||||
if (j > 1) {
|
||||
this.charWidths[j - 2] += this.charProps[j].delta;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.charProps[this.chars.length] !== undefined) {
|
||||
delete this.charProps[this.chars.length];
|
||||
} else {
|
||||
if (f_.Italic) {
|
||||
this.charWidths[this.charWidths.length - 1] += delta;
|
||||
}
|
||||
}
|
||||
if (hasRepeats) {
|
||||
if (maxWidth === undefined) {
|
||||
throw "Undefined width of cell width Numeric Format";
|
||||
}
|
||||
this._insertRepeatChars(maxWidth);
|
||||
}
|
||||
return this._calcTextMetrics();
|
||||
},
|
||||
_doMeasure: function (maxWidth) {
|
||||
var tm = this._measureChars(maxWidth);
|
||||
if (this.flags && this.flags.shrinkToFit && tm.width > maxWidth) {
|
||||
this.ratio = maxWidth / tm.width;
|
||||
tm.width = maxWidth;
|
||||
}
|
||||
return tm;
|
||||
},
|
||||
_doRender: function (drawingCtx, x, y, maxWidth, textColor) {
|
||||
var self = this;
|
||||
var ctx = (undefined !== drawingCtx) ? drawingCtx : this.drawingCtx;
|
||||
var ppix = ctx.getPPIX();
|
||||
var ppiy = ctx.getPPIY();
|
||||
var shrink = this.flags && this.flags.shrinkToFit;
|
||||
var align = this.flags ? this.flags.textAlign.toLowerCase() : "";
|
||||
var i, j, p, p_, f, f_, strBeg;
|
||||
var n = 0,
|
||||
l = this.lines[0],
|
||||
x1 = l ? initX(0) : 0,
|
||||
y1 = y,
|
||||
dx = l ? computeWordDeltaX() : 0;
|
||||
function initX(startPos) {
|
||||
var x_ = x;
|
||||
if (align === "right") {
|
||||
x_ = asc_calcnpt(x + maxWidth - self._calcLineWidth(startPos), ppix, -1);
|
||||
} else {
|
||||
if (align === "center") {
|
||||
x_ = asc_calcnpt(x + 0.5 * (maxWidth - self._calcLineWidth(startPos)), ppix, 0);
|
||||
}
|
||||
}
|
||||
l.startX = x_;
|
||||
return x_;
|
||||
}
|
||||
function computeWordDeltaX() {
|
||||
if (align !== "justify") {
|
||||
return 0;
|
||||
}
|
||||
for (var i = l.beg, c = 0; i <= l.end; ++i) {
|
||||
var p = self.charProps[i];
|
||||
if (p && p.wrd) {
|
||||
++c;
|
||||
}
|
||||
}
|
||||
return c > 1 ? (maxWidth - l.tw) / (c - 1) : 0;
|
||||
}
|
||||
function renderFragment(begin, end, prop, angle) {
|
||||
var dh = prop && prop.lm && prop.lm.bl2 > 0 ? prop.lm.bl2 - prop.lm.bl : 0;
|
||||
var dw = self._calcCharsWidth(strBeg, end - 1);
|
||||
var so = prop.font.Strikeout;
|
||||
var ul = prop.font.Underline;
|
||||
var isSO = so === true;
|
||||
var isUL = ul === true || !(ul === undefined || ul === false || ul.search(/\w/) < 0 || ul.search(/\s*none\s*/i) >= 0);
|
||||
var fsz, x2, y, lw, dy, i, b, x_, cp, w_1px, h_1px;
|
||||
if (align !== "justify" || dx < 1e-06) {
|
||||
ctx.fillText(self.chars.slice(begin, end), x1, y1 + l.bl + dh, undefined, self.charWidths.slice(begin, end), angle);
|
||||
} else {
|
||||
for (i = b = begin, x_ = x1; i < end; ++i) {
|
||||
cp = self.charProps[i];
|
||||
if (cp && cp.wrd && i > b) {
|
||||
ctx.fillText(self.chars.slice(b, i), x_, y1 + l.bl + dh, undefined, self.charWidths.slice(b, i), angle);
|
||||
x_ += self._calcCharsWidth(b, i - 1) + dx;
|
||||
dw += dx;
|
||||
b = i;
|
||||
}
|
||||
}
|
||||
if (i > b) {
|
||||
ctx.fillText(self.chars.slice(b, i), x_, y1 + l.bl + dh, undefined, self.charWidths.slice(b, i), angle);
|
||||
}
|
||||
}
|
||||
if (isSO || isUL) {
|
||||
x2 = asc_calcnpt(x1 + dw, ppix);
|
||||
fsz = prop.font.FontSize * self.ratio;
|
||||
lw = asc_round(fsz * ppiy / 72 / 18) || 1;
|
||||
ctx.setStrokeStyle(prop.c || textColor).setLineWidth(lw).beginPath();
|
||||
w_1px = asc_calcnpt(0, ppix, 1);
|
||||
h_1px = asc_calcnpt(0, ppiy, 1);
|
||||
dy = (lw / 2);
|
||||
dy = dy >> 0;
|
||||
if (isSO) {
|
||||
dy += 1;
|
||||
y = asc_calcnpt(y1 + l.bl - prop.lm.a * 0.275, ppiy);
|
||||
ctx.lineHor(x1, y - dy * h_1px, x2 + w_1px);
|
||||
}
|
||||
if (isUL) {
|
||||
y = asc_calcnpt(y1 + l.bl + prop.lm.d * 0.4, ppiy);
|
||||
ctx.lineHor(x1, y + dy * h_1px, x2 + w_1px);
|
||||
}
|
||||
ctx.stroke();
|
||||
}
|
||||
return dw;
|
||||
}
|
||||
for (i = 0, strBeg = 0, f_ = ctx.getFont(); i < this.chars.length; ++i) {
|
||||
p = this.charProps[i];
|
||||
if (p && (p.font || p.nl || p.hp || p.skip > 0)) {
|
||||
if (strBeg < i) {
|
||||
x1 += renderFragment(strBeg, i, p_, this.angle);
|
||||
strBeg = i;
|
||||
}
|
||||
if (p.font) {
|
||||
f = p.font.clone();
|
||||
if (shrink) {
|
||||
f.FontSize *= this.ratio;
|
||||
}
|
||||
if (!f.isEqual(f_) || this.fontNeedUpdate) {
|
||||
ctx.setFont(f, this.angle);
|
||||
f_ = f;
|
||||
this.fontNeedUpdate = false;
|
||||
}
|
||||
var fillStyle;
|
||||
if (null != p.c && null != p.c.getRgb) {
|
||||
fillStyle = p.c.getRgb();
|
||||
} else {
|
||||
fillStyle = p.c || textColor;
|
||||
}
|
||||
ctx.setFillStyle(fillStyle);
|
||||
p_ = p;
|
||||
}
|
||||
if (p.skip > 0) {
|
||||
j = i + p.skip - 1;
|
||||
x1 += this._calcCharsWidth(i, j);
|
||||
strBeg = j + 1;
|
||||
i = j;
|
||||
continue;
|
||||
}
|
||||
if (p.nl || p.hp) {
|
||||
y1 += l.th;
|
||||
l = self.lines[++n];
|
||||
x1 = initX(i);
|
||||
dx = computeWordDeltaX();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (strBeg < i) {
|
||||
renderFragment(strBeg, i, p_, this.angle);
|
||||
}
|
||||
},
|
||||
getInternalState: function () {
|
||||
return {
|
||||
defaultFont: this.defaultFont !== undefined ? this.defaultFont.clone() : undefined,
|
||||
flags: this.flags,
|
||||
chars: this.chars,
|
||||
charWidths: this.charWidths,
|
||||
charProps: this.charProps,
|
||||
lines: this.lines,
|
||||
ratio: this.ratio
|
||||
};
|
||||
},
|
||||
restoreInternalState: function (state) {
|
||||
this.defaultFont = state.defaultFont;
|
||||
this.flags = state.flags;
|
||||
this.chars = state.chars;
|
||||
this.charWidths = state.charWidths;
|
||||
this.charProps = state.charProps;
|
||||
this.lines = state.lines;
|
||||
this.ratio = state.ratio;
|
||||
return this;
|
||||
}
|
||||
};
|
||||
window["Asc"].StringRender = StringRender;
|
||||
})(window);
|
||||
1598
OfficeWeb/sdk/Excel/view/WorkbookView.js
Normal file
1598
OfficeWeb/sdk/Excel/view/WorkbookView.js
Normal file
File diff suppressed because it is too large
Load Diff
8283
OfficeWeb/sdk/Excel/view/WorksheetView.js
Normal file
8283
OfficeWeb/sdk/Excel/view/WorksheetView.js
Normal file
File diff suppressed because it is too large
Load Diff
1161
OfficeWeb/sdk/Excel/view/iscroll.js
Normal file
1161
OfficeWeb/sdk/Excel/view/iscroll.js
Normal file
File diff suppressed because it is too large
Load Diff
906
OfficeWeb/sdk/Excel/view/mobileTouch.js
Normal file
906
OfficeWeb/sdk/Excel/view/mobileTouch.js
Normal file
@@ -0,0 +1,906 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
"use strict";
|
||||
function CMobileTouchManager() {
|
||||
this.AnimateScroll = false;
|
||||
this.AnimateZoom = false;
|
||||
this.bIsTextSelected = false;
|
||||
this.bIsTextSelecting = false;
|
||||
this.LogicDocument = null;
|
||||
this.DrawingDocument = null;
|
||||
this.HtmlPage = null;
|
||||
this.Mode = 0;
|
||||
this.ReadingGlassTime = 750;
|
||||
this.TimeDown = 0;
|
||||
this.DownPoint = null;
|
||||
this.DownPointOriginal = {
|
||||
X: 0,
|
||||
Y: 0
|
||||
};
|
||||
this.MoveAfterDown = false;
|
||||
this.MoveMinDist = 10;
|
||||
this.RectSelect1 = null;
|
||||
this.RectSelect2 = null;
|
||||
this.PageSelect1 = 0;
|
||||
this.PageSelect2 = 0;
|
||||
this.CheckFirstRect = true;
|
||||
this.TrackTargetEps = 20;
|
||||
this.ScrollH = 0;
|
||||
this.ScrollV = 0;
|
||||
this.ZoomDistance = 0;
|
||||
this.ZoomValue = 100;
|
||||
this.ZoomValueMin = 50;
|
||||
this.ZoomValueMax = 300;
|
||||
this.iScroll = null;
|
||||
this.ctrl = null;
|
||||
this.TableMovePoint = null;
|
||||
this.TableHorRulerPoints = null;
|
||||
this.TableVerRulerPoints = null;
|
||||
this.TableStartTrack_Check = false;
|
||||
this.TableRulersRectOffset = 5;
|
||||
this.TableRulersRectSize = 20;
|
||||
this.TableCurrentMoveDir = -1;
|
||||
this.TableCurrentMovePos = -1;
|
||||
this.TableCurrentMoveValue = 0;
|
||||
this.TableCurrentMoveValueOld = 0;
|
||||
this.TableCurrentMoveValueMin = null;
|
||||
this.TableCurrentMoveValueMax = null;
|
||||
this.ShowMenuTimerId = -1;
|
||||
this.wasMove = false;
|
||||
}
|
||||
CMobileTouchManager.prototype = {
|
||||
Init: function (ctrl) {
|
||||
this.ctrl = ctrl;
|
||||
this.iScroll = new window.CTouchScroll(ctrl, {
|
||||
hScrollbar: true,
|
||||
vScrollbar: true,
|
||||
momentum: false
|
||||
});
|
||||
},
|
||||
MoveCursorToPoint: function (e) {
|
||||
check_MouseMoveEvent(e);
|
||||
var pos = this.DrawingDocument.ConvertCoordsFromCursor2(global_mouseEvent.X, global_mouseEvent.Y);
|
||||
var old_click_count = global_mouseEvent.ClickCount;
|
||||
global_mouseEvent.ClickCount = 1;
|
||||
var nearPos = this.LogicDocument.Get_NearestPos(pos.Page, pos.X, pos.Y);
|
||||
this.DrawingDocument.NeedScrollToTargetFlag = true;
|
||||
this.LogicDocument.OnMouseDown(global_mouseEvent, nearPos.X, nearPos.Y, pos.Page);
|
||||
this.LogicDocument.OnMouseUp(global_mouseEvent, nearPos.X, nearPos.Y, pos.Page);
|
||||
this.DrawingDocument.NeedScrollToTargetFlag = false;
|
||||
global_mouseEvent.ClickCount = old_click_count;
|
||||
},
|
||||
onTouchStart: function (e) {
|
||||
var point = arguments[0].touches ? arguments[0].touches[0] : arguments[0];
|
||||
this.DownPointOriginal.X = point.clientX;
|
||||
this.DownPointOriginal.Y = point.clientY;
|
||||
this.wasMove = false;
|
||||
this.iScroll._start(e);
|
||||
e.preventDefault();
|
||||
e.returnValue = false;
|
||||
return false;
|
||||
},
|
||||
onTouchMove: function (e) {
|
||||
this.wasMove = true;
|
||||
this.iScroll._move(e);
|
||||
e.preventDefault();
|
||||
e.returnValue = false;
|
||||
return false;
|
||||
},
|
||||
onTouchEnd: function (e) {
|
||||
this.iScroll._end(e);
|
||||
var point = e.changedTouches ? e.changedTouches[0] : e;
|
||||
if (Math.abs(this.DownPointOriginal.X - point.clientX) < this.ctrl.controller.settings.hscrollStep && Math.abs(this.DownPointOriginal.Y - point.clientY) < this.ctrl.controller.settings.vscrollStep) {
|
||||
this.ctrl.handlers.trigger("asc_onTapEvent", e);
|
||||
}
|
||||
this.wasMove = false;
|
||||
e.preventDefault();
|
||||
e.returnValue = false;
|
||||
return;
|
||||
},
|
||||
onTouchStart_renderer: function (e) {
|
||||
check_MouseDownEvent(e.touches ? e.touches[0] : e, true);
|
||||
global_mouseEvent.LockMouse();
|
||||
this.ScrollH = this.HtmlPage.m_dScrollX;
|
||||
this.ScrollV = this.HtmlPage.m_dScrollY;
|
||||
this.MoveAfterDown = false;
|
||||
if (e.touches && 2 == e.touches.length) {
|
||||
this.Mode = MobileTouchMode.Zoom;
|
||||
}
|
||||
switch (this.Mode) {
|
||||
case MobileTouchMode.None:
|
||||
this.Mode = MobileTouchMode.Scroll;
|
||||
this.DownPoint = this.DrawingDocument.ConvertCoordsFromCursor2(global_mouseEvent.X, global_mouseEvent.Y);
|
||||
this.DownPointOriginal.X = global_mouseEvent.X;
|
||||
this.DownPointOriginal.Y = global_mouseEvent.Y;
|
||||
this.iScroll._start(e);
|
||||
break;
|
||||
case MobileTouchMode.Scroll:
|
||||
this.DownPoint = this.DrawingDocument.ConvertCoordsFromCursor2(global_mouseEvent.X, global_mouseEvent.Y);
|
||||
this.DownPointOriginal.X = global_mouseEvent.X;
|
||||
this.DownPointOriginal.Y = global_mouseEvent.Y;
|
||||
this.iScroll._start(e);
|
||||
break;
|
||||
case MobileTouchMode.Zoom:
|
||||
this.HtmlPage.NoneRepaintPages = true;
|
||||
var _x1 = (e.touches[0].pageX !== undefined) ? e.touches[0].pageX : e.touches[0].clientX;
|
||||
var _y1 = (e.touches[0].pageY !== undefined) ? e.touches[0].pageY : e.touches[0].clientY;
|
||||
var _x2 = (e.touches[1].pageX !== undefined) ? e.touches[1].pageX : e.touches[1].clientX;
|
||||
var _y2 = (e.touches[1].pageY !== undefined) ? e.touches[1].pageY : e.touches[1].clientY;
|
||||
this.ZoomDistance = Math.sqrt((_x1 - _x2) * (_x1 - _x2) + (_y1 - _y2) * (_y1 - _y2));
|
||||
this.ZoomValue = this.HtmlPage.m_nZoomValue;
|
||||
break;
|
||||
}
|
||||
if (e.preventDefault) {
|
||||
e.preventDefault();
|
||||
} else {
|
||||
e.returnValue = false;
|
||||
}
|
||||
},
|
||||
onTouchMove_renderer: function (e) {
|
||||
check_MouseMoveEvent(e.touches ? e.touches[0] : e);
|
||||
if (!this.MoveAfterDown) {
|
||||
if (Math.abs(this.DownPointOriginal.X - global_mouseEvent.X) > this.MoveMinDist || Math.abs(this.DownPointOriginal.Y - global_mouseEvent.Y) > this.MoveMinDist) {
|
||||
this.MoveAfterDown = true;
|
||||
}
|
||||
}
|
||||
switch (this.Mode) {
|
||||
case MobileTouchMode.Scroll:
|
||||
var _offsetX = global_mouseEvent.X - this.DownPointOriginal.X;
|
||||
var _offsetY = global_mouseEvent.Y - this.DownPointOriginal.Y;
|
||||
this.iScroll._move(e);
|
||||
break;
|
||||
case MobileTouchMode.Zoom:
|
||||
if (2 != e.touches.length) {
|
||||
this.Mode = MobileTouchMode.None;
|
||||
return;
|
||||
}
|
||||
var _x1 = (e.touches[0].pageX !== undefined) ? e.touches[0].pageX : e.touches[0].clientX;
|
||||
var _y1 = (e.touches[0].pageY !== undefined) ? e.touches[0].pageY : e.touches[0].clientY;
|
||||
var _x2 = (e.touches[1].pageX !== undefined) ? e.touches[1].pageX : e.touches[1].clientX;
|
||||
var _y2 = (e.touches[1].pageY !== undefined) ? e.touches[1].pageY : e.touches[1].clientY;
|
||||
var zoomCurrentDist = Math.sqrt((_x1 - _x2) * (_x1 - _x2) + (_y1 - _y2) * (_y1 - _y2));
|
||||
if (zoomCurrentDist == 0) {
|
||||
zoomCurrentDist = 1;
|
||||
}
|
||||
var _zoomFix = this.ZoomValue / 100;
|
||||
var _zoomCur = _zoomFix * (zoomCurrentDist / this.ZoomDistance);
|
||||
_zoomCur = (_zoomCur * 100) >> 0;
|
||||
if (_zoomCur < this.ZoomValueMin) {
|
||||
_zoomCur = this.ZoomValueMin;
|
||||
} else {
|
||||
if (_zoomCur > this.ZoomValueMax) {
|
||||
_zoomCur = this.ZoomValueMax;
|
||||
}
|
||||
}
|
||||
this.HtmlPage.m_oApi.zoom(_zoomCur);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (e.preventDefault) {
|
||||
e.preventDefault();
|
||||
} else {
|
||||
e.returnValue = false;
|
||||
}
|
||||
},
|
||||
onTouchEnd_renderer: function (e) {
|
||||
check_MouseUpEvent(e.changedTouches ? e.changedTouches[0] : e);
|
||||
this.ScrollH = this.HtmlPage.m_dScrollX;
|
||||
this.ScrollV = this.HtmlPage.m_dScrollY;
|
||||
switch (this.Mode) {
|
||||
case MobileTouchMode.Scroll:
|
||||
this.iScroll._end(e);
|
||||
this.Mode = MobileTouchMode.None;
|
||||
if (!this.MoveAfterDown) {
|
||||
this.HtmlPage.m_oApi.asc_fireCallback("asc_onTapEvent", e);
|
||||
}
|
||||
break;
|
||||
case MobileTouchMode.Zoom:
|
||||
this.HtmlPage.NoneRepaintPages = false;
|
||||
this.HtmlPage.m_bIsFullRepaint = true;
|
||||
this.HtmlPage.OnScroll();
|
||||
this.Mode = MobileTouchMode.None;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
this.iScroll._scrollbar("h");
|
||||
this.iScroll._scrollbar("v");
|
||||
if (e.preventDefault) {
|
||||
e.preventDefault();
|
||||
} else {
|
||||
e.returnValue = false;
|
||||
}
|
||||
},
|
||||
CheckSelectEnd: function (bIsAttack) {
|
||||
var _bIsRet = false;
|
||||
if (!bIsAttack) {
|
||||
_bIsRet = this.IsTrackingCurrent;
|
||||
}
|
||||
if (_bIsRet) {
|
||||
return;
|
||||
}
|
||||
if (null != this.RectSelect1 && null != this.RectSelect2 && !this.HtmlPage.m_oApi.isViewMode) {
|
||||
var _matrix = this.DrawingDocument.TextMatrix;
|
||||
var pos1 = null;
|
||||
var pos4 = null;
|
||||
if (!_matrix || global_MatrixTransformer.IsIdentity(_matrix)) {
|
||||
pos1 = this.DrawingDocument.ConvertCoordsToCursorWR(this.RectSelect1.x, this.RectSelect1.y, this.PageSelect1);
|
||||
pos4 = this.DrawingDocument.ConvertCoordsToCursorWR(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y + this.RectSelect2.h, this.PageSelect2);
|
||||
} else {
|
||||
var _x1 = _matrix.TransformPointX(this.RectSelect1.x, this.RectSelect1.y);
|
||||
var _y1 = _matrix.TransformPointY(this.RectSelect1.x, this.RectSelect1.y);
|
||||
var _x2 = _matrix.TransformPointX(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y + this.RectSelect2.h);
|
||||
var _y2 = _matrix.TransformPointY(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y + this.RectSelect2.h);
|
||||
pos1 = this.DrawingDocument.ConvertCoordsToCursorWR(_x1, _y1, this.PageSelect1);
|
||||
pos4 = this.DrawingDocument.ConvertCoordsToCursorWR(_x2, _y2, this.PageSelect2);
|
||||
}
|
||||
var _x = (pos1.X + pos4.X) >> 1;
|
||||
var _y = pos1.Y;
|
||||
if (!this.iScroll.animating) {
|
||||
this.SendShowMenu(_x, _y);
|
||||
}
|
||||
}
|
||||
},
|
||||
CheckZoomCriticalValues: function (zoomMin) {
|
||||
if (zoomMin !== undefined) {
|
||||
this.ZoomValueMin = zoomMin;
|
||||
return;
|
||||
}
|
||||
var w = this.HtmlPage.m_oEditor.AbsolutePosition.R - this.HtmlPage.m_oEditor.AbsolutePosition.L;
|
||||
var Zoom = 100;
|
||||
if (0 != this.HtmlPage.m_dDocumentPageWidth) {
|
||||
Zoom = 100 * (w - 10) / this.HtmlPage.m_dDocumentPageWidth;
|
||||
if (Zoom < 5) {
|
||||
Zoom = 5;
|
||||
}
|
||||
if (this.HtmlPage.m_oApi.isMobileVersion) {
|
||||
var _w = this.HtmlPage.m_oEditor.HtmlElement.width;
|
||||
if (this.bIsRetinaSupport) {
|
||||
_w >>= 1;
|
||||
}
|
||||
Zoom = 100 * _w * g_dKoef_pix_to_mm / this.HtmlPage.m_dDocumentPageWidth;
|
||||
}
|
||||
}
|
||||
var _new_value = (Zoom - 0.5) >> 0;
|
||||
this.ZoomValueMin = _new_value;
|
||||
if (this.ZoomValue < this.ZoomValueMin) {
|
||||
this.ZoomValue = this.ZoomValueMin;
|
||||
this.HtmlPage.m_oApi.zoom(this.ZoomValue);
|
||||
}
|
||||
},
|
||||
Resize: function () {
|
||||
if (this.iScroll != null) {
|
||||
this.iScroll.refresh(true);
|
||||
}
|
||||
},
|
||||
SendShowMenu: function (x, y) {
|
||||
if (-1 != this.ShowMenuTimerId) {
|
||||
clearTimeout(this.ShowMenuTimerId);
|
||||
}
|
||||
var that = this;
|
||||
that.ShowMenuTimerId = setTimeout(function () {
|
||||
that.HtmlPage.m_oApi.asc_fireCallback("asc_onShowPopMenu", x, y);
|
||||
},
|
||||
500);
|
||||
},
|
||||
OnScrollAnimationEnd: function () {
|
||||
if (this.HtmlPage.m_oApi.isViewMode) {
|
||||
return;
|
||||
}
|
||||
if (null != this.RectSelect1 && null != this.RectSelect2) {
|
||||
var pos1 = null;
|
||||
var pos4 = null;
|
||||
var _matrix = this.DrawingDocument.TextMatrix;
|
||||
if (!_matrix || global_MatrixTransformer.IsIdentity(_matrix)) {
|
||||
pos1 = this.DrawingDocument.ConvertCoordsToCursorWR(this.RectSelect1.x, this.RectSelect1.y, this.PageSelect1);
|
||||
pos4 = this.DrawingDocument.ConvertCoordsToCursorWR(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y + this.RectSelect2.h, this.PageSelect2);
|
||||
} else {
|
||||
var _x1 = _matrix.TransformPointX(this.RectSelect1.x, this.RectSelect1.y);
|
||||
var _y1 = _matrix.TransformPointY(this.RectSelect1.x, this.RectSelect1.y);
|
||||
var _x2 = _matrix.TransformPointX(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y + this.RectSelect2.h);
|
||||
var _y2 = _matrix.TransformPointY(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y + this.RectSelect2.h);
|
||||
pos1 = this.DrawingDocument.ConvertCoordsToCursorWR(_x1, _y1, this.PageSelect1);
|
||||
pos4 = this.DrawingDocument.ConvertCoordsToCursorWR(_x2, _y2, this.PageSelect2);
|
||||
}
|
||||
var _x = (pos1.X + pos4.X) >> 1;
|
||||
var _y = pos1.Y;
|
||||
this.SendShowMenu(_x, _y);
|
||||
}
|
||||
},
|
||||
CheckSelect: function (overlay) {
|
||||
if (null == this.RectSelect1 || null == this.RectSelect2) {
|
||||
return;
|
||||
}
|
||||
var _matrix = this.DrawingDocument.TextMatrix;
|
||||
if (!_matrix || global_MatrixTransformer.IsIdentity(_matrix)) {
|
||||
var pos1 = this.DrawingDocument.ConvertCoordsToCursorWR(this.RectSelect1.x, this.RectSelect1.y, this.PageSelect1);
|
||||
var pos2 = this.DrawingDocument.ConvertCoordsToCursorWR(this.RectSelect1.x, this.RectSelect1.y + this.RectSelect1.h, this.PageSelect1);
|
||||
var pos3 = this.DrawingDocument.ConvertCoordsToCursorWR(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y, this.PageSelect2);
|
||||
var pos4 = this.DrawingDocument.ConvertCoordsToCursorWR(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y + this.RectSelect2.h, this.PageSelect2);
|
||||
var ctx = overlay.m_oContext;
|
||||
ctx.strokeStyle = "#1B63BA";
|
||||
ctx.moveTo(pos1.X >> 0, pos1.Y >> 0);
|
||||
ctx.lineTo(pos2.X >> 0, pos2.Y >> 0);
|
||||
ctx.moveTo(pos3.X >> 0, pos3.Y >> 0);
|
||||
ctx.lineTo(pos4.X >> 0, pos4.Y >> 0);
|
||||
ctx.lineWidth = 2;
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
ctx.fillStyle = "rgba(0, 0, 0, 0.5)";
|
||||
overlay.AddEllipse(pos1.X, pos1.Y - 5, 6.5);
|
||||
overlay.AddEllipse(pos4.X, pos4.Y + 5, 6.5);
|
||||
ctx.fill();
|
||||
ctx.beginPath();
|
||||
ctx.fillStyle = "#FFFFFF";
|
||||
overlay.AddEllipse(pos1.X, pos1.Y - 5, 6);
|
||||
overlay.AddEllipse(pos4.X, pos4.Y + 5, 6);
|
||||
ctx.fill();
|
||||
ctx.beginPath();
|
||||
ctx.fillStyle = "#1B63BA";
|
||||
overlay.AddEllipse(pos1.X, pos1.Y - 5, 5);
|
||||
overlay.AddEllipse(pos4.X, pos4.Y + 5, 5);
|
||||
ctx.fill();
|
||||
} else {
|
||||
var _xx11 = _matrix.TransformPointX(this.RectSelect1.x, this.RectSelect1.y);
|
||||
var _yy11 = _matrix.TransformPointY(this.RectSelect1.x, this.RectSelect1.y);
|
||||
var _xx12 = _matrix.TransformPointX(this.RectSelect1.x, this.RectSelect1.y + this.RectSelect1.h);
|
||||
var _yy12 = _matrix.TransformPointY(this.RectSelect1.x, this.RectSelect1.y + this.RectSelect1.h);
|
||||
var _xx21 = _matrix.TransformPointX(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y);
|
||||
var _yy21 = _matrix.TransformPointY(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y);
|
||||
var _xx22 = _matrix.TransformPointX(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y + this.RectSelect2.h);
|
||||
var _yy22 = _matrix.TransformPointY(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y + this.RectSelect2.h);
|
||||
var pos1 = this.DrawingDocument.ConvertCoordsToCursorWR(_xx11, _yy11, this.PageSelect1);
|
||||
var pos2 = this.DrawingDocument.ConvertCoordsToCursorWR(_xx12, _yy12, this.PageSelect1);
|
||||
var pos3 = this.DrawingDocument.ConvertCoordsToCursorWR(_xx21, _yy21, this.PageSelect2);
|
||||
var pos4 = this.DrawingDocument.ConvertCoordsToCursorWR(_xx22, _yy22, this.PageSelect2);
|
||||
var ctx = overlay.m_oContext;
|
||||
ctx.strokeStyle = "#1B63BA";
|
||||
ctx.moveTo(pos1.X, pos1.Y);
|
||||
ctx.lineTo(pos2.X, pos2.Y);
|
||||
ctx.moveTo(pos3.X, pos3.Y);
|
||||
ctx.lineTo(pos4.X, pos4.Y);
|
||||
ctx.lineWidth = 2;
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
ctx.fillStyle = "rgba(0, 0, 0, 0.5)";
|
||||
overlay.AddEllipse(pos1.X, pos1.Y - 5, 6.5);
|
||||
overlay.AddEllipse(pos4.X, pos4.Y + 5, 6.5);
|
||||
ctx.fill();
|
||||
ctx.beginPath();
|
||||
ctx.fillStyle = "#FFFFFF";
|
||||
overlay.AddEllipse(pos1.X, pos1.Y - 5, 6);
|
||||
overlay.AddEllipse(pos4.X, pos4.Y + 5, 6);
|
||||
ctx.fill();
|
||||
ctx.beginPath();
|
||||
ctx.fillStyle = "#1B63BA";
|
||||
overlay.AddEllipse(pos1.X, pos1.Y - 5, 5);
|
||||
overlay.AddEllipse(pos4.X, pos4.Y + 5, 5);
|
||||
ctx.fill();
|
||||
}
|
||||
},
|
||||
CheckSelect2: function (overlay) {
|
||||
if (null == this.RectSelect1 || null == this.RectSelect2) {
|
||||
return;
|
||||
}
|
||||
var _matrix = this.DrawingDocument.TextMatrix;
|
||||
if (!_matrix || global_MatrixTransformer.IsIdentity(_matrix)) {
|
||||
var pos1 = this.DrawingDocument.ConvertCoordsToCursorWR(this.RectSelect1.x, this.RectSelect1.y, this.PageSelect1);
|
||||
var pos2 = this.DrawingDocument.ConvertCoordsToCursorWR(this.RectSelect1.x, this.RectSelect1.y + this.RectSelect1.h, this.PageSelect1);
|
||||
var pos3 = this.DrawingDocument.ConvertCoordsToCursorWR(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y, this.PageSelect2);
|
||||
var pos4 = this.DrawingDocument.ConvertCoordsToCursorWR(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y + this.RectSelect2.h, this.PageSelect2);
|
||||
var ctx = overlay.m_oContext;
|
||||
ctx.strokeStyle = "#1B63BA";
|
||||
ctx.moveTo(pos1.X >> 0, pos1.Y >> 0);
|
||||
ctx.lineTo(pos2.X >> 0, pos2.Y >> 0);
|
||||
ctx.moveTo(pos3.X >> 0, pos3.Y >> 0);
|
||||
ctx.lineTo(pos4.X >> 0, pos4.Y >> 0);
|
||||
ctx.lineWidth = 2;
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
if (!window.g_table_track_round.asc_complete) {
|
||||
return;
|
||||
}
|
||||
var _w = window.g_table_track_round.width;
|
||||
var _h = window.g_table_track_round.height;
|
||||
var _x1 = (pos1.X - (_w / 2)) >> 0;
|
||||
var _y1 = (pos1.Y - 5 - (_h / 2)) >> 0;
|
||||
var _x2 = (pos4.X - (_w / 2)) >> 0;
|
||||
var _y2 = (pos4.Y + 5 - (_h / 2)) >> 0;
|
||||
ctx.drawImage(window.g_table_track_round, _x1, _y1);
|
||||
ctx.drawImage(window.g_table_track_round, _x2, _y2);
|
||||
overlay.CheckRect(_x1, _y1, _w, _h);
|
||||
overlay.CheckRect(_x2, _y2, _w, _h);
|
||||
} else {
|
||||
var _xx11 = _matrix.TransformPointX(this.RectSelect1.x, this.RectSelect1.y);
|
||||
var _yy11 = _matrix.TransformPointY(this.RectSelect1.x, this.RectSelect1.y);
|
||||
var _xx12 = _matrix.TransformPointX(this.RectSelect1.x, this.RectSelect1.y + this.RectSelect1.h);
|
||||
var _yy12 = _matrix.TransformPointY(this.RectSelect1.x, this.RectSelect1.y + this.RectSelect1.h);
|
||||
var _xx21 = _matrix.TransformPointX(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y);
|
||||
var _yy21 = _matrix.TransformPointY(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y);
|
||||
var _xx22 = _matrix.TransformPointX(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y + this.RectSelect2.h);
|
||||
var _yy22 = _matrix.TransformPointY(this.RectSelect2.x + this.RectSelect2.w, this.RectSelect2.y + this.RectSelect2.h);
|
||||
var pos1 = this.DrawingDocument.ConvertCoordsToCursorWR(_xx11, _yy11, this.PageSelect1);
|
||||
var pos2 = this.DrawingDocument.ConvertCoordsToCursorWR(_xx12, _yy12, this.PageSelect1);
|
||||
var pos3 = this.DrawingDocument.ConvertCoordsToCursorWR(_xx21, _yy21, this.PageSelect2);
|
||||
var pos4 = this.DrawingDocument.ConvertCoordsToCursorWR(_xx22, _yy22, this.PageSelect2);
|
||||
var ctx = overlay.m_oContext;
|
||||
ctx.strokeStyle = "#1B63BA";
|
||||
ctx.moveTo(pos1.X, pos1.Y);
|
||||
ctx.lineTo(pos2.X, pos2.Y);
|
||||
ctx.moveTo(pos3.X, pos3.Y);
|
||||
ctx.lineTo(pos4.X, pos4.Y);
|
||||
ctx.lineWidth = 2;
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
if (!window.g_table_track_round.asc_complete) {
|
||||
return;
|
||||
}
|
||||
var ex01 = _matrix.TransformPointX(0, 0);
|
||||
var ey01 = _matrix.TransformPointY(0, 0);
|
||||
var ex11 = _matrix.TransformPointX(0, 1);
|
||||
var ey11 = _matrix.TransformPointY(0, 1);
|
||||
var _len = Math.sqrt((ex11 - ex01) * (ex11 - ex01) + (ey11 - ey01) * (ey11 - ey01));
|
||||
if (_len == 0) {
|
||||
_len = 0.01;
|
||||
}
|
||||
var ex = 5 * (ex11 - ex01) / _len;
|
||||
var ey = 5 * (ey11 - ey01) / _len;
|
||||
var _w = window.g_table_track_round.width;
|
||||
var _h = window.g_table_track_round.height;
|
||||
var _x1 = (pos1.X - ex - (_w / 2)) >> 0;
|
||||
var _y1 = (pos1.Y - ey - (_h / 2)) >> 0;
|
||||
var _x2 = (pos4.X + ex - (_w / 2)) >> 0;
|
||||
var _y2 = (pos4.Y + ey - (_h / 2)) >> 0;
|
||||
ctx.drawImage(window.g_table_track_round, _x1, _y1);
|
||||
ctx.drawImage(window.g_table_track_round, _x2, _y2);
|
||||
overlay.CheckRect(_x1, _y1, _w, _h);
|
||||
overlay.CheckRect(_x2, _y2, _w, _h);
|
||||
}
|
||||
},
|
||||
CheckTableRules: function (overlay) {
|
||||
if (this.HtmlPage.m_oApi.isViewMode) {
|
||||
return;
|
||||
}
|
||||
var horRuler = this.HtmlPage.m_oHorRuler;
|
||||
var verRuler = this.HtmlPage.m_oVerRuler;
|
||||
var _table_outline_dr = this.DrawingDocument.TableOutlineDr;
|
||||
var _tableOutline = _table_outline_dr.TableOutline;
|
||||
if (horRuler.CurrentObjectType != RULER_OBJECT_TYPE_TABLE || verRuler.CurrentObjectType != RULER_OBJECT_TYPE_TABLE || !_tableOutline) {
|
||||
this.TableMovePoint = null;
|
||||
this.TableHorRulerPoints = null;
|
||||
this.TableVerRulerPoints = null;
|
||||
return;
|
||||
}
|
||||
var _table_markup = horRuler.m_oTableMarkup;
|
||||
this.HtmlPage.CheckShowOverlay();
|
||||
var _epsRects = this.TableRulersRectOffset;
|
||||
var _rectWidth = this.TableRulersRectSize;
|
||||
var ctx = overlay.m_oContext;
|
||||
ctx.fillStyle = "#F0F0F0";
|
||||
ctx.strokeStyle = "#000000";
|
||||
ctx.lineWidth = 1;
|
||||
var _tableW = 0;
|
||||
var _cols = _table_markup.Cols;
|
||||
for (var i = 0; i < _cols.length; i++) {
|
||||
_tableW += _cols[i];
|
||||
}
|
||||
if (!_table_outline_dr.TableMatrix || global_MatrixTransformer.IsIdentity(_table_outline_dr.TableMatrix)) {
|
||||
this.TableMovePoint = {
|
||||
X: _tableOutline.X,
|
||||
Y: _tableOutline.Y
|
||||
};
|
||||
var pos1 = this.DrawingDocument.ConvertCoordsToCursorWR(_tableOutline.X, _tableOutline.Y, _tableOutline.PageNum);
|
||||
var pos2 = this.DrawingDocument.ConvertCoordsToCursorWR(_tableOutline.X + _tableW, _tableOutline.Y, _tableOutline.PageNum);
|
||||
ctx.beginPath();
|
||||
var TableMoveRect_x = (pos1.X >> 0) + 0.5 - (_epsRects + _rectWidth);
|
||||
var TableMoveRect_y = (pos1.Y >> 0) + 0.5 - (_epsRects + _rectWidth);
|
||||
overlay.AddRect(TableMoveRect_x, TableMoveRect_y, _rectWidth, _rectWidth);
|
||||
overlay.AddRect((pos1.X >> 0) + 0.5, TableMoveRect_y, (pos2.X - pos1.X) >> 0, _rectWidth);
|
||||
var _count = _table_markup.Rows.length;
|
||||
var _y1 = 0;
|
||||
var _y2 = 0;
|
||||
for (var i = 0; i < _count; i++) {
|
||||
if (i == 0) {
|
||||
_y1 = _table_markup.Rows[i].Y;
|
||||
}
|
||||
_y2 = _table_markup.Rows[i].Y;
|
||||
_y2 += _table_markup.Rows[i].H;
|
||||
}
|
||||
var pos3 = this.DrawingDocument.ConvertCoordsToCursorWR(_tableOutline.X, _y1, this.DrawingDocument.m_lCurrentPage);
|
||||
var pos4 = this.DrawingDocument.ConvertCoordsToCursorWR(_tableOutline.X, _y2, this.DrawingDocument.m_lCurrentPage);
|
||||
overlay.AddRect((pos1.X >> 0) + 0.5 - (_epsRects + _rectWidth), (pos3.Y >> 0) + 0.5, _rectWidth, (pos4.Y - pos3.Y) >> 0);
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
ctx.fillStyle = "#FFFFFF";
|
||||
ctx.strokeStyle = "#0000FF";
|
||||
var dKoef = (this.HtmlPage.m_nZoomValue * g_dKoef_mm_to_pix / 100);
|
||||
var xDst = this.DrawingDocument.m_arrPages[this.DrawingDocument.m_lCurrentPage].drawingPage.left;
|
||||
var yDst = this.DrawingDocument.m_arrPages[this.DrawingDocument.m_lCurrentPage].drawingPage.top;
|
||||
var _oldY = _table_markup.Rows[0].Y + _table_markup.Rows[0].H;
|
||||
this.TableVerRulerPoints = [];
|
||||
var _rectIndex = 0;
|
||||
var _x = (pos1.X >> 0) + 0.5 - (_epsRects + _rectWidth);
|
||||
for (var i = 1; i <= _count; i++) {
|
||||
var _newPos = (i != _count) ? _table_markup.Rows[i].Y : _oldY;
|
||||
var _p = {
|
||||
Y: _oldY,
|
||||
H: (_newPos - _oldY)
|
||||
};
|
||||
var _r_x = _x;
|
||||
var _r_y = ((yDst + dKoef * _oldY) >> 0) + 0.5;
|
||||
var _r_h = ((_newPos - _oldY) * dKoef) >> 0;
|
||||
overlay.AddRect(_r_x, _r_y, _rectWidth, _r_h);
|
||||
this.TableVerRulerPoints[_rectIndex++] = _p;
|
||||
if (i != _count) {
|
||||
_oldY = _table_markup.Rows[i].Y + _table_markup.Rows[i].H;
|
||||
}
|
||||
}
|
||||
this.TableHorRulerPoints = [];
|
||||
_rectIndex = 0;
|
||||
var _col = _table_markup.X;
|
||||
for (var i = 1; i <= _cols.length; i++) {
|
||||
_col += _cols[i - 1];
|
||||
var _x = _col - _table_markup.Margins[i - 1].Right;
|
||||
var _r = _col + ((i == _cols.length) ? 0 : _table_markup.Margins[i].Left);
|
||||
var __x = ((xDst + dKoef * _x) >> 0) + 0.5;
|
||||
var __r = ((xDst + dKoef * _r) >> 0) + 0.5;
|
||||
overlay.AddRect(__x, TableMoveRect_y, __r - __x, _rectWidth);
|
||||
this.TableHorRulerPoints[_rectIndex++] = {
|
||||
X: _x,
|
||||
W: _r - _x,
|
||||
C: _col
|
||||
};
|
||||
}
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
if (this.Mode == MobileTouchMode.TableRuler) {
|
||||
if (0 == this.TableCurrentMoveDir) {
|
||||
var _pos = this.DrawingDocument.ConvertCoordsToCursorWR(this.TableCurrentMoveValue, 0, _table_outline_dr.CurrentPageIndex);
|
||||
overlay.VertLine(_pos.X, true);
|
||||
} else {
|
||||
var _pos = this.DrawingDocument.ConvertCoordsToCursorWR(0, this.TableCurrentMoveValue, _table_outline_dr.CurrentPageIndex);
|
||||
overlay.HorLine(_pos.Y, true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var dKoef = (this.HtmlPage.m_nZoomValue * g_dKoef_mm_to_pix / 100);
|
||||
var xDst = this.DrawingDocument.m_arrPages[this.DrawingDocument.m_lCurrentPage].drawingPage.left;
|
||||
var yDst = this.DrawingDocument.m_arrPages[this.DrawingDocument.m_lCurrentPage].drawingPage.top;
|
||||
ctx.lineWidth = 1 / dKoef;
|
||||
var _coord_transform = new CMatrix();
|
||||
_coord_transform.sx = dKoef;
|
||||
_coord_transform.sy = dKoef;
|
||||
_coord_transform.tx = xDst;
|
||||
_coord_transform.ty = yDst;
|
||||
_coord_transform.Multiply(_table_outline_dr.TableMatrix, MATRIX_ORDER_PREPEND);
|
||||
ctx.setTransform(_coord_transform.sx, _coord_transform.shy, _coord_transform.shx, _coord_transform.sy, _coord_transform.tx, _coord_transform.ty);
|
||||
this.TableMovePoint = {
|
||||
X: _tableOutline.X,
|
||||
Y: _tableOutline.Y
|
||||
};
|
||||
ctx.beginPath();
|
||||
var _rectW = _rectWidth / dKoef;
|
||||
var _offset = (_epsRects + _rectWidth) / dKoef;
|
||||
ctx.rect(this.TableMovePoint.X - _offset, this.TableMovePoint.Y - _offset, _rectW, _rectW);
|
||||
ctx.rect(this.TableMovePoint.X, this.TableMovePoint.Y - _offset, _tableW, _rectW);
|
||||
var _count = _table_markup.Rows.length;
|
||||
var _y1 = 0;
|
||||
var _y2 = 0;
|
||||
for (var i = 0; i < _count; i++) {
|
||||
if (i == 0) {
|
||||
_y1 = _table_markup.Rows[i].Y;
|
||||
}
|
||||
_y2 = _table_markup.Rows[i].Y;
|
||||
_y2 += _table_markup.Rows[i].H;
|
||||
}
|
||||
ctx.rect(this.TableMovePoint.X - _offset, this.TableMovePoint.Y, _rectW, _y2 - _y1);
|
||||
overlay.CheckRectT(this.TableMovePoint.X, this.TableMovePoint.Y, _tableW, _y2 - _y1, _coord_transform, 2 * (_epsRects + _rectWidth));
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
ctx.fillStyle = "#FFFFFF";
|
||||
ctx.strokeStyle = "#0000FF";
|
||||
var _oldY = _table_markup.Rows[0].Y + _table_markup.Rows[0].H;
|
||||
_oldY -= _table_outline_dr.TableMatrix.ty;
|
||||
this.TableVerRulerPoints = [];
|
||||
var _rectIndex = 0;
|
||||
var _xx = this.TableMovePoint.X - _offset;
|
||||
for (var i = 1; i <= _count; i++) {
|
||||
var _newPos = (i != _count) ? (_table_markup.Rows[i].Y - _table_outline_dr.TableMatrix.ty) : _oldY;
|
||||
var _p = {
|
||||
Y: _oldY,
|
||||
H: (_newPos - _oldY)
|
||||
};
|
||||
ctx.rect(_xx, _p.Y, _rectW, _p.H);
|
||||
this.TableVerRulerPoints[_rectIndex++] = _p;
|
||||
if (i != _count) {
|
||||
_oldY = _table_markup.Rows[i].Y + _table_markup.Rows[i].H;
|
||||
_oldY -= _table_outline_dr.TableMatrix.ty;
|
||||
}
|
||||
}
|
||||
this.TableHorRulerPoints = [];
|
||||
_rectIndex = 0;
|
||||
var _col = this.TableMovePoint.X;
|
||||
for (var i = 1; i <= _cols.length; i++) {
|
||||
_col += _cols[i - 1];
|
||||
var _x = _col - _table_markup.Margins[i - 1].Right;
|
||||
var _r = _col + ((i == _cols.length) ? 0 : _table_markup.Margins[i].Left);
|
||||
ctx.rect(_x, this.TableMovePoint.Y - _offset, _r - _x, _rectW);
|
||||
this.TableHorRulerPoints[_rectIndex++] = {
|
||||
X: _x,
|
||||
W: _r - _x,
|
||||
C: _col
|
||||
};
|
||||
}
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
||||
ctx.beginPath();
|
||||
if (this.Mode == MobileTouchMode.TableRuler) {
|
||||
if (0 == this.TableCurrentMoveDir) {
|
||||
var _pos = this.DrawingDocument.ConvertCoordsToCursorWR(this.TableCurrentMoveValue, 0, _table_outline_dr.CurrentPageIndex, _table_outline_dr.TableMatrix);
|
||||
overlay.VertLine(_pos.X, true);
|
||||
} else {
|
||||
var _pos = this.DrawingDocument.ConvertCoordsToCursorWR(0, this.TableCurrentMoveValue, _table_outline_dr.CurrentPageIndex, _table_outline_dr.TableMatrix);
|
||||
overlay.HorLine(_pos.Y, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
CheckTableRules2: function (overlay) {
|
||||
if (this.HtmlPage.m_oApi.isViewMode) {
|
||||
return;
|
||||
}
|
||||
var horRuler = this.HtmlPage.m_oHorRuler;
|
||||
var verRuler = this.HtmlPage.m_oVerRuler;
|
||||
var _table_outline_dr = this.DrawingDocument.TableOutlineDr;
|
||||
var _tableOutline = _table_outline_dr.TableOutline;
|
||||
if (horRuler.CurrentObjectType != RULER_OBJECT_TYPE_TABLE || verRuler.CurrentObjectType != RULER_OBJECT_TYPE_TABLE || !_tableOutline) {
|
||||
this.TableMovePoint = null;
|
||||
this.TableHorRulerPoints = null;
|
||||
this.TableVerRulerPoints = null;
|
||||
return;
|
||||
}
|
||||
if (!window.g_table_track_mobile_move.asc_complete || !window.g_table_track_round.asc_complete || !window.g_table_track_diamond.asc_complete) {
|
||||
return;
|
||||
}
|
||||
var _table_markup = horRuler.m_oTableMarkup;
|
||||
this.HtmlPage.CheckShowOverlay();
|
||||
var _epsRects = this.TableRulersRectOffset;
|
||||
var _rectWidth = this.TableRulersRectSize;
|
||||
var ctx = overlay.m_oContext;
|
||||
ctx.strokeStyle = "#616161";
|
||||
ctx.lineWidth = 1;
|
||||
var _tableW = 0;
|
||||
var _cols = _table_markup.Cols;
|
||||
for (var i = 0; i < _cols.length; i++) {
|
||||
_tableW += _cols[i];
|
||||
}
|
||||
if (!_table_outline_dr.TableMatrix || global_MatrixTransformer.IsIdentity(_table_outline_dr.TableMatrix)) {
|
||||
this.TableMovePoint = {
|
||||
X: _tableOutline.X,
|
||||
Y: _tableOutline.Y
|
||||
};
|
||||
var pos1 = this.DrawingDocument.ConvertCoordsToCursorWR(_tableOutline.X, _tableOutline.Y, _tableOutline.PageNum);
|
||||
var pos2 = this.DrawingDocument.ConvertCoordsToCursorWR(_tableOutline.X + _tableW, _tableOutline.Y, _tableOutline.PageNum);
|
||||
ctx.beginPath();
|
||||
var TableMoveRect_x = (pos1.X >> 0) + 0.5 - (_epsRects + _rectWidth);
|
||||
var TableMoveRect_y = (pos1.Y >> 0) + 0.5 - (_epsRects + _rectWidth);
|
||||
overlay.CheckPoint(TableMoveRect_x, TableMoveRect_y);
|
||||
overlay.CheckPoint(TableMoveRect_x + _rectWidth, TableMoveRect_y + _rectWidth);
|
||||
ctx.drawImage(window.g_table_track_mobile_move, TableMoveRect_x, TableMoveRect_y);
|
||||
var gradObj = ctx.createLinearGradient((pos1.X >> 0) + 0.5, TableMoveRect_y, (pos1.X >> 0) + 0.5, TableMoveRect_y + _rectWidth);
|
||||
gradObj.addColorStop(0, "#f1f1f1");
|
||||
gradObj.addColorStop(1, "#dfdfdf");
|
||||
ctx.fillStyle = gradObj;
|
||||
overlay.AddRoundRect((pos1.X >> 0) + 0.5, TableMoveRect_y, (pos2.X - pos1.X) >> 0, _rectWidth, 4);
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
var _count = _table_markup.Rows.length;
|
||||
var _y1 = 0;
|
||||
var _y2 = 0;
|
||||
for (var i = 0; i < _count; i++) {
|
||||
if (i == 0) {
|
||||
_y1 = _table_markup.Rows[i].Y;
|
||||
}
|
||||
_y2 = _table_markup.Rows[i].Y;
|
||||
_y2 += _table_markup.Rows[i].H;
|
||||
}
|
||||
var pos3 = this.DrawingDocument.ConvertCoordsToCursorWR(_tableOutline.X, _y1, this.DrawingDocument.m_lCurrentPage);
|
||||
var pos4 = this.DrawingDocument.ConvertCoordsToCursorWR(_tableOutline.X, _y2, this.DrawingDocument.m_lCurrentPage);
|
||||
var _ttX = (pos1.X >> 0) + 0.5 - (_epsRects + _rectWidth);
|
||||
gradObj = ctx.createLinearGradient(_ttX, (pos3.Y >> 0) + 0.5, _ttX, (pos3.Y >> 0) + 0.5 + (pos4.Y - pos3.Y) >> 0);
|
||||
gradObj.addColorStop(0, "#f1f1f1");
|
||||
gradObj.addColorStop(1, "#dfdfdf");
|
||||
ctx.fillStyle = gradObj;
|
||||
overlay.AddRoundRect((pos1.X >> 0) + 1.5 - (_epsRects + _rectWidth), (pos3.Y >> 0) + 0.5, _rectWidth - 1, (pos4.Y - pos3.Y) >> 0, 4);
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
var ___w = window.g_table_track_diamond.width;
|
||||
var ___h = window.g_table_track_diamond.height;
|
||||
var dKoef = (this.HtmlPage.m_nZoomValue * g_dKoef_mm_to_pix / 100);
|
||||
var xDst = this.DrawingDocument.m_arrPages[this.DrawingDocument.m_lCurrentPage].drawingPage.left;
|
||||
var yDst = this.DrawingDocument.m_arrPages[this.DrawingDocument.m_lCurrentPage].drawingPage.top;
|
||||
var _oldY = _table_markup.Rows[0].Y + _table_markup.Rows[0].H;
|
||||
this.TableVerRulerPoints = [];
|
||||
var _rectIndex = 0;
|
||||
var _x = (pos1.X >> 0) + 0.5 - (_epsRects + _rectWidth);
|
||||
for (var i = 1; i <= _count; i++) {
|
||||
var _newPos = (i != _count) ? _table_markup.Rows[i].Y : _oldY;
|
||||
var _p = {
|
||||
Y: _oldY,
|
||||
H: (_newPos - _oldY)
|
||||
};
|
||||
var _r_x = _x;
|
||||
var _r_y = ((yDst + dKoef * _oldY) >> 0) + 0.5;
|
||||
var _r_h = ((_newPos - _oldY) * dKoef) >> 0;
|
||||
var xImage = (_r_x + 1) >> 0;
|
||||
var yImage = (_r_y + (_r_h / 2) - (___h / 2)) >> 0;
|
||||
overlay.CheckRect(xImage, yImage, ___w, ___h);
|
||||
ctx.drawImage(window.g_table_track_diamond, xImage, yImage);
|
||||
this.TableVerRulerPoints[_rectIndex++] = _p;
|
||||
if (i != _count) {
|
||||
_oldY = _table_markup.Rows[i].Y + _table_markup.Rows[i].H;
|
||||
}
|
||||
}
|
||||
this.TableHorRulerPoints = [];
|
||||
_rectIndex = 0;
|
||||
var _col = _table_markup.X;
|
||||
for (var i = 1; i <= _cols.length; i++) {
|
||||
_col += _cols[i - 1];
|
||||
var _x = _col - _table_markup.Margins[i - 1].Right;
|
||||
var _r = _col + ((i == _cols.length) ? 0 : _table_markup.Margins[i].Left);
|
||||
var __x = ((xDst + dKoef * _x) >> 0) + 0.5;
|
||||
var __r = ((xDst + dKoef * _r) >> 0) + 0.5;
|
||||
var __c = ((xDst + dKoef * _col) >> 0) + 0.5;
|
||||
var xImage = (__c - (___w / 2)) >> 0;
|
||||
var yImage = (TableMoveRect_y + 1) >> 0;
|
||||
overlay.CheckRect(xImage, yImage, ___w, ___h);
|
||||
ctx.drawImage(window.g_table_track_diamond, xImage, yImage);
|
||||
this.TableHorRulerPoints[_rectIndex++] = {
|
||||
X: _x,
|
||||
W: _r - _x,
|
||||
C: _col
|
||||
};
|
||||
}
|
||||
ctx.beginPath();
|
||||
if (this.Mode == MobileTouchMode.TableRuler) {
|
||||
if (0 == this.TableCurrentMoveDir) {
|
||||
var _pos = this.DrawingDocument.ConvertCoordsToCursorWR(this.TableCurrentMoveValue, 0, _table_outline_dr.CurrentPageIndex);
|
||||
overlay.VertLine(_pos.X, true);
|
||||
} else {
|
||||
var _pos = this.DrawingDocument.ConvertCoordsToCursorWR(0, this.TableCurrentMoveValue, _table_outline_dr.CurrentPageIndex);
|
||||
overlay.HorLine(_pos.Y, true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var dKoef = (this.HtmlPage.m_nZoomValue * g_dKoef_mm_to_pix / 100);
|
||||
var xDst = this.DrawingDocument.m_arrPages[this.DrawingDocument.m_lCurrentPage].drawingPage.left;
|
||||
var yDst = this.DrawingDocument.m_arrPages[this.DrawingDocument.m_lCurrentPage].drawingPage.top;
|
||||
ctx.lineWidth = 1 / dKoef;
|
||||
var _coord_transform = new CMatrix();
|
||||
_coord_transform.sx = dKoef;
|
||||
_coord_transform.sy = dKoef;
|
||||
_coord_transform.tx = xDst;
|
||||
_coord_transform.ty = yDst;
|
||||
_coord_transform.Multiply(_table_outline_dr.TableMatrix, MATRIX_ORDER_PREPEND);
|
||||
ctx.setTransform(_coord_transform.sx, _coord_transform.shy, _coord_transform.shx, _coord_transform.sy, _coord_transform.tx, _coord_transform.ty);
|
||||
this.TableMovePoint = {
|
||||
X: _tableOutline.X,
|
||||
Y: _tableOutline.Y
|
||||
};
|
||||
ctx.beginPath();
|
||||
var _rectW = _rectWidth / dKoef;
|
||||
var _offset = (_epsRects + _rectWidth) / dKoef;
|
||||
ctx.drawImage(window.g_table_track_mobile_move, this.TableMovePoint.X - _offset, this.TableMovePoint.Y - _offset, _rectW, _rectW);
|
||||
var gradObj = ctx.createLinearGradient(this.TableMovePoint.X, this.TableMovePoint.Y - _offset, this.TableMovePoint.X, this.TableMovePoint.Y - _offset + _rectW);
|
||||
gradObj.addColorStop(0, "#f1f1f1");
|
||||
gradObj.addColorStop(1, "#dfdfdf");
|
||||
ctx.fillStyle = gradObj;
|
||||
overlay.AddRoundRectCtx(ctx, this.TableMovePoint.X, this.TableMovePoint.Y - _offset, _tableW, _rectW, 5 / dKoef);
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
var _count = _table_markup.Rows.length;
|
||||
var _y1 = 0;
|
||||
var _y2 = 0;
|
||||
for (var i = 0; i < _count; i++) {
|
||||
if (i == 0) {
|
||||
_y1 = _table_markup.Rows[i].Y;
|
||||
}
|
||||
_y2 = _table_markup.Rows[i].Y;
|
||||
_y2 += _table_markup.Rows[i].H;
|
||||
}
|
||||
gradObj = ctx.createLinearGradient(this.TableMovePoint.X - _offset, this.TableMovePoint.Y, this.TableMovePoint.X - _offset, this.TableMovePoint.X - _offset + _y2 - _y1);
|
||||
gradObj.addColorStop(0, "#f1f1f1");
|
||||
gradObj.addColorStop(1, "#dfdfdf");
|
||||
ctx.fillStyle = gradObj;
|
||||
overlay.AddRoundRectCtx(ctx, this.TableMovePoint.X - _offset, this.TableMovePoint.Y, _rectW, _y2 - _y1, 5 / dKoef);
|
||||
overlay.CheckRectT(this.TableMovePoint.X, this.TableMovePoint.Y, _tableW, _y2 - _y1, _coord_transform, 2 * (_epsRects + _rectWidth));
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
var _oldY = _table_markup.Rows[0].Y + _table_markup.Rows[0].H;
|
||||
_oldY -= _table_outline_dr.TableMatrix.ty;
|
||||
var ___w = window.g_table_track_diamond.width;
|
||||
var ___h = window.g_table_track_diamond.height;
|
||||
this.TableVerRulerPoints = [];
|
||||
var _rectIndex = 0;
|
||||
var _xx = this.TableMovePoint.X - _offset;
|
||||
for (var i = 1; i <= _count; i++) {
|
||||
var _newPos = (i != _count) ? (_table_markup.Rows[i].Y - _table_outline_dr.TableMatrix.ty) : _oldY;
|
||||
var _p = {
|
||||
Y: _oldY,
|
||||
H: (_newPos - _oldY)
|
||||
};
|
||||
var ___y = (_p.Y + (_p.H / 2) - ((___h / dKoef) / 2));
|
||||
ctx.drawImage(window.g_table_track_diamond, _xx, ___y, ___w / dKoef, ___h / dKoef);
|
||||
this.TableVerRulerPoints[_rectIndex++] = _p;
|
||||
if (i != _count) {
|
||||
_oldY = _table_markup.Rows[i].Y + _table_markup.Rows[i].H;
|
||||
_oldY -= _table_outline_dr.TableMatrix.ty;
|
||||
}
|
||||
}
|
||||
this.TableHorRulerPoints = [];
|
||||
_rectIndex = 0;
|
||||
var _col = this.TableMovePoint.X;
|
||||
for (var i = 1; i <= _cols.length; i++) {
|
||||
_col += _cols[i - 1];
|
||||
var _x = _col - _table_markup.Margins[i - 1].Right;
|
||||
var _r = _col + ((i == _cols.length) ? 0 : _table_markup.Margins[i].Left);
|
||||
var ___x = (_col - ((___w / dKoef) / 2));
|
||||
ctx.drawImage(window.g_table_track_diamond, ___x, (this.TableMovePoint.Y - _offset), ___w / dKoef, ___h / dKoef);
|
||||
this.TableHorRulerPoints[_rectIndex++] = {
|
||||
X: _x,
|
||||
W: _r - _x,
|
||||
C: _col
|
||||
};
|
||||
}
|
||||
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
||||
ctx.beginPath();
|
||||
if (this.Mode == MobileTouchMode.TableRuler) {
|
||||
if (0 == this.TableCurrentMoveDir) {
|
||||
var _pos = this.DrawingDocument.ConvertCoordsToCursorWR(this.TableCurrentMoveValue, 0, _table_outline_dr.CurrentPageIndex, _table_outline_dr.TableMatrix);
|
||||
overlay.VertLine(_pos.X, true);
|
||||
} else {
|
||||
var _pos = this.DrawingDocument.ConvertCoordsToCursorWR(0, this.TableCurrentMoveValue, _table_outline_dr.CurrentPageIndex, _table_outline_dr.TableMatrix);
|
||||
overlay.HorLine(_pos.Y, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user