跳到主要内容

GetAllOleObjects

返回包含幻灯片母版中所有 OLE 对象的数组。

语法

expression.GetAllOleObjects();

expression - 表示 ApiMaster 类的变量。

参数

此方法没有任何参数。

返回值

ApiOleObject[]

示例

此示例演示如何获取包含幻灯片母版中所有 OLE 对象的数组。

// How to get all OLE objects from the master of presentation.

// Get all OLE objects from the presentation slide master as an array.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
const master = presentation.GetMaster(0);

const oleObject = Api.CreateOleObject(
'https://static.onlyoffice.com/assets/docs/samples/img/onlyoffice_logo.png',
150 * 36000, 150 * 36000,
'https://youtu.be/SKGz4pmnpgY',
'asc.{38E022EA-AD92-45FC-B22B-49DF39746DB4}'
);
oleObject.SetSize(200 * 36000, 130 * 36000);
oleObject.SetPosition(70 * 36000, 30 * 36000);
master.AddObject(oleObject);

const allOleObjects = master.GetAllOleObjects();
const appId = allOleObjects[0].GetApplicationId();

const gs1 = Api.CreateGradientStop(Api.RGB(255, 224, 204), 0);
const gs2 = Api.CreateGradientStop(Api.RGB(255, 164, 101), 100000);
const fill = Api.CreateLinearGradientFill([gs1, gs2], 5400000);
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const drawing = Api.CreateShape('rect', 300 * 36000, 15 * 36000, fill, stroke);
drawing.SetPosition(20 * 36000, 170 * 36000);
const docContent = drawing.GetContent();
const paragraph = docContent.GetElement(0);
paragraph.AddText('The application ID for the current OLE object: ' + appId);
master.AddObject(drawing);