Compare commits

...

11 Commits

Author SHA1 Message Date
b4073edd9a [oform] Fix problem with lock check when setting form value 2023-02-08 23:52:26 +05:00
1c7cd19c47 For bug #60921
Update roles after applying collaboration changes
2023-02-01 00:34:30 +03:00
da20bb573a Fix bug #60922
Fix setting of settings for multiple fields at the same time
2023-02-01 00:34:30 +03:00
d8628c74c6 [oform] Add new base class for all format classes 2023-01-31 16:23:04 +03:00
0ae117891d Merge branch release/v7.3.0 into master 2023-01-31 08:01:17 +00:00
77cad58384 [oform] Fix field count in case of complex forms 2023-01-27 02:27:31 +05:00
a908a16e95 [oform] Add event to handle undo/redo 2023-01-19 19:59:29 +05:00
72139c5780 Fix bug #60651
Add translation for default role
2023-01-19 18:40:36 +05:00
366f847ba3 Fix bug #60326
Add ability to add date-time content control with form properties
2023-01-13 17:22:39 +03:00
6171e936a3 Hide oform context from public access 2023-01-12 19:04:17 +03:00
13dd617208 Fix bug #60321
Fix the problem with adding a fixed form inside the complex form
2023-01-11 22:20:56 +03:00
11 changed files with 205 additions and 30 deletions

47
api.js
View File

@ -298,10 +298,35 @@ window["AscOForm"] = window.AscOForm = AscOForm;
if (!oLogicDocument.IsSelectionLocked(AscCommon.changestype_Paragraph_Content))
{
oLogicDocument.StartAction(AscDFH.historydescription_Document_AddContentControlList);
var oCC = oLogicDocument.AddContentControlDatePicker(oPr, oCommonPr);
let dateTimePr = null;
let formPr = null;
let ccPr = null;
// Пока для совместимости со старым форматом оставляем, чтобы настройки могли приходить по старому (oPr, oCommonPr)
// но в будущем надо перейти на новый вариант contentPr (AscCommon.CContentControlPr)
if (oPr && (oPr instanceof AscCommon.CContentControlPr))
{
dateTimePr = oPr.DateTimePr;
ccPr = oPr;
formPr = oPr.FormPr;
}
else if (oPr && (oPr instanceof AscWord.CSdtDatePickerPr))
{
dateTimePr = oPr;
ccPr = oCommonPr ? oCommonPr : null;
}
var oCC = oLogicDocument.AddContentControlDatePicker(dateTimePr);
if (oCC && oCommonPr)
oCC.SetContentControlPr(oCommonPr);
if (oCC && ccPr)
oCC.SetContentControlPr(ccPr);
if (oCC && formPr)
{
private_ApplyFormPr(oCC, formPr, oLogicDocument);
private_CheckFormKey(oCC, oLogicDocument);
}
oLogicDocument.Recalculate();
oLogicDocument.UpdateInterface();
@ -431,18 +456,20 @@ window["AscOForm"] = window.AscOForm = AscOForm;
if (!form || !formPr)
return;
form.SetFormPr(formPr);
form.SetFormPr(formPr.Copy());
if (formPr.GetFixed())
{
logicDocument.Recalculate(true);
let drawing = form.ConvertFormToFixed();
let drawingPr = new Asc.asc_CImgProperty();
drawingPr.asc_putWrappingStyle(Asc.c_oAscWrapStyle2.Square);
drawing.Set_Props(drawingPr);
form.MoveCursorToContentControl(false);
if (drawing)
{
let drawingPr = new Asc.asc_CImgProperty();
drawingPr.asc_putWrappingStyle(Asc.c_oAscWrapStyle2.Square);
drawing.Set_Props(drawingPr);
form.MoveCursorToContentControl(false);
}
}
}

View File

