示例#1
0
 virtual public Stream ProcessPart(Stream partData, Workshare.FCS.Lite.Base.DocumentText discoveryText, RelatedPartProvider relPartProvider, DocumentProcessingActions action)
 {
     Initialize();
     ConstructFilter(partData, discoveryText, action);
     ExecuteFilter();
     return m_outStream;
 }
 override protected void ConstructFilter(System.IO.Stream partData, Workshare.FCS.Lite.Base.DocumentText discoveryText, DocumentProcessingActions action)
 {
     ConstructFilterObject(discoveryText);
     m_xmlFilter.ConnectToInputStream(partData);//this doesn't write anything it is just going to store data for when we process the strings later
     if (action == DocumentProcessingActions.Clean)
         m_xmlFilter.IsCleaning = true;
 }
        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);
        }
            internal override Stream ProcessPartData(IPartFilter pf, Stream inputData, RelatedPartProvider relPartProv, DocumentProcessingActions action)
            {
                if (!(pf is XmlPartFilter))
                    Assert.IsInstanceOf(typeof(DefaultPartFilter), pf, "Partfilter wasn't a default part filter");
                Assert.IsNotNull(inputData, "input data unexpectedly null");
                Assert.AreEqual(expectedAction, action, "action wasn't what we expected");
                Assert.IsNotNull(relPartProv, "the related part provider is unexpectedly null");

                return base.ProcessPartData(pf, inputData, relPartProv, action);
            }
示例#5
0
 public System.IO.Stream ProcessPart(System.IO.Stream partData, Workshare.FCS.Lite.Base.DocumentText discoveryText, RelatedPartProvider relPartProvider, DocumentProcessingActions action)
 {
     switch (action)
     {
         case DocumentProcessingActions.Discover:
             return null;
         default:
             return partData;
     }
 }
 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);
 }
        public override Stream ProcessPart(Stream partData, DocumentText discoveryText, RelatedPartProvider relPartProvider, DocumentProcessingActions action)
        {
            //this is for the discovery on open documents - the copy loses all other macro information except this items
            //specifying macro content - there is a single vbaproject.bin file containing all macros
            //so far this appears to be valid

            if (DocumentProcessor.ActionIncludesCleaning(action))
                return null;

            if (action == DocumentProcessingActions.PassThrough)
                return partData;

            if (m_bInterestedInMacros)
            {
                List<IAbstractTextType> ttypes = discoveryText.GetTextTypes(ContentType.Macro);
                TextType macro = null;
                if (ttypes.Count > 0)
                {
                    macro = (TextType)ttypes[0];
                }
                else
                {
                    macro = new TextType(ContentType.Macro);
                    discoveryText.AddTextType(macro);
                }

                TextNode macroNode = new TextNode();
                NodeInfo ni = new NodeInfo();
                ni.name = "Id";
                ni.value = m_id;
                ni.type = DataType.String;
                macroNode.AddInfo(ni);

                ni = new NodeInfo();
                ni.name = "Target";
                ni.value = m_target;
                ni.type = DataType.String;
                macroNode.AddInfo(ni);

                ni = new NodeInfo();
                ni.name = "Type";
                ni.value = m_type;
                ni.type = DataType.String;
                macroNode.AddInfo(ni);

                macro.AddChild(macroNode);
            }

            Initialize();
            ConstructFilter(partData, discoveryText, action);
            ExecuteFilter();
            return m_outStream;
        }
 override protected void ConstructFilter(System.IO.Stream partData, Workshare.FCS.Lite.Base.DocumentText discoveryText, DocumentProcessingActions action)
 {
     m_filterViewProps = new PptxViewProps(discoveryText, m_commonNamespaces);
     m_filterViewProps.ConnectToInputStream(partData);
     if (ShouldWriteTheOutput(action))
     {
         m_outStream = new MemoryStream();
         m_filterViewProps.ConnectToOutputStream(m_outStream);
     }
     if (action == DocumentProcessingActions.PassThrough)
         m_filterViewProps.BypassFilter = true;
     else
         m_filterViewProps.RelatedSlideHiddenInfo = m_dictRelatedSlideIsHidden;
 }
 override protected void ConstructFilter(System.IO.Stream partData, Workshare.FCS.Lite.Base.DocumentText discoveryText, DocumentProcessingActions action)
 {
     m_filterSlideMaster = new PptOLEObjectAwareStateMachineBasedXmlFilter(discoveryText, m_commonNamespaces);
     m_filterSlideMaster.AddNodesToTriggerList(Triggers);
     if (DocumentProcessor.ActionIncludesCleaning(action))
     {
         m_filterSlideMaster.ListGraphicFrameHasOLEObject = m_listbGraphicFrameHasOLEObject;
     }
     m_filterSlideMaster.ConnectToInputStream(partData);
     if (ShouldWriteTheOutput(action))
     {
         m_outStream = new MemoryStream();
         m_filterSlideMaster.ConnectToOutputStream(m_outStream);
     }
 }
        override protected void ConstructFilter(System.IO.Stream partData, Workshare.FCS.Lite.Base.DocumentText discoveryText, DocumentProcessingActions action)
        {
            m_filterPresentation = new PptxPresentation(discoveryText, m_commonNamespaces);

            if(m_interestedInHiddenSlides)
                AddTriggersForHiddenSlideReferences();
            
            m_filterPresentation.AddNodesToTriggerList(Triggers);
            m_filterPresentation.ConnectToInputStream(partData);
            if (action != DocumentProcessingActions.Discover)
            {
                m_outStream = new MemoryStream();
                m_filterPresentation.ConnectToOutputStream(m_outStream);
            }
            if (action == DocumentProcessingActions.PassThrough)
                m_filterPresentation.BypassFilter = true;
        }
 public override Stream ProcessPart(Stream partData, DocumentText discoveryText, RelatedPartProvider relPartProvider, DocumentProcessingActions action)
 {
     switch (action)
     {
         case DocumentProcessingActions.Discover:
             {
                 Initialize();
                 ConstructFilter(partData, discoveryText, action);
                 ExecuteFilter();
                 return m_outStream;
             }
         default:
             { 
                 return null;
             }
     }
 }
