/// <summary>
			/// Creates prototype from list content control and fieldNames.
			/// </summary>
			/// <param name="context">Process context.</param>
			/// <param name="listContentControl">List content control element.</param>
			/// <param name="fieldNames">Names of fields with content.</param>
			public Prototype(ProcessContext context, XElement listContentControl, IEnumerable<string> fieldNames)
			{
				_context = context;
				if (listContentControl.Name != W.sdt)
					throw new Exception("List content control is not a content control element");

				fieldNames = fieldNames.ToList();

				// All elements inside list control content are included to the prototype.
				var listItems = listContentControl
					.Element(W.sdtContent)
					.Elements()
					.ToList();

				var tagsInPrototype = listItems.DescendantsAndSelf(W.sdt)
					.Select(sdt => sdt.SdtTagName());

				// If any field not found return empty list.
				if (fieldNames.Any(fn => !tagsInPrototype.Contains(fn)))
				{
					IsValid = false;
					return;
				}

				IsValid = true;
				PrototypeItems = listItems;
			}
예제 #2
0
            public LevelPrototype(ProcessContext context, IEnumerable <XElement> prototypeItems, IEnumerable <string> fieldNames)
            {
                this._context = context;
                var currentLevelPrototype = new List <XElement>();

                // Items for which no content control.
                // Add this items to the prototype if there are items after them.
                var maybeNeedToAdd          = new List <XElement>();
                var numberingElementReached = false;

                foreach (var prototypeItem in prototypeItems)
                {
                    // search for first item with numbering
                    if (!numberingElementReached)
                    {
                        var paragraph = prototypeItem.DescendantsAndSelf(W.p).FirstOrDefault();
                        if (paragraph != null &&
                            ListItemRetriever.RetrieveListItem(
                                context.Document.NumberingPart, context.Document.StylesPart, paragraph)
                            .IsListItem)
                        {
                            numberingElementReached = true;
                        }
                        else
                        {
                            continue;
                        }
                    }

                    if ((!prototypeItem.FirstLevelDescendantsAndSelf(W.sdt).Any() && prototypeItem.Value != string.Empty) ||
                        prototypeItem
                        .FirstLevelDescendantsAndSelf(W.sdt)
                        .Any(sdt => fieldNames.Contains(sdt.SdtTagName())))
                    {
                        currentLevelPrototype.AddRange(maybeNeedToAdd);
                        currentLevelPrototype.Add(prototypeItem);
                    }

                    else
                    {
                        maybeNeedToAdd.Add(prototypeItem);
                    }
                }

                if (!currentLevelPrototype.Any())
                {
                    return;
                }

                this.PrototypeItems = currentLevelPrototype;

                if (fieldNames.Any(fn => !this.SdtTags.Contains(fn)))
                {
                    this.IsValid = false;
                    return;
                }

                this.IsValid        = true;
                this.PrototypeItems = currentLevelPrototype;
            }
            /// <summary>
            /// Creates prototype from list content control and fieldNames.
            /// </summary>
            /// <param name="context">Process context.</param>
            /// <param name="listContentControl">List content control element.</param>
            /// <param name="fieldNames">Names of fields with content.</param>
            public Prototype(ProcessContext context, XElement listContentControl, IEnumerable <string> fieldNames)
            {
                _context = context;
                if (listContentControl.Name != W.sdt)
                {
                    throw new Exception("List content control is not a content control element");
                }

                fieldNames = fieldNames.ToList();

                // All elements inside list control content are included to the prototype.
                var listItems = listContentControl
                                .Element(W.sdtContent)
                                .Elements()
                                .ToList();

                var tagsInPrototype = listItems.DescendantsAndSelf(W.sdt)
                                      .Select(sdt => sdt.SdtTagName());

                // If any field not found return empty list.
                if (fieldNames.Any(fn => !tagsInPrototype.Contains(fn)))
                {
                    IsValid = false;
                    return;
                }

                IsValid        = true;
                PrototypeItems = listItems;
            }
		internal ContentProcessor(ProcessContext context)
		{
			_processors = new List<IProcessor>
			{
				new FieldsProcessor(context),
				new TableProcessor(context),
				new ListProcessor(context)			
			};
		}
 internal ContentProcessor(ProcessContext context)
 {
     _processors = new List <IProcessor>
     {
         new FieldsProcessor(context),
         new TableProcessor(context),
         new ListProcessor(context)
     };
 }
