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