Exemplo n.º 1
0
        /// <summary>
        /// Gets placeholder data from SDK-element.
        /// </summary>
        /// <param name="sdkElement">Placeholder which is placeholder.</param>
        public static PlaceholderData CreatePlaceholderData(OpenXmlElement sdkElement)
        {
            Check.NotNull(sdkElement, nameof(sdkElement));

            var result    = new PlaceholderData();
            var ph        = sdkElement.Descendants <P.PlaceholderShape>().First();
            var phTypeXml = ph.Type;

            // TYPE
            if (phTypeXml == null)
            {
                result.PlaceholderType = PlaceholderType.Custom;
            }
            else
            {
                // Simple title and centered title placeholders were united
                if (phTypeXml == P.PlaceholderValues.Title || phTypeXml == P.PlaceholderValues.CenteredTitle)
                {
                    result.PlaceholderType = PlaceholderType.Title;
                }
                else
                {
                    result.PlaceholderType = Enum.Parse <PlaceholderType>(phTypeXml.Value.ToString());
                }
            }

            // INDEX
            if (ph.Index != null)
            {
                result.Index = (int)ph.Index.Value;
            }

            return(result);
        }
        /// <summary>
        /// Creates a new <see cref="PlaceholderLocationData"/> instance from <see cref="PlaceholderData"/>.
        /// </summary>
        public PlaceholderLocationData(PlaceholderData phData)
        {
            Check.NotNull(phData, nameof(phData));

            PlaceholderType = phData.PlaceholderType;
            Index           = phData.Index;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets placeholder data from SDK-element.
        /// </summary>
        /// <param name="sdkElement">Placeholder which is placeholder.</param>
        public PlaceholderData CreatePlaceholderData(OpenXmlElement sdkElement)
        {
            Check.NotNull(sdkElement, nameof(sdkElement));

            var result = new PlaceholderData();
            var ph     = sdkElement.Descendants <P.PlaceholderShape>().First();

            // TYPE
            result.PlaceholderType = GetPlaceholderType(ph);

            // INDEX
            if (ph.Index != null)
            {
                result.Index = (int)ph.Index.Value;
            }

            return(result);
        }