Commit 100312b5 authored by Oleg Korshul's avatar Oleg Korshul

mouse events from plugins

parent 3cad6ab0
......@@ -3504,6 +3504,7 @@ var editor;
prot["asc_pluginButtonClick"] = prot.asc_pluginButtonClick;
prot["asc_addOleObject"] = prot.asc_addOleObject;
prot["asc_editOleObject"] = prot.asc_editOleObject;
prot["asc_pluginEnableMouseEvents"] = prot.asc_pluginEnableMouseEvents;
// system input
prot["SetTextBoxInputMode"] = prot.SetTextBoxInputMode;
......
......@@ -950,6 +950,18 @@
this.pluginsManager.buttonClick(id);
};
baseEditorsApi.prototype.asc_pluginEnableMouseEvents = function(isEnable)
{
if (!this.pluginsManager)
return;
var _pluginData = new Asc.CPluginData();
_pluginData.setAttribute("type", "enableMouseEvent");
_pluginData.setAttribute("isEnabled", isEnable);
this.pluginsManager.sendMessage(_pluginData);
};
// Builder
baseEditorsApi.prototype.asc_nativeInitBuilder = function()
{
......
......@@ -30,12 +30,14 @@
*
*/
(function(window, undefined){
(function(window, undefined)
{
function CPluginData()
{
this.privateData = {};
}
CPluginData.prototype =
{
setAttribute : function(name, value)
......@@ -55,7 +57,7 @@
{
_data = JSON.stringify(this.privateData);
}
catch(err)
catch (err)
{
_data = "{ \"data\" : \"\" }";
}
......@@ -68,9 +70,9 @@
{
this.privateData = JSON.parse(_data);
}
catch(err)
catch (err)
{
this.privateData = { "data" : "" };
this.privateData = {"data" : ""};
}
}
};
......@@ -207,7 +209,10 @@
if (-1 == id)
{
// защита от плохого плагина
this.closeAttackTimer = setTimeout(function(){ window.g_asc_plugins.close(); }, 5000);
this.closeAttackTimer = setTimeout(function()
{
window.g_asc_plugins.close();
}, 5000);
}
var _iframe = document.getElementById("plugin_iframe");
if (_iframe)
......@@ -228,7 +233,10 @@
{
var text_data = {
data : "",
pushData : function(format, value) { this.data = value; }
pushData : function(format, value)
{
this.data = value;
}
};
this.api.asc_CheckCopy(text_data, 1);
......@@ -239,7 +247,10 @@
{
var text_data = {
data : "",
pushData : function(format, value) { this.data = value; }
pushData : function(format, value)
{
this.data = value;
}
};
this.api.asc_CheckCopy(text_data, 2);
......@@ -293,7 +304,7 @@
this.plugins.push(_p);
}
var _pluginsInstall = { "url" : this.path, "pluginsData" : [] };
var _pluginsInstall = {"url" : this.path, "pluginsData" : []};
for (var i = 0; i < this.plugins.length; i++)
{
_pluginsInstall["pluginsData"].push(this.plugins[i].serialize());
......@@ -311,6 +322,19 @@
{
//console.log("endLongAction");
this.api.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.SlowOperation);
},
sendMessage : function(pluginData)
{
if (!this.current)
return;
var _iframe = document.getElementById("plugin_iframe");
if (_iframe)
{
pluginData.setAttribute("guid", this.current.guid);
_iframe.contentWindow.postMessage(pluginData.serialize(), "*");
}
}
};
......@@ -348,49 +372,79 @@
window.g_asc_plugins.closeAttackTimer = -1;
}
if (value && value != "") {
try {
if (window.g_asc_plugins.api.asc_canPaste()) {
if (value && value != "")
{
try
{
if (window.g_asc_plugins.api.asc_canPaste())
{
var _script = "(function(){ var Api = window.g_asc_plugins.api;\n" + value + "})();";
eval(_script);
if (pluginData.getAttribute("recalculate") == true) {
if (pluginData.getAttribute("recalculate") == true)
{
var editorId = window.g_asc_plugins.api.getEditorId();
if (AscCommon.c_oEditorId.Word === editorId) {
if (AscCommon.c_oEditorId.Word === editorId)
{
var oLogicDocument = window.g_asc_plugins.api.WordControl ?
window.g_asc_plugins.api.WordControl.m_oLogicDocument : null;
var _fonts = oLogicDocument.Document_Get_AllFontNames();
var _imagesArray = oLogicDocument.Get_AllImageUrls();
var _images = {};
for (var i = 0; i < _imagesArray.length; i++) {
for (var i = 0; i < _imagesArray.length; i++)
{
_images[_imagesArray[i]] = _imagesArray[i];
}
window.g_asc_plugins.images_rename = _images;
AscCommon.Check_LoadingDataBeforePrepaste(window.g_asc_plugins.api, _fonts, _images,
function () {
function()
{
if (window.g_asc_plugins.api.WordControl &&
window.g_asc_plugins.api.WordControl.m_oLogicDocument &&
window.g_asc_plugins.api.WordControl.m_oLogicDocument.Reassign_ImageUrls) {
window.g_asc_plugins.api.WordControl.m_oLogicDocument.Reassign_ImageUrls)
{
window.g_asc_plugins.api.WordControl.m_oLogicDocument.Reassign_ImageUrls(
window.g_asc_plugins.images_rename);
}
delete window.g_asc_plugins.images_rename;
window.g_asc_plugins.api.asc_Recalculate();
});
} else if (AscCommon.c_oEditorId.Spreadsheet === editorId) {
}
else if (AscCommon.c_oEditorId.Spreadsheet === editorId)
{
window.g_asc_plugins.api.asc_Recalculate();
}
}
}
} catch (err) {
} catch (err)
{
}
}
if ("close" == name) {
if ("close" == name)
{
window.g_asc_plugins.close();
}
}
else if ("resize" == name)
{
var _sizes = JSON.parse(value);
window.g_asc_plugins.api.asc_fireCallback("asc_onPluginResize", _sizes["width"], _sizes["height"], function() {
// TODO: send resize end event
});
}
else if ("onmousemove" == name)
{
var _pos = JSON.parse(value);
window.g_asc_plugins.api.asc_fireCallback("asc_onPluginMouseMove", _pos["x"], _pos["y"]);
}
else if ("onmouseup" == name)
{
var _pos = JSON.parse(value);
window.g_asc_plugins.api.asc_fireCallback("asc_onPluginMouseUp", _pos["x"], _pos["y"]);
}
}
}
......@@ -414,9 +468,11 @@
window.g_asc_plugins.api = api;
window.g_asc_plugins["api"] = window.g_asc_plugins.api;
window.g_asc_plugins.api.asc_registerCallback('asc_onDocumentContentReady', function(){
window.g_asc_plugins.api.asc_registerCallback('asc_onDocumentContentReady', function()
{
setTimeout(function(){
setTimeout(function()
{
window.g_asc_plugins.loadExtensionPlugins(window["Asc"]["extensionPlugins"]);
}, 10);
......@@ -429,9 +485,15 @@
window["Asc"].CPluginData_wrap = function(obj)
{
if (!obj.getAttribute)
obj.getAttribute = function(name) { return this[name]; }
obj.getAttribute = function(name)
{
return this[name];
};
if (!obj.setAttribute)
obj.setAttribute = function(name, value) { return this[name] = value; }
obj.setAttribute = function(name, value)
{
return this[name] = value;
};
};
})(window, undefined);
......@@ -461,8 +523,8 @@ function TEST_PLUGINS()
isUpdateOleOnResize : true,
buttons : [ { text: "Ok", primary: true },
{ text: "Cancel", primary: false } ]
buttons : [{text : "Ok", primary : true},
{text : "Cancel", primary : false}]
},
{
description : "about",
......@@ -481,7 +543,7 @@ function TEST_PLUGINS()
isUpdateOleOnResize : false,
buttons : [ { "text": "Ok", "primary": true } ]
buttons : [{"text" : "Ok", "primary" : true}]
}
]
},
......@@ -507,7 +569,7 @@ function TEST_PLUGINS()
isUpdateOleOnResize : false,
buttons : [ { text: "Ok", primary: true } ]
buttons : [{text : "Ok", primary : true}]
}
]
},
......@@ -559,7 +621,7 @@ function TEST_PLUGINS()
isUpdateOleOnResize : false,
buttons : [ ]
buttons : []
}
]
},
......@@ -585,8 +647,8 @@ function TEST_PLUGINS()
isUpdateOleOnResize : false,
buttons : [ { text: "Ok", primary: true },
{ text: "Cancel", primary: false } ]
buttons : [{text : "Ok", primary : true},
{text : "Cancel", primary : false}]
}
]
},
......@@ -645,8 +707,8 @@ function TEST_PLUGINS()
"isUpdateOleOnResize" : false,
"buttons" : [ { "text": "Insert In Document", "primary": true},
{ "text": "Cancel", "primary": false } ]
"buttons" : [{"text" : "Insert In Document", "primary" : true},
{"text" : "Cancel", "primary" : false}]
}
]
},
......@@ -698,7 +760,7 @@ function TEST_PLUGINS()
"isUpdateOleOnResize" : false,
"buttons" : [ { "text": "Ok", "primary": true } ]
"buttons" : [{"text" : "Ok", "primary" : true}]
}
]
}
......
......@@ -6766,6 +6766,8 @@ background-repeat: no-repeat;\
asc_docs_api.prototype["asc_pluginRun"] = asc_docs_api.prototype.asc_pluginRun;
asc_docs_api.prototype["asc_pluginResize"] = asc_docs_api.prototype.asc_pluginResize;
asc_docs_api.prototype["asc_pluginButtonClick"] = asc_docs_api.prototype.asc_pluginButtonClick;
asc_docs_api.prototype["asc_pluginEnableMouseEvents"] = asc_docs_api.prototype.asc_pluginEnableMouseEvents;
asc_docs_api.prototype["asc_addOleObject"] = asc_docs_api.prototype.asc_addOleObject;
asc_docs_api.prototype["asc_editOleObject"] = asc_docs_api.prototype.asc_editOleObject;
asc_docs_api.prototype["asc_InputClearKeyboardElement"] = asc_docs_api.prototype.asc_InputClearKeyboardElement;
......
......@@ -8883,6 +8883,8 @@ background-repeat: no-repeat;\
asc_docs_api.prototype["asc_pluginRun"] = asc_docs_api.prototype.asc_pluginRun;
asc_docs_api.prototype["asc_pluginResize"] = asc_docs_api.prototype.asc_pluginResize;
asc_docs_api.prototype["asc_pluginButtonClick"] = asc_docs_api.prototype.asc_pluginButtonClick;
asc_docs_api.prototype["asc_pluginEnableMouseEvents"] = asc_docs_api.prototype.asc_pluginEnableMouseEvents;
asc_docs_api.prototype["asc_nativeInitBuilder"] = asc_docs_api.prototype.asc_nativeInitBuilder;
asc_docs_api.prototype["asc_SetSilentMode"] = asc_docs_api.prototype.asc_SetSilentMode;
asc_docs_api.prototype["asc_addOleObject"] = asc_docs_api.prototype.asc_addOleObject;
......
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