fix: Add space before bullet list if set in settings

This commit is contained in:
Georgy Litvinov 2021-10-15 20:17:46 +02:00
parent 8b676491fe
commit 334c569332

View file

@ -111,13 +111,13 @@ public class ListCounter {
} }
public String getLabelAndSuffix() { public String getLabelAndSuffix() {
String sLabel="";
if (style != null && style.isNumber(nLevel)) { if (style != null && style.isNumber(nLevel)) {
String sLabel="";
if (sNumFormat[nLevel]==null) return ""; if (sNumFormat[nLevel]==null) return "";
int nLevels = Misc.getPosInteger(style.getLevelProperty(nLevel, int nLevels = Misc.getPosInteger(style.getLevelProperty(nLevel,
XMLString.TEXT_DISPLAY_LEVELS),1); XMLString.TEXT_DISPLAY_LEVELS),1);
String sSuffix = style.getLevelProperty(nLevel,XMLString.STYLE_NUM_SUFFIX); String sSuffix = getSuffix();
String sSpace = "nothing".equals(style.getLevelStyleProperty(nLevel, XMLString.TEXT_LABEL_FOLLOWED_BY)) ? "" : " "; String sSpace = getSpace();
for (int j=nLevel-nLevels+1; j<nLevel; j++) { for (int j=nLevel-nLevels+1; j<nLevel; j++) {
sLabel+=formatNumber(nCounter[j],sNumFormat[j],true)+"."; sLabel+=formatNumber(nCounter[j],sNumFormat[j],true)+".";
} }
@ -125,15 +125,23 @@ public class ListCounter {
sLabel+=formatNumber(nCounter[nLevel],sNumFormat[nLevel],true); sLabel+=formatNumber(nCounter[nLevel],sNumFormat[nLevel],true);
if (sSuffix!=null) { sLabel+=sSuffix; } if (sSuffix!=null) { sLabel+=sSuffix; }
if (sLabel.length()>0 && sSpace!=null) { sLabel+=sSpace; } if (sLabel.length()>0 && sSpace!=null) { sLabel+=sSpace; }
return sLabel;
} }
else if (style != null && style.isBullet(nLevel)) { else if (style != null && style.isBullet(nLevel)) {
return style.getLevelProperty(nLevel,XMLString.TEXT_BULLET_CHAR); sLabel = style.getLevelProperty(nLevel,XMLString.TEXT_BULLET_CHAR);
String sSpace = getSpace();
if (sLabel.length()>0 && sSpace!=null) { sLabel+=sSpace; }
} }
else {
return ""; return sLabel;
}
} }
private String getSpace() {
return "nothing".equals(style.getLevelStyleProperty(nLevel, XMLString.TEXT_LABEL_FOLLOWED_BY)) ? "" : " ";
}
private String getSuffix() {
return style.getLevelProperty(nLevel,XMLString.STYLE_NUM_SUFFIX);
}
// Utility method to generate number // Utility method to generate number
private String formatNumber(int number,String sStyle,boolean bLetterSync) { private String formatNumber(int number,String sStyle,boolean bLetterSync) {