Import OnlyOffice code from the 'onlyoffice' branch and sframe it

pull/1/head
yflory 7 years ago
parent c50b8dd3e9
commit 5827905dbd

@ -39,4 +39,5 @@ body.cp-app-profile { @import "../../../profile/app-profile.less"; }
body.cp-app-settings { @import "../../../settings/app-settings.less"; } body.cp-app-settings { @import "../../../settings/app-settings.less"; }
body.cp-app-debug { @import "../../../debug/app-debug.less"; } body.cp-app-debug { @import "../../../debug/app-debug.less"; }
body.cp-app-worker { @import "../../../worker/app-worker.less"; } body.cp-app-worker { @import "../../../worker/app-worker.less"; }
body.cp-app-oo { @import "../../../onlyoffice/document/app-oo.less"; }

@ -0,0 +1,117 @@
const sockjs = require('sockjs');
const co = require('co');
try {
config = require('./config');
} catch (e) {
console.log("You can customize the configuration by copying config.example.js to config.js");
config = require('./config.example');
}
var origin = config.httpUnsafeOrigin || 'http://localhost:3000/';
exports.install = function(server, callbackFunction) {
var sockjs_opts = {sockjs_url: ""},
sockjs_echo = sockjs.createServer(sockjs_opts),
urlParse = new RegExp("^/onlyoffice/doc/([0-9-.a-zA-Z_=]*)/c.+", 'i');
console.log("Start ooserver");
console.log("Port " + sockjs_echo.port);
function getBaseUrl(protocol, hostHeader, forwardedProtoHeader, forwardedHostHeader) {
var url = '';
if (forwardedProtoHeader) {
url += forwardedProtoHeader;
} else if (protocol) {
url += protocol;
} else {
url += 'http';
}
url += '://';
if (forwardedHostHeader) {
url += forwardedHostHeader;
} else if (hostHeader) {
url += hostHeader;
} else {
url += origin.slice(0, -1);
}
return url;
}
function getBaseUrlByConnection(conn) {
return getBaseUrl('', conn.headers['host'], conn.headers['x-forwarded-proto'], conn.headers['x-forwarded-host']);
}
function sendData(conn, data) {
conn.write(JSON.stringify(data));
}
function sendDataWarning(conn, msg) {
sendData(conn, {type: "warning", message: msg});
}
function sendDataMessage(conn, msg) {
sendData(conn, {type: "message", messages: msg});
}
sockjs_echo.on('connection', function(conn) {
console.log("ooserver in connection");
if (null == conn) {
console.log("null == conn");
return;
}
conn.baseUrl = getBaseUrlByConnection(conn);
console.log("BaseUrl: " + conn.baseUrl);
conn.sessionIsSendWarning = false;
conn.sessionTimeConnect = conn.sessionTimeLastAction = new Date().getTime();
console.log("ooserver setting handlers");
conn.on('data', function(message) {
console.log("In data");
return co(function* () {
try {
console.log("Received: " + message);
var data = JSON.parse(message);
switch (data.type) {
case 'auth':
console.log("Response auth");
var fileUrl = origin + "onlyoffice/document/test.bin";
if (data.openCmd.format=="xlsx")
fileUrl = origin + "onlyoffice/spreadsheet/test.bin"
else if (data.openCmd.format=="pptx")
fileUrl = origin + "onlyoffice/presentation/test.bin"
sendData(conn, {"type":"auth","result":1,"sessionId":"08e77705-dc5c-477d-b73a-b1a7cbca1e9b","sessionTimeConnect":1494226099270,"participants":[]});
sendData(conn, {"type":"documentOpen","data":{"type":"open","status":"ok","data":{"Editor.bin":fileUrl}}});
break;
default:
break;
}
} catch (e) {
console.log("error receiving response: docId = %s type = %s\r\n%s", docId, (data && data.type) ? data.type : 'null', e.stack);
}
});
});
conn.on('error', function() {
console.log("On error");
});
conn.on('close', function() {
return co(function* () {
console.log("On close");
});
});
console.log("ooserver sending welcome message");
sendData(conn, {
type: 'license',
license: {
type: 3,
light: false,
trial: false,
rights: 1,
buildVersion: "4.3.3",
buildNumber: 4,
branding: false
}
});
});
sockjs_echo.installHandlers(server, {prefix: '/onlyoffice/doc/[0-9-.a-zA-Z_=]*/c', log: function(severity, message) {
console.log(message);
}});
callbackFunction();
};

