Example #1
0
 /**
  * Create a new child POIXMLDocumentPart
  *
  * @param descriptor the part descriptor
  * @param factory the factory that will create an instance of the requested relation
  * @param idx part number
  * @param noRelation if true, then no relationship is Added.
  * @return the Created child POIXMLDocumentPart
  */
 protected POIXMLDocumentPart CreateRelationship(POIXMLRelation descriptor, POIXMLFactory factory, int idx, bool noRelation)
 {
     try
     {
         PackagePartName ppName = PackagingUriHelper.CreatePartName(descriptor.GetFileName(idx));
         PackageRelationship rel = null;
         PackagePart part = packagePart.Package.CreatePart(ppName, descriptor.ContentType);
         if (!noRelation)
         {
             /* only add to relations, if according relationship is being Created. */
             rel = packagePart.AddRelationship(ppName, TargetMode.Internal, descriptor.Relation);
         }
         POIXMLDocumentPart doc = factory.CreateDocumentPart(descriptor);
         doc.packageRel = rel;
         doc.packagePart = part;
         doc.parent = this;
         if (!noRelation)
         {
             /* only add to relations, if according relationship is being Created. */
             AddRelation(rel.Id, doc);
         }
         return doc;
     }
     catch (PartAlreadyExistsException pae)
     {
         // Return the specific exception so the user knows
         //  that the name is already taken
         throw pae;
     }
     catch (Exception e)
     {
         // Give a general wrapped exception for the problem
         throw new POIXMLException(e);
     }
 }
Example #2
0
 public POIXMLDocumentPart CreateRelationship(POIXMLRelation descriptor, POIXMLFactory factory, int idx)
 {
     return(CreateRelationship(descriptor, factory, idx, false).DocumentPart);
 }
Example #3
0
 public POIXMLDocumentPart CreateRelationship(POIXMLRelation descriptor, POIXMLFactory factory, int idx)
 {
     return CreateRelationship(descriptor, factory, idx, false);
 }
Example #4
0
 /**
  * Create a new child POIXMLDocumentPart
  *
  * @param descriptor the part descriptor
  * @param factory the factory that will create an instance of the requested relation
  * @return the Created child POIXMLDocumentPart
  */
 public POIXMLDocumentPart CreateRelationship(POIXMLRelation descriptor, POIXMLFactory factory)
 {
     return(CreateRelationship(descriptor, factory, -1, false));
 }
Example #5
0
 /**
  * Create a new POIXMLDocumentPart using the supplied descriptor. This method is used when Adding new parts
  * to a document, for example, when Adding a sheet to a workbook, slide to a presentation, etc.
  *
  * @param descriptor  describes the object to create
  * @return A new instance of a POIXMLDocumentPart.
  */
 public abstract POIXMLDocumentPart CreateDocumentPart(POIXMLRelation descriptor);
Example #6
0
 /**
  * Create a new child POIXMLDocumentPart
  *
  * @param descriptor the part descriptor
  * @param factory the factory that will create an instance of the requested relation
  * @param idx part number
  * @param noRelation if true, then no relationship is Added.
  * @return the Created child POIXMLDocumentPart
  */
 protected POIXMLDocumentPart CreateRelationship(POIXMLRelation descriptor, POIXMLFactory factory, int idx, bool noRelation){
     try {
         PackagePartName ppName = PackagingUriHelper.CreatePartName(descriptor.GetFileName(idx));
         PackageRelationship rel = null;
         PackagePart part = packagePart.Package.CreatePart(ppName, descriptor.ContentType);
         if(!noRelation) {
             /* only add to relations, if according relationship is being Created. */
             rel = packagePart.AddRelationship(ppName, TargetMode.Internal, descriptor.Relation);
         }
         POIXMLDocumentPart doc = factory.CreateDocumentPart(descriptor);
         doc.packageRel = rel;
         doc.packagePart = part;
         doc.parent = this;
         if(!noRelation) {
             /* only add to relations, if according relationship is being Created. */
             AddRelation(rel.Id,doc);
         }
         return doc;
     } catch (Exception e){
         throw new POIXMLException(e);
     }
 }
Example #7
0
 public override POIXMLDocumentPart CreateDocumentPart(POIXMLRelation descriptor)
 {
     throw new NotSupportedException();
 }
Example #8
0
 /**
  * Create a new POIXMLDocumentPart using the supplied descriptor. This method is used when Adding new parts
  * to a document, for example, when Adding a sheet to a workbook, slide to a presentation, etc.
  *
  * @param descriptor  describes the object to create
  * @return A new instance of a POIXMLDocumentPart.
  */
 public abstract POIXMLDocumentPart CreateDocumentPart(POIXMLRelation descriptor);