DocumentServer/OfficeWeb/sdk/Excel/model/DrawingObjects/Format/ChartLayout.js
nikolay ivanov a8be6b9e72 init repo
2014-07-05 18:22:49 +00:00

175 lines
6.1 KiB
JavaScript

/*
* (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
*
*/
var LAYOUT_MODE_EDGE = 0;
var LAYOUT_MODE_FACTOR = 1;
var LAYOUT_TARGET_INNER = 0;
var LAYOUT_TARGET_OUTER = 1;
function CChartLayout() {
this.isManual = false;
this.layoutTarget = null;
this.xMode = null;
this.yMode = null;
this.wMode = null;
this.hMode = null;
this.x = null;
this.y = null;
this.w = null;
this.h = null;
this.Id = g_oIdCounter.Get_NewId();
g_oTableId.Add(this, this.Id, null);
}
CChartLayout.prototype = {
Get_Id: function () {
return this.Id;
},
getObjectType: function () {
return CLASS_TYPE_CHART_LAYOUT;
},
setXMode: function (mode) {
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_Layout_Set_X_Mode, null, null, new UndoRedoDataGraphicObjects(this.Id, new UndoRedoDataGOSingleProp(this.xMode, mode)), null);
this.xMode = mode;
},
setYMode: function (mode) {
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_Layout_Set_Y_Mode, null, null, new UndoRedoDataGraphicObjects(this.Id, new UndoRedoDataGOSingleProp(this.yMode, mode)), null);
this.yMode = mode;
},
setX: function (x) {
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_Layout_Set_X, null, null, new UndoRedoDataGraphicObjects(this.Id, new UndoRedoDataGOSingleProp(this.x, x)), null);
this.x = x;
},
setY: function (y) {
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_Layout_Set_Y, null, null, new UndoRedoDataGraphicObjects(this.Id, new UndoRedoDataGOSingleProp(this.y, y)), null);
this.y = y;
},
setIsManual: function (isManual) {
this.isManual = isManual;
},
Undo: function (type, data) {
switch (type) {
case historyitem_AutoShapes_Layout_Set_X_Mode:
this.xMode = data.oldValue;
break;
case historyitem_AutoShapes_Layout_Set_Y_Mode:
this.yMode = data.oldValue;
break;
case historyitem_AutoShapes_Layout_Set_X:
this.x = data.oldValue;
break;
case historyitem_AutoShapes_Layout_Set_Y:
this.y = data.oldValue;
break;
}
},
Redo: function (type, data) {
switch (type) {
case historyitem_AutoShapes_Layout_Set_X_Mode:
this.xMode = data.newValue;
break;
case historyitem_AutoShapes_Layout_Set_Y_Mode:
this.yMode = data.newValue;
break;
case historyitem_AutoShapes_Layout_Set_X:
this.x = data.newValue;
break;
case historyitem_AutoShapes_Layout_Set_Y:
this.y = data.newValue;
break;
}
},
writeToBinary: function (w) {
w.WriteBool(isRealNumber(this.layoutTarget));
if (isRealNumber(this.layoutTarget)) {
w.WriteLong(this.layoutTarget);
}
w.WriteBool(isRealNumber(this.xMode));
if (isRealNumber(this.xMode)) {
w.WriteLong(this.xMode);
}
w.WriteBool(isRealNumber(this.yMode));
if (isRealNumber(this.yMode)) {
w.WriteLong(this.yMode);
}
w.WriteBool(isRealNumber(this.wMode));
if (isRealNumber(this.wMode)) {
w.WriteLong(this.wMode);
}
w.WriteBool(isRealNumber(this.hMode));
if (isRealNumber(this.hMode)) {
w.WriteLong(this.hMode);
}
w.WriteBool(isRealNumber(this.x));
if (isRealNumber(this.x)) {
w.WriteDouble(this.x);
}
w.WriteBool(isRealNumber(this.y));
if (isRealNumber(this.y)) {
w.WriteDouble(this.y);
}
w.WriteBool(isRealNumber(this.w));
if (isRealNumber(this.w)) {
w.WriteDouble(this.w);
}
w.WriteBool(isRealNumber(this.h));
if (isRealNumber(this.h)) {
w.WriteDouble(this.h);
}
},
readFromBinary: function (r) {
if (r.GetBool()) {
this.layoutTarget = r.GetLong();
}
if (r.GetBool()) {
this.setXMode(r.GetLong());
}
if (r.GetBool()) {
this.setYMode(r.GetLong());
}
if (r.GetBool()) {
this.wMode = r.GetLong();
}
if (r.GetBool()) {
this.hMode = r.GetLong();
}
if (r.GetBool()) {
this.setX(r.GetDouble());
}
if (r.GetBool()) {
this.setY(r.GetDouble());
}
if (r.GetBool()) {
this.w = r.GetDouble();
}
if (r.GetBool()) {
this.h = r.GetDouble();
}
}
};