示例#1
0
        /// <summary>
        /// <inheritdoc cref="IPlaceholderService.TryGet"/>
        /// </summary>
        public PlaceholderLocationData TryGet(OpenXmlCompositeElement sdkElement)
        {
            if (!sdkElement.IsPlaceholder())
            {
                return(null);
            }

            var phXml = PlaceholderDataFrom(sdkElement);

            if (phXml.PlaceholderType == PlaceholderType.Custom)
            {
                return(_phLocations.FirstOrDefault(p => p.Index == phXml.Index));
            }

            return(_phLocations.FirstOrDefault(p => p.PlaceholderType == phXml.PlaceholderType));
        }
示例#2
0
        public PlaceholderLocationData TryGet(OpenXmlCompositeElement sdkCompositeElement)
        {
            Check.NotNull(sdkCompositeElement, nameof(sdkCompositeElement));

            if (!sdkCompositeElement.IsPlaceholder())
            {
                return(null);
            }

            var placeholderData = CreatePlaceholderData(sdkCompositeElement);
            var result          = _phLocations.FirstOrDefault(p => p.Equals(placeholderData));

            if (result == null && placeholderData.Index != null)
            {
                var idx = placeholderData.Index;
                return(_phLocations.FirstOrDefault(p => p.PlaceholderType == PlaceholderType.Body && p.Index == idx));
            }

            return(result);
        }