Skip to content

Commit

Permalink
Fix bug #72929
Browse files Browse the repository at this point in the history
Allow to add content controls in a range permission
  • Loading branch information
KirillovIlya committed Jan 29, 2025
1 parent 82bf48a commit 62f8c5b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
40 changes: 33 additions & 7 deletions word/Editor/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -13444,11 +13444,12 @@ CDocument.prototype.IsCursorInHyperlink = function(bCheckEnd)
* @param [checkType=undefined]
* @param [additionalData=undefined]
* @param [sendEvent=false]
* @param [actionDescription=undefined]
* @returns {boolean}
*/
CDocument.prototype.CanPerformAction = function(isIgnoreCanEditFlag, checkType, additionalData, sendEvent)
CDocument.prototype.CanPerformAction = function(isIgnoreCanEditFlag, checkType, additionalData, sendEvent, actionDescription)
{
let isPermRange = this.IsPermRangeEditing(checkType, additionalData);
let isPermRange = this.IsPermRangeEditing(checkType, additionalData, actionDescription);
if (sendEvent)
{
if (!isPermRange && this.IsNeedNotificationOnEditProtectedRange(checkType, additionalData))
Expand All @@ -13461,16 +13462,42 @@ CDocument.prototype.CanPerformAction = function(isIgnoreCanEditFlag, checkType,
* Проверяем, что действие с заданным типом произойдет в разрешенной области
* @param changesType
* @param additionalData
* @param actionDescription
* @returns {boolean}
*/
CDocument.prototype.IsPermRangeEditing = function(changesType, additionalData)
CDocument.prototype.IsPermRangeEditing = function(changesType, additionalData, actionDescription)
{
if (this.Api.isViewMode)
return false;

if (!this.Api.isRestrictionComments() && !this.Api.isRestrictionView())
return true;

// Для некоторых специфичных действий пока оставим такую обработку
let t = this;
function getChangesTypeByDescription(changesType, actionDescription)
{
if (undefined === actionDescription)
return changesType;

if (AscDFH.historydescription_Document_AddBlockLevelContentControl === actionDescription)
{
if (t.IsTextSelectionUse())
changesType = AscCommon.changestype_Paragraph_Properties;
else
changesType = AscCommon.changestype_Paragraph_Content;
}
else if (AscDFH.historydescription_Document_AddInlineLevelContentControl === actionDescription)
{
changesType = AscCommon.changestype_Paragraph_Content;
}

return changesType;
}

changesType = getChangesTypeByDescription(changesType, actionDescription);


if (AscCommon.changestype_None !== changesType)
{
if (AscCommon.changestype_Table_Properties === changesType || AscCommon.changestype_Table_RemoveCells === changesType)
Expand Down Expand Up @@ -13501,10 +13528,9 @@ CDocument.prototype.IsPermRangeEditing = function(changesType, additionalData)
}
}

let t = this;
function checkAdditional(additionalData)
{
if (!additionalData)
if (!additionalData || undefined === additionalData.Type)
return true;

if (AscCommon.changestype_2_InlineObjectMove === additionalData.Type)
Expand Down Expand Up @@ -13677,12 +13703,12 @@ CDocument.prototype._checkPermRangeForElement = function(element)

return element.isWholeElementInPermRange();
};
CDocument.prototype.Document_Is_SelectionLocked = function(CheckType, AdditionalData, DontLockInFastMode, isIgnoreCanEditFlag, fCallback)
CDocument.prototype.Document_Is_SelectionLocked = function(CheckType, AdditionalData, DontLockInFastMode, isIgnoreCanEditFlag, fCallback, actionDescription)
{
if (this.IsActionStarted() && this.IsPostActionLockCheck())
return false;

if (!this.CanPerformAction(isIgnoreCanEditFlag, CheckType, AdditionalData, true))
if (!this.CanPerformAction(isIgnoreCanEditFlag, CheckType, AdditionalData, true, actionDescription))
{
if (fCallback)
fCallback(true);
Expand Down
4 changes: 2 additions & 2 deletions word/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -9951,7 +9951,7 @@ background-repeat: no-repeat;\
var oResult = null;
if (c_oAscSdtLevelType.Block === nType)
{
if (false === oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_ContentControl_Add, null))
if (false === oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_ContentControl_Add, null, true, false, null, AscDFH.historydescription_Document_AddBlockLevelContentControl))
{
oLogicDocument.StartAction(AscDFH.historydescription_Document_AddBlockLevelContentControl);

Expand All @@ -9973,7 +9973,7 @@ background-repeat: no-repeat;\
}
else if (c_oAscSdtLevelType.Inline === nType)
{
if (false === oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_ContentControl_Add, null))
if (false === oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_ContentControl_Add, null, true, false, null, AscDFH.historydescription_Document_AddInlineLevelContentControl))
{
oLogicDocument.StartAction(AscDFH.historydescription_Document_AddInlineLevelContentControl);

Expand Down

0 comments on commit 62f8c5b

Please sign in to comment.