Aspose.Slides for .NET是独特的演示处理API,使应用程序可以读取,编写,修改和转换PowerPoint演示文稿。做为独立的API,它提供了管理PowerPoint关键功能的功能,例如管理文本,形状,表格和动画,向幻灯片添加音频和视频,预览幻灯片等等。ide
Aspose.Slides for .NET(点击下载)更新至最新版v19.8,引入了用于得到有效值的新API,从而获取“本地”值和“有效”值。下面咱们一块儿来了解一下具体内容吧!布局
新的功能支持经过IPortion.PortionFormat在不一样级别的表示结构层次结构中设置文本部分的属性。如下是其中一些:字体
对于任何这些级别,直接在此级别设置的值称为“本地”。在任何级别,能够定义或省略“本地”值。但最后,当应用程序(使用Aspose.Slides甚至PowerPoint自己构建)须要知道该部分应该是什么样的时候(在图像导出或在屏幕上绘图时),它使用“有效”值 - 彻底使用层次结构构建的已定义值集,可能的值覆盖最低层的每一个级别以及硬编码到PowerPoint中的默认值。动画
“有效数据”对象本质上是不可变的-它们仅用于获取最终的组合信息。“本地数据“”对象是可变的-它们用于设置属性。编码
启动Aspose.Slides v19.8所须要的只是从您但愿得到有效值的本地格式调用GetEffective()方法。下面列举个例子说明:spa
using (Presentation pres = new Presentation("MyPresentation.pptx")) { IAutoShape shape = pres.Slides[0].Shapes[0] as IAutoShape; ITextFrameFormat localTextFrameFormat = shape.TextFrame.TextFrameFormat; ITextFrameFormatEffectiveData effectiveTextFrameFormat = localTextFrameFormat.GetEffective(); IPortionFormat localPortionFormat = shape.TextFrame.Paragraphs[0].Portions[0].PortionFormat; IPortionFormatEffectiveData effectivePortionFormat = localPortionFormat.GetEffective(); }
注意:orm
GetEffective()方法已添加到ITextFrameFormat、ITextStyle、IParagraphFormat、IPortionFormat、IFillFormat、ILineFormat、IEffectFormat、IThreeDFormat、ITableFormat、IRowFormat、IColumnFormat、ICellFormat、IBackground 和ITheme接口。视频
这两个类都是抽象的,并在内部用于维护系统的统一有效值。AccessibleEffectiveData类是具备本身的继承层次结构的格式的有效数据类的基类。BaseEffectiveData类是AccessibleEffectiveData的基类,也是全部有效数据类的基类,它们没有本身的继承层次结构,而且做为更复杂的有效数据类的一部分。对象
如下是在不一样的表示结构级别上设置本地字体高度值后,演示部分的有效字体高度值的代码。继承
using (Presentation pres = new Presentation()) { IAutoShape newShape = pres.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 100, 100, 400, 75, false); newShape.AddTextFrame(""); newShape.TextFrame.Paragraphs[0].Portions.Clear(); IPortion portion0 = new Portion("Sample text with first portion"); IPortion portion1 = new Portion(" and second portion."); newShape.TextFrame.Paragraphs[0].Portions.Add(portion0); newShape.TextFrame.Paragraphs[0].Portions.Add(portion1); Console.WriteLine("Effective font height just after creation:"); Console.WriteLine("Portion #0: " + portion0.PortionFormat.GetEffective().FontHeight); Console.WriteLine("Portion #1: " + portion1.PortionFormat.GetEffective().FontHeight); pres.DefaultTextStyle.GetLevel(0).DefaultPortionFormat.FontHeight = 24; Console.WriteLine("Effective font height after setting entire presentation default font height:"); Console.WriteLine("Portion #0: " + portion0.PortionFormat.GetEffective().FontHeight); Console.WriteLine("Portion #1: " + portion1.PortionFormat.GetEffective().FontHeight); newShape.TextFrame.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontHeight = 40; Console.WriteLine("Effective font height after setting paragraph default font height:"); Console.WriteLine("Portion #0: " + portion0.PortionFormat.GetEffective().FontHeight); Console.WriteLine("Portion #1: " + portion1.PortionFormat.GetEffective().FontHeight); newShape.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FontHeight = 55; Console.WriteLine("Effective font height after setting portion #0 font height:"); Console.WriteLine("Portion #0: " + portion0.PortionFormat.GetEffective().FontHeight); Console.WriteLine("Portion #1: " + portion1.PortionFormat.GetEffective().FontHeight); newShape.TextFrame.Paragraphs[0].Portions[1].PortionFormat.FontHeight = 18; Console.WriteLine("Effective font height after setting portion #1 font height:"); Console.WriteLine("Portion #0: " + portion0.PortionFormat.GetEffective().FontHeight); Console.WriteLine("Portion #1: " + portion1.PortionFormat.GetEffective().FontHeight); } // Output: // Effective font height just after creation: // Portion #0: 18 // Portion #1: 18 // Effective font height after setting entire presentation default font height: // Portion #0: 24 // Portion #1: 24 // Effective font height after setting paragraph default font height: // Portion #0: 40 // Portion #1: 40 // Effective font height after setting portion #0 font height: // Portion #0: 55 // Portion #1: 40 // Effective font height after setting portion #1 font height: // Portion #0: 55 // Portion #1: 18