Visio.ShapeView class

表示 ShapeView 类。

Extends

注解

[ API 集: 1.1 ]

属性

context

与 对象关联的请求上下文。 这会将加载项的进程连接到 Office 主机应用程序的进程。

highlight

表示形状周围的突出显示内容。

方法

addOverlay(OverlayType, Content, OverlayHorizontalAlignment, OverlayVerticalAlignment, Width, Height)

在形状之上添加覆盖。

addOverlay(OverlayTypeString, Content, OverlayHorizontalAlignmentString, OverlayVerticalAlignmentString, Width, Height)

在形状之上添加覆盖。

load(options)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()

load(propertyNames)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()

load(propertyNamesAndPaths)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()

removeOverlay(OverlayId)

删除形状上的特定覆盖或所有覆盖。

set(properties, options)

同时设置对象的多个属性。 可以传递具有相应属性的纯对象,也可以传递同一类型的另一个 API 对象。

set(properties)

基于现有的已加载对象,同时对对象设置多个属性。

setMockData(data)

设置模拟数据

setText(Text)

SetText API 的用途是在运行时更新 Visio 形状中的文本。 更新的文本保留形状文本的现有格式属性。

showOverlay(overlayId, show)

显示形状上的特定覆盖层。

toJSON()

重写 JavaScript toJSON() 方法,以便在将 API 对象传递给 JSON.stringify()时提供更有用的输出。 JSON.stringify (,依次调用toJSON传递给它的 对象的 方法。) 而原始 Visio.ShapeView 对象是 API 对象,toJSON该方法返回一个纯 JavaScript 对象, (类型为 Visio.Interfaces.ShapeViewData) ,该对象包含从原始对象加载的任何子属性的浅表副本。

属性详细信息

context

与 对象关联的请求上下文。 这会将加载项的进程连接到 Office 主机应用程序的进程。

context: RequestContext;

属性值

highlight

表示形状周围的突出显示内容。

highlight: Visio.Highlight;

属性值

注解

[ API 集: 1.1 ]

示例

