示例#1
0
 private void PackageChangeEvent(FeatureEventArgs <OpenXmlPackage> obj)
 {
     if (obj.Type == EventType.Closing)
     {
         if (_shared.Remove(_collection))
         {
             _shared.Add(new ParagraphIdCollectionFeature(_collection));
         }
     }
 }
示例#2
0
        /// <summary>
        /// Registers a document to use a shared paragragraph collection, which potentially may ensure uniqueness among many documents.
        /// </summary>
        /// <param name="shared">Shared collection feature.</param>
        /// <param name="doc">Document to register with shared paragraph collection.</param>
        /// <returns></returns>
        public static ISharedFeature <IParagraphIdCollectionFeature> Add(this ISharedFeature <IParagraphIdCollectionFeature> shared, WordprocessingDocument doc)
        {
            doc.AddPackageEventsFeature();
            doc.AddParagraphIdFeature();

            var paragraphIdCollection = doc.Features.GetRequired <IParagraphIdCollectionFeature>();

            shared.Add(paragraphIdCollection);
            doc.Features.SetDisposable(new ParagraphIdSnapshotGenerator(paragraphIdCollection, shared, doc.Features.GetRequired <IPackageEventsFeature>()));
            doc.Features.Set(shared);
            doc.Features.Set(shared.Composite);

            return(shared);
        }
示例#3
0
 /// <summary>
 /// Add arbitrary values to be tracked as a shared collection.
 /// </summary>
 /// <param name="shared">Shared collection feature.</param>
 /// <param name="paragraphIds">Paragraph ids to be included with the shared collection.</param>
 /// <returns></returns>
 public static ISharedFeature <IParagraphIdCollectionFeature> Add(this ISharedFeature <IParagraphIdCollectionFeature> shared, IEnumerable <string> paragraphIds)
 {
     shared.Add(new ParagraphIdCollectionFeature(paragraphIds));
     return(shared);
 }