Removed some unneeded fields. Rewrote part of the insertContentTag function. ElementStructure8 (mauve test) still fails because of this function. I am still working on it.
2006-02-01 Lillian Angel <[EMAIL PROTECTED]> * javax/swing/text/DefaultStyledDocument.java: Removed unneeded fields. (insertUpdate): Removed field initialization. (insertContentTag): Rewrote part of function. Still not complete. On Wed, 2006-02-01 at 14:40 -0500, Lillian Angel wrote: > Most structures for DefaultStyledDocument are now correct. Mauve test > ElementStructure8 still fails because DefaultStyledDocument is still > not perfect for strings inserted with 2 or more fractures. The other > mauve tests pass :) > > > 2006-02-01 Lillian Angel <[EMAIL PROTECTED]> > > * javax/swing/text/DefaultStyledDocument.java > (insertParagraph): Cleaned up code. > (insertFirstContentTag): Fixed call to recreateLeaves. > (insertContentTag): Added check to code to determine where > content should be inserted with respect to next element. > (createFracture): Removed check, recreateLeaves is called in > other places when needed. > (recreateLeaves): Added new parameter for paragraph instead > of checking the stack. Removed editing for newBranch, replaced > with a replace call. >
Index: javax/swing/text/DefaultStyledDocument.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/text/DefaultStyledDocument.java,v retrieving revision 1.54 diff -u -r1.54 DefaultStyledDocument.java --- javax/swing/text/DefaultStyledDocument.java 1 Feb 2006 19:41:24 -0000 1.54 +++ javax/swing/text/DefaultStyledDocument.java 1 Feb 2006 21:27:05 -0000 @@ -445,9 +445,6 @@ /** Holds the element that was last fractured. */ private Element lastFractured; - /** True if a paragraph was already created for the originate direction. */ - private boolean origParCreated; - /** True if a fracture was not created during a insertFracture call. */ private boolean fracNotCreated; @@ -677,7 +674,6 @@ edits.removeAllElements(); elementStack.removeAllElements(); lastFractured = null; - origParCreated = false; fracNotCreated = false; insertUpdate(data); @@ -706,7 +702,6 @@ protected void insertUpdate(ElementSpec[] data) { // Push the root and the paragraph at offset onto the element stack. - origParCreated = false; Element current = root; int index; while (!current.isLeaf()) @@ -765,7 +760,6 @@ // Create a new paragraph and push it onto the stack. Element newParagraph = insertParagraph(paragraph, offset); elementStack.push(newParagraph); - origParCreated = true; break; } break; @@ -968,27 +962,31 @@ } } } - else if (!origParCreated || dir != ElementSpec.OriginateDirection) + else { int end = pos + len; Element leaf = createLeafElement(paragraph, tag.getAttributes(), pos, end); - if (pos > target.getStartOffset()) - { - // put it after the target - edit = getEditForParagraphAndIndex(paragraph, - paragraph.getElementCount()); - edit.addAddedElement(leaf); - recreateLeaves(end, (BranchElement) target, false); - } - else + boolean onlyContent = true; + BranchElement toRec = paragraph; + if (!target.isLeaf()) { - // put it before the target - edit = getEditForParagraphAndIndex(paragraph, index); - edit.addAddedElement(leaf); - recreateLeaves(end, paragraph, true); - edit.addRemovedElement(target); + onlyContent = false; + toRec = (BranchElement) target; } + + if (pos > target.getStartOffset()) + index++; + + edit = getEditForParagraphAndIndex(paragraph, index); + edit.addAddedElement(leaf); + + if (end != toRec.getEndOffset()) + recreateLeaves(end, toRec, onlyContent); + + // FIXME: this is not fully correct + if (target.isLeaf()) + edit.addRemovedElement(target); } pos += len;