Commit 4f59197f authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Поправил копирование фрагментов при открытии редактора ячейки. Разделил...

Поправил копирование фрагментов при открытии редактора ячейки. Разделил дефалтовые настройки и изменяемые в редакторе ячейки.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55743 954022d7-b5bf-4e40-9824-e11837661b57
parent c2130a30
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
var asc_HL = asc.HandlersList; var asc_HL = asc.HandlersList;
var asc_DC = asc.DrawingContext; var asc_DC = asc.DrawingContext;
var asc_TR = asc.CellTextRender; var asc_TR = asc.CellTextRender;
var asc_FP = asc.FontProperties;
var asc_incDecFonSize = asc.incDecFonSize; var asc_incDecFonSize = asc.incDecFonSize;
...@@ -77,7 +76,7 @@ ...@@ -77,7 +76,7 @@
* @param {Array} fmgrGraphics * @param {Array} fmgrGraphics
* @param {FontProperties} oFont * @param {FontProperties} oFont
* @param {HandlersList} handlers * @param {HandlersList} handlers
* @param {Object} settings See CellEditor.defaults * @param {Object} settings
*/ */
function CellEditor(elem, input, fmgrGraphics, oFont, handlers, settings) { function CellEditor(elem, input, fmgrGraphics, oFont, handlers, settings) {
if ( !(this instanceof CellEditor) ) {return new CellEditor(elem, input, fmgrGraphics, oFont, handlers, settings);} if ( !(this instanceof CellEditor) ) {return new CellEditor(elem, input, fmgrGraphics, oFont, handlers, settings);}
...@@ -85,7 +84,6 @@ ...@@ -85,7 +84,6 @@
this.element = elem; this.element = elem;
this.input = input; this.input = input;
this.handlers = new asc_HL(handlers); this.handlers = new asc_HL(handlers);
this.settings = $.extend(true, {}, this.defaults, settings);
this.options = {}; this.options = {};
//---declaration--- //---declaration---
...@@ -134,54 +132,42 @@ ...@@ -134,54 +132,42 @@
this.fKeyMouseUp = null; this.fKeyMouseUp = null;
this.fKeyMouseMove = null; this.fKeyMouseMove = null;
//----------------- //-----------------
// Автоподстановка формул. Цвет селекта
this.formulaSelectorColor = "rgba(105, 119, 62, 0.2)";
this.objAutoComplete = {}; this.objAutoComplete = {};
this._init(); /** @type RegExp */
this.reReplaceNL = /\r?\n|\r/g;
return this; /** @type RegExp */
} this.reReplaceTab = /[\t\v\f]/g;
// RegExp с поддержкой рэнджей вида $E1:$F2
CellEditor.prototype = { this.reRangeStr = "[^a-z0-9_$!:](\\$?[a-z]+\\$?\\d+:\\$?[a-z]+\\$?\\d+(?=[^a-z0-9_]|$)|\\$?[a-z]+:\\$?[a-z]+(?=[^a-z0-9_]|$)|\\$?\\d+:\\$?\\d+(?=[^a-z0-9_]|$)|\\$?[a-z]+\\$?\\d+(?=[^a-z0-9_]|$))";
this.rangeChars = "= - + * / ( { , < > ^ ! & : ;".split(' ');
constructor: CellEditor, this.reNotFormula = /[^a-z0-9_]/i;
this.reFormula = /^([a-z_][a-z0-9_]*)/i;
defaults: { this.defaults = {
background : new CColor(255, 255, 255),
font : new asc_FP("Calibri", 11),
padding : 2, padding : 2,
selectColor : new CColor(190, 190, 255, 0.5), selectColor : new CColor(190, 190, 255, 0.5),
textAlign : kLeftAlign,
textColor : new CColor(0, 0, 0),
canvasZindex : 1000, canvasZIndex : 1000,
blinkInterval : 500, blinkInterval : 500,
cursorShape : "text", cursorShape : "text",
selectionTimeout: 20 selectionTimeout: 20
}, };
/** @type RegExp */
reReplaceNL: /\r?\n|\r/g,
/** @type RegExp */ this._init(settings);
reReplaceTab: /[\t\v\f]/g,
// RegExp с поддержкой рэнджей вида $E1:$F2
reRangeStr: "[^a-z0-9_$!:](\\$?[a-z]+\\$?\\d+:\\$?[a-z]+\\$?\\d+(?=[^a-z0-9_]|$)|\\$?[a-z]+:\\$?[a-z]+(?=[^a-z0-9_]|$)|\\$?\\d+:\\$?\\d+(?=[^a-z0-9_]|$)|\\$?[a-z]+\\$?\\d+(?=[^a-z0-9_]|$))",
rangeChars: "= - + * / ( { , < > ^ ! & : ;".split(' '), return this;
}
reNotFormula: /[^a-z0-9_]/i, CellEditor.prototype = {
reFormula: /^([a-z_][a-z0-9_]*)/i, constructor: CellEditor,
_init: function () { _init: function (settings) {
var t = this; var t = this;
var z = t.settings.canvasZindex; var z = t.defaults.canvasZIndex;
if (null != this.element) { if (null != this.element) {
t.canvasOuter = document.createElement('div'); t.canvasOuter = document.createElement('div');
...@@ -189,7 +175,7 @@ ...@@ -189,7 +175,7 @@
t.canvasOuter.style.display = "none"; t.canvasOuter.style.display = "none";
t.canvasOuter.style.zIndex = z; t.canvasOuter.style.zIndex = z;
var innerHTML = '<canvas id="ce-canvas" style="z-index: ' + (z+1) + '"></canvas>'; var innerHTML = '<canvas id="ce-canvas" style="z-index: ' + (z+1) + '"></canvas>';
innerHTML += '<canvas id="ce-canvas-overlay" style="z-index: ' + (z+2) + '; cursor: ' + t.settings.cursorShape + '"></canvas>'; innerHTML += '<canvas id="ce-canvas-overlay" style="z-index: ' + (z+2) + '; cursor: ' + t.defaults.cursorShape + '"></canvas>';
innerHTML += '<div id="ce-cursor" style="display: none; z-index: ' + (z+3) + '"></div>'; innerHTML += '<div id="ce-cursor" style="display: none; z-index: ' + (z+3) + '"></div>';
t.canvasOuter.innerHTML = innerHTML; t.canvasOuter.innerHTML = innerHTML;
this.element.appendChild(t.canvasOuter); this.element.appendChild(t.canvasOuter);
...@@ -205,7 +191,7 @@ ...@@ -205,7 +191,7 @@
t.drawingCtx = asc_DC({canvas: t.canvas, units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics, font: this.m_oFont}); t.drawingCtx = asc_DC({canvas: t.canvas, units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics, font: this.m_oFont});
t.overlayCtx = asc_DC({canvas: t.canvasOverlay, units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics, font: this.m_oFont}); t.overlayCtx = asc_DC({canvas: t.canvasOverlay, units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics, font: this.m_oFont});
t.textRender = asc_TR(t.drawingCtx); t.textRender = asc_TR(t.drawingCtx);
t.textRender.setDefaultFont(t.settings.font.clone()); t.textRender.setDefaultFont(settings.font.clone());
// bind event handlers // bind event handlers
if (t.canvasOverlay && t.canvasOverlay.addEventListener) { if (t.canvasOverlay && t.canvasOverlay.addEventListener) {
...@@ -253,7 +239,6 @@ ...@@ -253,7 +239,6 @@
* font * font
* background * background
* textColor * textColor
* selectColor
* saveValueCallback * saveValueCallback
*/ */
open: function (options) { open: function (options) {
...@@ -636,11 +621,11 @@ ...@@ -636,11 +621,11 @@
function cmpNumRev(a, b) {return b - a;} function cmpNumRev(a, b) {return b - a;}
var t = this; var t = this;
var opt = t.options = $.extend(true, {}, t.settings, options); var opt = t.options = options;
var ctx = t.drawingCtx; var ctx = t.drawingCtx;
var u = ctx.getUnits(); var u = ctx.getUnits();
t.textFlags = $.extend(true, {}, opt.flags); t.textFlags = opt.flags;
if (t.textFlags.textAlign.toLowerCase() === "justify" || this.isFormula()) { if (t.textFlags.textAlign.toLowerCase() === "justify" || this.isFormula()) {
t.textFlags.textAlign = "left"; t.textFlags.textAlign = "left";
} }
...@@ -980,7 +965,7 @@ ...@@ -980,7 +965,7 @@
_adjustCanvas: function () { _adjustCanvas: function () {
var t = this; var t = this;
var z = t.settings.canvasZindex; var z = t.defaults.canvasZIndex;
t.canvasOuterStyle.left = (t.left * t.kx) + "px"; t.canvasOuterStyle.left = (t.left * t.kx) + "px";
t.canvasOuterStyle.top = (t.top * t.ky) + "px"; t.canvasOuterStyle.top = (t.top * t.ky) + "px";
...@@ -1011,37 +996,36 @@ ...@@ -1011,37 +996,36 @@
}, },
_drawSelection: function () { _drawSelection: function () {
var t = this, opt = t.options, ctx = t.overlayCtx, ppix = ctx.getPPIX(), ppiy = ctx.getPPIY(); var ctx = this.overlayCtx, ppix = ctx.getPPIX(), ppiy = ctx.getPPIY();
var begPos, endPos, top, top1, top2, begInfo, endInfo, line1, line2, i; var begPos, endPos, top, top1, top2, begInfo, endInfo, line1, line2, i;
function drawRect(x, y, w, h) { function drawRect(x, y, w, h) {
ctx.fillRect( ctx.fillRect(
asc_calcnpt(x, ppix), asc_calcnpt(y, ppiy), asc_calcnpt(x, ppix), asc_calcnpt(y, ppiy),
asc_calcnpt(w, ppix), asc_calcnpt(h, ppiy)); asc_calcnpt(w, ppix), asc_calcnpt(h, ppiy));
} }
begPos = t.selectionBegin; begPos = this.selectionBegin;
endPos = t.selectionEnd; endPos = this.selectionEnd;
ctx.setFillStyle(opt.selectColor) ctx.setFillStyle(this.defaults.selectColor).clear();
.clear();
if (begPos !== endPos && !t.isTopLineActive) { if (begPos !== endPos && !this.isTopLineActive) {
top = t.textRender.calcLineOffset(t.topLineIndex); top = this.textRender.calcLineOffset(this.topLineIndex);
begInfo = t.textRender.calcCharOffset(Math.min(begPos, endPos)); begInfo = this.textRender.calcCharOffset(Math.min(begPos, endPos));
line1 = t.textRender.getLineInfo(begInfo.lineIndex); line1 = this.textRender.getLineInfo(begInfo.lineIndex);
top1 = t.textRender.calcLineOffset(begInfo.lineIndex); top1 = this.textRender.calcLineOffset(begInfo.lineIndex);
endInfo = t.textRender.calcCharOffset(Math.max(begPos, endPos)); endInfo = this.textRender.calcCharOffset(Math.max(begPos, endPos));
if (begInfo.lineIndex === endInfo.lineIndex) { if (begInfo.lineIndex === endInfo.lineIndex) {
drawRect(begInfo.left, top1 - top, endInfo.left - begInfo.left, line1.th); drawRect(begInfo.left, top1 - top, endInfo.left - begInfo.left, line1.th);
} else { } else {
line2 = t.textRender.getLineInfo(endInfo.lineIndex); line2 = this.textRender.getLineInfo(endInfo.lineIndex);
top2 = t.textRender.calcLineOffset(endInfo.lineIndex); top2 = this.textRender.calcLineOffset(endInfo.lineIndex);
drawRect(begInfo.left, top1 - top, line1.tw - begInfo.left + line1.startX, line1.th); drawRect(begInfo.left, top1 - top, line1.tw - begInfo.left + line1.startX, line1.th);
if (line2) {drawRect(line2.startX, top2 - top, endInfo.left - line2.startX, line2.th);} if (line2) {drawRect(line2.startX, top2 - top, endInfo.left - line2.startX, line2.th);}
top = top1 - top + line1.th; top = top1 - top + line1.th;
for (i = begInfo.lineIndex + 1; i < endInfo.lineIndex; ++i, top += line1.th) { for (i = begInfo.lineIndex + 1; i < endInfo.lineIndex; ++i, top += line1.th) {
line1 = t.textRender.getLineInfo(i); line1 = this.textRender.getLineInfo(i);
drawRect(line1.startX, top, line1.tw, line1.th); drawRect(line1.startX, top, line1.tw, line1.th);
} }
} }
...@@ -1063,7 +1047,7 @@ ...@@ -1063,7 +1047,7 @@
t.cursorStyle.display = "block"; t.cursorStyle.display = "block";
t.cursorTID = window.setInterval(function () { t.cursorTID = window.setInterval(function () {
t.cursorStyle.display = ("none" === t.cursorStyle.display) ? "block" : "none"; t.cursorStyle.display = ("none" === t.cursorStyle.display) ? "block" : "none";
}, t.settings.blinkInterval); }, t.defaults.blinkInterval);
}, },
_hideCursor: function () { _hideCursor: function () {
...@@ -1209,13 +1193,12 @@ ...@@ -1209,13 +1193,12 @@
// Content // Content
_getContentLeft: function () { _getContentLeft: function () {
var t = this, opt = t.options; return asc_calcnpt(0, this.drawingCtx.getPPIX(), this.defaults.padding/*px*/);
return asc_calcnpt(0, t.drawingCtx.getPPIX(), opt.padding/*px*/);
}, },
_getContentWidth: function () { _getContentWidth: function () {
var t = this, opt = t.options; return this.right - this.left - asc_calcnpt(0, this.drawingCtx.getPPIX(),
return t.right - t.left - asc_calcnpt(0, t.drawingCtx.getPPIX(), opt.padding + opt.padding + 1/*px*/); this.defaults.padding + this.defaults.padding + 1/*px*/);
}, },
_getContentHeight: function () { _getContentHeight: function () {
...@@ -1224,15 +1207,15 @@ ...@@ -1224,15 +1207,15 @@
}, },
_getContentPosition: function () { _getContentPosition: function () {
var t = this, opt = t.options, ppix = t.drawingCtx.getPPIX(); var ppix = this.drawingCtx.getPPIX();
switch (t.textFlags.textAlign) { switch (this.textFlags.textAlign) {
case kRightAlign: case kRightAlign:
return asc_calcnpt(t.right - t.left, ppix, -opt.padding - 1); return asc_calcnpt(this.right - this.left, ppix, -this.defaults.padding - 1);
case kCenterAlign: case kCenterAlign:
return asc_calcnpt(0.5 * (t.right - t.left), ppix, 0); return asc_calcnpt(0.5 * (this.right - this.left), ppix, 0);
} }
return asc_calcnpt(0, ppix, opt.padding); return asc_calcnpt(0, ppix, this.defaults.padding);
}, },
_wrapFragments: function (frag) { _wrapFragments: function (frag) {
...@@ -1374,7 +1357,7 @@ ...@@ -1374,7 +1357,7 @@
if (t.isSelectMode) { if (t.isSelectMode) {
t.selectionTimer = window.setTimeout( t.selectionTimer = window.setTimeout(
function () {doChangeSelection(coord);}, function () {doChangeSelection(coord);},
t.settings.selectionTimeout); t.defaults.selectionTimeout);
} }
} }
......
...@@ -10244,7 +10244,7 @@ ...@@ -10244,7 +10244,7 @@
fragments: fragments, fragments: fragments,
flags: fl, flags: fl,
font: new asc_FP(c.getFontname(), c.getFontsize()), font: new asc_FP(c.getFontname(), c.getFontsize()),
background: bg !== null ? bg : t.settings.cells.defaultState.background, background: bg || t.settings.cells.defaultState.background,
textColor: oFontColor || t.settings.cells.defaultState.color, textColor: oFontColor || t.settings.cells.defaultState.color,
cursorPos: cursorPos, cursorPos: cursorPos,
zoom: t.getZoom(), zoom: t.getZoom(),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment