From: <ox-...@us...> - 2003-05-09 01:03:52
|
Update of /cvsroot/sheets/sheets In directory sc8-pr-cvs1:/tmp/cvs-serv14801 Modified Files: Sheets.sheets Log Message: 1. Fixed DocDefinition parsing and editing (which is necessary to rename commands). 2. Changed error mapping to also try to resolve against project roots (useful when the compilation filenames don't match the full path of the exported files). Index: Sheets.sheets =================================================================== RCS file: /cvsroot/sheets/sheets/Sheets.sheets,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** Sheets.sheets 6 May 2003 10:03:39 -0000 1.47 --- Sheets.sheets 8 May 2003 22:21:11 -0000 1.48 *************** *** 31512,31516 **** // Converts the XML element into a Fragment. elt is assumed to be a single // top-level tag. ! private Fragment DocParser.toFragment (Element elt, FragmentList oldLinks) { if (elt.getTagName() == null) return null; --- 31512,31516 ---- // Converts the XML element into a Fragment. elt is assumed to be a single // top-level tag. ! private Fragment[] DocParser.toFragment (Element elt, FragmentList oldLinks) { if (elt.getTagName() == null) return null; *************** *** 31518,31535 **** String tag = elt.getTagName(); if (tag.equals("p")) { ! return parseParagraph(elt, oldLinks); } else if (tag.equals("source")) { ! return parseSource(elt, oldLinks); } else if (tag.equals("section")) { ! return parseSection(elt, oldLinks); } else if (tag.equals("document")) { ! return parseDocument(elt, oldLinks); } else if (tag.equals("ol") || tag.equals("ul")) { ! return parseList(elt, oldLinks); } else if (tag.equals("dl")) { return parseDefinition(elt, oldLinks); } else { Console.internalError("Unknown tag " + tag); ! return new UnknownDocFragment(State.getObjectDatabase(), xmlToText(elt), null); } } --- 31518,31535 ---- String tag = elt.getTagName(); if (tag.equals("p")) { ! return new Fragment[] {parseParagraph(elt, oldLinks)}; } else if (tag.equals("source")) { ! return new Fragment[] {parseSource(elt, oldLinks)}; } else if (tag.equals("section")) { ! return new Fragment[] {parseSection(elt, oldLinks)}; } else if (tag.equals("document")) { ! return new Fragment[] {parseDocument(elt, oldLinks)}; } else if (tag.equals("ol") || tag.equals("ul")) { ! return new Fragment[] {parseList(elt, oldLinks)}; } else if (tag.equals("dl")) { return parseDefinition(elt, oldLinks); } else { Console.internalError("Unknown tag " + tag); ! return new Fragment[] {new UnknownDocFragment(State.getObjectDatabase(), xmlToText(elt), null)}; } } *************** *** 31652,31666 **** Element child = (Element)nodes.item(i); if (ignoreTag == null || !child.getTagName().equals(ignoreTag)) { ! Fragment comp = toFragment(child, links); ! if (comp != null && comp instanceof DocFragment) { ! comps.addElement(comp); ! if (!(comp instanceof UnknownDocFragment)) { ! DocFragment newComp = (DocFragment) comp; ! NamedNodeMap attributes = child.getAttributes(); ! for (int j=0; j<attributes.getLength(); i++) { ! Attr attr = (Attr)attributes.item(j); ! if (attr.getName().startsWith("anchor")) { ! ScalarAttribute anchor = newComp.getAnchorAttribute(); ! anchor.changeValue(anchor.getValue() + "\\n" + attr.getValue()); } } --- 31652,31670 ---- Element child = (Element)nodes.item(i); if (ignoreTag == null || !child.getTagName().equals(ignoreTag)) { ! Fragment[] newComps = toFragment(child, links); ! for (int j=0; newComps!=null && j<newComps.length; j++) { ! Fragment comp = newComps[j]; ! if (comp != null && comp instanceof DocFragment) { ! comps.addElement(comp); ! if (!(comp instanceof UnknownDocFragment)) { ! // ### Really need to fix this for apache anchor attributes (which only occur on ! // sections and documents) ! NamedNodeMap attributes = child.getAttributes(); ! for (int k=0; k<attributes.getLength(); i++) { ! Attr attr = (Attr)attributes.item(k); ! if (attr.getName().startsWith("anchor")) { ! ScalarAttribute anchor = ((DocFragment)comp).getAnchorAttribute(); ! anchor.changeValue(anchor.getValue() + "\\n" + attr.getValue()); ! } } } *************** *** 32079,32082 **** --- 32083,32089 ---- old.insertImplicitTags(lines); text = StringSplitter.join(lines, '\\n'); + String wrapperTag = old.wrapperTag(); + if (wrapperTag != null) + System.out.println(text = "<" + wrapperTag + ">" + text + "</" + wrapperTag + ">"); return replaceWithDoc(old, text, force, extend, container); *************** *** 32616,32631 **** section text nkramer:30904 public void DocDefinition.insertImplicitTags (String[] lines) { ! int i = 0; ! for (i = 0; i < lines.length; i++) { if (StringSplitter.isBlank(lines[i])) break; - else - lines[i] = "<dt>" + lines[i] + "</dt>"; } ! DocHelper.insertImplicitTags(lines, i, "p", "p"); ! ! lines[0] = "<dd>" + lines[0]; ! lines[lines.length - 1] = lines[lines.length - 1] + "</dd>"; } object nkramer:30911 --- 32623,32641 ---- section text nkramer:30904 public void DocDefinition.insertImplicitTags (String[] lines) { ! lines[0] = "<dt>" + lines[0]; ! int i=0; ! for (; i < lines.length; i++) { if (StringSplitter.isBlank(lines[i])) break; } + lines[i - 1] = lines[i - 1] + "</dt>"; ! if (i < lines.length) { ! DocHelper.insertImplicitTags(lines, i, "p", "p"); ! lines[i] = "<dd>" + lines[i]; ! lines[lines.length - 1] = lines[lines.length - 1] + "</dd>"; ! } else { ! lines[lines.length - 1] = lines[lines.length - 1] + "<dd/>"; ! } } object nkramer:30911 *************** *** 32871,32889 **** type=java section text nkramer:31093 ! // Parses a <definition> ! private DocDefinition DocParser.parseDefinition ! (Element elt, FragmentList oldLinks) { StringBuffer buf = new StringBuffer(); Vector newLinks = new Vector(); NodeList nodes = elt.getChildNodes(); ! for (int i=0; i<nodes.getLength(); i++) { ! Element child = (Element)nodes.item(i); ! if (child.getTagName().equals("term")) { ! renumberLinks(child, oldLinks, newLinks); ! buf.append(retrieveStyledText(child) + "\\n"); } } ! Fragment[] subs = retrieveSubFragments(elt, "term", oldLinks, false); ! return new DocDefinition(State.getObjectDatabase(), buf.toString(), subs, newLinks); } object nkramer:31097 --- 32881,32911 ---- type=java section text nkramer:31093 ! // Parses a definition list <dl> into multiple definitions ! // ### Really need to add dtd validation (since this method does not do any) ! private DocDefinition[] DocParser.parseDefinition (Element elt, FragmentList oldLinks) { StringBuffer buf = new StringBuffer(); Vector newLinks = new Vector(); NodeList nodes = elt.getChildNodes(); ! ArrayList definitions = new ArrayList(nodes.getLength() / 2); ! int i=0; ! while (i<nodes.getLength()) { ! Node node = nodes.item(i++); ! if (node.getNodeType() != node.ELEMENT_NODE || ! !node.getNodeName().equals("dt")) ! continue; ! Element dt = (Element)node; ! while (i<nodes.getLength()) { ! node = nodes.item(i++); ! if (node.getNodeType() != node.ELEMENT_NODE || ! !node.getNodeName().equals("dd")) ! continue; ! Element dd = (Element)node; ! renumberLinks(dt, oldLinks, newLinks); ! String term = retrieveStyledText(dt); ! Fragment[] subs = retrieveSubFragments(dd, null, oldLinks, false); ! definitions.add(new DocDefinition(State.getObjectDatabase(), term, subs, newLinks)); } } ! return (DocDefinition[])definitions.toArray(new DocDefinition[0]); } object nkramer:31097 *************** *** 90210,90214 **** if (result == null) { try { ! result = getCanonicalTable().get(new File(filename).getCanonicalPath()); } catch (IOException e) { } --- 90232,90246 ---- if (result == null) { try { ! File file = new File(filename); // check for file relative to start directory ! if (!file.exists()) { ! // check for file relative to project directories ! Project[] projects = Project.getAllProjects(); ! for (int i=0; i<projects.length; i++) { ! if (projects[i].getRootFrag() == null) continue; ! file = new File(projects[i].getRootFrag().getRoot(), filename); ! if (file.exists()) break; ! } ! } ! result = getCanonicalTable().get(file.getCanonicalPath()); } catch (IOException e) { } |