git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1910627 13f79535-47bb-0310-9956-ffa450edef68tags/REL_5_2_4
// https://docs.sonarqube.org/display/SONARQUBE52/Analyzing+with+SonarQube+Scanner+for+Gradle | // https://docs.sonarqube.org/display/SONARQUBE52/Analyzing+with+SonarQube+Scanner+for+Gradle | ||||
// for documentation of properties. | // for documentation of properties. | ||||
// | // | ||||
// Some additional properties are currently set in the Jenkins-DSL, see jenksin/create_jobs.groovy | |||||
// Some additional properties are currently set in the Jenkins-DSL, see jenkins/create_jobs.groovy | |||||
// | // | ||||
sonarqube { | sonarqube { | ||||
properties { | properties { |
<property name="util.lib" location="${basedir}/lib/util"/> | <property name="util.lib" location="${basedir}/lib/util"/> | ||||
<!-- compiler options options --> | |||||
<!-- compiler options --> | |||||
<property name="jdk.version.source" value="1.8" description="JDK version of source code"/> | <property name="jdk.version.source" value="1.8" description="JDK version of source code"/> | ||||
<property name="jdk.version.class" value="1.8" description="JDK version of generated class files"/> | <property name="jdk.version.class" value="1.8" description="JDK version of generated class files"/> | ||||
<property name="compile.debug" value="true"/> | <property name="compile.debug" value="true"/> | ||||
<pathelement location="${main.output.dir}"/> | <pathelement location="${main.output.dir}"/> | ||||
<pathelement location="${ooxml.test.guava.jar}"/> | <pathelement location="${ooxml.test.guava.jar}"/> | ||||
<pathelement location="${ooxml.test.opczip.jar}"/> | <pathelement location="${ooxml.test.opczip.jar}"/> | ||||
<!-- classes are omitted on test cases outside the xml-dsign area to avoid classpath poisioning --> | |||||
<!-- classes are omitted on test cases outside the xml-dsign area to avoid classpath poisoning --> | |||||
<!--path refid="ooxml.xmlsec.classpath"/--> | <!--path refid="ooxml.xmlsec.classpath"/--> | ||||
<!-- Used only for ExtractorFactory, see #57963 --> | <!-- Used only for ExtractorFactory, see #57963 --> | ||||
<pathelement location="${scratchpad.output.dir}" unless:true="${scratchpad.ignore}"/> | <pathelement location="${scratchpad.output.dir}" unless:true="${scratchpad.ignore}"/> | ||||
<fail><condition><matches pattern="[1-9][0-9]* Unknown Licens" string="${rat.reportcontent}"/></condition></fail> | <fail><condition><matches pattern="[1-9][0-9]* Unknown Licens" string="${rat.reportcontent}"/></condition></fail> | ||||
</target> | </target> | ||||
<!-- Runs the Forbiddens APIs checker against the source code, to --> | |||||
<!-- Runs the Forbidden APIs checker against the source code, to --> | |||||
<!-- spot any cases where we've accidently used methods we shouldn't --> | <!-- spot any cases where we've accidently used methods we shouldn't --> | ||||
<!-- See https://github.com/policeman-tools/forbidden-apis for details --> | <!-- See https://github.com/policeman-tools/forbidden-apis for details --> | ||||
<!-- of the checks that this can do --> | <!-- of the checks that this can do --> | ||||
<target name="test-scratchpad-download-resources"> | <target name="test-scratchpad-download-resources"> | ||||
<!-- disable font downloading until TestFontRendering works on all plattforms --> | |||||
<!-- disable font downloading until TestFontRendering works on all platforms --> | |||||
<!-- ... eventually copy the files into the resource dirs ... --> | <!-- ... eventually copy the files into the resource dirs ... --> | ||||
<!-- | <!-- | ||||
<mkdir dir="build/scratchpad-test-resources"/> | <mkdir dir="build/scratchpad-test-resources"/> | ||||
<tstamp> | <tstamp> | ||||
<!-- usually overwritten by a command line argument --> | <!-- usually overwritten by a command line argument --> | ||||
<!-- for convience this is kept in the same format as in the release-prep call --> | |||||
<!-- for convenience this is kept in the same format as in the release-prep call --> | |||||
<format property="file_date" pattern="yyyyMMdd" locale="US"/> | <format property="file_date" pattern="yyyyMMdd" locale="US"/> | ||||
</tstamp> | </tstamp> | ||||
</sequential> | </sequential> | ||||
</macrodef> | </macrodef> | ||||
<!-- TODO: currently this only saves a copy and paste snipplet to a file ... | |||||
<!-- TODO: currently this only saves a copy and paste snippet to a file ... | |||||
would be nice if it really changes changes.xml and download.xml | would be nice if it really changes changes.xml and download.xml | ||||
Doesn't work with Java6 - the https urls can't be accessed via loadChecksum | Doesn't work with Java6 - the https urls can't be accessed via loadChecksum | ||||
--> | --> |
'adoptopenjdk_hotspot_8u282', | 'adoptopenjdk_hotspot_8u282', | ||||
'ibmjdk_1.8.0_261' | 'ibmjdk_1.8.0_261' | ||||
) | ) | ||||
// Note H50 is reserved according to its node-descripion | |||||
// Note H50 is reserved according to its node-description | |||||
label('Nodes','H22','H23','H24','H25','H26','H27','H28','H29','H30','H31','H32','H33','H34','H35','H36','H37','H38','H39','H40','H41','H42','H43','H44','H48','lucene1','lucene2','master') | label('Nodes','H22','H23','H24','H25','H26','H27','H28','H29','H30','H31','H32','H33','H34','H35','H36','H37','H38','H39','H40','H41','H42','H43','H44','H48','lucene1','lucene2','master') | ||||
} | } | ||||
steps { | steps { |
/** | /** | ||||
* Use Excel conditional formatting to hide the duplicate values, | * Use Excel conditional formatting to hide the duplicate values, | ||||
* and make the list easier to read. In this example, when the table is sorted by Region, | * and make the list easier to read. In this example, when the table is sorted by Region, | ||||
* the second (and subsequent) occurences of each region name will have white font colour. | |||||
* the second (and subsequent) occurrences of each region name will have white font colour. | |||||
*/ | */ | ||||
static void hideDupplicates(Sheet sheet) { | static void hideDupplicates(Sheet sheet) { | ||||
sheet.createRow(0).createCell(0).setCellValue("City"); | sheet.createRow(0).createCell(0).setCellValue("City"); | ||||
sheetCF.addConditionalFormatting(regions, rule1); | sheetCF.addConditionalFormatting(regions, rule1); | ||||
sheet.getRow(1).createCell(1).setCellValue("<== the second (and subsequent) " + | sheet.getRow(1).createCell(1).setCellValue("<== the second (and subsequent) " + | ||||
"occurences of each region name will have white font colour. " + | |||||
"occurrences of each region name will have white font colour. " + | |||||
"Condition: Formula Is =A2=A1 (White Font)"); | "Condition: Formula Is =A2=A1 (White Font)"); | ||||
} | } | ||||
// It is not wise to have such a wide catch clause - Exception is very | // It is not wise to have such a wide catch clause - Exception is very | ||||
// close to being at the top of the inheritance hierarchy - though it | // close to being at the top of the inheritance hierarchy - though it | ||||
// will suffice for this example as it is really not possible to recover | // will suffice for this example as it is really not possible to recover | ||||
// easilly from an exceptional set of circumstances at this point in the | |||||
// easily from an exceptional set of circumstances at this point in the | |||||
// program. It should however, ideally be replaced with one or more | // program. It should however, ideally be replaced with one or more | ||||
// catch clauses optimised to handle more specific problems. | // catch clauses optimised to handle more specific problems. | ||||
catch(Exception ex) { | catch(Exception ex) { |
/** | /** | ||||
* Custom listener class for Ants junitlauncher, because it chomps the important running details | * Custom listener class for Ants junitlauncher, because it chomps the important running details | ||||
* | * | ||||
* @see <a href="https://bz.apache.org/bugzilla/show_bug.cgi?id=64836">Bug 64836 - junitlaucher poor summary</a> | |||||
* @see <a href="https://bz.apache.org/bugzilla/show_bug.cgi?id=64836">Bug 64836 - junitlauncher poor summary</a> | |||||
**/ | **/ | ||||
public class Junit5Progress implements TestExecutionListener { | public class Junit5Progress implements TestExecutionListener { | ||||
private final AtomicInteger numSkippedInTestSet = new AtomicInteger(); | private final AtomicInteger numSkippedInTestSet = new AtomicInteger(); |
DEFAULT_XML_OPTIONS.setCharacterEncoding("UTF-8"); | DEFAULT_XML_OPTIONS.setCharacterEncoding("UTF-8"); | ||||
DEFAULT_XML_OPTIONS.setDisallowDocTypeDeclaration(true); | DEFAULT_XML_OPTIONS.setDisallowDocTypeDeclaration(true); | ||||
DEFAULT_XML_OPTIONS.setEntityExpansionLimit(1); | DEFAULT_XML_OPTIONS.setEntityExpansionLimit(1); | ||||
// Piccolo is disabled for POI builts, i.e. JAXP is used for parsing | |||||
// JAXP is used for parsing | |||||
// so only user code using XmlObject/XmlToken.Factory.parse | // so only user code using XmlObject/XmlToken.Factory.parse | ||||
// directly can bypass the entity check, which is probably unlikely (... and not within our responsibility :)) | // directly can bypass the entity check, which is probably unlikely (... and not within our responsibility :)) | ||||
// DEFAULT_XML_OPTIONS.setLoadEntityBytesLimit(4096); | // DEFAULT_XML_OPTIONS.setLoadEntityBytesLimit(4096); |
/** | /** | ||||
* @param lowerbound the lower limit of the id-range to manage. Must be greater than or equal to {@link #MIN_ID}. | * @param lowerbound the lower limit of the id-range to manage. Must be greater than or equal to {@link #MIN_ID}. | ||||
* @param upperbound the upper limit of the id-range to manage. Must be less then or equal {@link #MAX_ID}. | |||||
* @param upperbound the upper limit of the id-range to manage. Must be less than or equal {@link #MAX_ID}. | |||||
*/ | */ | ||||
public IdentifierManager(long lowerbound, long upperbound) { | public IdentifierManager(long lowerbound, long upperbound) { | ||||
if (lowerbound > upperbound) { | if (lowerbound > upperbound) { |
// pack.originalPackagePath = file.getAbsolutePath(); | // pack.originalPackagePath = file.getAbsolutePath(); | ||||
return pack; | return pack; | ||||
} catch (InvalidFormatException | RuntimeException e) { | } catch (InvalidFormatException | RuntimeException e) { | ||||
// use revert() to free resources when the packgae is opened read-only | |||||
// use revert() to free resources when the package is opened read-only | |||||
pack.revert(); | pack.revert(); | ||||
throw e; | throw e; | ||||
/** | /** | ||||
* Add a thumbnail to the package. This method is provided to make easier | * Add a thumbnail to the package. This method is provided to make easier | ||||
* the addition of a thumbnail in a package. You can do the same work by | * the addition of a thumbnail in a package. You can do the same work by | ||||
* using the traditionnal relationship and part mechanism. | |||||
* using the traditional relationship and part mechanism. | |||||
* | * | ||||
* @param path The full path to the image file. | * @param path The full path to the image file. | ||||
*/ | */ | ||||
/** | /** | ||||
* Add a thumbnail to the package. This method is provided to make easier | * Add a thumbnail to the package. This method is provided to make easier | ||||
* the addition of a thumbnail in a package. You can do the same work by | * the addition of a thumbnail in a package. You can do the same work by | ||||
* using the traditionnal relationship and part mechanism. | |||||
* using the traditional relationship and part mechanism. | |||||
* | * | ||||
* @param filename The full path to the image file. | * @param filename The full path to the image file. | ||||
* @param data the image data | * @param data the image data | ||||
// If the specified partis flagged as deleted, we make it | // If the specified partis flagged as deleted, we make it | ||||
// available | // available | ||||
part.setDeleted(false); | part.setDeleted(false); | ||||
// and delete the old part to replace it thereafeter | |||||
// and delete the old part to replace it thereafter | |||||
this.partList.remove(part._partName); | this.partList.remove(part._partName); | ||||
} | } | ||||
this.partList.put(part._partName, part); | this.partList.put(part._partName, part); | ||||
/** | /** | ||||
* Replace a content type in this package.<p> | * Replace a content type in this package.<p> | ||||
* A typical scneario to call this method is to rename a template file to the main format, e.g. | |||||
* A typical scenario to call this method is to rename a template file to the main format, e.g. | |||||
* <ul> | * <ul> | ||||
* <li>".dotx" to ".docx"</li> | * <li>".dotx" to ".docx"</li> | ||||
* <li>".dotm" to ".docm"</li> | * <li>".dotm" to ".docm"</li> |
partURI = new URI(partName); | partURI = new URI(partName); | ||||
} catch (URISyntaxException e) { | } catch (URISyntaxException e) { | ||||
throw new IllegalArgumentException( | throw new IllegalArgumentException( | ||||
"partName argmument is not a valid OPC part name !"); | |||||
"partName argument is not a valid OPC part name !"); | |||||
} | } | ||||
if (checkConformance) { | if (checkConformance) { | ||||
} | } | ||||
/** | /** | ||||
* Throws an exception if the specified part name ends with a forwar slash | |||||
* Throws an exception if the specified part name ends with a forward slash | |||||
* character '/'. [M1.5] | * character '/'. [M1.5] | ||||
* | * | ||||
* @param partUri | * @param partUri | ||||
* The part name to check. | * The part name to check. | ||||
* @throws InvalidFormatException | * @throws InvalidFormatException | ||||
* If the specified part name ends with a forwar slash character | |||||
* If the specified part name ends with a forward slash character | |||||
* '/'. | * '/'. | ||||
*/ | */ | ||||
private static void throwExceptionIfPartNameEndsWithForwardSlashChar( | private static void throwExceptionIfPartNameEndsWithForwardSlashChar( |
* The part that own this relationships collection. If <b>null</b> | * The part that own this relationships collection. If <b>null</b> | ||||
* then this part is considered as the package root. | * then this part is considered as the package root. | ||||
* @throws InvalidFormatException | * @throws InvalidFormatException | ||||
* If an error occurs during the parsing of the relatinships | |||||
* If an error occurs during the parsing of the relationships | |||||
* part fo the specified part. | * part fo the specified part. | ||||
*/ | */ | ||||
public PackageRelationshipCollection(OPCPackage container, PackagePart part) | public PackageRelationshipCollection(OPCPackage container, PackagePart part) |
* | * | ||||
* @param partName | * @param partName | ||||
* The part name to validate. | * The part name to validate. | ||||
* @return The correspondant part name if valid, else <code>null</code>. | |||||
* @return The correspondent part name if valid, else <code>null</code>. | |||||
* @throws InvalidFormatException | * @throws InvalidFormatException | ||||
* Throws if the specified part name is not OPC compliant. | * Throws if the specified part name is not OPC compliant. | ||||
* @see #createPartName(URI) | * @see #createPartName(URI) | ||||
* The part name to validate. | * The part name to validate. | ||||
* @param relativePart | * @param relativePart | ||||
* The relative base part. | * The relative base part. | ||||
* @return The correspondant part name if valid, else <code>null</code>. | |||||
* @return The correspondent part name if valid, else <code>null</code>. | |||||
* @throws InvalidFormatException | * @throws InvalidFormatException | ||||
* Throws if the specified part name is not OPC compliant. | * Throws if the specified part name is not OPC compliant. | ||||
* @see #createPartName(URI) | * @see #createPartName(URI) | ||||
* The part name URI to validate. | * The part name URI to validate. | ||||
* @param relativePart | * @param relativePart | ||||
* The relative base part. | * The relative base part. | ||||
* @return The correspondant part name if valid, else <code>null</code>. | |||||
* @return The correspondent part name if valid, else <code>null</code>. | |||||
* @throws InvalidFormatException | * @throws InvalidFormatException | ||||
* Throws if the specified part name is not OPC compliant. | * Throws if the specified part name is not OPC compliant. | ||||
* @see #createPartName(URI) | * @see #createPartName(URI) | ||||
* Source part URI | * Source part URI | ||||
* @return the full path (as URI) of the relation file | * @return the full path (as URI) of the relation file | ||||
* @throws InvalidOperationException | * @throws InvalidOperationException | ||||
* Throws if the specified URI is a relationshp part. | |||||
* Throws if the specified URI is a relationship part. | |||||
*/ | */ | ||||
public static PackagePartName getRelationshipPartName( | public static PackagePartName getRelationshipPartName( | ||||
PackagePartName partName) { | PackagePartName partName) { | ||||
value = value.replace('\\', '/'); | value = value.replace('\\', '/'); | ||||
} | } | ||||
// URI fragemnts (those starting with '#') are not encoded | |||||
// URI fragments (those starting with '#') are not encoded | |||||
// and may contain white spaces and raw unicode characters | // and may contain white spaces and raw unicode characters | ||||
int fragmentIdx = value.indexOf('#'); | int fragmentIdx = value.indexOf('#'); | ||||
if(fragmentIdx != -1){ | if(fragmentIdx != -1){ |
addDefaultContentType(extension, contentType); | addDefaultContentType(extension, contentType); | ||||
} | } | ||||
// Overriden content types | |||||
// Overridden content types | |||||
NodeList overrideTypes = xmlContentTypetDoc.getDocumentElement().getElementsByTagNameNS(TYPES_NAMESPACE_URI, OVERRIDE_TAG_NAME); | NodeList overrideTypes = xmlContentTypetDoc.getDocumentElement().getElementsByTagNameNS(TYPES_NAMESPACE_URI, OVERRIDE_TAG_NAME); | ||||
int overrideTypeCount = overrideTypes.getLength(); | int overrideTypeCount = overrideTypes.getLength(); | ||||
for (int i = 0; i < overrideTypeCount; i++) { | for (int i = 0; i < overrideTypeCount; i++) { |
private String commitmentType = "Created and approved this document"; | private String commitmentType = "Created and approved this document"; | ||||
/** | /** | ||||
* Swtich to enable/disable automatic CRL download - by default the download is with all https hostname | |||||
* Switch to enable/disable automatic CRL download - by default the download is with all https hostname | |||||
* and certificate verifications disabled. | * and certificate verifications disabled. | ||||
* | * | ||||
* @since POI 5.2.1 | * @since POI 5.2.1 | ||||
} | } | ||||
/** | /** | ||||
* @param xadesIssuerNameNoReverseOrder when true, the issuer DN instead of the issuer X500 prinicpal is used | |||||
* @param xadesIssuerNameNoReverseOrder when true, the issuer DN instead of the issuer X500 principal is used | |||||
*/ | */ | ||||
public void setXadesIssuerNameNoReverseOrder(boolean xadesIssuerNameNoReverseOrder) { | public void setXadesIssuerNameNoReverseOrder(boolean xadesIssuerNameNoReverseOrder) { | ||||
this.xadesIssuerNameNoReverseOrder = xadesIssuerNameNoReverseOrder; | this.xadesIssuerNameNoReverseOrder = xadesIssuerNameNoReverseOrder; | ||||
/** | /** | ||||
* @return the cannonicalization method for XAdES-XL signing. | |||||
* @return the canonicalization method for XAdES-XL signing. | |||||
* Defaults to {@code EXCLUSIVE} | * Defaults to {@code EXCLUSIVE} | ||||
* @see <a href="http://docs.oracle.com/javase/7/docs/api/javax/xml/crypto/dsig/CanonicalizationMethod.html">javax.xml.crypto.dsig.CanonicalizationMethod</a> | * @see <a href="http://docs.oracle.com/javase/7/docs/api/javax/xml/crypto/dsig/CanonicalizationMethod.html">javax.xml.crypto.dsig.CanonicalizationMethod</a> | ||||
*/ | */ | ||||
} | } | ||||
/** | /** | ||||
* @param xadesCanonicalizationMethod the cannonicalization method for XAdES-XL signing | |||||
* @param xadesCanonicalizationMethod the canonicalization method for XAdES-XL signing | |||||
* @see <a href="http://docs.oracle.com/javase/7/docs/api/javax/xml/crypto/dsig/CanonicalizationMethod.html">javax.xml.crypto.dsig.CanonicalizationMethod</a> | * @see <a href="http://docs.oracle.com/javase/7/docs/api/javax/xml/crypto/dsig/CanonicalizationMethod.html">javax.xml.crypto.dsig.CanonicalizationMethod</a> | ||||
*/ | */ | ||||
public void setXadesCanonicalizationMethod(String xadesCanonicalizationMethod) { | public void setXadesCanonicalizationMethod(String xadesCanonicalizationMethod) { |
insertXChild(unsignedSigProps, validationData); | insertXChild(unsignedSigProps, validationData); | ||||
} | } | ||||
} catch (CertificateEncodingException e) { | } catch (CertificateEncodingException e) { | ||||
throw new MarshalException("unable to create XAdES signatrue", e); | |||||
throw new MarshalException("unable to create XAdES signature", e); | |||||
} | } | ||||
/** | /** | ||||
* Check if CRL is to be added, check cached CRLs in config and download if necessary. | * Check if CRL is to be added, check cached CRLs in config and download if necessary. | ||||
* Can be overriden to suppress the logic | |||||
* Can be overridden to suppress the logic | |||||
* @return empty list, if not found or suppressed, otherwise the list of CRLs as encoded bytes | * @return empty list, if not found or suppressed, otherwise the list of CRLs as encoded bytes | ||||
*/ | */ | ||||
protected List<byte[]> retrieveCRL(SignatureConfig signatureConfig, X509Certificate holder) throws IOException { | protected List<byte[]> retrieveCRL(SignatureConfig signatureConfig, X509Certificate holder) throws IOException { |
/** | /** | ||||
* @return returns bounds as a path in local coordinates, which is | * @return returns bounds as a path in local coordinates, which is | ||||
* userful if you need to transform to global coordinates | |||||
* useful if you need to transform to global coordinates | |||||
* | * | ||||
* Warning: Don't use this for 1d objects, and will fail for | * Warning: Don't use this for 1d objects, and will fail for | ||||
* infinite line objects | * infinite line objects |
try { | try { | ||||
return new SVGFormat(textAsShapes); | return new SVGFormat(textAsShapes); | ||||
} catch (Exception | NoClassDefFoundError e) { | } catch (Exception | NoClassDefFoundError e) { | ||||
LOG.atError().withThrowable(e).log("Batik is not not added to/working on the module-path. Use classpath mode instead of JPMS. Fallback to PNG."); | |||||
LOG.atError().withThrowable(e).log("Batik is not added to/working on the module-path. Use classpath mode instead of JPMS. Fallback to PNG."); | |||||
return new BitmapFormat("png"); | return new BitmapFormat("png"); | ||||
} | } | ||||
} | } |
final String key = lsid + "#" + ( (int) element ); | final String key = lsid + "#" + ( (int) element ); | ||||
int num; | int num; | ||||
if ( !list.isStartAtOverriden( element ) | |||||
if ( !list.isStartAtOverridden( element ) | |||||
&& numberingState.levels.containsKey( key ) ) | && numberingState.levels.containsKey( key ) ) | ||||
{ | { | ||||
num = numberingState.levels.get( key ); | num = numberingState.levels.get( key ); |
import org.apache.poi.hwpf.model.StyleSheet; | import org.apache.poi.hwpf.model.StyleSheet; | ||||
import org.apache.poi.hwpf.sprm.CharacterSprmCompressor; | import org.apache.poi.hwpf.sprm.CharacterSprmCompressor; | ||||
import org.apache.poi.hwpf.sprm.ParagraphSprmCompressor; | import org.apache.poi.hwpf.sprm.ParagraphSprmCompressor; | ||||
import org.apache.poi.util.Removal; | |||||
/** | /** | ||||
* This class is used to create a list in a Word document. It is used in | * This class is used to create a list in a Word document. It is used in | ||||
public int getStartAt( char level ) | public int getStartAt( char level ) | ||||
{ | { | ||||
if ( isStartAtOverriden( level ) ) | |||||
if ( isStartAtOverridden( level ) ) | |||||
{ | { | ||||
return _lfoData.getRgLfoLvl()[level].getIStartAt(); | return _lfoData.getRgLfoLvl()[level].getIStartAt(); | ||||
} | } | ||||
return _ignoreLogicalLeftIdentation; | return _ignoreLogicalLeftIdentation; | ||||
} | } | ||||
public boolean isStartAtOverriden( char level ) | |||||
/** | |||||
* @since POI 5.2.4 | |||||
*/ | |||||
public boolean isStartAtOverridden(char level ) | |||||
{ | |||||
ListFormatOverrideLevel lfolvl = _lfoData.getRgLfoLvl().length > level ? _lfoData | |||||
.getRgLfoLvl()[level] : null; | |||||
return lfolvl != null && lfolvl.getIStartAt() != 0 | |||||
&& !lfolvl.isFormatting(); | |||||
} | |||||
/** | |||||
* @deprecated use {@link #isStartAtOverridden(char)} | |||||
*/ | |||||
@Removal(version = "POI 6.0.0") | |||||
public boolean isStartAtOverriden(char level ) | |||||
{ | { | ||||
ListFormatOverrideLevel lfolvl = _lfoData.getRgLfoLvl().length > level ? _lfoData | ListFormatOverrideLevel lfolvl = _lfoData.getRgLfoLvl().length > level ? _lfoData | ||||
.getRgLfoLvl()[level] : null; | .getRgLfoLvl()[level] : null; |
*/ | */ | ||||
public int createFormat(String formatString) { | public int createFormat(String formatString) { | ||||
maxformatid = maxformatid >= 0xa4 ? maxformatid + 1 : 0xa4; //Starting value from M$ empircal study. | |||||
maxformatid = maxformatid >= 0xa4 ? maxformatid + 1 : 0xa4; //Starting value from M$ empirical study. | |||||
FormatRecord rec = new FormatRecord(maxformatid, formatString); | FormatRecord rec = new FormatRecord(maxformatid, formatString); | ||||
int pos = 0; | int pos = 0; |
String fmt = _formats.size() > index ? _formats.get(index) : null; | String fmt = _formats.size() > index ? _formats.get(index) : null; | ||||
if (_builtinFormats.length > index && _builtinFormats[index] != null) { | if (_builtinFormats.length > index && _builtinFormats[index] != null) { | ||||
// It's in the built in range | |||||
// It's in the built-in range | |||||
if (fmt != null) { | if (fmt != null) { | ||||
// It's been overriden, use that value | |||||
// It's been overridden, use that value | |||||
return fmt; | return fmt; | ||||
} else { | } else { | ||||
// Standard built in format | // Standard built in format |
/** | /** | ||||
* Returns a new byte array with a truncated to the given size. | * Returns a new byte array with a truncated to the given size. | ||||
* If the hash has less then size bytes, it will be filled with 0x36-bytes | |||||
* If the hash has less than size bytes, it will be filled with 0x36-bytes | |||||
* | * | ||||
* @param hash the to be truncated/filled hash byte array | * @param hash the to be truncated/filled hash byte array | ||||
* @param size the size of the returned byte array | * @param size the size of the returned byte array | ||||
/** | /** | ||||
* Returns a new byte array with a truncated to the given size. | * Returns a new byte array with a truncated to the given size. | ||||
* If the hash has less then size bytes, it will be filled with 0-bytes | |||||
* If the hash has less than size bytes, it will be filled with 0-bytes | |||||
* | * | ||||
* @param hash the to be truncated/filled hash byte array | * @param hash the to be truncated/filled hash byte array | ||||
* @param size the size of the returned byte array | * @param size the size of the returned byte array |
/** | /** | ||||
* Apply 2-D transforms before drawing this shape. This includes rotation and flipping. | * Apply 2-D transforms before drawing this shape. This includes rotation and flipping. | ||||
* | * | ||||
* @param graphics the graphics whos transform matrix will be modified | |||||
* @param graphics the graphics whose transform matrix will be modified | |||||
*/ | */ | ||||
public void applyTransform(Graphics2D graphics) { | public void applyTransform(Graphics2D graphics) { | ||||
} | } |
/** | /** | ||||
* Apply 2-D transforms before drawing this shape. This includes rotation and flipping. | * Apply 2-D transforms before drawing this shape. This includes rotation and flipping. | ||||
* | * | ||||
* @param graphics the graphics whos transform matrix will be modified | |||||
* @param graphics the graphics whose transform matrix will be modified | |||||
*/ | */ | ||||
@Override | @Override | ||||
public void applyTransform(Graphics2D graphics) { | public void applyTransform(Graphics2D graphics) { |
/** | /** | ||||
* Apply 2-D transforms before drawing this shape. This includes rotation and flipping. | * Apply 2-D transforms before drawing this shape. This includes rotation and flipping. | ||||
* | * | ||||
* @param graphics the graphics whos transform matrix will be modified | |||||
* @param graphics the graphics whose transform matrix will be modified | |||||
*/ | */ | ||||
void applyTransform(Graphics2D graphics); | void applyTransform(Graphics2D graphics); | ||||
protected double[] collectValues(ValueEval arg) throws EvaluationException { | protected double[] collectValues(ValueEval arg) throws EvaluationException { | ||||
double[] values = instance.collectValues(arg); | double[] values = instance.collectValues(arg); | ||||
/* handle case where MDETERM is operating on an array that that is not completely filled*/ | |||||
/* handle case where MDETERM is operating on an array that is not completely filled*/ | |||||
if (arg instanceof AreaEval && values.length == 1) | if (arg instanceof AreaEval && values.length == 1) | ||||
throw new EvaluationException(ErrorEval.VALUE_INVALID); | throw new EvaluationException(ErrorEval.VALUE_INVALID); | ||||
protected double[] collectValues(ValueEval arg) throws EvaluationException { | protected double[] collectValues(ValueEval arg) throws EvaluationException { | ||||
double[] values = instance.collectValues(arg); | double[] values = instance.collectValues(arg); | ||||
/* handle case where MDETERM is operating on an array that that is not completely filled*/ | |||||
/* handle case where MDETERM is operating on an array that is not completely filled*/ | |||||
if (arg instanceof AreaEval && values.length == 1) | if (arg instanceof AreaEval && values.length == 1) | ||||
throw new EvaluationException(ErrorEval.VALUE_INVALID); | throw new EvaluationException(ErrorEval.VALUE_INVALID); | ||||
StringRecord sr = new StringRecord(); | StringRecord sr = new StringRecord(); | ||||
sr.setString("NA"); | sr.setString("NA"); | ||||
SharedValueManager svm = SharedValueManager.createEmpty(); | SharedValueManager svm = SharedValueManager.createEmpty(); | ||||
// bug 46213 -> String record was supplied but formula record flag is not set | |||||
// bug 46213 -> String record was supplied but formula record flag is not set | |||||
FormulaRecordAggregate fra = new FormulaRecordAggregate(fr, sr, svm); | FormulaRecordAggregate fra = new FormulaRecordAggregate(fr, sr, svm); | ||||
List<org.apache.poi.hssf.record.Record> vraRecs = new ArrayList<>(); | List<org.apache.poi.hssf.record.Record> vraRecs = new ArrayList<>(); | ||||
fra.visitContainedRecords(vraRecs::add); | fra.visitContainedRecords(vraRecs::add); |
* multiple of 512 bytes) | * multiple of 512 bytes) | ||||
* | * | ||||
* As yet, this problem remains. One school of thought is | * As yet, this problem remains. One school of thought is | ||||
* not not issue an EOF when we discover the last block | |||||
* to not issue an EOF when we discover the last block | |||||
* is short, but this seems a bit wrong. | * is short, but this seems a bit wrong. | ||||
* The other is to fix the handling of the last block in | * The other is to fix the handling of the last block in | ||||
* POIFS, since it seems to be slight wrong | * POIFS, since it seems to be slight wrong |
assertEquals(5, row.getCell(5, MissingCellPolicy.CREATE_NULL_AS_BLANK).getColumnIndex()); | assertEquals(5, row.getCell(5, MissingCellPolicy.CREATE_NULL_AS_BLANK).getColumnIndex()); | ||||
// Now change the cell policy on the workbook, check | |||||
// that that is now used if no policy given | |||||
// Now change the cell policy on the workbook, check that is now used if no policy given | |||||
workbook.setMissingCellPolicy(MissingCellPolicy.RETURN_BLANK_AS_NULL); | workbook.setMissingCellPolicy(MissingCellPolicy.RETURN_BLANK_AS_NULL); | ||||
assertEquals(CellType.STRING, row.getCell(0).getCellType()); | assertEquals(CellType.STRING, row.getCell(0).getCellType()); |
// autosize not-evaluated cells, formula cells are sized as if the result is 0 | // autosize not-evaluated cells, formula cells are sized as if the result is 0 | ||||
for (int i = 0; i < 6; i++) sheet.autoSizeColumn(i); | for (int i = 0; i < 6; i++) sheet.autoSizeColumn(i); | ||||
assertTrue(sheet.getColumnWidth(0) < sheet.getColumnWidth(1)); // width of '0' is less then width of '10' | |||||
assertTrue(sheet.getColumnWidth(0) < sheet.getColumnWidth(1)); // width of '0' is less than width of '10' | |||||
assertEquals(sheet.getColumnWidth(1), sheet.getColumnWidth(2)); // 10 and '10' should be sized equally | assertEquals(sheet.getColumnWidth(1), sheet.getColumnWidth(2)); // 10 and '10' should be sized equally | ||||
assertEquals(sheet.getColumnWidth(3), sheet.getColumnWidth(0)); // formula result is unknown, the width is calculated for '0' | assertEquals(sheet.getColumnWidth(3), sheet.getColumnWidth(0)); // formula result is unknown, the width is calculated for '0' | ||||
assertEquals(sheet.getColumnWidth(4), sheet.getColumnWidth(5)); // 10.0000 and '10.0000' | assertEquals(sheet.getColumnWidth(4), sheet.getColumnWidth(5)); // 10.0000 and '10.0000' | ||||
for (int i = 0; i < 6; i++) sheet.autoSizeColumn(i); | for (int i = 0; i < 6; i++) sheet.autoSizeColumn(i); | ||||
assertTrue(sheet.getColumnWidth(0) < sheet.getColumnWidth(1)); // width of '0' is less then width of '10' | |||||
assertTrue(sheet.getColumnWidth(0) < sheet.getColumnWidth(1)); // width of '0' is less than width of '10' | |||||
assertEquals(sheet.getColumnWidth(1), sheet.getColumnWidth(2)); // columns 1, 2 and 3 should have the same width | assertEquals(sheet.getColumnWidth(1), sheet.getColumnWidth(2)); // columns 1, 2 and 3 should have the same width | ||||
assertEquals(sheet.getColumnWidth(2), sheet.getColumnWidth(3)); // columns 1, 2 and 3 should have the same width | assertEquals(sheet.getColumnWidth(2), sheet.getColumnWidth(3)); // columns 1, 2 and 3 should have the same width | ||||
assertEquals(sheet.getColumnWidth(4), sheet.getColumnWidth(5)); // 10.0000 and '10.0000' | assertEquals(sheet.getColumnWidth(4), sheet.getColumnWidth(5)); // 10.0000 and '10.0000' |