Commit a74c3acd authored by Ilya Kirillov's avatar Ilya Kirillov

Implemented removing an content control function in Api. Implemented a lock of...

Implemented removing an content control function in Api. Implemented a lock of block level content control class for collaborative editing.
parent 8d51aafb
......@@ -1019,6 +1019,9 @@
case AscDFH.historydescription_Document_AddInlineLevelContentControl:
sString = "Document_AddInlineLevelContentControl";
break;
case AscDFH.historydescription_Document_RemoveContentControl:
sString = "Document_RemoveContentControl";
break;
}
return sString;
}
......@@ -2907,6 +2910,7 @@
window['AscDFH'].historydescription_Document_InsertSignatureLine = 0x0140;
window['AscDFH'].historydescription_Document_AddBlockLevelContentControl = 0x0141;
window['AscDFH'].historydescription_Document_AddInlineLevelContentControl = 0x0142;
window['AscDFH'].historydescription_Document_RemoveContentControl = 0x0143;
......
......@@ -629,12 +629,17 @@ CBlockLevelSdt.prototype.Document_Is_SelectionLocked = function(CheckType, bChec
var nContentControlLock = this.GetContentControlLock();
if (AscCommon.changestype_ContentControl_Remove === CheckType
|| AscCommon.changestype_ContentControl_Properties === CheckType)
this.Lock.Check(this.GetId());
if (isCheckContentControlLock
&& (AscCommon.changestype_Paragraph_Content === CheckType
|| AscCommon.changestype_Remove === CheckType
|| AscCommon.changestype_Delete === CheckType
|| AscCommon.changestype_Document_Content === CheckType
|| AscCommon.changestype_Document_Content_Add === CheckType)
|| AscCommon.changestype_Document_Content_Add === CheckType
|| AscCommon.changestype_ContentControl_Remove === CheckType)
&& this.IsSelectionUse()
&& this.IsSelectedAll())
{
......
This diff is collapsed.
......@@ -52,6 +52,7 @@ function CBlockLevelSdt(oLogicDocument, oParent)
this.LogicDocument = oLogicDocument;
this.Content = new CDocumentContent(this, oLogicDocument ? oLogicDocument.Get_DrawingDocument() : null, 0, 0, 0, 0, true, false, false);
this.Pr = new CSdtPr();
this.Lock = new AscCommon.CLock();
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add(this, this.Id);
......@@ -142,6 +143,12 @@ CBlockLevelSdt.prototype.Read_FromBinary2 = function(Reader)
CBlockLevelSdt.prototype.Draw = function(CurPage, oGraphics)
{
this.Content.Draw(CurPage, oGraphics);
if (AscCommon.locktype_None !== this.Lock.Get_Type())
{
var oBounds = this.GetContentBounds(CurPage);
oGraphics.DrawLockObjectRect(this.Lock.Get_Type(), oBounds.Left, oBounds.Top, oBounds.Right - oBounds.Left, oBounds.Bottom - oBounds.Top);
}
};
CBlockLevelSdt.prototype.Get_CurrentPage_Absolute = function()
{
......@@ -165,6 +172,20 @@ CBlockLevelSdt.prototype.IsTableBorder = function(X, Y, CurPage)
};
CBlockLevelSdt.prototype.UpdateCursorType = function(X, Y, CurPage)
{
var oBounds = this.GetContentBounds(CurPage);
if (true === this.Lock.Is_Locked() && X < oBounds.Right && X > oBounds.Left && Y > oBounds.Top && Y < oBounds.Bottom)
{
var MMData = new AscCommon.CMouseMoveData();
var Coords = this.LogicDocument.DrawingDocument.ConvertCoordsToCursorWR(oBounds.Left, oBounds.Top, this.Get_AbsolutePage(CurPage), this.Get_ParentTextTransform());
MMData.X_abs = Coords.X - 5;
MMData.Y_abs = Coords.Y;
MMData.Type = AscCommon.c_oAscMouseMoveDataTypes.LockedObject;
MMData.UserId = this.Lock.Get_UserId();
MMData.HaveChanges = this.Lock.Have_Changes();
MMData.LockedObjectType = c_oAscMouseMoveLockedObjectType.Common;
this.LogicDocument.Api.sync_MouseMoveCallback(MMData);
}
this.DrawContentControlsTrack(true);
return this.Content.UpdateCursorType(X, Y, CurPage);
};
......
......@@ -7202,9 +7202,9 @@ background-repeat: no-repeat;\
var sDefaultText = this.textArtTranslate ? this.textArtTranslate.DefaultText : "Your text here";
if (AscCommonWord.sdttype_BlockLevel === nType)
{
if (false === oLogicDocument.Document_Is_SelectionLocked())
if (false === oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Document_Content))
{
History.Create_NewPoint(AscDFH.historydescription_Document_AddBlockLevelContentControl);
oLogicDocument.Create_NewHistoryPoint(AscDFH.historydescription_Document_AddBlockLevelContentControl);
var oContentControl = oLogicDocument.AddContentControl(AscCommonWord.sdttype_BlockLevel);
if (oContentControlPr)
......@@ -7223,9 +7223,9 @@ background-repeat: no-repeat;\
}
else if (AscCommonWord.sdttype_InlineLevel === nType)
{
if (false === oLogicDocument.Document_Is_SelectionLocked())
if (false === oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Paragraph_Content))
{
History.Create_NewPoint(AscDFH.historydescription_Document_AddInlineLevelContentControl);
oLogicDocument.Create_NewHistoryPoint(AscDFH.historydescription_Document_AddInlineLevelContentControl);
var oContentControl = oLogicDocument.AddContentControl(AscCommonWord.sdttype_InlineLevel);
......@@ -7244,7 +7244,65 @@ background-repeat: no-repeat;\
}
}
};
asc_docs_api.prototype.asc_RemoveContentControl = function(Id)
{
var oLogicDocument = this.WordControl.m_oLogicDocument;
if (!oLogicDocument)
return;
var isLocked = true;
var oContentControl = null;
if (undefined === Id)
{
var oInfo = oLogicDocument.GetSelectedElementsInfo();
var oInlineControl = oInfo.GetInlineLevelSdt();
var oBlockControl = oInfo.GetBlockLevelSdt();
if (oInlineControl)
oContentControl = oInlineControl;
else if (oBlockControl)
oContentControl = oBlockControl;
}
else
{
oContentControl = AscCommon.g_oTableId.Get_ById(Id);
}
if (oContentControl && oContentControl.GetContentControlType)
{
if (AscCommonWord.sdttype_BlockLevel === oContentControl.GetContentControlType())
{
isLocked = oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_None, {
Type : AscCommon.changestype_2_ElementsArray_and_Type,
Elements : [oContentControl],
CheckType : AscCommon.changestype_ContentControl_Remove
});
}
else if (AscCommonWord.sdttype_InlineLevel === oContentControl.GetContentControlType())
{
var oParagraph = oContentControl.GetParagraph();
if (oParagraph)
{
isLocked = oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_None, {
Type : AscCommon.changestype_2_ElementsArray_and_Type,
Elements : [oParagraph],
CheckType : AscCommon.changestype_Paragraph_Content
});
}
}
Id = oContentControl.GetId();
}
if (false === isLocked)
{
oLogicDocument.Create_NewHistoryPoint(AscDFH.historydescription_Document_RemoveContentControl);
oLogicDocument.RemoveContentControl(Id);
oLogicDocument.Recalculate();
oLogicDocument.Document_UpdateInterfaceState();
oLogicDocument.Document_UpdateSelectionState();
}
};
// input
asc_docs_api.prototype.Begin_CompositeInput = function()
......
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