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
5f3b1e41
Commit
5f3b1e41
authored
Mar 03, 2017
by
Ilya Kirillov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reworked algorithm of Undo in fast collaboration mode. Fixed bug #33883. Fixed bug #33884.
parent
3a65ee43
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
66 deletions
+65
-66
common/CollaborativeEditingBase.js
common/CollaborativeEditingBase.js
+53
-66
common/HistoryCommon.js
common/HistoryCommon.js
+12
-0
No files found.
common/CollaborativeEditingBase.js
View file @
5f3b1e41
...
...
@@ -880,15 +880,10 @@ CCollaborativeEditingBase.prototype.private_RestoreDocumentState = function(DocS
// Объектная модель у нас простая: класс, в котором возможно есть массив элементов(тоже классов), у которого воможно
// есть набор свойств. Поэтому у нас ровно 2 типа изменений: изменения внутри массива элементов, либо изменения
// свойств. Изменения этих двух типов коммутируют между собой, изменения разных классов тоже коммутируют.
var
arrChanges
=
[];
var
oIndexes
=
this
.
m_aOwnChangesIndexes
[
this
.
m_aOwnChangesIndexes
.
length
-
1
];
var
nPosition
=
oIndexes
.
Position
;
var
nCount
=
oIndexes
.
Count
;
var
nOverallCount
=
this
.
m_aAllChanges
.
length
;
var
oContentChangesMap
=
{
};
var
arrChanges
=
[];
var
oIndexes
=
this
.
m_aOwnChangesIndexes
[
this
.
m_aOwnChangesIndexes
.
length
-
1
];
var
nPosition
=
oIndexes
.
Position
;
var
nCount
=
oIndexes
.
Count
;
for
(
var
nIndex
=
nCount
-
1
;
nIndex
>=
0
;
--
nIndex
)
{
...
...
@@ -901,8 +896,10 @@ CCollaborativeEditingBase.prototype.private_RestoreDocumentState = function(DocS
{
var
_oChange
=
oChange
.
Copy
();
if
(
this
.
private_CommutateContentChanges
(
oContentChangesMap
,
oClass
,
_oChange
,
nPosition
+
nCount
))
arrChanges
.
push
(
_oChange
);
if
(
this
.
private_CommutateContentChanges
(
_oChange
,
nPosition
+
nCount
))
arrChanges
.
push
(
_oChange
);
oChange
.
SetReverted
(
true
);
}
else
{
...
...
@@ -921,7 +918,10 @@ CCollaborativeEditingBase.prototype.private_RestoreDocumentState = function(DocS
{
var
oReverseChange
=
arrChanges
[
nIndex
].
CreateReverseChange
();
if
(
oReverseChange
)
{
arrReverseChanges
.
push
(
oReverseChange
);
oReverseChange
.
SetReverted
(
true
);
}
}
// Накатываем изменения в данном клиенте
...
...
@@ -1096,69 +1096,56 @@ CCollaborativeEditingBase.prototype.private_RestoreDocumentState = function(DocS
{
return
this
.
m_aOwnChangesIndexes
.
length
<=
0
?
false
:
true
;
};
CCollaborativeEditingBase
.
prototype
.
private_CommutateContentChanges
=
function
(
oMap
,
oClass
,
oChange
,
nStartPosition
)
{
var
arrOtherActions
=
[];
if
(
oMap
[
oClass
.
Get_Id
()])
{
arrOtherActions
=
oMap
[
oClass
.
Get_Id
()];
}
else
{
for
(
var
nIndex
=
nStartPosition
,
nOverallCount
=
this
.
m_aAllChanges
.
length
;
nIndex
<
nOverallCount
;
++
nIndex
)
{
var
oTempChange
=
this
.
m_aAllChanges
[
nIndex
];
if
(
!
oTempChange
)
continue
;
if
(
oChange
.
IsRelated
(
oTempChange
))
{
arrOtherActions
.
push
(
oTempChange
.
ConvertToSimpleActions
());
}
}
oMap
[
oClass
.
Get_Id
()]
=
arrOtherActions
;
}
CCollaborativeEditingBase
.
prototype
.
private_CommutateContentChanges
=
function
(
oChange
,
nStartPosition
)
{
var
arrActions
=
oChange
.
ConvertToSimpleActions
();
var
arrCommutateActions
=
[];
var
arrActions
=
oChange
.
ConvertToSimpleActions
();
for
(
var
nActionIndex
=
arrActions
.
length
-
1
;
nActionIndex
>=
0
;
--
nActionIndex
)
{
var
oAction
=
arrActions
[
nActionIndex
];
var
oResult
=
oAction
;
var
arrCommutateActions
=
[];
for
(
var
nActionIndex
=
arrActions
.
length
-
1
;
nActionIndex
>=
0
;
--
nActionIndex
)
{
var
oAction
=
arrActions
[
nActionIndex
];
var
oResult
=
oAction
;
for
(
var
nIndex
=
nStartPosition
,
nOverallCount
=
this
.
m_aAllChanges
.
length
;
nIndex
<
nOverallCount
;
++
nIndex
)
{
var
oTempChange
=
this
.
m_aAllChanges
[
nIndex
];
if
(
!
oTempChange
)
continue
;
for
(
var
nIndex
=
0
,
nOtherActionsCount
=
arrOtherActions
.
length
;
nIndex
<
nOtherActionsCount
;
++
nIndex
)
{
var
arrOActions
=
arrOtherActions
[
nIndex
];
for
(
var
nIndex2
=
0
,
nOtherActionsCount2
=
arrOActions
.
length
;
nIndex2
<
nOtherActionsCount2
;
++
nIndex2
)
{
var
oOtherAction
=
arrOActions
[
nIndex2
];
if
(
oChange
.
IsRelated
(
oTempChange
)
&&
true
!==
oTempChange
.
IsReverted
())
{
var
arrOtherActions
=
oTempChange
.
ConvertToSimpleActions
();
for
(
var
nIndex2
=
0
,
nOtherActionsCount2
=
arrOtherActions
.
length
;
nIndex2
<
nOtherActionsCount2
;
++
nIndex2
)
{
var
oOtherAction
=
arrOtherActions
[
nIndex2
];
if
(
false
===
this
.
private_Commutate
(
oAction
,
oOtherAction
))
{
arrOtherActions
.
splice
(
nIndex2
,
1
);
oResult
=
null
;
break
;
}
}
oTempChange
.
ConvertFromSimpleActions
(
arrOtherActions
);
}
if
(
false
===
this
.
private_Commutate
(
oAction
,
oOtherAction
))
{
arrOActions
.
splice
(
nIndex2
,
1
);
oResult
=
null
;
break
;
}
}
if
(
!
oResult
)
break
;
if
(
null
===
oResult
)
break
;
}
}
if
(
null
!==
oResult
)
arrCommutateActions
.
push
(
oResult
);
}
if
(
null
!==
oResult
)
arrCommutateActions
.
push
(
oResult
);
}
if
(
arrCommutateActions
.
length
>
0
)
oChange
.
ConvertFromSimpleActions
(
arrCommutateActions
);
else
return
false
;
if
(
arrCommutateActions
.
length
>
0
)
oChange
.
ConvertFromSimpleActions
(
arrCommutateActions
);
else
return
false
;
return
true
;
};
return
true
;
};
CCollaborativeEditingBase
.
prototype
.
private_Commutate
=
function
(
oActionL
,
oActionR
)
{
if
(
oActionL
.
Add
)
...
...
common/HistoryCommon.js
View file @
5f3b1e41
...
...
@@ -2898,6 +2898,8 @@
function
CChangesBase
(
Class
)
{
this
.
Class
=
Class
;
this
.
Reverted
=
false
;
}
CChangesBase
.
prototype
.
Type
=
window
[
'
AscDFH
'
].
historyitem_Unknown_Unknown
;
CChangesBase
.
prototype
.
Undo
=
function
()
...
...
@@ -2949,6 +2951,14 @@
{
return
false
;
};
CChangesBase
.
prototype
.
IsReverted
=
function
()
{
return
this
.
Reverted
;
};
CChangesBase
.
prototype
.
SetReverted
=
function
(
isReverted
)
{
this
.
Reverted
=
isReverted
;
};
window
[
'
AscDFH
'
].
CChangesBase
=
CChangesBase
;
/**
* Базовый класс для изменений, которые меняют содержимое родительского класса.*
...
...
@@ -2964,6 +2974,8 @@
this
.
UseArray
=
false
;
this
.
PosArray
=
[];
this
.
Add
=
isAdd
;
this
.
Reverted
=
false
;
}
AscCommon
.
extendClass
(
CChangesBaseContentChange
,
CChangesBase
);
CChangesBaseContentChange
.
prototype
.
IsContentChange
=
function
()
...
...
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