Ejemplo n.º 1
0
        private GeometryType ForCompositeElement(OpenXmlCompositeElement sdkCompositeElement, P.ShapeProperties spPr)
        {
            var t2D = spPr.Transform2D;

            if (t2D != null)
            {
                var presetGeometry = spPr.GetFirstChild <PresetGeometry>();
                // Placeholder can have transform on the slide, without having geometry
                if (presetGeometry == null)
                {
                    if (spPr.OfType <CustomGeometry>().Any())
                    {
                        return(GeometryType.Custom);
                    }
                    return(FromLayout());
                }

                var name = presetGeometry.Preset.Value.ToString();
                Enum.TryParse(name, true, out GeometryType geometryType);
                return(geometryType);
            }

            return(FromLayout());

            GeometryType FromLayout()
            {
                var placeholderLocationData = _phService.TryGetLocation(sdkCompositeElement);

                if (placeholderLocationData == null)
                {
                    return(GeometryType.Rectangle);
                }
                return(placeholderLocationData.Geometry);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets
        /// </summary>
        /// <param name="sdkCompositeElement"></param>
        /// <returns></returns>
        public ILocation FromComposite(OpenXmlCompositeElement sdkCompositeElement)
        {
            Check.NotNull(sdkCompositeElement, nameof(sdkCompositeElement));

            ILocation innerTransform;
            var       aTransform = sdkCompositeElement.Descendants <A.Transform2D>().FirstOrDefault();

            if (aTransform != null ||
                sdkCompositeElement.Descendants <P.Transform>().FirstOrDefault() != null)   // p:graphicFrame contains p:xfrm
            {
                // Group
                if (sdkCompositeElement.Parent is P.GroupShape groupShape)
                {
                    innerTransform = new NonPlaceholderGroupedTransform(sdkCompositeElement, groupShape);
                }
                // ShapeTree
                else
                {
                    innerTransform = new NonPlaceholderTransform(sdkCompositeElement);
                }
            }
            else
            {
                var placeholderLocationData = _phService.TryGetLocation(sdkCompositeElement);
                innerTransform = new PlaceholderTransform(placeholderLocationData);
            }

            return(innerTransform);
        }