public XlsxMacrosheetXmlPartFilter(CommonNamespaces commonNamespaces, Dictionary<string, string> StringContentLookup, Dictionary<string, WorkSheet> WorksheetLookup, Dictionary<string, CellFormatData> CellFormats, ContentType[] contentTypesToDetect, ref XlsxProcessingDictionaries processingDictionaries, ref PredefinedObjectsProcessingHelper predefinedObjectsHelper, PartInfo rel)
     : base(commonNamespaces, rel.Target, StringContentLookup, WorksheetLookup, CellFormats, contentTypesToDetect, ref processingDictionaries, ref predefinedObjectsHelper)
 {
     m_id = rel.Id;
     m_target = rel.Target;
     m_type = rel.GetContentType();
 }
        internal override IPartFilter GetPartFilter(PartInfo rel, DocumentProcessingActions action)
        {
            switch (rel.GetContentType())
            {
                case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml":
				case "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml":
				case "application/vnd.ms-excel.sheet.macroEnabled.main+xml": 
				case "application/vnd.ms-excel.template.macroEnabled.main+xml":
					return ConstructMainSpreadSheetFilter(rel);
                
                case "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml":
                case "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml":
                case "application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml":
                    return ConstructWorksheetFilter(rel.Target, action);

                case "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml":
                    return ConstructCommentFilter();

                case "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml":
                    return ConstructSharedStringsFilter();
            
                case "application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml":
                    if (AreWeInterestedIn(ContentType.Links))
                        return GetPartFilterForExternalLinks(rel.Target, rel);
                    break;

                case "application/vnd.ms-office.vbaProject":
                    if (AreWeInterestedIn(ContentType.Macro))
                        return new VBABlockingPartFilter(rel);
                    break;
                case "application/vnd.ms-excel.intlmacrosheet+xml":
                case "application/vnd.ms-excel.macrosheet+xml":
                    return ConstructMacrosheetFilter(rel, action);

                case "application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml":
                    return ConstructCalcChainFilter();

                case "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionLog+xml":
                    if (AreWeInterestedIn(ContentType.TrackChange))
                    {
                        if (action != DocumentProcessingActions.Clean)
                            return ConstructRevisionFilter();

                        return new BlockingPartFilter();
                    }
                    break;
                case "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionHeaders+xml":
                case "application/vnd.openxmlformats-officedocument.spreadsheetml.userNames+xml":
                    if(AreWeInterestedIn(ContentType.TrackChange) && action == DocumentProcessingActions.Clean)
                        return new BlockingPartFilter();
                    break;
                case "application/vnd.openxmlformats-officedocument.drawing+xml":
                case "application/vnd.openxmlformats-officedocument.vmlDrawing":
                    return ConstructDrawingFilter();
            }
            return base.GetPartFilter(rel, action);
        }
Exemple #3
0
 public PartInfo(OPCPackage containingPackage, PartInfo templatePartInfo)
 {
     this.Id = templatePartInfo.Id;
     this.Type = templatePartInfo.Type;
     this.Target = templatePartInfo.Target;
     this.External = templatePartInfo.External;
     this.RelatedTo = templatePartInfo.RelatedTo;
     this.m_containingPackage = containingPackage;
     m_relationships = new Relationships();
 }
 protected override IPartFilter GetPartFilterForPreprocessing(PartInfo rel, DocumentProcessingActions actions)
 {
     switch (rel.GetContentType())
     {
         case "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml":
         case "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml":
         case "application/vnd.ms-word.document.macroEnabled.main+xml":
         case "application/vnd.ms-word.template.macroEnabledTemplate.main+xml":
             return ConstructMainDocFilter(true, ActionIncludesCleaning(actions));
     }
     return base.GetPartFilterForPreprocessing(rel, actions);
 }
        internal override IPartFilter GetPartFilter(PartInfo rel, DocumentProcessingActions actions)
        {
            switch (rel.GetContentType())
            {
                case "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml":
                case "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml":
                case "application/vnd.ms-word.document.macroEnabled.main+xml":
                case "application/vnd.ms-word.template.macroEnabledTemplate.main+xml":
                    return ConstructMainDocFilter(false, ActionIncludesCleaning(actions));

                case "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml":
                    return ConstructFootNoteFilter(ActionIncludesCleaning(actions));

                case "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml":
                    return ConstructEndNoteFilter(ActionIncludesCleaning(actions));

                case "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml":
                    return ConstructFooterFilter( ActionIncludesCleaning(actions) );

                case "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml":
                    return ConstructHeaderFilter( ActionIncludesCleaning(actions) );

                case "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml":
					return ConstructCommentFilter(ActionIncludesCleaning(actions));

                case "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml":
                    return ConstructSettingsFilter(rel);

                case "application/vnd.ms-word.vbaData+xml":
                    return ConstructVBADataFilter();

                case "application/vnd.ms-office.vbaProject":
                    if (AreWeInterestedIn(ContentType.Macro))
                        return new VBABlockingPartFilter(rel);
                    break;

                case "application/vnd.ms-word.keyMapCustomizations+xml":
                    if (AreWeInterestedIn(ContentType.Macro))
                        return new BlockingPartFilter(true);
                    break;
                case "application/inkml+xml":
                    return ConstructInkPartFilter(rel.Target, ActionIncludesCleaning(actions));
            }
            return base.GetPartFilter(rel, actions);
        }
