Bugzilla 52745: fixed XSSFRichtextString.append to preserve leading / trailing spaces
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1292759 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
89e6f4ffc2
commit
2774c6717a
@ -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>
|
||||
|
@ -194,11 +194,14 @@ public class XSSFRichTextString implements RichTextString {
|
||||
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 implements RichTextString {
|
||||
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));
|
||||
|
@ -140,6 +140,12 @@ public final class TestXSSFRichTextString extends TestCase {
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user