I have 2 shapeIds lists from two separate PowerPoint presentations, one from the original PowerPoint and the other from the edited PowerPoint.
Now I want to compare the elements in these two ShapeId lists with each other. For example, I want to compare font color and size, etc.
I tried several ways to do this and decided that the best way is to iterate over each ShapeId into 2 lists. Anyway, can I iterate over each list within the same foreach loop? For instance,foreach (Microsoft.Office.Interop.PowerPoint.Slide slide item1 in list1, Microsoft.Office.Interop.PowerPoint.Slide slide item2 in list2)
My code is like vapor
Microsoft.Office.Interop.PowerPoint.CustomLayout customLayout = pptPresentationOriginal.SlideMaster.CustomLayouts[Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutText];
Microsoft.Office.Interop.PowerPoint.Slides Originalslides;
Microsoft.Office.Interop.PowerPoint.Slides EditedSlides;
Microsoft.Office.Interop.PowerPoint.Shape originalShp;
Microsoft.Office.Interop.PowerPoint.Shape editShp;
Originalslides = pptPresentationOriginal.Slides;
EditedSlides = pptPresentationEdit.Slides;
List<char> l = new List<char>();
List<char> l2 = new List<char>();
List<int> originalShapesListID = new List<int>();
List<int> editedShapesListID = new List<int>();
List<int> originalListID = new List<int>();
List<int> editedListID = new List<int>();
List<Microsoft.Office.Interop.PowerPoint.Shape> originalList = new List<Microsoft.Office.Interop.PowerPoint.Shape>();
List<Microsoft.Office.Interop.PowerPoint.Shape> editList = new List<Microsoft.Office.Interop.PowerPoint.Shape>();
Microsoft.Office.Interop.PowerPoint.Shape editedShpID;
Logics
String pps = "";
foreach (Microsoft.Office.Interop.PowerPoint.Slide slide in Originalslides)
{
foreach (Microsoft.Office.Interop.PowerPoint.Shape originalShape in slide.Shapes)
{
originalShp = originalShape;
if (originalShape.HasTextFrame == Microsoft.Office.Core.MsoTriState.msoTrue)
{
var textFrame = originalShape.TextFrame;
if (textFrame.HasText == Microsoft.Office.Core.MsoTriState.msoTrue)
{
var textRange = textFrame.TextRange;
pps += originalShape.TextFrame.TextRange.Text;
foreach (char word in pps)
{
l.Add(word);
Debug.WriteLine(word);
}
}
}
originalShapesListID.Add(originalShape.Id);
originalShapeID = originalShape.Id;
originalList.Add(originalShape);
}
originalListID.Add(slide.SlideID);
}
foreach (Microsoft.Office.Interop.PowerPoint.Slide slide in EditedSlides)
{
foreach (Microsoft.Office.Interop.PowerPoint.Shape editShape in slide.Shapes)
{
editShp = editShape;
if (editShape.HasTextFrame == Microsoft.Office.Core.MsoTriState.msoTrue)
{
var textFrame = editShape.TextFrame;
if (textFrame.HasText == Microsoft.Office.Core.MsoTriState.msoTrue)
{
var textRange = textFrame.TextRange;
pps += editShape.TextFrame.TextRange.Text;
foreach (char word in pps)
{
l.Add(word);
Debug.WriteLine(word);
}
}
}
editedShapesListID.Add(editShape.Id);
editedShapeID = editShape.Id;
editList.Add(editShape);
}
editedListID.Add(slide.SlideID);
}
Here I want to go through 2 lists and compare each element (ShapeId) in each list. I want to do something like this.
foreach (Microsoft.Office.Interop.PowerPoint.Shape editShape in editedShapesListID, Microsoft.Office.Interop.PowerPoint.Shape original in originalShapesListID )
{
if (originalShapeID == editedShapeID)
{
if (original.TextFrame.TextRange.Font.Color.RGB != editShape.TextFrame.TextRange.Font.Color.RGB)
{
originalShp.TextFrame2.TextRange.Font.StrikeThrough.ToString();
}
}
}