Exemple #6
0
        public void AddContent(PartInfo rel, Stream sourceStream, OpenXmlFormat openXmlFormat)
        {
            PartInfo parentPart = GetPart(rel.RelatedTo);
            PartInfo clonedPart = new PartInfo(this, rel);
            string sContentType;
            if (ContentIsInternalType(rel.Type, openXmlFormat))
            {
                sContentType = rel.GetContentType();
                clonedPart.Target = RemoveLeadingSlash(clonedPart.Target);
                parentPart.AddRelatedItem(clonedPart);
                if (m_partsMap.ContainsKey(clonedPart.AbsolutePath()) && sourceStream == null)
                { // we have already added this content via a relationship elsewhere, don't need to write it
                    return;
                }
                m_partsMap.Add(clonedPart.AbsolutePath(), clonedPart);

                if (sourceStream != null)
                {
                    string partName = clonedPart.AbsolutePath();
                    AddZipEntry(partName, sourceStream);
                    if (rel.ContentTypeOverriden())
                        m_contentTypes.Add("/" + partName, sContentType);
                }
            }
            else
            {//we should only get here for external rels - so there should never be an additional stream to add
                parentPart.AddRelatedItem(clonedPart);
                sContentType = rel.Type;
                if (m_partsMap.ContainsKey(clonedPart.Target))
                { // we have already added this content via a relationship elsewhere, don't need to write it
                    return;
                }
                m_partsMap.Add(clonedPart.Target, clonedPart);
                if (sourceStream != null)
                {
                    throw new System.InvalidOperationException("Sourcestream is not null for supposedly external hyperlink part");
                }
            }
        }
        protected override IPartFilter GetPartFilterForPreprocessing(PartInfo rel, DocumentProcessingActions actions)
        {
            switch (rel.GetContentType())
            {
                case "application/vnd.openxmlformats-officedocument.presentationml.commentAuthors+xml":
                    return GetCommentAuthorPartFilter(true, false);

                case "application/vnd.openxmlformats-officedocument.presentationml.slide+xml":
                    return GetSlidePartFilter(rel, DocumentProcessingActions.Discover, false);

                case "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml":
                    if (ActionIncludesCleaning(actions) && AreWeInterestedIn(ContentType.Field))
                        return GetSlideLayoutPartFilter(rel.Target);
                    break;

                case "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml":
                    return GetSlideMasterPartFilter(rel.Target, ActionIncludesCleaning(actions));

                case "application/vnd.openxmlformats-officedocument.presentationml.handoutMaster+xml":
                    return GetHandoutsMasterPartFilter(rel.Target, ActionIncludesCleaning(actions));

                case "application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml":
                    return GetNotesMasterPartFilter(rel.Target, ActionIncludesCleaning(actions));

                case "application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml":
                case "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml":
                case "application/vnd.ms-powerpoint.template.macroEnabled.main+xml":
                case "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml":
                case "application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml":
                case "application/vnd.ms-powerpoint.slideshow.macroEnabled.main+xml":
                    return GetPresentationPartFilter();
            }
            return base.GetPartFilterForPreprocessing(rel, actions);
        }
        private void CollectPreProcessResultsForSlideLayoutPart(PartInfo rel, PptxSlideLayoutPartFilter pf)
        {
            if (pf == null || string.IsNullOrEmpty(rel.Target))
                return;

            m_dictSlideLayoutOLEObjectsInGraphicFrames.Add(rel.Target, pf.ListGraphicFrameHasOLEObject);
        }
        private void CollectPreProcessResultsForSlidePart(PartInfo rel, PptxSlidePartFilter pf)
        {
            if (pf != null && pf.SlideNumber != 0)
            {
                m_dictHiddenSlides.Add(pf.SlideNumber, pf.HiddenSlide);
                m_dictSlideTargets.Add(rel.Target, pf.SlideNumber);

                if (pf.SlideNumber > m_iMaxSlideNumber)
                    m_iMaxSlideNumber = pf.SlideNumber;

                m_dictSlideShapesWithPostItNoteComment.Add(pf.SlideNumber, pf.ListShapeWithPostItNoteComment);
                m_dictSlideOLEObjectsInGraphicFrames.Add(pf.SlideNumber, pf.ListGraphicFrameHasOLEObject);
            }
        }
        public static bool PartInfoContainsEmbeddedObjects(PartInfo pi, ref List<string> PartInfoTargets)
        {
            string sThisTarget = pi.Target;
            if(PartInfoTargets.Contains(sThisTarget))
                return false;

            PartInfoTargets.Add(sThisTarget);
            switch(pi.GetContentType())
            {
                case "application/vnd.openxmlformats-officedocument.oleObject":
                case "application/vnd.ms-office.activeX+xml":
                case "application/vnd.ms-office.activeX":
                case "application/msword":
                   return true;
            }

            foreach (PartInfo piChild in pi.GetRelatedObjects())
            {
                if (PartInfoContainsEmbeddedObjects(piChild, ref PartInfoTargets))
                        return true;
            }
            return false;
        }
 public XlsxExternalLinkPartFilter(CommonNamespaces commonNamespaces, string target, PartInfo rel)
     : base(commonNamespaces)
 {
     m_targetName = target;
     StoreRelatedPartsData(rel.GetRelatedObjects());
 }
        protected override void PreprocessPart(PartInfo rel, DocumentProcessingActions actions)
        {
            if (rel.External)
                return;

            if (m_listPreprocessedParts.Contains(rel.AbsolutePath()))
                return;
            if (IsASlidePartButNotInRelationToPresentation(rel))
                return;

            m_listPreprocessedParts.Add(rel.AbsolutePath());

            IPartFilter pf = GetPartFilterForPreprocessing(rel, actions);
            if (pf == null)
                return;

            PreprocessSpecialParts(rel, pf);

            foreach (PartInfo subRel in pf.SortRelatedParts(rel.GetRelatedObjects()))
            {
                PreprocessPart(subRel, actions);
            }
        }
        private IPartFilter GetViewPropsPartFilter(PartInfo rel)
        {
            PptxViewPropsPartFilter vppf = new PptxViewPropsPartFilter(m_commonNamespaces);

            foreach (PartInfo subRel in rel.GetRelatedObjects())
            {
                if (subRel.GetContentType() == "application/vnd.openxmlformats-officedocument.presentationml.slide+xml")
                {
                    bool bHidden = IsSlideHidden(subRel.Target);
                    vppf.AddRelatedSlideHiddenFlag(subRel.Id, bHidden);
                }
            }
            return vppf as IPartFilter;
        }
