Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
5d7fe4fb
Commit
5d7fe4fb
authored
Nov 30, 2016
by
Sergey Luzyanin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New undo-redo scheme
parent
ae3cf693
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
107 additions
and
56 deletions
+107
-56
cell/model/History.js
cell/model/History.js
+69
-44
cell/model/UndoRedo.js
cell/model/UndoRedo.js
+16
-7
cell/view/DrawingObjectsController.js
cell/view/DrawingObjectsController.js
+17
-4
common/CollaborativeEditingBase.js
common/CollaborativeEditingBase.js
+1
-0
word/Editor/DocumentChanges.js
word/Editor/DocumentChanges.js
+4
-1
No files found.
cell/model/History.js
View file @
5d7fe4fb
...
...
@@ -252,10 +252,25 @@ CHistory.prototype.Undo = function()
for
(
var
Index
=
Point
.
Items
.
length
-
1
;
Index
>=
0
;
Index
--
)
{
var
Item
=
Point
.
Items
[
Index
];
if
(
!
Item
.
Class
.
Read_FromBinary2
)
if
(
!
Item
.
Class
.
Read_FromBinary2
&&
!
Item
.
Class
.
IsChangesClass
)
Item
.
Class
.
Undo
(
Item
.
Type
,
Item
.
Data
,
Item
.
SheetId
);
else
Item
.
Class
.
Undo
(
Item
.
Data
);
{
if
(
Item
.
Class
&&
Item
.
Class
.
IsChangesClass
&&
Item
.
Class
.
IsChangesClass
())
{
Item
.
Class
.
Undo
();
Item
.
Class
.
RefreshRecalcData
();
}
else
{
Item
.
Class
.
Undo
(
Item
.
Type
);
Item
.
Class
.
Refresh_RecalcData
(
Item
.
Type
);
}
}
this
.
_addRedoObjectParam
(
oRedoObjectParam
,
Item
);
}
this
.
UndoRedoEnd
(
Point
,
oRedoObjectParam
,
true
);
...
...
@@ -301,26 +316,39 @@ CHistory.prototype.RedoAdd = function(oRedoObjectParam, Class, Type, sheetid, ra
this
.
TurnOff
();
// ToDo Убрать это!!!
if
(
Class
&&
!
Class
.
Load_Changes
)
if
(
Class
&&
!
Class
.
Load_Changes
&&
!
Class
.
Load
)
{
Class
.
Redo
(
Type
,
Data
,
sheetid
);
}
else
{
if
(
!
Data
.
isDrawingCollaborativeData
)
if
(
Class
&&
Data
&&
!
Data
.
isDrawingCollaborativeData
)
Class
.
Redo
(
Data
);
else
{
Data
.
oBinaryReader
.
Seek2
(
Data
.
nPos
);
if
(
!
Class
)
{
Class
=
AscCommon
.
g_oTableId
.
Get_ById
(
Data
.
sChangedObjectId
);
if
(
Class
)
this
.
Add
(
Class
,
Type
,
sheetid
,
range
,
Data
,
LocalChange
);
}
if
(
Class
)
{
Class
.
Load_Changes
(
Data
.
oBinaryReader
,
null
,
new
CDocumentColor
(
255
,
255
,
255
));
if
(
!
Class
){
if
(
Data
.
isDrawingCollaborativeData
){
Data
.
oBinaryReader
.
Seek2
(
Data
.
nPos
);
var
nReaderPos
=
Data
.
oBinaryReader
.
GetCurPos
();
var
nChangesType
=
Data
.
oBinaryReader
.
GetLong
();
var
changedObject
=
AscCommon
.
g_oTableId
.
Get_ById
(
Data
.
sChangedObjectId
);
if
(
changedObject
){
var
fChangesClass
=
AscDFH
.
changesFactory
[
nChangesType
];
if
(
fChangesClass
)
{
var
oChange
=
new
fChangesClass
(
changedObject
);
oChange
.
ReadFromBinary
(
Data
.
oBinaryReader
);
oChange
.
Load
(
new
CDocumentColor
(
255
,
255
,
255
));
}
else
{
Data
.
oBinaryReader
.
Seek2
(
nReaderPos
);
changedObject
.
Load_Changes
(
Data
.
oBinaryReader
,
null
,
new
CDocumentColor
(
255
,
255
,
255
));
}
}
}
}
}
}
...
...
@@ -340,12 +368,24 @@ CHistory.prototype.RedoExecute = function(Point, oRedoObjectParam)
for
(
var
Index
=
0
;
Index
<
Point
.
Items
.
length
;
Index
++
)
{
var
Item
=
Point
.
Items
[
Index
];
if
(
!
Item
.
Class
.
Load_Change
s
)
if
(
!
Item
.
Class
.
Read_FromBinary2
&&
!
Item
.
Class
.
IsChangesClas
s
)
Item
.
Class
.
Redo
(
Item
.
Type
,
Item
.
Data
,
Item
.
SheetId
);
else
{
if
(
!
Item
.
Data
.
isDrawingCollaborativeData
)
Item
.
Class
.
Redo
(
Item
.
Data
);
if
(
!
Item
.
Data
||
!
Item
.
Data
.
isDrawingCollaborativeData
)
{
if
(
Item
.
Class
&&
Item
.
Class
.
IsChangesClass
&&
Item
.
Class
.
IsChangesClass
())
{
Item
.
Class
.
Redo
();
Item
.
Class
.
RefreshRecalcData
();
}
else
{
Item
.
Class
.
Redo
(
Item
.
Type
);
Item
.
Class
.
Refresh_RecalcData
(
Item
.
Type
);
}
}
else
{
Item
.
Data
.
oBinaryReader
.
Seek
(
Item
.
Data
.
nPos
);
...
...
@@ -548,8 +588,10 @@ CHistory.prototype.Get_RecalcData = function(Point2)
{
var
Item
=
Point
.
Items
[
Index
];
if
(
/*true === Item.NeedRecalc*/
Item
.
Class
&&
Item
.
Class
.
Refresh_RecalcData
)
Item
.
Class
.
Refresh_RecalcData
(
Item
.
Data
);
if
(
Item
.
Class
&&
Item
.
Class
.
Refresh_RecalcData
)
Item
.
Class
.
Refresh_RecalcData
(
Item
.
Type
);
else
if
(
Item
.
Class
&&
Item
.
Class
.
RefreshRecalcData
)
Item
.
Class
.
RefreshRecalcData
();
if
(
Item
.
Type
===
AscCH
.
historyitem_Workbook_ChangeColorScheme
&&
Item
.
Class
===
AscCommonExcel
.
g_oUndoRedoWorkbook
)
{
var
wsViews
=
Asc
[
"
editor
"
].
wb
.
wsViews
;
...
...
@@ -694,32 +736,15 @@ CHistory.prototype.Add = function(Class, Type, sheetid, range, Data, LocalChange
var
Item
;
if
(
this
.
RecIndex
>=
this
.
Index
)
this
.
RecIndex
=
this
.
Index
-
1
;
// ToDo Убрать это!!!
if
(
Class
&&
!
Class
.
Save_Changes
)
Item
=
{
Item
=
{
Class
:
Class
,
Type
:
Type
,
SheetId
:
sheetid
,
Range
:
null
,
Data
:
Data
,
LocalChange
:
this
.
LocalChange
};
}
else
{
Item
=
{
Class
:
Class
,
Type
:
Type
.
Type
,
SheetId
:
sheetid
,
Range
:
null
,
Data
:
Type
,
LocalChange
:
this
.
LocalChange
};
}
Class
:
Class
,
Type
:
Type
,
SheetId
:
sheetid
,
Range
:
null
,
Data
:
Data
,
LocalChange
:
this
.
LocalChange
};
if
(
null
!=
range
)
Item
.
Range
=
range
.
clone
();
if
(
null
!=
LocalChange
)
...
...
cell/model/UndoRedo.js
View file @
5d7fe4fb
...
...
@@ -82,7 +82,7 @@ function UndoRedoItemSerializable(oClass, nActionType, nSheetId, oRange, oData,
UndoRedoItemSerializable
.
prototype
=
{
Serialize
:
function
(
oBinaryWriter
,
collaborativeEditing
)
{
if
(
this
.
oData
.
getType
||
this
.
oClass
.
Save_Changes
)
if
(
(
this
.
oData
&&
this
.
oData
.
getType
)
||
this
.
oClass
.
Save_Changes
||
this
.
oClass
.
WriteToBinary
)
{
var
oThis
=
this
;
var
oBinaryCommonWriter
=
new
AscCommon
.
BinaryCommonWriter
(
oBinaryWriter
);
...
...
@@ -92,7 +92,7 @@ UndoRedoItemSerializable.prototype = {
SerializeInner
:
function
(
oBinaryWriter
,
collaborativeEditing
)
{
//nClassType
if
(
!
this
.
oClass
.
Save_Changes
)
if
(
!
this
.
oClass
.
Save_Changes
&&
!
this
.
oClass
.
WriteToBinary
)
{
oBinaryWriter
.
WriteBool
(
true
);
var
nClassType
=
this
.
oClass
.
getClassType
();
...
...
@@ -139,9 +139,20 @@ UndoRedoItemSerializable.prototype = {
else
{
oBinaryWriter
.
WriteBool
(
false
);
oBinaryWriter
.
WriteString2
(
this
.
oClass
.
Get_Id
());
var
Class
;
if
(
this
.
oClass
&&
this
.
oClass
.
IsChangesClass
&&
this
.
oClass
.
IsChangesClass
())
{
Class
=
this
.
oClass
.
GetClass
();
oBinaryWriter
.
WriteString2
(
Class
.
Get_Id
());
oBinaryWriter
.
WriteLong
(
this
.
oClass
.
Type
);
this
.
oClass
.
WriteToBinary
(
oBinaryWriter
);
}
else
{
oBinaryWriter
.
WriteString2
(
this
.
oClass
.
Get_Id
());
this
.
oClass
.
Save_Changes
(
this
.
nActionType
,
oBinaryWriter
);
}
this
.
oClass
.
Save_Changes
(
this
.
oData
,
oBinaryWriter
);
}
},
SerializeDataObject
:
function
(
oBinaryWriter
,
oData
,
nSheetId
,
collaborativeEditing
)
...
...
@@ -281,14 +292,12 @@ UndoRedoItemSerializable.prototype = {
else
{
var
changedObjectId
=
oBinaryReader
.
GetString2
();
var
changedObject
=
AscCommon
.
g_oTableId
.
Get_ById
(
changedObjectId
);
this
.
nActionType
=
1
;
this
.
oClass
=
changedObject
;
this
.
oData
=
new
DrawingCollaborativeData
();
this
.
oData
.
oClass
=
changedObject
;
this
.
oData
.
sChangedObjectId
=
changedObjectId
;
this
.
oData
.
oBinaryReader
=
oBinaryReader
;
this
.
oData
.
nPos
=
oBinaryReader
.
cur
;
}
},
DeserializeData
:
function
(
oBinaryReader
)
...
...
cell/view/DrawingObjectsController.js
View file @
5d7fe4fb
...
...
@@ -59,10 +59,23 @@ AscCommon.CContentChangesElement.prototype.Refresh_BinaryData = function()
var
Binary_Writer
=
History
.
BinaryWriter
;
var
Binary_Pos
=
Binary_Writer
.
GetCurPosition
();
this
.
m_pData
.
Data
.
UseArray
=
true
;
this
.
m_pData
.
Data
.
PosArray
=
this
.
m_aPositions
;
Binary_Writer
.
WriteString2
(
this
.
m_pData
.
Class
.
Get_Id
());
this
.
m_pData
.
Class
.
Save_Changes
(
this
.
m_pData
.
Data
,
Binary_Writer
);
if
(
this
.
m_pData
.
Data
&&
this
.
m_pData
.
Data
.
IsChangesClass
&&
this
.
m_pData
.
Data
.
IsChangesClass
())
{
this
.
m_pData
.
Data
.
UseArray
=
true
;
this
.
m_pData
.
Data
.
PosArray
=
this
.
m_aPositions
;
Binary_Writer
.
WriteString2
(
this
.
m_pData
.
Class
.
Get_Id
());
Binary_Writer
.
WriteLong
(
this
.
m_pData
.
Data
.
Type
);
this
.
m_pData
.
Data
.
WriteToBinary
(
Binary_Writer
);
}
else
{
this
.
m_pData
.
Data
.
UseArray
=
true
;
this
.
m_pData
.
Data
.
PosArray
=
this
.
m_aPositions
;
Binary_Writer
.
WriteString2
(
this
.
m_pData
.
Class
.
Get_Id
());
this
.
m_pData
.
Class
.
Save_Changes
(
this
.
m_pData
.
Data
,
Binary_Writer
);
}
var
Binary_Len
=
Binary_Writer
.
GetCurPosition
()
-
Binary_Pos
;
...
...
common/CollaborativeEditingBase.js
View file @
5d7fe4fb
...
...
@@ -743,6 +743,7 @@ CCollaborativeEditingBase.prototype.InitMemory = function() {
};
CCollaborativeEditingBase
.
prototype
.
private_AddOverallChange
=
function
(
oChange
)
{
return
true
;
};
...
...
word/Editor/DocumentChanges.js
View file @
5d7fe4fb
...
...
@@ -300,7 +300,10 @@ CChangesDocumentRemoveItem.prototype.Load = function(Color)
oDocument
.
Content
[
Pos
].
Prev
=
null
;
}
oDocument
.
SectionsInfo
.
Update_OnRemove
(
Pos
,
1
);
if
(
oDocument
.
SectionsInfo
)
{
oDocument
.
SectionsInfo
.
Update_OnRemove
(
Pos
,
1
);
}
oDocument
.
private_ReindexContent
(
Pos
);
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment