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