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 @@ ...@@ -1019,6 +1019,9 @@
case AscDFH.historydescription_Document_AddInlineLevelContentControl: case AscDFH.historydescription_Document_AddInlineLevelContentControl:
sString = "Document_AddInlineLevelContentControl"; sString = "Document_AddInlineLevelContentControl";
break; break;
case AscDFH.historydescription_Document_RemoveContentControl:
sString = "Document_RemoveContentControl";
break;
} }
return sString; return sString;
} }
...@@ -2907,6 +2910,7 @@ ...@@ -2907,6 +2910,7 @@
window['AscDFH'].historydescription_Document_InsertSignatureLine = 0x0140; window['AscDFH'].historydescription_Document_InsertSignatureLine = 0x0140;
window['AscDFH'].historydescription_Document_AddBlockLevelContentControl = 0x0141; window['AscDFH'].historydescription_Document_AddBlockLevelContentControl = 0x0141;
window['AscDFH'].historydescription_Document_AddInlineLevelContentControl = 0x0142; window['AscDFH'].historydescription_Document_AddInlineLevelContentControl = 0x0142;
window['AscDFH'].historydescription_Document_RemoveContentControl = 0x0143;
......
...@@ -629,12 +629,17 @@ CBlockLevelSdt.prototype.Document_Is_SelectionLocked = function(CheckType, bChec ...@@ -629,12 +629,17 @@ CBlockLevelSdt.prototype.Document_Is_SelectionLocked = function(CheckType, bChec
var nContentControlLock = this.GetContentControlLock(); var nContentControlLock = this.GetContentControlLock();
if (AscCommon.changestype_ContentControl_Remove === CheckType
|| AscCommon.changestype_ContentControl_Properties === CheckType)
this.Lock.Check(this.GetId());
if (isCheckContentControlLock if (isCheckContentControlLock
&& (AscCommon.changestype_Paragraph_Content === CheckType && (AscCommon.changestype_Paragraph_Content === CheckType
|| AscCommon.changestype_Remove === CheckType || AscCommon.changestype_Remove === CheckType
|| AscCommon.changestype_Delete === CheckType || AscCommon.changestype_Delete === CheckType
|| AscCommon.changestype_Document_Content === 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.IsSelectionUse()
&& this.IsSelectedAll()) && this.IsSelectedAll())
{ {
......
...@@ -1050,6 +1050,8 @@ ...@@ -1050,6 +1050,8 @@
var changestype_Table_Properties = 20; // Любые изменения в таблице var changestype_Table_Properties = 20; // Любые изменения в таблице
var changestype_Table_RemoveCells = 21; // Удаление ячеек (строк или столбцов) var changestype_Table_RemoveCells = 21; // Удаление ячеек (строк или столбцов)
var changestype_Image_Properties = 23; // Изменения настроек картинки var changestype_Image_Properties = 23; // Изменения настроек картинки
var changestype_ContentControl_Remove = 24; // Удаление контейнера целиком
var changestype_ContentControl_Properties = 25; // Изменение свойств контейнера
var changestype_HdrFtr = 30; // Изменения в колонтитуле (любые изменения) var changestype_HdrFtr = 30; // Изменения в колонтитуле (любые изменения)
var changestype_Remove = 40; // Удаление, через кнопку backspace (Удаление назад) var changestype_Remove = 40; // Удаление, через кнопку backspace (Удаление назад)
var changestype_Delete = 41; // Удаление, через кнопку delete (Удаление вперед) var changestype_Delete = 41; // Удаление, через кнопку delete (Удаление вперед)
...@@ -1747,6 +1749,8 @@ ...@@ -1747,6 +1749,8 @@
window["AscCommon"].changestype_Table_Properties = changestype_Table_Properties; window["AscCommon"].changestype_Table_Properties = changestype_Table_Properties;
window["AscCommon"].changestype_Table_RemoveCells = changestype_Table_RemoveCells; window["AscCommon"].changestype_Table_RemoveCells = changestype_Table_RemoveCells;
window["AscCommon"].changestype_Image_Properties = changestype_Image_Properties; window["AscCommon"].changestype_Image_Properties = changestype_Image_Properties;
window["AscCommon"].changestype_ContentControl_Remove = changestype_ContentControl_Remove;
window["AscCommon"].changestype_ContentControl_Properties = changestype_ContentControl_Properties;
window["AscCommon"].changestype_HdrFtr = changestype_HdrFtr; window["AscCommon"].changestype_HdrFtr = changestype_HdrFtr;
window["AscCommon"].changestype_Remove = changestype_Remove; window["AscCommon"].changestype_Remove = changestype_Remove;
window["AscCommon"].changestype_Delete = changestype_Delete; window["AscCommon"].changestype_Delete = changestype_Delete;
......
...@@ -52,6 +52,7 @@ function CBlockLevelSdt(oLogicDocument, oParent) ...@@ -52,6 +52,7 @@ function CBlockLevelSdt(oLogicDocument, oParent)
this.LogicDocument = oLogicDocument; this.LogicDocument = oLogicDocument;
this.Content = new CDocumentContent(this, oLogicDocument ? oLogicDocument.Get_DrawingDocument() : null, 0, 0, 0, 0, true, false, false); this.Content = new CDocumentContent(this, oLogicDocument ? oLogicDocument.Get_DrawingDocument() : null, 0, 0, 0, 0, true, false, false);
this.Pr = new CSdtPr(); this.Pr = new CSdtPr();
this.Lock = new AscCommon.CLock();
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора) // Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add(this, this.Id); g_oTableId.Add(this, this.Id);
...@@ -142,6 +143,12 @@ CBlockLevelSdt.prototype.Read_FromBinary2 = function(Reader) ...@@ -142,6 +143,12 @@ CBlockLevelSdt.prototype.Read_FromBinary2 = function(Reader)
CBlockLevelSdt.prototype.Draw = function(CurPage, oGraphics) CBlockLevelSdt.prototype.Draw = function(CurPage, oGraphics)
{ {
this.Content.Draw(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() CBlockLevelSdt.prototype.Get_CurrentPage_Absolute = function()
{ {
...@@ -165,6 +172,20 @@ CBlockLevelSdt.prototype.IsTableBorder = function(X, Y, CurPage) ...@@ -165,6 +172,20 @@ CBlockLevelSdt.prototype.IsTableBorder = function(X, Y, CurPage)
}; };
CBlockLevelSdt.prototype.UpdateCursorType = 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); this.DrawContentControlsTrack(true);
return this.Content.UpdateCursorType(X, Y, CurPage); return this.Content.UpdateCursorType(X, Y, CurPage);
}; };
......
...@@ -7202,9 +7202,9 @@ background-repeat: no-repeat;\ ...@@ -7202,9 +7202,9 @@ background-repeat: no-repeat;\
var sDefaultText = this.textArtTranslate ? this.textArtTranslate.DefaultText : "Your text here"; var sDefaultText = this.textArtTranslate ? this.textArtTranslate.DefaultText : "Your text here";
if (AscCommonWord.sdttype_BlockLevel === nType) 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); var oContentControl = oLogicDocument.AddContentControl(AscCommonWord.sdttype_BlockLevel);
if (oContentControlPr) if (oContentControlPr)
...@@ -7223,9 +7223,9 @@ background-repeat: no-repeat;\ ...@@ -7223,9 +7223,9 @@ background-repeat: no-repeat;\
} }
else if (AscCommonWord.sdttype_InlineLevel === nType) 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); var oContentControl = oLogicDocument.AddContentControl(AscCommonWord.sdttype_InlineLevel);
...@@ -7244,7 +7244,65 @@ background-repeat: no-repeat;\ ...@@ -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 // input
asc_docs_api.prototype.Begin_CompositeInput = function() 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