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())
{
......
......@@ -1040,35 +1040,37 @@
var locktype_Other2 = 4; // данный объект залочен другим(не текущим) пользователем (обновления уже пришли)
var locktype_Other3 = 5; // данный объект был залочен (обновления пришли) и снова стал залочен
var changestype_None = 0; // Ничего не происходит с выделенным элементом (проверка идет через дополнительный параметр)
var changestype_Paragraph_Content = 1; // Добавление/удаление элементов в параграф
var changestype_Paragraph_Properties = 2; // Изменение свойств параграфа
var changestype_Document_Content = 10; // Добавление/удаление элементов в Document или в DocumentContent
var changestype_Document_Content_Add = 11; // Добавление элемента в класс Document или в класс DocumentContent
var changestype_Document_SectPr = 12; // Изменения свойств данной секции (размер страницы, поля и ориентация)
var changestype_Document_Styles = 13; // Изменяем стили документа (добавление/удаление/модифицирование)
var changestype_Table_Properties = 20; // Любые изменения в таблице
var changestype_Table_RemoveCells = 21; // Удаление ячеек (строк или столбцов)
var changestype_Image_Properties = 23; // Изменения настроек картинки
var changestype_HdrFtr = 30; // Изменения в колонтитуле (любые изменения)
var changestype_Remove = 40; // Удаление, через кнопку backspace (Удаление назад)
var changestype_Delete = 41; // Удаление, через кнопку delete (Удаление вперед)
var changestype_Drawing_Props = 51; // Изменение свойств фигуры
var changestype_ColorScheme = 60; // Изменение свойств фигуры
var changestype_Text_Props = 61; // Изменение свойств фигуры
var changestype_RemoveSlide = 62; // Изменение свойств фигуры
var changestype_PresentationProps = 63; // Изменение темы, цветовой схемы, размера слайда;
var changestype_Theme = 64; // Изменение темы;
var changestype_SlideSize = 65; // Изменение цветовой схемы;
var changestype_SlideBg = 66; // Изменение цветовой схемы;
var changestype_SlideTiming = 67; // Изменение цветовой схемы;
var changestype_MoveComment = 68;
var changestype_AddSp = 69;
var changestype_AddComment = 70;
var changestype_Layout = 71;
var changestype_AddShape = 72;
var changestype_AddShapes = 73;
var changestype_PresDefaultLang = 74;
var changestype_None = 0; // Ничего не происходит с выделенным элементом (проверка идет через дополнительный параметр)
var changestype_Paragraph_Content = 1; // Добавление/удаление элементов в параграф
var changestype_Paragraph_Properties = 2; // Изменение свойств параграфа
var changestype_Document_Content = 10; // Добавление/удаление элементов в Document или в DocumentContent
var changestype_Document_Content_Add = 11; // Добавление элемента в класс Document или в класс DocumentContent
var changestype_Document_SectPr = 12; // Изменения свойств данной секции (размер страницы, поля и ориентация)
var changestype_Document_Styles = 13; // Изменяем стили документа (добавление/удаление/модифицирование)
var changestype_Table_Properties = 20; // Любые изменения в таблице
var changestype_Table_RemoveCells = 21; // Удаление ячеек (строк или столбцов)
var changestype_Image_Properties = 23; // Изменения настроек картинки
var changestype_ContentControl_Remove = 24; // Удаление контейнера целиком
var changestype_ContentControl_Properties = 25; // Изменение свойств контейнера
var changestype_HdrFtr = 30; // Изменения в колонтитуле (любые изменения)
var changestype_Remove = 40; // Удаление, через кнопку backspace (Удаление назад)
var changestype_Delete = 41; // Удаление, через кнопку delete (Удаление вперед)
var changestype_Drawing_Props = 51; // Изменение свойств фигуры
var changestype_ColorScheme = 60; // Изменение свойств фигуры
var changestype_Text_Props = 61; // Изменение свойств фигуры
var changestype_RemoveSlide = 62; // Изменение свойств фигуры
var changestype_PresentationProps = 63; // Изменение темы, цветовой схемы, размера слайда;
var changestype_Theme = 64; // Изменение темы;
var changestype_SlideSize = 65; // Изменение цветовой схемы;
var changestype_SlideBg = 66; // Изменение цветовой схемы;
var changestype_SlideTiming = 67; // Изменение цветовой схемы;
var changestype_MoveComment = 68;
var changestype_AddSp = 69;
var changestype_AddComment = 70;
var changestype_Layout = 71;
var changestype_AddShape = 72;
var changestype_AddShapes = 73;
var changestype_PresDefaultLang = 74;
var changestype_2_InlineObjectMove = 1; // Передвигаем объект в заданную позцию (проверяем место, в которое пытаемся передвинуть)
var changestype_2_HdrFtr = 2; // Изменения с колонтитулом
......@@ -1737,41 +1739,43 @@
window["AscCommon"].locktype_Other2 = locktype_Other2;
window["AscCommon"].locktype_Other3 = locktype_Other3;
window["AscCommon"].changestype_None = changestype_None;
window["AscCommon"].changestype_Paragraph_Content = changestype_Paragraph_Content;
window["AscCommon"].changestype_Paragraph_Properties = changestype_Paragraph_Properties;
window["AscCommon"].changestype_Document_Content = changestype_Document_Content;
window["AscCommon"].changestype_Document_Content_Add = changestype_Document_Content_Add;
window["AscCommon"].changestype_Document_SectPr = changestype_Document_SectPr;
window["AscCommon"].changestype_Document_Styles = changestype_Document_Styles;
window["AscCommon"].changestype_Table_Properties = changestype_Table_Properties;
window["AscCommon"].changestype_Table_RemoveCells = changestype_Table_RemoveCells;
window["AscCommon"].changestype_Image_Properties = changestype_Image_Properties;
window["AscCommon"].changestype_HdrFtr = changestype_HdrFtr;
window["AscCommon"].changestype_Remove = changestype_Remove;
window["AscCommon"].changestype_Delete = changestype_Delete;
window["AscCommon"].changestype_Drawing_Props = changestype_Drawing_Props;
window["AscCommon"].changestype_ColorScheme = changestype_ColorScheme;
window["AscCommon"].changestype_Text_Props = changestype_Text_Props;
window["AscCommon"].changestype_RemoveSlide = changestype_RemoveSlide;
window["AscCommon"].changestype_Theme = changestype_Theme;
window["AscCommon"].changestype_SlideSize = changestype_SlideSize;
window["AscCommon"].changestype_SlideBg = changestype_SlideBg;
window["AscCommon"].changestype_SlideTiming = changestype_SlideTiming;
window["AscCommon"].changestype_MoveComment = changestype_MoveComment;
window["AscCommon"].changestype_AddComment = changestype_AddComment;
window["AscCommon"].changestype_Layout = changestype_Layout;
window["AscCommon"].changestype_AddShape = changestype_AddShape;
window["AscCommon"].changestype_AddShapes = changestype_AddShapes;
window["AscCommon"].changestype_PresDefaultLang = changestype_PresDefaultLang;
window["AscCommon"].changestype_2_InlineObjectMove = changestype_2_InlineObjectMove;
window["AscCommon"].changestype_2_HdrFtr = changestype_2_HdrFtr;
window["AscCommon"].changestype_2_Comment = changestype_2_Comment;
window["AscCommon"].changestype_2_Element_and_Type = changestype_2_Element_and_Type;
window["AscCommon"].changestype_2_ElementsArray_and_Type = changestype_2_ElementsArray_and_Type;
window["AscCommon"].changestype_2_AdditionalTypes = changestype_2_AdditionalTypes;
window["AscCommon"].contentchanges_Add = contentchanges_Add;
window["AscCommon"].contentchanges_Remove = contentchanges_Remove;
window["AscCommon"].changestype_None = changestype_None;
window["AscCommon"].changestype_Paragraph_Content = changestype_Paragraph_Content;
window["AscCommon"].changestype_Paragraph_Properties = changestype_Paragraph_Properties;
window["AscCommon"].changestype_Document_Content = changestype_Document_Content;
window["AscCommon"].changestype_Document_Content_Add = changestype_Document_Content_Add;
window["AscCommon"].changestype_Document_SectPr = changestype_Document_SectPr;
window["AscCommon"].changestype_Document_Styles = changestype_Document_Styles;
window["AscCommon"].changestype_Table_Properties = changestype_Table_Properties;
window["AscCommon"].changestype_Table_RemoveCells = changestype_Table_RemoveCells;
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_Remove = changestype_Remove;
window["AscCommon"].changestype_Delete = changestype_Delete;
window["AscCommon"].changestype_Drawing_Props = changestype_Drawing_Props;
window["AscCommon"].changestype_ColorScheme = changestype_ColorScheme;
window["AscCommon"].changestype_Text_Props = changestype_Text_Props;
window["AscCommon"].changestype_RemoveSlide = changestype_RemoveSlide;
window["AscCommon"].changestype_Theme = changestype_Theme;
window["AscCommon"].changestype_SlideSize = changestype_SlideSize;
window["AscCommon"].changestype_SlideBg = changestype_SlideBg;
window["AscCommon"].changestype_SlideTiming = changestype_SlideTiming;
window["AscCommon"].changestype_MoveComment = changestype_MoveComment;
window["AscCommon"].changestype_AddComment = changestype_AddComment;
window["AscCommon"].changestype_Layout = changestype_Layout;
window["AscCommon"].changestype_AddShape = changestype_AddShape;
window["AscCommon"].changestype_AddShapes = changestype_AddShapes;
window["AscCommon"].changestype_PresDefaultLang = changestype_PresDefaultLang;
window["AscCommon"].changestype_2_InlineObjectMove = changestype_2_InlineObjectMove;
window["AscCommon"].changestype_2_HdrFtr = changestype_2_HdrFtr;
window["AscCommon"].changestype_2_Comment = changestype_2_Comment;
window["AscCommon"].changestype_2_Element_and_Type = changestype_2_Element_and_Type;
window["AscCommon"].changestype_2_ElementsArray_and_Type = changestype_2_ElementsArray_and_Type;
window["AscCommon"].changestype_2_AdditionalTypes = changestype_2_AdditionalTypes;
window["AscCommon"].contentchanges_Add = contentchanges_Add;
window["AscCommon"].contentchanges_Remove = contentchanges_Remove;
window["AscCommon"].offlineMode = offlineMode;
......
......@@ -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