diff options
author | PJ Fanning <fanningpj@apache.org> | 2021-12-27 11:27:54 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2021-12-27 11:27:54 +0000 |
commit | 2d4c270bad29b288686b417389fd0b5ce6b642ce (patch) | |
tree | 242b520cde384c07ff034c240d015582a7358b3b | |
parent | 3daa439e9d3dae871e1b27848335b3c67cb89aee (diff) | |
download | poi-2d4c270bad29b288686b417389fd0b5ce6b642ce.tar.gz poi-2d4c270bad29b288686b417389fd0b5ce6b642ce.zip |
code format
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1896449 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java | 69 |
1 files changed, 32 insertions, 37 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java index 432ee0191c..835e8da2e6 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java @@ -17,15 +17,6 @@ package org.apache.poi.xssf.usermodel; -import java.util.Iterator; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.xml.namespace.QName; - import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.usermodel.RichTextString; import org.apache.poi.util.Internal; @@ -33,11 +24,15 @@ import org.apache.poi.xssf.model.StylesTable; import org.apache.poi.xssf.model.ThemesTable; import org.apache.xmlbeans.XmlCursor; import org.openxmlformats.schemas.officeDocument.x2006.sharedTypes.STXstring; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRElt; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRPrElt; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst; +import org.openxmlformats.schemas.spreadsheetml.x2006.main.*; + +import javax.xml.namespace.QName; +import java.util.Iterator; +import java.util.Map; +import java.util.SortedMap; +import java.util.TreeMap; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** @@ -569,34 +564,34 @@ public class XSSFRichTextString implements RichTextString { } void applyFont(TreeMap<Integer, CTRPrElt> formats, int startIndex, int endIndex, CTRPrElt fmt) { - // delete format runs that fit between startIndex and endIndex - // runs intersecting startIndex and endIndex remain - int runStartIdx = 0; - for (Iterator<Integer> it = formats.keySet().iterator(); it.hasNext();) { - int runEndIdx = it.next(); - if (runStartIdx >= startIndex && runEndIdx < endIndex) { - it.remove(); - } - runStartIdx = runEndIdx; + // delete format runs that fit between startIndex and endIndex + // runs intersecting startIndex and endIndex remain + int runStartIdx = 0; + for (Iterator<Integer> it = formats.keySet().iterator(); it.hasNext(); ) { + int runEndIdx = it.next(); + if (runStartIdx >= startIndex && runEndIdx < endIndex) { + it.remove(); } + runStartIdx = runEndIdx; + } - if(startIndex > 0 && !formats.containsKey(startIndex)) { - // If there's a format that starts later in the string, make it start now - for(Map.Entry<Integer, CTRPrElt> entry : formats.entrySet()) { - if(entry.getKey() > startIndex) { - formats.put(startIndex, entry.getValue()); - break; - } + if (startIndex > 0 && !formats.containsKey(startIndex)) { + // If there's a format that starts later in the string, make it start now + for (Map.Entry<Integer, CTRPrElt> entry : formats.entrySet()) { + if (entry.getKey() > startIndex) { + formats.put(startIndex, entry.getValue()); + break; } } - formats.put(endIndex, fmt); - - // assure that the range [startIndex, endIndex] consists if a single run - // there can be two or three runs depending whether startIndex or endIndex - // intersected existing format runs - SortedMap<Integer, CTRPrElt> sub = formats.subMap(startIndex, endIndex); - while(sub.size() > 1) sub.remove(sub.lastKey()); } + formats.put(endIndex, fmt); + + // assure that the range [startIndex, endIndex] consists if a single run + // there can be two or three runs depending whether startIndex or endIndex + // intersected existing format runs + SortedMap<Integer, CTRPrElt> sub = formats.subMap(startIndex, endIndex); + while (sub.size() > 1) sub.remove(sub.lastKey()); + } TreeMap<Integer, CTRPrElt> getFormatMap(CTRst entry){ int length = 0; |