Commit 266b5e42 authored by Ilya Kirillov's avatar Ilya Kirillov

Added class for working with ContentControl through a plugins api. Implemented...

Added class for working with ContentControl through a plugins api. Implemented function for removing ContentControl from the document.
parent dd4e9b07
......@@ -15168,9 +15168,16 @@ CDocument.prototype.GetAllContentControls = function()
}
return arrContentControls;
};
CDocument.prototype.SelectContentControl = function(oContentControl)
CDocument.prototype.RemoveContentControl = function(Id)
{
var oBlockLevelSdt = this.TableId.Get_ById(Id);
if (oBlockLevelSdt && oBlockLevelSdt.Parent)
{
var oDocContent = oBlockLevelSdt.Parent;
oDocContent.Update_ContentIndexing();
var nIndex = oBlockLevelSdt.GetIndex();
oDocContent.Remove_FromContent(nIndex, 1);
}
};
function CDocumentSelectionState()
......
......@@ -919,6 +919,31 @@ CBlockLevelSdt.prototype.GetContentControlLock = function()
{
return (undefined !== this.Pr.Lock ? this.Pr.Lock : sdtlock_Unlocked);
};
CBlockLevelSdt.prototype.SetContentControlPr = function(oPr)
{
if (oPr)
return;
if (undefined !== oPr.Tag)
this.SetTag(oPr.Tag);
if (undefined !== oPr.Id)
this.SetContentControlId(oPr.Id);
if (undefined !== oPr.Lock)
this.SetContentControlLock(oPr.Lock);
};
CBlockLevelSdt.prototype.GetContentControlPr = function()
{
var oPr = new CContentControlPr();
oPr.Tag = this.Pr.Tag;
oPr.Id = this.Pr.Id;
oPr.Lock = this.Pr.Lock;
oPr.InternalId = this.GetId();
return oPr;
};
//--------------------------------------------------------export--------------------------------------------------------
window['AscCommonWord'] = window['AscCommonWord'] || {};
window['AscCommonWord'].CBlockLevelSdt = CBlockLevelSdt;
......@@ -931,7 +956,7 @@ function TEST_ADD_SDT()
oLogicDocument.Create_NewHistoryPoint();
oLogicDocument.AddContentControl();
var oContentControl = oLogicDocument.AddContentControl();
oLogicDocument.AddToParagraph(new ParaText("S"));
oLogicDocument.AddToParagraph(new ParaText("d"));
oLogicDocument.AddToParagraph(new ParaText("t"));
......@@ -940,4 +965,20 @@ function TEST_ADD_SDT()
oLogicDocument.Document_UpdateSelectionState();
oLogicDocument.Document_UpdateInterfaceState();
oLogicDocument.Document_UpdateRulersState();
return oContentControl ? oContentControl.GetId() : null;
}
function TEST_REMOVE_SDT(Id)
{
var oLogicDocument = editor.WordControl.m_oLogicDocument;
oLogicDocument.Create_NewHistoryPoint();
oLogicDocument.RemoveContentControl(Id);
oLogicDocument.Recalculate();
oLogicDocument.Document_UpdateSelectionState();
oLogicDocument.Document_UpdateInterfaceState();
oLogicDocument.Document_UpdateRulersState();
}
\ No newline at end of file
......@@ -124,6 +124,42 @@ CSdtPr.prototype.Read_FromBinary = function(Reader)
this.Lock = Reader.GetLong();
};
function CContentControlPr()
{
this.Id = undefined;
this.Tag = undefined;
this.Lock = undefined;
this.InternalId = undefined;
}
CContentControlPr.prototype.get_Id = function()
{
return this.Id;
};
CContentControlPr.prototype.put_Id = function(Id)
{
this.Id = Id;
};
CContentControlPr.prototype.get_Tag = function()
{
return this.Tag;
};
CContentControlPr.prototype.put_Tag = function(sTag)
{
this.Tag = sTag;
};
CContentControlPr.prototype.get_Lock = function()
{
return this.Lock;
};
CContentControlPr.prototype.put_Lock = function(nLock)
{
this.Lock = nLock;
};
CContentControlPr.prototype.get_InternalId = function()
{
return this.InternalId;
};
//--------------------------------------------------------export--------------------------------------------------------
window['AscCommonWord'] = window['AscCommonWord'] || {};
window['AscCommonWord'].CSdtPr = CSdtPr;
......@@ -131,3 +167,13 @@ window['AscCommonWord'].sdtlock_Unlocked = sdtlock_Unlocked;
window['AscCommonWord'].sdtlock_ContentLocked = sdtlock_ContentLocked;
window['AscCommonWord'].sdtlock_SdtContentLocked = sdtlock_SdtContentLocked;
window['AscCommonWord'].sdtlock_SdtLocked = sdtlock_SdtLocked;
window['AscCommonWord'].CContentControlPr = CContentControlPr;
CContentControlPr.prototype['get_Id'] = CContentControlPr.prototype.get_Id;
CContentControlPr.prototype['put_Id'] = CContentControlPr.prototype.put_Id;
CContentControlPr.prototype['get_Tag'] = CContentControlPr.prototype.get_Tag;
CContentControlPr.prototype['put_Tag'] = CContentControlPr.prototype.put_Tag;
CContentControlPr.prototype['get_Lock'] = CContentControlPr.prototype.get_Lock;
CContentControlPr.prototype['put_Lock'] = CContentControlPr.prototype.put_Lock;
CContentControlPr.prototype['get_InternalId'] = CContentControlPr.prototype.get_InternalId;
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