@ -10,7 +10,9 @@
"saferphore": "0.0.1", "saferphore": "0.0.1",
"stream-to-pull-stream": "^1.7.2", "stream-to-pull-stream": "^1.7.2",
"tweetnacl": "~0.12.2", "tweetnacl": "~0.12.2",
"ws": "^1.0.1" "ws": "^1.0.1",
"co": "^4.6.0",
"sockjs": "^0.3.18"
}, },
"devDependencies": { "devDependencies": {
"flow-bin": "^0.59.0", "flow-bin": "^0.59.0",

@ -9,6 +9,7 @@ var WebSocketServer = require('ws').Server;
var NetfluxSrv = require('./node_modules/chainpad-server/NetfluxWebsocketSrv'); var NetfluxSrv = require('./node_modules/chainpad-server/NetfluxWebsocketSrv');
var Package = require('./package.json'); var Package = require('./package.json');
var Path = require("path"); var Path = require("path");
var OOServer = require('./ooserver.js');
var config; var config;
try { try {
@ -176,6 +177,53 @@ var send404 = function (res, path) {
}); });
}; };
/* SPECIAL CODE FOR ONLYOFFICE
/* Font support as onlyoffice requires fonts transformed to js */
var FONT_OBFUSCATION_MAGIC = new Buffer([
0xA0, 0x66, 0xD6, 0x20, 0x14, 0x96, 0x47, 0xfa, 0x95, 0x69, 0xB8, 0x50, 0xB0, 0x41, 0x49, 0x48
]);
var FONT_NAME_MAP = {};
[ './www/onlyoffice/fonts/' ].forEach(function (path) {
Fs.readdir(path, function (err, list) {
if (err) { throw err; }
list.forEach(function (fontName) {
FONT_NAME_MAP[fontName.toLowerCase()] = path + fontName;
});
});
});
/* Code to automatically transform font to js */
/* Currently not active, but might be necessary */
app.use("/onlyoffice/fonts/odttf/:name", function (req, res) {
var name = req.params.name.replace(/\.js$/, '').toLowerCase();
console.log(name);
if (!FONT_NAME_MAP[name]) {
console.log(name);
console.log(FONT_NAME_MAP[name]);
res.status(400).send('No such font');
return;
}
Fs.readFile(FONT_NAME_MAP[name], function (err, ret) {
if (err) { throw err; }
var maxLen = Math.min(32, ret.length);
for (var i = 0; i < maxLen; i++) {
ret[i] ^= FONT_OBFUSCATION_MAGIC[i % 16];
}
res.end(ret);
});
});
/* All fonts file replaced by the list of fonts in ttf */
app.use("/onlyoffice/sdkjs/common/AllFonts.js",
Express.static("./www/onlyoffice/allfonts-noobf.js"));
/* Replace fonts thumbnail call */
app.use("/onlyoffice/sdkjs/common/Images/fonts_thumbnail@2x.png",
Express.static("./www/onlyoffice/fonts_thumbnail.png"));
app.use(function (req, res, next) { app.use(function (req, res, next) {
res.status(404); res.status(404);
send404(res, custom_four04_path); send404(res, custom_four04_path);
@ -183,17 +231,22 @@ app.use(function (req, res, next) {
var httpServer = httpsOpts ? Https.createServer(httpsOpts, app) : Http.createServer(app); var httpServer = httpsOpts ? Https.createServer(httpsOpts, app) : Http.createServer(app);
httpServer.listen(config.httpPort,config.httpAddress,function(){ /* Install sockjs websocket server */
var host = config.httpAddress; OOServer.install(httpServer, () => {
var hostName = !host.indexOf(':') ? '[' + host + ']' : host; httpServer.listen(config.httpPort,config.httpAddress,function(){
var host = config.httpAddress;
var hostName = !host.indexOf(':') ? '[' + host + ']' : host;
var port = config.httpPort; var port = config.httpPort;
var ps = port === 80? '': ':' + port; var ps = port === 80? '': ':' + port;
console.log('\n[%s] server available http://%s%s', new Date().toISOString(), hostName, ps); console.log('\n[%s] server available http://%s%s', new Date().toISOString(), hostName, ps);
});
}); });
if (config.httpSafePort) { if (config.httpSafePort) {
Http.createServer(app).listen(config.httpSafePort, config.httpAddress); var safeHttpServer = Http.createServer(app).listen(config.httpSafePort, config.httpAddress);
OOServer.install(safeHttpServer, () => {
});
} }
var wsConfig = { server: httpServer }; var wsConfig = { server: httpServer };

@ -167,7 +167,7 @@ define([
}).nThen(function (/*waitFor*/) { }).nThen(function (/*waitFor*/) {
metaObj.doc = { metaObj.doc = {
defaultTitle: defaultTitle, defaultTitle: defaultTitle,
type: parsed.type type: cfg.type || parsed.type
}; };
var additionalPriv = { var additionalPriv = {
accountName: Utils.LocalStore.getAccountName(), accountName: Utils.LocalStore.getAccountName(),
@ -588,10 +588,10 @@ define([
crypto: Crypto.createEncryptor(secret.keys), crypto: Crypto.createEncryptor(secret.keys),
onConnect: function (wc) { onConnect: function (wc) {
if (window.location.hash && window.location.hash !== '#') { if (window.location.hash && window.location.hash !== '#') {
window.location = parsed.getUrl({ /*window.location = parsed.getUrl({
present: parsed.hashData.present, present: parsed.hashData.present,
embed: parsed.hashData.embed embed: parsed.hashData.embed
}); });*/
return; return;
} }
if (readOnly || cfg.noHash) { return; } if (readOnly || cfg.noHash) { return; }

File diff suppressed because one or more lines are too long

@ -0,0 +1,10 @@
git clone https://github.com/ldubost/web-apps.git
git clone https://github.com/ldubost/sdkjs.git
cd sdkjs
make
cd ..
rm -rf ../web-apps
cp -r web-apps/deploy/web-apps ..
rm -rf ../sdkjs
cp -r web-apps/deploy/sdkjs ..

@ -0,0 +1,5 @@
cd web-apps
git pull
cd ../sdkjs
git pull
make clean

@ -0,0 +1,38 @@
@import (once) "../../customize/src/less2/include/browser.less";
@import (once) "../../customize/src/less2/include/toolbar.less";
@import (once) "../../customize/src/less2/include/markdown.less";
@import (once) '../../customize/src/less2/include/fileupload.less';
@import (once) '../../customize/src/less2/include/alertify.less';
@import (once) '../../customize/src/less2/include/avatar.less';
.toolbar_main();
.fileupload_main();
.alertify_main();
// body
&.cp-app-oo {
display: flex;
flex-flow: column;
#cp-toolbar {
display: flex; // We need this to remove a 3px border at the bottom of the toolbar
}
.cp-cryptpad-toolbar {
padding: 0px;
display: inline-block;
}
#cp-app-oo-container {
flex: 1;
height: 100%;
background-color: lightgrey;
display: flex;
}
#ooframe {
flex: 1;
border:none;
margin:0;
padding:0;
}
}

@ -0,0 +1,23 @@
config = {
"document": {
"fileType": "docx",
"key": "Khirz6zTPdfd7",
"title": "test.docx",
"url": "/onlyoffice/test.docx"
},
"documentType": "text",
"editorConfig": {
"user": {
"id": "c0c3bf82-20d7-4663-bf6d-7fa39c598b1d",
"name": "John Smith"
}
},
"events": {
"onDocumentStateChange": function(evt) { console.log("in change"); window.top.APP.onLocal(); },
"onReady": function(evt) { console.log("in onReady"); window.top.onOOReady(); }
}
};
var docEditor = new DocsAPI.DocEditor("placeholder", config);

@ -0,0 +1,14 @@
<html>
<head>
<style>
body {
margin: 0;
}
</style>
</head>
<body>
<div id="placeholder"></div>
<script type="text/javascript" src="/onlyoffice/web-apps/apps/api/documents/api.js"></script>
<script type="text/javascript" src="/onlyoffice/document/doc.js"></script>
</body>
</html>

@ -0,0 +1,38 @@
<!DOCTYPE html>
<html>
<head>
<title>CryptPad</title>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="referrer" content="no-referrer" />
<script async data-bootload="main.js" data-main="/common/boot.js?ver=1.0" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
<style>
html, body {
margin: 0px;
padding: 0px;
}
#sbox-iframe {
position:fixed;
top:0px;
left:0px;
bottom:0px;
right:0px;
width:100%;
height:100%;
border:none;
margin:0;
padding:0;
overflow:hidden;
}
#sbox-filePicker-iframe {
position: fixed;
top:0; left:0;
bottom:0; right:0;
width:100%;
height: 100%;
border: 0;
}
</style>
</head>
<body>
<iframe id="sbox-iframe">

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html class="cp-app-noscroll">
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<script async data-bootload="/onlyoffice/document/inner.js" data-main="/common/sframe-boot.js?ver=1.4" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
<style>
.loading-hidden { display: none; }
</style>
</head>
<body class="cp-app-oo">
<div id="cp-toolbar" class="cp-toolbar-container"></div>
<div id="cp-app-oo-container">
<iframe id="ooframe" src="document.html" width="100%" height="100%">
</iframe>
</div>
</body>

@ -0,0 +1,308 @@
define([
'jquery',
'/common/toolbar3.js',
'json.sortify',
'/bower_components/nthen/index.js',
'/common/sframe-common.js',
'/common/common-interface.js',
'/api/config',
'/customize/messages.js',
'/customize/application_config.js',
'/bower_components/chainpad/chainpad.dist.js',
'/bower_components/file-saver/FileSaver.min.js',
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
'less!/bower_components/components-font-awesome/css/font-awesome.min.css',
'less!/customize/src/less2/main.less',
], function (
$,
Toolbar,
JSONSortify,
nThen,
SFCommon,
UI,
ApiConfig,
Messages,
AppConfig,
ChainPad)
{
var saveAs = window.saveAs;
var ooReady = window.frames[0] && window.frames[0].frames[0] && window.frames[0].frames[0].editor;
window.onOOReady = function () {
ooReady = true;
};
var APP = window.APP = {
$: $
};
var stringify = function (obj) {
return JSONSortify(obj);
};
var toolbar;
var andThen = function (common) {
var config = {};
var emitResize = APP.emitResize = function () {
var cw = $('#ooframe')[0].contentWindow;
var evt = cw.document.createEvent('UIEvents');
evt.initUIEvent('resize', true, false, cw, 0);
cw.dispatchEvent(evt);
};
var saveToServer = APP.saveToServer = function () {
config.onLocal();
}
var callRemote = APP.callRemote = function() {
config.onRemote();
}
var saveDocument = APP.saveDocument = function () {
var defaultName = "text.oot";
UI.prompt(Messages.exportPrompt, defaultName, function (filename) {
if (!(typeof(filename) === 'string' && filename)) { return; }
console.log("In saveDocument");
var content = window.frames[0].frames[0].editor.asc_nativeGetFile();
var blob = new Blob([content], {type: "text/plain;charset=utf-8"});
saveAs(blob, filename);
});
};
var loadDocument = APP.loadDocument = function (content, file) {
console.log("Read " + content);
return;
window.frames[0].frames[0].editor.asc_CloseFile();
var openResult = {bSerFormat: true, data: content, url: "http://localhost:3000/onlyoffice/", changes: null};
window.frames[0].frames[0].editor.openDocument(openResult);
};
var readOnly = false;
var initializing = true;
var $bar = $('#cp-toolbar');
var Title;
var cpNfInner;
var metadataMgr = common.getMetadataMgr();
config = {
readOnly: readOnly,
patchTransformer: ChainPad.NaiveJSONTransformer,
// cryptpad debug logging (default is 1)
// logLevel: 0,
validateContent: function (content) {
try {
JSON.parse(content);
return true;
} catch (e) {
console.log("Failed to parse, rejecting patch");
return false;
}
}
};
var setEditable = function (state) {
console.log(state);
};
var stringifyInner = function (textValue) {
var obj = {
content: textValue,
metadata: metadataMgr.getMetadataLazy()
};
// stringify the json and send it into chainpad
return stringify(obj);
};
APP.onLocal = config.onLocal = function () {
console.log(initializing, readOnly);
if (initializing) { return; }
if (readOnly) { return; }
if (!window.frames[0].frames[0] || !window.frames[0].frames[0].editor) {
console.log("Cannot access editor");
return;
}
console.log('ok');
var data = window.frames[0].frames[0].editor.asc_nativeGetFile();
var content = stringifyInner(data);
APP.realtime.contentUpdate(content);
};
config.onInit = function (info) {
readOnly = metadataMgr.getPrivateData().readOnly;
Title = common.createTitle({});
var configTb = {
displayed: [
'userlist',
'title',
'useradmin',
'spinner',
'newpad',
'share',
'limit',
'unpinnedWarning'
],
title: Title.getTitleConfig(),
metadataMgr: metadataMgr,
readOnly: readOnly,
realtime: info.realtime,
sfCommon: common,
$container: $bar,
$contentContainer: $('#cp-app-oo-container')
};
toolbar = APP.toolbar = Toolbar.create(configTb);
Title.setToolbar(toolbar);
var $rightside = toolbar.$rightside;
/* add an export button */
var $export = common.createButton('export', true, {}, saveDocument);
$rightside.append($export);
var $import = common.createButton('import', true, {}, loadDocument);
$rightside.append($import);
var $save = common.createButton('save', true, {}, saveToServer);
$save.click(function () {
saveToServer();
});
$rightside.append($save);
var $remote = common.createButton('remote', true, {}, callRemote);
$remote.click(function () {
callRemote();
});
$rightside.append($remote);
if (common.isLoggedIn()) {
common.createButton('hashtag', true).appendTo($rightside);
}
var $forget = common.createButton('forget', true, {}, function (err) {
if (err) { return; }
setEditable(false);
});
$rightside.append($forget);
};
config.onReady = function (info) {
if (APP.realtime !== info.realtime) {
APP.realtime = info.realtime;
}
if (!window.frames[0].frames[0] || !window.frames[0].frames[0].editor) {
console.log("Cannot access editor");
return;
}
var userDoc = APP.realtime.getUserDoc();
var isNew = false;
var newDoc = '';
if (userDoc === "" || userDoc === "{}") { isNew = true; }
if (userDoc !== "") {
var hjson = JSON.parse(userDoc);
if (hjson && hjson.metadata) {
metadataMgr.updateMetadata(hjson.metadata);
}
if (typeof (hjson) !== 'object' || Array.isArray(hjson) ||
(hjson.metadata && typeof(hjson.metadata.type) !== 'undefined' &&
hjson.metadata.type !== 'oo')) {
var errorText = Messages.typeError;
UI.errorLoadingScreen(errorText);
throw new Error(errorText);
}
newDoc = hjson.content;
} else {
Title.updateTitle(Title.defaultTitle);
}
loadDocument(newDoc);
initializing = false;
setEditable(!readOnly);
UI.removeLoadingScreen();
};
config.onRemote = function () {
if (initializing) { return; }
if (!window.frames[0].frames[0] || !window.frames[0].frames[0].editor) {
console.log("Cannot access editor");
return;
}
// force readonly to prevent interlacing
readOnly = true;
var previousData = window.frames[0].frames[0].editor.asc_nativeGetFile();
var userDoc = APP.realtime.getUserDoc();
var json = JSON.parse(userDoc);
if (json.metadata) {
metadataMgr.updateMetadata(json.metadata);
}
var remoteDoc = json.content;
if (remoteDoc!=previousData) {
console.log("Remote content is different")
console.log("Remote content hjson: " + remoteDoc);
loadDocument(remoteDoc);
common.notify();
} else {
console.log("Data is unchanged");
}
readOnly = false;
};
config.onAbort = function () {
// inform of network disconnect
setEditable(false);
toolbar.failed();
UI.alert(Messages.common_connectionLost, undefined, true);
};
config.onConnectionChange = function (info) {
setEditable(info.state);
if (info.state) {
initializing = true;
UI.findOKButton().click();
} else {
UI.alert(Messages.common_connectionLost, undefined, true);
}
};
cpNfInner = common.startRealtime(config);
cpNfInner.onInfiniteSpinner(function () {
setEditable(false);
UI.confirm(Messages.realtime_unrecoverableError, function (yes) {
if (!yes) { return; }
common.gotoURL();
});
});
common.onLogout(function () { setEditable(false); });
};
var main = function () {
var common;
nThen(function (waitFor) {
if (!ooReady) {
window.onOOReady = waitFor();
}
$(waitFor(function () {
UI.addLoadingScreen();
}));
SFCommon.create(waitFor(function (c) { APP.common = common = c; }));
}).nThen(function (/*waitFor*/) {
andThen(common);
});
};
main();
});

@ -0,0 +1,43 @@
// Load #1, load as little as possible because we are in a race to get the loading screen up.
define([
'/bower_components/nthen/index.js',
'/api/config',
'/common/dom-ready.js',
'/common/requireconfig.js',
'/common/sframe-common-outer.js'
], function (nThen, ApiConfig, DomReady, RequireConfig, SFCommonO) {
var requireConfig = RequireConfig();
// Loaded in load #2
nThen(function (waitFor) {
DomReady.onReady(waitFor());
}).nThen(function (waitFor) {
var req = {
cfg: requireConfig,
req: [ '/common/loading.js' ],
pfx: window.location.origin
};
window.rc = requireConfig;
window.apiconf = ApiConfig;
document.getElementById('sbox-iframe').setAttribute('src',
ApiConfig.httpSafeOrigin + '/onlyoffice/document/inner.html?' + requireConfig.urlArgs +
'#' + encodeURIComponent(JSON.stringify(req)));
// This is a cheap trick to avoid loading sframe-channel in parallel with the
// loading screen setup.
var done = waitFor();
var onMsg = function (msg) {
var data = JSON.parse(msg.data);
if (data.q !== 'READY') { return; }
window.removeEventListener('message', onMsg);
var _done = done;
done = function () { };
_done();
};
window.addEventListener('message', onMsg);
}).nThen(function (/*waitFor*/) {
SFCommonO.start({
type: 'oo'
});
});
});

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 KiB

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<body>
<ul>
<li><a href="document/">Text</a></li>
<li><a href="spreadsheet/">Calc</a></li>
<li><a href="presentation/">Presentation</a></li>
</ul>
</body>
</html>

@ -0,0 +1,60 @@
<!DOCTYPE html>
<html class="cp">
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<script data-bootload="main.js" data-main="/common/boot.js" src="/bower_components/requirejs/require.js"></script>
<link rel="icon" type="image/png"
href="/customize/main-favicon.png"
data-main-favicon="/customize/main-favicon.png"
data-alt-favicon="/customize/alt-favicon.png"
id="favicon" />
<link rel="stylesheet" href="/bower_components/components-font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="/customize/main.css" />
<style>
html, body{
padding: 0px;
margin: 0px;
}
#editor {
position: absolute;
margin-top: 70px;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
background-color: lightgrey;
}
#ooframe {
position:absolute;
width:100%;
height:100%;
border:none;
margin:0;
padding:0;
overflow:hidden;
}
.cryptpad-toolbar {
height: 100px;
}
</style>
</head>
<body>
<div id="toolbar" class="toolbar-container"></div>
<div id="editor">
<iframe id="ooframe" src="presentation.html" width="100%" height="100%">
</iframe>
</div>
<div id="loading">
<div class="loadingContainer">
<img class="cryptofist" src="/customize/cryptofist_small.png" />
<div class="spinnerContainer">
<span class="fa fa-spinner fa-pulse fa-4x fa-fw"></span>
</div>
<p data-localization="loading"></p>
</div>
</div>
</body>
</html>

@ -0,0 +1,495 @@
require.config({ paths: {
'json.sortify': '/bower_components/json.sortify/dist/JSON.sortify'
}});
define([
'/api/config?cb=' + Math.random().toString(16).substring(2),
'/bower_components/chainpad-netflux/chainpad-netflux.js',
'/bower_components/hyperjson/hyperjson.js',
'/bower_components/chainpad-crypto/crypto.js',
'/common/toolbar.js',
'/bower_components/textpatcher/TextPatcher.amd.js',
'json.sortify',
'/bower_components/chainpad-json-validator/json-ot.js',
'/common/cryptpad-common.js',
'/bower_components/secure-fabric.js/dist/fabric.min.js',
'/bower_components/jquery/dist/jquery.min.js',
'/bower_components/file-saver/FileSaver.min.js',
'/bower_components/diff-dom/diffDOM.js',
], function (Config, Realtime, Hyperjson, Crypto, Toolbar, TextPatcher, JSONSortify, JsonOT, Cryptpad) {
var saveAs = window.saveAs;
var Messages = Cryptpad.Messages;
var module = window.APP = { };
var $ = module.$ = window.jQuery;
var Fabric = module.Fabric = window.fabric;
window.Hyperjson = Hyperjson;
$(function () {
var DiffDom = window.diffDOM;
Cryptpad.addLoadingScreen();
var onConnectError = function (info) {
Cryptpad.errorLoadingScreen(Messages.websocketError);
};
var emitResize = module.emitResize = function () {
var cw = $('#ooframe')[0].contentWindow;
var evt = cw.document.createEvent('UIEvents');
evt.initUIEvent('resize', true, false, cw, 0);
cw.dispatchEvent(evt);
};
var toolbar;
var secret = Cryptpad.getSecrets();
readOnly = secret.keys && !secret.keys.editKeyStr;
ooReady = false;
firstRemote = false;
if (!secret.keys) {
secret.keys = secret.key;
}
var andThen = function () {
var saveToServer = module.saveToServer = function () {
config.onLocal();
}
var callRemote = module.callRemote = function() {
config.onRemote();
}
var saveDocument = module.saveDocument = function () {
var defaultName = "text.oot";
Cryptpad.prompt(Messages.exportPrompt, defaultName, function (filename) {
if (!(typeof(filename) === 'string' && filename)) { return; }
console.log("In saveDocument");
var content = window.frames[0].frames[0].editor.asc_nativeGetFile();
var blob = new Blob([content], {type: "text/plain;charset=utf-8"});
saveAs(blob, filename);
});
};
var loadDocument = module.loadDocument = function (content, file) {
// console.log("Read " + content);
console.log("In loadDocument");
var openResult = {data: content, url: "http://localhost:3000/onlyoffice/"};
window.frames[0].frames[0].AscCommon.History.TurnOff();
window.frames[0].frames[0].editor.openDocument(openResult);
};
initializing = true;
var $bar = $('#toolbar');
var parsedHash = Cryptpad.parsePadUrl(window.location.href);
var defaultName = Cryptpad.getDefaultName(parsedHash);
var isHistoryMode = false;
var userData = module.userData = {}; // List of pretty name of all users (mapped with their server ID)
var userList; // List of users still connected to the channel (server IDs)
var addToUserData = function(data) {
var users = module.users;
for (var attrname in data) { userData[attrname] = data[attrname]; }
if (users && users.length) {
for (var userKey in userData) {
if (users.indexOf(userKey) === -1) {
delete userData[userKey];
}
}
}
if(userList && typeof userList.onChange === "function") {
userList.onChange(userData);
}
};
var myData = {};
var myUserName = ''; // My "pretty name"
var myID; // My server ID
var setMyID = function(info) {
myID = info.myID || null;
myUserName = myID;
};
var config = module.config = {
initialState: '{}',
websocketURL: Cryptpad.getWebsocketURL(),
validateKey: secret.keys.validateKey,
readOnly: readOnly,
channel: secret.channel,
crypto: Crypto.createEncryptor(secret.keys),
setMyID: setMyID,
transformFunction: JsonOT.transform,
};
var suggestName = function (fallback) {
if (document.title === defaultName) {
return fallback || "";
} else {
return document.title || defaultName;
}
};
var renameCb = function (err, title) {
if (err) { return; }
document.title = title;
config.onLocal();
};
var editHash;
var onInit = config.onInit = function (info) {
userList = info.userList;
var config = {
displayed: ['useradmin', 'spinner', 'lag', 'state', 'share', 'userlist', 'newpad'],
userData: userData,
readOnly: readOnly,
share: {
secret: secret,
channel: info.channel
},
ifrw: window,
title: {
onRename: renameCb,
defaultName: defaultName,
suggestName: suggestName
},
common: Cryptpad
};
if (readOnly) {delete config.changeNameID; }
toolbar = module.toolbar = Toolbar.create($bar, info.myID, info.realtime, info.getLag, userList, config);
var $rightside = $bar.find('.' + Toolbar.constants.rightside);
/* add a history button */
var histConfig = {};
histConfig.onRender = function (val) {
if (typeof val === "undefined") { return; }
try {
console.log("History render: " + val);
} catch (e) {
// Probably a parse error
console.error(e);
}
};
histConfig.onClose = function () {
// Close button clicked
setHistory(false, true);
jQuery("#editor")[0].style="margin-top: 70px;";
};
histConfig.onRevert = function () {
// Revert button clicked
setHistory(false, false);
onLocal();
onRemote();
};
histConfig.onReady = function () {
// Called when the history is loaded and the UI displayed
setHistory(true);
jQuery("#editor")[0].style="margin-top: 100px;";
};
histConfig.$toolbar = $bar;
var $hist = Cryptpad.createButton('history', true, {histConfig: histConfig});
$rightside.append($hist);
var $export = Cryptpad.createButton('export', true, {}, saveDocument);
$rightside.append($export);
var $import = Cryptpad.createButton('import', true, {}, loadDocument);
$rightside.append($import);
var $save = Cryptpad.createButton('save', true, {}, saveToServer);
$save.click(function () {
saveToServer();
});
$rightside.append($save);
var $remote = Cryptpad.createButton('remote', true, {}, callRemote);
$remote.click(function () {
callRemote();
});
$rightside.append($remote);
var editHash;
var viewHash = Cryptpad.getViewHashFromKeys(info.channel, secret.keys);
if (!readOnly) {
editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
}
if (!readOnly) { Cryptpad.replaceHash(editHash); }
};
// used for debugging, feel free to remove
var Catch = function (f) {
return function () {
try {
f();
} catch (e) {
console.error(e);
}
};
};
var setHistory = function (bool, update) {
isHistoryMode = bool;
// setEditable(!bool);
if (!bool && update) {
config.onRemote();
}
};
var updateTitle = function (newTitle) {
if (newTitle === document.title) { return; }
// Change the title now, and set it back to the old value if there is an error
var oldTitle = document.title;
document.title = newTitle;
Cryptpad.renamePad(newTitle, function (err, data) {
if (err) {
console.log("Couldn't set pad title");
console.error(err);
document.title = oldTitle;
return;
}
document.title = data;
$bar.find('.' + Toolbar.constants.title).find('span.title').text(data);
$bar.find('.' + Toolbar.constants.title).find('input').val(data);
});
};
var updateDefaultTitle = function (defaultTitle) {
defaultName = defaultTitle;
$bar.find('.' + Toolbar.constants.title).find('input').attr("placeholder", defaultName);
};
var updateMetadata = function(shjson) {
// Extract the user list (metadata) from the hyperjson
var json = (shjson === "") ? "" : JSON.parse(shjson);
var titleUpdated = false;
if (json && json.metadata) {
if (json.metadata.users) {
var userData = json.metadata.users;
// Update the local user data
addToUserData(userData);
}
if (json.metadata.defaultTitle) {
updateDefaultTitle(json.metadata.defaultTitle);
}
if (typeof json.metadata.title !== "undefined") {
updateTitle(json.metadata.title || defaultName);
titleUpdated = true;
}
}
if (!titleUpdated) {
updateTitle(defaultName);
}
};
var hjson2domstring = function(hjson) {
var userDocStateDom = hjsonToDom(JSON.parse(hjson));
var tmp = document.createElement("div");
tmp.appendChild(userDocStateDom);
return tmp.innerHTML;
};
var onRemoteInit = config.onRemoteInit = Catch(function() {
console.log("In onRemoteInit");
ooReady = true;
});
var onRemote = config.onRemote = Catch(function () {
console.log("In onRemote");
if (initializing) { return; }
if (isHistoryMode) { return; }
// force readonly to prevent interlacing
readOnly = true;
try {
if (window.frames[0].frames[0]==null || window.frames[0].frames[0].editor==null) {
console.log("Cannot access editor");
return;
}
console.log("In onRemote sync");
var previousData = window.frames[0].frames[0].editor.asc_nativeGetFile();
var userDoc = module.realtime.getUserDoc();
// console.log("Current data " + previousData);
updateMetadata(userDoc);
var json = JSON.parse(userDoc);
var remoteDoc = json.content;
if (remoteDoc!=previousData) {
console.log("Remote content is different")
// console.log("Remote content hjson: " + remoteDoc);
if (ooReady) {
if (remoteDoc)
loadDocument(remoteDoc);
firstRemote = true;
}
} else {
console.log("Data is unchanged");
firstRemote = true;
}
readOnly = false;
} catch (e) {
console.log("Exception: " + e);
throw e;
} finally {
readOnly = false;
}
});
var diffOptions = {
preDiffApply: function (info) {
},
postDiffApply : function(info) {
}
};
var DD = new DiffDom(diffOptions);
// apply patches, and try not to lose the cursor in the process!
var applyHjson = function (shjson, domElement) {
var userDocStateDom = hjsonToDom(JSON.parse(shjson));
if (!readOnly && !initializing) {
userDocStateDom.setAttribute("contenteditable", "true"); // lol wtf
}
var patch = (DD).diff(domElement, userDocStateDom);
(DD).apply(domElement, patch);
};
var stringify = function (obj) {
return JSONSortify(obj);
};
var hjsonToDom = function (H) {
var dom = Hyperjson.toDOM(H);
return dom;
};
var stringifyInner = function (textValue) {
var obj = {
content: textValue,
metadata: {
users: userData,
defaultTitle: defaultName
}
};
if (!initializing) {
obj.metadata.title = document.title;
}
// stringify the json and send it into chainpad
return JSONSortify(obj);
};
var onLocal = config.onLocal = Catch(function () {
console.log("In onLocal");
if (initializing) { return; }
if (isHistoryMode) { return; }
if (readOnly) { return; }
if (!ooReady) { return; }
if (!firstRemote) {
console.log("First remote");
onRemote();
if (firstRemote) {
console.log("First remote success");
} else {
console.log("First remote failure");
return;
}
}
if (window.frames[0].frames[0]==null || window.frames[0].frames[0].editor==null)
return;
console.log("In onLocal sync");
var data = window.frames[0].frames[0].editor.asc_nativeGetFile();
var content = stringifyInner(data);
module.patchText(content);
});
var setName = module.setName = function (newName) {
if (typeof(newName) !== 'string') { return; }
var myUserNameTemp = newName.trim();
if(newName.trim().length > 32) {
myUserNameTemp = myUserNameTemp.substr(0, 32);
}
myUserName = myUserNameTemp;
myData[myID] = {
name: myUserName,
uid: Cryptpad.getUid(),
};
addToUserData(myData);
Cryptpad.setAttribute('username', myUserName, function (err, data) {
if (err) {
console.log("Couldn't set username");
console.error(err);
return;
}
onLocal();
});
};
var onReady = config.onReady = function (info) {
var realtime = module.realtime = info.realtime;
module.patchText = TextPatcher.create({
realtime: realtime
});
Cryptpad.removeLoadingScreen();
// setEditable(true);
initializing = false;
onRemote();
Cryptpad.getLastName(function (err, lastName) {
if (err) {
console.log("Could not get previous name");
console.error(err);
return;
}
// Update the toolbar list:
// Add the current user in the metadata if he has edit rights
if (readOnly) { return; }
if (typeof(lastName) === 'string') {
setName(lastName);
} else {
myData[myID] = {
name: "",
uid: Cryptpad.getUid(),
};
addToUserData(myData);
onLocal();
// module.$userNameButton.click();
}
});
};
var onAbort = config.onAbort = function (info) {
// setEditable(false);
window.alert("Server Connection Lost");
if (window.confirm("Would you like to save your image?")) {
saveImage();
}
};
var rt = Realtime.start(config);
};
Cryptpad.ready(function (err, env) {
andThen();
});
Cryptpad.onError(function (info) {
if (info) {
onConnectError();
}
});
});
});

@ -0,0 +1,31 @@
<html>
<body>
<div id="placeholder"></div>
<script type="text/javascript" src="/onlyoffice/web-apps/apps/api/documents/api.js"></script>
<script type="text/javascript">
config = {
"document": {
"fileType": "pptx",
"key": "Khirz6zTPdfd7",
"title": "test.pptx",
"url": "http://localhost:3000/onlyoffice/test.pptx"
},
"documentType": "presentation",
"editorConfig": {
"user": {
"id": "c0c3bf82-20d7-4663-bf6d-7fa39c598b1d",
"name": "John Smith"
}
},
"events": {
"onDocumentStateChange": function(evt) { console.log("in change"); window.top.APP.config.onLocal(); },
"onReady": function(evt) { console.log("in onReady"); window.top.APP.config.onRemoteInit(); }
}
};
var docEditor = new DocsAPI.DocEditor("placeholder", config);
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

@ -0,0 +1,110 @@
@charset "UTF-8";
/*
* Worksheet canvas
* --------------------------------------------------------
*/
#ws-canvas-outer {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
}
#ws-canvas {
border: 0;
}
#ws-canvas-overlay, #ws-canvas-graphic, #ws-canvas-graphic-overlay {
border: 0;
position: absolute;
left: 0;
top: 0;
z-index: 1;
}
/*
* Worksheet scroll bars
* --------------------------------------------------------
*/
#ws-v-scrollbar {
position: absolute;
right: 0;
width: 19px;
top: -1px;
bottom: 18px;
overflow: hidden;
z-index: 10;
}
#ws-v-scroll-helper {
width: 1px;
}
#ws-h-scrollbar {
position: absolute;
bottom: 0;
height: 19px;
left: 0;
right: 18px;
overflow: hidden;
z-index: 10;
}
#ws-h-scroll-helper {
height: 1px;
}
#ws-scrollbar-corner {
position: absolute;
right: 0;
bottom: 0;
width: 18px;
height: 18px;
background-color: #DCE2E8;
border: 0;
z-index: 10;
}
/* Scrollbars common */
#ws-v-scrollbar .jspVerticalBar,
#ws-h-scrollbar .jspHorizontalBar,
#ws-v-scrollbar .jspTrack,
#ws-h-scrollbar .jspTrack {
background-color: #DCE2E8;
}
#ws-v-scrollbar .jspDrag,
#ws-h-scrollbar .jspDrag {
background-color: #C0C0C0;
}
#ws-v-scrollbar .jspDrag.jspHover,
#ws-v-scrollbar .jspDrag.jspActive,
#ws-h-scrollbar .jspDrag.jspHover,
#ws-h-scrollbar .jspDrag.jspActive {
background-color: #808080;
}
/* Vertical scrollbar */
#ws-v-scrollbar .jspVerticalBar {
width: 7px;
border-left: 1px solid #C1C6CC;
}
#ws-v-scrollbar .jspTrack {
width: 8px;
}
/* Horizontal scrollbar */
#ws-h-scrollbar .jspHorizontalBar {
height: 7px;
border-top: 1px solid #C1C6CC;
}
#ws-h-scrollbar .jspTrack {
height: 8px;
}

