sonar fixes
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1832735 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6ecad91893
commit
d09cb8f9d8
@ -111,18 +111,18 @@ public enum FontGroup {
|
|||||||
* @return the FontGroup
|
* @return the FontGroup
|
||||||
*/
|
*/
|
||||||
public static List<FontGroupRange> getFontGroupRanges(final String runText) {
|
public static List<FontGroupRange> getFontGroupRanges(final String runText) {
|
||||||
List<FontGroupRange> ttrList = new ArrayList<>();
|
final List<FontGroupRange> ttrList = new ArrayList<>();
|
||||||
if (runText == null || runText.isEmpty()) {
|
if (runText == null || runText.isEmpty()) {
|
||||||
return ttrList;
|
return ttrList;
|
||||||
}
|
}
|
||||||
FontGroupRange ttrLast = null;
|
FontGroupRange ttrLast = null;
|
||||||
final int rlen = (runText != null) ? runText.length() : 0;
|
final int rlen = runText.length();
|
||||||
for(int cp, i = 0, charCount; i < rlen; i += charCount) {
|
for(int cp, i = 0, charCount; i < rlen; i += charCount) {
|
||||||
cp = runText.codePointAt(i);
|
cp = runText.codePointAt(i);
|
||||||
charCount = Character.charCount(cp);
|
charCount = Character.charCount(cp);
|
||||||
|
|
||||||
// don't switch the font group for a few default characters supposedly available in all fonts
|
// don't switch the font group for a few default characters supposedly available in all fonts
|
||||||
FontGroup tt;
|
final FontGroup tt;
|
||||||
if (ttrLast != null && " \n\r".indexOf(cp) > -1) {
|
if (ttrLast != null && " \n\r".indexOf(cp) > -1) {
|
||||||
tt = ttrLast.fontGroup;
|
tt = ttrLast.fontGroup;
|
||||||
} else {
|
} else {
|
||||||
|
@ -67,12 +67,10 @@ import org.apache.poi.util.SuppressForbidden;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Translates Graphics2D calls into PowerPoint.
|
* Translates Graphics2D calls into PowerPoint.
|
||||||
*
|
|
||||||
* @author Yegor Kozlov
|
|
||||||
*/
|
*/
|
||||||
public final class SLGraphics extends Graphics2D implements Cloneable {
|
public class SLGraphics extends Graphics2D implements Cloneable {
|
||||||
|
|
||||||
protected POILogger log = POILogFactory.getLogger(this.getClass());
|
private static final POILogger LOG = POILogFactory.getLogger(SLGraphics.class);
|
||||||
|
|
||||||
//The ppt object to write into.
|
//The ppt object to write into.
|
||||||
private GroupShape<?,?> _group;
|
private GroupShape<?,?> _group;
|
||||||
@ -303,7 +301,8 @@ public final class SLGraphics extends Graphics2D implements Cloneable {
|
|||||||
float ascent = layout.getAscent();
|
float ascent = layout.getAscent();
|
||||||
|
|
||||||
float width = (float) Math.floor(layout.getAdvance());
|
float width = (float) Math.floor(layout.getAdvance());
|
||||||
/**
|
|
||||||
|
/*
|
||||||
* Even if top and bottom margins are set to 0 PowerPoint
|
* Even if top and bottom margins are set to 0 PowerPoint
|
||||||
* always sets extra space between the text and its bounding box.
|
* always sets extra space between the text and its bounding box.
|
||||||
*
|
*
|
||||||
@ -384,8 +383,8 @@ public final class SLGraphics extends Graphics2D implements Cloneable {
|
|||||||
*/
|
*/
|
||||||
@NotImplemented
|
@NotImplemented
|
||||||
public void clip(Shape s){
|
public void clip(Shape s){
|
||||||
if (log.check(POILogger.WARN)) {
|
if (LOG.check(POILogger.WARN)) {
|
||||||
log.log(POILogger.WARN, "Not implemented");
|
LOG.log(POILogger.WARN, "Not implemented");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,8 +406,8 @@ public final class SLGraphics extends Graphics2D implements Cloneable {
|
|||||||
*/
|
*/
|
||||||
@NotImplemented
|
@NotImplemented
|
||||||
public Shape getClip(){
|
public Shape getClip(){
|
||||||
if (log.check(POILogger.WARN)) {
|
if (LOG.check(POILogger.WARN)) {
|
||||||
log.log(POILogger.WARN, "Not implemented");
|
LOG.log(POILogger.WARN, "Not implemented");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -676,8 +675,8 @@ public final class SLGraphics extends Graphics2D implements Cloneable {
|
|||||||
public boolean drawImage(Image img, int x, int y,
|
public boolean drawImage(Image img, int x, int y,
|
||||||
Color bgcolor,
|
Color bgcolor,
|
||||||
ImageObserver observer){
|
ImageObserver observer){
|
||||||
if (log.check(POILogger.WARN)) {
|
if (LOG.check(POILogger.WARN)) {
|
||||||
log.log(POILogger.WARN, "Not implemented");
|
LOG.log(POILogger.WARN, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -726,8 +725,8 @@ public final class SLGraphics extends Graphics2D implements Cloneable {
|
|||||||
int width, int height,
|
int width, int height,
|
||||||
Color bgcolor,
|
Color bgcolor,
|
||||||
ImageObserver observer){
|
ImageObserver observer){
|
||||||
if (log.check(POILogger.WARN)) {
|
if (LOG.check(POILogger.WARN)) {
|
||||||
log.log(POILogger.WARN, "Not implemented");
|
LOG.log(POILogger.WARN, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -786,8 +785,8 @@ public final class SLGraphics extends Graphics2D implements Cloneable {
|
|||||||
int dx1, int dy1, int dx2, int dy2,
|
int dx1, int dy1, int dx2, int dy2,
|
||||||
int sx1, int sy1, int sx2, int sy2,
|
int sx1, int sy1, int sx2, int sy2,
|
||||||
ImageObserver observer){
|
ImageObserver observer){
|
||||||
if (log.check(POILogger.WARN)) {
|
if (LOG.check(POILogger.WARN)) {
|
||||||
log.log(POILogger.WARN, "Not implemented");
|
LOG.log(POILogger.WARN, "Not implemented");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -851,8 +850,8 @@ public final class SLGraphics extends Graphics2D implements Cloneable {
|
|||||||
int sx1, int sy1, int sx2, int sy2,
|
int sx1, int sy1, int sx2, int sy2,
|
||||||
Color bgcolor,
|
Color bgcolor,
|
||||||
ImageObserver observer){
|
ImageObserver observer){
|
||||||
if (log.check(POILogger.WARN)) {
|
if (LOG.check(POILogger.WARN)) {
|
||||||
log.log(POILogger.WARN, "Not implemented");
|
LOG.log(POILogger.WARN, "Not implemented");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -892,8 +891,8 @@ public final class SLGraphics extends Graphics2D implements Cloneable {
|
|||||||
@NotImplemented
|
@NotImplemented
|
||||||
public boolean drawImage(Image img, int x, int y,
|
public boolean drawImage(Image img, int x, int y,
|
||||||
ImageObserver observer) {
|
ImageObserver observer) {
|
||||||
if (log.check(POILogger.WARN)) {
|
if (LOG.check(POILogger.WARN)) {
|
||||||
log.log(POILogger.WARN, "Not implemented");
|
LOG.log(POILogger.WARN, "Not implemented");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1079,8 +1078,8 @@ public final class SLGraphics extends Graphics2D implements Cloneable {
|
|||||||
*/
|
*/
|
||||||
@NotImplemented
|
@NotImplemented
|
||||||
public void setClip(Shape clip) {
|
public void setClip(Shape clip) {
|
||||||
if (log.check(POILogger.WARN)) {
|
if (LOG.check(POILogger.WARN)) {
|
||||||
log.log(POILogger.WARN, "Not implemented");
|
LOG.log(POILogger.WARN, "Not implemented");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1102,11 +1101,10 @@ public final class SLGraphics extends Graphics2D implements Cloneable {
|
|||||||
* @since JDK1.1
|
* @since JDK1.1
|
||||||
*/
|
*/
|
||||||
public Rectangle getClipBounds(){
|
public Rectangle getClipBounds(){
|
||||||
Shape c = getClip();
|
if (LOG.check(POILogger.WARN)) {
|
||||||
if (c==null) {
|
LOG.log(POILogger.WARN, "Not implemented");
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
return c.getBounds();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1379,8 +1377,8 @@ public final class SLGraphics extends Graphics2D implements Cloneable {
|
|||||||
*/
|
*/
|
||||||
@NotImplemented
|
@NotImplemented
|
||||||
public void setComposite(Composite comp){
|
public void setComposite(Composite comp){
|
||||||
if (log.check(POILogger.WARN)) {
|
if (LOG.check(POILogger.WARN)) {
|
||||||
log.log(POILogger.WARN, "Not implemented");
|
LOG.log(POILogger.WARN, "Not implemented");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1393,8 +1391,8 @@ public final class SLGraphics extends Graphics2D implements Cloneable {
|
|||||||
*/
|
*/
|
||||||
@NotImplemented
|
@NotImplemented
|
||||||
public Composite getComposite(){
|
public Composite getComposite(){
|
||||||
if (log.check(POILogger.WARN)) {
|
if (LOG.check(POILogger.WARN)) {
|
||||||
log.log(POILogger.WARN, "Not implemented");
|
LOG.log(POILogger.WARN, "Not implemented");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -1537,8 +1535,8 @@ public final class SLGraphics extends Graphics2D implements Cloneable {
|
|||||||
*/
|
*/
|
||||||
@NotImplemented
|
@NotImplemented
|
||||||
public void drawString(AttributedCharacterIterator iterator, float x, float y) {
|
public void drawString(AttributedCharacterIterator iterator, float x, float y) {
|
||||||
if (log.check(POILogger.WARN)) {
|
if (LOG.check(POILogger.WARN)) {
|
||||||
log.log(POILogger.WARN, "Not implemented");
|
LOG.log(POILogger.WARN, "Not implemented");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1644,8 +1642,8 @@ public final class SLGraphics extends Graphics2D implements Cloneable {
|
|||||||
*/
|
*/
|
||||||
@NotImplemented
|
@NotImplemented
|
||||||
public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) {
|
public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) {
|
||||||
if (log.check(POILogger.WARN)) {
|
if (LOG.check(POILogger.WARN)) {
|
||||||
log.log(POILogger.WARN, "Not implemented");
|
LOG.log(POILogger.WARN, "Not implemented");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1690,8 +1688,8 @@ public final class SLGraphics extends Graphics2D implements Cloneable {
|
|||||||
public boolean drawImage(Image img, int x, int y,
|
public boolean drawImage(Image img, int x, int y,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
ImageObserver observer) {
|
ImageObserver observer) {
|
||||||
if (log.check(POILogger.WARN)) {
|
if (LOG.check(POILogger.WARN)) {
|
||||||
log.log(POILogger.WARN, "Not implemented");
|
LOG.log(POILogger.WARN, "Not implemented");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1741,8 +1739,8 @@ public final class SLGraphics extends Graphics2D implements Cloneable {
|
|||||||
*/
|
*/
|
||||||
@NotImplemented
|
@NotImplemented
|
||||||
public void setXORMode(Color c1) {
|
public void setXORMode(Color c1) {
|
||||||
if (log.check(POILogger.WARN)) {
|
if (LOG.check(POILogger.WARN)) {
|
||||||
log.log(POILogger.WARN, "Not implemented");
|
LOG.log(POILogger.WARN, "Not implemented");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1755,8 +1753,8 @@ public final class SLGraphics extends Graphics2D implements Cloneable {
|
|||||||
*/
|
*/
|
||||||
@NotImplemented
|
@NotImplemented
|
||||||
public void setPaintMode() {
|
public void setPaintMode() {
|
||||||
if (log.check(POILogger.WARN)) {
|
if (LOG.check(POILogger.WARN)) {
|
||||||
log.log(POILogger.WARN, "Not implemented");
|
LOG.log(POILogger.WARN, "Not implemented");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1793,8 +1791,8 @@ public final class SLGraphics extends Graphics2D implements Cloneable {
|
|||||||
*/
|
*/
|
||||||
@NotImplemented
|
@NotImplemented
|
||||||
public void drawRenderedImage(RenderedImage img, AffineTransform xform) {
|
public void drawRenderedImage(RenderedImage img, AffineTransform xform) {
|
||||||
if (log.check(POILogger.WARN)) {
|
if (LOG.check(POILogger.WARN)) {
|
||||||
log.log(POILogger.WARN, "Not implemented");
|
LOG.log(POILogger.WARN, "Not implemented");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1821,8 +1819,8 @@ public final class SLGraphics extends Graphics2D implements Cloneable {
|
|||||||
*/
|
*/
|
||||||
@NotImplemented
|
@NotImplemented
|
||||||
public void drawRenderableImage(RenderableImage img, AffineTransform xform) {
|
public void drawRenderableImage(RenderableImage img, AffineTransform xform) {
|
||||||
if (log.check(POILogger.WARN)) {
|
if (LOG.check(POILogger.WARN)) {
|
||||||
log.log(POILogger.WARN, "Not implemented");
|
LOG.log(POILogger.WARN, "Not implemented");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,7 +632,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
|
|||||||
for (int c = region.getFirstColumn(); c <= region.getLastColumn(); c++) {
|
for (int c = region.getFirstColumn(); c <= region.getLastColumn(); c++) {
|
||||||
Cell cell = row.getCell(c);
|
Cell cell = row.getCell(c);
|
||||||
final ValueAndFormat cv = getCellValue(cell);
|
final ValueAndFormat cv = getCellValue(cell);
|
||||||
if (cv != null && (withText || cv.isNumber()) ) {
|
if (withText || cv.isNumber()) {
|
||||||
allValues.add(cv);
|
allValues.add(cv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -646,13 +646,19 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
|
|||||||
|
|
||||||
private ValueAndFormat getCellValue(Cell cell) {
|
private ValueAndFormat getCellValue(Cell cell) {
|
||||||
if (cell != null) {
|
if (cell != null) {
|
||||||
final CellType type = cell.getCellType();
|
final String format = cell.getCellStyle().getDataFormatString();
|
||||||
if (type == CellType.NUMERIC || (type == CellType.FORMULA && cell.getCachedFormulaResultType() == CellType.NUMERIC) ) {
|
CellType type = cell.getCellType();
|
||||||
return new ValueAndFormat(Double.valueOf(cell.getNumericCellValue()), cell.getCellStyle().getDataFormatString(), decimalTextFormat);
|
if (type == CellType.FORMULA) {
|
||||||
} else if (type == CellType.STRING || (type == CellType.FORMULA && cell.getCachedFormulaResultType() == CellType.STRING) ) {
|
type = cell.getCachedFormulaResultType();
|
||||||
return new ValueAndFormat(cell.getStringCellValue(), cell.getCellStyle().getDataFormatString());
|
}
|
||||||
} else if (type == CellType.BOOLEAN || (type == CellType.FORMULA && cell.getCachedFormulaResultType() == CellType.BOOLEAN) ) {
|
switch (type) {
|
||||||
return new ValueAndFormat(cell.getStringCellValue(), cell.getCellStyle().getDataFormatString());
|
case NUMERIC:
|
||||||
|
return new ValueAndFormat(Double.valueOf(cell.getNumericCellValue()), format, decimalTextFormat);
|
||||||
|
case STRING:
|
||||||
|
case BOOLEAN:
|
||||||
|
return new ValueAndFormat(cell.getStringCellValue(), format);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ValueAndFormat("", "");
|
return new ValueAndFormat("", "");
|
||||||
|
@ -59,14 +59,15 @@ public enum TableStyleType {
|
|||||||
|
|
||||||
int firstStart = table.getStartColIndex();
|
int firstStart = table.getStartColIndex();
|
||||||
int secondStart = firstStart + c1Stripe;
|
int secondStart = firstStart + c1Stripe;
|
||||||
int c = cell.getCol();
|
final int c = cell.getCol();
|
||||||
|
|
||||||
// look for the stripe containing c, accounting for the style element stripe size
|
// look for the stripe containing c, accounting for the style element stripe size
|
||||||
// could do fancy math, but tables can't be that wide, a simple loop is fine
|
// could do fancy math, but tables can't be that wide, a simple loop is fine
|
||||||
// if not in this type of stripe, return null
|
// if not in this type of stripe, return null
|
||||||
while (true) {
|
while (firstStart <= c) {
|
||||||
if (firstStart > c) break;
|
if (c >= firstStart && c <= secondStart -1) {
|
||||||
if (c >= firstStart && c <= secondStart -1) return new CellRangeAddress(table.getStartRowIndex(), table.getEndRowIndex(), firstStart, secondStart - 1);
|
return new CellRangeAddress(table.getStartRowIndex(), table.getEndRowIndex(), firstStart, secondStart - 1);
|
||||||
|
}
|
||||||
firstStart = secondStart + c2Stripe;
|
firstStart = secondStart + c2Stripe;
|
||||||
secondStart = firstStart + c1Stripe;
|
secondStart = firstStart + c1Stripe;
|
||||||
}
|
}
|
||||||
@ -86,14 +87,15 @@ public enum TableStyleType {
|
|||||||
|
|
||||||
int firstStart = table.getStartColIndex();
|
int firstStart = table.getStartColIndex();
|
||||||
int secondStart = firstStart + c1Stripe;
|
int secondStart = firstStart + c1Stripe;
|
||||||
int c = cell.getCol();
|
final int c = cell.getCol();
|
||||||
|
|
||||||
// look for the stripe containing c, accounting for the style element stripe size
|
// look for the stripe containing c, accounting for the style element stripe size
|
||||||
// could do fancy math, but tables can't be that wide, a simple loop is fine
|
// could do fancy math, but tables can't be that wide, a simple loop is fine
|
||||||
// if not in this type of stripe, return null
|
// if not in this type of stripe, return null
|
||||||
while (true) {
|
while (firstStart <= c) {
|
||||||
if (firstStart > c) break;
|
if (c >= secondStart && c <= secondStart + c2Stripe -1) {
|
||||||
if (c >= secondStart && c <= secondStart + c2Stripe -1) return new CellRangeAddress(table.getStartRowIndex(), table.getEndRowIndex(), secondStart, secondStart + c2Stripe - 1);
|
return new CellRangeAddress(table.getStartRowIndex(), table.getEndRowIndex(), secondStart, secondStart + c2Stripe - 1);
|
||||||
|
}
|
||||||
firstStart = secondStart + c2Stripe;
|
firstStart = secondStart + c2Stripe;
|
||||||
secondStart = firstStart + c1Stripe;
|
secondStart = firstStart + c1Stripe;
|
||||||
}
|
}
|
||||||
@ -113,14 +115,15 @@ public enum TableStyleType {
|
|||||||
|
|
||||||
int firstStart = table.getStartRowIndex() + table.getHeaderRowCount();
|
int firstStart = table.getStartRowIndex() + table.getHeaderRowCount();
|
||||||
int secondStart = firstStart + c1Stripe;
|
int secondStart = firstStart + c1Stripe;
|
||||||
int c = cell.getRow();
|
final int c = cell.getRow();
|
||||||
|
|
||||||
// look for the stripe containing c, accounting for the style element stripe size
|
// look for the stripe containing c, accounting for the style element stripe size
|
||||||
// could do fancy math, but tables can't be that wide, a simple loop is fine
|
// could do fancy math, but tables can't be that wide, a simple loop is fine
|
||||||
// if not in this type of stripe, return null
|
// if not in this type of stripe, return null
|
||||||
while (true) {
|
while (firstStart <= c) {
|
||||||
if (firstStart > c) break;
|
if (c >= firstStart && c <= secondStart -1) {
|
||||||
if (c >= firstStart && c <= secondStart -1) return new CellRangeAddress(firstStart, secondStart - 1, table.getStartColIndex(), table.getEndColIndex());
|
return new CellRangeAddress(firstStart, secondStart - 1, table.getStartColIndex(), table.getEndColIndex());
|
||||||
|
}
|
||||||
firstStart = secondStart + c2Stripe;
|
firstStart = secondStart + c2Stripe;
|
||||||
secondStart = firstStart + c1Stripe;
|
secondStart = firstStart + c1Stripe;
|
||||||
}
|
}
|
||||||
@ -140,14 +143,15 @@ public enum TableStyleType {
|
|||||||
|
|
||||||
int firstStart = table.getStartRowIndex() + table.getHeaderRowCount();
|
int firstStart = table.getStartRowIndex() + table.getHeaderRowCount();
|
||||||
int secondStart = firstStart + c1Stripe;
|
int secondStart = firstStart + c1Stripe;
|
||||||
int c = cell.getRow();
|
final int c = cell.getRow();
|
||||||
|
|
||||||
// look for the stripe containing c, accounting for the style element stripe size
|
// look for the stripe containing c, accounting for the style element stripe size
|
||||||
// could do fancy math, but tables can't be that wide, a simple loop is fine
|
// could do fancy math, but tables can't be that wide, a simple loop is fine
|
||||||
// if not in this type of stripe, return null
|
// if not in this type of stripe, return null
|
||||||
while (true) {
|
while (firstStart <= c) {
|
||||||
if (firstStart > c) break;
|
if (c >= secondStart && c <= secondStart +c2Stripe -1) {
|
||||||
if (c >= secondStart && c <= secondStart +c2Stripe -1) return new CellRangeAddress(secondStart, secondStart + c2Stripe - 1, table.getStartColIndex(), table.getEndColIndex());
|
return new CellRangeAddress(secondStart, secondStart + c2Stripe - 1, table.getStartColIndex(), table.getEndColIndex());
|
||||||
|
}
|
||||||
firstStart = secondStart + c2Stripe;
|
firstStart = secondStart + c2Stripe;
|
||||||
secondStart = firstStart + c1Stripe;
|
secondStart = firstStart + c1Stripe;
|
||||||
}
|
}
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
/* ====================================================================
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
|
||||||
this work for additional information regarding copyright ownership.
|
|
||||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
(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
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
==================================================================== */
|
|
||||||
|
|
||||||
package org.apache.poi.openxml4j.opc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies the encryption option for parts in a Package.
|
|
||||||
*
|
|
||||||
* @author Julien Chable
|
|
||||||
* @version 0.1
|
|
||||||
*/
|
|
||||||
public enum EncryptionOption {
|
|
||||||
/** No encryption. */
|
|
||||||
NONE
|
|
||||||
}
|
|
@ -244,13 +244,11 @@ public final class PackageRelationshipCollection implements
|
|||||||
* The relationship ID to remove.
|
* The relationship ID to remove.
|
||||||
*/
|
*/
|
||||||
public void removeRelationship(String id) {
|
public void removeRelationship(String id) {
|
||||||
if (relationshipsByID != null && relationshipsByType != null) {
|
PackageRelationship rel = relationshipsByID.get(id);
|
||||||
PackageRelationship rel = relationshipsByID.get(id);
|
if (rel != null) {
|
||||||
if (rel != null) {
|
relationshipsByID.remove(rel.getId());
|
||||||
relationshipsByID.remove(rel.getId());
|
relationshipsByType.values().remove(rel);
|
||||||
relationshipsByType.values().remove(rel);
|
internalRelationshipsByTargetName.values().remove(rel);
|
||||||
internalRelationshipsByTargetName.values().remove(rel);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,28 +411,23 @@ public final class PackageRelationshipCollection implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String str;
|
String str = relationshipsByID.size() + " relationship(s) = [";
|
||||||
if (relationshipsByID == null) {
|
|
||||||
str = "relationshipsByID=null";
|
|
||||||
} else {
|
|
||||||
str = relationshipsByID.size() + " relationship(s) = [";
|
|
||||||
}
|
|
||||||
if ((relationshipPart != null) && (relationshipPart._partName != null)) {
|
if ((relationshipPart != null) && (relationshipPart._partName != null)) {
|
||||||
str = str + "," + relationshipPart._partName;
|
str += relationshipPart._partName;
|
||||||
} else {
|
} else {
|
||||||
str = str + ",relationshipPart=null";
|
str += "relationshipPart=null";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Source of this relationship
|
// Source of this relationship
|
||||||
if ((sourcePart != null) && (sourcePart._partName != null)) {
|
if ((sourcePart != null) && (sourcePart._partName != null)) {
|
||||||
str = str + "," + sourcePart._partName;
|
str += "," + sourcePart._partName;
|
||||||
} else {
|
} else {
|
||||||
str = str + ",sourcePart=null";
|
str += ",sourcePart=null";
|
||||||
}
|
}
|
||||||
if (partName != null) {
|
if (partName != null) {
|
||||||
str = str + "," + partName;
|
str += "," + partName;
|
||||||
} else {
|
} else {
|
||||||
str = str + ",uri=null)";
|
str += ",uri=null)";
|
||||||
}
|
}
|
||||||
return str + "]";
|
return str + "]";
|
||||||
}
|
}
|
||||||
|
@ -316,7 +316,7 @@ public class SignatureInfo implements SignatureConfigurable {
|
|||||||
} catch (InvalidFormatException e) {
|
} catch (InvalidFormatException e) {
|
||||||
LOG.log(POILogger.WARN, "Reference to signature is invalid.", e);
|
LOG.log(POILogger.WARN, "Reference to signature is invalid.", e);
|
||||||
}
|
}
|
||||||
} while (sigPart == null);
|
} while (sigRelPart == null);
|
||||||
return new SignaturePart(sigRelPart, signatureConfig);
|
return new SignaturePart(sigRelPart, signatureConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,12 +32,15 @@ import org.apache.poi.util.IOUtils;
|
|||||||
*/
|
*/
|
||||||
public abstract class HPBFPart {
|
public abstract class HPBFPart {
|
||||||
private byte[] data;
|
private byte[] data;
|
||||||
|
private final String[] path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param path the path to the part, eg Contents or Quill, QuillSub, CONTENTS
|
* @param path the path to the part, eg Contents or Quill, QuillSub, CONTENTS
|
||||||
*/
|
*/
|
||||||
public HPBFPart(DirectoryNode baseDir, String[] path) throws IOException {
|
public HPBFPart(DirectoryNode baseDir, String[] path) throws IOException {
|
||||||
|
this.path = path;
|
||||||
|
|
||||||
DirectoryNode dir = getDir(path, baseDir);
|
DirectoryNode dir = getDir(baseDir, path);
|
||||||
String name = path[path.length-1];
|
String name = path[path.length-1];
|
||||||
|
|
||||||
if (!dir.hasEntry(name)) {
|
if (!dir.hasEntry(name)) {
|
||||||
@ -45,11 +48,12 @@ public abstract class HPBFPart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Grab the data from the part stream
|
// Grab the data from the part stream
|
||||||
InputStream is = dir.createDocumentInputStream(name);
|
try (InputStream is = dir.createDocumentInputStream(name)) {
|
||||||
data = IOUtils.toByteArray(is);
|
data = IOUtils.toByteArray(is);
|
||||||
is.close();
|
}
|
||||||
}
|
}
|
||||||
private DirectoryNode getDir(String[] path, DirectoryNode baseDir) {
|
|
||||||
|
private static DirectoryNode getDir(DirectoryNode baseDir, String[] path) {
|
||||||
DirectoryNode dir = baseDir;
|
DirectoryNode dir = baseDir;
|
||||||
for(int i=0; i<path.length-1; i++) {
|
for(int i=0; i<path.length-1; i++) {
|
||||||
try {
|
try {
|
||||||
@ -64,9 +68,6 @@ public abstract class HPBFPart {
|
|||||||
|
|
||||||
public void writeOut(DirectoryNode baseDir) throws IOException {
|
public void writeOut(DirectoryNode baseDir) throws IOException {
|
||||||
String[] path = getPath();
|
String[] path = getPath();
|
||||||
if (path == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure that all parent directories exist
|
// Ensure that all parent directories exist
|
||||||
DirectoryNode dir = baseDir;
|
DirectoryNode dir = baseDir;
|
||||||
@ -97,7 +98,9 @@ public abstract class HPBFPart {
|
|||||||
* Returns the raw data that makes up
|
* Returns the raw data that makes up
|
||||||
* this document part.
|
* this document part.
|
||||||
*/
|
*/
|
||||||
public final byte[] getData() { return data; }
|
public final byte[] getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
protected final void setData(byte data[]) {
|
protected final void setData(byte data[]) {
|
||||||
this.data = data.clone();
|
this.data = data.clone();
|
||||||
@ -106,5 +109,7 @@ public abstract class HPBFPart {
|
|||||||
/**
|
/**
|
||||||
* Returns
|
* Returns
|
||||||
*/
|
*/
|
||||||
public final String[] getPath() {return null;}
|
public final String[] getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -113,11 +113,7 @@ public class HSLFTabStopPropCollection extends TextProp {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
return 31 * super.hashCode() + tabStops.hashCode();
|
||||||
int result = super.hashCode();
|
|
||||||
result = prime * result
|
|
||||||
+ ((tabStops == null) ? 0 : tabStops.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -338,7 +338,7 @@ public class TextPropCollection {
|
|||||||
result = prime * result + charactersCovered;
|
result = prime * result + charactersCovered;
|
||||||
result = prime * result + maskSpecial;
|
result = prime * result + maskSpecial;
|
||||||
result = prime * result + indentLevel;
|
result = prime * result + indentLevel;
|
||||||
result = prime * result + ((textProps == null) ? 0 : textProps.hashCode());
|
result = prime * result + textProps.hashCode();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -193,9 +193,6 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFShape,HSLFText
|
|||||||
private void supplySheet(HSLFSheet sheet) {
|
private void supplySheet(HSLFSheet sheet) {
|
||||||
this._sheet = sheet;
|
this._sheet = sheet;
|
||||||
|
|
||||||
if (_runs == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (HSLFTextRun rt : _runs) {
|
for (HSLFTextRun rt : _runs) {
|
||||||
rt.updateSheet();
|
rt.updateSheet();
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,6 @@ import org.apache.poi.util.LittleEndian;
|
|||||||
import org.apache.poi.util.POILogFactory;
|
import org.apache.poi.util.POILogFactory;
|
||||||
import org.apache.poi.util.POILogger;
|
import org.apache.poi.util.POILogger;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Ryan Ackley
|
|
||||||
*/
|
|
||||||
@Internal
|
@Internal
|
||||||
public final class ListTables
|
public final class ListTables
|
||||||
{
|
{
|
||||||
@ -169,10 +166,8 @@ public final class ListTables
|
|||||||
{
|
{
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result
|
result = prime * result + _listMap.hashCode();
|
||||||
+ ( ( _listMap == null ) ? 0 : _listMap.hashCode() );
|
result = prime * result + ( ( _plfLfo == null ) ? 0 : _plfLfo.hashCode() );
|
||||||
result = prime * result
|
|
||||||
+ ( ( _plfLfo == null ) ? 0 : _plfLfo.hashCode() );
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,12 +181,7 @@ public final class ListTables
|
|||||||
if ( getClass() != obj.getClass() )
|
if ( getClass() != obj.getClass() )
|
||||||
return false;
|
return false;
|
||||||
ListTables other = (ListTables) obj;
|
ListTables other = (ListTables) obj;
|
||||||
if ( _listMap == null )
|
if ( !_listMap.equals( other._listMap ) )
|
||||||
{
|
|
||||||
if ( other._listMap != null )
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if ( !_listMap.equals( other._listMap ) )
|
|
||||||
return false;
|
return false;
|
||||||
if ( _plfLfo == null )
|
if ( _plfLfo == null )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user