/**
   * Create a new spread that reflects the
   *
   * @param masterSpreadName
   * @return
   * @throws Exception
   */
  public Spread addSpread(String masterSpreadName) throws Exception {
    Spread spread = newSpread(masterSpreadName);

    // Get the corresponding master spread, clone its data source,
    // and use that to load the spread.

    spread.setTransformationMatrix(this.spreads.size());

    return spread;
  }
 /**
  * @param child
  * @return
  * @throws Exception
  */
 private Spread newSpread(Class<? extends Spread> clazz, Element child) throws Exception {
   Spread obj = (Spread) newObject(clazz, child);
   this.addChild(obj);
   // The spreadIndex parameter is zero-index
   // for spread in list of spreads.
   obj.setSpreadIndex(spreads.size());
   if (!(obj instanceof MasterSpread)) {
     this.spreads.add(obj);
   }
   obj.postLoad();
   return obj;
 }
  /**
   * @param masterSpreadName
   * @return
   * @throws Exception
   */
  public Spread newSpread(String masterSpreadName) throws Exception {
    Spread newSpread = new Spread();
    assignIdAndRegister(newSpread);
    newSpread.setParent(this);
    newSpread.setSpreadIndex(this.spreads.size());
    this.spreads.add(newSpread);
    MasterSpread masterSpread = this.getMasterSpread(masterSpreadName);
    if (masterSpread == null) {
      logger.info("Master spread \"" + masterSpreadName + "\" not found. Master spreads: ");
      for (String key : this.masterSpreads.keySet()) {
        logger.info(" \"" + key + "\"");
      }
      throw new Exception("Failed to find master spread \"" + masterSpreadName + "\"");
    }
    newSpread.setTransformationMatrix(this.spreads.size());
    // Note that masters apply to pages, not spreads.
    for (Page page : newSpread.getPages()) {
      page.setAppliedMaster(masterSpread);
    }

    this.addChild(newSpread);
    return newSpread;
  }
 /**
  * Construct a new document by cloning an existing document, copying only the master spreads. Note
  * that this is different from a generic loadObject(InDesignObject) operation (as for
  * InDesignObject), which is a full copy.
  *
  * @param inddDoc
  * @throws Exception
  */
 public InDesignDocument(InDesignDocument inddDoc, boolean removeSpreads) throws Exception {
   Document cloneSourceDoc = inddDoc.getDataSource();
   if (cloneSourceDoc == null)
     throw new Exception("Got null data source from input InDesign document.");
   this.dataSource = (Document) cloneSourceDoc.cloneNode(true);
   logger.debug("InDesignDocument(inddDoc): setting dataSource to " + dataSource);
   Element clonedDataSource = this.dataSource.getDocumentElement();
   if (removeSpreads) {
     // Now delete the components that hold actual content, namely spreads and stories:
     for (Element spread : DataUtil.getElementChildren(clonedDataSource, null, SPRD_TAGNAME)) {
       clonedDataSource.removeChild(spread);
     }
     // FIXME: For stories, we only want to delete stories that are associated with frames on
     // normal spreads, not master spreads. So for now just leaving them in.
     //			for (Element story : DataUtil.getElementChildren(clonedDataSource, null, CFLO_TAGNAME)) {
     //				clonedDataSource.removeChild(story);
     //			}
   }
   this.load(clonedDataSource);
   this.spreads.clear(); // Just to make sure
   // Now make sure there is a spread as a document must have at least one spread.
   Spread spread = this.newSpread(this.getMasterSpreads().get(0).getName());
   spread.addPage(1);
 }
Пример #5
0
 public void loadObject(Element dataSource) throws Exception {
   super.loadObject(dataSource);
 }