Smaller theme patches in OO slides

pull/1/head
yflory 3 years ago
parent 21d6057c1f
commit df440b19df

@ -1077,17 +1077,31 @@ define([
return; return;
} }
var type = common.getMetadataMgr().getPrivateData().ooType; var type = common.getMetadataMgr().getPrivateData().ooType;
var b = obj.block && obj.block[0];
content.locks = content.locks || {};
// Send the lock to other users
var msg = { var msg = {
time: now(), time: now(),
user: myUniqueOOId, user: myUniqueOOId,
block: obj.block && obj.block[0], block: b
}; };
var editor = getEditor();
if (type === "presentation" && (APP.themeChanged || APP.themeRemote) && b &&
b.guid === editor.GetPresentation().Presentation.themeLock.Id) {
APP.themeLocked = APP.themeChanged;
APP.themeChanged = undefined;
var fakeLocks = getLock();
fakeLocks[Util.uid()] = msg;
send({
type: "getLock",
locks: fakeLocks
});
return;
}
content.locks = content.locks || {};
// Send the lock to other users
var myId = getId(); var myId = getId();
content.locks[myId] = content.locks[myId] || {}; content.locks[myId] = content.locks[myId] || {};
var b = obj.block && obj.block[0];
if (type === "sheet" || typeof(b) !== "string") { if (type === "sheet" || typeof(b) !== "string") {
var uid = Util.uid(); var uid = Util.uid();
content.locks[myId][uid] = msg; content.locks[myId][uid] = msg;
@ -1098,15 +1112,6 @@ define([
// Remove old locks // Remove old locks
deleteOfflineLocks(); deleteOfflineLocks();
var editor = getEditor();
console.error(type, APP.themeChanged, b, b.guid, editor.GetPresentation().Presentation.themeLock.Id, typeof(b.guid));
if (type === "presentation" && APP.themeChanged && b &&
b.guid === editor.GetPresentation().Presentation.themeLock.Id) {
console.error('OK');
APP.themeLocked = APP.themeChanged;
APP.themeChanged = undefined;
}
// Prepare callback // Prepare callback
if (cpNfInner) { if (cpNfInner) {
var waitLock = APP.waitLock = Util.mkEvent(true); var waitLock = APP.waitLock = Util.mkEvent(true);
@ -1148,7 +1153,7 @@ define([
APP.realtime.sync(); APP.realtime.sync();
}; };
var parseChanges = function (changes) { var parseChanges = function (changes, isObj) {
try { try {
changes = JSON.parse(changes); changes = JSON.parse(changes);
} catch (e) { } catch (e) {
@ -1157,7 +1162,7 @@ define([
return changes.map(function (change) { return changes.map(function (change) {
return { return {
docid: "fresh", docid: "fresh",
change: '"' + change + '"', change: isObj ? change : '"' + change + '"',
time: now(), time: now(),
user: myUniqueOOId, user: myUniqueOOId,
useridoriginal: String(myOOId) useridoriginal: String(myOOId)
@ -1188,11 +1193,16 @@ define([
return; return;
} }
var changes = obj.changes;
if (obj.type === "cp_theme") {
changes = JSON.stringify([JSON.stringify(obj)]);
}
// Send the changes // Send the changes
content.locks = content.locks || {}; content.locks = content.locks || {};
rtChannel.sendMsg({ rtChannel.sendMsg({
type: "saveChanges", type: "saveChanges",
changes: parseChanges(obj.changes), changes: parseChanges(changes, obj.type === "cp_theme"),
changesIndex: ooChannel.cpIndex || 0, changesIndex: ooChannel.cpIndex || 0,
locks: getUserLock(getId(), true), locks: getUserLock(getId(), true),
excelAdditionalInfo: obj.excelAdditionalInfo excelAdditionalInfo: obj.excelAdditionalInfo
@ -1322,6 +1332,16 @@ define([
obj.type = "cp_theme"; obj.type = "cp_theme";
console.error(obj); console.error(obj);
} }
if (APP.themeRemote) {
delete APP.themeRemote;
send({
type: "unSaveLock",
index: ooChannel.cpIndex,
time: +new Date()
});
return;
}
// We're sending our changes to netflux // We're sending our changes to netflux
handleChanges(obj, send); handleChanges(obj, send);
// If we're alone, clean up the medias // If we're alone, clean up the medias
@ -1653,32 +1673,13 @@ define([
}); });
}; };
APP.changeTheme = function (id, selected) { APP.remoteTheme = function () {
var slides; APP.themeRemote = true;
// If "selected" is undefined, apply to selection if more than one };
// slide is selected. APP.changeTheme = function (id) {
// If it's true, apply to the selected slides
// If it's false, apply to the entire presentation
var editor = getEditor();
if (typeof(selected) === "undefined") {
slides = editor.WordControl.Thumbnails.GetSelectedArray();
if (slides.length === 1) { slides = undefined; }
} else if (selected) {
slides = editor.WordControl.Thumbnails.GetSelectedArray();
}
APP.themeChanged = { APP.themeChanged = {
slides: slides,
id: id id: id
}; };
console.error(slides, id);
// XXX ChangeTheme(themeId, selectedSlides)
// editor.WordControl.Thumbnails.GetSelectedArray()
// editor.WordControl.Thumbnails.SelectPage(id)
/*
editor.WordControl.Thumbnails.m_arrPages.forEach(function (obj) {
obj.IsSelected = [0,1].indexOf(obj.pageIndex) !== -1
});
*/
}; };
APP.openURL = function (url) { APP.openURL = function (url) {
common.openUnsafeURL(url); common.openUnsafeURL(url);

Loading…
Cancel
Save