Commit c3328e1c authored by Alexander.Trofimov's avatar Alexander.Trofimov

change formatting style

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@68090 954022d7-b5bf-4e40-9824-e11837661b57
parent 9ad7b082
......@@ -5,13 +5,12 @@
* Author: Dmitry.Sokolov@avsmedia.net
* Date: Jan 27, 2012
*/
(
/**
(/**
* @param {jQuery} $
* @param {Window} window
* @param {undefined} undefined
*/
function ($, window, undefined) {
function($, window, undefined) {
/*
......@@ -27,50 +26,34 @@
var asc_getcvt = asc.getCvtRatio;
var asc_CSP = asc.asc_CStylesPainter;
function WorkbookCommentsModel (handlers) {
function WorkbookCommentsModel(handlers) {
this.workbook = {handlers: handlers};
}
WorkbookCommentsModel.prototype.getId = function () {
WorkbookCommentsModel.prototype.getId = function() {
return "workbook";
};
WorkbookCommentsModel.prototype.getMergedByCell = function () {
WorkbookCommentsModel.prototype.getMergedByCell = function() {
return null;
};
function WorksheetViewSettings() {
this.header = {
style: [
// Header colors
style: [// Header colors
{ // kHeaderDefault
background: new CColor(244, 244, 244),
border: new CColor(213, 213, 213),
color: new CColor(54, 54, 54)
},
{ // kHeaderActive
background: new CColor(193, 193, 193),
border: new CColor(146, 146, 146),
color: new CColor(54, 54, 54)
},
{ // kHeaderHighlighted
background: new CColor(223, 223, 223),
border: new CColor(175, 175, 175),
color: new CColor(101, 106, 112)
},
{ // kHeaderSelected
background: new CColor(170, 170, 170),
border: new CColor(117, 119, 122),
color: new CColor(54, 54, 54)
}
],
cornerColor: new CColor(193, 193, 193)
background: new CColor(244, 244, 244), border: new CColor(213, 213, 213), color: new CColor(54, 54, 54)
}, { // kHeaderActive
background: new CColor(193, 193, 193), border: new CColor(146, 146, 146), color: new CColor(54, 54, 54)
}, { // kHeaderHighlighted
background: new CColor(223, 223, 223), border: new CColor(175, 175, 175), color: new CColor(101, 106, 112)
}, { // kHeaderSelected
background: new CColor(170, 170, 170), border: new CColor(117, 119, 122), color: new CColor(54, 54, 54)
}], cornerColor: new CColor(193, 193, 193)
};
this.cells = {
defaultState: {
background: new CColor(255, 255, 255),
border: new CColor(212, 212, 212),
color: new CColor(0, 0, 0)
},
padding: -1, /*px horizontal padding*/
background: new CColor(255, 255, 255), border: new CColor(212, 212, 212), color: new CColor(0, 0, 0)
}, padding: -1, /*px horizontal padding*/
paddingPlusBorder: -1
};
this.activeCellBorderColor = new CColor(126, 152, 63);
......@@ -118,10 +101,8 @@
function WorkbookView(model, controller, handlers, elem, inputElem, Api, collaborativeEditing, fontRenderingMode) {
this.defaults = {
scroll: {
widthPx : 14,
heightPx: 14
},
worksheetView: new WorksheetViewSettings()
widthPx: 14, heightPx: 14
}, worksheetView: new WorksheetViewSettings()
};
this.model = model;
......@@ -752,38 +733,39 @@
return this;
};
WorkbookView.prototype.destroy = function () {
WorkbookView.prototype.destroy = function() {
this.controller.destroy();
this.cellEditor.destroy();
return this;
};
WorkbookView.prototype._createWorksheetView = function (wsModel) {
return new asc.WorksheetView(wsModel, this.wsViewHandlers, this.buffers, this.stringRender,
this.maxDigitWidth, this.collaborativeEditing, this.defaults.worksheetView);
WorkbookView.prototype._createWorksheetView = function(wsModel) {
return new asc.WorksheetView(wsModel, this.wsViewHandlers, this.buffers, this.stringRender, this.maxDigitWidth, this.collaborativeEditing, this.defaults.worksheetView);
};
WorkbookView.prototype._onSelectionNameChanged = function (name) {
WorkbookView.prototype._onSelectionNameChanged = function(name) {
this.handlers.trigger("asc_onSelectionNameChanged", name);
};
WorkbookView.prototype._onSelectionMathInfoChanged = function (info) {
WorkbookView.prototype._onSelectionMathInfoChanged = function(info) {
this.handlers.trigger("asc_onSelectionMathChanged", info);
};
// Проверяет, сменили ли мы диапазон (для того, чтобы не отправлять одинаковую информацию о диапазоне)
WorkbookView.prototype._isEqualRange = function (range, isSelectOnShape) {
if (null === this.lastSendInfoRange)
WorkbookView.prototype._isEqualRange = function(range, isSelectOnShape) {
if (null === this.lastSendInfoRange) {
return false;
}
return this.lastSendInfoRange.isEqual(range) && this.lastSendInfoRangeIsSelectOnShape === isSelectOnShape;
};
WorkbookView.prototype._onWSSelectionChanged = function (info) {
WorkbookView.prototype._onWSSelectionChanged = function(info) {
var ws = this.getWorksheet();
if( this.cellFormulaEnterWSOpen )
if (this.cellFormulaEnterWSOpen) {
ws = this.cellFormulaEnterWSOpen;
}
var ar = ws.activeRange;
this.lastSendInfoRange = ar.clone(true);
......@@ -793,8 +775,7 @@
info = ws.getSelectionInfo();
}
// При редактировании ячейки не нужно пересылать изменения
if (this.input && false === ws.getCellEditMode() &&
c_oAscSelectionDialogType.None === this.selectionDialogType) {
if (this.input && false === ws.getCellEditMode() && c_oAscSelectionDialogType.None === this.selectionDialogType) {
// Сами запретим заходить в строку формул, когда выделен shape
if (this.lastSendInfoRangeIsSelectOnShape) {
this.input.disabled = true;
......@@ -808,20 +789,20 @@
};
WorkbookView.prototype._onScrollReinitialize = function (whichSB, callback) {
var ws = this.getWorksheet(),
vsize = !whichSB || whichSB === 1 ? ws.getVerticalScrollRange() : undefined,
hsize = !whichSB || whichSB === 2 ? ws.getHorizontalScrollRange() : undefined;
WorkbookView.prototype._onScrollReinitialize = function(whichSB, callback) {
var ws = this.getWorksheet(), vsize = !whichSB || whichSB === 1 ? ws.getVerticalScrollRange() : undefined, hsize = !whichSB || whichSB === 2 ? ws.getHorizontalScrollRange() : undefined;
if( vsize != undefined )
if (vsize != undefined) {
this.m_dScrollY_max = Math.max(this.controller.settings.vscrollStep * (vsize + 1), 1);
if( hsize != undefined )
}
if (hsize != undefined) {
this.m_dScrollX_max = Math.max(this.controller.settings.hscrollStep * (hsize + 1), 1);
}
asc_applyFunction(callback, vsize, hsize);
};
WorkbookView.prototype._onScrollY = function (pos) {
WorkbookView.prototype._onScrollY = function(pos) {
var ws = this.getWorksheet();
var delta = asc_round(pos - ws.getFirstVisibleRow(/*allowPane*/true));
if (delta !== 0) {
......@@ -829,7 +810,7 @@
}
};
WorkbookView.prototype._onScrollX = function (pos) {
WorkbookView.prototype._onScrollX = function(pos) {
var ws = this.getWorksheet();
var delta = asc_round(pos - ws.getFirstVisibleCol(/*allowPane*/true));
if (delta !== 0) {
......@@ -837,28 +818,29 @@
}
};
WorkbookView.prototype._onSetSelection = function (range, validRange) {
WorkbookView.prototype._onSetSelection = function(range, validRange) {
var ws = this.getWorksheet();
ws._checkSelectionShape();
var d = ws.setSelectionUndoRedo(range, validRange);
this.controller.scroll(d);
};
WorkbookView.prototype._onGetSelection = function () {
WorkbookView.prototype._onGetSelection = function() {
var ws = this.getWorksheet();
return ws.getActiveRangeObj();
};
WorkbookView.prototype._onGetSelectionState = function () {
WorkbookView.prototype._onGetSelectionState = function() {
var ws = this.getWorksheet();
var res = null;
if (isRealObject(ws.objectRender) && isRealObject(ws.objectRender.controller))
if (isRealObject(ws.objectRender) && isRealObject(ws.objectRender.controller)) {
res = ws.objectRender.controller.getSelectionState();
}
// ToDo лучше на getSelectionState возвращать null
return (res && res[0] && res[0].focus) ? res : null;
};
WorkbookView.prototype._onSetSelectionState = function (state) {
WorkbookView.prototype._onSetSelectionState = function(state) {
if (null !== state) {
var ws = this.getWorksheetById(state[0].worksheetId);
if (ws && ws.objectRender && ws.objectRender.controller) {
......@@ -874,11 +856,9 @@
}
};
WorkbookView.prototype._onChangeSelection = function (isStartPoint, dc, dr, isCoord, isSelectMode, callback) {
WorkbookView.prototype._onChangeSelection = function(isStartPoint, dc, dr, isCoord, isSelectMode, callback) {
var ws = this.getWorksheet();
var d = isStartPoint ?
ws.changeSelectionStartPoint(dc, dr, isCoord, isSelectMode):
ws.changeSelectionEndPoint(dc, dr, isCoord, isSelectMode);
var d = isStartPoint ? ws.changeSelectionStartPoint(dc, dr, isCoord, isSelectMode) : ws.changeSelectionEndPoint(dc, dr, isCoord, isSelectMode);
if (!isCoord && !isStartPoint && !isSelectMode) {
// Выделение с зажатым shift
this.canUpdateAfterShiftUp = true;
......@@ -887,7 +867,7 @@
};
// Окончание выделения
WorkbookView.prototype._onChangeSelectionDone = function (x, y) {
WorkbookView.prototype._onChangeSelectionDone = function(x, y) {
if (c_oAscSelectionDialogType.None !== this.selectionDialogType) {
return;
}
......@@ -910,19 +890,21 @@
if (c_oTargetType.Hyperlink === ct.target) {
// Проверим замерженность
var isHyperlinkClick = false;
if ((ar.c1 === ar.c2 && ar.r1 === ar.r2) || isSelectOnShape)
if ((ar.c1 === ar.c2 && ar.r1 === ar.r2) || isSelectOnShape) {
isHyperlinkClick = true;
else {
} else {
var mergedRange = ws.model.getMergedByCell(ar.r1, ar.c1);
if (mergedRange && ar.isEqual(mergedRange))
if (mergedRange && ar.isEqual(mergedRange)) {
isHyperlinkClick = true;
}
}
if (isHyperlinkClick) {
if (false === ct.hyperlink.hyperlinkModel.getVisited() && !isSelectOnShape) {
ct.hyperlink.hyperlinkModel.setVisited(true);
if (ct.hyperlink.hyperlinkModel.Ref)
if (ct.hyperlink.hyperlinkModel.Ref) {
ws.updateRange(ct.hyperlink.hyperlinkModel.Ref.getBBox0(), false, false);
}
}
switch (ct.hyperlink.asc_getType()) {
case c_oAscHyperlinkType.WebLink:
this.handlers.trigger("asc_onHyperlinkClick", ct.hyperlink.asc_getHyperlinkUrl());
......@@ -938,19 +920,19 @@
};
// Обработка нажатия правой кнопки мыши
WorkbookView.prototype._onChangeSelectionRightClick = function (dc, dr) {
WorkbookView.prototype._onChangeSelectionRightClick = function(dc, dr) {
var ws = this.getWorksheet();
ws.changeSelectionStartPointRightClick(dc, dr);
};
// Обработка движения в выделенной области
WorkbookView.prototype._onSelectionActivePointChanged = function (dc, dr, callback) {
WorkbookView.prototype._onSelectionActivePointChanged = function(dc, dr, callback) {
var ws = this.getWorksheet();
var d = ws.changeSelectionActivePoint(dc, dr);
asc_applyFunction(callback, d);
};
WorkbookView.prototype._onUpdateWorksheet = function (canvasElem, x, y, ctrlKey, callback) {
WorkbookView.prototype._onUpdateWorksheet = function(canvasElem, x, y, ctrlKey, callback) {
var ws = this.getWorksheet(), ct = undefined;
var arrMouseMoveObjects = []; // Теперь это массив из объектов, над которыми курсор
......@@ -964,29 +946,45 @@
// Отправление эвента об удалении всего листа (именно удалении, т.к. если просто залочен, то не рисуем рамку вокруг)
if (undefined !== ct.userIdAllSheet) {
arrMouseMoveObjects.push(new asc_CMM({type: c_oAscMouseMoveType.LockedObject, x: ct.lockAllPosLeft,
y: ct.lockAllPosTop, userId: ct.userIdAllSheet,
lockedObjectType: c_oAscMouseMoveLockedObjectType.Sheet}));
arrMouseMoveObjects.push(new asc_CMM({
type: c_oAscMouseMoveType.LockedObject,
x: ct.lockAllPosLeft,
y: ct.lockAllPosTop,
userId: ct.userIdAllSheet,
lockedObjectType: c_oAscMouseMoveLockedObjectType.Sheet
}));
} else {
// Отправление эвента о залоченности свойств всего листа (только если не удален весь лист)
if (undefined !== ct.userIdAllProps) {
arrMouseMoveObjects.push(new asc_CMM({type: c_oAscMouseMoveType.LockedObject, x: ct.lockAllPosLeft,
y: ct.lockAllPosTop, userId: ct.userIdAllProps,
lockedObjectType: c_oAscMouseMoveLockedObjectType.TableProperties}));
arrMouseMoveObjects.push(new asc_CMM({
type: c_oAscMouseMoveType.LockedObject,
x: ct.lockAllPosLeft,
y: ct.lockAllPosTop,
userId: ct.userIdAllProps,
lockedObjectType: c_oAscMouseMoveLockedObjectType.TableProperties
}));
}
}
// Отправление эвента о наведении на залоченный объект
if (undefined !== ct.userId) {
arrMouseMoveObjects.push(new asc_CMM({type: c_oAscMouseMoveType.LockedObject, x: ct.lockRangePosLeft,
y: ct.lockRangePosTop, userId: ct.userId,
lockedObjectType: c_oAscMouseMoveLockedObjectType.Range}));
arrMouseMoveObjects.push(new asc_CMM({
type: c_oAscMouseMoveType.LockedObject,
x: ct.lockRangePosLeft,
y: ct.lockRangePosTop,
userId: ct.userId,
lockedObjectType: c_oAscMouseMoveLockedObjectType.Range
}));
}
// Проверяем комментарии ячейки
if (undefined !== ct.commentIndexes) {
arrMouseMoveObjects.push(new asc_CMM({type: c_oAscMouseMoveType.Comment,
x: ct.commentCoords.asc_getLeftPX(), reverseX: ct.commentCoords.asc_getReverseLeftPX(), y: ct.commentCoords.asc_getTopPX(),
aCommentIndexes: ct.commentIndexes}));
arrMouseMoveObjects.push(new asc_CMM({
type: c_oAscMouseMoveType.Comment,
x: ct.commentCoords.asc_getLeftPX(),
reverseX: ct.commentCoords.asc_getReverseLeftPX(),
y: ct.commentCoords.asc_getTopPX(),
aCommentIndexes: ct.commentIndexes
}));
}
// Проверяем гиперссылку
if (ct.target === c_oTargetType.Hyperlink) {
......@@ -995,8 +993,9 @@
} else {
ct.cursor = ct.cellCursor.cursor;
}
arrMouseMoveObjects.push(new asc_CMM({type: c_oAscMouseMoveType.Hyperlink, x: x, y: y,
hyperlink: ct.hyperlink}));
arrMouseMoveObjects.push(new asc_CMM({
type: c_oAscMouseMoveType.Hyperlink, x: x, y: y, hyperlink: ct.hyperlink
}));
}
/* Проверяем, может мы на никаком объекте (такая схема оказалась приемлимой
......@@ -1009,7 +1008,7 @@
// Отсылаем эвент с объектами
this.handlers.trigger("asc_onMouseMove", arrMouseMoveObjects);
if(ct.target === c_oTargetType.MoveRange && ctrlKey && ct.cursor == "move"){
if (ct.target === c_oTargetType.MoveRange && ctrlKey && ct.cursor == "move") {
ct.cursor = "copy";
}
......@@ -1025,7 +1024,7 @@
asc_applyFunction(callback, ct);
};
WorkbookView.prototype._onResizeElement = function (target, x, y) {
WorkbookView.prototype._onResizeElement = function(target, x, y) {
var arrMouseMoveObjects = [];
if (target.target === c_oTargetType.ColumnResize) {
arrMouseMoveObjects.push(this.getWorksheet().drawColumnGuides(target.col, x, y, target.mouseX));
......@@ -1044,11 +1043,10 @@
this.handlers.trigger("asc_onMouseMove", arrMouseMoveObjects);
};
WorkbookView.prototype._onResizeElementDone = function (target, x, y, isResizeModeMove) {
WorkbookView.prototype._onResizeElementDone = function(target, x, y, isResizeModeMove) {
var ws = this.getWorksheet();
if (isResizeModeMove) {
if(ws.objectRender)
{
if (ws.objectRender) {
ws.objectRender.saveSizeDrawingObjects();
}
if (target.target === c_oTargetType.ColumnResize) {
......@@ -1067,49 +1065,49 @@
};
// Обработка автозаполнения
WorkbookView.prototype._onChangeFillHandle = function (x, y, callback) {
WorkbookView.prototype._onChangeFillHandle = function(x, y, callback) {
var ws = this.getWorksheet();
var d = ws.changeSelectionFillHandle(x, y);
asc_applyFunction(callback, d);
};
// Обработка окончания автозаполнения
WorkbookView.prototype._onChangeFillHandleDone = function (x, y, ctrlPress) {
WorkbookView.prototype._onChangeFillHandleDone = function(x, y, ctrlPress) {
var ws = this.getWorksheet();
ws.applyFillHandle(x, y, ctrlPress);
};
// Обработка перемещения диапазона
WorkbookView.prototype._onMoveRangeHandle = function (x, y, callback,ctrlKey) {
WorkbookView.prototype._onMoveRangeHandle = function(x, y, callback, ctrlKey) {
var ws = this.getWorksheet();
var d = ws.changeSelectionMoveRangeHandle(x, y, ctrlKey);
asc_applyFunction(callback, d);
};
// Обработка окончания перемещения диапазона
WorkbookView.prototype._onMoveRangeHandleDone = function (ctrlKey) {
WorkbookView.prototype._onMoveRangeHandleDone = function(ctrlKey) {
var ws = this.getWorksheet();
ws.applyMoveRangeHandle(ctrlKey);
};
WorkbookView.prototype._onMoveResizeRangeHandle = function (x, y, target, callback) {
WorkbookView.prototype._onMoveResizeRangeHandle = function(x, y, target, callback) {
var ws = this.getWorksheet();
var d = ws.changeSelectionMoveResizeRangeHandle(x, y, target, this.cellEditor);
asc_applyFunction(callback, d);
};
WorkbookView.prototype._onMoveResizeRangeHandleDone = function (target) {
WorkbookView.prototype._onMoveResizeRangeHandleDone = function(target) {
var ws = this.getWorksheet();
ws.applyMoveResizeRangeHandle(target);
};
// Frozen anchor
WorkbookView.prototype._onMoveFrozenAnchorHandle = function (x, y, target) {
WorkbookView.prototype._onMoveFrozenAnchorHandle = function(x, y, target) {
var ws = this.getWorksheet();
ws.drawFrozenGuides(x, y, target);
};
WorkbookView.prototype._onMoveFrozenAnchorHandleDone = function (x, y, target) {
WorkbookView.prototype._onMoveFrozenAnchorHandleDone = function(x, y, target) {
// Закрепляем область
var ws = this.getWorksheet();
ws.applyFrozenAnchor(x, y, target);
......@@ -1125,14 +1123,15 @@
this.getWorksheet().autoFilters.onAutoFilterClick(idFilter);
};
WorkbookView.prototype._onCommentCellClick = function (x, y) {
WorkbookView.prototype._onCommentCellClick = function(x, y) {
var ws = this.getWorksheet();
var comments = ws.cellCommentator.getCommentsXY(x, y);
if (comments.length)
if (comments.length) {
ws.cellCommentator.showComment(comments[0].asc_getId());
}
};
WorkbookView.prototype._onUpdateSelectionName = function () {
WorkbookView.prototype._onUpdateSelectionName = function() {
if (this.canUpdateAfterShiftUp) {
this.canUpdateAfterShiftUp = false;
var ws = this.getWorksheet();
......@@ -1140,60 +1139,61 @@
}
};
WorkbookView.prototype._onStopFormatPainter = function () {
WorkbookView.prototype._onStopFormatPainter = function() {
var ws = this.getWorksheet();
if (ws.stateFormatPainter)
if (ws.stateFormatPainter) {
ws.formatPainter();
}
};
// Shapes
WorkbookView.prototype._onGraphicObjectMouseDown = function (e, x, y) {
WorkbookView.prototype._onGraphicObjectMouseDown = function(e, x, y) {
var ws = this.getWorksheet();
ws.objectRender.graphicObjectMouseDown(e, x, y);
};
WorkbookView.prototype._onGraphicObjectMouseMove = function (e, x, y) {
WorkbookView.prototype._onGraphicObjectMouseMove = function(e, x, y) {
var ws = this.getWorksheet();
ws.objectRender.graphicObjectMouseMove(e, x, y);
};
WorkbookView.prototype._onGraphicObjectMouseUp = function (e, x, y) {
WorkbookView.prototype._onGraphicObjectMouseUp = function(e, x, y) {
var ws = this.getWorksheet();
ws.objectRender.graphicObjectMouseUp(e, x, y);
};
WorkbookView.prototype._onGraphicObjectMouseUpEx = function (e, x, y) {
WorkbookView.prototype._onGraphicObjectMouseUpEx = function(e, x, y) {
//var ws = this.getWorksheet();
//ws.objectRender.coordsManager.calculateCell(x, y);
};
WorkbookView.prototype._onGraphicObjectWindowKeyDown = function (e) {
WorkbookView.prototype._onGraphicObjectWindowKeyDown = function(e) {
var ws = this.getWorksheet();
return ws.objectRender.graphicObjectKeyDown(e);
};
WorkbookView.prototype._onGraphicObjectWindowKeyPress = function (e) {
WorkbookView.prototype._onGraphicObjectWindowKeyPress = function(e) {
var ws = this.getWorksheet();
return ws.objectRender.graphicObjectKeyPress(e);
};
WorkbookView.prototype._onGetGraphicsInfo = function (x, y) {
WorkbookView.prototype._onGetGraphicsInfo = function(x, y) {
var ws = this.getWorksheet();
return ws.objectRender.checkCursorDrawingObject(x, y);
};
WorkbookView.prototype._onGetSelectedGraphicObjects = function () {
WorkbookView.prototype._onGetSelectedGraphicObjects = function() {
var ws = this.getWorksheet();
return ws.objectRender.getSelectedGraphicObjects();
};
WorkbookView.prototype._onUpdateSelectionShape = function (isSelectOnShape) {
WorkbookView.prototype._onUpdateSelectionShape = function(isSelectOnShape) {
var ws = this.getWorksheet();
return ws.setSelectionShape(isSelectOnShape);
};
// Double click
WorkbookView.prototype._onMouseDblClick = function (x, y, isHideCursor, callback) {
WorkbookView.prototype._onMouseDblClick = function(x, y, isHideCursor, callback) {
var ws = this.getWorksheet();
var ct = ws.getCursorTypeFromXY(x, y, this.controller.settings.isViewerMode);
......@@ -1201,13 +1201,12 @@
ct.target === c_oTargetType.ColumnResize ? ws.optimizeColWidth(ct.col) : ws.optimizeRowHeight(ct.row);
asc_applyFunction(callback);
} else {
if (ct.col >=0 && ct.row >= 0)
if (ct.col >= 0 && ct.row >= 0) {
this.controller.setStrictClose(!ws._isCellEmptyText(ct.col, ct.row));
}
// Для нажатия на колонку/строку/all/frozenMove обрабатывать dblClick не нужно
if (c_oTargetType.ColumnHeader === ct.target || c_oTargetType.RowHeader === ct.target ||
c_oTargetType.Corner === ct.target || c_oTargetType.FrozenAnchorH === ct.target ||
c_oTargetType.FrozenAnchorV === ct.target) {
if (c_oTargetType.ColumnHeader === ct.target || c_oTargetType.RowHeader === ct.target || c_oTargetType.Corner === ct.target || c_oTargetType.FrozenAnchorH === ct.target || c_oTargetType.FrozenAnchorV === ct.target) {
asc_applyFunction(callback);
return;
}
......@@ -1218,18 +1217,17 @@
}
// При dbl клике фокус выставляем в зависимости от наличия текста в ячейке
this._onEditCell (x, y, /*isCoord*/true, /*isFocus*/undefined, /*isClearCell*/undefined,
/*isHideCursor*/isHideCursor, /*isQuickInput*/false);
this._onEditCell(x, y, /*isCoord*/true, /*isFocus*/undefined, /*isClearCell*/undefined, /*isHideCursor*/isHideCursor, /*isQuickInput*/false);
}
};
WorkbookView.prototype._onEditCell = function (x, y, isCoord, isFocus, isClearCell, isHideCursor,
isQuickInput, callback, event) {
WorkbookView.prototype._onEditCell = function(x, y, isCoord, isFocus, isClearCell, isHideCursor, isQuickInput, callback, event) {
var t = this;
// Проверка глобального лока
if (this.collaborativeEditing.getGlobalLock() || this.controller.isResizeMode)
if (this.collaborativeEditing.getGlobalLock() || this.controller.isResizeMode) {
return;
}
var ws = t.getWorksheet();
var activeCellRange = ws.getActiveCell(x, y, isCoord);
......@@ -1238,9 +1236,7 @@
var editFunction = function() {
t.controller.setCellEditMode(true);
ws.setCellEditMode(true);
if (!ws.openCellEditor(t.cellEditor, x, y, isCoord, /*fragments*/undefined,
/*cursorPos*/undefined, isFocus, isClearCell,
/*isHideCursor*/isHideCursor, /*isQuickInput*/isQuickInput, /*activeRange*/arn)) {
if (!ws.openCellEditor(t.cellEditor, x, y, isCoord, /*fragments*/undefined, /*cursorPos*/undefined, isFocus, isClearCell, /*isHideCursor*/isHideCursor, /*isQuickInput*/isQuickInput, /*activeRange*/arn)) {
t.controller.setCellEditMode(false);
t.controller.setStrictClose(false);
t.controller.setFormulaEditMode(false);
......@@ -1255,18 +1251,19 @@
t.handlers.trigger("asc_onEditCell", c_oAscCellEditorState.editStart);
// Эвент от предыдущего нажатия на символ или на backspace
if (event) {
if ("keydown" === event.type)
if ("keydown" === event.type) {
t.cellEditor._onWindowKeyDown(event);
else if ("keypress" === event.type)
} else if ("keypress" === event.type) {
t.cellEditor._onWindowKeyPress(event);
}
}
// Эвент на обновление состояния редактора
t.cellEditor._updateEditorState();
asc_applyFunction(callback, true);
};
var editLockCallback = function (res) {
var editLockCallback = function(res) {
if (!res) {
t.controller.setCellEditMode(false);
t.controller.setStrictClose(false);
......@@ -1289,16 +1286,16 @@
}
};
WorkbookView.prototype._onStopCellEditing = function () {
WorkbookView.prototype._onStopCellEditing = function() {
return this.cellEditor.close(true);
};
WorkbookView.prototype._onCloseCellEditor = function () {
WorkbookView.prototype._onCloseCellEditor = function() {
this.controller.setCellEditMode(false);
this.controller.setStrictClose(false);
this.controller.setFormulaEditMode(false);
var ws = this.getWorksheet();
if( this.cellFormulaEnterWSOpen ){
if (this.cellFormulaEnterWSOpen) {
ws.setCellEditMode(false);
ws.setFormulaEditMode(false);
ws = this.cellFormulaEnterWSOpen;
......@@ -1306,21 +1303,22 @@
var isCellEditMode = ws.getCellEditMode();
ws.setCellEditMode(false);
ws.setFormulaEditMode(false);
if( this.cellFormulaEnterWSOpen ){
if (this.cellFormulaEnterWSOpen) {
this.cellFormulaEnterWSOpen = null;
var index = ws.model.getIndex();
this.showWorksheet(index);
this.handlers.trigger("asc_onActiveSheetChanged", index);
}
if( this.getWorksheet().model.getId() == ws.model.getId() ){
if (this.getWorksheet().model.getId() == ws.model.getId()) {
ws.updateSelection();
}
for(var i in this.wsViews){
for (var i in this.wsViews) {
this.wsViews[i].cleanFormulaRanges()
this.wsViews[i].setFormulaEditMode( false );
this.wsViews[i].setFormulaEditMode(false);
}
if (isCellEditMode)
if (isCellEditMode) {
this.handlers.trigger("asc_onEditCell", c_oAscCellEditorState.editEnd);
}
// Обновляем состояние Undo/Redo
History._sendCanUndoRedo();
// Обновляем состояние информации
......@@ -1335,18 +1333,18 @@
};
WorkbookView.prototype._onEmpty = function () {
WorkbookView.prototype._onEmpty = function() {
this.getWorksheet().emptySelection(c_oAscCleanOptions.Text);
};
WorkbookView.prototype._onAddColumn = function (isNotActive) {
WorkbookView.prototype._onAddColumn = function(isNotActive) {
var res = this.getWorksheet().expandColsOnScroll(isNotActive);
if (res) {
this.controller.reinitializeScroll(/*horizontal*/2);
}
};
WorkbookView.prototype._onAddRow = function (isNotActive) {
WorkbookView.prototype._onAddRow = function(isNotActive) {
var res = this.getWorksheet().expandRowsOnScroll(isNotActive);
if (res) { // Добавлены строки
// после добавления controller.settings.wheelScrollLines
......@@ -1355,10 +1353,11 @@
}
};
WorkbookView.prototype._onShowNextPrevWorksheet = function (direction) {
WorkbookView.prototype._onShowNextPrevWorksheet = function(direction) {
// Проверка на неправильное направление
if (0 === direction)
if (0 === direction) {
return false;
}
// Колличество листов
var countWorksheets = this.model.getWorksheetCount();
// Покажем следующий лист или предыдущий (если больше нет)
......@@ -1375,7 +1374,7 @@
return false;
};
WorkbookView.prototype._onSetFontAttributes = function (prop) {
WorkbookView.prototype._onSetFontAttributes = function(prop) {
var val;
var selectionInfo = this.getWorksheet().getSelectionInfo().asc_getFont();
switch (prop) {
......@@ -1397,41 +1396,44 @@
return this.setFontAttributes(prop, val);
};
WorkbookView.prototype._onSelectColumnsByRange = function () {
WorkbookView.prototype._onSelectColumnsByRange = function() {
this.getWorksheet()._selectColumnsByRange();
};
WorkbookView.prototype._onSelectRowsByRange = function () {
WorkbookView.prototype._onSelectRowsByRange = function() {
this.getWorksheet()._selectRowsByRange();
};
WorkbookView.prototype._onShowCellEditorCursor = function () {
WorkbookView.prototype._onShowCellEditorCursor = function() {
var ws = this.getWorksheet();
// Показываем курсор
if (ws.getCellEditMode())
if (ws.getCellEditMode()) {
this.cellEditor.showCursor();
}
};
WorkbookView.prototype._onDocumentPlaceChanged = function () {
if (this.isDocumentPlaceChangedEnabled)
WorkbookView.prototype._onDocumentPlaceChanged = function() {
if (this.isDocumentPlaceChangedEnabled) {
this.handlers.trigger("asc_onDocumentPlaceChanged");
}
};
WorkbookView.prototype.getTablePictures = function () {
WorkbookView.prototype.getTablePictures = function() {
var autoFilters = new asc.AutoFilters();
return autoFilters.getTablePictures(this.model, this.fmgrGraphics, this.m_oFont);
};
WorkbookView.prototype.getCellStyles = function () {
WorkbookView.prototype.getCellStyles = function() {
var oStylesPainter = new asc_CSP();
oStylesPainter.generateStylesAll(this.model.CellStyles, this.fmgrGraphics, this.m_oFont, this.stringRender);
return oStylesPainter;
};
WorkbookView.prototype.getWorksheetById = function (id) {
WorkbookView.prototype.getWorksheetById = function(id) {
var wsModel = this.model.getWorksheetById(id);
if (wsModel)
if (wsModel) {
return this.getWorksheet(wsModel.getIndex());
}
return null;
};
......@@ -1439,7 +1441,7 @@
* @param {Number} [index]
* @return {WorksheetView}
*/
WorkbookView.prototype.getWorksheet = function (index) {
WorkbookView.prototype.getWorksheet = function(index) {
var wb = this.model;
var i = asc_typeof(index) === "number" && index >= 0 ? index : wb.getActive();
var ws = this.wsViews[i];
......@@ -1458,18 +1460,20 @@
* @param [bLockDraw]
* @returns {WorkbookView}
*/
WorkbookView.prototype.showWorksheet = function (index, isResized, bLockDraw) {
if (index === this.wsActive) {return this;}
WorkbookView.prototype.showWorksheet = function(index, isResized, bLockDraw) {
if (index === this.wsActive) {
return this;
}
var isSendInfo = (-1 === this.wsActive) || !isResized,
tmpWorksheet, selectionRange = null;
var isSendInfo = (-1 === this.wsActive) || !isResized, tmpWorksheet, selectionRange = null;
// Только если есть активный
if (-1 !== this.wsActive) {
var ws = this.getWorksheet();
// Останавливаем ввод данных в редакторе ввода. Если в режиме ввода формул, то продолжаем работать с cellEditor'ом, чтобы можно было
// выбирать ячейки для формулы
if (ws.getCellEditMode() && !(this.cellEditor && this.cellEditor.isFormula()) && !isResized)
if (ws.getCellEditMode() && !(this.cellEditor && this.cellEditor.isFormula()) && !isResized) {
this._onStopCellEditing();
}
// Делаем очистку селекта
ws.cleanSelection();
this.stopTarget(ws);
......@@ -1479,20 +1483,20 @@
// if( ws && ws.getCellEditMode() && this.cellEditor.isFormula() ){
/*запоминаем лист, на котором был открыт редактор ячейки, для работы cellEditor в режиме ввода ячеек с другого листа*/
if (this.cellEditor) {
if( this.cellEditor.formulaIsOperator() ){
var _ws = this.getWorksheet()
if( !this.cellFormulaEnterWSOpen )
if (this.cellEditor.formulaIsOperator()) {
var _ws = this.getWorksheet();
if (!this.cellFormulaEnterWSOpen) {
this.cellFormulaEnterWSOpen = tmpWorksheet = _ws;
else{
} else {
this.cellEditor._showCanvas();
_ws.setFormulaEditMode(false);
}
}
else{
if (this.getWorksheet().getCellEditMode() && !isResized)
} else {
if (this.getWorksheet().getCellEditMode() && !isResized) {
this._onStopCellEditing();
}
}
}
// }
if (c_oAscSelectionDialogType.Chart === this.selectionDialogType) {
......@@ -1504,7 +1508,9 @@
var wb = this.model;
if (asc_typeof(index) === "number" && index >= 0) {
if (index !== wb.getActive()) {wb.setActive(index);}
if (index !== wb.getActive()) {
wb.setActive(index);
}
} else {
index = wb.getActive();
}
......@@ -1513,35 +1519,36 @@
ws = this.getWorksheet(index);
// Мы делали resize или меняли zoom, но не перерисовывали данный лист (он был не активный)
if (ws.updateResize && ws.updateZoom)
if (ws.updateResize && ws.updateZoom) {
ws.changeZoomResize();
else if (ws.updateResize)
} else if (ws.updateResize) {
ws.resize(true);
else if (ws.updateZoom)
} else if (ws.updateZoom) {
ws.changeZoom(true);
}
if (!bLockDraw)
if (!bLockDraw) {
ws.draw();
}
if (c_oAscSelectionDialogType.Chart === this.selectionDialogType) {
// Когда идет выбор диапазона, то на показываемом листе должны выставить нужный режим
ws.setSelectionDialogMode(this.selectionDialogType, selectionRange);
this.handlers.trigger("asc_onSelectionRangeChanged", ws.getSelectionRangeValue());
}
if (!bLockDraw)
{
if (!bLockDraw) {
ws.objectRender.controller.updateSelectionState();
ws.objectRender.controller.updateOverlay();
}
if (this.cellEditor) {
if( this.cellFormulaEnterWSOpen && ws.model.getId() == this.cellFormulaEnterWSOpen.model.getId() ){
if (this.cellFormulaEnterWSOpen && ws.model.getId() == this.cellFormulaEnterWSOpen.model.getId()) {
this.cellFormulaEnterWSOpen = null;
this.cellEditor._showCanvas();
}
if ( this.cellFormulaEnterWSOpen && this.cellFormulaEnterWSOpen.getCellEditMode() && this.cellEditor.isFormula() && ws.model.getId() != this.cellFormulaEnterWSOpen.model.getId() ) {
if (this.cellFormulaEnterWSOpen && this.cellFormulaEnterWSOpen.getCellEditMode() && this.cellEditor.isFormula() && ws.model.getId() != this.cellFormulaEnterWSOpen.model.getId()) {
/*скрываем cellEditor, в редактор добавляем %selected sheet name%+"!" */
this.cellFormulaEnterWSOpen.setFormulaEditMode( true );
this.cellFormulaEnterWSOpen.setFormulaEditMode(true);
this.cellEditor._hideCanvas();
ws.cleanSelection();
ws.setFormulaEditMode(true);
......@@ -1554,8 +1561,9 @@
this._onSelectionMathInfoChanged(ws.getSelectionMathInfo());
}
this.controller.reinitializeScroll();
if(this.Api.isMobileVersion)
if (this.Api.isMobileVersion) {
this.MobileTouchManager.Resize();
}
// Zoom теперь на каждом листе одинаковый, не отправляем смену
// Нужно очистить поиск
......@@ -1564,7 +1572,7 @@
};
/** @param nIndex {Number} массив индексов */
WorkbookView.prototype.removeWorksheet = function (nIndex) {
WorkbookView.prototype.removeWorksheet = function(nIndex) {
this.stopTarget(null);
this.wsViews.splice(nIndex, 1);
// Сбрасываем активный (чтобы не досчитывать после смены)
......@@ -1572,13 +1580,14 @@
};
// Меняет местами 2 элемента просмотра
WorkbookView.prototype.replaceWorksheet = function (indexFrom, indexTo) {
WorkbookView.prototype.replaceWorksheet = function(indexFrom, indexTo) {
// Только если есть активный
if (-1 !== this.wsActive) {
var ws = this.getWorksheet(this.wsActive);
// Останавливаем ввод данных в редакторе ввода
if (ws.getCellEditMode())
if (ws.getCellEditMode()) {
this._onStopCellEditing();
}
// Делаем очистку селекта
ws.cleanSelection();
......@@ -1587,25 +1596,28 @@
// Чтобы поменять, нужно его добавить
this.getWorksheet(indexTo);
}
var movedSheet = this.wsViews.splice(indexFrom,1);
this.wsViews.splice(indexTo,0,movedSheet[0])
var movedSheet = this.wsViews.splice(indexFrom, 1);
this.wsViews.splice(indexTo, 0, movedSheet[0])
};
WorkbookView.prototype.stopTarget = function (ws) {
if (null === ws && -1 !== this.wsActive)
WorkbookView.prototype.stopTarget = function(ws) {
if (null === ws && -1 !== this.wsActive) {
ws = this.getWorksheet(this.wsActive);
if (null !== ws && ws.objectRender && ws.objectRender.drawingDocument)
}
if (null !== ws && ws.objectRender && ws.objectRender.drawingDocument) {
ws.objectRender.drawingDocument.TargetEnd();
}
};
// Копирует элемент перед другим элементом
WorkbookView.prototype.copyWorksheet = function (index, insertBefore) {
WorkbookView.prototype.copyWorksheet = function(index, insertBefore) {
// Только если есть активный
if (-1 !== this.wsActive) {
var ws = this.getWorksheet();
// Останавливаем ввод данных в редакторе ввода
if (ws.getCellEditMode())
if (ws.getCellEditMode()) {
this._onStopCellEditing();
}
// Делаем очистку селекта
ws.cleanSelection();
......@@ -1613,26 +1625,27 @@
this.wsActive = -1;
}
if (null != insertBefore && insertBefore >= 0 && insertBefore < this.wsViews.length){
if (null != insertBefore && insertBefore >= 0 && insertBefore < this.wsViews.length) {
// Помещаем нулевой элемент перед insertBefore
this.wsViews.splice(insertBefore, 0, null);
}
};
WorkbookView.prototype.updateWorksheetByModel = function () {
WorkbookView.prototype.updateWorksheetByModel = function() {
// ToDo Сделал небольшую заглушку с показом листа. Нужно как мне кажется перейти от wsViews на wsViewsId (хранить по id)
var oldActiveWs;
if (-1 !== this.wsActive)
if (-1 !== this.wsActive) {
oldActiveWs = this.wsViews[this.wsActive];
}
//расставляем ws так как они идут в модели.
var oNewWsViews = [];
for (var i in this.wsViews)
{
for (var i in this.wsViews) {
var item = this.wsViews[i];
if (null != item && null != this.model.getWorksheetById(item.model.getId()))
if (null != item && null != this.model.getWorksheetById(item.model.getId())) {
oNewWsViews[item.model.getIndex()] = item;
}
}
this.wsViews = oNewWsViews;
var wsActive = this.model.getActive();
......@@ -1641,17 +1654,18 @@
// Если сменили, то покажем
this.wsActive = -1;
this.showWorksheet(undefined, false, true);
} else
} else {
this.wsActive = wsActive;
}
};
WorkbookView.prototype.spliceWorksheet = function () {
WorkbookView.prototype.spliceWorksheet = function() {
this.stopTarget(null);
this.wsViews.splice.apply(this.wsViews, arguments);
this.wsActive = -1;
};
WorkbookView.prototype._canResize = function () {
WorkbookView.prototype._canResize = function() {
var oldWidth = this.canvas.width;
var oldHeight = this.canvas.height;
var width = this.element.offsetWidth - (this.Api.isMobileVersion ? 0 : this.defaults.scroll.widthPx);
......@@ -1665,18 +1679,15 @@
height <<= 1;
}
if (oldWidth === width && oldHeight === height)
if (oldWidth === width && oldHeight === height) {
return false;
}
this.canvas.width = this.canvasOverlay.width = this.canvasGraphic.width =
this.canvasGraphicOverlay.width = width;
this.canvas.height = this.canvasOverlay.height = this.canvasGraphic.height =
this.canvasGraphicOverlay.height = height;
this.canvas.width = this.canvasOverlay.width = this.canvasGraphic.width = this.canvasGraphicOverlay.width = width;
this.canvas.height = this.canvasOverlay.height = this.canvasGraphic.height = this.canvasGraphicOverlay.height = height;
if (isRetina) {
this.canvas.style.width = this.canvasOverlay.style.width = this.canvasGraphic.style.width
= this.canvasGraphicOverlay.style.width = styleWidth + 'px';
this.canvas.style.height = this.canvasOverlay.style.height = this.canvasGraphic.style.height
= this.canvasGraphicOverlay.style.height = styleHeight + 'px';
this.canvas.style.width = this.canvasOverlay.style.width = this.canvasGraphic.style.width = this.canvasGraphicOverlay.style.width = styleWidth + 'px';
this.canvas.style.height = this.canvasOverlay.style.height = this.canvasGraphic.style.height = this.canvasGraphicOverlay.style.height = styleHeight + 'px';
}
// При смене ориентации у планшета, сбрасываются флаги у canvas!
......@@ -1687,11 +1698,11 @@
};
/** @param event {jQuery.Event} */
WorkbookView.prototype.resize = function (event) {
WorkbookView.prototype.resize = function(event) {
if (this._canResize()) {
var item;
var activeIndex = this.model.getActive();
for(var i in this.wsViews) {
for (var i in this.wsViews) {
item = this.wsViews[i];
// Делаем resize (для не активных сменим как только сделаем его активным)
item.resize(/*isDraw*/i == activeIndex);
......@@ -1699,34 +1710,36 @@
this.showWorksheet(undefined, true);
} else {
// ToDo не должно происходить ничего, но нам приходит resize сверху, поэтому проверим отрисовывали ли мы
if (-1 === this.wsActive || this.wsMustDraw)
if (-1 === this.wsActive || this.wsMustDraw) {
this.showWorksheet(undefined, true);
}
}
this.wsMustDraw = false;
};
// Получаем свойство: редактируем мы сейчас или нет
WorkbookView.prototype.getCellEditMode = function () {
WorkbookView.prototype.getCellEditMode = function() {
return this.controller.isCellEditMode;
};
WorkbookView.prototype.getIsTrackShape = function(){
WorkbookView.prototype.getIsTrackShape = function() {
var ws = this.getWorksheet();
if(!ws){
if (!ws) {
return false;
}
if(ws.objectRender && ws.objectRender.controller){
if (ws.objectRender && ws.objectRender.controller) {
return ws.objectRender.controller.checkTrackDrawings();
}
};
WorkbookView.prototype.getZoom = function () {
WorkbookView.prototype.getZoom = function() {
return this.drawingCtx.getZoom();
};
WorkbookView.prototype.changeZoom = function (factor) {
if (factor === this.getZoom())
WorkbookView.prototype.changeZoom = function(factor) {
if (factor === this.getZoom()) {
return;
}
this.buffers.main.changeZoom(factor);
this.buffers.overlay.changeZoom(factor);
......@@ -1739,7 +1752,7 @@
var item;
var activeIndex = this.model.getActive();
for(i in this.wsViews) {
for (i in this.wsViews) {
item = this.wsViews[i];
// Меняем zoom (для не активных сменим как только сделаем его активным)
item.changeZoom(/*isDraw*/i == activeIndex);
......@@ -1751,21 +1764,23 @@
}
this.controller.reinitializeScroll();
this.handlers.trigger("asc_onZoomChanged",this.getZoom());
this.handlers.trigger("asc_onZoomChanged", this.getZoom());
};
WorkbookView.prototype.enableKeyEventsHandler = function (f) {
WorkbookView.prototype.enableKeyEventsHandler = function(f) {
this.controller.enableKeyEventsHandler(f);
if (this.cellEditor)
if (this.cellEditor) {
this.cellEditor.enableKeyEventsHandler(f);
}
};
// Останавливаем ввод данных в редакторе ввода
WorkbookView.prototype.closeCellEditor = function () {
WorkbookView.prototype.closeCellEditor = function() {
var ws = this.getWorksheet();
// Останавливаем ввод данных в редакторе ввода
if (ws.getCellEditMode() && !this.cellEditor.formulaIsOperator() /*&& !this.cellFormulaEnterWSOpen*/)
if (ws.getCellEditMode() && !this.cellEditor.formulaIsOperator() /*&& !this.cellFormulaEnterWSOpen*/) {
this._onStopCellEditing();
}
};
WorkbookView.prototype.restoreFocus = function() {
......@@ -1910,54 +1925,59 @@
}
};
WorkbookView.prototype.copyToClipboard = function () {
WorkbookView.prototype.copyToClipboard = function() {
var t = this, ws, v;
if (!t.controller.isCellEditMode) {
ws = t.getWorksheet();
t.clipboard.copyRange(ws.getSelectedRange(), ws);
} else {
v = t.cellEditor.copySelection();
if (v) {t.clipboard.copyCellValue(v);}
if (v) {
t.clipboard.copyCellValue(v);
}
}
};
WorkbookView.prototype.copyToClipboardButton = function () {
WorkbookView.prototype.copyToClipboardButton = function() {
var t = this, ws, v;
if (!t.controller.isCellEditMode) {
ws = t.getWorksheet();
return t.clipboard.copyRangeButton(ws.getSelectedRange(), ws);
} else {
v = t.cellEditor.copySelection();
if (v) {return t.clipboard.copyCellValueButton(v);}
else {return true;}
if (v) {
return t.clipboard.copyCellValueButton(v);
} else {
return true;
}
}
};
WorkbookView.prototype.pasteFromClipboard = function () {
WorkbookView.prototype.pasteFromClipboard = function() {
var t = this;
if (!t.controller.isCellEditMode) {
var ws = t.getWorksheet();
t.clipboard.pasteRange(ws);
} else {
t.clipboard.pasteAsText(function (text) {
t.clipboard.pasteAsText(function(text) {
t.cellEditor.pasteText(text);
});
}
};
WorkbookView.prototype.pasteFromClipboardButton = function () {
WorkbookView.prototype.pasteFromClipboardButton = function() {
var t = this;
if (!t.controller.isCellEditMode) {
var ws = t.getWorksheet();
return t.clipboard.pasteRangeButton(ws);
} else {
return t.clipboard.pasteAsTextButton(function (text) {
return t.clipboard.pasteAsTextButton(function(text) {
t.cellEditor.pasteText(text);
});
}
};
WorkbookView.prototype.cutToClipboard = function () {
WorkbookView.prototype.cutToClipboard = function() {
var t = this, ws, v;
if (!t.controller.isCellEditMode && !window.USER_AGENT_SAFARI_MACOS) {
ws = t.getWorksheet();
......@@ -1968,32 +1988,38 @@
t.clipboard.copyRange(ws.getSelectedRange(), ws, true);
ws.emptySelection(c_oAscCleanOptions.All);
} else if(!window.USER_AGENT_SAFARI_MACOS){
} else if (!window.USER_AGENT_SAFARI_MACOS) {
v = t.cellEditor.cutSelection();
if (v) {t.clipboard.copyCellValue(v);}
if (v) {
t.clipboard.copyCellValue(v);
}
}
};
WorkbookView.prototype.bIsEmptyClipboard = function () {
WorkbookView.prototype.bIsEmptyClipboard = function() {
return this.clipboard.bIsEmptyClipboard(this.controller.isCellEditMode);
};
WorkbookView.prototype.cutToClipboardButton = function () {
WorkbookView.prototype.cutToClipboardButton = function() {
var t = this, ws, v;
if (!t.controller.isCellEditMode) {
ws = t.getWorksheet();
var result = t.clipboard.copyRangeButton(ws.getSelectedRange(), ws, true);
if(result)
if (result) {
ws.emptySelection(c_oAscCleanOptions.All);
}
return result;
} else {
v = t.cellEditor.cutSelection();
if (v) {return t.clipboard.copyCellValueButton(v);}
else {return true;}
if (v) {
return t.clipboard.copyCellValueButton(v);
} else {
return true;
}
}
};
WorkbookView.prototype.undo = function () {
WorkbookView.prototype.undo = function() {
if (!this.controller.isCellEditMode) {
if (!History.Undo() && this.collaborativeEditing.getFast() && this.collaborativeEditing.getCollaborativeEditing()) {
this.Api.sync_TryUndoInFastCollaborative();
......@@ -2003,7 +2029,7 @@
}
};
WorkbookView.prototype.redo = function () {
WorkbookView.prototype.redo = function() {
if (!this.controller.isCellEditMode) {
History.Redo();
} else {
......@@ -2011,7 +2037,7 @@
}
};
WorkbookView.prototype.setFontAttributes = function (prop, val) {
WorkbookView.prototype.setFontAttributes = function(prop, val) {
if (!this.controller.isCellEditMode) {
this.getWorksheet().setSelectionInfo(prop, val);
} else {
......@@ -2019,7 +2045,7 @@
}
};
WorkbookView.prototype.changeFontSize = function (prop, val) {
WorkbookView.prototype.changeFontSize = function(prop, val) {
if (!this.controller.isCellEditMode) {
this.getWorksheet().setSelectionInfo(prop, val);
} else {
......@@ -2027,7 +2053,7 @@
}
};
WorkbookView.prototype.emptyCells = function (options) {
WorkbookView.prototype.emptyCells = function(options) {
if (!this.controller.isCellEditMode) {
this.getWorksheet().emptySelection(options);
this.restoreFocus();
......@@ -2036,9 +2062,10 @@
}
};
WorkbookView.prototype.setSelectionDialogMode = function (selectionDialogType, selectRange) {
if (selectionDialogType === this.selectionDialogType)
WorkbookView.prototype.setSelectionDialogMode = function(selectionDialogType, selectRange) {
if (selectionDialogType === this.selectionDialogType) {
return;
}
if (c_oAscSelectionDialogType.None === selectionDialogType) {
this.selectionDialogType = selectionDialogType;
......@@ -2058,9 +2085,9 @@
if (c_oAscSelectionDialogType.Chart === selectionDialogType) {
// Получаем sheet по имени
var ws = this.model.getWorksheetByName(tmpSelectRange.sheet);
if (!ws || ws.getHidden())
if (!ws || ws.getHidden()) {
tmpSelectRange = null;
else {
} else {
index = ws.getIndex();
this.showWorksheet(index);
// Посылаем эвент о смене активного листа
......@@ -2068,9 +2095,9 @@
tmpSelectRange = tmpSelectRange.range;
}
}
else
} else {
tmpSelectRange = tmpSelectRange.range;
}
} else {
// Это не 3D ссылка
tmpSelectRange = selectRange;
......@@ -2083,20 +2110,21 @@
}
};
WorkbookView.prototype._cleanFindResults = function () {
WorkbookView.prototype._cleanFindResults = function() {
this.lastFindOptions = null;
this.lastFindResults = {};
};
// Поиск текста в листе
WorkbookView.prototype.findCellText = function (options) {
WorkbookView.prototype.findCellText = function(options) {
// Для поиска эта переменная не нужна (но она может остаться от replace)
options.activeRange = null;
var ws = this.getWorksheet();
// Останавливаем ввод данных в редакторе ввода
if (ws.getCellEditMode())
if (ws.getCellEditMode()) {
this._onStopCellEditing();
}
var result = ws.findCellText(options);
if (false === options.scanOnOnlySheet) {
// Поиск по всей книге
......@@ -2110,13 +2138,15 @@
for (i = active + inc; i < end && i >= start; i += inc) {
tmpWs = this.getWorksheet(i);
tmpResult = tmpWs.findCellText(options);
if (tmpResult)
if (tmpResult) {
break;
}
}
if (!tmpResult) {
// Мы дошли до конца или начала (в зависимости от направления, теперь пойдем до активного)
if (options.scanForward) {
i = 0; end = active;
i = 0;
end = active;
} else {
i = end - 1;
start = active + 1;
......@@ -2125,17 +2155,18 @@
for (; i < end && i >= start; i += inc) {
tmpWs = this.getWorksheet(i);
tmpResult = tmpWs.findCellText(options);
if (tmpResult)
if (tmpResult) {
break;
}
}
}
if (tmpResult) {
ws = tmpWs;
result = tmpResult;
this.showWorksheet(i);
// Посылаем эвент о смене активного листа
this.handlers.trigger ("asc_onActiveSheetChanged", i);
this.handlers.trigger("asc_onActiveSheetChanged", i);
key = result.c1 + "-" + result.r1;
}
......@@ -2148,18 +2179,20 @@
}
}
if (result)
if (result) {
return ws._setActiveCell(result.c1, result.r1);
}
this._cleanFindResults();
return null;
};
// Замена текста в листе
WorkbookView.prototype.replaceCellText = function (options) {
WorkbookView.prototype.replaceCellText = function(options) {
var ws = this.getWorksheet();
// Останавливаем ввод данных в редакторе ввода
if (ws.getCellEditMode())
if (ws.getCellEditMode()) {
this._onStopCellEditing();
}
History.Create_NewPoint();
History.StartTransaction();
......@@ -2172,13 +2205,14 @@
ws.replaceCellText(options, false, this.fReplaceCallback);
};
WorkbookView.prototype._replaceCellTextCallback = function (options) {
WorkbookView.prototype._replaceCellTextCallback = function(options) {
options.updateFindAll();
if (!options.scanOnOnlySheet && options.isReplaceAll) {
// Замена на всей книге
var i = ++options.sheetIndex;
if (this.model.getActive() === i)
if (this.model.getActive() === i) {
i = ++options.sheetIndex;
}
if (i < this.model.getWorksheetCount()) {
var ws = this.getWorksheet(i);
......@@ -2197,55 +2231,55 @@
};
// Поиск ячейки по ссылке
WorkbookView.prototype.findCell = function (reference) {
WorkbookView.prototype.findCell = function(reference) {
var ws = this.getWorksheet(), retRange;
// Останавливаем ввод данных в редакторе ввода
if (ws.getCellEditMode())
if (ws.getCellEditMode()) {
this._onStopCellEditing();
}
return ws.findCell(reference);
};
WorkbookView.prototype.getDefinedNames = function (defNameListId) {
WorkbookView.prototype.getDefinedNames = function(defNameListId) {
return this.model.getDefinedNamesWB(defNameListId);
};
WorkbookView.prototype.setDefinedNames = function (defName) {
WorkbookView.prototype.setDefinedNames = function(defName) {
//ToDo проверка defName.ref на знак "=" в начале ссылки. знака нет тогда это либо число либо строка, так делает Excel.
this.model.setDefinesNames(defName.Name,defName.Ref,defName.Scope);
this.model.setDefinesNames(defName.Name, defName.Ref, defName.Scope);
this.handlers.trigger("asc_onDefName");
};
WorkbookView.prototype.checkDefName = function (checkName,scope) {
WorkbookView.prototype.checkDefName = function(checkName, scope) {
return this.model.checkDefName(checkName,scope);
return this.model.checkDefName(checkName, scope);
};
WorkbookView.prototype.editDefinedNames = function (oldName, newName) {
WorkbookView.prototype.editDefinedNames = function(oldName, newName) {
//ToDo проверка defName.ref на знак "=" в начале ссылки. знака нет тогда это либо число либо строка, так делает Excel.
if (this.collaborativeEditing.getGlobalLock())
if (this.collaborativeEditing.getGlobalLock()) {
return;
}
var ws = this.getWorksheet(),
t = this;
var ws = this.getWorksheet(), t = this;
var editDefinedNamesCallback = function (res) {
var editDefinedNamesCallback = function(res) {
if (res) {
t.model.editDefinesNames(oldName, newName);
t.handlers.trigger("asc_onEditDefName", oldName, newName);
t.handlers.trigger("asc_onRefreshDefNameList");
}
else{
t.handlers.trigger("asc_onError",c_oAscError.ID.LockCreateDefName,c_oAscError.Level.NoCritical);
} else {
t.handlers.trigger("asc_onError", c_oAscError.ID.LockCreateDefName, c_oAscError.Level.NoCritical);
}
t._onSelectionNameChanged(ws.getSelectionName(/*bRangeText*/false));
};
var defNameId;
if( oldName ){
if (oldName) {
defNameId = t.model.getDefinedName(oldName);
defNameId = defNameId ? defNameId.nodeId : null;
}
......@@ -2254,23 +2288,22 @@
};
WorkbookView.prototype.delDefinedNames = function (oldName) {
WorkbookView.prototype.delDefinedNames = function(oldName) {
//ToDo проверка defName.ref на знак "=" в начале ссылки. знака нет тогда это либо число либо строка, так делает Excel.
if (this.collaborativeEditing.getGlobalLock())
if (this.collaborativeEditing.getGlobalLock()) {
return;
}
var ws = this.getWorksheet(),
t = this
var ws = this.getWorksheet(), t = this
if( oldName ){
if (oldName) {
var delDefinedNamesCallback = function (res) {
var delDefinedNamesCallback = function(res) {
if (res) {
t.handlers.trigger("asc_onDelDefName", t.model.delDefinesNames(oldName));
t.handlers.trigger("asc_onRefreshDefNameList");
}
else{
t.handlers.trigger("asc_onError",c_oAscError.ID.LockCreateDefName,c_oAscError.Level.NoCritical);
} else {
t.handlers.trigger("asc_onError", c_oAscError.ID.LockCreateDefName, c_oAscError.Level.NoCritical);
}
t._onSelectionNameChanged(ws.getSelectionName(/*bRangeText*/false));
};
......@@ -2282,26 +2315,26 @@
};
WorkbookView.prototype.getDefaultDefinedName = function () {
WorkbookView.prototype.getDefaultDefinedName = function() {
//ToDo проверка defName.ref на знак "=" в начале ссылки. знака нет тогда это либо число либо строка, так делает Excel.
var ws = this.getWorksheet();
return new Asc.asc_CDefName( "", ws.getSelectionRangeValue(), null );
return new Asc.asc_CDefName("", ws.getSelectionRangeValue(), null);
};
WorkbookView.prototype.unlockDefName = function () {
WorkbookView.prototype.unlockDefName = function() {
this.model.unlockDefName();
this.handlers.trigger("asc_onRefreshDefNameList");
this.handlers.trigger("asc_onLockDefNameManager",c_oAscDefinedNameReason.OK);
this.handlers.trigger("asc_onLockDefNameManager", c_oAscDefinedNameReason.OK);
};
WorkbookView.prototype._onCheckDefNameLock = function () {
WorkbookView.prototype._onCheckDefNameLock = function() {
return this.model.checkDefNameLock();
};
// Печать
WorkbookView.prototype.printSheet = function (pdf_writer, printPagesData) {
WorkbookView.prototype.printSheet = function(pdf_writer, printPagesData) {
var ws;
// Закончили печать или нет
var isEndPrint = false;
......@@ -2327,7 +2360,7 @@
return isEndPrint;
};
WorkbookView.prototype.calcPagesPrint = function (adjustPrint) {
WorkbookView.prototype.calcPagesPrint = function(adjustPrint) {
var ws = null;
var wb = this.model;
var activeWs;
......@@ -2347,8 +2380,9 @@
ws = this.getWorksheet(i);
var arrPages = ws.calcPagesPrint(wb.getWorksheet(i).PagePrintOptions, /*printOnlySelection*/false, /*indexWorksheet*/i, bFitToWidth, bFitToHeight);
if (null !== arrPages) {
if (null === printPagesData.arrPages)
if (null === printPagesData.arrPages) {
printPagesData.arrPages = [];
}
printPagesData.arrPages = printPagesData.arrPages.concat(arrPages);
}
}
......@@ -2364,13 +2398,13 @@
// Вызывать только для нативной печати
WorkbookView.prototype._nativeCalculate = function() {
var item;
for(var i in this.wsViews) {
for (var i in this.wsViews) {
item = this.wsViews[i];
item._prepareDrawingObjects();
}
};
WorkbookView.prototype._initCommentsToSave = function () {
WorkbookView.prototype._initCommentsToSave = function() {
var isFirst = true;
for (var wsKey in this.wsViews) {
var wsView = this.wsViews[wsKey];
......@@ -2391,25 +2425,26 @@
}
};
WorkbookView.prototype.reInit = function () {
WorkbookView.prototype.reInit = function() {
var ws = this.getWorksheet();
ws._initCellsArea(/*fullRecalc*/true);
ws._updateVisibleColsCount();
ws._updateVisibleRowsCount();
};
WorkbookView.prototype.drawWS = function (){
WorkbookView.prototype.drawWS = function() {
this.getWorksheet().draw();
};
WorkbookView.prototype.onShowDrawingObjects = function (clearCanvas) {
WorkbookView.prototype.onShowDrawingObjects = function(clearCanvas) {
var ws = this.getWorksheet();
ws.objectRender.showDrawingObjects(clearCanvas);
};
WorkbookView.prototype.insertHyperlink = function (options) {
WorkbookView.prototype.insertHyperlink = function(options) {
var ws = this.getWorksheet();
if ( ws.objectRender.selectedGraphicObjectsExists() ) {
if ( ws.objectRender.controller.canAddHyperlink() )
if (ws.objectRender.selectedGraphicObjectsExists()) {
if (ws.objectRender.controller.canAddHyperlink()) {
ws.objectRender.controller.insertHyperlink(options);
}
} else {
// На всякий случай проверка (вдруг кто собирается вызвать...)
this.closeCellEditor();
......@@ -2417,16 +2452,16 @@
this.restoreFocus();
}
};
WorkbookView.prototype.removeHyperlink = function () {
WorkbookView.prototype.removeHyperlink = function() {
var ws = this.getWorksheet();
if (ws.objectRender.selectedGraphicObjectsExists())
if (ws.objectRender.selectedGraphicObjectsExists()) {
ws.objectRender.controller.removeHyperlink();
else {
} else {
ws.setSelectionInfo("rh");
}
};
WorkbookView.prototype.setDocumentPlaceChangedEnabled = function (val) {
WorkbookView.prototype.setDocumentPlaceChangedEnabled = function(val) {
this.isDocumentPlaceChangedEnabled = val;
};
......@@ -2434,16 +2469,17 @@
* @param {c_oAscRenderingModeType} mode Режим отрисовки
* @param {Boolean} isInit инициализация или нет
*/
WorkbookView.prototype.setFontRenderingMode = function (mode, isInit) {
WorkbookView.prototype.setFontRenderingMode = function(mode, isInit) {
var ws;
if (mode !== this.fontRenderingMode) {
this.fontRenderingMode = mode;
if (c_oAscFontRenderingModeType.noHinting === mode)
if (c_oAscFontRenderingModeType.noHinting === mode) {
this._setHintsProps(false, false);
else if (c_oAscFontRenderingModeType.hinting === mode)
} else if (c_oAscFontRenderingModeType.hinting === mode) {
this._setHintsProps(true, false);
else if (c_oAscFontRenderingModeType.hintingAndSubpixeling === mode)
} else if (c_oAscFontRenderingModeType.hintingAndSubpixeling === mode) {
this._setHintsProps(true, true);
}
if (!isInit) {
ws = this.getWorksheet();
......@@ -2453,20 +2489,21 @@
}
};
WorkbookView.prototype.initFormulasList = function () {
WorkbookView.prototype.initFormulasList = function() {
this.formulasList = [];
var oFormulaList = cFormulaFunctionLocalized ? cFormulaFunctionLocalized : cFormulaFunction;
for (var f in oFormulaList)
this.formulasList.push(f);
};
WorkbookView.prototype._setHintsProps = function (bIsHinting, bIsSubpixHinting) {
WorkbookView.prototype._setHintsProps = function(bIsHinting, bIsSubpixHinting) {
var manager, hintProps;
for (var i = 0, length = this.fmgrGraphics.length; i < length; ++i) {
manager = this.fmgrGraphics[i];
hintProps = manager.m_oLibrary.tt_hint_props;
if (!hintProps)
if (!hintProps) {
continue;
}
// Последний без хинтования (только для измерения)
if (i === length - 1) {
......@@ -2494,12 +2531,13 @@
}
};
WorkbookView.prototype._calcMaxDigitWidth = function () {
WorkbookView.prototype._calcMaxDigitWidth = function() {
// set default worksheet header font for calculations
this.buffers.main.setFont(this.defaultFont);
// Измеряем в pt
this.stringRender.measureString(
"0123456789", {wrapText: false, shrinkToFit: false, isMerged: false, textAlign: /*khaLeft*/"left"});
this.stringRender.measureString("0123456789", {
wrapText: false, shrinkToFit: false, isMerged: false, textAlign: /*khaLeft*/"left"
});
var ppiX = 96; // Мерить только с 96
var ptConvToPx = asc_getcvt(1/*pt*/, 0/*px*/, ppiX);
......@@ -2510,7 +2548,9 @@
this.maxDigitWidth = asc_round(maxWidthInPt * ptConvToPx);
// Проверка для Calibri 11 должно быть this.maxDigitWidth = 7
if (!this.maxDigitWidth) {throw "Error: can't measure text string";}
if (!this.maxDigitWidth) {
throw "Error: can't measure text string";
}
// Padding рассчитывается исходя из maxDigitWidth (http://social.msdn.microsoft.com/Forums/en-US/9a6a9785-66ad-4b6b-bb9f-74429381bd72/margin-padding-in-cell-excel?forum=os_binaryfile)
this.defaults.worksheetView.cells.padding = Math.max(asc.ceil(this.maxDigitWidth / 4), 2);
......@@ -2522,5 +2562,4 @@
* -----------------------------------------------------------------------------
*/
window["Asc"].WorkbookView = WorkbookView;
}
)(jQuery, window);
})(jQuery, window);
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