API publique et modifications incompatibles rétroactives dans Aspose.Slides pour .NET 14.9.0
Modifications de l’API publique
Héritage des interfaces ICollection et IEnumerable génériques ajouté à ISmartArtNodeCollection
La classe Aspose.Slides.SmartArt.SmartArtNodeCollection (et l’interface associée Aspose.Slides.SmartArt.ISmartArtNodeCollection) héritent de l’interface générique IEnumerable
Valeur d’énumération SmartArtLayoutType.Custom ajoutée
Le type de mise en page SmartArt personnalisé représente un diagramme avec un modèle personnalisé. Les diagrammes personnalisés ne peuvent être chargés qu’à partir d’un fichier de présentation et ne peuvent pas être créés via la méthode ShapeCollection.AddSmartArt(x, y, width, height, SmartArtLayoutType.Custom).
Classe SmartArtShape et interface ISmartArtShape ajoutées
La classe Aspose.Slides.SmartArt.SmartArtShape (et son interface Aspose.Slides.SmartArt.ISmartArtShape) donnent accès aux formes individuelles d’un diagramme SmartArt. SmartArtShape peut être utilisé pour modifier FillFormat, LineFormat, ajouter des hyperliens et d’autres tâches.
Note : SmartArtShape ne prend pas en charge les propriétés IShape RawFrame, Frame, Rotation, X, Y, Width, Height et lève une System.NotSupportedException lorsqu’on tente d’y accéder.
Exemple d’utilisation :
using (Presentation pres = new Presentation())
{
ISmartArt smart = pres.Slides[0].Shapes.AddSmartArt(10, 10, 400, 300, SmartArtLayoutType.BasicBlockList);
ISmartArtNode node = smart.AllNodes[0];
foreach (SmartArtShape shape in node.Shapes)
{
<span class="n">shape</span><span class="p">.</span><span class="n">FillFormat</span><span class="p">.</span><span class="n">FillType</span> <span class="p">=</span> <span class="n">FillType</span><span class="p">.</span><span class="n">Solid</span><span class="p">;</span>
<span class="n">shape</span><span class="p">.</span><span class="n">FillFormat</span><span class="p">.</span><span class="n">SolidFillColor</span><span class="p">.</span><span class="n">Color</span> <span class="p">=</span> <span class="n">Color</span><span class="p">.</span><span class="n">Red</span><span class="p">;</span>
}
pres.Save("out.pptx", Export.SaveFormat.Pptx);
}
Classe SmartArtShapeCollection, interface ISmartArtShapeCollection et propriété ISmartArtNode.Shapes ajoutées
La classe Aspose.Slides.SmartArt.SmartArtShapeCollection (et son interface Aspose.Slides.SmartArt.ISmartArtShapeCollection) donnent accès aux formes individuelles d’un diagramme SmartArt. La collection contient les formes associées à SmartArtNode. La propriété SmartArtNode.Shapes renvoie les collections de toutes les formes associées au nœud.
Note : selon le SmartArtLayoutType, une SmartArtShape peut être partagée entre plusieurs nœuds.
using (Presentation pres = new Presentation())
{
ISmartArt smart = pres.Slides[0].Shapes.AddSmartArt(10, 10, 400, 300, SmartArtLayoutType.BasicBlockList);
ISmartArtNode node = smart.AllNodes[0];
foreach (SmartArtShape shape in node.Shapes)
{
<span class="n">shape</span><span class="p">.</span><span class="n">FillFormat</span><span class="p">.</span><span class="n">FillType</span> <span class="p">=</span> <span class="n">FillType</span><span class="p">.</span><span class="n">Solid</span><span class="p">;</span>
<span class="n">shape</span><span class="p">.</span><span class="n">FillFormat</span><span class="p">.</span><span class="n">SolidFillColor</span><span class="p">.</span><span class="n">Color</span> <span class="p">=</span> <span class="n">Color</span><span class="p">.</span><span class="n">Red</span><span class="p">;</span>
}
pres.Save("out.pptx", Export.SaveFormat.Pptx);
}
Méthodes pour enregistrer les diapositives en conservant les numéros de pages ajoutées
Les méthodes suivantes ont été ajoutées :
- void IPresentation.Save(string fname, int[] slides, SaveFormat format);
- void IPresentation.Save(string fname, int[] slides, SaveFormat format, ISaveOption options);
- void IPresentation.Save(Stream stream, int[] slides, SaveFormat format);
- void IPresentation.Save(Stream stream, int[] slides, SaveFormat format, ISaveOption options);
Ces méthodes permettent aux développeurs d’enregistrer des diapositives de présentation spécifiques aux formats PDF, XPS, TIFF, HTML. Le tableau ‘slides’ est utilisé pour spécifier les numéros de pages, à partir de 1. Save(string fname, int[] slides, SaveFormat format);
Presentation presentation = new Presentation(presentationFileName);
int[] slides = new int[] { 2, 3, 5 }; //Array of slides positions
presentation.Save(outFileName, slides, SaveFormat.Pdf);
Méthodes de remplacement d’images ajoutées à PPImage, IPPImage
Nouvelles méthodes ajoutées :
- IPPImage.ReplaceImage(byte[] newImageData)
- IPPImage.ReplaceImage(Image newImage)
- IPPImage.ReplaceImage(IPPImage newImage)
Presentation presentation = new Presentation(presentation.pptx);
//First method
byte[] data = File.ReadAllBytes(image0.jpeg);
IPPImage oldImage = presentation.Images[0];
oldImage.ReplaceImage(data);
//Second method
Image newImage = Image.FromFile(image1.png);
oldImage = presentation.Images[1];
oldImage.ReplaceImage(newImage);
//Third method
oldImage = presentation.Images[2];
oldImage.ReplaceImage(presentation.Images[3]);
presentation.Save(presentation_out.pptx, SaveFormat.Pptx);