Commit 1a05afb5 authored by Ilya Kirillov's avatar Ilya Kirillov

Fixed bug with locking an content control and deleting it trough a plugin api.

parent 9248d711
......@@ -622,9 +622,12 @@ CTable.prototype.CheckContentControlDeletingLock = function()
};
CBlockLevelSdt.prototype.Document_Is_SelectionLocked = function(CheckType, bCheckInner)
{
var isCheckContentControlLock = this.LogicDocument ? this.LogicDocument.IsCheckContentControlsLock() : true;
var nContentControlLock = this.GetContentControlLock();
if ((AscCommon.changestype_Paragraph_Content === CheckType
if (isCheckContentControlLock
&& (AscCommon.changestype_Paragraph_Content === CheckType
|| AscCommon.changestype_Remove === CheckType
|| AscCommon.changestype_Delete === CheckType
|| AscCommon.changestype_Document_Content === CheckType
......@@ -644,7 +647,9 @@ CBlockLevelSdt.prototype.Document_Is_SelectionLocked = function(CheckType, bChec
return;
}
}
else if (AscCommonWord.sdtlock_SdtContentLocked === nContentControlLock || AscCommonWord.sdtlock_ContentLocked === nContentControlLock)
else if (isCheckContentControlLock
&& (AscCommonWord.sdtlock_SdtContentLocked === nContentControlLock
|| AscCommonWord.sdtlock_ContentLocked === nContentControlLock))
{
return AscCommon.CollaborativeEditing.Add_CheckLock(true);
}
......@@ -655,6 +660,10 @@ CBlockLevelSdt.prototype.Document_Is_SelectionLocked = function(CheckType, bChec
};
CBlockLevelSdt.prototype.CheckContentControlEditingLock = function()
{
var isCheckContentControlLock = this.LogicDocument ? this.LogicDocument.IsCheckContentControlsLock() : true;
if (!isCheckContentControlLock)
return;
var nContentControlLock = this.GetContentControlLock();
if (false === AscCommon.CollaborativeEditing.IsNeedToSkipContentControlOnCheckEditingLock(this)
......@@ -666,6 +675,10 @@ CBlockLevelSdt.prototype.CheckContentControlEditingLock = function()
};
CBlockLevelSdt.prototype.CheckContentControlDeletingLock = function()
{
var isCheckContentControlLock = this.LogicDocument ? this.LogicDocument.IsCheckContentControlsLock() : true;
if (!isCheckContentControlLock)
return;
var nContentControlLock = this.GetContentControlLock();
if (AscCommonWord.sdtlock_SdtContentLocked === nContentControlLock || AscCommonWord.sdtlock_SdtLocked === nContentControlLock)
......@@ -675,9 +688,14 @@ CBlockLevelSdt.prototype.CheckContentControlDeletingLock = function()
};
CInlineLevelSdt.prototype.Document_Is_SelectionLocked = function(CheckType)
{
var isCheckContentControlLock = this.Paragraph && this.Paragraph.LogicDocument ? this.Paragraph.LogicDocument.IsCheckContentControlsLock() : true;
if (!isCheckContentControlLock)
return;
var nContentControlLock = this.GetContentControlLock();
if ((AscCommon.changestype_Paragraph_Content === CheckType
if (CheckContentControlLock
&& (AscCommon.changestype_Paragraph_Content === CheckType
|| AscCommon.changestype_Remove === CheckType
|| AscCommon.changestype_Delete === CheckType
|| AscCommon.changestype_Document_Content === CheckType
......
......@@ -1546,6 +1546,9 @@ function CDocument(DrawingDocument, isMainLogicDocument)
// Объект для составного ввода текста
this.CompositeInput = null;
// Нужно ли проверять тип лока у ContentControl при проверке залоченности выделенных объектов
this.CheckContentControlsLock = true;
// Класс для работы со сносками
this.Footnotes = new CFootnotesController(this);
this.LogicDocumentController = new CLogicDocumentController(this);
......@@ -15253,6 +15256,14 @@ CDocument.prototype.GetAllSignatures = function()
{
return this.DrawingObjects.getAllSignatures();
};
CDocument.prototype.SetCheckContentControlsLock = function(isLocked)
{
this.CheckContentControlsLock = isLocked;
};
CDocument.prototype.IsCheckContentControlsLock = function()
{
return this.CheckContentControlsLock;
};
function CDocumentSelectionState()
{
......
......@@ -547,14 +547,31 @@
this.delete = function()
{
var LogicDocument = this.api.WordControl.m_oLogicDocument;
LogicDocument.Create_NewHistoryPoint(AscDFH.historydescription_Document_InsertDocumentsByUrls);
if (false === LogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Document_Content_Add))
var arrContentControl = [];
for (var i = 0; i < this.documents.length; i++)
{
var oContentControl = g_oTableId.Get_ById(this.documents[i].InternalId);
if (oContentControl
&& (oContentControl instanceof AscCommonWord.CBlockLevelSdt
|| oContentControl instanceof AscCommonWord.CInlineLevelSdt))
arrContentControl.push(g_oTableId.Get_ById(this.documents[i].InternalId));
}
LogicDocument.SetCheckContentControlsLock(false);
if (false === LogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_None, {
Type : AscCommon.changestype_2_ElementsArray_and_Type,
Elements : arrContentControl,
CheckType : AscCommon.changestype_Remove
}))
{
LogicDocument.Create_NewHistoryPoint(AscDFH.historydescription_Document_InsertDocumentsByUrls);
for (var i = 0; i < this.documents.length; i++)
{
LogicDocument.RemoveContentControl(this.documents[i].InternalId);
}
}
LogicDocument.SetCheckContentControlsLock(true);
this.api.asc_Recalculate();
delete this.api.__content_control_worker;
};
......
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