Free Support Forum - aspose.com

CustomDataParts are lost after Cloning a Slide

When Cloning a Slide from one Presentation to another all its CustomDateParts are removed from the shapes inside the cloned Slide.
So its not an exact copy of the original.

I have done the cloning with

var slideClone = pres.Slides.AddClone(slide);

Is there a not so brute force way to get all my CustomData from one presentation to the other?
And is this a known bug?

@jvoigtsolyp,

I have observed the issue shared by you and suggest you to please try using Aspose.Slides for .NET 18.6 on your end first. If there is still an issue then please share the working sample project along with source presentation, generated presentation and snapshot highlighting the issue. We will investigate that further on our end to help you.

Ok I was actually using :NET 18.6

I threw together a quick and dirty sample where you can “see” the problem
sample.zip (152.1 KB)(SampleSolution, input and output Presentations)

The important part of my sample:

Console.WriteLine("Custom Data from Original");
                    foreach (var shape in slide.Shapes)
                    {
                        foreach (var cData in shape.CustomData.CustomXmlParts)
                        {
                            Console.WriteLine(cData.XmlAsString);
                        }
                    }
                    var slideClone = outPres.Slides.AddClone(slide);



                    // do something with the Clone based on CustomData inside of its shapes
                    Console.WriteLine("Custom Data from Clone");
                    foreach (var shape in slideClone.Shapes)
                    {
                        foreach (var cData in shape.CustomData.CustomXmlParts)
                        {
                            Console.WriteLine(cData.XmlAsString);
                        }
                    }

based on this snippet I would expect the output of both Blocks to be the same

for now I have brute force cloned all CustomData from the Shapes and Slides so I can work again on my actuall problem

@jvoigtsolyp,

I have worked with sample project shared by you. For further investigation can you please share desired result in form of presentation and comparison screenshot of source file and generated result.

hi there,

ok I’ll try to explain what want to do.
I have a System to create Presenations form Templates and Data.

My Input Presentation has its purpose as a template:
Input.zip (38.0 KB)

In one of the Shapes I have inside the CustomDataPart definition how to repeat the Object.
depending on the Data one slide from the Template.

<ShapeQuery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Query>for ${numbers}</Query>
</ShapeQuery>

Information about moving a new clone for each Iteration is still missing.

A template can be used for more than one slide in the Solution, thats the reason why I need a clone of the Slide
From one or more InputPresenations I can create one output presentaion which can but does not have to contain a processed version of one of the input slides.

My Point is: when I clone a Slide With PresentationSlides.AddClone(slide) all its CustomDataParts are gone

Output: Solution.zip (41.1 KB)
this is an actuall output of my current working state. The Repeated Objects are moved one its height below itself for faciness.

Input (24.2 KB)
Result (24.0 KB)

How you can see in the third slide are data present for iterating the Shape with the $this data-directive inside it has backed data for repeating it, in the first two slides its missing because there is no data for it.

BUT:
the whole point of this topic was and is still that a Clone of a Slide in another Presentation is missing all the CustomDataParts and I believe its not the right behaviour because its altering the data inside the slide although it’s called ‘AddClone’ and I simply want to know if this is a known bug and if there are elegant solutions to or if I have to use my brute force copy until it’s fixed

@jvoigtsolyp,

I have observed the requirements shared by you and have not been able to completely understand your following points.

How, we can reproduce this and may verify this. Please also observe this attached image for reference as well that shows both source and cloned slides.

Can you please provide elaboration for the above as well. I request you to please provide a working sample project along with source presentation, generated presentation and desired output presentation that you want to generate using Aspose.Slides. I will be able to investigate the issue further on provision of requested information.

Ok I guess we need a bit of a step backwards.
My last answer was about what I want to do with Aspose and where the problem was.

The Error is fully reproducable with this sample

Inside the DemoTemplate.pptx is an Folder “customXml” where the CustomXmlParts are stored these Parts are referenced in the SlidePart

when I clone the slide (see: var slideClone = outPres.Slides.AddClone(slide);)
All the CustomXmlParts are not cloned with it.

My Issue is that the term “AddClone” has the meaning of creating an exact copy of the original. This includes copies of every reference so the two slides are equal.

In my above mentioned sample is also an output.pptx which is created by the contained project by simply cloning the slide.

how you can observed by the missing console output the CustomDataParts are not copied.
You can also see this in the output.pptx the “customXml” folder is but the reference to the customXml inside the picture is still there and the file is still mention in the slide relationships file.

To see yourself what I mean unpack the pptx files and look for the missing parts.
The ISlideCollection.AddClone Method is not working correctly.

Below a Full Sample where you can see and observe the Error I have in all its glory :neutral_face:
There is no need for a more complex sample it only distracts from the Problem.
I commented the important parts

using System;
using System.IO;
using System.Linq;
using Aspose.Slides;

namespace ErrorSample
{
    class Program
    {
        public static void Main()
        {
            // set your license Pathhere
            var licensePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Aspose.Total.lic");
            var license = new License();
            using (var file = new FileStream(licensePath, FileMode.Open))
            {
                license.SetLicense(file);
            }

            using (var inPres = new Presentation())
            using (var outPres = new Presentation())
            {
                var shape = inPres.Slides[0].Shapes.AddAutoShape(ShapeType.CircularArrow, 1, 1, 1, 1);
                shape.CustomData.CustomXmlParts.Add("<A></A>");

                // should obviously be 1
                var inCount = shape.CustomData.CustomXmlParts.Count;
                Console.WriteLine(inCount);

                outPres.Slides.RemoveAt(0);
                outPres.Slides.AddClone(inPres.Slides[0]); // this is where the magic happens, or fails to happen in your case

                var outCount = outPres.Slides.Last().CustomData.CustomXmlParts.Count;
                // this should also be 1
                Console.WriteLine(outCount);

                // this should be true
                Console.WriteLine(outCount == inCount);
            }
        }
    }
}

@jvoigtsolyp,

I have observed your comments. An issue with ID SLIDESNET-40397 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be fixed.

The issues you have found earlier (filed as SLIDESNET-40397) have been fixed in this update.