示例#12
0
        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);
        }
示例#13
0
        override protected void ConstructFilter(System.IO.Stream partData, Workshare.FCS.Lite.Base.DocumentText discoveryText, DocumentProcessingActions action)
        {
            m_filterSlide = new PptxSlide(discoveryText, m_commonNamespaces);
            m_filterSlide.AddNodesToTriggerList(Triggers);
            if (DocumentProcessor.ActionIncludesCleaning(action))
            {
                m_filterSlide.ListGraphicFrameHasOLEObject = m_listbGraphicFrameHasOLEObject;
                m_filterSlide.ListShapeWithPostItNoteComment = m_listbShapeWithPostItNoteComment;
            }
            m_filterSlide.ConnectToInputStream(partData);

            if (ShouldWriteTheOutput(action))
            {
                m_outStream = new MemoryStream();
                m_filterSlide.ConnectToOutputStream(m_outStream);
            }
            if (action == DocumentProcessingActions.PassThrough)
                m_filterSlide.BypassFilter = true;
        }
示例#14
0
        public void Process(DocumentProcessingActions documentProcessingActions)
        {
            if (documentProcessingActions != DocumentProcessingActions.Discover)
                m_outputPackage = SetupOutput(m_inputPackage);

            if (ActionIncludesDiscovery(documentProcessingActions))
                m_docText = new DocumentText();

            List<PartInfo> relObjects = m_inputPackage.GetRelatedObjects();
            foreach (PartInfo rel in relObjects)
            {
                PreprocessPart(rel, documentProcessingActions);
            }
            foreach (PartInfo rel in relObjects)
            {
                ProcessPart(rel, m_inputPackage, m_outputPackage, documentProcessingActions);
            }

            if (m_outputPackage != null)
                m_outputPackage.Dispose();

            PostProcess();
        }
示例#15
0
        virtual protected bool ShouldWriteTheOutput(DocumentProcessingActions action)
        {
            if (action == DocumentProcessingActions.PassThrough)
                return true;

            if (m_bBlockFilter)
                return false;

            if (action == DocumentProcessingActions.Discover)
                return false;

            return true;
        }
示例#16
0
        virtual internal IPartFilter GetPartFilter(string contentType, DocumentProcessingActions actions)
        {
            switch (contentType)
            {
                case "application/vnd.openxmlformats-officedocument.extended-properties+xml":
                    return BuildDocumentPropsPartFilter(contentType);
                case "application/vnd.openxmlformats-package.core-properties+xml":
                    return BuildCorePropsPartFilter();
                case "application/vnd.openxmlformats-officedocument.custom-properties+xml":
                    return BuildCustomPropsPartFilter(!ActionIncludesCleaning(actions), contentType);
                case "application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml":
                    return BuildDiagramFilter();

                default:
                    return new DefaultPartFilter();
            }
        }
示例#17
0
 static public bool ActionIncludesDiscovery(DocumentProcessingActions action)
 {
     return (action == DocumentProcessingActions.Discover || action == DocumentProcessingActions.DiscoverAndClean);
 }
