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();
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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");
                }
            }
        }
Ejemplo n.º 6
0
        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;
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
0
        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;
        }
Ejemplo n.º 10
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;
 }
Ejemplo n.º 11
0
 virtual internal IPartFilter GetPartFilter(PartInfo rel, DocumentProcessingActions actions)
 {
     return GetPartFilter(rel.GetContentType(), actions);
 }
Ejemplo n.º 12
0
        protected override IPartFilter GetPartFilterForPreprocessing(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":
                case "application/vnd.ms-excel.intlmacrosheet+xml":
                case "application/vnd.ms-excel.macrosheet+xml":
                    return ConstructWorksheetPreProcessingFilter(rel.Target);

                case "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml":
                    return ConstructStyleFilter();
                case "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml":
                    {
                        if (m_tablePreprocessed)
                            return null;
                        return ConstructTableFilter(rel);
                    }
            }
            return base.GetPartFilterForPreprocessing(rel, action);
        }