Shape Effective Properties
In this topic, we will discuss effective and local properties. When we set values directly at these levels
- In portion properties on portion’s slide.
- In prototype shape text style on layout or master slide (if portion’s text frame shape has one).
- In presentation global text settings.
then those values are called local values. At any level, local values could be defined or omitted. But finally when it comes to the moment when the application needs to know what the portion should look like it uses effective values. You can get effective values by using getEffective() method from the local format.
The following example shows how to get effective values.
using (Presentation pres = new Presentation("Presentation1.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();
}
Get Effective Properties of Camera
Aspose.Slides for .NET allows developers to get effective properties of the camera. For this purpose, the CameraEffectiveData class has been added in Aspose.Slides. CameraEffectiveData class represents an immutable object which contains effective camera properties. An instance of CameraEffectiveData class is used as part of ThreeDFormatEffectiveData class which is an effective values pair for ThreeDFormat class.
The following code sample shows how to get effective properties for the camera.
using (Presentation pres = new Presentation("Presentation1.pptx"))
{
IThreeDFormatEffectiveData threeDEffectiveData = pres.Slides[0].Shapes[0].ThreeDFormat.GetEffective();
Console.WriteLine("= Effective camera properties =");
Console.WriteLine("Type: " + threeDEffectiveData.Camera.CameraType);
Console.WriteLine("Field of view: " + threeDEffectiveData.Camera.FieldOfViewAngle);
Console.WriteLine("Zoom: " + threeDEffectiveData.Camera.Zoom);
}
Get Effective Properties of Light Rig
Aspose.Slides for .NET allows developers to get effective properties of Light Rig. For this purpose, the LightRigEffectiveData class has been added in Aspose.Slides. LightRigEffectiveData class represents an immutable object which contains effective light rig properties. An instance of LightRigEffectiveData class is used as part of ThreeDFormatEffectiveData class which is an effective values pair for ThreeDFormat class.
The following code sample shows how to get effective properties for the Light Rig.
using (Presentation pres = new Presentation("Presentation1.pptx"))
{
IThreeDFormatEffectiveData threeDEffectiveData = pres.Slides[0].Shapes[0].ThreeDFormat.GetEffective();
Console.WriteLine("= Effective light rig properties =");
Console.WriteLine("Type: " + threeDEffectiveData.LightRig.LightType);
Console.WriteLine("Direction: " + threeDEffectiveData.LightRig.Direction);
}
Get Effective Properties of Bevel Shape
Aspose.Slides for .NET allows developers to get effective properties of Bevel Shape. For this purpose, the ShapeBevelEffectiveData class has been added in Aspose.Slides. ShapeBevelEffectiveData class represents an immutable object which contains effective shape’s face relief properties. An instance of ShapeBevelEffectiveData class is used as part of ThreeDFormatEffectiveData class which is an effective values pair for ThreeDFormat class.
The following code sample shows how to get effective properties for the Bevel Shape.
using (Presentation pres = new Presentation("Presentation1.pptx"))
{
IThreeDFormatEffectiveData threeDEffectiveData = pres.Slides[0].Shapes[0].ThreeDFormat.GetEffective();
Console.WriteLine("= Effective shape's top face relief properties =");
Console.WriteLine("Type: " + threeDEffectiveData.BevelTop.BevelType);
Console.WriteLine("Width: " + threeDEffectiveData.BevelTop.Width);
Console.WriteLine("Height: " + threeDEffectiveData.BevelTop.Height);
}
Get Effective Properties of Text Frame
Using Aspose.Slides for .NET, you can get effective properties of Text Frame. For this purpose, the TextFrameFormatEffectiveData class has been added in Aspose.Slides which contains effective text frame formatting properties.
The following code sample shows how to get effective text frame formatting properties.
using (Presentation pres = new Presentation("Presentation1.pptx"))
{
IAutoShape shape = pres.Slides[0].Shapes[0] as IAutoShape;
ITextFrameFormat textFrameFormat = shape.TextFrame.TextFrameFormat;
ITextFrameFormatEffectiveData effectiveTextFrameFormat = textFrameFormat.GetEffective();
Console.WriteLine("Anchoring type: " + effectiveTextFrameFormat.AnchoringType);
Console.WriteLine("Autofit type: " + effectiveTextFrameFormat.AutofitType);
Console.WriteLine("Text vertical type: " + effectiveTextFrameFormat.TextVerticalType);
Console.WriteLine("Margins");
Console.WriteLine(" Left: " + effectiveTextFrameFormat.MarginLeft);
Console.WriteLine(" Top: " + effectiveTextFrameFormat.MarginTop);
Console.WriteLine(" Right: " + effectiveTextFrameFormat.MarginRight);
Console.WriteLine(" Bottom: " + effectiveTextFrameFormat.MarginBottom);
}
Get Effective Properties of Text Style
Using Aspose.Slides for .NET, you can get effective properties of Text Style. For this purpose, the TextStyleEffectiveData class has been added in Aspose.Slides which contains effective text style properties.
The following code sample shows how to get effective text style properties.
using (Presentation pres = new Presentation("Presentation1.pptx"))
{
IAutoShape shape = pres.Slides[0].Shapes[0] as IAutoShape;
ITextStyleEffectiveData effectiveTextStyle = shape.TextFrame.TextFrameFormat.TextStyle.GetEffective();
for (int i = 0; i <= 8; i++)
{
IParagraphFormatEffectiveData effectiveStyleLevel = effectiveTextStyle.GetLevel(i);
Console.WriteLine("= Effective paragraph formatting for style level #" + i + " =");
Console.WriteLine("Depth: " + effectiveStyleLevel.Depth);
Console.WriteLine("Indent: " + effectiveStyleLevel.Indent);
Console.WriteLine("Alignment: " + effectiveStyleLevel.Alignment);
Console.WriteLine("Font alignment: " + effectiveStyleLevel.FontAlignment);
}
}
Get Effective Font Height Value
Using Aspose.Slides for .NET, you can get effective properties of Font Height . Here is the code demonstrating the portion’s effective font height value changing after setting local font height values on different presentation structure levels.
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);
pres.Save("SetLocalFontHeightValues.pptx",SaveFormat.Pptx);
}
Get Effective Fill Format for Table
Using Aspose.Slides for .NET, you can get effective fill formatting for different table logic parts. For this purpose, the IFillFormatEffectiveData interface has been added in Aspose.Slides which contains effective fill formatting properties. Please note that cell formatting always has higher priority than row formatting, a row has higher priority than column and column higher that whole table.
So finally CellFormatEffectiveData properties always used to draw the table. The following code sample shows how to get effective fill formatting for different table logic parts.
using (Presentation pres = new Presentation("pres.pptx"))
{
ITable tbl = pres.Slides[0].Shapes[0] as ITable;
ITableFormatEffectiveData tableFormatEffective = tbl.TableFormat.GetEffective();
IRowFormatEffectiveData rowFormatEffective = tbl.Rows[0].RowFormat.GetEffective();
IColumnFormatEffectiveData columnFormatEffective = tbl.Columns[0].ColumnFormat.GetEffective();
ICellFormatEffectiveData cellFormatEffective = tbl[0, 0].CellFormat.GetEffective();
IFillFormatEffectiveData tableFillFormatEffective = tableFormatEffective.FillFormat;
IFillFormatEffectiveData rowFillFormatEffective = rowFormatEffective.FillFormat;
IFillFormatEffectiveData columnFillFormatEffective = columnFormatEffective.FillFormat;
IFillFormatEffectiveData cellFillFormatEffective = cellFormatEffective.FillFormat;
}