Exemple #14
0
        private void TryLoadRelationships(PartInfo forPart)
        {
            string sRelRoot = forPart.AbsolutePath();
            PartInfo rootPart;
            if (m_partsMap.TryGetValue(sRelRoot, out rootPart))
            {
                // already been here by some other path
                // However, need to add the related objects to forPart, which is a copy of the object in the map, because sorting in
                // the part filter may change the order in which we retrieve things from the relationship tree
                // Slides have circular relationships in the pptx files so watch that if we re-write this to use the mapped objets
                List<PartInfo> pliRels = rootPart.GetRelatedObjects();
                foreach (PartInfo rpi in pliRels)
                {
                    forPart.AddRelatedItem(rpi);
                }
                return;
            }

            m_partsMap[sRelRoot] = forPart;

            using (Stream str = GetPartContent(BuildRelationshipPartName(sRelRoot)))
            {
                if (str == null)
                    return;

                forPart.LoadRelationships(str);


                foreach (PartInfo part in forPart.GetRelatedObjects())
                {
                    if (!part.External)
                        TryLoadRelationships(part);
                }
            }
        }
Exemple #15
0
        private void Initialize()
        {
            m_rootPart = new PartInfo(this);
            m_rootPart.RelatedTo = "";
            m_rootPart.Target = "";

            if (!m_bForWriting)
            {
                m_zipFile = new ZipFile(m_stream);

                using (Stream strIndex = GetPartContent("[Content_Types].xml"))
                {
                    m_contentTypes = new PackageContentTypes(strIndex);
                }
                TryLoadRelationships(m_rootPart);
            }
            else
            {
                m_zipOutput = new ZipOutputStream(m_stream);
                m_zipOutput.UseZip64 = UseZip64.Off;
                m_contentTypes = new PackageContentTypes();
                m_partsMap.Add("", m_rootPart);
            }
        }
