/// /// <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> * generate a JDF 1.2 compatible Layout from this (1.3) /// * </summary> /// * <returns> bool true if successful /// * </returns> /// public virtual bool fromNewLayout() { // TODO: fix content object placement VElement vLO = getChildElementVector_JDFElement(ElementName.LAYOUT, null, new JDFAttributeMap("SignatureName", ""), false, 0, false); VElement vSig = new VElement(); if (vLO.IsEmpty()) { JDFSignature signature = (JDFSignature)appendElement(ElementName.SIGNATURE); signature.setName("Sig_00"); vSig.Add(signature); moveElementsTo((JDFLayout)signature); } else { JDFSignature sig = null; for (int i = 0; i < vLO.Count; i++) { JDFElement lo = (JDFElement)vLO[i]; sig = null; if (lo.hasAttribute(AttributeName.SIGNATURENAME)) { lo.renameAttribute(AttributeName.SIGNATURENAME, AttributeName.NAME, null, null); sig = (JDFSignature)lo.renameElement(ElementName.SIGNATURE, null); sig.cleanResourceAttributes(); vSig.Add(sig); } else { if (vSig.IsEmpty()) { JDFSignature signature = (JDFSignature)appendElement(ElementName.SIGNATURE); signature.setName("Sig_00"); vSig.Add(sig); } } if (sig != null) { moveElement(sig, null); } } } int nSheet = 0; for (int iSig = 0; iSig < vSig.Count; iSig++) { JDFSignature sig = (JDFSignature)vSig[iSig]; vLO = sig.getChildElementVector_JDFElement(ElementName.LAYOUT, null, new JDFAttributeMap("SheetName", ""), false, 0, false); VElement vSheet = new VElement(); if (vLO.IsEmpty()) { nSheet++; JDFSheet sheet = (JDFSheet)sig.appendElement(ElementName.SHEET); sheet.setName("Sheet_" + Convert.ToString(nSheet)); vSheet.Add(sheet); ((JDFLayout)sig).moveElementsTo((JDFLayout)sheet); } else { JDFSheet sheet = null; for (int i = 0; i < vLO.Count; i++) { sheet = null; JDFElement lo = (JDFElement)vLO[i]; if (lo.hasAttribute(AttributeName.SHEETNAME)) { lo.renameAttribute(AttributeName.SHEETNAME, AttributeName.NAME, null, null); sheet = (JDFSheet)lo.renameElement(ElementName.SHEET, null); sheet.cleanResourceAttributes(); vSheet.Add(sheet); nSheet++; } else { if (vSheet.IsEmpty()) { nSheet++; sheet = (JDFSheet)sig.appendElement(ElementName.SHEET); sheet.setName("Sheet_" + Convert.ToString(nSheet)); vSheet.Add(sheet); } if (sheet != null) { sheet.moveElement(lo, null); } } } } for (int iSheet = 0; iSheet < vSheet.Count; iSheet++) { JDFSheet sheet = (JDFSheet)vSheet[iSheet]; vLO = sheet.getChildElementVector_JDFElement(ElementName.LAYOUT, null, new JDFAttributeMap("Side", ""), false, 0, false); if (vLO.IsEmpty()) { JDFSurface surf = (JDFSurface)sheet.appendElement(ElementName.SURFACE); surf.setSide(EnumSide.Front); ((JDFLayout)sheet).moveElementsTo((JDFLayout)surf); } else { for (int i = 0; i < vLO.Count; i++) { JDFSurface surface = (JDFSurface)vLO[i]; //C# renameElement only returns the renamed element. surface = (JDFSurface)surface.renameElement(ElementName.SURFACE, null); EnumSide sid = surface.getSide(); surface.cleanResourceAttributes(); surface.setSide(sid); } } } } removeFromAttribute(AttributeName.PARTIDKEYS, AttributeName.SIGNATURENAME, null, JDFConstants.BLANK, -1); removeFromAttribute(AttributeName.PARTIDKEYS, AttributeName.SHEETNAME, null, JDFConstants.BLANK, -1); removeFromAttribute(AttributeName.PARTIDKEYS, AttributeName.SIDE, null, JDFConstants.BLANK, -1); return(true); }