@ -0,0 +1,156 @@
@charset "UTF-8";
/*
* Worksheet canvas
* --------------------------------------------------------
*/
#ws-canvas-outer {
position: absolute;
left: 0;
top: 0;
right: 14px;
bottom: 14px;
overflow: hidden;
}
#ws-canvas {
border: 0;
-webkit-user-select: none;
}
#ws-canvas-overlay, #ws-canvas-graphic, #ws-canvas-graphic-overlay {
-webkit-user-select: none;
border: 0;
position: absolute;
left: 0;
top: 0;
z-index: 1;
}
/*
* Worksheet scroll bars
* --------------------------------------------------------
*/
#ws-v-scrollbar {
position: absolute;
right: 0;
width: 14px;
top: 0px;
bottom: 14px;
overflow: hidden;
z-index: 10;
background-color: #f1f1f1;
}
#ws-v-scroll-helper {
width: 1px;
}
#ws-h-scrollbar {
position: absolute;
bottom: 0;
height: 14px;
left: 0px;
right: 14px;
overflow: hidden;
z-index: 10;
background-color: #f1f1f1;
}
#ws-h-scroll-helper {
height: 1px;
}
#ws-scrollbar-corner {
position: absolute;
right: 0;
bottom: 0;
width: 14px;
height: 14px;
background-color: #F4F4F4;
border: 0;
z-index: 10;
}
/* Scrollbars common */
#ws-v-scrollbar .jspVerticalBar,
#ws-h-scrollbar .jspHorizontalBar,
#ws-v-scrollbar .jspTrack,
#ws-h-scrollbar .jspTrack {
background-color: #DCE2E8;
}
#ws-v-scrollbar .jspDrag,
#ws-h-scrollbar .jspDrag {
background-color: #C0C0C0;
}
#ws-v-scrollbar .jspDrag.jspHover,
#ws-v-scrollbar .jspDrag.jspActive,
#ws-h-scrollbar .jspDrag.jspHover,
#ws-h-scrollbar .jspDrag.jspActive {
background-color: #808080;
}
/* Vertical scrollbar */
#ws-v-scrollbar .jspVerticalBar {
width: 7px;
border-left: 1px solid #C1C6CC;
}
#ws-v-scrollbar .jspTrack {
width: 8px;
}
/* Horizontal scrollbar */
#ws-h-scrollbar .jspHorizontalBar {
height: 7px;
border-top: 1px solid #C1C6CC;
}
#ws-h-scrollbar .jspTrack {
height: 8px;
}
/*
* Cell editor
* --------------------------------------------------------
*/
#ce-canvas-outer {
position: absolute;
border: 0;
overflow: hidden;
}
#ce-canvas,
#ce-canvas-overlay {
border: 0;
position: absolute;
left: 0;
top: 0;
}
#ce-cursor {
position: absolute;
background-color: #000;
width: 1px;
height: 11pt;
cursor: text;
}
#apiPopUpSelector {
position: absolute;
}
#apiPopUpList {
width: 100%;
height: 100%;
max-height: 210px;
overflow: hidden;
position: relative;
}
#apiPopUpList li {
max-width: 500px;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 902 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

