Example #1
0
        public override POIXMLDocumentPart CreateDocumentPart(POIXMLDocumentPart parent, PackageRelationship rel, PackagePart part)
        {
            POIXMLRelation instance = (POIXMLRelation)XSSFRelation.GetInstance(rel.RelationshipType);

            if (instance != null)
            {
                if (instance.RelationClass != null)
                {
                    try
                    {
                        return((POIXMLDocumentPart)instance.RelationClass.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, (Binder)null, new Type[2] {
                            typeof(PackagePart), typeof(PackageRelationship)
                        }, (ParameterModifier[])null).Invoke(new object[2] {
                            (object)part, (object)rel
                        }));
                    }
                    catch (Exception ex)
                    {
                        throw new POIXMLException(ex);
                    }
                }
            }
            XSSFFactory.logger.Log(1, (object)("using default POIXMLDocumentPart for " + rel.RelationshipType));
            return(new POIXMLDocumentPart(part, rel));
        }
Example #2
0
        public override POIXMLDocumentPart CreateDocumentPart(POIXMLDocumentPart parent, PackageRelationship rel, PackagePart part)
        {
            POIXMLRelation descriptor = XSSFRelation.GetInstance(rel.RelationshipType);

            if (descriptor == null || descriptor.RelationClass == null)
            {
                logger.Log(POILogger.DEBUG, "using default POIXMLDocumentPart for " + rel.RelationshipType);
                return(new POIXMLDocumentPart(part, rel));
            }

            try
            {
                Type            cls         = descriptor.RelationClass;
                ConstructorInfo constructor = cls.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(PackagePart), typeof(PackageRelationship) }, null);
                return((POIXMLDocumentPart)constructor.Invoke(new object[] { part, rel }));
            }
            catch (Exception e)
            {
                throw new POIXMLException(e);
            }
        }
Example #3
0
 /**
  * @since POI 3.14-Beta1
  */
 protected override POIXMLRelation GetDescriptor(String relationshipType)
 {
     return(XSSFRelation.GetInstance(relationshipType));
 }