]> source.dussan.org Git - poi.git/commitdiff
convert line breaks into internal ppt represenatation when changing text
authorYegor Kozlov <yegor@apache.org>
Wed, 14 May 2008 12:42:30 +0000 (12:42 +0000)
committerYegor Kozlov <yegor@apache.org>
Wed, 14 May 2008 12:42:30 +0000 (12:42 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@656252 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/changes.xml
src/documentation/content/xdocs/status.xml
src/documentation/release-guide.txt
src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java

index 2be7cb4ec818e90b4e713c20c92a57b75293ba18..52e0f717561d5a2a35fdc7b5dfa5493205f95d70 100644 (file)
@@ -37,6 +37,7 @@
 
                <!-- Don't forget to update status.xml too! -->
         <release version="3.1-beta2" date="2008-05-??">
+           <action dev="POI-DEVELOPERS" type="fix">44985 - Properly update TextSpecInfoAtom when the parent text is changed</action>
            <action dev="POI-DEVELOPERS" type="fix">41187 - fixed HSSFSheet to properly read xls files without ROW records</action>
            <action dev="POI-DEVELOPERS" type="fix">44950 - fixed HSSFFormulaEvaluator.evaluateInCell() and Area3DEval.getValue() also added validation for number of elements in AreaEvals</action>
            <action dev="POI-DEVELOPERS" type="fix">42570 - fixed LabelRecord to use empty string instead of null when the length is zero.</action>
index 3212850d3042d8a2813694e64bdf56e4a971c951..6879556e8ee2cd2626446c53989904643a5dd00e 100644 (file)
@@ -34,6 +34,7 @@
        <!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.1-beta2" date="2008-05-??">
+           <action dev="POI-DEVELOPERS" type="fix">44985 - Properly update TextSpecInfoAtom when the parent text is changed</action>
            <action dev="POI-DEVELOPERS" type="fix">41187 - fixed HSSFSheet to properly read xls files without ROW records</action>
            <action dev="POI-DEVELOPERS" type="fix">44950 - fixed HSSFFormulaEvaluator.evaluateInCell() and Area3DEval.getValue() also added validation for number of elements in AreaEvals</action>
            <action dev="POI-DEVELOPERS" type="fix">42570 - fixed LabelRecord to use empty string instead of null when the length is zero.</action>
index 56ebf3fa1d3c6e6851a97c9a15ce39e614f66c9a..e1fbc94e6f655843b2b828ecb5496fe1df4b0915 100755 (executable)
@@ -37,14 +37,14 @@ where $TAG is the release tag, for example, REL_3_1_BETA1
   3. Checkout the tagged version\r
 {code}\r
 cd tags\r
-svn checkout https://svn.apache.org/repos/asf/poi/tags/TAG\r
+svn checkout https://svn.apache.org/repos/asf/poi/tags/$TAG\r
 {code}\r
 \r
   4. Merge (if required)\r
 \r
 {code}\r
 cd $TAG\r
-$ svn merge https://svn.apache.org/repos/asf/poi/tags/TAG \\r
+$ svn merge https://svn.apache.org/repos/asf/poi/tags/$TAG \\r
 https://svn.apache.org/repos/asf/poi/trunk\r
 {code}\r
 \r
index f2d265363bc49abe5d7f4f5b7afead87774e2e6b..4030ddc0c281a571bd3f54c5c379e970fde10166 100644 (file)
@@ -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;
+    }
 }
index 7458df7e637fd64f1195e0d3fb8657cb79f09537..6bc203b658f97a512c9726554544320386cef698 100644 (file)
@@ -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