Visio.ShapeView class
表示 ShapeView 类。
方法
| add |
在形状之上添加覆盖。 |
| add |
在形状之上添加覆盖。 |
| load(options) | 将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 |
| load(property |
将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 |
| load(property |
将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 |
| remove |
删除形状上的特定覆盖或所有覆盖。 |
| set(properties, options) | 同时设置对象的多个属性。 可以传递具有相应属性的纯文本对象,也可以传递另一个相同类型的 API 对象。 |
| set(properties) | 基于现有加载的对象,同时在对象上设置多个属性。 |
| set |
SetText API 的目的是在运行时更新 Visio 形状内的文本。 更新的文本将保留形状文本的现有格式属性。 |
| show |
在形状上显示特定覆盖。 |
| toJSON() | 覆盖 JavaScript |
属性详细信息
context
highlight
表示形状周围的突出显示内容。
highlight: Visio.Highlight;
属性值
注解
示例
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
覆盖类型。 可以是“文本”、“图像”或“html”。
- Content
-
string
覆盖的内容。
- OverlayHorizontalAlignment
- Visio.OverlayHorizontalAlignment
叠加层的水平对齐。 可以是“左”、“居中”或“右”。
- OverlayVerticalAlignment
- Visio.OverlayVerticalAlignment
叠加层的垂直对齐。 可以是“Top”、“Middle”、“Bottom”。
- Width
-
number
覆盖宽度。
- Height
-
number
覆盖高度。
返回
OfficeExtension.ClientResult<number>
注解
示例
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(OverlayType, Content, OverlayHorizontalAlignment, OverlayVerticalAlignment, Width, Height)
在形状之上添加覆盖。
addOverlay(OverlayType: "Text" | "Image" | "Html", Content: string, OverlayHorizontalAlignment: "Left" | "Center" | "Right", OverlayVerticalAlignment: "Top" | "Middle" | "Bottom", Width: number, Height: number): OfficeExtension.ClientResult<number>;
参数
- OverlayType
-
"Text" | "Image" | "Html"
覆盖类型。 可以是“文本”、“图像”或“html”。
- Content
-
string
覆盖的内容。
- OverlayHorizontalAlignment
-
"Left" | "Center" | "Right"
叠加层的水平对齐。 可以是“左”、“居中”或“右”。
- OverlayVerticalAlignment
-
"Top" | "Middle" | "Bottom"
叠加层的垂直对齐。 可以是“Top”、“Middle”、“Bottom”。
- Width
-
number
覆盖宽度。
- Height
-
number
覆盖高度。
返回
OfficeExtension.ClientResult<number>
注解
load(options)
将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()。
load(options?: Visio.Interfaces.ShapeViewLoadOptions): Visio.ShapeView;
参数
为要加载的对象属性提供选项。
返回
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
注解
示例
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
setText(Text)
SetText API 的目的是在运行时更新 Visio 形状内的文本。 更新的文本将保留形状文本的现有格式属性。
setText(Text: string): void;
参数
- Text
-
string
文本参数是要显示在形状上的更新文本。
返回
void
注解
showOverlay(overlayId, show)
在形状上显示特定覆盖。
showOverlay(overlayId: number, show: boolean): void;
参数
- overlayId
-
number
上下文中的覆盖 ID。
- show
-
boolean
是否显示叠加。
返回
void
注解
toJSON()
覆盖 JavaScript toJSON() 方法,以便在将 API 对象传递给 JSON.stringify()时提供更有用的输出。 (JSON.stringify反过来调用 toJSON 传递给它的对象的方法。) 虽然原始 Visio.ShapeView 对象是 API 对象,但该 toJSON 方法返回一个纯 JavaScript 对象, (类型化为 Visio.Interfaces.ShapeViewData) ,其中包含从原始对象加载的任何子属性的浅层副本。
toJSON(): Visio.Interfaces.ShapeViewData;