Author: gwoolsey
Date: Fri May  5 21:50:59 2017
New Revision: 1794111

URL: http://svn.apache.org/viewvc?rev=1794111&view=rev
Log:
60184 - invalid OOXML produced when XSSFFont.getFamily() called with no 
families defined

Fix to stop creating an empty family when none exist, just use the existing 
logic to return NOT_APPLICABLE.  Creating the empty element produces XML that 
doesn't comply with the XSD.

Alternative would have been to set the family int value for the new family, but 
this way checking the value doesn't change the output, which is my preferred 
behavior.  No quantum effects!

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java?rev=1794111&r1=1794110&r2=1794111&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java 
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java Fri 
May  5 21:50:59 2017
@@ -598,7 +598,7 @@ public class XSSFFont implements Font {
      * @see org.apache.poi.ss.usermodel.FontFamily
      */
     public int getFamily() {
-        CTIntProperty family = _ctFont.sizeOfFamilyArray() == 0 ? 
_ctFont.addNewFamily() : _ctFont.getFamilyArray(0);
+        CTIntProperty family = _ctFont.sizeOfFamilyArray() == 0 ? null : 
_ctFont.getFamilyArray(0);
         return family == null ? FontFamily.NOT_APPLICABLE.getValue() : 
FontFamily.valueOf(family.getVal()).getValue();
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to