@ -128,8 +128,13 @@
|| !oForm.IsForm())
return;
// При проверке лока внутри параграфа мы ориентируемся на выделение внутри этого параграфа
// поэтому нужно выделить форму
let state = oLogicDocument.SaveDocumentState();
oForm.SelectContentControl();
let oParagraph = oForm.GetParagraph();
oForm.SkipSpecialContentControlLock(true);
if (!oParagraph
|| oLogicDocument.IsSelectionLocked(AscCommon.changestype_None, {
@ -138,9 +143,11 @@
CheckType : AscCommon.changestype_Paragraph_Content
}, true, oLogicDocument.IsFillingFormMode()))
{
oLogicDocument.LoadDocumentState(state);
oForm.SkipSpecialContentControlLock(false);
return;
}
oLogicDocument.LoadDocumentState(state);
oForm.SkipSpecialContentControlLock(false);
oLogicDocument.StartAction(AscDFH.historydescription_Document_FillFormInPlugin);

View File

@ -10,6 +10,7 @@
"oform/Role.js",
"oform/xml/XmlPackage.js",
"oform/xml/XmlContext.js",
"oform/format/BaseFormatObject.js",
"oform/format/Document.js",
"oform/format/FieldGroup.js",
"oform/format/FieldMaster.js",

View File