예제 #6
0
 internal ContentProcessor(ProcessContext context)
 {
     this.processors = new List <IProcessor>
     {
         new FieldsProcessor(),
         new RepeatProcessor(context),
         new TableProcessor(context),
         new ListProcessor(context),
         new ImagesProcessor(context),
     };
 }
예제 #7
0
 internal ContentProcessor(ProcessContext context)
 {
     _processors = new List <IProcessor>
     {
         new FieldsProcessor(),
         new RepeatProcessor(context),
         new TableProcessor(context),
         new ListProcessor(context),
         new ImagesProcessor(context),
         new TableDeleteProcessor(),
         new FieldsDeleteProcessor()
     };
 }
예제 #8
0
 public RepeatProcessor(ProcessContext context)
 {
     this.context = context;
 }
 public ListProcessor(ProcessContext context)
 {
     _context = context;
 }
예제 #10
0
 public RepeatProcessor(ProcessContext context)
 {
     _context = context;
 }
예제 #11
0
 public TableProcessor(ProcessContext context)
 {
     this.context = context;
 }
예제 #12
0
 public ImagesProcessor(ProcessContext context)
 {
     _context = context;
 }
		public ImagesProcessor(ProcessContext context)
		{
			_context = context;
		}
		public TableProcessor(ProcessContext context)
		{
			_context = context;
		}
예제 #15
0
 private LevelPrototype(ProcessContext context, IEnumerable <XElement> prototypeItems)
 {
     this._context       = context;
     this.PrototypeItems = prototypeItems.ToList();
 }
		public FieldsProcessor(ProcessContext context)
		{
			_context = context;
		}
			/// <summary>
			/// Creates prototype from list of prototype items.
			/// </summary>
			/// <param name="context">Process context.</param>
			/// <param name="prototypeItems">List of prototype items.</param>
			private Prototype(ProcessContext context, IEnumerable<XElement> prototypeItems)
			{
				_context = context;
				PrototypeItems = prototypeItems.ToList();
			}
 public TableProcessor(ProcessContext context)
 {
     _context = context;
 }
 public FieldsProcessor(ProcessContext context)
 {
     _context = context;
 }
예제 #20
0
 public ListProcessor(ProcessContext context)
 {
     this.context = context;
 }
 /// <summary>
 /// Creates prototype from list of prototype items.
 /// </summary>
 /// <param name="context">Process context.</param>
 /// <param name="prototypeItems">List of prototype items.</param>
 private Prototype(ProcessContext context, IEnumerable <XElement> prototypeItems)
 {
     _context       = context;
     PrototypeItems = prototypeItems.ToList();
 }
			public LevelPrototype(ProcessContext context, IEnumerable<XElement> prototypeItems, IEnumerable<string> fieldNames)
			{
				_context = context;
				var currentLevelPrototype = new List<XElement>();

				// Items for which no content control.
				// Add this items to the prototype if there are items after them.
				var maybeNeedToAdd = new List<XElement>();
				var numberingElementReached = false;

				foreach (var prototypeItem in prototypeItems)
				{
					//search for first item with numbering
					if (!numberingElementReached)
					{
						var paragraph = prototypeItem.DescendantsAndSelf(W.p).FirstOrDefault();
						if (paragraph != null &&
							ListItemRetriever.RetrieveListItem(
							context.NumberingPart, context.StylesPart, paragraph)
							.IsListItem)
							numberingElementReached = true;
						else
							continue;
					}
					if ((!prototypeItem.FirstLevelDescendantsAndSelf(W.sdt).Any() && prototypeItem.Value != "") ||
						(prototypeItem
						.FirstLevelDescendantsAndSelf(W.sdt)
						.Any(sdt => fieldNames.Contains(sdt.SdtTagName()))))
					{
						currentLevelPrototype.AddRange(maybeNeedToAdd);
						currentLevelPrototype.Add(prototypeItem);
					}

					else
					{
						maybeNeedToAdd.Add(prototypeItem);
					}
				}
				if (!currentLevelPrototype.Any()) return;

				PrototypeItems = currentLevelPrototype;

				if (fieldNames.Any(fn => !SdtTags.Contains(fn)))
				{
					IsValid = false;
					return;
				}

				IsValid = true;
				PrototypeItems = currentLevelPrototype;

			}
		public ListProcessor(ProcessContext context)
		{
			_context = context;
		}
예제 #24
0
 public ImagesProcessor(ProcessContext context)
 {
     this.context = context;
 }