aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2008-05-14 12:42:30 +0000
committerYegor Kozlov <yegor@apache.org>2008-05-14 12:42:30 +0000
commit10579757d32a7e2132426dc1b70d125b099f44ff (patch)
treed1d896b2ccece3da934797af2f7ab1643297222a /src
parente212f1ad6c740988c1a4f3180c6d43b833de76d9 (diff)
downloadpoi-10579757d32a7e2132426dc1b70d125b099f44ff.tar.gz
poi-10579757d32a7e2132426dc1b70d125b099f44ff.zip
convert line breaks into internal ppt represenatation when changing text
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@656252 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/documentation/content/xdocs/changes.xml1
-rw-r--r--src/documentation/content/xdocs/status.xml1
-rwxr-xr-xsrc/documentation/release-guide.txt4
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java25
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java12
5 files changed, 35 insertions, 8 deletions
diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml
index 2be7cb4ec8..52e0f71756 100644
--- a/src/documentation/content/xdocs/changes.xml
+++ b/src/documentation/content/xdocs/changes.xml
@@ -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>
diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml
index 3212850d30..6879556e8e 100644
--- a/src/documentation/content/xdocs/status.xml
+++ b/src/documentation/content/xdocs/status.xml
@@ -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>
diff --git a/src/documentation/release-guide.txt b/src/documentation/release-guide.txt
index 56ebf3fa1d..e1fbc94e6f 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 f2d265363b..4030ddc0c2 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 7458df7e63..6bc203b658 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