Exemple #16
0
        private void AddNewRelationship(XmlNode node, string relationshipRoot)
        {
            if (node.Name != "Relationship")
                return;

            PartInfo rel = new PartInfo(m_containingPackage);

            rel.Id = node.Attributes["Id"].Value;
            rel.Target = node.Attributes["Target"].Value;
            rel.Type = node.Attributes["Type"].Value;
            rel.RelatedTo = relationshipRoot;
            
            if (node.Attributes.GetNamedItem("TargetMode") != null)
            {
                rel.External = node.Attributes.GetNamedItem("TargetMode").Value == "External";
            }

            m_relationships.Add(rel);
        }
        public static List<TriggeringNodeDefinition> GetAttachedTemplateDef(PartInfo settingsPart, OpenXmlFormat openXmlFormat)
        {
            List<TriggeringNodeDefinition> results = new List<TriggeringNodeDefinition>();
            EffectDescriptor td = new EffectDescriptor();
            td.ContentType = ContentType.AttachedTemplate;
            td.BlockType = Effect.BlockType.Structure;

            td.DictStringToStringLookup = ConstructTemplateLookup(settingsPart, openXmlFormat);

            AdditionalInfoDescriptor adi = new AdditionalInfoDescriptor("Path", "id", AdditionalInfoDescriptor.MappingType.StringToStringLookup);
            adi.LookupNamespace = NamespaceId.r;
            adi.StringMangler = URLToPath;
            td.AddAdditionalInfoDescriptor(adi);
            adi = new AdditionalInfoDescriptor("Name", "id", AdditionalInfoDescriptor.MappingType.StringToStringLookup);
            adi.LookupNamespace = NamespaceId.r;
            adi.StringMangler = URLToFilename;
            td.AddAdditionalInfoDescriptor(adi);


            results.Add(new TriggeringNodeDefinition(NamespaceId.w, "attachedTemplate", null, null, td));

            return results;
        }
Exemple #18
0
 public void Add(PartInfo rel)
 {
     m_relationships.Add(rel);
 }
