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);
            }
        }
 public XlsxExternalLinkPartFilter(CommonNamespaces commonNamespaces, string target, PartInfo rel)
     : base(commonNamespaces)
 {
     m_targetName = target;
     StoreRelatedPartsData(rel.GetRelatedObjects());
 }
Esempio n. 3
0
        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;
        }
        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;
        }
Esempio n. 5
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;
        }
Esempio n. 6
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);
                }
            }
        }
        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;
        }
 public XlsxWorkbookXmlPartFilter(CommonNamespaces commonNamespaces, ContentType[] contentTypesToDetect, PartInfo rel)
     : base(commonNamespaces)
 {
     m_contentTypesToDetect = contentTypesToDetect;
     SortRelatedParts(rel.GetRelatedObjects());
 }
Esempio n. 9
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);
            }
        }
Esempio n. 10
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);
            }
        }
Esempio n. 11
0
 protected override void PreprocessSpecialParts(PartInfo rel, IPartFilter pf)
 {
     Stream inputData = rel.GetContent();
     if (pf is XlsxWorkbookXmlPartFilter ||
         pf is XlsxStyleXmlPartFilter ||
         pf is XlsxPreprocessTablePartFilter)
     {
         pf.PreProcessPart(inputData);
     }
     else if (pf is XlsxPreprocessWorksheetPartFilter)
     {
         foreach (PartInfo subRel in pf.SortRelatedParts(rel.GetRelatedObjects()))
         {
             if (subRel.Type == OpenXmlFactory.Get(m_openXmlFormat).OfficeDocumentRelationshipsTable)
             {
                 PreprocessPart(subRel, DocumentProcessingActions.Discover);
                 m_tablePreprocessed = true;
                 break;
             }
         }
         pf.PreProcessPart(inputData);
     }
     base.PreprocessSpecialParts(rel, pf);
 }