We encountered an inconsistency while rendering OleObjects using Aspose.Slides for .NET v19.7 versus v19.8.
For our use case, we pass a byte array that we convert to an Aspose OleObjectFrame and another byte array that we convert to an image that serves as the SubstitutePicture for the OleObjectFrame.
However, when we pass these byte arrays to the abovementioned versions it looks like for 19.8 (and all versions after 19.8), when we double click on the OleObject (which in our cases in an active graph) it fails to get activated. In contrast to this, in 19.7 the graph activates just fine on double-click.
Attached Files.zip (496.7 KB) are the expected and generated images and ppt along with the .txt files which contain both byte arrays.
Request you to change the path in the reproducer according to the location of the files in your system.
Please let us know if we missed something obvious.
Reproducer Function:
static void ActiveGraph()
{
byte[] oleObject = File.ReadAllBytes("PATH_TO_OleObject.txt");
byte[] substituteImage = File.ReadAllBytes("PATH_TO_image.txt");
IPPImage imgx;
var presentation = new Presentation();
var slides = presentation.Slides[0];
var oleObjectFrame = slides.Slide.Shapes.AddOleObjectFrame(0, 0, 800, 600, "ole-object-class", oleObject);
using (var outStream = new MemoryStream(substituteImage))
{
imgx = presentation.Images.AddImage(outStream);
}
oleObjectFrame.SubstitutePictureFormat.Picture.Image = imgx;
presentation.Save("ActiveGraph.pptx", SaveFormat.Pptx);
}
After observing the example provided by you, I suggest you to please first try using latest Aspose.Slides for .NET 20.8 on your end. Secondly, in your case when you are adding OLE Object the Ole class is unknown. The class is important as this is related to what is inside OLE Object data. If the OIe data is an XLSX file the class would Excel.Sheet.12. If you provide the wrong class identifier as compare to what is inside OLE data the OLE object will not get activated once clicked.
Please try the latest version and share the feedback with us if there is still an issue so that we may investigate it further.
Firstly, I did try the reproducer for v20.8 and it still won’t open, exactly how its behaving in 19.8.
Please check this image for your reference. Generated_20-8.PNG (67.8 KB)
Secondly, I understand your point about the class name being specific to the data contained by the Ole Object, however, for v19.7 using the above-mentioned class name (“ole-object-class”) I got the expected output, and the graph is activated correctly. Post 19.8 I am not getting the correct output. Any reason why that could be the case?
I have created an issue with ID SLIDESNET-42152 as investigation to further investigate this based on your assessment that whether if behavior exhibited in Aspose.Slides 19.7 was wrong or its an issue in Aspose.Slides for .NET 19.8 on wards to 20.8.
The concerned issue has been marked as resolved in upcoming Aspose.Slides for .NET 20.10. We will share the notification with you as soon as the issue will be fixed.
However, I checked the latest version using the same reproducer as above and the issue still persists.
I am not sure if we are missing something in the implementation.
Also, it looks like IShapeCollection.AddOleObjectFrame(float, float, float, float, string, byte[]) is obsolete and instead we are to use method AddOleObjectFrame(float x, float y, float width, float height, IOleEmbeddedDataInfo dataInfo).
I created a reproducer for the same and it shows this image.png
Please let us know if we are missing something.
Reproducer
static void ActiveGraph()
{
byte[] oleObject = File.ReadAllBytes("PATH_TO_OleObject.txt");
byte[] substituteImage = File.ReadAllBytes("PATH_TO_image.txt");
IPPImage imgx;
var presentation = new Presentation();
var slides = presentation.Slides[0];
var oleDataInfo = new OleEmbeddedDataInfo(oleObject, "");
var oleObjectFrame = slides.Slide.Shapes.AddOleObjectFrame(0, 0, 800, 600, oleDataInfo);
using (var outStream = new MemoryStream(substituteImage))
{
imgx = presentation.Images.AddImage(outStream);
}
oleObjectFrame.SubstitutePictureFormat.Picture.Image = imgx;
presentation.Save("ActiveGraph.pptx", SaveFormat.Pptx);
}
While working with OLE objects in Aspose.Slides has undergone a number of significant changes that improve the quality of working with them. As you may have noticed, the method you used to create an Ole object in the provided example has been deprecated.
You should use OleEmbeddedDataInfo object instead of а data array oleObject to create an Ole objects:
Hi,
Thanks for the update.
I have extracted all the objects from the ppt image.png (15.1 KB).
It looks like the extension of the embedded object is bin. image.png (3.7 KB)
So I pass bin as an embeddedFileExtension parameter and it still shows this error, in 20.10. image.png (8.6 KB)
As you pointed out, I am using the OleEmbedded DataInfo (oleDataInfo)
In following line you have used “bin” as extension where as you are adding txt file. It should be same extension as that of actual file you are providing.
We are not exactly trying to embed a text file. We are trying to read the contents from a text file, and converting that to a byte array. (This text file has got all the information about the object that we are trying to embed and the object, as shown here (3.7 KB) is a bin type file. ) This byte array is then converted to OleEmbeddedDataInfo which is then passed to AddOleObjectFrame.
If you see the first reproducer in the thread, it does exactly that. It uses the txt array to read the bytes, and then passes this byte array to the older version of AddOleObjectFrame and works okay for 19.7 and lower versions.
With the new version, we just have to convert the byte array to OleEmbeddedDataInfo and then pass to the new function. So we are doing that I guess. The extension that we pass has to be the extension for the embedded object which in our case is a bin file.