init repo
This commit is contained in:
288
OfficeWeb/apps/spreadsheeteditor/main/app/controller/CellEdit.js
Normal file
288
OfficeWeb/apps/spreadsheeteditor/main/app/controller/CellEdit.js
Normal file
@@ -0,0 +1,288 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
Ext.define("SSE.controller.CellEdit", {
|
||||
extend: "Ext.app.Controller",
|
||||
views: ["CellInfo"],
|
||||
refs: [{
|
||||
ref: "infoBox",
|
||||
selector: "ssecellinfo"
|
||||
},
|
||||
{
|
||||
ref: "dlgFormula",
|
||||
selector: "sseformuladialog"
|
||||
},
|
||||
{
|
||||
ref: "formulaList",
|
||||
selector: "#formulas-list"
|
||||
},
|
||||
{
|
||||
ref: "toolBar",
|
||||
selector: "ssetoolbar"
|
||||
},
|
||||
{
|
||||
ref: "cellTextBox",
|
||||
selector: "#infobox-cell-edit"
|
||||
},
|
||||
{
|
||||
ref: "buttonExpand",
|
||||
selector: "#infobox-cell-multiline-button"
|
||||
}],
|
||||
init: function () {
|
||||
this.control({
|
||||
"sseformuladialog": {
|
||||
beforeshow: function (o, eOpts) {},
|
||||
show: function () {
|
||||
this.getFormulaList().getSelectionModel().select(0);
|
||||
this.getDlgFormula().focus(undefined, 100);
|
||||
},
|
||||
beforerender: function () {
|
||||
if (! (this.getFormulaList().getStore().getCount() > 0)) {
|
||||
this._reloadFormulas();
|
||||
}
|
||||
this.getDlgFormula().setGroups(this.arrGroups);
|
||||
},
|
||||
hide: function () {
|
||||
this.getToolBar().fireEvent("editcomplete", this.getToolBar());
|
||||
}
|
||||
},
|
||||
"sseformuladialog #formulas-group-combo": {
|
||||
select: function (combo, records, eOpts) {
|
||||
this.getFormulaList().getStore().clearFilter();
|
||||
if (records[0].data["groupid"] !== "all") {
|
||||
this.getFormulaList().getStore().filter("group", records[0].data["groupid"]);
|
||||
}
|
||||
}
|
||||
},
|
||||
"sseformuladialog #formulas-button-ok": {
|
||||
click: function (btn) {
|
||||
var data = this.getFormulaList().getSelectionModel().getSelection()[0].data;
|
||||
this.api.asc_insertFormula(data.func);
|
||||
this.getDlgFormula().hide();
|
||||
}
|
||||
},
|
||||
"#formulas-list > gridview": {
|
||||
afterrender: function (cmp) {
|
||||
this.funcSearch = {
|
||||
index: 0,
|
||||
update: false,
|
||||
word: ""
|
||||
};
|
||||
cmp.addElListener("keypress", Ext.bind(this.keypressFormulasList, this));
|
||||
}
|
||||
},
|
||||
"#toolbar-button-insertformula": {
|
||||
click: function (btn) {
|
||||
this._handleInsertFormula(btn.menu, {
|
||||
func: "SUM"
|
||||
});
|
||||
}
|
||||
},
|
||||
"#toolbar-menu-insertformula": {
|
||||
click: this._handleInsertFormula
|
||||
},
|
||||
"#infobox-cell-edit": {
|
||||
blur: function (o) {
|
||||
if (this.api.isTextAreaBlur !== null) {
|
||||
this.api.isTextAreaBlur = true;
|
||||
}
|
||||
},
|
||||
specialkey: function (o, e) {
|
||||
if (e.getKey() == e.ENTER && !e.altKey) {
|
||||
this.api.isTextAreaBlur = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
"ssecellinfo #infobox-cell-name": {
|
||||
specialkey: function (o, e) {
|
||||
if (e.getKey() == e.ENTER) {
|
||||
this.api.asc_findCell(o.getValue());
|
||||
this.getInfoBox().fireEvent("editcomplete", this.getInfoBox());
|
||||
}
|
||||
}
|
||||
},
|
||||
"ssecellinfo": {
|
||||
resize: function (o, adjWidth, adjHeight, opts) {
|
||||
this.getButtonExpand()[adjHeight > 23 ? "addCls" : "removeCls"]("button-collapse");
|
||||
}
|
||||
},
|
||||
"ssecellinfo #infobox-cell-multiline-button": {
|
||||
click: this._expandFormulaField
|
||||
},
|
||||
"#field-formula-splitter": {
|
||||
beforedragstart: function (obj, event) {
|
||||
return event.currentTarget && !event.currentTarget.disabled;
|
||||
},
|
||||
move: function (obj, x, y) {
|
||||
delete this.getInfoBox().width;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
setApi: function (o) {
|
||||
this.api = o;
|
||||
if (this.api) {
|
||||
this.api.isTextAreaBlur = false;
|
||||
this.api.asc_registerCallback("asc_onSelectionNameChanged", Ext.bind(this.updateBox, this));
|
||||
this.api.asc_registerCallback("asc_onEditCell", Ext.bind(this._onEditCell, this));
|
||||
this.api.asc_registerCallback("asc_onСoAuthoringDisconnect", Ext.bind(this.onCoAuthoringDisconnect, this));
|
||||
}
|
||||
},
|
||||
updateBox: function (info) {
|
||||
this.getInfoBox().updateCellInfo(info);
|
||||
},
|
||||
_onEditCell: function (state) {
|
||||
if (state == c_oAscCellEditorState.editStart) {
|
||||
this.api.isCellEdited = true;
|
||||
} else {
|
||||
if (state == c_oAscCellEditorState.editEnd) {
|
||||
this.api.isCellEdited = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
_reloadFormulas: function () {
|
||||
var arrFuncs = [];
|
||||
this.arrGroups = [];
|
||||
dlgFormulas.arrayFormula = [];
|
||||
var groupFuncs, groupName, addGroup;
|
||||
var qa = this.api.asc_getFormulasInfo();
|
||||
for (var i = 0; i < qa.length; i++) {
|
||||
groupName = qa[i].asc_getGroupName();
|
||||
groupFuncs = qa[i].asc_getFormulasArray();
|
||||
addGroup = false;
|
||||
for (var j = 0; j < groupFuncs.length; j++) {
|
||||
if (addGroup !== true) {
|
||||
this.arrGroups.push(groupName);
|
||||
addGroup = true;
|
||||
}
|
||||
arrFuncs.push({
|
||||
group: groupName,
|
||||
func: groupFuncs[j].asc_getName(),
|
||||
args: groupFuncs[j].asc_getArguments()
|
||||
});
|
||||
dlgFormulas.arrayFormula.push(groupFuncs[j].asc_getName());
|
||||
}
|
||||
}
|
||||
this.getFormulaList().getStore().loadData(arrFuncs);
|
||||
},
|
||||
_smoothScrollIntoView: function (element, container) {
|
||||
var c = Ext.getDom(container) || Ext.getBody().dom,
|
||||
o = element.getOffsetsTo(c),
|
||||
t = o[1] + c.scrollTop;
|
||||
var newCTop = t - c.clientHeight / 2;
|
||||
if (newCTop < 0) {
|
||||
newCTop = 0;
|
||||
}
|
||||
container.scrollTo("top", newCTop, true);
|
||||
},
|
||||
scrollViewToNode: function (dataview, node) {
|
||||
if (dataview && node) {
|
||||
var plugin = dataview.getPlugin("scrollpane");
|
||||
if (plugin) {
|
||||
var doScroll = new Ext.util.DelayedTask(function () {
|
||||
plugin.scrollToElement(node, false, true);
|
||||
});
|
||||
doScroll.delay(100);
|
||||
}
|
||||
}
|
||||
},
|
||||
keypressFormulasList: function (event, el) {
|
||||
if ((new Date().getTime()) - this.funcSearch.presstime > 3000) {
|
||||
this.funcSearch.word = "";
|
||||
}
|
||||
var store = this.getFormulaList().getStore();
|
||||
var symbol = String.fromCharCode(event.getCharCode());
|
||||
var index = this.funcSearch.index;
|
||||
if (/[a-zA-Z]/.test(symbol)) {
|
||||
this.funcSearch.word += symbol;
|
||||
this.funcSearch.index = store.find("func", this.funcSearch.word, index);
|
||||
if (this.funcSearch.index < 0) {
|
||||
this.funcSearch.word = symbol;
|
||||
this.funcSearch.index = store.find("func", this.funcSearch.word, index + 1);
|
||||
}
|
||||
if (this.funcSearch.index < 0) {
|
||||
this.funcSearch.index = store.find("func", this.funcSearch.word, 0);
|
||||
}
|
||||
if (! (this.funcSearch.index < 0)) {
|
||||
this.getFormulaList().getSelectionModel().select(this.funcSearch.index);
|
||||
var row = this.getFormulaList().getView().getNode(this.funcSearch.index);
|
||||
this.scrollViewToNode(this.getFormulaList(), row);
|
||||
}
|
||||
}
|
||||
this.funcSearch.presstime = new Date().getTime();
|
||||
},
|
||||
_handleInsertFormula: function (menu, item, opt) {
|
||||
if (item.func === "more") {
|
||||
var me = this;
|
||||
dlgFormulas.addListener("onmodalresult", function (o, mr, s) {
|
||||
me.getToolBar().fireEvent("editcomplete", me.getToolBar(), {
|
||||
checkorder: true
|
||||
});
|
||||
Common.component.Analytics.trackEvent("Toolbar", "Insert formula");
|
||||
},
|
||||
this, {
|
||||
single: true
|
||||
});
|
||||
dlgFormulas.show();
|
||||
} else {
|
||||
if (! (this.getFormulaList().getStore().getCount() > 0)) {
|
||||
this._reloadFormulas();
|
||||
}
|
||||
var index = this.getFormulaList().getStore().findExact("func", item.func);
|
||||
if (! (index < 0)) {
|
||||
var record = this.getFormulaList().getStore().getAt(index);
|
||||
this.api.asc_insertFormula(record.data.func, true);
|
||||
}
|
||||
this.getToolBar().fireEvent("editcomplete", this.getToolBar(), {
|
||||
checkorder: true
|
||||
});
|
||||
Common.component.Analytics.trackEvent("ToolBar", "Insert formula");
|
||||
}
|
||||
},
|
||||
_expandFormulaField: function () {
|
||||
if (this.getInfoBox().getHeight() > 23) {
|
||||
this.getInfoBox().keep_height = this.getInfoBox().getHeight();
|
||||
this.getInfoBox().setHeight(23);
|
||||
this.getButtonExpand().removeCls("button-collapse");
|
||||
} else {
|
||||
this.getInfoBox().setHeight(this.getInfoBox().keep_height);
|
||||
this.getButtonExpand().addCls("button-collapse");
|
||||
}
|
||||
},
|
||||
onCoAuthoringDisconnect: function () {
|
||||
if (dlgFormulas.isVisible()) {
|
||||
dlgFormulas.hide();
|
||||
}
|
||||
this.getInfoBox().setMode({
|
||||
isDisconnected: true
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* (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 url_create_template = "{0}?title={1}&template={2}&action=create&doctype=spreadsheet";
|
||||
var url_create_new = "{0}?title={1}&action=create&doctype=spreadsheet";
|
||||
Ext.define("SSE.controller.CreateFile", {
|
||||
extend: "Ext.app.Controller",
|
||||
uses: ["SSE.view.OpenDialog"],
|
||||
views: ["CreateFile"],
|
||||
stores: ["FileTemplates"],
|
||||
refs: [{
|
||||
ref: "filePanel",
|
||||
selector: "ssefile"
|
||||
}],
|
||||
init: function () {
|
||||
Common.Gateway.on("init", Ext.bind(this.loadConfig, this));
|
||||
this.control({
|
||||
"ssecreatenew": {
|
||||
afterrender: Ext.bind(this.onRenderView, this, {
|
||||
single: true
|
||||
})
|
||||
},
|
||||
"ssecreatenew dataview": {
|
||||
itemclick: this.onTemplateClick
|
||||
},
|
||||
"ssefile #file-button-createnew": {
|
||||
click: function (el, event) {
|
||||
var templates = this.getFileTemplatesStore();
|
||||
if (! (templates && templates.getCount())) {
|
||||
this.onBlankDocClick(event, el);
|
||||
}
|
||||
}
|
||||
},
|
||||
"ssefile button[docType]": {
|
||||
click: this.clickBtnDownloadAs
|
||||
},
|
||||
"ssefile button[docType=0]": {
|
||||
click: this.clickBtnDownloadAs
|
||||
}
|
||||
});
|
||||
},
|
||||
loadConfig: function (data) {
|
||||
var templates = this.getFileTemplatesStore();
|
||||
if (templates) {
|
||||
templates.removeAll();
|
||||
if (data && data.config) {
|
||||
this.createUrl = data.config.createUrl;
|
||||
this.nativeApp = data.config.nativeApp;
|
||||
if (data.config.templates) {
|
||||
templates.add(data.config.templates);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
onRenderView: function () {
|
||||
var btnBlankDocument = Ext.fly("id-create-blank-document");
|
||||
if (btnBlankDocument) {
|
||||
btnBlankDocument.addClsOnOver("over");
|
||||
btnBlankDocument.on("click", this.onBlankDocClick, this);
|
||||
}
|
||||
},
|
||||
onBlankDocClick: function (event, el) {
|
||||
var filePanel = this.getFilePanel();
|
||||
if (filePanel) {
|
||||
filePanel.closeMenu();
|
||||
}
|
||||
if (this.nativeApp === true) {
|
||||
this.api.asc_openNewDocument();
|
||||
} else {
|
||||
if (this.createUrl && this.createUrl.length) {
|
||||
var newDocumentPage = window.open(Ext.String.format(url_create_new, this.createUrl, this.newDocumentTitle));
|
||||
if (newDocumentPage) {
|
||||
newDocumentPage.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
Common.component.Analytics.trackEvent("Create New", "Blank");
|
||||
},
|
||||
onTemplateClick: function (view, record, item, index, e) {
|
||||
var filePanel = this.getFilePanel();
|
||||
if (filePanel) {
|
||||
filePanel.closeMenu();
|
||||
}
|
||||
if (this.nativeApp === true) {
|
||||
this.api.asc_openNewDocument(record.data.name);
|
||||
} else {
|
||||
if (this.createUrl && this.createUrl.length) {
|
||||
var newDocumentPage = window.open(Ext.String.format(url_create_template, this.createUrl, this.newDocumentTitle, record.data.name));
|
||||
if (newDocumentPage) {
|
||||
newDocumentPage.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
Common.component.Analytics.trackEvent("Create New");
|
||||
},
|
||||
setApi: function (o) {
|
||||
this.api = o;
|
||||
return this;
|
||||
},
|
||||
clickBtnDownloadAs: function (btn) {
|
||||
if (this.api) {
|
||||
if (this.api.asc_drawingObjectsExist() && btn.docType != c_oAscFileType.XLSX) {
|
||||
Ext.create("Ext.window.MessageBox", {
|
||||
buttonText: {
|
||||
ok: "OK",
|
||||
yes: "Yes",
|
||||
no: "No",
|
||||
cancel: this.textCancel
|
||||
}
|
||||
}).show({
|
||||
title: this.textWarning,
|
||||
msg: this.warnDownloadAs,
|
||||
icon: Ext.Msg.QUESTION,
|
||||
buttons: Ext.Msg.OKCANCEL,
|
||||
scope: this,
|
||||
fn: function (res, text) {
|
||||
if (res == "ok") {
|
||||
this.getFilePanel().fireEvent("downloadas");
|
||||
this.api.asc_DownloadAs(btn.docType);
|
||||
this.getFilePanel().closeMenu();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.getFilePanel().fireEvent("downloadas");
|
||||
this.api.asc_DownloadAs(btn.docType);
|
||||
this.getFilePanel().closeMenu();
|
||||
}
|
||||
}
|
||||
Common.component.Analytics.trackEvent("Download As", String(btn.docType));
|
||||
},
|
||||
warnDownloadAs: "If you continue saving in this format all the charts and images will be lost.<br>Are you sure you want to continue?",
|
||||
newDocumentTitle : "Unnamed document",
|
||||
textWarning: "Warning",
|
||||
textCancel: "Cancel"
|
||||
});
|
||||
@@ -0,0 +1,818 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
Ext.define("SSE.controller.DocumentHolder", {
|
||||
extend: "Ext.app.Controller",
|
||||
requires: [],
|
||||
views: ["DocumentHolder"],
|
||||
uses: ["SSE.view.AutoFilterDialog", "SSE.view.DigitalFilterDialog", "SSE.view.SetValueDialog", "SSE.view.ParagraphSettingsAdvanced", "SSE.view.HyperlinkSettings"],
|
||||
refs: [{
|
||||
ref: "documentHolder",
|
||||
selector: "ssedocumentholder"
|
||||
},
|
||||
{
|
||||
ref: "splitterMainMenu",
|
||||
selector: "#main-menu-splitter"
|
||||
}],
|
||||
init: function () {
|
||||
this.tooltips = {
|
||||
hyperlink: {},
|
||||
comment: {},
|
||||
coauth: {
|
||||
ttHeight: 20
|
||||
}
|
||||
};
|
||||
this.mouse = {};
|
||||
this.popupmenu = false;
|
||||
this.control({
|
||||
"ssedocumentholder": {
|
||||
resize: this._handleDocumentResize,
|
||||
afterrender: this._onAfterRender
|
||||
},
|
||||
"menu[group=menu-document]": {
|
||||
show: function () {
|
||||
this.popupmenu = true;
|
||||
if (this.tooltips.comment.editCommentId || this.tooltips.comment.viewCommentId) {
|
||||
this.tooltips.comment.viewCommentId = this.tooltips.comment.editCommentId = this.tooltips.comment.moveCommentId = undefined;
|
||||
this.getController("Common.controller.CommentsPopover").onApiHideComment();
|
||||
}
|
||||
},
|
||||
hide: function (cnt, eOpt) {
|
||||
this.popupmenu = false;
|
||||
this.getDocumentHolder().fireEvent("editcomplete", this.getDocumentHolder());
|
||||
}
|
||||
},
|
||||
"#view-main-menu": {
|
||||
panelbeforeshow: function (fullscreen) {
|
||||
this._isMenuHided = true;
|
||||
if (fullscreen !== true) {
|
||||
this.getSplitterMainMenu().show();
|
||||
this.getDocumentHolder().addCls("left-border");
|
||||
Ext.ComponentQuery.query("#infobox-container-cell-name")[0].addCls("left-border");
|
||||
}
|
||||
},
|
||||
panelbeforehide: function () {
|
||||
this._isMenuHided = true;
|
||||
},
|
||||
panelshow: function (panel, fullscreen) {
|
||||
this._isMenuHided = false;
|
||||
this._isFullscreenMenu = fullscreen;
|
||||
if (!fullscreen) {
|
||||
var me = this;
|
||||
me._handleDocumentResize(me.getDocumentHolder(), me.getDocumentHolder().getWidth(), me.getDocumentHolder().getHeight());
|
||||
if (!panel.isSizeInit) {
|
||||
panel.isSizeInit = true;
|
||||
var view = panel.down("dataview");
|
||||
if (view) {
|
||||
var nodes = view.getNodes(),
|
||||
width_parent = panel.getWidth();
|
||||
for (var item in nodes) {
|
||||
nodes[item].style["width"] = width_parent + "px";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
panelhide: function (panel, fullscreen) {
|
||||
this._isMenuHided = false;
|
||||
this._isFullscreenMenu = false;
|
||||
if (!fullscreen) {
|
||||
var me = this;
|
||||
me._handleDocumentResize(me.getDocumentHolder(), me.getDocumentHolder().getWidth(), me.getDocumentHolder().getHeight());
|
||||
me.getSplitterMainMenu().hide();
|
||||
me.getDocumentHolder().removeCls("left-border");
|
||||
Ext.ComponentQuery.query("#infobox-container-cell-name")[0].removeCls("left-border");
|
||||
}
|
||||
}
|
||||
},
|
||||
"#cmi-add-comment": {
|
||||
click: this._addComment
|
||||
},
|
||||
"menu[action=insert-cells]": {
|
||||
click: this.handleCellInsertMenu
|
||||
},
|
||||
"menu[action=delete-cells]": {
|
||||
click: this.handleCellDeleteMenu
|
||||
},
|
||||
"#cmi-sort-cells": {
|
||||
click: this.handleCellSortMenu
|
||||
},
|
||||
"#context-menu-cell": {
|
||||
click: this.handleCellsMenu
|
||||
},
|
||||
"#main-menu-splitter": {
|
||||
beforedragstart: function (obj, event) {
|
||||
return !event.currentTarget.disabled;
|
||||
},
|
||||
move: function (obj, x, y) {
|
||||
if (this._isMenuHided) {
|
||||
return;
|
||||
}
|
||||
var jsp_container, width_parent = obj.up("container").down("ssemainmenu").getWidth();
|
||||
if (width_parent > 40) {
|
||||
width_parent -= 40;
|
||||
Ext.ComponentQuery.query("dataview[group=scrollable]").forEach(function (list) {
|
||||
var nodes = list.getNodes();
|
||||
for (var item in nodes) {
|
||||
nodes[item].style["width"] = width_parent + "px";
|
||||
}
|
||||
list.getEl().setWidth(width_parent);
|
||||
jsp_container = list.getEl().down(".jspContainer");
|
||||
if (jsp_container) {
|
||||
jsp_container.setWidth(width_parent);
|
||||
list.getEl().down(".jspPane").setWidth(width_parent);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
"menu[action=setting-hide]": {
|
||||
click: function (menu, item) {
|
||||
var current = this.api.asc_getSheetViewSettings();
|
||||
switch (item.action) {
|
||||
case "headers":
|
||||
current.asc_setShowRowColHeaders(item.checked);
|
||||
break;
|
||||
case "lines":
|
||||
current.asc_setShowGridLines(item.checked);
|
||||
break;
|
||||
}
|
||||
this.api.asc_setSheetViewSettings(current);
|
||||
}
|
||||
},
|
||||
"menuitem[group=popupparagraphvalign]": {
|
||||
click: this._onParagraphVAlign
|
||||
},
|
||||
"menuitem[action=image-grouping]": {
|
||||
click: function (btn) {
|
||||
this.api[btn.grouping ? "asc_groupGraphicsObjects" : "asc_unGroupGraphicsObjects"]();
|
||||
this.getDocumentHolder().fireEvent("editcomplete", this.getDocumentHolder());
|
||||
}
|
||||
},
|
||||
"menuitem[action=add-hyperlink-shape]": {
|
||||
click: this._handleAddHyperlink
|
||||
},
|
||||
"menuitem[action=remove-hyperlink-shape]": {
|
||||
click: this._handleRemoveHyperlink
|
||||
},
|
||||
"menuitem[action=remove-hyperlink]": {
|
||||
click: this._handleRemoveHyperlink
|
||||
},
|
||||
"menuitem[action=text-advanced]": {
|
||||
click: this._handleTextAdvanced
|
||||
}
|
||||
});
|
||||
this.wrapEvents = {
|
||||
apiShowComment: Ext.bind(this.onApiShowComment, this),
|
||||
apiHideComment: Ext.bind(this.onApiHideComment, this)
|
||||
};
|
||||
},
|
||||
setApi: function (o) {
|
||||
this.api = o;
|
||||
this.api.asc_registerCallback("asc_onMouseMove", Ext.bind(this.onApiMouseMove, this));
|
||||
this.api.asc_registerCallback("asc_onHideComment", this.wrapEvents.apiHideComment);
|
||||
this.api.asc_registerCallback("asc_onShowComment", this.wrapEvents.apiShowComment);
|
||||
this.api.asc_registerCallback("asc_onHyperlinkClick", Ext.bind(this.onHyperlinkClick, this));
|
||||
this.api.asc_registerCallback("asc_onSetAFDialog", Ext.bind(this.onAutofilter, this));
|
||||
this.api.asc_registerCallback("asc_onСoAuthoringDisconnect", Ext.bind(this.onCoAuthoringDisconnect, this));
|
||||
return this;
|
||||
},
|
||||
resetApi: function (api) {
|
||||
this.api.asc_unregisterCallback("asc_onHideComment", this.wrapEvents.apiHideComment);
|
||||
this.api.asc_unregisterCallback("asc_onShowComment", this.wrapEvents.apiShowComment);
|
||||
this.api.asc_registerCallback("asc_onHideComment", this.wrapEvents.apiHideComment);
|
||||
this.api.asc_registerCallback("asc_onShowComment", this.wrapEvents.apiShowComment);
|
||||
},
|
||||
onCoAuthoringDisconnect: function () {
|
||||
this.permissions.isEdit = false;
|
||||
},
|
||||
loadConfig: function (data) {
|
||||
this.editorConfig = data.config;
|
||||
},
|
||||
setMode: function (m) {
|
||||
this.permissions = m;
|
||||
},
|
||||
onApiMouseMove: function (dataarray) {
|
||||
if (!this._isFullscreenMenu && dataarray.length) {
|
||||
var index_hyperlink, index_comments, index_locked;
|
||||
for (var i = dataarray.length; i > 0; i--) {
|
||||
switch (dataarray[i - 1].asc_getType()) {
|
||||
case c_oAscMouseMoveType.Hyperlink:
|
||||
index_hyperlink = i;
|
||||
break;
|
||||
case c_oAscMouseMoveType.Comment:
|
||||
index_comments = i;
|
||||
break;
|
||||
case c_oAscMouseMoveType.LockedObject:
|
||||
index_locked = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var me = this;
|
||||
if (index_hyperlink) {
|
||||
var data = dataarray[index_hyperlink - 1];
|
||||
var props = data.asc_getHyperlink();
|
||||
if (props.asc_getType() == c_oAscHyperlinkType.WebLink) {
|
||||
var linkstr = props.asc_getTooltip();
|
||||
if (linkstr) {
|
||||
linkstr = Ext.String.htmlEncode(linkstr) + "<br><b>" + me.textCtrlClick + "</b>";
|
||||
} else {
|
||||
linkstr = props.asc_getHyperlinkUrl() + "<br><b>" + me.textCtrlClick + "</b>";
|
||||
}
|
||||
} else {
|
||||
linkstr = props.asc_getTooltip() || (props.asc_getSheet() + "!" + props.asc_getRange());
|
||||
}
|
||||
if (me.tooltips.hyperlink.ref && me.tooltips.hyperlink.ref.isVisible()) {
|
||||
if (me.tooltips.hyperlink.text != linkstr) {
|
||||
me.tooltips.hyperlink.ref.close();
|
||||
}
|
||||
}
|
||||
if (!me.tooltips.hyperlink.ref || !me.tooltips.hyperlink.ref.isVisible()) {
|
||||
me.tooltips.hyperlink.text = linkstr;
|
||||
me.tooltips.hyperlink.ref = Ext.create("Ext.tip.ToolTip", {
|
||||
closeAction: "destroy",
|
||||
dismissDelay: 2000,
|
||||
html: linkstr,
|
||||
listeners: {
|
||||
beforeclose: function () {
|
||||
me.tooltips.hyperlink.ref = undefined;
|
||||
me.tooltips.hyperlink.text = "";
|
||||
},
|
||||
hide: function () {
|
||||
me.tooltips.hyperlink.ref = undefined;
|
||||
me.tooltips.hyperlink.text = "";
|
||||
}
|
||||
}
|
||||
});
|
||||
me.tooltips.hyperlink.ref.show();
|
||||
var xy = me.tooltips.hyperlink.ref.getEl().getAlignToXY("editor_sdk", "tl?", [data.asc_getX() + 4, data.asc_getY() + 6]);
|
||||
me.tooltips.hyperlink.ref.showAt(xy);
|
||||
}
|
||||
}
|
||||
if (me.permissions.isEdit) {
|
||||
if (index_comments && !this.popupmenu) {
|
||||
data = dataarray[index_comments - 1];
|
||||
if (!me.tooltips.comment.editCommentId && me.tooltips.comment.moveCommentId != data.asc_getCommentIndexes()[0]) {
|
||||
me.tooltips.comment.moveCommentId = data.asc_getCommentIndexes()[0];
|
||||
if (me.tooltips.comment.moveCommentTimer) {
|
||||
clearTimeout(me.tooltips.comment.moveCommentTimer);
|
||||
}
|
||||
var idxs = data.asc_getCommentIndexes(),
|
||||
x = data.asc_getX(),
|
||||
y = data.asc_getY(),
|
||||
leftx = data.asc_getReverseX();
|
||||
me.tooltips.comment.moveCommentTimer = setTimeout(function () {
|
||||
if (me.tooltips.comment.moveCommentId && !me.tooltips.comment.editCommentId) {
|
||||
me.tooltips.comment.viewCommentId = me.tooltips.comment.moveCommentId;
|
||||
me.getController("Common.controller.CommentsPopover").onApiShowComment(idxs, x, y, leftx, false);
|
||||
}
|
||||
},
|
||||
400);
|
||||
}
|
||||
} else {
|
||||
me.tooltips.comment.moveCommentId = undefined;
|
||||
if (me.tooltips.comment.viewCommentId != undefined) {
|
||||
me.tooltips.comment = {};
|
||||
this.getController("Common.controller.CommentsPopover").onApiHideComment();
|
||||
}
|
||||
}
|
||||
if (index_locked) {
|
||||
data = dataarray[index_locked - 1];
|
||||
if (!me.tooltips.coauth.XY) {
|
||||
me._handleDocumentResize(me.getDocumentHolder(), me.getDocumentHolder().getWidth(), me.getDocumentHolder().getHeight());
|
||||
}
|
||||
if (me.tooltips.coauth.x_point != data.asc_getX() || me.tooltips.coauth.y_point != data.asc_getY()) {
|
||||
me.hideTips();
|
||||
me.tooltips.coauth.x_point = data.asc_getX();
|
||||
me.tooltips.coauth.y_point = data.asc_getY();
|
||||
var src = Ext.DomHelper.append(Ext.getBody(), {
|
||||
tag: "div",
|
||||
cls: "username-tip"
|
||||
},
|
||||
true);
|
||||
src.applyStyles({
|
||||
height: me.tooltips.coauth.ttHeight + "px",
|
||||
position: "absolute",
|
||||
zIndex: "19000",
|
||||
visibility: "visible"
|
||||
});
|
||||
me.tooltips.coauth.ref = src;
|
||||
var is_sheet_lock = data.asc_getLockedObjectType() == c_oAscMouseMoveLockedObjectType.Sheet || data.asc_getLockedObjectType() == c_oAscMouseMoveLockedObjectType.TableProperties;
|
||||
var showPoint = [me.tooltips.coauth.x_point + me.tooltips.coauth.XY[0], me.tooltips.coauth.y_point + me.tooltips.coauth.XY[1]]; ! is_sheet_lock && (showPoint[0] = me.tooltips.coauth.bodyWidth - showPoint[0]);
|
||||
if (showPoint[1] > me.tooltips.coauth.XY[1] && showPoint[1] + me.tooltips.coauth.ttHeight < me.tooltips.coauth.XY[1] + me.tooltips.coauth.apiHeight) {
|
||||
Ext.DomHelper.overwrite(src, me._getUserName(data.asc_getUserId()));
|
||||
src.applyStyles({
|
||||
visibility: "visible"
|
||||
});
|
||||
is_sheet_lock && src.applyStyles({
|
||||
top: showPoint[1] + "px",
|
||||
left: showPoint[0] + "px"
|
||||
}) || src.applyStyles({
|
||||
top: showPoint[1] + "px",
|
||||
right: showPoint[0] + "px"
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
me.hideTips();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
onApiHideComment: function () {
|
||||
this.tooltips.comment.viewCommentId = this.tooltips.comment.editCommentId = this.tooltips.comment.moveCommentId = undefined;
|
||||
},
|
||||
onApiShowComment: function (commentId, posX, posY, leftx, isnew) {
|
||||
commentId = commentId[0];
|
||||
if (this.tooltips.comment.viewCommentId) {
|
||||
this.tooltips.comment.viewCommentId = undefined;
|
||||
this.tooltips.comment.editCommentId = commentId;
|
||||
this.getController("Common.controller.CommentsPopover").makeCommentEditable(commentId);
|
||||
} else {
|
||||
if (this.tooltips.comment.editCommentId == commentId) {} else {
|
||||
this.tooltips.comment.editCommentId = commentId;
|
||||
if (isnew) {
|
||||
if (!this.getDocumentHolder().isLiveCommenting) {
|
||||
var mainMenuCmp = Ext.getCmp("view-main-menu");
|
||||
mainMenuCmp && mainMenuCmp.selectMenu("menuComments");
|
||||
}
|
||||
var popupComment = Ext.ComponentQuery.query("commoncommentspopover");
|
||||
if (popupComment.length) {
|
||||
popupComment = popupComment[0];
|
||||
popupComment.fireTransformToAdd();
|
||||
var dataView = popupComment.query("dataview")[0];
|
||||
if (dataView) {
|
||||
dataView.on("viewready", function () {
|
||||
popupComment.fireTransformToAdd();
|
||||
},
|
||||
this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
onHyperlinkClick: function (url) {
|
||||
var newDocumentPage = window.open(url, "_blank");
|
||||
if (newDocumentPage) {
|
||||
newDocumentPage.focus();
|
||||
}
|
||||
},
|
||||
_getUserName: function (id) {
|
||||
var usersStore = Ext.getStore("Common.store.Users");
|
||||
if (usersStore) {
|
||||
var rec = usersStore.findRecord("id", id);
|
||||
if (rec) {
|
||||
return Ext.String.ellipsis(Ext.String.htmlEncode(rec.get("username")), 25, true);
|
||||
}
|
||||
}
|
||||
return this.guestText;
|
||||
},
|
||||
hideTips: function () {
|
||||
if (this.tooltips.coauth.ref) {
|
||||
Ext.destroy(this.tooltips.coauth.ref);
|
||||
this.tooltips.coauth.ref = undefined;
|
||||
this.tooltips.coauth.x_point = undefined;
|
||||
this.tooltips.coauth.y_point = undefined;
|
||||
}
|
||||
},
|
||||
_handleDocumentResize: function (obj, width, height) {
|
||||
var me = this;
|
||||
setTimeout(function () {
|
||||
me.tooltips.coauth.XY = obj.getPosition();
|
||||
me.tooltips.coauth.apiHeight = height;
|
||||
me.tooltips.coauth.bodyWidth = Ext.getBody().getWidth();
|
||||
},
|
||||
10);
|
||||
},
|
||||
_onAfterRender: function (ct) {
|
||||
ct.addCls("top-border");
|
||||
document.body.onmousedown = Ext.bind(this._handleRightDown, this);
|
||||
document.body.onmouseup = Ext.bind(this._handleRightUp, this);
|
||||
var meEl = ct.getEl();
|
||||
meEl.on({
|
||||
contextmenu: {
|
||||
fn: this._showObjectMenu,
|
||||
preventDefault: true,
|
||||
scope: this
|
||||
},
|
||||
mousewheel: this._handleDocumentWheel,
|
||||
keydown: this._handleKeyDown,
|
||||
click: function (event, el) {
|
||||
if (this.api) {
|
||||
this.api.isTextAreaBlur = false;
|
||||
if (! (el instanceof HTMLTextAreaElement || el instanceof HTMLInputElement)) {
|
||||
this.getDocumentHolder().focus(false);
|
||||
}
|
||||
}
|
||||
},
|
||||
scope: this
|
||||
});
|
||||
Ext.getDoc().on("mousewheel", this._handleDocumentWheel, this);
|
||||
Ext.getDoc().on("keydown", this._handleDocumentKeyDown, this);
|
||||
},
|
||||
_handleDocumentWheel: function (event) {
|
||||
if (this.api) {
|
||||
var delta = event.getWheelDelta();
|
||||
if (event.ctrlKey) {
|
||||
var f = this.api.asc_getZoom();
|
||||
if (delta < 0) {
|
||||
f -= 0.1;
|
||||
if (! (f < 0.5)) {
|
||||
this.api.asc_setZoom(f);
|
||||
}
|
||||
} else {
|
||||
if (delta > 0) {
|
||||
f += 0.1;
|
||||
if (f > 0 && !(f > 2)) {
|
||||
this.api.asc_setZoom(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
event.stopEvent();
|
||||
}
|
||||
}
|
||||
},
|
||||
_handleDocumentKeyDown: function (event) {
|
||||
if (this.api) {
|
||||
var key = event.getKey();
|
||||
if ((event.ctrlKey || event.metaKey) && !event.shiftKey) {
|
||||
if (key === event.NUM_PLUS || (Ext.isOpera && key == 43)) {
|
||||
if (!this.api.isCellEdited) {
|
||||
var f = this.api.asc_getZoom() + 0.1;
|
||||
if (f > 0 && !(f > 2)) {
|
||||
this.api.asc_setZoom(f);
|
||||
}
|
||||
event.stopEvent();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (key === event.NUM_MINUS || (Ext.isOpera && key == 45)) {
|
||||
if (!this.api.isCellEdited) {
|
||||
f = this.api.asc_getZoom() - 0.1;
|
||||
if (! (f < 0.5)) {
|
||||
this.api.asc_setZoom(f);
|
||||
}
|
||||
event.stopEvent();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
_handleRightDown: function (event, docElement, eOpts) {
|
||||
event.button == 0 && (this.mouse.isLeftButtonDown = true);
|
||||
event.button == 2 && (this.mouse.isRightButtonDown = true);
|
||||
},
|
||||
_handleRightUp: function (event, docElement, eOpts) {
|
||||
event.button == 0 && (this.mouse.isLeftButtonDown = false);
|
||||
},
|
||||
_handleKeyDown: function (event, docElement, eOpts) {
|
||||
if (event.getKey() == event.F10 && event.shiftKey) {
|
||||
event.stopEvent();
|
||||
this._showObjectMenu(event, docElement, eOpts);
|
||||
}
|
||||
},
|
||||
_showObjectMenu: function (event, docElement, eOpts) {
|
||||
if (this.api && this.permissions.isEdit && !this.mouse.isLeftButtonDown) {
|
||||
var iscellmenu, isrowmenu, iscolmenu, isallmenu, ischartmenu, isimagemenu, istextshapemenu;
|
||||
var holder = this.getDocumentHolder();
|
||||
var cellinfo = this.api.asc_getCellInfo();
|
||||
var seltype = cellinfo.asc_getFlags().asc_getSelectionType();
|
||||
switch (seltype) {
|
||||
case c_oAscSelectionType.RangeCells:
|
||||
iscellmenu = true;
|
||||
break;
|
||||
case c_oAscSelectionType.RangeRow:
|
||||
isrowmenu = true;
|
||||
break;
|
||||
case c_oAscSelectionType.RangeCol:
|
||||
iscolmenu = true;
|
||||
break;
|
||||
case c_oAscSelectionType.RangeMax:
|
||||
isallmenu = true;
|
||||
break;
|
||||
case c_oAscSelectionType.RangeImage:
|
||||
isimagemenu = true;
|
||||
break;
|
||||
case c_oAscSelectionType.RangeShape:
|
||||
isimagemenu = true;
|
||||
break;
|
||||
case c_oAscSelectionType.RangeShapeText:
|
||||
istextshapemenu = true;
|
||||
break;
|
||||
}
|
||||
if (isimagemenu) {
|
||||
holder.mnuUnGroupImg.setDisabled(!this.api.asc_canUnGroupGraphicsObjects());
|
||||
holder.mnuGroupImg.setDisabled(!this.api.asc_canGroupGraphicsObjects());
|
||||
this._showPopupMenu(holder.imgMenu, {},
|
||||
event, docElement, eOpts);
|
||||
} else {
|
||||
if (istextshapemenu) {
|
||||
holder.pmiTextAdvanced.textInfo = undefined;
|
||||
var SelectedObjects = this.api.asc_getGraphicObjectProps();
|
||||
for (var i = 0; i < SelectedObjects.length; i++) {
|
||||
var elType = SelectedObjects[i].asc_getObjectType();
|
||||
if (elType == c_oAscTypeSelectElement.Image) {
|
||||
var value = SelectedObjects[i].asc_getObjectValue();
|
||||
var align = value.asc_getVerticalTextAlign();
|
||||
holder.menuParagraphTop.setChecked(align == c_oAscVerticalTextAlign.TEXT_ALIGN_TOP);
|
||||
holder.menuParagraphCenter.setChecked(align == c_oAscVerticalTextAlign.TEXT_ALIGN_CTR);
|
||||
holder.menuParagraphBottom.setChecked(align == c_oAscVerticalTextAlign.TEXT_ALIGN_BOTTOM);
|
||||
} else {
|
||||
if (elType == c_oAscTypeSelectElement.Paragraph) {
|
||||
holder.pmiTextAdvanced.textInfo = SelectedObjects[i].asc_getObjectValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
var hyperinfo = cellinfo.asc_getHyperlink();
|
||||
holder.pmiInsHyperlinkShape.setVisible(this.api.asc_canAddShapeHyperlink() !== false);
|
||||
holder.pmiInsHyperlinkShape.cellInfo = cellinfo;
|
||||
holder.pmiInsHyperlinkShape.setText((hyperinfo) ? holder.editHyperlinkText : holder.txtInsHyperlink);
|
||||
holder.pmiRemoveHyperlinkShape.setVisible(hyperinfo !== undefined && hyperinfo !== null);
|
||||
holder.pmiTextAdvanced.setVisible(holder.pmiTextAdvanced.textInfo !== undefined);
|
||||
this._showPopupMenu(holder.textInShapeMenu, {},
|
||||
event, docElement, eOpts);
|
||||
} else {
|
||||
if ((seltype !== c_oAscSelectionType.RangeImage && seltype !== c_oAscSelectionType.RangeShape && seltype !== c_oAscSelectionType.RangeShapeText)) {
|
||||
holder.pmiInsertEntire.setVisible(isrowmenu || iscolmenu);
|
||||
holder.pmiDeleteEntire.setVisible(isrowmenu || iscolmenu);
|
||||
holder.pmiInsertCells.setVisible(iscellmenu);
|
||||
holder.pmiDeleteCells.setVisible(iscellmenu);
|
||||
holder.pmiSortCells.setVisible(iscellmenu || isallmenu);
|
||||
holder.pmiInsFunction.setVisible(iscellmenu);
|
||||
holder.pmiInsHyperlink.setVisible(iscellmenu);
|
||||
holder.pmiDelHyperlink.setVisible(false);
|
||||
if (iscellmenu) {
|
||||
if (cellinfo.asc_getHyperlink()) {
|
||||
holder.pmiInsHyperlink.setText(holder.editHyperlinkText);
|
||||
holder.pmiDelHyperlink.setVisible(true);
|
||||
} else {
|
||||
holder.pmiInsHyperlink.setText(holder.txtInsHyperlink);
|
||||
}
|
||||
}
|
||||
holder.pmiRowHeight.setVisible(isrowmenu || isallmenu);
|
||||
holder.pmiColumnWidth.setVisible(iscolmenu || isallmenu);
|
||||
holder.pmiEntireHide.setVisible(iscolmenu || isrowmenu);
|
||||
holder.pmiEntireShow.setVisible(iscolmenu || isrowmenu);
|
||||
holder.ssMenu.items.items[10].setVisible(iscellmenu && this.permissions.canCoAuthoring);
|
||||
holder.pmiAddComment.setVisible(iscellmenu && this.permissions.canCoAuthoring);
|
||||
holder.pmiCellMenuSeparator.setVisible(iscellmenu || isrowmenu || iscolmenu || isallmenu);
|
||||
holder.pmiEntireHide.isrowmenu = isrowmenu;
|
||||
holder.pmiEntireShow.isrowmenu = isrowmenu;
|
||||
this._showPopupMenu(holder.ssMenu, {},
|
||||
event, docElement, eOpts);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.mouse.isRightButtonDown = false;
|
||||
},
|
||||
_showPopupMenu: function (menu, value, event, docElement, eOpts) {
|
||||
if (Ext.isDefined(menu)) {
|
||||
Ext.menu.Manager.hideAll();
|
||||
var showPoint = event.getXY();
|
||||
if (!this.mouse.isRightButtonDown) {
|
||||
var coord = this.api.asc_getActiveCellCoord();
|
||||
var offset = $("#" + this.getDocumentHolder().id).offset();
|
||||
showPoint[0] = coord.asc_getX() + coord.asc_getWidth() + offset.left;
|
||||
showPoint[1] = (coord.asc_getY() < 0 ? 0 : coord.asc_getY()) + coord.asc_getHeight() + offset.top;
|
||||
} else {}
|
||||
if (Ext.isFunction(menu.initMenu)) {
|
||||
menu.initMenu(value);
|
||||
}
|
||||
menu.showAt(event.getXY());
|
||||
}
|
||||
},
|
||||
_addComment: function (item, e, eOpt) {
|
||||
var ascCommentData = new asc_CCommentData();
|
||||
var now = new Date(),
|
||||
timeZoneOffsetInMs = now.getTimezoneOffset() * 60000;
|
||||
if (ascCommentData) {
|
||||
ascCommentData.asc_putText("");
|
||||
ascCommentData.asc_putTime((now.getTime() - timeZoneOffsetInMs).toString());
|
||||
ascCommentData.asc_putUserId(this.editorConfig.user.id);
|
||||
ascCommentData.asc_putUserName(this.editorConfig.user.name);
|
||||
ascCommentData.asc_putDocumentFlag(false);
|
||||
ascCommentData.asc_putSolved(false);
|
||||
this.api.asc_addComment(ascCommentData);
|
||||
}
|
||||
},
|
||||
handleCellsMenu: function (menu, item) {
|
||||
if (item) {
|
||||
if (item.action == "insert-entire") {
|
||||
switch (this.api.asc_getCellInfo().asc_getFlags().asc_getSelectionType()) {
|
||||
case c_oAscSelectionType.RangeRow:
|
||||
this.api.asc_insertCells(c_oAscInsertOptions.InsertRows);
|
||||
break;
|
||||
case c_oAscSelectionType.RangeCol:
|
||||
this.api.asc_insertCells(c_oAscInsertOptions.InsertColumns);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (item.action == "delete-entire") {
|
||||
switch (this.api.asc_getCellInfo().asc_getFlags().asc_getSelectionType()) {
|
||||
case c_oAscSelectionType.RangeRow:
|
||||
this.api.asc_deleteCells(c_oAscDeleteOptions.DeleteRows);
|
||||
break;
|
||||
case c_oAscSelectionType.RangeCol:
|
||||
this.api.asc_deleteCells(c_oAscDeleteOptions.DeleteColumns);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (item.action == "row-height" || item.action == "column-width") {
|
||||
var me = this;
|
||||
var win = Ext.widget("setvaluedialog", {
|
||||
title: item.text,
|
||||
startvalue: item.action == "row-height" ? me.api.asc_getRowHeight() : me.api.asc_getColumnWidth(),
|
||||
maxvalue: 409,
|
||||
valuecaption: item.action == "row-height" ? this.txtHeight : this.txtWidth
|
||||
});
|
||||
win.addListener("onmodalresult", function (o, mr, v) {
|
||||
if (mr) {
|
||||
item.action == "row-height" ? me.api.asc_setRowHeight(v) : me.api.asc_setColumnWidth(v);
|
||||
}
|
||||
me.getDocumentHolder().fireEvent("editcomplete", me.getDocumentHolder());
|
||||
},
|
||||
me, {
|
||||
single: true
|
||||
});
|
||||
win.show();
|
||||
} else {
|
||||
if (item.action == "clear-all") {
|
||||
this.api.asc_emptyCells(c_oAscCleanOptions.All);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
handleCellInsertMenu: function (menu, item) {
|
||||
this.api.asc_insertCells(item.kind);
|
||||
this.getDocumentHolder().fireEvent("editcomplete", this.getDocumentHolder());
|
||||
},
|
||||
handleCellDeleteMenu: function (menu, item) {
|
||||
this.api.asc_deleteCells(item.kind);
|
||||
this.getDocumentHolder().fireEvent("editcomplete", this.getDocumentHolder());
|
||||
},
|
||||
handleCellSortMenu: function (menu, item) {
|
||||
this.api.asc_sortColFilter(item.direction, "");
|
||||
},
|
||||
onAutofilter: function (config) {
|
||||
var me = this;
|
||||
var dlgFilter = Ext.widget("sseautofilterdialog", {});
|
||||
dlgFilter.addListener("onmodalresult", function (obj, mr, s) {
|
||||
if (mr == 1) {
|
||||
var sett = obj.getSettings();
|
||||
me.api.asc_applyAutoFilter("mainFilter", sett);
|
||||
} else {
|
||||
if (mr == 2) {
|
||||
dlgCustom.show();
|
||||
return;
|
||||
} else {
|
||||
if (mr == 3) {
|
||||
me.api.asc_sortColFilter(s, config.asc_getCellId());
|
||||
}
|
||||
}
|
||||
}
|
||||
me.mouse.isLeftButtonDown = me.mouse.isRightButtonDown = false;
|
||||
me.getDocumentHolder().fireEvent("editcomplete", me.getDocumentHolder());
|
||||
},
|
||||
this);
|
||||
dlgFilter.setSettings(config);
|
||||
dlgFilter.show();
|
||||
var dlgCustom = Ext.widget("ssedigitalfilterdialog", {});
|
||||
dlgCustom.setSettings(config);
|
||||
dlgCustom.addListener("onmodalresult", function (obj, mr, s) {
|
||||
if (mr == 1) {
|
||||
me.api.asc_applyAutoFilter("digitalFilter", obj.getSettings());
|
||||
}
|
||||
me.mouse.isLeftButtonDown = me.mouse.isRightButtonDown = false;
|
||||
me.getDocumentHolder().fireEvent("editcomplete", me.getDocumentHolder());
|
||||
},
|
||||
this);
|
||||
},
|
||||
onCellChanged: function (text, cursorPosition, isFormula, formulaPos, formulaName) {
|
||||
if (isFormula && text.length > 1) {
|
||||
var menu = this.getDocumentHolder().funcMenu;
|
||||
var arr = dlgFormulas.arrayFormula.filter(function (item) {
|
||||
return new RegExp("^" + text.substr(1), "i").test(item);
|
||||
});
|
||||
if (arr && arr.length) {
|
||||
var i = -1;
|
||||
while (++i < 5) {
|
||||
if (arr[i]) {
|
||||
menu.items.getAt(i).setText(arr[i]);
|
||||
menu.items.getAt(i).show();
|
||||
} else {
|
||||
menu.items.getAt(i).hide();
|
||||
}
|
||||
}
|
||||
var coord = this.api.asc_getActiveCellCoord();
|
||||
var xy = menu.show().getEl().getAlignToXY("editor_sdk", "tl?", [coord.asc_getX(), coord.asc_getY() + coord.asc_getHeight() + 4]);
|
||||
menu.showAt(xy);
|
||||
}
|
||||
}
|
||||
console.log("onCellChanged: " + text + ", " + cursorPosition + ", " + isFormula + ", " + formulaPos + ", " + formulaName);
|
||||
},
|
||||
_onParagraphVAlign: function (item, e) {
|
||||
var properties = new Asc.asc_CImgProperty();
|
||||
properties.asc_putVerticalTextAlign(item.valign);
|
||||
this.api.asc_setGraphicObjectProps(properties);
|
||||
},
|
||||
_handleAddHyperlink: function (item) {
|
||||
var me = this;
|
||||
var win, props;
|
||||
if (me.api && item) {
|
||||
var wc = me.api.asc_getWorksheetsCount(),
|
||||
i = -1;
|
||||
var items = [];
|
||||
while (++i < wc) {
|
||||
if (!this.api.asc_isWorksheetHidden(i)) {
|
||||
items.push([me.api.asc_getWorksheetName(i)]);
|
||||
}
|
||||
}
|
||||
win = Ext.widget("ssehyperlinksettings", {
|
||||
sheets: items
|
||||
});
|
||||
win.setSettings(item.cellInfo.asc_getHyperlink(), item.cellInfo.asc_getText(), item.cellInfo.asc_getFlags().asc_getLockText());
|
||||
}
|
||||
if (win) {
|
||||
win.addListener("onmodalresult", function (o, mr) {
|
||||
if (mr == 1) {
|
||||
props = win.getSettings();
|
||||
me.api.asc_insertHyperlink(props);
|
||||
}
|
||||
me.getDocumentHolder().fireEvent("editcomplete", me.getDocumentHolder());
|
||||
},
|
||||
false);
|
||||
win.show();
|
||||
}
|
||||
},
|
||||
_handleRemoveHyperlink: function () {
|
||||
if (this.api) {
|
||||
this.api.asc_removeHyperlink();
|
||||
this.getDocumentHolder().fireEvent("editcomplete", this.getDocumentHolder());
|
||||
}
|
||||
},
|
||||
_handleTextAdvanced: function (item) {
|
||||
var me = this;
|
||||
var win;
|
||||
if (me.api && item) {
|
||||
win = Ext.create("SSE.view.ParagraphSettingsAdvanced");
|
||||
win.updateMetricUnit();
|
||||
win.setSettings({
|
||||
paragraphProps: item.textInfo,
|
||||
api: me.api
|
||||
});
|
||||
}
|
||||
if (win) {
|
||||
win.addListener("onmodalresult", Ext.bind(function (o, mr, s) {
|
||||
if (mr == 1 && s) {
|
||||
me.api.asc_setGraphicObjectProps(s.paragraphProps);
|
||||
}
|
||||
},
|
||||
me), false);
|
||||
win.addListener("close", function () {
|
||||
me.getDocumentHolder().fireEvent("editcomplete", me.getDocumentHolder());
|
||||
},
|
||||
false);
|
||||
win.show();
|
||||
}
|
||||
},
|
||||
guestText: "Guest",
|
||||
textCtrlClick: "Press CTRL and click link",
|
||||
txtRowHeight: "Row Height",
|
||||
txtHeight: "Height",
|
||||
txtWidth: "Width",
|
||||
tipIsLocked: "This element is being edited by another user."
|
||||
});
|
||||
1401
OfficeWeb/apps/spreadsheeteditor/main/app/controller/Main.js
Normal file
1401
OfficeWeb/apps/spreadsheeteditor/main/app/controller/Main.js
Normal file
File diff suppressed because it is too large
Load Diff
382
OfficeWeb/apps/spreadsheeteditor/main/app/controller/Print.js
Normal file
382
OfficeWeb/apps/spreadsheeteditor/main/app/controller/Print.js
Normal file
@@ -0,0 +1,382 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
Ext.define("SSE.controller.Print", {
|
||||
extend: "Ext.app.Controller",
|
||||
uses: ["SSE.view.DocumentStatusInfo", "SSE.view.PrintSettings"],
|
||||
views: ["MainSettingsPrint"],
|
||||
refs: [{
|
||||
ref: "toolbar",
|
||||
selector: "ssetoolbar"
|
||||
},
|
||||
{
|
||||
ref: "printAdvanced",
|
||||
selector: "ssemainsettingsprint"
|
||||
}],
|
||||
init: function () {
|
||||
this.adjPrintParams = new Asc.asc_CAdjustPrint();
|
||||
this.adjPrintParams.asc_setPrintType(c_oAscPrintType.ActiveSheets);
|
||||
this.adjPrintParams.asc_setLayoutPageType(c_oAscLayoutPageType.FitToWidth);
|
||||
this.control({
|
||||
"documentstatusinfo": {
|
||||
"updatesheetsinfo": function () {
|
||||
this.isFillSheets = false;
|
||||
this.diffParams = {};
|
||||
}
|
||||
},
|
||||
"ssemainsettingsprint": {
|
||||
show: function () {
|
||||
if (!this.isFillSheets) {
|
||||
this.isFillSheets = true;
|
||||
this.updateSettings();
|
||||
}
|
||||
if (!this.isUpdatedSettings) {
|
||||
this.isUpdatedSettings = true;
|
||||
this.getPrintAdvanced().cmbSheet.select(this.getPrintAdvanced().cmbSheet.getStore().findRecord("sheetindex", this.api.asc_getActiveWorksheetIndex()));
|
||||
}
|
||||
}
|
||||
},
|
||||
"sseprintsettings": {
|
||||
onmodalresult: this.closePrintSettings
|
||||
},
|
||||
"#advsettings-print-combo-sheets": {
|
||||
change: this.comboSheetsChange
|
||||
},
|
||||
"#advsettings-print-button-save": {
|
||||
click: this.querySavePrintSettings
|
||||
},
|
||||
"#toolbar-menuitem-print-options": {
|
||||
click: this.openPrintSettings
|
||||
},
|
||||
"#dialog-print-options-ok": {
|
||||
click: this.queryClosePrintSettings
|
||||
},
|
||||
"#dialog-printoptions-grouprange": {
|
||||
change: function (obj, newvalue, oldvalue, opts) {
|
||||
if (typeof(newvalue.printrange) == "number") {
|
||||
var panel = obj.up("window");
|
||||
if (newvalue.printrange == c_oAscPrintType.EntireWorkbook) {
|
||||
this.indeterminatePageOptions(panel);
|
||||
} else {
|
||||
if (obj.lastCheckedRange == c_oAscPrintType.EntireWorkbook) {
|
||||
this.fillPageOptions(panel, this.api.asc_getPageOptions());
|
||||
}
|
||||
}
|
||||
obj.lastCheckedRange = newvalue.printrange;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
setApi: function (o) {
|
||||
this.api = o;
|
||||
},
|
||||
updateSettings: function () {
|
||||
var panel = this.getPrintAdvanced();
|
||||
panel.cmbSheet.getStore().removeAll();
|
||||
var wc = this.api.asc_getWorksheetsCount(),
|
||||
i = -1;
|
||||
var items = [{
|
||||
sheetname: this.strAllSheets,
|
||||
sheetindex: -255
|
||||
}];
|
||||
while (++i < wc) {
|
||||
if (!this.api.asc_isWorksheetHidden(i)) {
|
||||
items.push({
|
||||
sheetname: this.api.asc_getWorksheetName(i).replace(/\s/g, " "),
|
||||
sheetindex: i
|
||||
});
|
||||
}
|
||||
}
|
||||
panel.cmbSheet.getStore().loadData(items);
|
||||
},
|
||||
comboSheetsChange: function (combo, newvalue, oldvalue, eopts) {
|
||||
var panel = this.getPrintAdvanced();
|
||||
if (newvalue == -255) {
|
||||
this.indeterminatePageOptions(panel);
|
||||
} else {
|
||||
this.fillPageOptions(panel, this.api.asc_getPageOptions(newvalue));
|
||||
}
|
||||
},
|
||||
isDiffRefill: function () {
|
||||
for (var item in this.diffParams) {
|
||||
if (this.diffParams[item] == undefined) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return item == undefined;
|
||||
},
|
||||
indeterminatePageOptions: function (panel) {
|
||||
if (this.isDiffRefill()) {
|
||||
var wc = this.api.asc_getWorksheetsCount();
|
||||
if (wc == 1) {
|
||||
this.diffParams.orientation = false;
|
||||
this.diffParams.size = false;
|
||||
this.diffParams.headings = false;
|
||||
this.diffParams.grid = false;
|
||||
this.diffParams.margintop = false;
|
||||
this.diffParams.marginright = false;
|
||||
this.diffParams.marginbottom = false;
|
||||
this.diffParams.marginleft = false;
|
||||
} else {
|
||||
var index = 0;
|
||||
var opts = this.api.asc_getPageOptions(index),
|
||||
opts_next;
|
||||
while (++index < wc) {
|
||||
opts_next = this.api.asc_getPageOptions(index);
|
||||
if (this.diffParams.orientation == undefined) {
|
||||
this.diffParams.orientation = opts.asc_getPageSetup().asc_getOrientation() != opts_next.asc_getPageSetup().asc_getOrientation();
|
||||
}
|
||||
if (this.diffParams.size == undefined) {
|
||||
this.diffParams.size = (opts.asc_getPageSetup().asc_getWidth() != opts_next.asc_getPageSetup().asc_getWidth() || opts.asc_getPageSetup().asc_getHeight() != opts_next.asc_getPageSetup().asc_getHeight());
|
||||
}
|
||||
if (this.diffParams.headings == undefined) {
|
||||
this.diffParams.headings = opts.asc_getHeadings() != opts_next.asc_getHeadings();
|
||||
}
|
||||
if (this.diffParams.grid == undefined) {
|
||||
this.diffParams.grid = opts.asc_getGridLines() != opts_next.asc_getGridLines();
|
||||
}
|
||||
if (this.diffParams.margintop == undefined) {
|
||||
this.diffParams.margintop = opts.asc_getPageMargins().asc_getTop() != opts_next.asc_getPageMargins().asc_getTop();
|
||||
}
|
||||
if (this.diffParams.marginright == undefined) {
|
||||
this.diffParams.marginright = opts.asc_getPageMargins().asc_getRight() != opts_next.asc_getPageMargins().asc_getRight();
|
||||
}
|
||||
if (this.diffParams.marginbottom == undefined) {
|
||||
this.diffParams.marginbottom = opts.asc_getPageMargins().asc_getBottom() != opts_next.asc_getPageMargins().asc_getBottom();
|
||||
}
|
||||
if (this.diffParams.marginleft == undefined) {
|
||||
this.diffParams.marginleft = opts.asc_getPageMargins().asc_getLeft() != opts_next.asc_getPageMargins().asc_getLeft();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.diffParams.orientation) {
|
||||
panel.cmbPaperOrientation.setValue("-");
|
||||
}
|
||||
if (this.diffParams.size) {
|
||||
panel.cmbPaperSize.setValue("-");
|
||||
}
|
||||
if (this.diffParams.margintop) {
|
||||
panel.spnMarginTop.setRawValue("-");
|
||||
}
|
||||
if (this.diffParams.marginright) {
|
||||
panel.spnMarginRight.setRawValue("-");
|
||||
}
|
||||
if (this.diffParams.marginbottom) {
|
||||
panel.spnMarginBottom.setRawValue("-");
|
||||
}
|
||||
if (this.diffParams.marginleft) {
|
||||
panel.spnMarginLeft.setRawValue("-");
|
||||
}
|
||||
if (this.diffParams.grid) {
|
||||
panel.chPrintGrid.setValue("indeterminate");
|
||||
}
|
||||
if (this.diffParams.headings) {
|
||||
panel.chPrintRows.setValue("indeterminate");
|
||||
}
|
||||
},
|
||||
fillPageOptions: function (panel, props) {
|
||||
var opt = props.asc_getPageSetup();
|
||||
var index = panel.cmbPaperOrientation.getStore().find("orient", opt.asc_getOrientation());
|
||||
panel.cmbPaperOrientation.select(panel.cmbPaperOrientation.getStore().getAt(index));
|
||||
var w = opt.asc_getWidth();
|
||||
var h = opt.asc_getHeight();
|
||||
index = panel.cmbPaperSize.getStore().find("size", w + "|" + h);
|
||||
if (index < 0) {
|
||||
panel.cmbPaperSize.setValue("Custom (" + w + " x " + h);
|
||||
} else {
|
||||
panel.cmbPaperSize.select(panel.cmbPaperSize.getStore().getAt(index));
|
||||
}
|
||||
opt = props.asc_getPageMargins();
|
||||
panel.spnMarginLeft.setValue(Common.MetricSettings.fnRecalcFromMM(opt.asc_getLeft()));
|
||||
panel.spnMarginTop.setValue(Common.MetricSettings.fnRecalcFromMM(opt.asc_getTop()));
|
||||
panel.spnMarginRight.setValue(Common.MetricSettings.fnRecalcFromMM(opt.asc_getRight()));
|
||||
panel.spnMarginBottom.setValue(Common.MetricSettings.fnRecalcFromMM(opt.asc_getBottom()));
|
||||
panel.chPrintGrid.setValue(props.asc_getGridLines());
|
||||
panel.chPrintRows.setValue(props.asc_getHeadings());
|
||||
},
|
||||
fillPrintOptions: function (panel, props) {
|
||||
panel.groupRange.setValue({
|
||||
printrange: props.asc_getPrintType()
|
||||
});
|
||||
panel.groupLayout.setValue({
|
||||
printlayout: props.asc_getLayoutPageType()
|
||||
});
|
||||
},
|
||||
getPageOptions: function (panel) {
|
||||
var props = new Asc.asc_CPageOptions();
|
||||
props.asc_setGridLines(panel.chPrintGrid.getValue() == "indeterminate" ? undefined : panel.chPrintGrid.getValue() == "checked" ? 1 : 0);
|
||||
props.asc_setHeadings(panel.chPrintRows.getValue() == "indeterminate" ? undefined : panel.chPrintRows.getValue() == "checked" ? 1 : 0);
|
||||
var opt = new Asc.asc_CPageSetup();
|
||||
opt.asc_setOrientation(panel.cmbPaperOrientation.getValue() == "-" ? undefined : panel.cmbPaperOrientation.getValue());
|
||||
var pagew = /^\d{3}\.?\d*/.exec(panel.cmbPaperSize.getValue());
|
||||
var pageh = /\d{3}\.?\d*$/.exec(panel.cmbPaperSize.getValue());
|
||||
opt.asc_setWidth(!pagew ? undefined : parseFloat(pagew[0]));
|
||||
opt.asc_setHeight(!pageh ? undefined : parseFloat(pageh[0]));
|
||||
props.asc_setPageSetup(opt);
|
||||
opt = new Asc.asc_CPageMargins();
|
||||
opt.asc_setLeft(panel.spnMarginLeft.getRawValue() == "-" ? undefined : Common.MetricSettings.fnRecalcToMM(panel.spnMarginLeft.getNumberValue()));
|
||||
opt.asc_setTop(panel.spnMarginTop.getRawValue() == "-" ? undefined : Common.MetricSettings.fnRecalcToMM(panel.spnMarginTop.getNumberValue()));
|
||||
opt.asc_setRight(panel.spnMarginRight.getRawValue() == "-" ? undefined : Common.MetricSettings.fnRecalcToMM(panel.spnMarginRight.getNumberValue()));
|
||||
opt.asc_setBottom(panel.spnMarginBottom.getRawValue() == "-" ? undefined : Common.MetricSettings.fnRecalcToMM(panel.spnMarginBottom.getNumberValue()));
|
||||
props.asc_setPageMargins(opt);
|
||||
return props;
|
||||
},
|
||||
savePageOptions: function (panel, index) {
|
||||
var opts = this.getPageOptions(panel);
|
||||
if (index == -255) {
|
||||
var wc = this.api.asc_getWorksheetsCount();
|
||||
index = -1;
|
||||
while (++index < wc) {
|
||||
this.api.asc_setPageOptions(opts, index);
|
||||
}
|
||||
if (this.diffParams.orientation) {
|
||||
this.diffParams.orientation = opts.asc_getPageSetup().asc_getOrientation() == undefined;
|
||||
}
|
||||
if (this.diffParams.size) {
|
||||
this.diffParams.size = (opts.asc_getPageSetup().asc_getWidth() == undefined || opts.asc_getPageSetup().asc_getHeight() == undefined);
|
||||
}
|
||||
if (this.diffParams.headings) {
|
||||
this.diffParams.headings = opts.asc_getHeadings() == undefined;
|
||||
}
|
||||
if (this.diffParams.grid) {
|
||||
this.diffParams.grid = opts.asc_getGridLines() == undefined;
|
||||
}
|
||||
if (this.diffParams.margintop) {
|
||||
this.diffParams.margintop = opts.asc_getPageMargins().asc_getTop() == undefined;
|
||||
}
|
||||
if (this.diffParams.marginright) {
|
||||
this.diffParams.marginright = opts.asc_getPageMargins().asc_getRight() == undefined;
|
||||
}
|
||||
if (this.diffParams.marginbottom) {
|
||||
this.diffParams.marginbottom = opts.asc_getPageMargins().asc_getBottom() == undefined;
|
||||
}
|
||||
if (this.diffParams.marginleft) {
|
||||
this.diffParams.marginleft = opts.asc_getPageMargins().asc_getLeft() == undefined;
|
||||
}
|
||||
} else {
|
||||
this.api.asc_setPageOptions(opts, index);
|
||||
this.diffParams = {};
|
||||
}
|
||||
},
|
||||
openPrintSettings: function () {
|
||||
if (this.api) {
|
||||
var win = Ext.widget("sseprintsettings", {});
|
||||
this.fillPageOptions(win, this.api.asc_getPageOptions());
|
||||
this.fillPrintOptions(win, this.adjPrintParams);
|
||||
win.updateMetricUnit();
|
||||
win.show();
|
||||
}
|
||||
},
|
||||
closePrintSettings: function (obj, mr) {
|
||||
if (mr == 1) {
|
||||
this.savePageOptions(obj, obj.groupRange.getValue().printrange == c_oAscPrintType.EntireWorkbook ? -255 : undefined);
|
||||
this.adjPrintParams.asc_setPrintType(obj.groupRange.getValue().printrange);
|
||||
this.adjPrintParams.asc_setLayoutPageType(obj.groupLayout.getValue().printlayout);
|
||||
this.api.asc_Print(this.adjPrintParams);
|
||||
this.isUpdatedSettings = false;
|
||||
}
|
||||
this.getToolbar().fireEvent("editcomplete", this.getToolbar());
|
||||
},
|
||||
querySavePrintSettings: function () {
|
||||
var panel = this.getPrintAdvanced();
|
||||
if (this.checkMargins(panel)) {
|
||||
this.savePageOptions(panel, panel.cmbSheet.getValue());
|
||||
panel.up("ssedocumentsettings").fireEvent("savedocsettings", panel);
|
||||
}
|
||||
},
|
||||
queryClosePrintSettings: function (btn) {
|
||||
var panel = btn.up("window");
|
||||
if (this.checkMargins(panel)) {
|
||||
panel.fireEvent("onmodalresult", panel, 1);
|
||||
panel.close();
|
||||
}
|
||||
},
|
||||
checkMargins: function (panel) {
|
||||
if (panel.cmbPaperOrientation.getValue() == c_oAscPageOrientation.PagePortrait) {
|
||||
var pagewidth = /^\d{3}\.?\d*/.exec(panel.cmbPaperSize.getValue());
|
||||
var pageheight = /\d{3}\.?\d*$/.exec(panel.cmbPaperSize.getValue());
|
||||
} else {
|
||||
pageheight = /^\d{3}\.?\d*/.exec(panel.cmbPaperSize.getValue());
|
||||
pagewidth = /\d{3}\.?\d*$/.exec(panel.cmbPaperSize.getValue());
|
||||
}
|
||||
var ml = Common.MetricSettings.fnRecalcToMM(panel.spnMarginLeft.getNumberValue());
|
||||
var mr = Common.MetricSettings.fnRecalcToMM(panel.spnMarginRight.getNumberValue());
|
||||
var mt = Common.MetricSettings.fnRecalcToMM(panel.spnMarginTop.getNumberValue());
|
||||
var mb = Common.MetricSettings.fnRecalcToMM(panel.spnMarginBottom.getNumberValue());
|
||||
var result = false;
|
||||
if (ml > pagewidth) {
|
||||
result = "left";
|
||||
} else {
|
||||
if (mr > pagewidth - ml) {
|
||||
result = "right";
|
||||
} else {
|
||||
if (mt > pageheight) {
|
||||
result = "top";
|
||||
} else {
|
||||
if (mb > pageheight - mt) {
|
||||
result = "bottom";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result) {
|
||||
Ext.Msg.show({
|
||||
title: this.textWarning,
|
||||
msg: this.warnCheckMargings,
|
||||
icon: Ext.Msg.WARNING,
|
||||
buttons: Ext.Msg.OK,
|
||||
fn: function (btn, text) {
|
||||
switch (result) {
|
||||
case "left":
|
||||
panel.spnMarginLeft.focus();
|
||||
return;
|
||||
case "right":
|
||||
panel.spnMarginRight.focus();
|
||||
return;
|
||||
case "top":
|
||||
panel.spnMarginTop.focus();
|
||||
return;
|
||||
case "bottom":
|
||||
panel.spnMarginBottom.focus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
warnCheckMargings: "Margins are incorrect",
|
||||
strAllSheets: "All Sheets",
|
||||
textWarning: "Warning"
|
||||
});
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
Ext.define("SSE.controller.RecentFiles", {
|
||||
extend: "Ext.app.Controller",
|
||||
views: ["RecentFiles"],
|
||||
stores: ["RecentFiles"],
|
||||
refs: [{
|
||||
ref: "filePanel",
|
||||
selector: "ssefile"
|
||||
}],
|
||||
init: function () {
|
||||
this.control({
|
||||
"sserecentfiles dataview": {
|
||||
itemclick: this.onRecentFileClick
|
||||
}
|
||||
});
|
||||
},
|
||||
loadConfig: function (data) {
|
||||
var recent = this.getRecentFilesStore();
|
||||
if (recent && data && data.config && data.config.recent) {
|
||||
recent.removeAll();
|
||||
recent.add(data.config.recent);
|
||||
}
|
||||
},
|
||||
onRecentFileClick: function (view, record, item, index, e) {
|
||||
var filePanel = this.getFilePanel();
|
||||
if (filePanel) {
|
||||
filePanel.closeMenu();
|
||||
}
|
||||
var recentDocPage = window.open(record.data.url);
|
||||
if (recentDocPage) {
|
||||
recentDocPage.focus();
|
||||
}
|
||||
}
|
||||
});
|
||||
193
OfficeWeb/apps/spreadsheeteditor/main/app/controller/Search.js
Normal file
193
OfficeWeb/apps/spreadsheeteditor/main/app/controller/Search.js
Normal file
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
Ext.define("SSE.controller.Search", {
|
||||
extend: "Ext.app.Controller",
|
||||
refs: [{
|
||||
ref: "searchDialog",
|
||||
selector: "commonsearchdialog"
|
||||
},
|
||||
{
|
||||
ref: "searchQuery",
|
||||
selector: "#search-dialog-text-search"
|
||||
},
|
||||
{
|
||||
ref: "replaceQuery",
|
||||
selector: "#search-dialog-text-replace"
|
||||
}],
|
||||
init: function () {
|
||||
var me = this;
|
||||
this.control({
|
||||
"commonsearchdialog": {
|
||||
show: function () {
|
||||
me.api.asc_closeCellEditor();
|
||||
me.setDefaultView();
|
||||
}
|
||||
},
|
||||
"commonsearchdialog button[group=search-text]": {
|
||||
click: function (btn) {
|
||||
this._startSearch(btn.direction);
|
||||
}
|
||||
},
|
||||
"commonsearchdialog button[group=replace-text]": {
|
||||
click: this.btnReplaceText
|
||||
},
|
||||
"#search-dialog-text-search": {
|
||||
searchstart: function (obj, text) {
|
||||
this._startSearch("next");
|
||||
obj.stopSearch(true);
|
||||
}
|
||||
},
|
||||
"ssemainmenu #main-menu-search": {
|
||||
toggle: this.showSearchDialog
|
||||
}
|
||||
});
|
||||
},
|
||||
setMode: function (mode) {
|
||||
this.mode = mode;
|
||||
this._frmSearch && this._frmSearch.setViewMode(!this.mode.isEdit);
|
||||
},
|
||||
setApi: function (o) {
|
||||
this.api = o;
|
||||
this.api.asc_registerCallback("asc_onRenameCellTextEnd", Ext.bind(this._onRenameText, this));
|
||||
this.api.asc_registerCallback("asc_onСoAuthoringDisconnect", Ext.bind(this.onCoAuthoringDisconnect, this));
|
||||
},
|
||||
setDefaultView: function () {
|
||||
this.getSearchDialog().searchMode();
|
||||
},
|
||||
showWarning: function (text) {
|
||||
var me = this;
|
||||
if (!this.msgbox) {
|
||||
this.msgbox = Ext.create("Ext.window.MessageBox", {
|
||||
listeners: {
|
||||
beforehide: function () {
|
||||
me.getSearchQuery().focus(true, 100);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
var config = {
|
||||
title: this.textSearch,
|
||||
msg: text,
|
||||
icon: Ext.Msg.INFO,
|
||||
buttons: Ext.Msg.OK
|
||||
};
|
||||
if (Common.userAgent.isIE) {
|
||||
var oldFn = {
|
||||
enter: Ext.FocusManager.navigateIn,
|
||||
esc: Ext.FocusManager.navigateOut
|
||||
};
|
||||
Ext.FocusManager.navigateIn = Ext.emptyFn;
|
||||
Ext.FocusManager.navigateOut = function (event) {
|
||||
me.msgbox.close();
|
||||
};
|
||||
config.fn = function (btn) {
|
||||
Ext.FocusManager.navigateIn = oldFn.enter;
|
||||
Ext.FocusManager.navigateOut = oldFn.esc;
|
||||
};
|
||||
}
|
||||
this.msgbox.show(config);
|
||||
},
|
||||
btnReplaceText: function (btn, event, opts) {
|
||||
var me = this;
|
||||
if (me.getSearchQuery().isValueValid()) {
|
||||
var sett = this.getSearchDialog().getSettings();
|
||||
this.api.isReplaceAll = (btn.type == "all");
|
||||
this.api.asc_replaceText(sett.textsearch, sett.textreplace, btn.type == "all", sett.casesensitive, sett.wholewords);
|
||||
}
|
||||
},
|
||||
_startSearch: function (direction) {
|
||||
if (this.api && this.getSearchQuery().isValueValid()) {
|
||||
var sett = this.getSearchDialog().getSettings();
|
||||
if (!this.api.asc_findText(sett.textsearch, true, direction == "next", sett.casesensitive, sett.wholewords)) {
|
||||
this.showWarning(this.textNoTextFound);
|
||||
}
|
||||
}
|
||||
},
|
||||
_onRenameText: function (found, replaced) {
|
||||
var me = this;
|
||||
if (this.api.isReplaceAll) {
|
||||
if (found) {
|
||||
if (! (found - replaced)) {
|
||||
me.showWarning(Ext.String.format(this.textReplaceSuccess, replaced));
|
||||
} else {
|
||||
me.showWarning(Ext.String.format(this.textReplaceSkipped, found - replaced));
|
||||
}
|
||||
} else {
|
||||
me.showWarning(me.textNoTextFound);
|
||||
}
|
||||
} else {
|
||||
var sett = this.getSearchDialog().getSettings();
|
||||
if (!me.api.asc_findText(sett.textsearch, true, true, sett.casesensitive, sett.wholewords)) {
|
||||
me.showWarning(me.textNoTextFound);
|
||||
}
|
||||
}
|
||||
},
|
||||
showSearchDialog: function (btn, pressed) {
|
||||
if (pressed) {
|
||||
var mainmenu = btn.up("#view-main-menu");
|
||||
mainmenu.closeFullScaleMenu();
|
||||
var me = this;
|
||||
if (!me._frmSearch) {
|
||||
me._frmSearch = Ext.create("Common.view.SearchDialog", {
|
||||
animateTarget: "main-menu-search",
|
||||
closeAction: "hide",
|
||||
isViewMode: !me.mode.isEdit,
|
||||
highlight: false,
|
||||
listeners: {
|
||||
hide: function (cnt, eOpts) {
|
||||
if (!btn.ownrise) {
|
||||
btn.ownrise = true;
|
||||
btn.toggle(false, true);
|
||||
mainmenu.fireEvent("editcomplete", mainmenu);
|
||||
}
|
||||
btn.ownrise = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
me._frmSearch.show();
|
||||
} else {
|
||||
if (this._frmSearch && !btn.ownrise) {
|
||||
btn.ownrise = true;
|
||||
this._frmSearch.hide();
|
||||
}
|
||||
}
|
||||
},
|
||||
onCoAuthoringDisconnect: function () {
|
||||
this.mode.isEdit = false;
|
||||
this._frmSearch && this._frmSearch.setViewMode(true);
|
||||
},
|
||||
textSearch: "Search",
|
||||
textNoTextFound: "Text not found",
|
||||
textReplaceSuccess: "Search has been done. {0} occurrences have been replaced",
|
||||
textReplaceSkipped: "The replacement has been made. {0} occurrences were skipped."
|
||||
});
|
||||
1542
OfficeWeb/apps/spreadsheeteditor/main/app/controller/Toolbar.js
Normal file
1542
OfficeWeb/apps/spreadsheeteditor/main/app/controller/Toolbar.js
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user