Exemple #19
0
 public void AddRelatedItem(PartInfo partInfo)
 {
     m_relationships.Add(partInfo);
 }
        internal override IPartFilter GetPartFilter(PartInfo rel, DocumentProcessingActions actions)
        {
            string sContentType = rel.GetContentType();
            switch (sContentType)
            {
                case "application/vnd.openxmlformats-officedocument.presentationml.slide+xml":
                    if (string.IsNullOrEmpty(rel.RelatedTo))
                        break;
                    if (rel.RelatedTo.ToLower().IndexOf("presentation") < 0)
                        break; // only want the presentation relationships no others
                    return GetSlidePartFilter(rel, actions, AreWeInterestedIn(ContentType.HiddenSlide));

                case "application/vnd.openxmlformats-officedocument.presentationml.commentAuthors+xml":
                    return GetCommentAuthorPartFilter(false, AreWeInterestedIn(ContentType.Comment));

                case "application/vnd.openxmlformats-officedocument.presentationml.comments+xml":
                    return GetCommentPartFilter();

                case "application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml":
                    return GetNotesSlidePartFilter(actions);

                case "application/vnd.openxmlformats-officedocument.oleObject":
                case "application/vnd.ms-office.activeX+xml":
                case "application/vnd.ms-office.activeX":
                case "application/msword":
                    if (ActionIncludesCleaning(actions) && AreWeInterestedIn(ContentType.Field))
                        return new BlockingPartFilter();
                    break;

                case "application/vnd.ms-office.vbaProject":
                    if (AreWeInterestedIn(ContentType.Macro))  // ActionIncludesCleaning(actions) intentionally omitted 
                        return new VBABlockingPartFilter(rel);
                    break;

                case "application/vnd.openxmlformats-officedocument.presentationml.viewProps+xml":
                    if (ActionIncludesCleaning(actions) && AreWeInterestedIn(ContentType.HiddenSlide))
                        return GetViewPropsPartFilter(rel);
                    break;

                case "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml":
                    if (ActionIncludesCleaning(actions) && AreWeInterestedIn(ContentType.Field))
                        return GetSlideLayoutPartFilter(rel.Target);
                    break;

                case "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml":
                    return GetSlideMasterPartFilter(rel.Target, ActionIncludesCleaning(actions));

                case "application/vnd.openxmlformats-officedocument.presentationml.handoutMaster+xml":
                    return GetHandoutsMasterPartFilter(rel.Target, ActionIncludesCleaning(actions));

                case "application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml":
                    return GetNotesMasterPartFilter(rel.Target, ActionIncludesCleaning(actions));

                case "application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml":
                case "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml":
                case "application/vnd.ms-powerpoint.template.macroEnabled.main+xml":
                case "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml":
                case "application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml":
                case "application/vnd.ms-powerpoint.slideshow.macroEnabled.main+xml":
                    return GetPresentationPartFilter();
                case "application/vnd.openxmlformats-officedocument.vmlDrawing":
                    return GetDrawingPartFilter(rel.Target);
                case "application/inkml+xml":
                    return GetInkPartFilter(rel.Target, ActionIncludesCleaning(actions));
            }
            return base.GetPartFilter(rel.GetContentType(), actions);
        }
        private IPartFilter GetSlidePartFilter(PartInfo rel, DocumentProcessingActions action, bool bBlockHiddenSlides)
        {
            int iSlideNumber = 0;
            if (m_ppf != null)
                iSlideNumber = m_ppf.GetSlidePositionFromRelId(rel.Id);

            PptxSlidePartFilter spf = new PptxSlidePartFilter(m_commonNamespaces, iSlideNumber);
            spf.Triggers.AddRange(PptxMetadataDefinitions.ParagraphText);

            if (AreWeInterestedIn(ContentType.Comment))
            {
                spf.Triggers.AddRange(PptxMetadataDefinitions.PostItNoteComment);
                spf.ListShapeWithPostItNoteComment = GetListOfSlideShapesWithPostItNoteComment(iSlideNumber);
            }

            if (AreWeInterestedIn(ContentType.TextBox))
                spf.Triggers.AddRange(PptxMetadataDefinitions.TextBoxes);

            if (AreWeInterestedIn(ContentType.HiddenSlide))
            {
                spf.Triggers.AddRange(PptxMetadataDefinitions.HiddenSlide(iSlideNumber));
                if (bBlockHiddenSlides &&
                    ActionIncludesCleaning(action) &&
                    IsSlideHidden(iSlideNumber))
                {
                    spf.BlockFilter = true;
                }
            }
            if (AreWeInterestedIn(ContentType.Hyperlink))
                spf.Triggers.AddRange(PptxMetadataDefinitions.Hyperlink);

            if (AreWeInterestedIn(ContentType.Field))
            {
                spf.Triggers.AddRange(PptxMetadataDefinitions.ActiveXControls);
                spf.Triggers.AddRange(PptxMetadataDefinitions.EmbeddedObjects);
                spf.ListGraphicFrameHasOLEObject = GetListOfSlideOLEObjectsInGraphicFrames(iSlideNumber);
            }
            if (AreWeInterestedIn(ContentType.Footer))
            {
                spf.Triggers.AddRange(PptxMetadataDefinitions.Footer);
                spf.Triggers.AddRange(PptxMetadataDefinitions.FooterOnSlide);
            }

            return spf as IPartFilter;
        }
