Exemple #1
0
        public override POIXMLDocumentPart CreateDocumentPart(POIXMLDocumentPart parent, PackageRelationship rel, PackagePart part)
        {
            POIXMLRelation descriptor = XWPFRelation.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;
                try
                {
                    ConstructorInfo constructor = cls.GetConstructor(new Type[] { typeof(POIXMLDocumentPart), typeof(PackagePart), typeof(PackageRelationship) });
                    return(constructor.Invoke(new object[] { parent, part, rel }) as POIXMLDocumentPart);
                }
                catch (Exception)
                {
                    ConstructorInfo constructor = cls.GetConstructor(new Type[] { typeof(PackagePart), typeof(PackageRelationship) });
                    return(constructor.Invoke(new object[] { part, rel }) as POIXMLDocumentPart);
                }
            }
            catch (Exception e)
            {
                throw new POIXMLException(e);
            }
        }
Exemple #2
0
        public override POIXMLDocumentPart CreateDocumentPart(POIXMLDocumentPart parent, PackageRelationship rel, PackagePart part)
        {
            POIXMLRelation instance = (POIXMLRelation)XWPFRelation.GetInstance(rel.RelationshipType);

            if (instance != null)
            {
                if (instance.RelationClass != null)
                {
                    try
                    {
                        Type relationClass = instance.RelationClass;
                        try
                        {
                            return(relationClass.GetConstructor(new Type[3] {
                                typeof(POIXMLDocumentPart), typeof(PackagePart), typeof(PackageRelationship)
                            }).Invoke(new object[3] {
                                (object)parent, (object)part, (object)rel
                            }) as POIXMLDocumentPart);
                        }
                        catch (Exception ex)
                        {
                            return(relationClass.GetConstructor(new Type[2] {
                                typeof(PackagePart), typeof(PackageRelationship)
                            }).Invoke(new object[2] {
                                (object)part, (object)rel
                            }) as POIXMLDocumentPart);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new POIXMLException(ex);
                    }
                }
            }
            XWPFFactory.logger.Log(1, (object)("using default POIXMLDocumentPart for " + rel.RelationshipType));
            return(new POIXMLDocumentPart(part, rel));
        }
Exemple #3
0
 /**
  * @since POI 3.14-Beta1
  */
 protected override POIXMLRelation GetDescriptor(String relationshipType)
 {
     return(XWPFRelation.GetInstance(relationshipType));
 }