Skip to content

Commit

Permalink
For bug 72801
Browse files Browse the repository at this point in the history
Add removeAllInks for presentation
  • Loading branch information
Coolcooo committed Feb 12, 2025
1 parent 7d9a3b3 commit 710d32e
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 0 deletions.
32 changes: 32 additions & 0 deletions common/Drawings/Format/Format.js
Original file line number Diff line number Diff line change
Expand Up @@ -10087,6 +10087,38 @@
}

InitClass(CSld, CBaseNoIdObject, 0);
CSld.prototype.removeAllInks = function () {
if (!this.parent) {
return;
}
const arrSpTree = this.spTree;
for (let i = arrSpTree.length - 1; i >= 0; i -= 1) {
const oDrawing = arrSpTree[i];
if (oDrawing.isInk()) {
this.parent.removeFromSpTreeByPos(i);
if (oDrawing.setBDeleted2) {
oDrawing.setBDeleted2(true);
} else {
oDrawing.setBDeleted(true);
}
} else {
oDrawing.removeAllInks();
}
}
};
CSld.prototype.getAllInks = function (arrInks) {
arrInks = arrInks || [];
const arrSpTree = this.spTree;
for (let i = arrSpTree.length - 1; i >= 0; i -= 1) {
const oDrawing = arrSpTree[i];
if (oDrawing.isInk()) {
arrInks.push(oDrawing);
} else {
oDrawing.getAllInks(arrInks);
}
}
return arrInks;
};
CSld.prototype.getObjectsNamesPairs = function () {
var aPairs = [];
var aSpTree = this.spTree;
Expand Down
2 changes: 2 additions & 0 deletions common/Drawings/Format/GraphicObjectBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -3799,6 +3799,8 @@
CGraphicObjectBase.prototype.generateLocalDrawingPart = function () {};
CGraphicObjectBase.prototype.generateSmartArtDrawingPart = function () {};
CGraphicObjectBase.prototype.checkDrawingPartWithHistory = function () {};
CGraphicObjectBase.prototype.removeAllInks = function () {};
CGraphicObjectBase.prototype.getAllInks = function (arrInks) {return arrInks || []};
var ANIM_LABEL_WIDTH_PIX = 22;
var ANIM_LABEL_HEIGHT_PIX = 17;

Expand Down
39 changes: 39 additions & 0 deletions common/Drawings/Format/GroupShape.js
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,45 @@
this.spTree[i].generateSmartArtDrawingPart();
}
};
CGroupShape.prototype.isInk = function () {
if (!this.spTree.length) {
return false;
}
for (let i = 0; i < this.spTree.length; i++) {
const oDrawing = this.spTree[i];
if (!oDrawing.isInk()) {
return false;
}
}
return true;
};
CGroupShape.prototype.removeAllInks = function () {
for (let i = this.spTree.length - 1; i >= 0; i -= 1) {
const oDrawing = this.spTree[i];
if (oDrawing.isInk()) {
this.removeFromSpTreeByPos(i);
if (oDrawing.setBDeleted2) {
oDrawing.setBDeleted2(true);
} else {
oDrawing.setBDeleted(true);
}
} else {
oDrawing.removeAllInks();
}
}
};
CGroupShape.prototype.getAllInks = function (arrInks) {
arrInks = arrInks || [];
for (let i = this.spTree.length - 1; i >= 0; i -= 1) {
const oDrawing = this.spTree[i];
if (oDrawing.isInk()) {
arrInks.push(oDrawing);
} else {
oDrawing.getAllInks(arrInks);
}
}
return arrInks;
};