Exemple #22
0
 public Stream GetPartContent(PartInfo part)
 {
     string sPhysicalName = part.AbsolutePath();
     return GetPartContent(sPhysicalName);
 }
        private bool IsASlidePartButNotInRelationToPresentation(PartInfo rel)
        {
            string sType = rel.GetContentType();
            if (sType != "application/vnd.openxmlformats-officedocument.presentationml.slide+xml")
                return false;
            if (string.IsNullOrEmpty(rel.RelatedTo))
                return true;
            if (rel.RelatedTo.ToLower().IndexOf("presentation") >= 0)
                return false;

            return true;
        }
 public XlsxWorkbookXmlPartFilter(CommonNamespaces commonNamespaces, ContentType[] contentTypesToDetect, PartInfo rel)
     : base(commonNamespaces)
 {
     m_contentTypesToDetect = contentTypesToDetect;
     SortRelatedParts(rel.GetRelatedObjects());
 }
        private void ProcessExternalPart(PartInfo rel, OPCPackage outputPackage, DocumentProcessingActions action)
        {
            if (action == DocumentProcessingActions.Discover)
                return;

            outputPackage.AddContent(rel, null, m_openXmlFormat);
        }
        private void ProcessPart(PartInfo rel, OPCPackage inputPackage, OPCPackage outputPackage, DocumentProcessingActions action)
        {
            if (rel.External)
            {
                ProcessExternalPart(rel, outputPackage, action);
                return;
            }

            if (m_ProcessedParts.ContainsKey(rel.AbsolutePath()))
            {
                if (outputPackage != null)
                    outputPackage.AddContent(rel, null, m_openXmlFormat);
                return;
            }

            m_ProcessedParts.Add(rel.AbsolutePath(), true);

            IPartFilter pf = GetPartFilter(rel, action);
            Stream inputData = rel.GetContent();
            RelatedPartProvider relPartProv = new RelatedPartProvider(inputPackage, rel);

            Stream modifiedStream = ProcessPartData(pf, inputData, relPartProv, action);

            if (modifiedStream != null)
                outputPackage.AddContent(rel, modifiedStream, m_openXmlFormat);

            if (action != DocumentProcessingActions.PassThrough && pf.IsBlockedFilter)
                return;

            foreach (PartInfo subRel in pf.SortRelatedParts(rel.GetRelatedObjects()))
            {
                ProcessPart(subRel, m_inputPackage, m_outputPackage, action);
            }
        }
        protected override void PreprocessSpecialParts(PartInfo rel, IPartFilter pf)
        {
            Stream inputData = rel.GetContent();
            pf.PreProcessPart(inputData);

            if (pf is PptxSlidePartFilter)
            {
                CollectPreProcessResultsForSlidePart(rel, pf as PptxSlidePartFilter);
            }
            else if (pf is PptxNotesMasterPartFilter)
            {
                CollectPreProcessResultsForNotesMasterPart(rel, pf as PptxNotesMasterPartFilter);
            }
            else if (pf is PptxHandoutsMasterPartFilter)
            {
                CollectPreProcessResultsForHandoutsMasterPart(rel, pf as PptxHandoutsMasterPartFilter);
            }
            else if (pf is PptxSlideMasterPartFilter)
            {
                CollectPreProcessResultsForSlideMasterPart(rel, pf as PptxSlideMasterPartFilter);
            }
            else if (pf is PptxSlideLayoutPartFilter)
            {
                CollectPreProcessResultsForSlideLayoutPart(rel, pf as PptxSlideLayoutPartFilter);
            }

            base.PreprocessSpecialParts(rel, pf);
        }
        private static Dictionary<string, string> ConstructTemplateLookup(PartInfo settingsPart, OpenXmlFormat openXmlFormat)
        {
            Dictionary<string, string> result = new Dictionary<string,string>();

            foreach (PartInfo pi in settingsPart.GetRelatedObjects())
            {
                if (pi.Type == OpenXmlFactory.Get(openXmlFormat).OfficeDocumentRelationshipsAttachedTemplate)
                {
                    result.Add(pi.Id, pi.Target);
                }
            }

            return result;
        }
 private IPartFilter ConstructSettingsFilter(PartInfo rel)
 {
     XmlPartFilter xpf = new XmlPartFilter(m_commonNamespaces);
     xpf.Triggers.AddRange(DocxMetadataDefinitions.DocumentVariables);
     xpf.Triggers.AddRange(DocxMetadataDefinitions.GetAttachedTemplateDef(rel, m_openXmlFormat));
     xpf.Triggers.AddRange(DocxMetadataDefinitions.FootnoteProperties);
     xpf.Triggers.AddRange(DocxMetadataDefinitions.EndnoteProperties);
     xpf.Triggers.AddRange(DocxMetadataDefinitions.TrackChangesFlag);
     return xpf;
 }
        private static List<XmlDocument> GetSubPartsXml(PartInfo piDocument, string sContentType)
        {
            List<XmlDocument> results = null;
            foreach (PartInfo pi in piDocument.GetRelatedObjects())
            {
                if (pi.GetContentType() != sContentType)
                    continue;

                if (results == null)
                    results = new List<XmlDocument>();

                Stream xmlData = pi.GetContent();
                XmlDocument doc = new XmlDocument();
                doc.Load(xmlData);
                results.Add(doc);
            }
            return results;
        }