File diff suppressed because it is too large Load Diff

@ -0,0 +1,856 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* 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 editor = undefined;
var window = {};
var navigator = {};
navigator.userAgent = "chrome";
window.navigator = navigator;
window.location = {};
window.location.protocol = "";
window.location.host = "";
window.location.href = "";
window.location.pathname = "";
window.NATIVE_EDITOR_ENJINE = true;
window.NATIVE_EDITOR_ENJINE_SYNC_RECALC = true;
var document = {};
window.document = document;
window["Asc"] = {};
var Asc = window["Asc"];
window["AscFonts"] = {};
var AscFonts = window["AscFonts"];
window["AscCommon"] = {};
var AscCommon = window["AscCommon"];
window["AscFormat"] = {};
var AscFormat = window["AscFormat"];
window["AscDFH"] = {};
var AscDFH = window["AscDFH"];
window["AscCH"] = {};
var AscCH = window["AscCH"];
window["AscCommonExcel"] = {};
var AscCommonExcel = window["AscCommonExcel"];
window["AscCommonWord"] = {};
var AscCommonWord = window["AscCommonWord"];
window["AscCommonSlide"] = {};
var AscCommonSlide = window["AscCommonSlide"];
function ConvertJSC_Array(_array)
{
var _len = _array.length;
var ret = new Uint8Array(_len);
for (var i = 0; i < _len; i++)
ret[i] = _array.getAt(i);
return ret;
}
function Image()
{
this.src = "";
this.onload = function ()
{
};
this.onerror = function ()
{
};
}
function _image_data()
{
this.data = null;
this.length = 0;
}
function native_pattern_fill()
{
}
native_pattern_fill.prototype =
{
setTransform: function (transform)
{
}
};
function native_gradient_fill()
{
}
native_gradient_fill.prototype =
{
addColorStop: function (offset, color)
{
}
};
function native_context2d(parent)
{
this.canvas = parent;
this.globalAlpha = 0;
this.globalCompositeOperation = "";
this.fillStyle = "";
this.strokeStyle = "";
this.lineWidth = 0;
this.lineCap = 0;
this.lineJoin = 0;
this.miterLimit = 0;
this.shadowOffsetX = 0;
this.shadowOffsetY = 0;
this.shadowBlur = 0;
this.shadowColor = 0;
this.font = "";
this.textAlign = 0;
this.textBaseline = 0;
}
native_context2d.prototype =
{
save: function ()
{
},
restore: function ()
{
},
scale: function (x, y)
{
},
rotate: function (angle)
{
},
translate: function (x, y)
{
},
transform: function (m11, m12, m21, m22, dx, dy)
{
},
setTransform: function (m11, m12, m21, m22, dx, dy)
{
},
createLinearGradient: function (x0, y0, x1, y1)
{
return new native_gradient_fill();
},
createRadialGradient: function (x0, y0, r0, x1, y1, r1)
{
return null;
},
createPattern: function (image, repetition)
{
return new native_pattern_fill();
},
clearRect: function (x, y, w, h)
{
},
fillRect: function (x, y, w, h)
{
},
strokeRect: function (x, y, w, h)
{
},
beginPath: function ()
{
},
closePath: function ()
{
},
moveTo: function (x, y)
{
},
lineTo: function (x, y)
{
},
quadraticCurveTo: function (cpx, cpy, x, y)
{
},
bezierCurveTo: function (cp1x, cp1y, cp2x, cp2y, x, y)
{
},
arcTo: function (x1, y1, x2, y2, radius)
{
},
rect: function (x, y, w, h)
{
},
arc: function (x, y, radius, startAngle, endAngle, anticlockwise)
{
},
fill: function ()
{
},
stroke: function ()
{
},
clip: function ()
{
},
isPointInPath: function (x, y)
{
},
drawFocusRing: function (element, xCaret, yCaret, canDrawCustom)
{
},
fillText: function (text, x, y, maxWidth)
{
},
strokeText: function (text, x, y, maxWidth)
{
},
measureText: function (text)
{
},
drawImage: function (img_elem, dx_or_sx, dy_or_sy, dw_or_sw, dh_or_sh, dx, dy, dw, dh)
{
},
createImageData: function (imagedata_or_sw, sh)
{
var _data = new _image_data();
_data.length = imagedata_or_sw * sh * 4;
_data.data = (typeof(Uint8Array) != 'undefined') ? new Uint8Array(_data.length) : new Array(_data.length);
return _data;
},
getImageData: function (sx, sy, sw, sh)
{
},
putImageData: function (image_data, dx, dy, dirtyX, dirtyY, dirtyWidth, dirtyHeight)
{
}
};
function native_canvas()
{
this.id = "";
this.width = 300;
this.height = 150;
this.nodeType = 1;
}
native_canvas.prototype =
{
getContext: function (type)
{
if (type == "2d")
return new native_context2d(this);
return null;
},
toDataUrl: function (type)
{
return "";
},
addEventListener: function ()
{
},
attr: function ()
{
}
};
var _null_object = {};
_null_object.length = 0;
_null_object.nodeType = 1;
_null_object.offsetWidth = 1;
_null_object.offsetHeight = 1;
_null_object.clientWidth = 1;
_null_object.clientHeight = 1;
_null_object.scrollWidth = 1;
_null_object.scrollHeight = 1;
_null_object.style = {};
_null_object.documentElement = _null_object;
_null_object.body = _null_object;
_null_object.ownerDocument = _null_object;
_null_object.defaultView = _null_object;
_null_object.addEventListener = function ()
{
};
_null_object.setAttribute = function ()
{
};
_null_object.getElementsByTagName = function ()
{
return [];
};
_null_object.appendChild = function ()
{
};
_null_object.removeChild = function ()
{
};
_null_object.insertBefore = function ()
{
};
_null_object.childNodes = [];
_null_object.parent = _null_object;
_null_object.parentNode = _null_object;
_null_object.find = function ()
{
return this;
};
_null_object.appendTo = function ()
{
return this;
};
_null_object.css = function ()
{
return this;
};
_null_object.width = function ()
{
return 0;
};
_null_object.height = function ()
{
return 0;
};
_null_object.attr = function ()
{
return this;
};
_null_object.prop = function ()
{
return this;
};
_null_object.val = function ()
{
return this;
};
_null_object.remove = function ()
{
};
_null_object.getComputedStyle = function ()
{
return null;
};
_null_object.getContext = function (type)
{
if (type == "2d")
return new native_context2d(this);
return null;
};
window._null_object = _null_object;
document.createElement = function (type)
{
if (type && type.toLowerCase)
{
if (type.toLowerCase() == "canvas")
return new native_canvas();
}
return _null_object;
};
function _return_empty_html_element()
{
return _null_object;
};
document.createDocumentFragment = _return_empty_html_element;
document.getElementsByTagName = function (tag)
{
var ret = [];
if ("head" == tag)
ret.push(_null_object);
return ret;
};
document.insertBefore = function ()
{
};
document.appendChild = function ()
{
};
document.removeChild = function ()
{
};
document.getElementById = function ()
{
return _null_object;
};
document.createComment = function ()
{
return undefined;
};
document.documentElement = _null_object;
document.body = _null_object;
var native = (typeof native === undefined) ? undefined : native;
if (!native)
{
if (typeof NativeEngine === "undefined")
{
native = CreateNativeEngine();
}
else
{
native = NativeEngine;
}
}
window.native = native;
function GetNativeEngine()
{
return window.native;
}
var native_renderer = null;
var Api = null;
var _api = null;
function NativeOpenFileData(data, version)
{
window.NATIVE_DOCUMENT_TYPE = window.native.GetEditorType();
if (window.NATIVE_DOCUMENT_TYPE == "presentation" || window.NATIVE_DOCUMENT_TYPE == "document")
{
_api = new window["Asc"]["asc_docs_api"]({});
_api.asc_nativeOpenFile(data, version);
}
else
{
_api = new window["Asc"]["spreadsheet_api"]({});
_api.asc_nativeOpenFile(data, version);
}
Api = _api;
}
function NativeOpenFile()
{
var doc_bin = window.native.GetFileString(window.native.GetFilePath());
window.NATIVE_DOCUMENT_TYPE = window.native.GetEditorType();
if (window.NATIVE_DOCUMENT_TYPE == "presentation" || window.NATIVE_DOCUMENT_TYPE == "document")
{
_api = new window["Asc"]["asc_docs_api"]("");
_api.asc_nativeOpenFile(doc_bin);
}
else
{
_api = new window["Asc"]["spreadsheet_api"]();
_api.asc_nativeOpenFile(doc_bin);
}
Api = _api;
}
function NativeOpenFile2(_params)
{
window["CreateMainTextMeasurerWrapper"]();
window.g_file_path = "native_open_file";
window.NATIVE_DOCUMENT_TYPE = window.native.GetEditorType();
var doc_bin = window.native.GetFileString(window.g_file_path);
if (window.NATIVE_DOCUMENT_TYPE == "presentation" || window.NATIVE_DOCUMENT_TYPE == "document")
{
_api = new window["Asc"]["asc_docs_api"]("");
if (undefined !== _api.Native_Editor_Initialize_Settings)
{
_api.Native_Editor_Initialize_Settings(_params);
}
_api.asc_nativeOpenFile(doc_bin);
if (_api.NativeAfterLoad)
_api.NativeAfterLoad();
// ToDo get_PropertyThemeColorSchemes method removed, now the only Event!!!!
/*if (_api.__SendThemeColorScheme)
_api.__SendThemeColorScheme();
if (_api.get_PropertyThemeColorSchemes)
{
var schemes = _api.get_PropertyThemeColorSchemes();
if (schemes)
{
var st = global_memory_stream_menu;
st["ClearNoAttack"]();
AscCommon.asc_WriteColorSchemes(schemes, st);
window["native"]["OnCallMenuEvent"](2404, st); // ASC_MENU_EVENT_TYPE_COLOR_SCHEMES
}
}*/
}
else
{
_api = new window["Asc"]["spreadsheet_api"]();
_api.asc_nativeOpenFile(doc_bin);
}
Api = _api;
}
function NativeCalculateFile()
{
_api.asc_nativeCalculateFile();
}
function NativeApplyChangesData(data, isFull)
{
if (window.NATIVE_DOCUMENT_TYPE == "presentation" || window.NATIVE_DOCUMENT_TYPE == "document")
{
_api.asc_nativeApplyChanges2(data, isFull);
}
else
{
_api.asc_nativeApplyChanges2(data, isFull);
}
}
function NativeApplyChanges()
{
if (window.NATIVE_DOCUMENT_TYPE == "presentation" || window.NATIVE_DOCUMENT_TYPE == "document")
{
var __changes = [];
var _count_main = window.native.GetCountChanges();
for (var i = 0; i < _count_main; i++)
{
var _changes_file = window.native.GetChangesFile(i);
var _changes = JSON.parse(window.native.GetFileString(_changes_file));
for (var j = 0; j < _changes.length; j++)
{
__changes.push(_changes[j]);
}
}
_api.asc_nativeApplyChanges(__changes);
}
else
{
var __changes = [];
var _count_main = window.native.GetCountChanges();
for (var i = 0; i < _count_main; i++)
{
var _changes_file = window.native.GetChangesFile(i);
var _changes = JSON.parse(window.native.GetFileString(_changes_file));
for (var j = 0; j < _changes.length; j++)
{
__changes.push(_changes[j]);
}
}
_api.asc_nativeApplyChanges(__changes);
}
}
function NativeGetFileString()
{
return _api.asc_nativeGetFile();
}
function NativeGetFileData()
{
return _api.asc_nativeGetFileData();
}
function NativeGetFileDataHtml()
{
if (_api.asc_nativeGetHtml)
return _api.asc_nativeGetHtml();
return "";
}
function NativeStartMailMergeByList(database)
{
if (_api.asc_StartMailMergeByList)
return _api.asc_StartMailMergeByList(database);
return undefined;
}
function NativePreviewMailMergeResult(index)
{
if (_api.asc_PreviewMailMergeResult)
return _api.asc_PreviewMailMergeResult(index);
return undefined;
}
function NativeGetMailMergeFiledValue(index, name)
{
if (_api.asc_GetMailMergeFiledValue)
return _api.asc_GetMailMergeFiledValue(index, name);
return "";
}
function GetNativeCountPages()
{
return _api.asc_nativePrintPagesCount();
}
function GetNativeFileDataPDF(_param)
{
return _api.asc_nativeGetPDF(_param);
}
window.memory1 = null;
window.memory2 = null;
function GetNativePageBase64(pageIndex)
{
if (null == window.memory1)
window.memory1 = CreateNativeMemoryStream();
else
window.memory1.ClearNoAttack();
if (null == window.memory2)
window.memory2 = CreateNativeMemoryStream();
else
window.memory2.ClearNoAttack();
if (native_renderer == null)
{
native_renderer = _api.asc_nativeCheckPdfRenderer(window.memory1, window.memory2);
}
else
{
window.memory1.ClearNoAttack();
window.memory2.ClearNoAttack();
}
_api.asc_nativePrint(native_renderer, pageIndex);
return window.memory1;
}
function GetNativePageMeta(pageIndex)
{
return _api.GetNativePageMeta(pageIndex);
}
function GetNativeId()
{
return window.native.GetFileId();
}
// для работы с таймерами
window.NativeSupportTimeouts = false;
window.NativeTimeoutObject = {};
function clearTimeout(_id)
{
if (!window.NativeSupportTimeouts)
return;
window.NativeTimeoutObject["" + _id] = undefined;
window.native["ClearTimeout"](_id);
}
function setTimeout(func, interval)
{
if (!window.NativeSupportTimeouts)
return;
var _id = window.native["GenerateTimeoutId"](interval);
window.NativeTimeoutObject["" + _id] = func;
return _id;
}
window.native.Call_TimeoutFire = function (_id)
{
if (!window.NativeSupportTimeouts)
return;
var _prop = "" + _id;
var _func = window.NativeTimeoutObject[_prop];
window.NativeTimeoutObject[_prop] = undefined;
if (!_func)
return;
_func.call(null);
_func = null;
};
function clearInterval(_id)
{
if (!window.NativeSupportTimeouts)
return;
window.NativeTimeoutObject["" + _id] = undefined;
window.native["ClearTimeout"](_id);
}
function setInterval(func, interval)
{
if (!window.NativeSupportTimeouts)
return;
var _intervalFunc = function ()
{
func.call(null);
setTimeout(func, interval);
};
var _id = window.native["GenerateTimeoutId"](interval);
window.NativeTimeoutObject["" + _id] = _intervalFunc;
return _id;
}
window.clearTimeout = clearTimeout;
window.setTimeout = setTimeout;
window.clearInterval = clearInterval;
window.setInterval = setInterval;
var console = {
log: function (param)
{
window.native.ConsoleLog(param);
},
time: function (param)
{
},
timeEnd: function (param)
{
}
};
window["NativeCorrectImageUrlOnPaste"] = function (url)
{
return window["native"]["CorrectImageUrlOnPaste"](url);
};
window["NativeCorrectImageUrlOnCopy"] = function (url)
{
return window["native"]["CorrectImageUrlOnCopy"](url);
};
var global_memory_stream_menu = CreateNativeMemoryStream();
// HTML page interface
window.native.Call_OnUpdateOverlay = function (param)
{
return _api.Call_OnUpdateOverlay(param);
};
window.native.Call_OnMouseDown = function (e)
{
return _api.Call_OnMouseDown(e);
};
window.native.Call_OnMouseUp = function (e)
{
return _api.Call_OnMouseUp(e);
};
window.native.Call_OnMouseMove = function (e)
{
return _api.Call_OnMouseMove(e);
};
window.native.Call_OnCheckMouseDown = function (e)
{
return _api.Call_OnCheckMouseDown(e);
};
window.native.Call_OnKeyDown = function (e)
{
return _api.Call_OnKeyDown(e);
};
window.native.Call_OnKeyPress = function (e)
{
return _api.Call_OnKeyPress(e);
};
window.native.Call_OnKeyUp = function (e)
{
return _api.Call_OnKeyUp(e);
};
window.native.Call_OnKeyboardEvent = function (e)
{
return _api.Call_OnKeyboardEvent(e);
};
window.native.Call_CalculateResume = function ()
{
return _api.Call_CalculateResume();
};
window.native.Call_TurnOffRecalculate = function ()
{
return _api.Call_TurnOffRecalculate();
};
window.native.Call_TurnOnRecalculate = function ()
{
return _api.Call_TurnOnRecalculate();
};
window.native.Call_CheckTargetUpdate = function ()
{
return _api.Call_CheckTargetUpdate();
};
window.native.Call_Common = function (type, param)
{
return _api.Call_Common(type, param);
};
window.native.Call_HR_Tabs = function (arrT, arrP)
{
return _api.Call_HR_Tabs(arrT, arrP);
};
window.native.Call_HR_Pr = function (_indent_left, _indent_right, _indent_first)
{
return _api.Call_HR_Pr(_indent_left, _indent_right, _indent_first);
};
window.native.Call_HR_Margins = function (_margin_left, _margin_right)
{
return _api.Call_HR_Margins(_margin_left, _margin_right);
};
window.native.Call_HR_Table = function (_params, _cols, _margins, _rows)
{
return _api.Call_HR_Table(_params, _cols, _margins, _rows);
};
window.native.Call_VR_Margins = function (_top, _bottom)
{
return _api.Call_VR_Margins(_top, _bottom);
};
window.native.Call_VR_Header = function (_header_top, _header_bottom)
{
return _api.Call_VR_Header(_header_top, _header_bottom);
};
window.native.Call_VR_Table = function (_params, _cols, _margins, _rows)
{
return _api.Call_VR_Table(_params, _cols, _margins, _rows);
};
window.native.Call_Menu_Event = function (type, _params)
{
return _api.Call_Menu_Event(type, _params);
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save