@ -170,7 +170,22 @@
if (this.Roles.length <= 1
&& this.Roles[roleIndex].getUserMaster() === this.Format.getDefaultUserMaster()
&& -1 === delegateIndex)
{
let defaultUserMaster = this.Format.getDefaultUserMaster();
if (!defaultUserMaster.isDefaultUserProps())
{
if (!this.startAction(AscDFH.historydescription_OForm_RemoveRole))
return false;
defaultUserMaster.initDefaultUser();
this.NeedRedraw = true;
this.endAction();
return true;
}
return false;
}
if (!this.startAction(AscDFH.historydescription_OForm_RemoveRole))
return false;
@ -445,7 +460,7 @@
{
if (!this.NeedUpdateRoles)
return;
this.NeedUpdateRoles = false;
this.Roles = [];
@ -537,6 +552,15 @@
this.updateRoles();
this.checkRedraw();
};
OForm.prototype.onUndoRedo = function()
{
this.updateRoles();
this.checkRedraw();
};
OForm.prototype.onEndLoadChanges = function()
{
this.onUndoRedo();
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Private area
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,76 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
"use strict";
(function(window)
{
/**
* Базовый класс для всех форматных классов в oform
* @constructor
*/
function CBaseFormatObject()
{
this.Id = null;
if (!AscCommon.g_oIdCounter.m_bLoad && !AscCommon.History.CanAddChanges())
return;
this.Id = AscCommon.g_oIdCounter.GetNewIdForOForm();
AscCommon.g_oTableId.Add(this, this.Id);
}
CBaseFormatObject.prototype.GetId = function()
{
return this.Id;
};
CBaseFormatObject.prototype.Get_Id = function()
{
return this.Id;
};
CBaseFormatObject.prototype.Write_ToBinary2 = function(writer)
{
writer.WriteLong(this.classType);
writer.WriteString2(this.GetId());
};
CBaseFormatObject.prototype.Read_FromBinary2 = function(reader)
{
this.Id = reader.GetString2();
};
CBaseFormatObject.prototype.Refresh_RecalcData = function(change)
{
};
//--------------------------------------------------------export----------------------------------------------------
AscOForm.CBaseFormatObject = CBaseFormatObject;
})(window);

View File

@ -38,10 +38,11 @@
* Основной класс для работы с форматом oform
* @param oform {AscOForm.OForm}
* @constructor
* @extends AscOForm.CBaseFormatObject
*/
function CDocument(oform)
{
AscFormat.CBaseFormatObject.call(this);
AscOForm.CBaseFormatObject.call(this);
this.OForm = oform;
@ -63,7 +64,7 @@
this.UserMasters = [];
this.FieldMasters = [];
}
AscFormat.InitClass(CDocument, AscFormat.CBaseFormatObject, AscDFH.historyitem_type_OForm_Document);
AscFormat.InitClass(CDocument, AscOForm.CBaseFormatObject, AscDFH.historyitem_type_OForm_Document);
CDocument.prototype.clear = function()
{
// TODO: fields?
@ -202,7 +203,7 @@
if (mainContent)
{
let xmlParserContext = new AscCommon.XmlParserContext();
xmlParserContext.xmlReaderContext = xmlContext;
xmlParserContext.setOformContext(xmlContext);
let reader = new AscCommon.StaxParser(mainContent, mainPart, xmlParserContext);
this.fromXml(reader);
}
@ -320,7 +321,7 @@
{
if ("r:id" === reader.GetName())
{
let xmlReaderContext = reader.GetContext().xmlReaderContext;
let xmlReaderContext = reader.GetOformContext();
let rId = reader.GetValueDecodeXml();
let rel = reader.rels.getRelationship(rId);
let userMaster = xmlReaderContext.getUserMaster(rel.getFullPath());

View File

@ -36,10 +36,11 @@
{
/**
* @constructor
* @extends AscOForm.CBaseFormatObject
*/
function CFieldGroup()
{
AscFormat.CBaseFormatObject.call(this);
AscOForm.CBaseFormatObject.call(this);
this.Weight = null;
this.Fields = [];
@ -47,10 +48,14 @@
this.Parent = null;
}
AscFormat.InitClass(CFieldGroup, AscFormat.CBaseFormatObject, AscDFH.historyitem_type_OForm_FieldGroup);
AscFormat.InitClass(CFieldGroup, AscOForm.CBaseFormatObject, AscDFH.historyitem_type_OForm_FieldGroup);
CFieldGroup.prototype.setParent = function(parent)
{
if (this.Parent === parent)
return;
this.Parent = parent;
this.onChange();
};
CFieldGroup.prototype.setWeight = function(value)
{
@ -149,8 +154,11 @@
let fields = [];
for (let fieldIndex = 0, fieldCount = this.Fields.length; fieldIndex < fieldCount; ++fieldIndex)
{
if (this.Fields[fieldIndex].isUseInDocument())
if (this.Fields[fieldIndex].isUseInDocument()
&& this.Fields[fieldIndex].isMainField())
{
fields.push(this.Fields[fieldIndex]);
}
}
if (this.Users.length && this.Parent)
@ -160,8 +168,12 @@
let userFields = this.Parent.getAllFieldsByUserMaster(this.Users[index]);
for (let fieldIndex = 0, fieldCount = userFields.length; fieldIndex < fieldCount; ++fieldIndex)
{
if (-1 === fields.indexOf(userFields[fieldIndex]) && userFields[fieldIndex].isUseInDocument())
if (-1 === fields.indexOf(userFields[fieldIndex])
&& userFields[fieldIndex].isUseInDocument()
&& userFields[fieldIndex].isMainField())
{
fields.push(userFields[fieldIndex]);
}
}
}
}
@ -231,7 +243,7 @@
fG.setWeight(reader.GetValueInt());
}
let xmlReaderContext = reader.GetContext().xmlReaderContext;
let xmlReaderContext = reader.GetOformContext();
let depth = reader.GetDepth();
while (reader.ReadNextSiblingNode(depth))
{

View File

@ -37,10 +37,11 @@
/**
* @param {boolean} [generateId=false]
* @constructor
* @extends AscOForm.CBaseFormatObject
*/
function CFieldMaster(generateId)
{
AscFormat.CBaseFormatObject.call(this);
AscOForm.CBaseFormatObject.call(this);
this.FieldId = null;
this.Field = null;
@ -50,7 +51,7 @@
if (true === generateId)
this.setFieldId(AscCommon.CreateGUID());
}
AscFormat.InitClass(CFieldMaster, AscFormat.CBaseFormatObject, AscDFH.historyitem_type_OForm_FieldMaster);
AscFormat.InitClass(CFieldMaster, AscOForm.CBaseFormatObject, AscDFH.historyitem_type_OForm_FieldMaster);
CFieldMaster.prototype.setLogicField = function(logicField)
{
this.Field = logicField;
@ -178,6 +179,10 @@
&& this.Field.IsUseInDocument()
&& this === this.Field.GetFieldMaster());
};
CFieldMaster.prototype.isMainField = function()
{
return (this.Field && this.Field.IsMainForm());
};
CFieldMaster.prototype.toXml = function(writer)
{
let context = writer.context;
@ -270,7 +275,7 @@
function readUsersFromXml(reader)
{
let xmlReaderContext = reader.GetContext().xmlReaderContext;
let xmlReaderContext = reader.GetOformContext();
let users = [];
let depth = reader.GetDepth();
while (reader.ReadNextSiblingNode(depth))

View File

@ -37,10 +37,11 @@
/**
* @param {AscOForm.CUserMaster} userMaster
* @constructor
* @extends AscOForm.CBaseFormatObject
*/
function CUser(userMaster)
{
AscFormat.CBaseFormatObject.call(this);
AscOForm.CBaseFormatObject.call(this);
this.Email = undefined;
this.Telephone = undefined;
@ -49,7 +50,7 @@
if (userMaster)
this.setUserMaster(userMaster);
}
AscFormat.InitClass(CUser, AscFormat.CBaseFormatObject, AscDFH.historyitem_type_OForm_User);
AscFormat.InitClass(CUser, AscOForm.CBaseFormatObject, AscDFH.historyitem_type_OForm_User);
CUser.prototype.setUserMaster = function(userMaster)
{
if (this.UserMaster === userMaster)

View File

@ -37,10 +37,11 @@
/**
* @param {boolean} [generateId=false]
* @constructor
* @extends AscOForm.CBaseFormatObject
*/
function CUserMaster(generateId)
{
AscFormat.CBaseFormatObject.call(this);
AscOForm.CBaseFormatObject.call(this);
this.UserId = undefined;
this.Role = undefined;
@ -51,10 +52,14 @@
this.Parent = null;
}
AscFormat.InitClass(CUserMaster, AscFormat.CBaseFormatObject, AscDFH.historyitem_type_OForm_UserMaster);
AscFormat.InitClass(CUserMaster, AscOForm.CBaseFormatObject, AscDFH.historyitem_type_OForm_UserMaster);
CUserMaster.prototype.setParent = function(parent)
{
if (this.Parent === parent)
return;
this.Parent = parent;
this.onChange();
};
CUserMaster.prototype.setUserId = function(userId)
{
@ -102,7 +107,7 @@
CUserMaster.prototype.initDefaultUser = function()
{
// TODO: Возможно стоит придумать уникальный id общий для дефолтовой роли
this.setRole("Anyone");
this.setRole(AscCommon.translateManager.getValue("Anyone"));
this.setColor(255, 239, 191);
};
CUserMaster.prototype.compare = function(user)
@ -142,6 +147,18 @@
{
return (0 === this.compare(user));
};
CUserMaster.prototype.isDefaultUserProps = function()
{
let result = false;
let u = this;
AscCommon.ExecuteNoHistory(function()
{
let defaultUser = new CUserMaster();
defaultUser.initDefaultUser();
result = defaultUser.isEqual(u);
});
return result;
};
CUserMaster.prototype.onChange = function()
{
if (!this.Parent)

View File

@ -52,6 +52,10 @@
this.pathToField = {};
this.pathToFieldMaster = {};
}
XmlReaderContext.prototype.getOformContext = function()
{
return this;
};
XmlReaderContext.prototype.getUser = function(path)
{
let user = this.pathToUser[path];
@ -143,7 +147,7 @@
return null;
let xmlParserContext = new AscCommon.XmlParserContext();
xmlParserContext.xmlReaderContext = this;
xmlParserContext.setOformContext(this);
return new AscCommon.StaxParser(partContent, part, xmlParserContext);
};
XmlReaderContext.prototype.getAllByMapAndPath = function(map, path, fromXml)