Beispiel #1
0
 public static A.Outline GetOutline(this DocumentFormat.OpenXml.Presentation.Shape shape)
 {
     A.Outline outline = shape.ShapeProperties.FirstElement <A.Outline>();
     if (outline != null)
     {
         return(outline.CloneNode(true) as A.Outline);
     }
     return(null);
 }
Beispiel #2
0
 public static A.SolidFill GetFill(this DocumentFormat.OpenXml.Presentation.Shape shape)
 {
     A.SolidFill fill = shape.ShapeProperties.FirstElement <A.SolidFill>();
     if (fill != null)
     {
         return(fill.CloneNode(true) as A.SolidFill);
     }
     return(null);
 }
Beispiel #3
0
        public static TextCharacterPropertiesType GetRunProperties(this DocumentFormat.OpenXml.Presentation.Shape shape)
        {
            Paragraph paragraph = shape.TextBody.FirstElement <Paragraph>();

            if (paragraph != null)
            {
                Run run = paragraph.FirstElement <Run>();
                if (run != null)
                {
                    return(run.RunProperties.CloneNode(true) as RunProperties);
                }
                EndParagraphRunProperties endProp = paragraph.FirstElement <EndParagraphRunProperties>();
                return(endProp.CloneNode(true) as EndParagraphRunProperties);
            }
            return(null);
        }
Beispiel #4
0
 /// <summary>
 /// Replaces the content of the shape.
 /// </summary>
 /// <param name="shape">The shape.</param>
 /// <param name="newValue">The new value.</param>
 /// <param name="fill">The fill.</param>
 public static void Replace(this DocumentFormat.OpenXml.Presentation.Shape shape, string newValue, SolidFill fill = null)
 {
     if (shape.InnerText.Contains("##"))
     {
         foreach (Paragraph paragraph in shape.TextBody.Elements <Paragraph>())
         {
             paragraph.Replace("##", newValue, fill);
         }
     }
     else
     {
         if (shape.TextBody.Elements <Paragraph>().Any())
         {
             shape.TextBody.Elements <Paragraph>().First().Replace(newValue, fill);
         }
     }
 }
Beispiel #5
0
        // Determines whether the shape is a title shape.
        private static bool IsTitleShape(DocumentFormat.OpenXml.Presentation.Shape shape)
        {
            var placeholderShape = shape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.GetFirstChild <DocumentFormat.OpenXml.Presentation.PlaceholderShape>();

            if (placeholderShape != null && placeholderShape.Type != null && placeholderShape.Type.HasValue)
            {
                switch ((DocumentFormat.OpenXml.Presentation.PlaceholderValues)placeholderShape.Type)
                {
                // Any title shape.
                case DocumentFormat.OpenXml.Presentation.PlaceholderValues.Title:

                // A centered title.
                case DocumentFormat.OpenXml.Presentation.PlaceholderValues.CenteredTitle:
                    return(true);

                default:
                    return(false);
                }
            }
            return(false);
        }
Beispiel #6
0
 /// <summary>
 /// Gets the element name
 /// </summary>
 /// <param name="shape">The shape.</param>
 /// <returns>The name</returns>
 public static string ElementName(this DocumentFormat.OpenXml.Presentation.Shape shape)
 {
     return(shape.NonVisualShapeProperties.NonVisualDrawingProperties.Name.Value);
 }