示例#18
0
        private void ProcessExternalPart(PartInfo rel, OPCPackage outputPackage, DocumentProcessingActions action)
        {
            if (action == DocumentProcessingActions.Discover)
                return;

            outputPackage.AddContent(rel, null, m_openXmlFormat);
        }
示例#19
0
        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);
            }
        }
示例#20
0
        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);
            }
        }
示例#21
0
 virtual internal Stream ProcessPartData(IPartFilter pf, Stream inputData, RelatedPartProvider relPartProv, DocumentProcessingActions action)
 {
     pf.FilterTriggersToRequiredContentTypes(ContentTypesOfInterest);
     return pf.ProcessPart(inputData, m_docText, relPartProv, action);
 }
示例#22
0
 virtual internal IPartFilter GetPartFilter(PartInfo rel, DocumentProcessingActions actions)
 {
     return GetPartFilter(rel.GetContentType(), actions);
 }
示例#23
0
 protected virtual IPartFilter GetPartFilterForPreprocessing(PartInfo rel, DocumentProcessingActions actions)
 {
     switch (rel.GetContentType())
     {
         case "application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml":
             return BuildDiagramPreprocessingFilter();
         case "application/vnd.openxmlformats-officedocument.theme+xml":
             return BuildThemePreprocessingFilter();
         case "application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml":
             return BuildDiagramColoursPreprocessingFilter();
     }
     return null;
 }
示例#24
0
 public override Stream ProcessPart(Stream partData, Workshare.FCS.Lite.Base.DocumentText discoveryText, RelatedPartProvider relPartProvider, DocumentProcessingActions action)
 {
     Stream result = base.ProcessPart(partData, discoveryText, relPartProvider, action);
     return null;
 }
示例#25
0
        virtual protected void ConstructFilter(System.IO.Stream partData, Workshare.FCS.Lite.Base.DocumentText discoveryText, DocumentProcessingActions action)
        {
            m_filter = ConstructFilterObject(discoveryText);
            m_filter.ExcludeList = exclusionList;
            if(Triggers.Count > 0)
                m_filter.AddNodesToTriggerList(Triggers);

            m_filter.ConnectToInputStream(partData);
            if (ShouldWriteTheOutput(action))
            {
                m_outStream = new MemoryStream();
                m_filter.ConnectToOutputStream(m_outStream);
            }

            if (action == DocumentProcessingActions.PassThrough)
                m_filter.BypassFilter = true;
            else if (DocumentProcessor.ActionIncludesCleaning(action))
                m_filter.IsCleaning = true;
        }
示例#26
0
        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);
        }
示例#27
0
        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;
        }
示例#28
0
        private IPartFilter GetNotesSlidePartFilter(DocumentProcessingActions actions)
        {
            bool bBlockNotes = AreWeInterestedIn(ContentType.SpeakerNote);

            PptxNotesSlidePartFilter nspf = new PptxNotesSlidePartFilter(m_commonNamespaces);
            nspf.Triggers.AddRange(PptxMetadataDefinitions.ParagraphText);
            if (AreWeInterestedIn(ContentType.SpeakerNote))
            {
                nspf.BlockFilter = true;
                nspf.Triggers.AddRange(PptxMetadataDefinitions.SpeakerNote);
            }
            if (AreWeInterestedIn(ContentType.Header))
                nspf.Triggers.AddRange(PptxMetadataDefinitions.Header);
            if (AreWeInterestedIn(ContentType.Footer))
                nspf.Triggers.AddRange(PptxMetadataDefinitions.Footer);
            if (AreWeInterestedIn(ContentType.Hyperlink))
            {
                if(ActionIncludesCleaning(actions))
                    nspf.StripAllHyperlinkNodes = true;
                nspf.Triggers.AddRange(PptxMetadataDefinitions.Hyperlink);
            }
            // This would only discover slidenumbers and date inserts as far as I can tell so not particularly useful
            //if (AreWeInterestedIn(ContentType.Field))
            //    nspf.Triggers.AddRange(PptxMetadataDefinitions.FieldInSlideNote);

            return nspf as IPartFilter;
        }
示例#29
0
        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);
        }
示例#30
0
        protected virtual void PreprocessPart(PartInfo rel, DocumentProcessingActions action)
        {
            if (rel.External)
                return;
            else if (action == DocumentProcessingActions.PassThrough)
                return;

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

            PreprocessSpecialParts(rel, pf);
            
            foreach (PartInfo subRel in pf.SortRelatedParts(rel.GetRelatedObjects()))
            {
                PreprocessPart(subRel, action);
            }
        }