I have to convert smart-art to textual view same as "convert To Text" ribbon's work highlight in image (http://i.stack.imgur.com/1UdgY.png). Till now i am able to extract text from smart-art and write it to a shape. but i found below issues.
- unable to make indentation of texts
After deleting the smart-art shape it add a blank shape to the slide.
below is the code what I have
private void ChangeSmartartToText(ref PresentationEXT textDeck, string deckType)
{
PPT.Slide slide = textDeck.destinationPresentation.Slides[textDeck.currentSlideNumber+1];
PPT.Shape tempSmartShape = null;
foreach (Microsoft.Office.Interop.PowerPoint.Shape shape in slide.Shapes)
{
if (shape.HasSmartArt == MsoTriState.msoTrue)
{
tempSmartShape = shape;
break;
}
}
PPT.Shape newTextShape = null;
if (tempSmartShape != null)
{
var smartartTop = tempSmartShape.Top;
var smartartLeft = tempSmartShape.Left;
var smartartHeight = tempSmartShape.Height;
var smartartWidth = tempSmartShape.Width;
newTextShape = slide.Shapes.AddShape(MsoAutoShapeType.msoShapeRectangle, smartartLeft, smartartTop, smartartWidth, smartartHeight);
var val1 = tempSmartShape.SmartArt;
string name = val1.Layout.Name;
string category = val1.Layout.Category;
StringBuilder smartartText = new StringBuilder();
foreach (SmartArtNode node in val1.AllNodes)
{
smartartText.AppendLine(node.TextFrame2.TextRange.Text);
}
Microsoft.Office.Interop.PowerPoint.TextRange objText;
objText = newTextShape.TextFrame.TextRange;
newTextShape.TextFrame.Orientation = MsoTextOrientation.msoTextOrientationHorizontal;
objText.Text = smartartText.ToString();
tempSmartShape.Delete();
tempSmartShape = null;
}
}
from the above code I got the out put(shown in imagehttp://i.stack.imgur.com/ra1Hl.png) and also show what i need