Commit a10f0edb authored by Alexey.Musinov's avatar Alexey.Musinov

Merge branch 'develop' of https://github.com/ONLYOFFICE/sdkjs into develop

* 'develop' of https://github.com/ONLYOFFICE/sdkjs:
  Implemented removing an content control function in Api. Implemented a lock of block level content control class for collaborative editing.
  delete functions from _xlfn
  extend clone functions
  add tests for EXPON.DIST
  add EXPON.DIST function
  add GAUSS function
parents fd3eb2a9 a74c3acd
...@@ -1106,6 +1106,19 @@ $( function () { ...@@ -1106,6 +1106,19 @@ $( function () {
strictEqual( oParser.calculate().getValue().toFixed(6) - 0, 0.068094, "GAMMADIST(A2,A3,A4,TRUE)" ); strictEqual( oParser.calculate().getValue().toFixed(6) - 0, 0.068094, "GAMMADIST(A2,A3,A4,TRUE)" );
} ); } );
test( "Test: \"EXPON.DIST\"", function () {
ws.getRange2( "A2" ).setValue( "0.2" );
ws.getRange2( "A3" ).setValue( "10" );
oParser = new parserFormula( "EXPON.DIST(A2,A3,TRUE)", "A1", ws );
ok( oParser.parse(), "EXPON.DIST(A2,A3,TRUE)" );
strictEqual( oParser.calculate().getValue().toFixed(8) - 0, 0.86466472, "EXPON.DIST(A2,A3,TRUE)" );
oParser = new parserFormula( "EXPON.DIST(0.2,10,FALSE)", "A1", ws );
ok( oParser.parse(), "EXPON.DIST(0.2,10,FALSE)" );
strictEqual( oParser.calculate().getValue().toFixed(8) - 0, 1.35335283, "EXPON.DIST(0.2,10,FALSE)" );
} );
test( "Test: \"CHIDIST\"", function () { test( "Test: \"CHIDIST\"", function () {
ws.getRange2( "A2" ).setValue( "18.307" ); ws.getRange2( "A2" ).setValue( "18.307" );
ws.getRange2( "A3" ).setValue( "10" ); ws.getRange2( "A3" ).setValue( "10" );
...@@ -1115,6 +1128,12 @@ $( function () { ...@@ -1115,6 +1128,12 @@ $( function () {
strictEqual( oParser.calculate().getValue().toFixed(7) - 0, 0.0500006, "CHIDIST(A2,A3)" ); strictEqual( oParser.calculate().getValue().toFixed(7) - 0, 0.0500006, "CHIDIST(A2,A3)" );
} ); } );
test( "Test: \"GAUSS\"", function () {
oParser = new parserFormula( "GAUSS(2)", "A1", ws );
ok( oParser.parse(), "GAUSS(2)" );
strictEqual( oParser.calculate().getValue().toFixed(5) - 0, 0.47725, "GAUSS(2)" );
} );
test( "Test: \"CHISQ.DIST.RT\"", function () { test( "Test: \"CHISQ.DIST.RT\"", function () {
ws.getRange2( "A2" ).setValue( "18.307" ); ws.getRange2( "A2" ).setValue( "18.307" );
ws.getRange2( "A3" ).setValue( "10" ); ws.getRange2( "A3" ).setValue( "10" );
......
This diff is collapsed.
...@@ -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())
{ {
......
This diff is collapsed.
...@@ -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