You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2012/02/23 13:07:16 UTC
svn commit: r1292759 - in /poi/trunk/src:
documentation/content/xdocs/status.xml
ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java
ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java
Author: yegor
Date: Thu Feb 23 12:07:16 2012
New Revision: 1292759
URL: http://svn.apache.org/viewvc?rev=1292759&view=rev
Log:
Bugzilla 52745: fixed XSSFRichtextString.append to preserve leading / trailing spaces
Modified:
poi/trunk/src/documentation/content/xdocs/status.xml
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java
Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1292759&r1=1292758&r2=1292759&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Thu Feb 23 12:07:16 2012
@@ -34,6 +34,7 @@
<changes>
<release version="3.8-beta6" date="2012-??-??">
+ <action dev="poi-developers" type="fix">52745 - fixed XSSFRichtextString.append to preserve leading / trailing spaces </action>
<action dev="poi-developers" type="fix">52716 - tolerate hyperlinks that have neither location nor relation </action>
<action dev="poi-developers" type="fix">52599 - avoid duplicate text when rendering slides in HSLF</action>
<action dev="poi-developers" type="fix">52598 - respect slide background when rendering slides in HSLF</action>
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java?rev=1292759&r1=1292758&r2=1292759&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java Thu Feb 23 12:07:16 2012
@@ -194,11 +194,14 @@ public class XSSFRichTextString implemen
public void append(String text, XSSFFont font){
if(st.sizeOfRArray() == 0 && st.isSetT()) {
//convert <t>string</t> into a text run: <r><t>string</t></r>
- st.addNewR().setT(st.getT());
+ CTRElt lt = st.addNewR();
+ lt.setT(st.getT());
+ preserveSpaces(lt.xgetT());
st.unsetT();
}
CTRElt lt = st.addNewR();
lt.setT(text);
+ preserveSpaces(lt.xgetT());
CTRPrElt pr = lt.addNewRPr();
if(font != null) setRunAttributes(font.getCTFont(), pr);
}
@@ -392,7 +395,7 @@ public class XSSFRichTextString implemen
if(st.sizeOfRArray() > 0) {
for (CTRElt r : st.getRArray()) {
CTRPrElt pr = r.getRPr();
- if(pr != null){
+ if(pr != null && pr.sizeOfRFontArray() > 0){
String fontName = pr.getRFontArray(0).getVal();
if(fontName.startsWith("#")){
int idx = Integer.parseInt(fontName.substring(1));
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java?rev=1292759&r1=1292758&r2=1292759&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java Thu Feb 23 12:07:16 2012
@@ -140,6 +140,12 @@ public final class TestXSSFRichTextStrin
rt.setString(" Apache");
assertEquals("<xml-fragment xml:space=\"preserve\"> Apache</xml-fragment>", xs.xmlText());
+ rt.append(" POI");
+ rt.append(" ");
+ assertEquals(" Apache POI ", rt.getString());
+ assertEquals("<xml-fragment xml:space=\"preserve\"> Apache</xml-fragment>", rt.getCTRst().getRArray(0).xgetT().xmlText());
+ assertEquals("<xml-fragment xml:space=\"preserve\"> POI</xml-fragment>", rt.getCTRst().getRArray(1).xgetT().xmlText());
+ assertEquals("<xml-fragment xml:space=\"preserve\"> </xml-fragment>", rt.getCTRst().getRArray(2).xgetT().xmlText());
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org