diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index 2be7cb4ec..52e0f7175 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -37,6 +37,7 @@ + 44985 - Properly update TextSpecInfoAtom when the parent text is changed 41187 - fixed HSSFSheet to properly read xls files without ROW records 44950 - fixed HSSFFormulaEvaluator.evaluateInCell() and Area3DEval.getValue() also added validation for number of elements in AreaEvals 42570 - fixed LabelRecord to use empty string instead of null when the length is zero. diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 3212850d3..6879556e8 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 44985 - Properly update TextSpecInfoAtom when the parent text is changed 41187 - fixed HSSFSheet to properly read xls files without ROW records 44950 - fixed HSSFFormulaEvaluator.evaluateInCell() and Area3DEval.getValue() also added validation for number of elements in AreaEvals 42570 - fixed LabelRecord to use empty string instead of null when the length is zero. diff --git a/src/documentation/release-guide.txt b/src/documentation/release-guide.txt index 56ebf3fa1..e1fbc94e6 100755 --- a/src/documentation/release-guide.txt +++ b/src/documentation/release-guide.txt @@ -37,14 +37,14 @@ where $TAG is the release tag, for example, REL_3_1_BETA1 3. Checkout the tagged version {code} cd tags -svn checkout https://svn.apache.org/repos/asf/poi/tags/TAG +svn checkout https://svn.apache.org/repos/asf/poi/tags/$TAG {code} 4. Merge (if required) {code} cd $TAG -$ svn merge https://svn.apache.org/repos/asf/poi/tags/TAG \ +$ svn merge https://svn.apache.org/repos/asf/poi/tags/$TAG \ https://svn.apache.org/repos/asf/poi/trunk {code} diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java b/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java index f2d265363..4030ddc0c 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java @@ -318,9 +318,9 @@ public class TextRun * touch the stylings. */ private void storeText(String s) { - // Remove a single trailing \n, as there is an implicit one at the + // Remove a single trailing \r, as there is an implicit one at the // end of every record - if(s.endsWith("\n")) { + if(s.endsWith("\r")) { s = s.substring(0, s.length()-1); } @@ -457,7 +457,7 @@ public class TextRun * as the the first character has. * If you care about styling, do setText on a RichTextRun instead */ - public synchronized void setText(String s) { + public synchronized void setRawText(String s) { // Save the new text to the atoms storeText(s); RichTextRun fst = _rtRuns[0]; @@ -487,7 +487,16 @@ public class TextRun } - /** + /** + * Changes the text. + * Converts '\r' into '\n' + */ + public synchronized void setText(String s) { + String text = normalize(s); + setRawText(text); + } + + /** * Ensure a StyleTextPropAtom is present for this run, * by adding if required. Normally for internal TextRun use. */ @@ -666,4 +675,12 @@ public class TextRun return null; } + + /** + * Returns a new string with line breaks converted into internal ppt representation + */ + public String normalize(String s){ + String ns = s.replaceAll("\\r?\\n", "\r"); + return ns; + } } diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java index 7458df7e6..6bc203b65 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java @@ -162,10 +162,18 @@ public class RichTextRun { * Change the text */ public void setText(String text) { - length = text.length(); - parentRun.changeTextInRichTextRun(this,text); + String s = parentRun.normalize(text); + setRawText(s); } + /** + * Change the text + */ + public void setRawText(String text) { + length = text.length(); + parentRun.changeTextInRichTextRun(this,text); + } + /** * Tells the RichTextRun its new position in the parent TextRun * @param startAt