Commit cbe81145 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander.Trofimov

Bug 25578 - [CoEdit] Другому пользователю приходит инвертированный порядок листов при подключении.

частично отменены изменения Revision: 57134. добавленные между сохранениями шрифты хранятся в истории.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57663 954022d7-b5bf-4e40-9824-e11837661b57
parent 356cf0b6
......@@ -1268,14 +1268,9 @@ DrawingObjectsController.prototype =
},
setCellFontName: function (fontName) {
var t = this;
var text_pr = new ParaTextPr({ FontFamily : { Name : fontName , Index : -1 } });
this.checkSelectedObjectsAndCallback(function () {
// ToDo стоит перейти на проверку шрифтов на deserialize
History.Add(g_oUndoRedoWorkbook, historyitem_Workbook_AddFont, null, null,
new UndoRedoData_SingleProperty([fontName]), true);
t.paragraphAdd(text_pr);
}, []);
this.checkSelectedObjectsAndCallback(this.paragraphAdd, [text_pr]);
},
setCellFontSize: function (fontSize) {
......
......@@ -1338,6 +1338,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
_loadFonts: function (fonts, callback) {
if (window["NATIVE_EDITOR_ENJINE"])
return callback();
History.loadFonts(fonts);
this.asyncMethodCallback = callback;
var arrLoadFonts = [];
for(var i in fonts)
......
......@@ -8,7 +8,6 @@ var historyitem_Workbook_SheetMove = 3;
var historyitem_Workbook_SheetPositions = 4;
var historyitem_Workbook_ChangeColorScheme = 5;
var historyitem_Workbook_AddFont = 6;
var historyitem_Workbook_AddFont2 = 7;
var historyitem_Worksheet_RemoveCell = 1;
var historyitem_Worksheet_RemoveRows = 2;
......@@ -183,6 +182,7 @@ function CHistory(workbook)
this.RecIndex = -1;
this.lastDrawingObjects = null;
this.LastState = null;
this.LoadFonts = {};//собираем все загруженные шрифты между моментами сохранения
this.SavedIndex = null; // Номер точки отката, на которой произошло последнее сохранение
}
......@@ -195,6 +195,7 @@ CHistory.prototype.Clear = function()
this.IsModify = false;
this.TurnOffHistory = 0;
this.Transaction = 0;
this.LoadFonts = {};
this.SavedIndex = null;
......@@ -803,6 +804,14 @@ CHistory.prototype.GetSerializeArray = function()
}
aRes.push(aPointChanges);
}
if (aRes.length > 0) {
var aFonts = [];
for (var i in this.LoadFonts)
aFonts.push(i);
//добавляем в начало, чтобы не потерять это изменение при undo/redo и обрезке изменений
if(aFonts.length > 0)
aRes[0].push(new UndoRedoItemSerializable(g_oUndoRedoWorkbook, historyitem_Workbook_AddFont, null, null, new UndoRedoData_SingleProperty(aFonts)));
}
return aRes;
};
//функция, которая перемещает последнее действие на первую позицию(в текущей точке)
......@@ -814,3 +823,7 @@ CHistory.prototype.ChangeActionsEndToStart = function()
this.CurPoint.Items.unshift(endAction);
}
};
CHistory.prototype.loadFonts = function (fonts) {
for (var i in fonts)
this.LoadFonts[i] = 1;
};
......@@ -1782,44 +1782,31 @@ Workbook.prototype.SerializeHistory = function(){
{
var oMemory = new CMemory();
var oThis = this;
var oFontMap = {};
var bChangeSheetPlace = false;
var aPointChangesBase64;
for(var i = 0, length = aActions.length; i < length; ++i)
{
var aPointChanges = aActions[i];
aPointChangesBase64 = [];
bChangeSheetPlace = false;
for (var j = 0, length2 = aPointChanges.length; j < length2; ++j) {
var item = aPointChanges[j];
if (g_oUndoRedoWorkbook == item.oClass) {
if (historyitem_Workbook_AddFont == item.nActionType) {
for (var k = 0, length3 = item.oData.elem.length; k < length3; ++k)
oFontMap[item.oData.elem[k]] = 1;
}
else if (historyitem_Workbook_SheetAdd == item.nActionType || historyitem_Workbook_SheetRemove == item.nActionType || historyitem_Workbook_SheetMove == item.nActionType)
if (historyitem_Workbook_SheetAdd == item.nActionType || historyitem_Workbook_SheetRemove == item.nActionType || historyitem_Workbook_SheetMove == item.nActionType)
bChangeSheetPlace = true;
}
this._SerializeHistoryBase64(oMemory, item, aPointChangesBase64);
}
aRes.push(aPointChangesBase64);
}
aPointChangesBase64 = [];
var aFonts = [];
for (var i in oFontMap)
aFonts.push(i);
if (aFonts.length > 0)
this._SerializeHistoryBase64(oMemory, new UndoRedoItemSerializable(g_oUndoRedoWorkbook, historyitem_Workbook_AddFont2, null, null, new UndoRedoData_SingleProperty(aFonts)), aPointChangesBase64);
if (bChangeSheetPlace) {
//создаем еще один элемент в undo/redo - взаимное расположение Sheet, чтобы не запутываться в add, move событиях
//добавляем не после конца aActions, чтобы можно было делать undo/redo и просто удалять хвост изменений.
var oSheetPlaceData = [];
for (var i = 0, length = this.aWorksheets.length; i < length; ++i)
oSheetPlaceData.push(this.aWorksheets[i].getId());
for (var j = 0, length2 = this.aWorksheets.length; j < length2; ++j)
oSheetPlaceData.push(this.aWorksheets[j].getId());
this._SerializeHistoryBase64(oMemory, new UndoRedoItemSerializable(g_oUndoRedoWorkbook, historyitem_Workbook_SheetPositions, null, null, new UndoRedoData_SheetPositions(oSheetPlaceData)), aPointChangesBase64);
}
if (aPointChangesBase64.length > 0)
aRes.push(aPointChangesBase64);
}
this.aCollaborativeActions = [];
}
return aRes;
......@@ -1865,7 +1852,7 @@ Workbook.prototype.DeserializeHistory = function(aChanges, fCallback){
nCurOffset = oBinaryFileReader.getbase64DecodedData2(sChange, aIndexesPoint[j], stream, nCurOffset);
var item = new UndoRedoItemSerializable();
item.Deserialize(stream);
if (g_oUndoRedoWorkbook == item.oClass && historyitem_Workbook_AddFont2 == item.nActionType) {
if (g_oUndoRedoWorkbook == item.oClass && historyitem_Workbook_AddFont == item.nActionType) {
for (var k = 0, length3 = item.oData.elem.length; k < length3; ++k)
oFontMap[item.oData.elem[k]] = 1;
}
......
......@@ -1714,7 +1714,6 @@
targetContent.Remove(1, true, true);
worksheet._loadFonts(newFonts, function () {
worksheet._addFontsToHistory(newFonts);
oPasteProcessor.InsertInPlace(targetContent , oPasteProcessor.aContent);
worksheet.objectRender.controller.startRecalculate();
......
......@@ -7942,13 +7942,7 @@
History.StartTransaction();
switch (prop) {
case "fn":
// ToDo стоит перейти на проверку шрифтов на deserialize
History.Add(g_oUndoRedoWorkbook, historyitem_Workbook_AddFont, null, null,
new UndoRedoData_SingleProperty([val]), true);
range.setFontname(val);
canChangeColWidth = c_oAscCanChangeColWidth.numbers;
break;
case "fn": range.setFontname(val); canChangeColWidth = c_oAscCanChangeColWidth.numbers; break;
case "fs": range.setFontsize(val); canChangeColWidth = c_oAscCanChangeColWidth.numbers; break;
case "b": range.setBold(val); break;
case "i": range.setItalic(val); break;
......@@ -8219,8 +8213,6 @@
var t = this;
//загрузка шрифтов, в случае удачи на callback вставляем текст
t._loadFonts(val.fontsNew, function () {
t._addFontsToHistory(val.fontsNew);
if(val.onlyImages !== true)
t._pasteFromLocalBuff(isLargeRange, isLocal, val, bIsUpdate, canChangeColWidth);
......@@ -8839,10 +8831,6 @@
var arrFormula = [];
var numFor = 0;
// ToDo не совсем грамотная правка, но пока так
var newFonts = {};
this._addFontsToHistory(val.generateFontMap(newFonts));
var pasteRange = window["Asc"]["editor"].wb.clipboard.activeRange;
var activeCellsPasteFragment = this.autoFilters._refToRange(pasteRange);
var rMax = (activeCellsPasteFragment.r2 - activeCellsPasteFragment.r1) + arn.r1 + 1;
......@@ -10822,15 +10810,6 @@
api._loadFonts(fonts, callback);
};
WorksheetView.prototype._addFontsToHistory = function (fonts) {
var arrNewFonts = [];
for (var oFontName in fonts)
arrNewFonts.push(oFontName);
// ToDo стоит перейти на проверку шрифтов на deserialize
History.Add(g_oUndoRedoWorkbook, historyitem_Workbook_AddFont, null, null,
new UndoRedoData_SingleProperty(arrNewFonts), true);
};
/*
* Export
* -----------------------------------------------------------------------------
......
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