Visio.run(session, function (ctx) {
    const activePage = ctx.document.getActivePage();
    const shape = activePage.shapes.getItem(0);
    shape.view.highlight = { color: "#E7E7E7", width: 100 };
    return ctx.sync();
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

方法详细信息

addOverlay(OverlayType, Content, OverlayHorizontalAlignment, OverlayVerticalAlignment, Width, Height)

在形状之上添加覆盖。

addOverlay(OverlayType: Visio.OverlayType, Content: string, OverlayHorizontalAlignment: Visio.OverlayHorizontalAlignment, OverlayVerticalAlignment: Visio.OverlayVerticalAlignment, Width: number, Height: number): OfficeExtension.ClientResult<number>;

参数

OverlayType
Visio.OverlayType

覆盖类型。 可以是“Text”、“Image”或“Html”。

Content

string

覆盖的内容。

OverlayHorizontalAlignment
Visio.OverlayHorizontalAlignment

覆盖的水平对齐方式。 可以是“Left”、“Center”或“Right”。

OverlayVerticalAlignment
Visio.OverlayVerticalAlignment

覆盖的垂直对齐方式。 可以是“Top”、“Middle”、“Bottom”。

Width

number

覆盖宽度。

Height

number

覆盖高度。

返回

注解

[ API 集: 1.1 ]

示例

Visio.run(session, function (ctx) {
    const activePage = ctx.document.getActivePage();
    const shape = activePage.shapes.getItem(0);
    const overlayId = shape.view.addOverlay("Image", "Visio Online", "Center", "Middle", 50, 50);
    return ctx.sync();
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

addOverlay(OverlayTypeString, Content, OverlayHorizontalAlignmentString, OverlayVerticalAlignmentString, Width, Height)

在形状之上添加覆盖。

addOverlay(OverlayTypeString: "Text" | "Image" | "Html", Content: string, OverlayHorizontalAlignmentString: "Left" | "Center" | "Right", OverlayVerticalAlignmentString: "Top" | "Middle" | "Bottom", Width: number, Height: number): OfficeExtension.ClientResult<number>;

参数

OverlayTypeString

"Text" | "Image" | "Html"

覆盖类型。 可以是“Text”、“Image”或“Html”。

Content

string

覆盖的内容。

OverlayHorizontalAlignmentString

"Left" | "Center" | "Right"

覆盖的水平对齐方式。 可以是“Left”、“Center”或“Right”。

OverlayVerticalAlignmentString

"Top" | "Middle" | "Bottom"

覆盖的垂直对齐方式。 可以是“Top”、“Middle”、“Bottom”。

Width

number

覆盖宽度。

Height

number

覆盖高度。

返回

注解

[ API 集: 1.1 ]

load(options)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()

load(options?: Visio.Interfaces.ShapeViewLoadOptions): Visio.ShapeView;

参数

options
Visio.Interfaces.ShapeViewLoadOptions

提供要加载对象的属性的选项。

返回

load(propertyNames)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()

load(propertyNames?: string | string[]): Visio.ShapeView;

参数

propertyNames

string | string[]

逗号分隔的字符串或指定要加载的属性的字符串数组。

返回

load(propertyNamesAndPaths)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): Visio.ShapeView;

参数

propertyNamesAndPaths

{ select?: string; expand?: string; }

propertyNamesAndPaths.select 是一个逗号分隔的字符串,指定要加载的属性,是 propertyNamesAndPaths.expand 一个逗号分隔的字符串,指定要加载的导航属性。

返回

removeOverlay(OverlayId)

删除形状上的特定覆盖或所有覆盖。

removeOverlay(OverlayId: number): void;

参数

OverlayId

number

覆盖 ID。删除形状上特定 ID 的覆盖。

返回

void

注解

[ API 集: 1.1 ]

示例

Visio.run(session, function (ctx) {
    const activePage = ctx.document.getActivePage();
    const shape = activePage.shapes.getItem(0);
    shape.view.removeOverlay(1);
    return ctx.sync();
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

set(properties, options)

同时设置对象的多个属性。 可以传递具有相应属性的纯对象,也可以传递同一类型的另一个 API 对象。

set(properties: Interfaces.ShapeViewUpdateData, options?: OfficeExtension.UpdateOptions): void;

参数

properties
Visio.Interfaces.ShapeViewUpdateData

一个 JavaScript 对象,其属性按同构方式构造为调用方法的对象的属性。

options
OfficeExtension.UpdateOptions

提供一个选项,用于在 properties 对象尝试设置任何只读属性时禁止显示错误。

返回

void

set(properties)

基于现有的已加载对象,同时对对象设置多个属性。

set(properties: Visio.ShapeView): void;

参数

properties
Visio.ShapeView

返回

void

setMockData(data)

设置模拟数据

setMockData(data: Visio.Interfaces.ShapeViewData): void;

参数

返回

void

setText(Text)

SetText API 的用途是在运行时更新 Visio 形状中的文本。 更新的文本保留形状文本的现有格式属性。

setText(Text: string): void;

参数

Text

string

Text 参数是在形状上显示的更新文本。

返回

void

注解

[ API 集: 1.1 ]

showOverlay(overlayId, show)

显示形状上的特定覆盖层。

showOverlay(overlayId: number, show: boolean): void;

参数

overlayId

number

上下文中的覆盖 ID。

show

boolean

是否显示覆盖层。

返回

void

注解

[ API 集: 1.1 ]

toJSON()

重写 JavaScript toJSON() 方法,以便在将 API 对象传递给 JSON.stringify()时提供更有用的输出。 JSON.stringify (,依次调用toJSON传递给它的 对象的 方法。) 而原始 Visio.ShapeView 对象是 API 对象,toJSON该方法返回一个纯 JavaScript 对象, (类型为 Visio.Interfaces.ShapeViewData) ,该对象包含从原始对象加载的任何子属性的浅表副本。

toJSON(): Visio.Interfaces.ShapeViewData;

返回