public override void setUp() { // TODO Auto-generated method stub base.setUp(); JDFDoc doc = new JDFDoc("JDF"); JDFNode n = doc.getJDFRoot(); n.setType(EnumType.Imposition); lo = (JDFLayout)n.addResource(ElementName.LAYOUT, null); }
public virtual void testGetMediaLayout() { c.setComponentType(null); JDFLayout lo = c.appendLayout(); JDFMedia m = lo.appendMedia(); Assert.AreEqual(m, c.getMedia()); lo.makeRootResource(null, null, true); Assert.AreEqual(m, c.getMedia()); }
/// /// <summary> * generate a JDF 1.3 compatible Layout from this (1.2) /// * </summary> /// * <returns> true if successful </returns> /// public virtual bool toNewLayout() { VElement vSig = getChildElementVector(ElementName.SIGNATURE, null, null, false, 0, false); // loop over all signatures and rename them to Layout for (int iSig = 0; iSig < vSig.Count; iSig++) { JDFElement rSig = (JDFElement)vSig[iSig]; if (rSig is JDFRefElement) { rSig = ((JDFRefElement)rSig).inlineRef(); } //C# renameElement only returns the renamed element. rSig = (JDFElement)rSig.renameElement(ElementName.LAYOUT, null); JDFLayout newLO = (JDFLayout)rSig; newLO.setPartIDKey(EnumPartIDKey.SignatureName, rSig.getAttribute(AttributeName.NAME, null, "Sig" + Convert.ToString(iSig))); newLO.cleanLayoutLeaf(); VElement vSheet = newLO.getChildElementVector(ElementName.SHEET, null, null, false, 0, false); // loop over all sheets and rename them to Layout for (int iSheet = 0; iSheet < vSheet.Count; iSheet++) { JDFElement rSheet = (JDFElement)vSheet[iSheet]; if (rSheet is JDFRefElement) { rSheet = ((JDFRefElement)rSheet).inlineRef(); } //C# renameElement only returns the renamed element. rSheet = (JDFElement)rSheet.renameElement(ElementName.LAYOUT, null); newLO = (JDFLayout)rSheet; newLO.setPartIDKey(EnumPartIDKey.SheetName, rSheet.getAttribute(AttributeName.NAME, null, "Sheet" + Convert.ToString(iSheet))); newLO.cleanLayoutLeaf(); VElement vSurf = newLO.getChildElementVector(ElementName.SURFACE, null, null, false, 0, false); // loop over all surfaces and rename them to Layout for (int iSurf = 0; iSurf < vSurf.Count; iSurf++) { JDFElement rSurf = (JDFElement)vSurf[iSurf]; if (rSurf is JDFRefElement) { rSurf = ((JDFRefElement)rSurf).inlineRef(); } //C# renameElement only returns the renamed element. rSurf = (JDFElement)rSurf.renameElement(ElementName.LAYOUT, null); newLO = (JDFLayout)rSurf; newLO.setPartIDKey(EnumPartIDKey.Side, rSurf.getAttribute(AttributeName.SIDE, null, "Surf" + Convert.ToString(iSurf))); newLO.cleanLayoutLeaf(); } } } return(true); }
/// /// <summary> * version fixing routine for JDF /// * /// * uses heuristics to modify this element and its children to be compatible /// * with a given version in general, it will be able to move from low to high /// * versions but potentially fail when attempting to move from higher to /// * lower versions /// * </summary> /// * <param name="version"> /// * : version that the resulting element should correspond to </param> /// * <returns> true if successful </returns> /// public override bool fixVersion(EnumVersion version) { bool bRet = true; if (version != null) { if (version.getValue() >= EnumVersion.Version_1_3.getValue()) { if (hasAttribute(AttributeName.SOURCESHEET)) { string sourceSheet = getSourceSheet(); JDFRefElement layoutRef = (JDFRefElement)getElement_KElement("LayoutRef", null, 0); if (layoutRef != null) { JDFLayout lo = (JDFLayout)layoutRef.getLinkRoot(layoutRef.getrRef()); if (lo != null) { lo.fixVersion(version); } layoutRef.setPartMap(new JDFAttributeMap(AttributeName.SHEETNAME, sourceSheet)); lo = (JDFLayout)layoutRef.getTarget(); layoutRef.setPartMap(lo.getPartMap()); } removeAttribute(AttributeName.SOURCESHEET); } } else { JDFLayout layout = getLayout(); if (layout != null) { string sourcesheet = layout.getSheetName(); setSourceSheet(sourcesheet); JDFRefElement layoutRef = (JDFRefElement)getElement_KElement("LayoutRef", null, 0); // JDF 1.2 layout should be unpartitioned if (layoutRef != null) { // JDF 1.2 layout should be unpartitioned layoutRef.removeChild(ElementName.PART, null, 0); } } } } return(base.fixVersion(version) && bRet); }
private void moveElementsTo(JDFLayout target) { VElement vPO = getPlacedObjectVector(); if (vPO != null) { for (int i = 0; i < vPO.Count; i++) { target.moveElement(vPO[i], null); } } vPO = getChildElementVector_JDFElement(ElementName.LAYOUT, null, null, false, 0, false); if (vPO != null) { for (int i = 0; i < vPO.Count; i++) { target.moveElement(vPO[i], null); } } }
/// /// <summary> * get the media that is associated with this component, either directly or in the layout </summary> /// * <returns> the media, null if none there </returns> /// public virtual JDFMedia getMedia() { JDFMedia m = (JDFMedia)getElement(ElementName.MEDIA); if (m != null) { return(m); } JDFLayout lo = getLayout(); if (lo == null) { return(null); } lo = (JDFLayout)lo.getPartition(getPartMap(), EnumPartUsage.Implicit); m = lo.getMedia(EnumMediaType.Paper); if (m == null) { m = lo.getMedia(0); } return(m); }
public virtual void testTagMap() { JDFLayout lo = (JDFLayout)root.addResource(ElementName.LAYOUT, null, EnumUsage.Input, null, null, null, null); JDFMedia med = (JDFMedia)root.addResource(ElementName.MEDIA, null, EnumUsage.Input, null, null, null, null); JDFMedia medM = (JDFMedia)med.addPartition(EnumPartIDKey.RunTags, "MaleCover"); JDFMedia medF = (JDFMedia)med.addPartition(EnumPartIDKey.RunTags, "FemaleCover"); JDFMedia medB = (JDFMedia)med.addPartition(EnumPartIDKey.RunTags, "MaleBigBody MaleSmallBody FemaleBigBody FemaleSmallBody"); JDFLayout loM = (JDFLayout)lo.addPartition(EnumPartIDKey.RunTags, "MaleCover"); loM.refElement(medM); JDFLayout loF = (JDFLayout)lo.addPartition(EnumPartIDKey.RunTags, "FemaleCover"); loF.refElement(medF); JDFLayout loBB = (JDFLayout)lo.addPartition(EnumPartIDKey.RunTags, "MaleBigBody FemaleBigBody"); loBB.refElement(medB); JDFLayout loSB = (JDFLayout)lo.addPartition(EnumPartIDKey.RunTags, "MaleSmallBody FemaleSmallBody"); loSB.refElement(medB); lo.setXMLComment("Layout for versioned product"); KElement metaMap = rl.appendElement(METADATA_MAP); metaMap.setXMLComment("The MetadataMap element maps arbitrary tags in the document to a structural RunTag partition key\n" + "Note that any partition key may be mapped.\n" + "Note also that although an XPath syntax is used, this may be mapped to any hierarchical structure including but not limited to XML.\n"); metaMap.setAttribute("Name", "RunTags"); metaMap.setAttribute(AttributeName.DATATYPE, "PartIDKey"); metaMap.setAttribute(AttributeName.VALUEFORMAT, "%s%s"); metaMap.setAttribute(AttributeName.VALUETEMPLATE, "sex,section"); KElement expr = metaMap.appendElement(EXPR); expr.setXMLComment("This expression maps the value of /Dokument/Rezipient/@Sex to a variable \"sex\"\n" + "The Mapping is unconditional, therefore no Term is required"); expr.setAttribute("Name", "sex"); expr.setAttribute("Path", "/Dokument/Rezipient/@Sex"); expr = metaMap.appendElement(EXPR); expr.setXMLComment("Maps all elements with /Dokument/Sektion=Einband to Cover"); expr.setAttribute("Name", "section"); expr.setAttribute("Value", "Cover"); JDFNameEvaluation nev = (JDFNameEvaluation)expr.appendElement(ElementName.NAMEEVALUATION); nev.setAttribute("Path", "/Dokument/Sektion"); nev.setRegExp("Einband"); expr = metaMap.appendElement(EXPR); expr.setXMLComment("Maps all elements with /Dokument/Sektion=HauptTeil and >50 pages to BigBody"); expr.setAttribute("Name", "section"); expr.setAttribute("Value", "BigBody"); JDFand and = (JDFand)expr.appendElement("and"); nev = (JDFNameEvaluation)and.appendElement(ElementName.NAMEEVALUATION); nev.setAttribute("Path", "/Dokument/Sektion"); nev.setRegExp("HauptTeil"); JDFIntegerEvaluation iev = (JDFIntegerEvaluation)and.appendTerm(EnumTerm.IntegerEvaluation); iev.setAttribute("Path", "count(PAGE)"); iev.setValueList(new JDFIntegerRangeList("51~INF")); expr = metaMap.appendElement(EXPR); expr.setXMLComment("Maps all elements with /Dokument/Sektion=HauptTeil and <=50 pages to SmallBody"); expr.setAttribute("Name", "section"); expr.setAttribute("Value", "SmallBody"); and = (JDFand)expr.appendElement("and"); nev = (JDFNameEvaluation)and.appendElement(ElementName.NAMEEVALUATION); nev.setAttribute("Path", "/Dokument/Sektion"); nev.setRegExp("HauptTeil"); iev = (JDFIntegerEvaluation)and.appendTerm(EnumTerm.IntegerEvaluation); iev.setAttribute("Path", "count(PAGE)"); iev.setValueList(new JDFIntegerRangeList("0~INF")); rl.setFileURL("bigVariable.ppml"); rl.setXMLComment("this runlist points to a ppml with arbitrary structural tagging"); JDFResourceLink rll = root.getLink(rl, null); rll.appendPart().setDocIndex(new JDFIntegerRangeList("10 ~ 20")); rll.setXMLComment("this link selects the 11-20 document"); doc.write2File(sm_dirTestDataTemp + "metadataMap.jdf", 2, false); }