aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/java/org/apache/poi/xssf/usermodel
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2015-07-31 17:22:05 +0000
committerNick Burch <nick@apache.org>2015-07-31 17:22:05 +0000
commit402c4455998c138d48f4c60a282fefc6d585945b (patch)
tree8afe35e6fac5306c1baea43bfd5dde3949748915 /src/ooxml/java/org/apache/poi/xssf/usermodel
parent7caf5eda4c642fcb8bdf223ff71f8539e8ffab7b (diff)
downloadpoi-402c4455998c138d48f4c60a282fefc6d585945b.tar.gz
poi-402c4455998c138d48f4c60a282fefc6d585945b.zip
Have XSSF rich test strings report if they have formatting applied or not, and fix them to only add the formatting child element when needed
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1693632 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java/org/apache/poi/xssf/usermodel')
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java3
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java23
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java3
3 files changed, 23 insertions, 6 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java
index 32eab8dc6b..27317345cd 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java
@@ -40,9 +40,6 @@ import org.apache.poi.ss.usermodel.FormulaEvaluator;
* For performance reasons, this class keeps a cache of all previously calculated intermediate
* cell values. Be sure to call {@link #clearAllCachedResultValues()} if any workbook cells are changed between
* calls to evaluate~ methods on this class.
- *
- * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
- * @author Josh Micich
*/
public class XSSFFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluatorProvider {
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java
index 13a1de914f..a7f9b3a8e3 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java
@@ -203,8 +203,11 @@ public class XSSFRichTextString implements RichTextString {
CTRElt lt = st.addNewR();
lt.setT(text);
preserveSpaces(lt.xgetT());
- CTRPrElt pr = lt.addNewRPr();
- if(font != null) setRunAttributes(font.getCTFont(), pr);
+
+ if (font != null) {
+ CTRPrElt pr = lt.addNewRPr();
+ setRunAttributes(font.getCTFont(), pr);
+ }
}
/**
@@ -244,6 +247,22 @@ public class XSSFRichTextString implements RichTextString {
if(ctFont.sizeOfShadowArray() > 0) pr.addNewShadow().setVal(ctFont.getShadowArray(0).getVal());
if(ctFont.sizeOfStrikeArray() > 0) pr.addNewStrike().setVal(ctFont.getStrikeArray(0).getVal());
}
+
+ /**
+ * Does this string have any explicit formatting applied, or is
+ * it just text in the default style?
+ */
+ public boolean hasFormatting() {
+ @SuppressWarnings("deprecation")
+ CTRElt[] rs = st.getRArray();
+ if (rs == null || rs.length == 0) {
+ return false;
+ }
+ for (CTRElt r : rs) {
+ if (r.isSetRPr()) return true;
+ }
+ return false;
+ }
/**
* Removes any formatting that may have been applied to the string.
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
index 0d62135d6e..153fc05d90 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
@@ -1629,7 +1629,8 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
* </p>
* @return true if the date systems used in the workbook starts in 1904
*/
- protected boolean isDate1904(){
+ @Internal
+ public boolean isDate1904(){
CTWorkbookPr workbookPr = workbook.getWorkbookPr();
return workbookPr != null && workbookPr.getDate1904();
}