//--------------------------------------------------------export----------------------------------------------------
window['AscFormat'] = window['AscFormat'] || {};
Expand Down
7 changes: 7 additions & 0 deletions slide/Editor/Format/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,13 @@ SlideLayout.prototype.getMaster = function(){
SlideLayout.prototype.checkPlaceholders = function(oPlaceholders) {
return AscCommonSlide.Slide.prototype.checkPlaceholders.call(this, oPlaceholders);
};
SlideLayout.prototype.removeAllInks = function() {
return AscCommonSlide.Slide.prototype.removeAllInks.call(this);
};
SlideLayout.prototype.getAllInks = function(arrInks) {
arrInks = arrInks || [];
return AscCommonSlide.Slide.prototype.getAllInks.call(this, arrInks);
};

let LAYOUT_TYPE_MAP = {};
LAYOUT_TYPE_MAP["blank"] = AscFormat.nSldLtTBlank;
Expand Down
55 changes: 55 additions & 0 deletions slide/Editor/Format/Presentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -10149,6 +10149,32 @@ CPresentation.prototype.Document_Is_SelectionLocked = function (CheckType, Addit
this.viewPrLock.Lock.Check(check_obj);
}

if (CheckType === AscCommon.changestype_None) {
if (AdditionalData) {
if (AscCommon.changestype_2_ElementsArray_and_Type === AdditionalData.Type) {
if (AdditionalData.CheckType === AscCommon.changestype_Drawing_Props) {
const arrElements = AdditionalData.Elements;
const oMainElements = {};
for (let i = 0; i < arrElements.length; ++i) {
const oElement = arrElements[i].getMainGroup() || arrElements[i];
const sElementId = oElement.Get_Id();
if (!oMainElements[sElementId]) {
oMainElements[sElementId] = true;
const oCheckObj =
{
"type" : c_oAscLockTypeElemPresentation.Object,
"slideId": slide_id,
"objId" : sElementId,
"guid" : sElementId
};
oElement.Lock.Check(oCheckObj);
}
}
}
}
}
}

var bResult = AscCommon.CollaborativeEditing.OnEnd_CheckLock(DontLockInFastMode);

if (true === bResult) {
Expand Down Expand Up @@ -11327,6 +11353,35 @@ CPresentation.prototype.RemoveCustomProperty = function(idx) {
this.FinalizeAction(true);
};

CPresentation.prototype.RemoveAllInks = function () {
const arrInks = this.GetAllInks();
if (!arrInks.length || this.Document_Is_SelectionLocked(AscCommon.changestype_None, {Type: AscCommon.changestype_2_ElementsArray_and_Type, CheckType: AscCommon.changestype_Drawing_Props, Elements: arrInks})) {
return;
}

this.StartAction(0);
for (let i = 0; i < this.Slides.length; i += 1) {
const oSlide = this.Slides[i];
oSlide.removeAllInks();
}
for (let i = 0; i < this.slideMasters.length; i += 1) {
const oSlideMaster = this.slideMasters[i];
oSlideMaster.removeAllInks();
}
this.FinalizeAction();
};
CPresentation.prototype.GetAllInks = function () {
const arrInks = [];
for (let i = 0; i < this.Slides.length; i += 1) {
const oSlide = this.Slides[i];
oSlide.getAllInks(arrInks);
}
for (let i = 0; i < this.slideMasters.length; i += 1) {
const oSlideMaster = this.slideMasters[i];
oSlideMaster.getAllInks(arrInks);
}
return arrInks;
};
function collectSelectedObjects(aSpTree, aCollectArray, bRecursive, oIdMap, bSourceFormatting) {
var oSp;
var oPr = new AscFormat.CCopyObjectProperties();
Expand Down
8 changes: 8 additions & 0 deletions slide/Editor/Format/Slide.js
Original file line number Diff line number Diff line change
Expand Up @@ -2127,6 +2127,14 @@ AscFormat.InitClass(Slide, AscFormat.CBaseFormatObject, AscDFH.historyitem_type_
}
return false;
};
Slide.prototype.removeAllInks = function () {
this.cSld.removeAllInks();
};
Slide.prototype.getAllInks = function (arrInks) {
arrInks = arrInks || [];
this.cSld.getAllInks(arrInks);
return arrInks;
};

function fLoadComments(oObject, authors)
{
Expand Down
16 changes: 16 additions & 0 deletions slide/Editor/Format/SlideMaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,22 @@ MasterSlide.prototype.drawViewPrMarks = function(oGraphics) {
if(oGraphics.isSupportTextDraw && !oGraphics.isSupportTextDraw()) return;
return AscCommonSlide.Slide.prototype.drawViewPrMarks.call(this, oGraphics);
};
MasterSlide.prototype.removeAllInks = function() {
AscCommonSlide.Slide.prototype.removeAllInks.call(this);
for (let i = 0; i < this.sldLayoutLst.length; i++) {
const oLayout = this.sldLayoutLst[i];
oLayout.removeAllInks();
}
};
MasterSlide.prototype.getAllInks = function(arrInks) {
arrInks = arrInks || [];
AscCommonSlide.Slide.prototype.getAllInks.call(this, arrInks);
for (let i = 0; i < this.sldLayoutLst.length; i++) {
const oLayout = this.sldLayoutLst[i];
oLayout.getAllInks(arrInks);
}
return arrInks;
};
function CMasterThumbnailDrawer()
{
this.CanvasImage = null;
Expand Down
12 changes: 12 additions & 0 deletions slide/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -9595,6 +9595,18 @@ background-repeat: no-repeat;\

oLogicDocument.EraseAllInksOnSlide();
};
asc_docs_api.prototype.removeAllInks = function () {
let oLogicDocument = this.getLogicDocument();
if(!oLogicDocument) return;

oLogicDocument.RemoveAllInks();
};
baseEditorsApi.prototype.haveInks = function() {
let oLogicDocument = this.getLogicDocument();
if(!oLogicDocument) return;

return !!oLogicDocument.GetAllInks().length;
};

//-------------------------------------------------------------export---------------------------------------------------
window['Asc'] = window['Asc'] || {};
Expand Down

0 comments on commit 710d32e

Please sign in to comment.