Commit faa16119 authored by Ilya Kirillov's avatar Ilya Kirillov

Implemented locking a changing content or/and deleting of a content control.

parent 18d5bd2b
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
// Import // Import
var locktype_None = AscCommon.locktype_None; var locktype_None = AscCommon.locktype_None;
var locktype_Mine = AscCommon.locktype_Mine; var locktype_Mine = AscCommon.locktype_Mine;
var changestype_Paragraph_Content = AscCommon.changestype_Paragraph_Content;
if(typeof CDocument !== "undefined") if(typeof CDocument !== "undefined")
{ {
...@@ -202,7 +201,7 @@ CAbstractNum.prototype.Document_Is_SelectionLocked = function(CheckType) ...@@ -202,7 +201,7 @@ CAbstractNum.prototype.Document_Is_SelectionLocked = function(CheckType)
{ {
switch ( CheckType ) switch ( CheckType )
{ {
case changestype_Paragraph_Content: case AscCommon.changestype_Paragraph_Content:
case AscCommon.changestype_Paragraph_Properties: case AscCommon.changestype_Paragraph_Properties:
{ {
this.Lock.Check( this.Get_Id() ); this.Lock.Check( this.Get_Id() );
...@@ -236,7 +235,7 @@ if(typeof CGraphicObjects !== "undefined") ...@@ -236,7 +235,7 @@ if(typeof CGraphicObjects !== "undefined")
|| AscCommon.changestype_Image_Properties === CheckType || AscCommon.changestype_Image_Properties === CheckType
|| AscCommon.changestype_Delete === CheckType || AscCommon.changestype_Delete === CheckType
|| AscCommon.changestype_Remove === CheckType || AscCommon.changestype_Remove === CheckType
|| changestype_Paragraph_Content === CheckType || AscCommon.changestype_Paragraph_Content === CheckType
|| AscCommon.changestype_Paragraph_Properties === CheckType || AscCommon.changestype_Paragraph_Properties === CheckType
|| AscCommon.changestype_Document_Content_Add === CheckType) || AscCommon.changestype_Document_Content_Add === CheckType)
{ {
...@@ -260,7 +259,7 @@ CStyle.prototype.Document_Is_SelectionLocked = function(CheckType) ...@@ -260,7 +259,7 @@ CStyle.prototype.Document_Is_SelectionLocked = function(CheckType)
{ {
switch ( CheckType ) switch ( CheckType )
{ {
case changestype_Paragraph_Content: case AscCommon.changestype_Paragraph_Content:
case AscCommon.changestype_Paragraph_Properties: case AscCommon.changestype_Paragraph_Properties:
case AscCommon.changestype_Document_Content: case AscCommon.changestype_Document_Content:
case AscCommon.changestype_Document_Content_Add: case AscCommon.changestype_Document_Content_Add:
...@@ -281,7 +280,7 @@ CStyles.prototype.Document_Is_SelectionLocked = function(CheckType) ...@@ -281,7 +280,7 @@ CStyles.prototype.Document_Is_SelectionLocked = function(CheckType)
{ {
switch ( CheckType ) switch ( CheckType )
{ {
case changestype_Paragraph_Content: case AscCommon.changestype_Paragraph_Content:
case AscCommon.changestype_Paragraph_Properties: case AscCommon.changestype_Paragraph_Properties:
case AscCommon.changestype_Document_Content: case AscCommon.changestype_Document_Content:
case AscCommon.changestype_Document_Content_Add: case AscCommon.changestype_Document_Content_Add:
...@@ -363,17 +362,31 @@ CDocumentContent.prototype.Document_Is_SelectionLocked = function(CheckType) ...@@ -363,17 +362,31 @@ CDocumentContent.prototype.Document_Is_SelectionLocked = function(CheckType)
} }
} }
}; };
CDocumentContent.prototype.CheckContentControlEditingLock = function()
{
if (this.Parent && this.Parent.CheckContentControlEditingLock)
this.Parent.CheckContentControlEditingLock();
};
CDocumentContent.prototype.CheckContentControlDeletingLock = function()
{
for (var nIndex = 0, nCount = this.Content.length; nIndex < nCount; ++nIndex)
{
this.Content[nIndex].CheckContentControlDeletingLock();
}
};
Paragraph.prototype.Document_Is_SelectionLocked = function(CheckType) Paragraph.prototype.Document_Is_SelectionLocked = function(CheckType)
{ {
var bCheckContentControl = false;
switch ( CheckType ) switch ( CheckType )
{ {
case changestype_Paragraph_Content: case AscCommon.changestype_Paragraph_Content:
case AscCommon.changestype_Paragraph_Properties: case AscCommon.changestype_Paragraph_Properties:
case AscCommon.changestype_Document_Content: case AscCommon.changestype_Document_Content:
case AscCommon.changestype_Document_Content_Add: case AscCommon.changestype_Document_Content_Add:
case AscCommon.changestype_Image_Properties: case AscCommon.changestype_Image_Properties:
{ {
this.Lock.Check( this.Get_Id() ); this.Lock.Check( this.Get_Id() );
bCheckContentControl = true;
break; break;
} }
case AscCommon.changestype_Remove: case AscCommon.changestype_Remove:
...@@ -416,7 +429,7 @@ Paragraph.prototype.Document_Is_SelectionLocked = function(CheckType) ...@@ -416,7 +429,7 @@ Paragraph.prototype.Document_Is_SelectionLocked = function(CheckType)
} }
this.Lock.Check( this.Get_Id() ); this.Lock.Check( this.Get_Id() );
bCheckContentControl = true;
break; break;
} }
case AscCommon.changestype_Delete: case AscCommon.changestype_Delete:
...@@ -450,7 +463,7 @@ Paragraph.prototype.Document_Is_SelectionLocked = function(CheckType) ...@@ -450,7 +463,7 @@ Paragraph.prototype.Document_Is_SelectionLocked = function(CheckType)
} }
this.Lock.Check( this.Get_Id() ); this.Lock.Check( this.Get_Id() );
bCheckContentControl = true;
break; break;
} }
case AscCommon.changestype_Document_SectPr: case AscCommon.changestype_Document_SectPr:
...@@ -462,12 +475,18 @@ Paragraph.prototype.Document_Is_SelectionLocked = function(CheckType) ...@@ -462,12 +475,18 @@ Paragraph.prototype.Document_Is_SelectionLocked = function(CheckType)
break; break;
} }
} }
if (bCheckContentControl && this.Parent && this.Parent.CheckContentControlEditingLock)
this.Parent.CheckContentControlEditingLock();
};
Paragraph.prototype.CheckContentControlDeletingLock = function()
{
}; };
CTable.prototype.Document_Is_SelectionLocked = function(CheckType, bCheckInner) CTable.prototype.Document_Is_SelectionLocked = function(CheckType, bCheckInner)
{ {
switch (CheckType) switch (CheckType)
{ {
case changestype_Paragraph_Content: case AscCommon.changestype_Paragraph_Content:
case AscCommon.changestype_Paragraph_Properties: case AscCommon.changestype_Paragraph_Properties:
case AscCommon.changestype_Document_Content: case AscCommon.changestype_Document_Content:
case AscCommon.changestype_Document_Content_Add: case AscCommon.changestype_Document_Content_Add:
...@@ -497,9 +516,21 @@ CTable.prototype.Document_Is_SelectionLocked = function(CheckType, bCheckInner) ...@@ -497,9 +516,21 @@ CTable.prototype.Document_Is_SelectionLocked = function(CheckType, bCheckInner)
case AscCommon.changestype_Remove: case AscCommon.changestype_Remove:
{ {
if (true === this.ApplyToAll || (true === this.Selection.Use && table_Selection_Cell === this.Selection.Type)) if (true === this.ApplyToAll || (true === this.Selection.Use && table_Selection_Cell === this.Selection.Type))
{
this.Lock.Check(this.Get_Id()); this.Lock.Check(this.Get_Id());
var arrCells = this.Internal_Get_SelectionArray();
for (var nIndex = 0, nCellsCount = arrCells.length; nIndex < nCellsCount; ++nIndex)
{
var Pos = arrCells[nIndex];
var Cell = this.Content[Pos.Row].Get_Cell(Pos.Cell);
Cell.Content.CheckContentControlDeletingLock();
}
}
else else
{
this.CurCell.Content.Document_Is_SelectionLocked(CheckType); this.CurCell.Content.Document_Is_SelectionLocked(CheckType);
}
break; break;
} }
...@@ -547,10 +578,68 @@ CTable.prototype.Document_Is_SelectionLocked = function(CheckType, bCheckInner) ...@@ -547,10 +578,68 @@ CTable.prototype.Document_Is_SelectionLocked = function(CheckType, bCheckInner)
} }
} }
}; };
CTable.prototype.CheckContentControlDeletingLock = function()
{
for (var nCurRow = 0, nRowsCount = this.Content.length; nCurRow < nRowsCount; ++nCurRow)
{
var oRow = this.Content[nCurRow];
for (var nCurCell = 0, nCellsCount = oRow.Get_CellsCount(); nCurCell < nCellsCount; ++nCurCell)
{
oRow.Get_Cell(nCurCell).Content.CheckContentControlDeletingLock();
}
}
};
CBlockLevelSdt.prototype.Document_Is_SelectionLocked = function(CheckType, bCheckInner) CBlockLevelSdt.prototype.Document_Is_SelectionLocked = function(CheckType, bCheckInner)
{ {
return this.Content.Document_Is_SelectionLocked(CheckType, bCheckInner); var nContentControlLock = this.GetContentControlLock();
if ((AscCommon.changestype_Paragraph_Content === CheckType
|| AscCommon.changestype_Remove === CheckType
|| AscCommon.changestype_Delete === CheckType
|| AscCommon.changestype_Document_Content === CheckType
|| AscCommon.changestype_Document_Content_Add === CheckType)
&& this.IsSelectionUse()
&& this.IsSelectedAll())
{
if (AscCommonWord.sdtlock_SdtContentLocked === nContentControlLock || AscCommonWord.sdtlock_SdtLocked === nContentControlLock)
return AscCommon.CollaborativeEditing.Add_CheckLock(true);
else
return this.Content.Document_Is_SelectionLocked(CheckType, bCheckInner);
}
else if (AscCommonWord.sdtlock_SdtContentLocked === nContentControlLock || AscCommonWord.sdtlock_ContentLocked === nContentControlLock)
{
return AscCommon.CollaborativeEditing.Add_CheckLock(true);
}
else
{
return this.Content.Document_Is_SelectionLocked(CheckType, bCheckInner);
}
};
CBlockLevelSdt.prototype.CheckContentControlEditingLock = function()
{
var nContentControlLock = this.GetContentControlLock();
if (AscCommonWord.sdtlock_SdtContentLocked === nContentControlLock || AscCommonWord.sdtlock_ContentLocked === nContentControlLock)
return AscCommon.CollaborativeEditing.Add_CheckLock(true);
if (this.Parent && this.Parent.CheckContentControlEditingLock)
this.Parent.CheckContentControlEditingLock();
};
CBlockLevelSdt.prototype.CheckContentControlDeletingLock = function()
{
var nContentControlLock = this.GetContentControlLock();
if (AscCommonWord.sdtlock_SdtContentLocked === nContentControlLock || AscCommonWord.sdtlock_SdtLocked === nContentControlLock)
return AscCommon.CollaborativeEditing.Add_CheckLock(true);
this.Content.CheckContentControlEditingLock();
}; };
CTableCell.prototype.CheckContentControlEditingLock = function()
{
if (this.Row && this.Row.Table && this.Row.Table.Parent && this.Row.Table.Parent.CheckContentControlEditingLock)
this.Row.Table.Parent.CheckContentControlEditingLock();
};
if(typeof CComments !== "undefined") if(typeof CComments !== "undefined")
{ {
CComments.prototype.Document_Is_SelectionLocked = function(Id) CComments.prototype.Document_Is_SelectionLocked = function(Id)
...@@ -835,4 +924,4 @@ if(typeof CPresentation !== "undefined") ...@@ -835,4 +924,4 @@ if(typeof CPresentation !== "undefined")
return bResult; return bResult;
}; };
} }
\ No newline at end of file
...@@ -8454,7 +8454,7 @@ CDocumentContent.prototype.IsSelectedAll = function() ...@@ -8454,7 +8454,7 @@ CDocumentContent.prototype.IsSelectedAll = function()
{ {
if (true === this.Selection.Use if (true === this.Selection.Use
&& ((0 === this.Selection.StartPos && this.Content.length - 1 === this.Selection.EndPos) && ((0 === this.Selection.StartPos && this.Content.length - 1 === this.Selection.EndPos)
|| (0 === this.Selection.EndPos && this.Content.length - 1 === this.Selection.EndPos)) || (0 === this.Selection.EndPos && this.Content.length - 1 === this.Selection.StartPos))
&& true === this.Content[0].IsSelectedAll() && true === this.Content[0].IsSelectedAll()
&& true === this.Content[this.Content.length - 1].IsSelectedAll()) && true === this.Content[this.Content.length - 1].IsSelectedAll())
return true; return true;
......
...@@ -629,6 +629,13 @@ CDocumentContentElementBase.prototype.GetStyleFromFormatting = function() ...@@ -629,6 +629,13 @@ CDocumentContentElementBase.prototype.GetStyleFromFormatting = function()
CDocumentContentElementBase.prototype.GetAllContentControls = function(arrContentControls) CDocumentContentElementBase.prototype.GetAllContentControls = function(arrContentControls)
{ {
}; };
CDocumentContentElementBase.prototype.IsSelectedAll = function()
{
return false;
};
CDocumentContentElementBase.prototype.CheckContentControlDeletingLock = function()
{
};
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
// Функции для работы с номерами страниц // Функции для работы с номерами страниц
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
......
...@@ -663,6 +663,10 @@ CBlockLevelSdt.prototype.GetAllContentControls = function(arrContentControls) ...@@ -663,6 +663,10 @@ CBlockLevelSdt.prototype.GetAllContentControls = function(arrContentControls)
arrContentControls.push(this); arrContentControls.push(this);
this.Content.GetAllContentControls(arrContentControls); this.Content.GetAllContentControls(arrContentControls);
}; };
CBlockLevelSdt.prototype.IsSelectedAll = function()
{
return this.Content.IsSelectedAll();
};
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
CBlockLevelSdt.prototype.Is_HdrFtr = function(bReturnHdrFtr) CBlockLevelSdt.prototype.Is_HdrFtr = function(bReturnHdrFtr)
{ {
......
...@@ -89,7 +89,7 @@ CSdtPr.prototype.Write_ToBinary = function(Writer) ...@@ -89,7 +89,7 @@ CSdtPr.prototype.Write_ToBinary = function(Writer)
if (undefined !== this.Label) if (undefined !== this.Label)
{ {
Writer.WriteString2(this.Tag); Writer.WriteLong(this.Tag);
Flags |= 8; Flags |= 8;
} }
...@@ -118,7 +118,7 @@ CSdtPr.prototype.Read_FromBinary = function(Reader) ...@@ -118,7 +118,7 @@ CSdtPr.prototype.Read_FromBinary = function(Reader)
this.Tag = Reader.GetString2(); this.Tag = Reader.GetString2();
if (Flags & 8) if (Flags & 8)
this.Tag = Reader.GetString2(); this.Tag = Reader.GetLong();
if (Flags & 16) if (Flags & 16)
this.Lock = Reader.GetLong(); this.Lock = Reader.GetLong();
......
...@@ -110,13 +110,13 @@ CChangesSdtPrTag.prototype.private_SetValue = function(Value) ...@@ -110,13 +110,13 @@ CChangesSdtPrTag.prototype.private_SetValue = function(Value)
}; };
/** /**
* @constructor * @constructor
* @extends {AscDFH.CChangesBaseStringProperty} * @extends {AscDFH.CChangesBaseLongProperty}
*/ */
function CChangesSdtPrLabel(Class, Old, New) function CChangesSdtPrLabel(Class, Old, New)
{ {
AscDFH.CChangesBaseStringProperty.call(this, Class, Old, New); AscDFH.CChangesBaseLongProperty.call(this, Class, Old, New);
} }
CChangesSdtPrLabel.prototype = Object.create(AscDFH.CChangesBaseStringProperty.prototype); CChangesSdtPrLabel.prototype = Object.create(AscDFH.CChangesBaseLongProperty.prototype);
CChangesSdtPrLabel.prototype.constructor = CChangesSdtPrLabel; CChangesSdtPrLabel.prototype.constructor = CChangesSdtPrLabel;
CChangesSdtPrLabel.prototype.Type = AscDFH.historyitem_SdtPr_Label; CChangesSdtPrLabel.prototype.Type = AscDFH.historyitem_SdtPr_Label;
CChangesSdtPrLabel.prototype.private_SetValue = function(Value) CChangesSdtPrLabel.prototype.private_SetValue = function(Value)
......
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