You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/05/22 20:22:17 UTC
svn commit: r1890119 [5/10] - in /poi/trunk/poi-ooxml/src:
main/java/org/apache/poi/ooxml/extractor/
main/java/org/apache/poi/ooxml/util/
main/java/org/apache/poi/openxml4j/exceptions/
main/java/org/apache/poi/openxml4j/opc/ main/java/org/apache/poi/op...
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSlideShow.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSlideShow.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSlideShow.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSlideShow.java Sat May 22 20:22:16 2021
@@ -6,7 +6,7 @@
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@@ -61,203 +61,203 @@ import org.openxmlformats.schemas.presen
*/
public class XSLFSlideShow extends POIXMLDocument {
- private final PresentationDocument presentationDoc;
- /**
- * The embedded OLE2 files in the OPC package
- */
- private final List<PackagePart> embedds;
-
- public XSLFSlideShow(OPCPackage container) throws OpenXML4JException, IOException, XmlException {
- super(container);
-
- if(getCorePart().getContentType().equals(XSLFRelation.THEME_MANAGER.getContentType())) {
- rebase(getPackage());
- }
-
- presentationDoc =
- PresentationDocument.Factory.parse(getCorePart().getInputStream(), DEFAULT_XML_OPTIONS);
-
- embedds = new LinkedList<>();
- for (CTSlideIdListEntry ctSlide : getSlideReferences().getSldIdArray()) {
- PackagePart corePart = getCorePart();
- PackagePart slidePart = corePart.getRelatedPart(corePart.getRelationship(ctSlide.getId2()));
-
- for(PackageRelationship rel : slidePart.getRelationshipsByType(OLE_OBJECT_REL_TYPE)) {
- if (TargetMode.EXTERNAL == rel.getTargetMode()) {
- continue;
- }
- // TODO: Add this reference to each slide as well
- embedds.add(slidePart.getRelatedPart(rel));
- }
-
- for (PackageRelationship rel : slidePart.getRelationshipsByType(PACK_OBJECT_REL_TYPE)) {
- embedds.add(slidePart.getRelatedPart(rel));
- }
- }
- }
- public XSLFSlideShow(String file) throws OpenXML4JException, IOException, XmlException {
- this(openPackage(file));
- }
-
- /**
- * Returns the low level presentation base object
- */
- @Internal
- public CTPresentation getPresentation() {
- return presentationDoc.getPresentation();
- }
-
- /**
- * Returns the references from the presentation to its
- * slides.
- * You'll need these to figure out the slide ordering,
- * and to get at the actual slides themselves
- */
- @Internal
- public CTSlideIdList getSlideReferences() {
- if(! getPresentation().isSetSldIdLst()) {
- getPresentation().setSldIdLst(CTSlideIdList.Factory.newInstance());
- }
- return getPresentation().getSldIdLst();
- }
-
- /**
- * Returns the references from the presentation to its
- * slide masters.
- * You'll need these to get at the actual slide
- * masters themselves
- */
- @Internal
- public CTSlideMasterIdList getSlideMasterReferences() {
- return getPresentation().getSldMasterIdLst();
- }
-
- public PackagePart getSlideMasterPart(CTSlideMasterIdListEntry master) throws IOException, XmlException {
- try {
- PackagePart corePart = getCorePart();
- return corePart.getRelatedPart(
- corePart.getRelationship(master.getId2())
- );
- } catch(InvalidFormatException e) {
- throw new XmlException(e);
- }
- }
- /**
- * Returns the low level slide master object from
- * the supplied slide master reference
- */
- @Internal
- public CTSlideMaster getSlideMaster(CTSlideMasterIdListEntry master) throws IOException, XmlException {
- PackagePart masterPart = getSlideMasterPart(master);
- SldMasterDocument masterDoc =
- SldMasterDocument.Factory.parse(masterPart.getInputStream(), DEFAULT_XML_OPTIONS);
- return masterDoc.getSldMaster();
- }
-
- public PackagePart getSlidePart(CTSlideIdListEntry slide) throws IOException, XmlException {
- try {
- PackagePart corePart = getCorePart();
- return corePart.getRelatedPart(corePart.getRelationship(slide.getId2()));
- } catch(InvalidFormatException e) {
- throw new XmlException(e);
- }
- }
- /**
- * Returns the low level slide object from
- * the supplied slide reference
- */
- @Internal
- public CTSlide getSlide(CTSlideIdListEntry slide) throws IOException, XmlException {
- PackagePart slidePart = getSlidePart(slide);
- SldDocument slideDoc =
- SldDocument.Factory.parse(slidePart.getInputStream(), DEFAULT_XML_OPTIONS);
- return slideDoc.getSld();
- }
-
- /**
- * Gets the PackagePart of the notes for the
- * given slide, or null if there isn't one.
- */
- public PackagePart getNodesPart(CTSlideIdListEntry parentSlide) throws IOException, XmlException {
- PackageRelationshipCollection notes;
- PackagePart slidePart = getSlidePart(parentSlide);
-
- try {
- notes = slidePart.getRelationshipsByType(XSLFRelation.NOTES.getRelation());
- } catch(InvalidFormatException e) {
- throw new IllegalStateException(e);
- }
-
- if(notes.size() == 0) {
- // No notes for this slide
- return null;
- }
- if(notes.size() > 1) {
- throw new IllegalStateException("Expecting 0 or 1 notes for a slide, but found " + notes.size());
- }
-
- try {
- return slidePart.getRelatedPart(notes.getRelationship(0));
- } catch(InvalidFormatException e) {
- throw new IllegalStateException(e);
- }
- }
- /**
- * Returns the low level notes object for the given
- * slide, as found from the supplied slide reference
- */
- @Internal
- public CTNotesSlide getNotes(CTSlideIdListEntry slide) throws IOException, XmlException {
- PackagePart notesPart = getNodesPart(slide);
- if(notesPart == null)
- return null;
-
- NotesDocument notesDoc =
- NotesDocument.Factory.parse(notesPart.getInputStream(), DEFAULT_XML_OPTIONS);
-
- return notesDoc.getNotes();
- }
-
- /**
- * Returns all the comments for the given slide
- */
- @Internal
- public CTCommentList getSlideComments(CTSlideIdListEntry slide) throws IOException, XmlException {
- PackageRelationshipCollection commentRels;
- PackagePart slidePart = getSlidePart(slide);
-
- try {
- commentRels = slidePart.getRelationshipsByType(XSLFRelation.COMMENTS.getRelation());
- } catch(InvalidFormatException e) {
- throw new IllegalStateException(e);
- }
-
- if(commentRels.size() == 0) {
- // No comments for this slide
- return null;
- }
- if(commentRels.size() > 1) {
- throw new IllegalStateException("Expecting 0 or 1 comments for a slide, but found " + commentRels.size());
- }
-
- try {
- PackagePart cPart = slidePart.getRelatedPart(
- commentRels.getRelationship(0)
- );
- CmLstDocument commDoc =
- CmLstDocument.Factory.parse(cPart.getInputStream(), DEFAULT_XML_OPTIONS);
- return commDoc.getCmLst();
- } catch(InvalidFormatException e) {
- throw new IllegalStateException(e);
- }
- }
-
- /**
- * Get the document's embedded files.
- */
- @Override
- public List<PackagePart> getAllEmbeddedParts() throws OpenXML4JException {
- return embedds;
- }
+ private final PresentationDocument presentationDoc;
+ /**
+ * The embedded OLE2 files in the OPC package
+ */
+ private final List<PackagePart> embedds;
+
+ public XSLFSlideShow(OPCPackage container) throws OpenXML4JException, IOException, XmlException {
+ super(container);
+
+ if(getCorePart().getContentType().equals(XSLFRelation.THEME_MANAGER.getContentType())) {
+ rebase(getPackage());
+ }
+
+ presentationDoc =
+ PresentationDocument.Factory.parse(getCorePart().getInputStream(), DEFAULT_XML_OPTIONS);
+
+ embedds = new LinkedList<>();
+ for (CTSlideIdListEntry ctSlide : getSlideReferences().getSldIdArray()) {
+ PackagePart corePart = getCorePart();
+ PackagePart slidePart = corePart.getRelatedPart(corePart.getRelationship(ctSlide.getId2()));
+
+ for(PackageRelationship rel : slidePart.getRelationshipsByType(OLE_OBJECT_REL_TYPE)) {
+ if (TargetMode.EXTERNAL == rel.getTargetMode()) {
+ continue;
+ }
+ // TODO: Add this reference to each slide as well
+ embedds.add(slidePart.getRelatedPart(rel));
+ }
+
+ for (PackageRelationship rel : slidePart.getRelationshipsByType(PACK_OBJECT_REL_TYPE)) {
+ embedds.add(slidePart.getRelatedPart(rel));
+ }
+ }
+ }
+ public XSLFSlideShow(String file) throws OpenXML4JException, IOException, XmlException {
+ this(openPackage(file));
+ }
+
+ /**
+ * Returns the low level presentation base object
+ */
+ @Internal
+ public CTPresentation getPresentation() {
+ return presentationDoc.getPresentation();
+ }
+
+ /**
+ * Returns the references from the presentation to its
+ * slides.
+ * You'll need these to figure out the slide ordering,
+ * and to get at the actual slides themselves
+ */
+ @Internal
+ public CTSlideIdList getSlideReferences() {
+ if(! getPresentation().isSetSldIdLst()) {
+ getPresentation().setSldIdLst(CTSlideIdList.Factory.newInstance());
+ }
+ return getPresentation().getSldIdLst();
+ }
+
+ /**
+ * Returns the references from the presentation to its
+ * slide masters.
+ * You'll need these to get at the actual slide
+ * masters themselves
+ */
+ @Internal
+ public CTSlideMasterIdList getSlideMasterReferences() {
+ return getPresentation().getSldMasterIdLst();
+ }
+
+ public PackagePart getSlideMasterPart(CTSlideMasterIdListEntry master) throws IOException, XmlException {
+ try {
+ PackagePart corePart = getCorePart();
+ return corePart.getRelatedPart(
+ corePart.getRelationship(master.getId2())
+ );
+ } catch(InvalidFormatException e) {
+ throw new XmlException(e);
+ }
+ }
+ /**
+ * Returns the low level slide master object from
+ * the supplied slide master reference
+ */
+ @Internal
+ public CTSlideMaster getSlideMaster(CTSlideMasterIdListEntry master) throws IOException, XmlException {
+ PackagePart masterPart = getSlideMasterPart(master);
+ SldMasterDocument masterDoc =
+ SldMasterDocument.Factory.parse(masterPart.getInputStream(), DEFAULT_XML_OPTIONS);
+ return masterDoc.getSldMaster();
+ }
+
+ public PackagePart getSlidePart(CTSlideIdListEntry slide) throws IOException, XmlException {
+ try {
+ PackagePart corePart = getCorePart();
+ return corePart.getRelatedPart(corePart.getRelationship(slide.getId2()));
+ } catch(InvalidFormatException e) {
+ throw new XmlException(e);
+ }
+ }
+ /**
+ * Returns the low level slide object from
+ * the supplied slide reference
+ */
+ @Internal
+ public CTSlide getSlide(CTSlideIdListEntry slide) throws IOException, XmlException {
+ PackagePart slidePart = getSlidePart(slide);
+ SldDocument slideDoc =
+ SldDocument.Factory.parse(slidePart.getInputStream(), DEFAULT_XML_OPTIONS);
+ return slideDoc.getSld();
+ }
+
+ /**
+ * Gets the PackagePart of the notes for the
+ * given slide, or null if there isn't one.
+ */
+ public PackagePart getNodesPart(CTSlideIdListEntry parentSlide) throws IOException, XmlException {
+ PackageRelationshipCollection notes;
+ PackagePart slidePart = getSlidePart(parentSlide);
+
+ try {
+ notes = slidePart.getRelationshipsByType(XSLFRelation.NOTES.getRelation());
+ } catch(InvalidFormatException e) {
+ throw new IllegalStateException(e);
+ }
+
+ if(notes.size() == 0) {
+ // No notes for this slide
+ return null;
+ }
+ if(notes.size() > 1) {
+ throw new IllegalStateException("Expecting 0 or 1 notes for a slide, but found " + notes.size());
+ }
+
+ try {
+ return slidePart.getRelatedPart(notes.getRelationship(0));
+ } catch(InvalidFormatException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ /**
+ * Returns the low level notes object for the given
+ * slide, as found from the supplied slide reference
+ */
+ @Internal
+ public CTNotesSlide getNotes(CTSlideIdListEntry slide) throws IOException, XmlException {
+ PackagePart notesPart = getNodesPart(slide);
+ if(notesPart == null)
+ return null;
+
+ NotesDocument notesDoc =
+ NotesDocument.Factory.parse(notesPart.getInputStream(), DEFAULT_XML_OPTIONS);
+
+ return notesDoc.getNotes();
+ }
+
+ /**
+ * Returns all the comments for the given slide
+ */
+ @Internal
+ public CTCommentList getSlideComments(CTSlideIdListEntry slide) throws IOException, XmlException {
+ PackageRelationshipCollection commentRels;
+ PackagePart slidePart = getSlidePart(slide);
+
+ try {
+ commentRels = slidePart.getRelationshipsByType(XSLFRelation.COMMENTS.getRelation());
+ } catch(InvalidFormatException e) {
+ throw new IllegalStateException(e);
+ }
+
+ if(commentRels.size() == 0) {
+ // No comments for this slide
+ return null;
+ }
+ if(commentRels.size() > 1) {
+ throw new IllegalStateException("Expecting 0 or 1 comments for a slide, but found " + commentRels.size());
+ }
+
+ try {
+ PackagePart cPart = slidePart.getRelatedPart(
+ commentRels.getRelationship(0)
+ );
+ CmLstDocument commDoc =
+ CmLstDocument.Factory.parse(cPart.getInputStream(), DEFAULT_XML_OPTIONS);
+ return commDoc.getCmLst();
+ } catch(InvalidFormatException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ /**
+ * Get the document's embedded files.
+ */
+ @Override
+ public List<PackagePart> getAllEmbeddedParts() throws OpenXML4JException {
+ return embedds;
+ }
}
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTable.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTable.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTable.java Sat May 22 20:22:16 2021
@@ -279,50 +279,50 @@ public class XSLFTable extends XSLFGraph
@SuppressWarnings("unused")
public void mergeCells(int firstRow, int lastRow, int firstCol, int lastCol) {
- if(firstRow > lastRow) {
- throw new IllegalArgumentException(
- "Cannot merge, first row > last row : "
- + firstRow + " > " + lastRow
- );
- }
-
- if(firstCol > lastCol) {
- throw new IllegalArgumentException(
- "Cannot merge, first column > last column : "
- + firstCol + " > " + lastCol
- );
- }
-
- int rowSpan = (lastRow - firstRow) + 1;
- boolean mergeRowRequired = rowSpan > 1;
-
- int colSpan = (lastCol - firstCol) + 1;
- boolean mergeColumnRequired = colSpan > 1;
-
- for(int i = firstRow; i <= lastRow; i++) {
-
- XSLFTableRow row = _rows.get(i);
-
- for(int colPos = firstCol; colPos <= lastCol; colPos++) {
-
- XSLFTableCell cell = row.getCells().get(colPos);
-
- if(mergeRowRequired) {
- if(i == firstRow) {
- cell.setRowSpan(rowSpan);
- } else {
- cell.setVMerge();
- }
- }
- if(mergeColumnRequired) {
- if(colPos == firstCol) {
- cell.setGridSpan(colSpan);
- } else {
- cell.setHMerge();
- }
- }
- }
- }
+ if(firstRow > lastRow) {
+ throw new IllegalArgumentException(
+ "Cannot merge, first row > last row : "
+ + firstRow + " > " + lastRow
+ );
+ }
+
+ if(firstCol > lastCol) {
+ throw new IllegalArgumentException(
+ "Cannot merge, first column > last column : "
+ + firstCol + " > " + lastCol
+ );
+ }
+
+ int rowSpan = (lastRow - firstRow) + 1;
+ boolean mergeRowRequired = rowSpan > 1;
+
+ int colSpan = (lastCol - firstCol) + 1;
+ boolean mergeColumnRequired = colSpan > 1;
+
+ for(int i = firstRow; i <= lastRow; i++) {
+
+ XSLFTableRow row = _rows.get(i);
+
+ for(int colPos = firstCol; colPos <= lastCol; colPos++) {
+
+ XSLFTableCell cell = row.getCells().get(colPos);
+
+ if(mergeRowRequired) {
+ if(i == firstRow) {
+ cell.setRowSpan(rowSpan);
+ } else {
+ cell.setVMerge();
+ }
+ }
+ if(mergeColumnRequired) {
+ if(colPos == firstCol) {
+ cell.setGridSpan(colSpan);
+ } else {
+ cell.setHMerge();
+ }
+ }
+ }
+ }
}
/**
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java Sat May 22 20:22:16 2021
@@ -717,18 +717,18 @@ public class XSLFTextParagraph implement
try {
cur.push();
if ((cur.toChild(nsPML, "txStyles") && cur.toChild(nsPML, defaultStyleSelector)) ||
- (cur.pop() && cur.toChild(nsPML, "notesStyle"))) {
+ (cur.pop() && cur.toChild(nsPML, "notesStyle"))) {
while (level >= 0) {
cur.push();
- if (cur.toChild(XSLFRelation.NS_DRAWINGML, "lvl" +(level+1)+ "pPr")) {
- return (CTTextParagraphProperties)cur.getObject();
- }
- cur.pop();
- level--;
+ if (cur.toChild(XSLFRelation.NS_DRAWINGML, "lvl" +(level+1)+ "pPr")) {
+ return (CTTextParagraphProperties)cur.getObject();
+ }
+ cur.pop();
+ level--;
}
}
} finally {
- cur.dispose();
+ cur.dispose();
}
}
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTheme.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTheme.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTheme.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTheme.java Sat May 22 20:22:16 2021
@@ -87,7 +87,7 @@ public class XSLFTheme extends POIXMLDoc
public CTColor getCTColor(String name) {
CTBaseStyles elems = _theme.getThemeElements();
CTColorScheme scheme = (elems == null) ? null : elems.getClrScheme();
- return getMapColor(name, scheme);
+ return getMapColor(name, scheme);
}
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/XLSBUnsupportedException.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/XLSBUnsupportedException.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/XLSBUnsupportedException.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/XLSBUnsupportedException.java Sat May 22 20:22:16 2021
@@ -28,6 +28,6 @@ public class XLSBUnsupportedException ex
public static final String MESSAGE = ".XLSB Binary Workbooks are not supported";
public XLSBUnsupportedException() {
- super(MESSAGE);
- }
+ super(MESSAGE);
+ }
}
\ No newline at end of file
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java Sat May 22 20:22:16 2021
@@ -461,14 +461,14 @@ public class XSSFExportToXml implements
return indexMap.getOrDefault(withPath, -1);
}
- private Node getNameOrRefElement(Node node) {
- Node returnNode = node.getAttributes().getNamedItem("ref");
+ private Node getNameOrRefElement(Node node) {
+ Node returnNode = node.getAttributes().getNamedItem("ref");
if(returnNode != null) {
return returnNode;
- }
-
+ }
+
return node.getAttributes().getNamedItem("name");
- }
+ }
private Node getComplexTypeForElement(String elementName,Node xmlSchema,Node localComplexTypeRootNode) {
String elementNameWithoutNamespace = removeNamespace(elementName);
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/MapInfo.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/MapInfo.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/MapInfo.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/MapInfo.java Sat May 22 20:22:16 2021
@@ -48,40 +48,40 @@ import org.openxmlformats.schemas.spread
public class MapInfo extends POIXMLDocumentPart {
- private CTMapInfo mapInfo;
+ private CTMapInfo mapInfo;
- private Map<Integer, XSSFMap> maps ;
+ private Map<Integer, XSSFMap> maps ;
- public MapInfo() {
- super();
- mapInfo = CTMapInfo.Factory.newInstance();
+ public MapInfo() {
+ super();
+ mapInfo = CTMapInfo.Factory.newInstance();
- }
+ }
- /**
+ /**
* @since POI 3.14-Beta1
*/
- public MapInfo(PackagePart part) throws IOException {
- super(part);
- readFrom(part.getInputStream());
+ public MapInfo(PackagePart part) throws IOException {
+ super(part);
+ readFrom(part.getInputStream());
}
- public void readFrom(InputStream is) throws IOException {
- try {
- MapInfoDocument doc = MapInfoDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
- mapInfo = doc.getMapInfo();
+ public void readFrom(InputStream is) throws IOException {
+ try {
+ MapInfoDocument doc = MapInfoDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
+ mapInfo = doc.getMapInfo();
maps= new HashMap<>();
for(CTMap map :mapInfo.getMapArray()){
maps.put((int)map.getID(), new XSSFMap(map,this));
}
- } catch (XmlException e) {
- throw new IOException(e.getLocalizedMessage());
- }
- }
+ } catch (XmlException e) {
+ throw new IOException(e.getLocalizedMessage());
+ }
+ }
- /**
+ /**
* Returns the parent XSSFWorkbook
*
* @return the parent XSSFWorkbook
@@ -90,70 +90,70 @@ public class MapInfo extends POIXMLDocum
return (XSSFWorkbook)getParent();
}
- /**
- *
- * @return the internal data object
- */
- public CTMapInfo getCTMapInfo(){
- return mapInfo;
-
- }
-
- /**
- * Gets the
- * @param schemaId the schema ID
- * @return CTSchema by it's ID
- */
- public CTSchema getCTSchemaById(String schemaId){
- CTSchema xmlSchema = null;
-
- for(CTSchema schema: mapInfo.getSchemaArray()){
- if(schema.getID().equals(schemaId)){
- xmlSchema = schema;
- break;
- }
- }
- return xmlSchema;
- }
-
-
- public XSSFMap getXSSFMapById(int id){
- return maps.get(id);
- }
-
- public XSSFMap getXSSFMapByName(String name){
-
- XSSFMap matchedMap = null;
-
- for(XSSFMap map :maps.values()){
- if(map.getCtMap().getName()!=null && map.getCtMap().getName().equals(name)){
- matchedMap = map;
- }
- }
-
- return matchedMap;
- }
-
- /**
- *
- * @return all the mappings configured in this document
- */
- public Collection<XSSFMap> getAllXSSFMaps(){
- return maps.values();
- }
-
- protected void writeTo(OutputStream out) throws IOException {
- MapInfoDocument doc = MapInfoDocument.Factory.newInstance();
- doc.setMapInfo(mapInfo);
- doc.save(out, DEFAULT_XML_OPTIONS);
- }
-
- @Override
- protected void commit() throws IOException {
- PackagePart part = getPackagePart();
- OutputStream out = part.getOutputStream();
- writeTo(out);
- out.close();
- }
+ /**
+ *
+ * @return the internal data object
+ */
+ public CTMapInfo getCTMapInfo(){
+ return mapInfo;
+
+ }
+
+ /**
+ * Gets the
+ * @param schemaId the schema ID
+ * @return CTSchema by it's ID
+ */
+ public CTSchema getCTSchemaById(String schemaId){
+ CTSchema xmlSchema = null;
+
+ for(CTSchema schema: mapInfo.getSchemaArray()){
+ if(schema.getID().equals(schemaId)){
+ xmlSchema = schema;
+ break;
+ }
+ }
+ return xmlSchema;
+ }
+
+
+ public XSSFMap getXSSFMapById(int id){
+ return maps.get(id);
+ }
+
+ public XSSFMap getXSSFMapByName(String name){
+
+ XSSFMap matchedMap = null;
+
+ for(XSSFMap map :maps.values()){
+ if(map.getCtMap().getName()!=null && map.getCtMap().getName().equals(name)){
+ matchedMap = map;
+ }
+ }
+
+ return matchedMap;
+ }
+
+ /**
+ *
+ * @return all the mappings configured in this document
+ */
+ public Collection<XSSFMap> getAllXSSFMaps(){
+ return maps.values();
+ }
+
+ protected void writeTo(OutputStream out) throws IOException {
+ MapInfoDocument doc = MapInfoDocument.Factory.newInstance();
+ doc.setMapInfo(mapInfo);
+ doc.save(out, DEFAULT_XML_OPTIONS);
+ }
+
+ @Override
+ protected void commit() throws IOException {
+ PackagePart part = getPackagePart();
+ OutputStream out = part.getOutputStream();
+ writeTo(out);
+ out.close();
+ }
}
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/SingleXmlCells.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/SingleXmlCells.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/SingleXmlCells.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/SingleXmlCells.java Sat May 22 20:22:16 2021
@@ -43,63 +43,63 @@ import org.openxmlformats.schemas.spread
public class SingleXmlCells extends POIXMLDocumentPart {
- private CTSingleXmlCells singleXMLCells;
+ private CTSingleXmlCells singleXMLCells;
- public SingleXmlCells() {
- super();
- singleXMLCells = CTSingleXmlCells.Factory.newInstance();
-
- }
-
- /**
- * @since POI 3.14-Beta1
- */
- public SingleXmlCells(PackagePart part) throws IOException {
- super(part);
- readFrom(part.getInputStream());
- }
-
- public void readFrom(InputStream is) throws IOException {
- try {
- SingleXmlCellsDocument doc = SingleXmlCellsDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
- singleXMLCells = doc.getSingleXmlCells();
- } catch (XmlException e) {
- throw new IOException(e.getLocalizedMessage());
- }
- }
-
- public XSSFSheet getXSSFSheet(){
- return (XSSFSheet) getParent();
- }
-
- protected void writeTo(OutputStream out) throws IOException {
- SingleXmlCellsDocument doc = SingleXmlCellsDocument.Factory.newInstance();
- doc.setSingleXmlCells(singleXMLCells);
- doc.save(out, DEFAULT_XML_OPTIONS);
- }
-
- @Override
- protected void commit() throws IOException {
- PackagePart part = getPackagePart();
- OutputStream out = part.getOutputStream();
- writeTo(out);
- out.close();
- }
-
- public CTSingleXmlCells getCTSingleXMLCells(){
- return singleXMLCells;
- }
-
- /**
- *
- * @return all the SimpleXmlCell contained in this SingleXmlCells element
- */
- public List<XSSFSingleXmlCell> getAllSimpleXmlCell(){
- List<XSSFSingleXmlCell> list = new Vector<>();
-
- for(CTSingleXmlCell singleXmlCell: singleXMLCells.getSingleXmlCellArray()){
- list.add(new XSSFSingleXmlCell(singleXmlCell,this));
- }
- return list;
- }
+ public SingleXmlCells() {
+ super();
+ singleXMLCells = CTSingleXmlCells.Factory.newInstance();
+
+ }
+
+ /**
+ * @since POI 3.14-Beta1
+ */
+ public SingleXmlCells(PackagePart part) throws IOException {
+ super(part);
+ readFrom(part.getInputStream());
+ }
+
+ public void readFrom(InputStream is) throws IOException {
+ try {
+ SingleXmlCellsDocument doc = SingleXmlCellsDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
+ singleXMLCells = doc.getSingleXmlCells();
+ } catch (XmlException e) {
+ throw new IOException(e.getLocalizedMessage());
+ }
+ }
+
+ public XSSFSheet getXSSFSheet(){
+ return (XSSFSheet) getParent();
+ }
+
+ protected void writeTo(OutputStream out) throws IOException {
+ SingleXmlCellsDocument doc = SingleXmlCellsDocument.Factory.newInstance();
+ doc.setSingleXmlCells(singleXMLCells);
+ doc.save(out, DEFAULT_XML_OPTIONS);
+ }
+
+ @Override
+ protected void commit() throws IOException {
+ PackagePart part = getPackagePart();
+ OutputStream out = part.getOutputStream();
+ writeTo(out);
+ out.close();
+ }
+
+ public CTSingleXmlCells getCTSingleXMLCells(){
+ return singleXMLCells;
+ }
+
+ /**
+ *
+ * @return all the SimpleXmlCell contained in this SingleXmlCells element
+ */
+ public List<XSSFSingleXmlCell> getAllSimpleXmlCell(){
+ List<XSSFSingleXmlCell> list = new Vector<>();
+
+ for(CTSingleXmlCell singleXmlCell: singleXMLCells.getSingleXmlCellArray()){
+ list.add(new XSSFSingleXmlCell(singleXmlCell,this));
+ }
+ return list;
+ }
}
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/GZIPSheetDataWriter.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/GZIPSheetDataWriter.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/GZIPSheetDataWriter.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/GZIPSheetDataWriter.java Sat May 22 20:22:16 2021
@@ -39,11 +39,11 @@ public class GZIPSheetDataWriter extends
public GZIPSheetDataWriter() throws IOException {
super();
}
-
- /**
+
+ /**
* @param sharedStringsTable the shared strings table, or null if inline text is used
*/
- public GZIPSheetDataWriter(SharedStringsTable sharedStringsTable) throws IOException {
+ public GZIPSheetDataWriter(SharedStringsTable sharedStringsTable) throws IOException {
super(sharedStringsTable);
}
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java Sat May 22 20:22:16 2021
@@ -113,8 +113,8 @@ public final class SXSSFFormulaEvaluator
int lastFlushedRowNum = ((SXSSFSheet) sheet).getLastFlushedRowNum();
if (lastFlushedRowNum > -1) {
if (!skipOutOfWindow) {
- throw new RowFlushedException(0, lastFlushedRowNum);
- }
+ throw new RowFlushedException(0, lastFlushedRowNum);
+ }
LOG.atInfo().log("Rows up to {} have already been flushed, skipping", box(lastFlushedRowNum));
}
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFPicture.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFPicture.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFPicture.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFPicture.java Sat May 22 20:22:16 2021
@@ -200,7 +200,7 @@ public final class SXSSFPicture implemen
private float getRowHeightInPixels(int rowIndex) {
// THE FOLLOWING THREE LINES ARE THE MAIN CHANGE compared to the non-streaming version: use the SXSSF sheet,
- // not the XSSF sheet (which never contais rows when using SXSSF)
+ // not the XSSF sheet (which never contais rows when using SXSSF)
XSSFSheet xssfSheet = getSheet();
SXSSFSheet sxSheet = _wb.getSXSSFSheet(xssfSheet);
Sheet sheet = sxSheet == null ? xssfSheet : sxSheet;
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/TextFontAlign.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/TextFontAlign.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/TextFontAlign.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/TextFontAlign.java Sat May 22 20:22:16 2021
@@ -22,10 +22,10 @@ package org.apache.poi.xssf.usermodel;
* Specified a list of text font alignment types
*/
public enum TextFontAlign {
- /**
- * Automatic alignment
- */
- AUTO,
+ /**
+ * Automatic alignment
+ */
+ AUTO,
/**
* Align text to the top.
*/
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDataValidationConstraint.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDataValidationConstraint.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDataValidationConstraint.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDataValidationConstraint.java Sat May 22 20:22:16 2021
@@ -27,227 +27,227 @@ public class XSSFDataValidationConstrain
/**
* Excel validation constraints with static lists are delimited with optional whitespace and the Windows List Separator,
* which is typically comma, but can be changed by users. POI will just assume comma.
- * In addition, Excel validation with static lists has a maximum size of 255 characters, including separators and excluding quotes.
+ * In addition, Excel validation with static lists has a maximum size of 255 characters, including separators and excluding quotes.
*/
private static final String LIST_SEPARATOR = ",";
private static final Pattern LIST_SPLIT_REGEX = Pattern.compile("\\s*" + LIST_SEPARATOR + "\\s*");
private static final String QUOTE = "\"";
- private static final int MAX_EXPLICIT_LIST_LENGTH = 257;
+ private static final int MAX_EXPLICIT_LIST_LENGTH = 257;
- private String formula1;
- private String formula2;
- private final int validationType;
- private int operator = -1;
- private String[] explicitListOfValues;
-
- /**
- * list literal constructor
- */
- public XSSFDataValidationConstraint(String[] explicitListOfValues) {
- if( explicitListOfValues==null || explicitListOfValues.length==0) {
- throw new IllegalArgumentException("List validation with explicit values must specify at least one value");
- }
- this.validationType = ValidationType.LIST;
- setExplicitListValues(explicitListOfValues);
-
- validate();
- }
-
- public XSSFDataValidationConstraint(int validationType, String formula1) {
- super();
- setFormula1(formula1);
- this.validationType = validationType;
- validate();
- }
-
-
-
- public XSSFDataValidationConstraint(int validationType, int operator, String formula1) {
- super();
- setFormula1(formula1);
- this.validationType = validationType;
- this.operator = operator;
- validate();
- }
-
- /**
- * This is the constructor called using the OOXML raw data. Excel overloads formula1 to also encode explicit value lists,
- * so this constructor has to check for and parse that syntax.
- * @param formula1 Overloaded: formula1 or list of explicit values
- * @param formula2 (formula1 is a list of explicit values, this is ignored: use {@code null})
- */
- public XSSFDataValidationConstraint(int validationType, int operator, String formula1, String formula2) {
- super();
- //removes leading equals sign if present
- setFormula1(formula1);
- setFormula2(formula2);
- this.validationType = validationType;
- this.operator = operator;
-
- validate();
-
- //FIXME: Need to confirm if this is not a formula.
- // empirical testing shows Excel saves explicit lists surrounded by double quotes,
- // range formula expressions can't start with quotes (I think - anyone have a creative counter example?)
- if ( ValidationType.LIST == validationType
- && this.formula1 != null
- && isQuoted(this.formula1) ) {
- explicitListOfValues = LIST_SPLIT_REGEX.split(unquote(this.formula1));
- }
- }
-
- /* (non-Javadoc)
- * @see org.apache.poi.ss.usermodel.DataValidationConstraint#getExplicitListValues()
- */
- @Override
- public String[] getExplicitListValues() {
- return explicitListOfValues;
- }
-
- /* (non-Javadoc)
- * @see org.apache.poi.ss.usermodel.DataValidationConstraint#getFormula1()
- */
- @Override
- public String getFormula1() {
- return formula1;
- }
-
- /* (non-Javadoc)
- * @see org.apache.poi.ss.usermodel.DataValidationConstraint#getFormula2()
- */
- @Override
- public String getFormula2() {
- return formula2;
- }
-
- /* (non-Javadoc)
- * @see org.apache.poi.ss.usermodel.DataValidationConstraint#getOperator()
- */
- @Override
- public int getOperator() {
- return operator;
- }
-
- /* (non-Javadoc)
- * @see org.apache.poi.ss.usermodel.DataValidationConstraint#getValidationType()
- */
- @Override
- public int getValidationType() {
- return validationType;
- }
-
- /* (non-Javadoc)
- * @see org.apache.poi.ss.usermodel.DataValidationConstraint#setExplicitListValues(java.lang.String[])
- */
- @Override
- public void setExplicitListValues(String[] explicitListValues) {
- this.explicitListOfValues = explicitListValues;
-
- // for OOXML we need to set formula1 to the quoted csv list of values (doesn't appear documented, but that's where Excel puts its lists)
- // further, Excel has no escaping for commas in explicit lists, so we don't need to worry about that.
- if ( explicitListOfValues!=null && explicitListOfValues.length > 0 ) {
- StringBuilder builder = new StringBuilder(QUOTE);
- for (String string : explicitListValues) {
- if (builder.length() > 1) {
- builder.append(LIST_SEPARATOR);
- }
- builder.append(string);
- }
- builder.append(QUOTE);
- setFormula1(builder.toString());
- }
- }
-
- /* (non-Javadoc)
- * @see org.apache.poi.ss.usermodel.DataValidationConstraint#setFormula1(java.lang.String)
- */
- @Override
- public void setFormula1(String formula1) {
- this.formula1 = removeLeadingEquals(formula1);
- }
-
- protected static String removeLeadingEquals(String formula1) {
- return isFormulaEmpty(formula1) ? formula1 : formula1.charAt(0)=='=' ? formula1.substring(1) : formula1;
- }
- private static boolean isQuoted(String s) {
- return s.startsWith(QUOTE) && s.endsWith(QUOTE);
- }
- private static String unquote(String s) {
- // removes leading and trailing quotes from a quoted string
- if (isQuoted(s)) {
- return s.substring(1, s.length()-1);
- }
- return s;
- }
- protected static boolean isFormulaEmpty(String formula1) {
- return formula1 == null || formula1.trim().length()==0;
- }
-
- /* (non-Javadoc)
- * @see org.apache.poi.ss.usermodel.DataValidationConstraint#setFormula2(java.lang.String)
- */
- @Override
- public void setFormula2(String formula2) {
- this.formula2 = removeLeadingEquals(formula2);
- }
-
- /* (non-Javadoc)
- * @see org.apache.poi.ss.usermodel.DataValidationConstraint#setOperator(int)
- */
- @Override
- public void setOperator(int operator) {
- this.operator = operator;
- }
-
- public void validate() {
- if (validationType==ValidationType.ANY) {
- return;
- }
-
- if (validationType==ValidationType.LIST ) {
- if (isFormulaEmpty(formula1)) {
- throw new IllegalArgumentException("A valid formula or a list of values must be specified for list validation.");
- }
- if(formula1.length() > MAX_EXPLICIT_LIST_LENGTH) {
- throw new IllegalArgumentException("A valid formula or a list of values must be less than or equal to 255 characters (including separators).");
- }
- } else {
- if( isFormulaEmpty(formula1) ) {
- throw new IllegalArgumentException("Formula is not specified. Formula is required for all validation types except explicit list validation.");
- }
-
- if( validationType!= ValidationType.FORMULA ) {
- if (operator==-1) {
- throw new IllegalArgumentException("This validation type requires an operator to be specified.");
- } else if (( operator==OperatorType.BETWEEN || operator==OperatorType.NOT_BETWEEN) && isFormulaEmpty(formula2)) {
- throw new IllegalArgumentException("Between and not between comparisons require two formulae to be specified.");
- }
- }
- }
- }
-
-
- public String prettyPrint() {
- StringBuilder builder = new StringBuilder();
- STDataValidationType.Enum vt = XSSFDataValidation.validationTypeMappings.get(validationType);
- Enum ot = XSSFDataValidation.operatorTypeMappings.get(operator);
- builder.append(vt);
- builder.append(' ');
- if (validationType!=ValidationType.ANY) {
- if (validationType != ValidationType.LIST
- && validationType != ValidationType.FORMULA) {
- builder.append(LIST_SEPARATOR).append(ot).append(", ");
- }
- final String NOQUOTE = "";
- if (validationType == ValidationType.LIST && explicitListOfValues != null) {
- builder.append(NOQUOTE).append(Arrays.asList(explicitListOfValues)).append(NOQUOTE).append(' ');
- } else {
- builder.append(NOQUOTE).append(formula1).append(NOQUOTE).append(' ');
- }
- if (formula2 != null) {
- builder.append(NOQUOTE).append(formula2).append(NOQUOTE).append(' ');
- }
- }
- return builder.toString();
- }
+ private String formula1;
+ private String formula2;
+ private final int validationType;
+ private int operator = -1;
+ private String[] explicitListOfValues;
+
+ /**
+ * list literal constructor
+ */
+ public XSSFDataValidationConstraint(String[] explicitListOfValues) {
+ if( explicitListOfValues==null || explicitListOfValues.length==0) {
+ throw new IllegalArgumentException("List validation with explicit values must specify at least one value");
+ }
+ this.validationType = ValidationType.LIST;
+ setExplicitListValues(explicitListOfValues);
+
+ validate();
+ }
+
+ public XSSFDataValidationConstraint(int validationType, String formula1) {
+ super();
+ setFormula1(formula1);
+ this.validationType = validationType;
+ validate();
+ }
+
+
+
+ public XSSFDataValidationConstraint(int validationType, int operator, String formula1) {
+ super();
+ setFormula1(formula1);
+ this.validationType = validationType;
+ this.operator = operator;
+ validate();
+ }
+
+ /**
+ * This is the constructor called using the OOXML raw data. Excel overloads formula1 to also encode explicit value lists,
+ * so this constructor has to check for and parse that syntax.
+ * @param formula1 Overloaded: formula1 or list of explicit values
+ * @param formula2 (formula1 is a list of explicit values, this is ignored: use {@code null})
+ */
+ public XSSFDataValidationConstraint(int validationType, int operator, String formula1, String formula2) {
+ super();
+ //removes leading equals sign if present
+ setFormula1(formula1);
+ setFormula2(formula2);
+ this.validationType = validationType;
+ this.operator = operator;
+
+ validate();
+
+ //FIXME: Need to confirm if this is not a formula.
+ // empirical testing shows Excel saves explicit lists surrounded by double quotes,
+ // range formula expressions can't start with quotes (I think - anyone have a creative counter example?)
+ if ( ValidationType.LIST == validationType
+ && this.formula1 != null
+ && isQuoted(this.formula1) ) {
+ explicitListOfValues = LIST_SPLIT_REGEX.split(unquote(this.formula1));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.poi.ss.usermodel.DataValidationConstraint#getExplicitListValues()
+ */
+ @Override
+ public String[] getExplicitListValues() {
+ return explicitListOfValues;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.poi.ss.usermodel.DataValidationConstraint#getFormula1()
+ */
+ @Override
+ public String getFormula1() {
+ return formula1;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.poi.ss.usermodel.DataValidationConstraint#getFormula2()
+ */
+ @Override
+ public String getFormula2() {
+ return formula2;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.poi.ss.usermodel.DataValidationConstraint#getOperator()
+ */
+ @Override
+ public int getOperator() {
+ return operator;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.poi.ss.usermodel.DataValidationConstraint#getValidationType()
+ */
+ @Override
+ public int getValidationType() {
+ return validationType;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.poi.ss.usermodel.DataValidationConstraint#setExplicitListValues(java.lang.String[])
+ */
+ @Override
+ public void setExplicitListValues(String[] explicitListValues) {
+ this.explicitListOfValues = explicitListValues;
+
+ // for OOXML we need to set formula1 to the quoted csv list of values (doesn't appear documented, but that's where Excel puts its lists)
+ // further, Excel has no escaping for commas in explicit lists, so we don't need to worry about that.
+ if ( explicitListOfValues!=null && explicitListOfValues.length > 0 ) {
+ StringBuilder builder = new StringBuilder(QUOTE);
+ for (String string : explicitListValues) {
+ if (builder.length() > 1) {
+ builder.append(LIST_SEPARATOR);
+ }
+ builder.append(string);
+ }
+ builder.append(QUOTE);
+ setFormula1(builder.toString());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.poi.ss.usermodel.DataValidationConstraint#setFormula1(java.lang.String)
+ */
+ @Override
+ public void setFormula1(String formula1) {
+ this.formula1 = removeLeadingEquals(formula1);
+ }
+
+ protected static String removeLeadingEquals(String formula1) {
+ return isFormulaEmpty(formula1) ? formula1 : formula1.charAt(0)=='=' ? formula1.substring(1) : formula1;
+ }
+ private static boolean isQuoted(String s) {
+ return s.startsWith(QUOTE) && s.endsWith(QUOTE);
+ }
+ private static String unquote(String s) {
+ // removes leading and trailing quotes from a quoted string
+ if (isQuoted(s)) {
+ return s.substring(1, s.length()-1);
+ }
+ return s;
+ }
+ protected static boolean isFormulaEmpty(String formula1) {
+ return formula1 == null || formula1.trim().length()==0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.poi.ss.usermodel.DataValidationConstraint#setFormula2(java.lang.String)
+ */
+ @Override
+ public void setFormula2(String formula2) {
+ this.formula2 = removeLeadingEquals(formula2);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.poi.ss.usermodel.DataValidationConstraint#setOperator(int)
+ */
+ @Override
+ public void setOperator(int operator) {
+ this.operator = operator;
+ }
+
+ public void validate() {
+ if (validationType==ValidationType.ANY) {
+ return;
+ }
+
+ if (validationType==ValidationType.LIST ) {
+ if (isFormulaEmpty(formula1)) {
+ throw new IllegalArgumentException("A valid formula or a list of values must be specified for list validation.");
+ }
+ if(formula1.length() > MAX_EXPLICIT_LIST_LENGTH) {
+ throw new IllegalArgumentException("A valid formula or a list of values must be less than or equal to 255 characters (including separators).");
+ }
+ } else {
+ if( isFormulaEmpty(formula1) ) {
+ throw new IllegalArgumentException("Formula is not specified. Formula is required for all validation types except explicit list validation.");
+ }
+
+ if( validationType!= ValidationType.FORMULA ) {
+ if (operator==-1) {
+ throw new IllegalArgumentException("This validation type requires an operator to be specified.");
+ } else if (( operator==OperatorType.BETWEEN || operator==OperatorType.NOT_BETWEEN) && isFormulaEmpty(formula2)) {
+ throw new IllegalArgumentException("Between and not between comparisons require two formulae to be specified.");
+ }
+ }
+ }
+ }
+
+
+ public String prettyPrint() {
+ StringBuilder builder = new StringBuilder();
+ STDataValidationType.Enum vt = XSSFDataValidation.validationTypeMappings.get(validationType);
+ Enum ot = XSSFDataValidation.operatorTypeMappings.get(operator);
+ builder.append(vt);
+ builder.append(' ');
+ if (validationType!=ValidationType.ANY) {
+ if (validationType != ValidationType.LIST
+ && validationType != ValidationType.FORMULA) {
+ builder.append(LIST_SEPARATOR).append(ot).append(", ");
+ }
+ final String NOQUOTE = "";
+ if (validationType == ValidationType.LIST && explicitListOfValues != null) {
+ builder.append(NOQUOTE).append(Arrays.asList(explicitListOfValues)).append(NOQUOTE).append(' ');
+ } else {
+ builder.append(NOQUOTE).append(formula1).append(NOQUOTE).append(' ');
+ }
+ if (formula2 != null) {
+ builder.append(NOQUOTE).append(formula2).append(NOQUOTE).append(' ');
+ }
+ }
+ return builder.toString();
+ }
}
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDataValidationHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDataValidationHelper.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDataValidationHelper.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDataValidationHelper.java Sat May 22 20:22:16 2021
@@ -31,143 +31,143 @@ import org.openxmlformats.schemas.spread
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STDataValidationType;
public class XSSFDataValidationHelper implements DataValidationHelper {
- // Findbugs: URF_UNREAD_FIELD. Do not delete without understanding how this class works.
- //private XSSFSheet xssfSheet;
+ // Findbugs: URF_UNREAD_FIELD. Do not delete without understanding how this class works.
+ //private XSSFSheet xssfSheet;
public XSSFDataValidationHelper(XSSFSheet xssfSheet) {
- super();
- // Findbugs: URF_UNREAD_FIELD. Do not delete without understanding how this class works.
- //this.xssfSheet = xssfSheet;
- }
-
- /* (non-Javadoc)
- * @see org.apache.poi.ss.usermodel.DataValidationHelper#createDateConstraint(int, java.lang.String, java.lang.String, java.lang.String)
- */
- public DataValidationConstraint createDateConstraint(int operatorType, String formula1, String formula2, String dateFormat) {
- return new XSSFDataValidationConstraint(ValidationType.DATE, operatorType,formula1, formula2);
- }
-
- /* (non-Javadoc)
- * @see org.apache.poi.ss.usermodel.DataValidationHelper#createDecimalConstraint(int, java.lang.String, java.lang.String)
- */
- public DataValidationConstraint createDecimalConstraint(int operatorType, String formula1, String formula2) {
- return new XSSFDataValidationConstraint(ValidationType.DECIMAL, operatorType,formula1, formula2);
- }
-
- /* (non-Javadoc)
- * @see org.apache.poi.ss.usermodel.DataValidationHelper#createExplicitListConstraint(java.lang.String[])
- */
- public DataValidationConstraint createExplicitListConstraint(String[] listOfValues) {
- return new XSSFDataValidationConstraint(listOfValues);
- }
-
- /* (non-Javadoc)
- * @see org.apache.poi.ss.usermodel.DataValidationHelper#createFormulaListConstraint(java.lang.String)
- */
- public DataValidationConstraint createFormulaListConstraint(String listFormula) {
- return new XSSFDataValidationConstraint(ValidationType.LIST, listFormula);
- }
-
-
-
- public DataValidationConstraint createNumericConstraint(int validationType, int operatorType, String formula1, String formula2) {
- if( validationType==ValidationType.INTEGER) {
- return createIntegerConstraint(operatorType, formula1, formula2);
- } else if ( validationType==ValidationType.DECIMAL) {
- return createDecimalConstraint(operatorType, formula1, formula2);
- } else if ( validationType==ValidationType.TEXT_LENGTH) {
- return createTextLengthConstraint(operatorType, formula1, formula2);
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.apache.poi.ss.usermodel.DataValidationHelper#createIntegerConstraint(int, java.lang.String, java.lang.String)
- */
- public DataValidationConstraint createIntegerConstraint(int operatorType, String formula1, String formula2) {
- return new XSSFDataValidationConstraint(ValidationType.INTEGER, operatorType,formula1,formula2);
- }
-
- /* (non-Javadoc)
- * @see org.apache.poi.ss.usermodel.DataValidationHelper#createTextLengthConstraint(int, java.lang.String, java.lang.String)
- */
- public DataValidationConstraint createTextLengthConstraint(int operatorType, String formula1, String formula2) {
- return new XSSFDataValidationConstraint(ValidationType.TEXT_LENGTH, operatorType,formula1,formula2);
- }
-
- /* (non-Javadoc)
- * @see org.apache.poi.ss.usermodel.DataValidationHelper#createTimeConstraint(int, java.lang.String, java.lang.String, java.lang.String)
- */
- public DataValidationConstraint createTimeConstraint(int operatorType, String formula1, String formula2) {
- return new XSSFDataValidationConstraint(ValidationType.TIME, operatorType,formula1,formula2);
- }
-
- public DataValidationConstraint createCustomConstraint(String formula) {
- return new XSSFDataValidationConstraint(ValidationType.FORMULA, formula);
- }
-
- /* (non-Javadoc)
- * @see org.apache.poi.ss.usermodel.DataValidationHelper#createValidation(org.apache.poi.ss.usermodel.DataValidationConstraint, org.apache.poi.ss.util.CellRangeAddressList)
- */
- public DataValidation createValidation(DataValidationConstraint constraint, CellRangeAddressList cellRangeAddressList) {
- XSSFDataValidationConstraint dataValidationConstraint = (XSSFDataValidationConstraint)constraint;
- CTDataValidation newDataValidation = CTDataValidation.Factory.newInstance();
-
- int validationType = constraint.getValidationType();
- switch(validationType) {
- case DataValidationConstraint.ValidationType.LIST:
- newDataValidation.setType(STDataValidationType.LIST);
- newDataValidation.setFormula1(constraint.getFormula1());
- break;
- case DataValidationConstraint.ValidationType.ANY:
- newDataValidation.setType(STDataValidationType.NONE);
- break;
- case DataValidationConstraint.ValidationType.TEXT_LENGTH:
- newDataValidation.setType(STDataValidationType.TEXT_LENGTH);
- break;
- case DataValidationConstraint.ValidationType.DATE:
- newDataValidation.setType(STDataValidationType.DATE);
- break;
- case DataValidationConstraint.ValidationType.INTEGER:
- newDataValidation.setType(STDataValidationType.WHOLE);
- break;
- case DataValidationConstraint.ValidationType.DECIMAL:
- newDataValidation.setType(STDataValidationType.DECIMAL);
- break;
- case DataValidationConstraint.ValidationType.TIME:
- newDataValidation.setType(STDataValidationType.TIME);
- break;
- case DataValidationConstraint.ValidationType.FORMULA:
- newDataValidation.setType(STDataValidationType.CUSTOM);
- break;
- default:
- newDataValidation.setType(STDataValidationType.NONE);
- }
+ super();
+ // Findbugs: URF_UNREAD_FIELD. Do not delete without understanding how this class works.
+ //this.xssfSheet = xssfSheet;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.poi.ss.usermodel.DataValidationHelper#createDateConstraint(int, java.lang.String, java.lang.String, java.lang.String)
+ */
+ public DataValidationConstraint createDateConstraint(int operatorType, String formula1, String formula2, String dateFormat) {
+ return new XSSFDataValidationConstraint(ValidationType.DATE, operatorType,formula1, formula2);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.poi.ss.usermodel.DataValidationHelper#createDecimalConstraint(int, java.lang.String, java.lang.String)
+ */
+ public DataValidationConstraint createDecimalConstraint(int operatorType, String formula1, String formula2) {
+ return new XSSFDataValidationConstraint(ValidationType.DECIMAL, operatorType,formula1, formula2);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.poi.ss.usermodel.DataValidationHelper#createExplicitListConstraint(java.lang.String[])
+ */
+ public DataValidationConstraint createExplicitListConstraint(String[] listOfValues) {
+ return new XSSFDataValidationConstraint(listOfValues);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.poi.ss.usermodel.DataValidationHelper#createFormulaListConstraint(java.lang.String)
+ */
+ public DataValidationConstraint createFormulaListConstraint(String listFormula) {
+ return new XSSFDataValidationConstraint(ValidationType.LIST, listFormula);
+ }
+
+
+
+ public DataValidationConstraint createNumericConstraint(int validationType, int operatorType, String formula1, String formula2) {
+ if( validationType==ValidationType.INTEGER) {
+ return createIntegerConstraint(operatorType, formula1, formula2);
+ } else if ( validationType==ValidationType.DECIMAL) {
+ return createDecimalConstraint(operatorType, formula1, formula2);
+ } else if ( validationType==ValidationType.TEXT_LENGTH) {
+ return createTextLengthConstraint(operatorType, formula1, formula2);
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.poi.ss.usermodel.DataValidationHelper#createIntegerConstraint(int, java.lang.String, java.lang.String)
+ */
+ public DataValidationConstraint createIntegerConstraint(int operatorType, String formula1, String formula2) {
+ return new XSSFDataValidationConstraint(ValidationType.INTEGER, operatorType,formula1,formula2);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.poi.ss.usermodel.DataValidationHelper#createTextLengthConstraint(int, java.lang.String, java.lang.String)
+ */
+ public DataValidationConstraint createTextLengthConstraint(int operatorType, String formula1, String formula2) {
+ return new XSSFDataValidationConstraint(ValidationType.TEXT_LENGTH, operatorType,formula1,formula2);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.poi.ss.usermodel.DataValidationHelper#createTimeConstraint(int, java.lang.String, java.lang.String, java.lang.String)
+ */
+ public DataValidationConstraint createTimeConstraint(int operatorType, String formula1, String formula2) {
+ return new XSSFDataValidationConstraint(ValidationType.TIME, operatorType,formula1,formula2);
+ }
+
+ public DataValidationConstraint createCustomConstraint(String formula) {
+ return new XSSFDataValidationConstraint(ValidationType.FORMULA, formula);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.poi.ss.usermodel.DataValidationHelper#createValidation(org.apache.poi.ss.usermodel.DataValidationConstraint, org.apache.poi.ss.util.CellRangeAddressList)
+ */
+ public DataValidation createValidation(DataValidationConstraint constraint, CellRangeAddressList cellRangeAddressList) {
+ XSSFDataValidationConstraint dataValidationConstraint = (XSSFDataValidationConstraint)constraint;
+ CTDataValidation newDataValidation = CTDataValidation.Factory.newInstance();
+
+ int validationType = constraint.getValidationType();
+ switch(validationType) {
+ case DataValidationConstraint.ValidationType.LIST:
+ newDataValidation.setType(STDataValidationType.LIST);
+ newDataValidation.setFormula1(constraint.getFormula1());
+ break;
+ case DataValidationConstraint.ValidationType.ANY:
+ newDataValidation.setType(STDataValidationType.NONE);
+ break;
+ case DataValidationConstraint.ValidationType.TEXT_LENGTH:
+ newDataValidation.setType(STDataValidationType.TEXT_LENGTH);
+ break;
+ case DataValidationConstraint.ValidationType.DATE:
+ newDataValidation.setType(STDataValidationType.DATE);
+ break;
+ case DataValidationConstraint.ValidationType.INTEGER:
+ newDataValidation.setType(STDataValidationType.WHOLE);
+ break;
+ case DataValidationConstraint.ValidationType.DECIMAL:
+ newDataValidation.setType(STDataValidationType.DECIMAL);
+ break;
+ case DataValidationConstraint.ValidationType.TIME:
+ newDataValidation.setType(STDataValidationType.TIME);
+ break;
+ case DataValidationConstraint.ValidationType.FORMULA:
+ newDataValidation.setType(STDataValidationType.CUSTOM);
+ break;
+ default:
+ newDataValidation.setType(STDataValidationType.NONE);
+ }
- if (validationType!=ValidationType.ANY && validationType!=ValidationType.LIST) {
+ if (validationType!=ValidationType.ANY && validationType!=ValidationType.LIST) {
STDataValidationOperator.Enum op = XSSFDataValidation.operatorTypeMappings.get(constraint.getOperator());
- if(op != null) {
+ if(op != null) {
newDataValidation.setOperator(op);
}
- if (constraint.getFormula1() != null) {
- newDataValidation.setFormula1(constraint.getFormula1());
- }
- if (constraint.getFormula2() != null) {
- newDataValidation.setFormula2(constraint.getFormula2());
- }
- }
-
- CellRangeAddress[] cellRangeAddresses = cellRangeAddressList.getCellRangeAddresses();
- List<String> sqref = new ArrayList<>();
- for (int i = 0; i < cellRangeAddresses.length; i++) {
- CellRangeAddress cellRangeAddress = cellRangeAddresses[i];
- sqref.add(cellRangeAddress.formatAsString());
- }
- newDataValidation.setSqref(sqref);
- newDataValidation.setAllowBlank(true);
- newDataValidation.setErrorStyle(STDataValidationErrorStyle.STOP);
+ if (constraint.getFormula1() != null) {
+ newDataValidation.setFormula1(constraint.getFormula1());
+ }
+ if (constraint.getFormula2() != null) {
+ newDataValidation.setFormula2(constraint.getFormula2());
+ }
+ }
+
+ CellRangeAddress[] cellRangeAddresses = cellRangeAddressList.getCellRangeAddresses();
+ List<String> sqref = new ArrayList<>();
+ for (int i = 0; i < cellRangeAddresses.length; i++) {
+ CellRangeAddress cellRangeAddress = cellRangeAddresses[i];
+ sqref.add(cellRangeAddress.formatAsString());
+ }
+ newDataValidation.setSqref(sqref);
+ newDataValidation.setAllowBlank(true);
+ newDataValidation.setErrorStyle(STDataValidationErrorStyle.STOP);
- return new XSSFDataValidation(dataValidationConstraint,cellRangeAddressList,newDataValidation);
- }
+ return new XSSFDataValidation(dataValidationConstraint,cellRangeAddressList,newDataValidation);
+ }
}
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java Sat May 22 20:22:16 2021
@@ -27,79 +27,79 @@ import org.apache.poi.ss.util.CellRangeA
*/
final class XSSFEvaluationCell implements EvaluationCell {
- private final EvaluationSheet _evalSheet;
- private final XSSFCell _cell;
+ private final EvaluationSheet _evalSheet;
+ private final XSSFCell _cell;
- public XSSFEvaluationCell(XSSFCell cell, XSSFEvaluationSheet evaluationSheet) {
- _cell = cell;
- _evalSheet = evaluationSheet;
- }
+ public XSSFEvaluationCell(XSSFCell cell, XSSFEvaluationSheet evaluationSheet) {
+ _cell = cell;
+ _evalSheet = evaluationSheet;
+ }
- public XSSFEvaluationCell(XSSFCell cell) {
- this(cell, new XSSFEvaluationSheet(cell.getSheet()));
- }
+ public XSSFEvaluationCell(XSSFCell cell) {
+ this(cell, new XSSFEvaluationSheet(cell.getSheet()));
+ }
- @Override
- public Object getIdentityKey() {
- // save memory by just using the cell itself as the identity key
- // Note - this assumes XSSFCell has not overridden hashCode and equals
- return _cell;
- }
+ @Override
+ public Object getIdentityKey() {
+ // save memory by just using the cell itself as the identity key
+ // Note - this assumes XSSFCell has not overridden hashCode and equals
+ return _cell;
+ }
- public XSSFCell getXSSFCell() {
- return _cell;
- }
- @Override
- public boolean getBooleanCellValue() {
- return _cell.getBooleanCellValue();
- }
- /**
- * @return cell type
- */
- @Override
- public CellType getCellType() {
- return _cell.getCellType();
- }
- @Override
- public int getColumnIndex() {
- return _cell.getColumnIndex();
- }
- @Override
- public int getErrorCellValue() {
- return _cell.getErrorCellValue();
- }
- @Override
- public double getNumericCellValue() {
- return _cell.getNumericCellValue();
- }
- @Override
- public int getRowIndex() {
- return _cell.getRowIndex();
- }
- @Override
- public EvaluationSheet getSheet() {
- return _evalSheet;
- }
- @Override
- public String getStringCellValue() {
- return _cell.getRichStringCellValue().getString();
- }
-
- @Override
- public CellRangeAddress getArrayFormulaRange() {
- return _cell.getArrayFormulaRange();
- }
-
- @Override
- public boolean isPartOfArrayFormulaGroup() {
- return _cell.isPartOfArrayFormulaGroup();
- }
-
- /**
- * @return cell type of cached formula result
- */
- @Override
- public CellType getCachedFormulaResultType() {
- return _cell.getCachedFormulaResultType();
- }
+ public XSSFCell getXSSFCell() {
+ return _cell;
+ }
+ @Override
+ public boolean getBooleanCellValue() {
+ return _cell.getBooleanCellValue();
+ }
+ /**
+ * @return cell type
+ */
+ @Override
+ public CellType getCellType() {
+ return _cell.getCellType();
+ }
+ @Override
+ public int getColumnIndex() {
+ return _cell.getColumnIndex();
+ }
+ @Override
+ public int getErrorCellValue() {
+ return _cell.getErrorCellValue();
+ }
+ @Override
+ public double getNumericCellValue() {
+ return _cell.getNumericCellValue();
+ }
+ @Override
+ public int getRowIndex() {
+ return _cell.getRowIndex();
+ }
+ @Override
+ public EvaluationSheet getSheet() {
+ return _evalSheet;
+ }
+ @Override
+ public String getStringCellValue() {
+ return _cell.getRichStringCellValue().getString();
+ }
+
+ @Override
+ public CellRangeAddress getArrayFormulaRange() {
+ return _cell.getArrayFormulaRange();
+ }
+
+ @Override
+ public boolean isPartOfArrayFormulaGroup() {
+ return _cell.isPartOfArrayFormulaGroup();
+ }
+
+ /**
+ * @return cell type of cached formula result
+ */
+ @Override
+ public CellType getCachedFormulaResultType() {
+ return _cell.getCachedFormulaResultType();
+ }
}
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java Sat May 22 20:22:16 2021
@@ -67,14 +67,14 @@ public class XSSFEvenFooter extends XSSF
*/
@Override
public void setText(String text) {
- if(text == null) {
- getHeaderFooter().unsetEvenFooter();
- if (!getHeaderFooter().isSetEvenHeader()) {
- getHeaderFooter().unsetDifferentOddEven();
- }
- } else {
- getHeaderFooter().setEvenFooter(text);
- }
+ if(text == null) {
+ getHeaderFooter().unsetEvenFooter();
+ if (!getHeaderFooter().isSetEvenHeader()) {
+ getHeaderFooter().unsetDifferentOddEven();
+ }
+ } else {
+ getHeaderFooter().setEvenFooter(text);
+ }
}
}
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java Sat May 22 20:22:16 2021
@@ -65,13 +65,13 @@ public class XSSFFirstFooter extends XSS
*/
@Override
public void setText(String text) {
- if(text == null) {
- getHeaderFooter().unsetFirstFooter();
- if (!getHeaderFooter().isSetFirstHeader()) {
- getHeaderFooter().unsetDifferentFirst();
- }
- } else {
- getHeaderFooter().setFirstFooter(text);
- }
+ if(text == null) {
+ getHeaderFooter().unsetFirstFooter();
+ if (!getHeaderFooter().isSetFirstHeader()) {
+ getHeaderFooter().unsetDifferentFirst();
+ }
+ } else {
+ getHeaderFooter().setFirstFooter(text);
+ }
}
}
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java Sat May 22 20:22:16 2021
@@ -63,14 +63,14 @@ public class XSSFFirstHeader extends XSS
*/
@Override
public void setText(String text) {
- if(text == null) {
- getHeaderFooter().unsetFirstHeader();
- if (!getHeaderFooter().isSetFirstFooter()) {
- getHeaderFooter().unsetDifferentFirst();
- }
- } else {
- getHeaderFooter().setFirstHeader(text);
- }
+ if(text == null) {
+ getHeaderFooter().unsetFirstHeader();
+ if (!getHeaderFooter().isSetFirstFooter()) {
+ getHeaderFooter().unsetDifferentFirst();
+ }
+ } else {
+ getHeaderFooter().setFirstHeader(text);
+ }
}
}
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFGraphicFrame.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFGraphicFrame.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFGraphicFrame.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFGraphicFrame.java Sat May 22 20:22:16 2021
@@ -41,21 +41,21 @@ import org.w3c.dom.NodeList;
*/
public final class XSSFGraphicFrame extends XSSFShape {
- private static CTGraphicalObjectFrame prototype;
+ private static CTGraphicalObjectFrame prototype;
- private final CTGraphicalObjectFrame graphicFrame;
+ private final CTGraphicalObjectFrame graphicFrame;
- /**
- * Construct a new XSSFGraphicFrame object.
- *
- * @param drawing the XSSFDrawing that owns this frame
- * @param ctGraphicFrame the XML bean that stores this frame content
- */
- protected XSSFGraphicFrame(XSSFDrawing drawing, CTGraphicalObjectFrame ctGraphicFrame) {
- this.drawing = drawing; // protected field on XSSFShape
- this.graphicFrame = ctGraphicFrame;
- // TODO: there may be a better way to delegate this
- CTGraphicalObjectData graphicData = graphicFrame.getGraphic().getGraphicData();
+ /**
+ * Construct a new XSSFGraphicFrame object.
+ *
+ * @param drawing the XSSFDrawing that owns this frame
+ * @param ctGraphicFrame the XML bean that stores this frame content
+ */
+ protected XSSFGraphicFrame(XSSFDrawing drawing, CTGraphicalObjectFrame ctGraphicFrame) {
+ this.drawing = drawing; // protected field on XSSFShape
+ this.graphicFrame = ctGraphicFrame;
+ // TODO: there may be a better way to delegate this
+ CTGraphicalObjectData graphicData = graphicFrame.getGraphic().getGraphicData();
if (graphicData != null) {
NodeList nodes = graphicData.getDomNode().getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
@@ -71,134 +71,134 @@ public final class XSSFGraphicFrame exte
}
}
}
- }
+ }
- @Internal
- public CTGraphicalObjectFrame getCTGraphicalObjectFrame() {
- return graphicFrame;
- }
-
- /**
- * Initialize default structure of a new graphic frame
- */
- protected static CTGraphicalObjectFrame prototype() {
- if (prototype == null) {
- CTGraphicalObjectFrame graphicFrame = CTGraphicalObjectFrame.Factory.newInstance();
-
- CTGraphicalObjectFrameNonVisual nvGraphic = graphicFrame.addNewNvGraphicFramePr();
- CTNonVisualDrawingProps props = nvGraphic.addNewCNvPr();
- props.setId(0);
- props.setName("Diagramm 1");
- nvGraphic.addNewCNvGraphicFramePr();
-
- CTTransform2D transform = graphicFrame.addNewXfrm();
- CTPositiveSize2D extPoint = transform.addNewExt();
- CTPoint2D offPoint = transform.addNewOff();
-
- extPoint.setCx(0);
- extPoint.setCy(0);
- offPoint.setX(0);
- offPoint.setY(0);
-
- /* CTGraphicalObject graphic = */ graphicFrame.addNewGraphic();
-
- prototype = graphicFrame;
- }
- return prototype;
- }
-
- /**
- * Sets the frame macro.
- */
- public void setMacro(String macro) {
- graphicFrame.setMacro(macro);
- }
-
- /**
- * Sets the frame name.
- */
- public void setName(String name) {
- getNonVisualProperties().setName(name);
- }
-
- /**
- * Returns the frame name.
- * @return name of the frame
- */
- public String getName() {
- return getNonVisualProperties().getName();
- }
-
- private CTNonVisualDrawingProps getNonVisualProperties() {
- CTGraphicalObjectFrameNonVisual nvGraphic = graphicFrame.getNvGraphicFramePr();
- return nvGraphic.getCNvPr();
- }
-
- /**
- * Attaches frame to an anchor.
- */
- protected void setAnchor(XSSFClientAnchor anchor) {
- this.anchor = anchor;
- }
-
- /**
- * Returns the frame anchor.
- * @return the XSSFClientAnchor anchor this frame is attached to
- */
- @Override
+ @Internal
+ public CTGraphicalObjectFrame getCTGraphicalObjectFrame() {
+ return graphicFrame;
+ }
+
+ /**
+ * Initialize default structure of a new graphic frame
+ */
+ protected static CTGraphicalObjectFrame prototype() {
+ if (prototype == null) {
+ CTGraphicalObjectFrame graphicFrame = CTGraphicalObjectFrame.Factory.newInstance();
+
+ CTGraphicalObjectFrameNonVisual nvGraphic = graphicFrame.addNewNvGraphicFramePr();
+ CTNonVisualDrawingProps props = nvGraphic.addNewCNvPr();
+ props.setId(0);
+ props.setName("Diagramm 1");
+ nvGraphic.addNewCNvGraphicFramePr();
+
+ CTTransform2D transform = graphicFrame.addNewXfrm();
+ CTPositiveSize2D extPoint = transform.addNewExt();
+ CTPoint2D offPoint = transform.addNewOff();
+
+ extPoint.setCx(0);
+ extPoint.setCy(0);
+ offPoint.setX(0);
+ offPoint.setY(0);
+
+ /* CTGraphicalObject graphic = */ graphicFrame.addNewGraphic();
+
+ prototype = graphicFrame;
+ }
+ return prototype;
+ }
+
+ /**
+ * Sets the frame macro.
+ */
+ public void setMacro(String macro) {
+ graphicFrame.setMacro(macro);
+ }
+
+ /**
+ * Sets the frame name.
+ */
+ public void setName(String name) {
+ getNonVisualProperties().setName(name);
+ }
+
+ /**
+ * Returns the frame name.
+ * @return name of the frame
+ */
+ public String getName() {
+ return getNonVisualProperties().getName();
+ }
+
+ private CTNonVisualDrawingProps getNonVisualProperties() {
+ CTGraphicalObjectFrameNonVisual nvGraphic = graphicFrame.getNvGraphicFramePr();
+ return nvGraphic.getCNvPr();
+ }
+
+ /**
+ * Attaches frame to an anchor.
+ */
+ protected void setAnchor(XSSFClientAnchor anchor) {
+ this.anchor = anchor;
+ }
+
+ /**
+ * Returns the frame anchor.
+ * @return the XSSFClientAnchor anchor this frame is attached to
+ */
+ @Override
public XSSFClientAnchor getAnchor() {
- return (XSSFClientAnchor) anchor;
- }
+ return (XSSFClientAnchor) anchor;
+ }
- /**
- * Assign a DrawingML chart to the graphic frame.
- */
- protected void setChart(XSSFChart chart, String relId) {
- CTGraphicalObjectData data = graphicFrame.getGraphic().addNewGraphicData();
- appendChartElement(data, relId);
- chart.setGraphicFrame(this);
- }
-
- /**
- * Gets the frame id.
- */
- public long getId() {
- return graphicFrame.getNvGraphicFramePr().getCNvPr().getId();
- }
-
- /**
- * Sets the frame id.
- */
- protected void setId(long id) {
- graphicFrame.getNvGraphicFramePr().getCNvPr().setId(id);
- }
-
- /**
- * The low level code to insert {@code <c:chart>} tag into
- * {@code <a:graphicData>}.
- *
- * Here is the schema (ECMA-376):
- * <pre>
- * {@code
- * <complexType name="CT_GraphicalObjectData">
- * <sequence>
- * <any minOccurs="0" maxOccurs="unbounded" processContents="strict"/>
- * </sequence>
- * <attribute name="uri" type="xsd:token"/>
- * </complexType>
- * }
- * </pre>
- */
- private void appendChartElement(CTGraphicalObjectData data, String id) {
- String r_namespaceUri = STRelationshipId.type.getName().getNamespaceURI();
- String c_namespaceUri = XSSFDrawing.NAMESPACE_C;
- XmlCursor cursor = data.newCursor();
- cursor.toNextToken();
- cursor.beginElement(new QName(c_namespaceUri, "chart", "c"));
- cursor.insertAttributeWithValue(new QName(r_namespaceUri, "id", "r"), id);
- cursor.dispose();
- data.setUri(c_namespaceUri);
- }
+ /**
+ * Assign a DrawingML chart to the graphic frame.
+ */
+ protected void setChart(XSSFChart chart, String relId) {
+ CTGraphicalObjectData data = graphicFrame.getGraphic().addNewGraphicData();
+ appendChartElement(data, relId);
+ chart.setGraphicFrame(this);
+ }
+
+ /**
+ * Gets the frame id.
+ */
+ public long getId() {
+ return graphicFrame.getNvGraphicFramePr().getCNvPr().getId();
+ }
+
+ /**
+ * Sets the frame id.
+ */
+ protected void setId(long id) {
+ graphicFrame.getNvGraphicFramePr().getCNvPr().setId(id);
+ }
+
+ /**
+ * The low level code to insert {@code <c:chart>} tag into
+ * {@code <a:graphicData>}.
+ *
+ * Here is the schema (ECMA-376):
+ * <pre>
+ * {@code
+ * <complexType name="CT_GraphicalObjectData">
+ * <sequence>
+ * <any minOccurs="0" maxOccurs="unbounded" processContents="strict"/>
+ * </sequence>
+ * <attribute name="uri" type="xsd:token"/>
+ * </complexType>
+ * }
+ * </pre>
+ */
+ private void appendChartElement(CTGraphicalObjectData data, String id) {
+ String r_namespaceUri = STRelationshipId.type.getName().getNamespaceURI();
+ String c_namespaceUri = XSSFDrawing.NAMESPACE_C;
+ XmlCursor cursor = data.newCursor();
+ cursor.toNextToken();
+ cursor.beginElement(new QName(c_namespaceUri, "chart", "c"));
+ cursor.insertAttributeWithValue(new QName(r_namespaceUri, "id", "r"), id);
+ cursor.dispose();
+ data.setUri(c_namespaceUri);
+ }
@Override
protected CTShapeProperties getShapeProperties(){
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFHeaderFooterProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFHeaderFooterProperties.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFHeaderFooterProperties.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFHeaderFooterProperties.java Sat May 22 20:22:16 2021
@@ -29,85 +29,85 @@ import org.openxmlformats.schemas.spread
* </p>
*/
public class XSSFHeaderFooterProperties {
- private final CTHeaderFooter headerFooter;
+ private final CTHeaderFooter headerFooter;
- /**
- * Create an instance of XSSFHeaderFooterProperties from the supplied XML bean
- */
- public XSSFHeaderFooterProperties(CTHeaderFooter headerFooter) {
+ /**
+ * Create an instance of XSSFHeaderFooterProperties from the supplied XML bean
+ */
+ public XSSFHeaderFooterProperties(CTHeaderFooter headerFooter) {
this.headerFooter = headerFooter;
- }
+ }
- /**
- * Returns the underlying CTHeaderFooter xml bean
- *
- * @return the underlying CTHeaderFooter xml bean
- */
+ /**
+ * Returns the underlying CTHeaderFooter xml bean
+ *
+ * @return the underlying CTHeaderFooter xml bean
+ */
@Internal
- public CTHeaderFooter getHeaderFooter() {
- return this.headerFooter;
- }
-
- /**
- * returns alignWithMargins attribute
- */
- public boolean getAlignWithMargins() {
- return getHeaderFooter().isSetAlignWithMargins() && getHeaderFooter().getAlignWithMargins();
- }
-
- /**
- * returns differentFirst attribute
- */
- public boolean getDifferentFirst() {
- return getHeaderFooter().isSetDifferentFirst() && getHeaderFooter().getDifferentFirst();
- }
-
- /**
- * returns differentOddEven attribute
- */
- public boolean getDifferentOddEven() {
- return getHeaderFooter().isSetDifferentOddEven() && getHeaderFooter().getDifferentOddEven();
- }
-
- /**
- * returns scaleWithDoc attribute
- */
- public boolean getScaleWithDoc() {
- return getHeaderFooter().isSetScaleWithDoc() && getHeaderFooter().getScaleWithDoc();
- }
-
- /**
- * set alignWithMargins attribute
- */
- public void setAlignWithMargins(boolean flag) {
- getHeaderFooter().setAlignWithMargins(flag);
- }
+ public CTHeaderFooter getHeaderFooter() {
+ return this.headerFooter;
+ }
+
+ /**
+ * returns alignWithMargins attribute
+ */
+ public boolean getAlignWithMargins() {
+ return getHeaderFooter().isSetAlignWithMargins() && getHeaderFooter().getAlignWithMargins();
+ }
+
+ /**
+ * returns differentFirst attribute
+ */
+ public boolean getDifferentFirst() {
+ return getHeaderFooter().isSetDifferentFirst() && getHeaderFooter().getDifferentFirst();
+ }
+
+ /**
+ * returns differentOddEven attribute
+ */
+ public boolean getDifferentOddEven() {
+ return getHeaderFooter().isSetDifferentOddEven() && getHeaderFooter().getDifferentOddEven();
+ }
+
+ /**
+ * returns scaleWithDoc attribute
+ */
+ public boolean getScaleWithDoc() {
+ return getHeaderFooter().isSetScaleWithDoc() && getHeaderFooter().getScaleWithDoc();
+ }
+
+ /**
+ * set alignWithMargins attribute
+ */
+ public void setAlignWithMargins(boolean flag) {
+ getHeaderFooter().setAlignWithMargins(flag);
+ }
/**
* set differentFirst attribute
*/
- public void setDifferentFirst(boolean flag) {
+ public void setDifferentFirst(boolean flag) {
getHeaderFooter().setDifferentFirst(flag);
}
/**
* set differentOddEven attribute
*/
- public void setDifferentOddEven(boolean flag) {
+ public void setDifferentOddEven(boolean flag) {
getHeaderFooter().setDifferentOddEven(flag);
}
/**
* set scaleWithDoc attribute
*/
- public void setScaleWithDoc(boolean flag) {
+ public void setScaleWithDoc(boolean flag) {
getHeaderFooter().setScaleWithDoc(flag);
}
/**
* remove alignWithMargins attribute
*/
- public void removeAlignWithMargins() {
+ public void removeAlignWithMargins() {
if (getHeaderFooter().isSetAlignWithMargins()) {
getHeaderFooter().unsetAlignWithMargins();
}
@@ -116,7 +116,7 @@ public class XSSFHeaderFooterProperties
/**
* remove differentFirst attribute
*/
- public void removeDifferentFirst() {
+ public void removeDifferentFirst() {
if (getHeaderFooter().isSetDifferentFirst()) {
getHeaderFooter().unsetDifferentFirst();
}
@@ -125,7 +125,7 @@ public class XSSFHeaderFooterProperties
/**
* remove differentOddEven attribute
*/
- public void removeDifferentOddEven() {
+ public void removeDifferentOddEven() {
if (getHeaderFooter().isSetDifferentOddEven()) {
getHeaderFooter().unsetDifferentOddEven();
}
@@ -134,7 +134,7 @@ public class XSSFHeaderFooterProperties
/**
* remove scaleWithDoc attribute
*/
- public void removeScaleWithDoc() {
+ public void removeScaleWithDoc() {
if (getHeaderFooter().isSetScaleWithDoc()) {
getHeaderFooter().unsetScaleWithDoc();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org