diff options
Diffstat (limited to 'src/java/org/apache')
282 files changed, 27945 insertions, 5627 deletions
diff --git a/src/java/org/apache/poi/EmptyFileException.java b/src/java/org/apache/poi/EmptyFileException.java new file mode 100644 index 0000000000..ddbd142806 --- /dev/null +++ b/src/java/org/apache/poi/EmptyFileException.java @@ -0,0 +1,28 @@ +/* ==================================================================== + 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; + +/** + * Exception thrown if an Empty (zero byte) file is supplied + */ +public class EmptyFileException extends IllegalArgumentException { + private static final long serialVersionUID = 1536449292174360166L; + + public EmptyFileException() { + super("The supplied file was empty (zero bytes long)"); + } +}
\ No newline at end of file diff --git a/src/java/org/apache/poi/EncryptedDocumentException.java b/src/java/org/apache/poi/EncryptedDocumentException.java index 12196c80cd..4ac6123e4b 100644 --- a/src/java/org/apache/poi/EncryptedDocumentException.java +++ b/src/java/org/apache/poi/EncryptedDocumentException.java @@ -16,9 +16,10 @@ ==================================================================== */ package org.apache.poi; -@SuppressWarnings("serial") public class EncryptedDocumentException extends IllegalStateException { + private static final long serialVersionUID = 7276950444540469193L; + public EncryptedDocumentException(String s) { super(s); } diff --git a/src/java/org/apache/poi/POIDocument.java b/src/java/org/apache/poi/POIDocument.java index 950e5eb3e4..4345d4b1ca 100644 --- a/src/java/org/apache/poi/POIDocument.java +++ b/src/java/org/apache/poi/POIDocument.java @@ -30,14 +30,11 @@ import org.apache.poi.hpsf.PropertySet; import org.apache.poi.hpsf.PropertySetFactory; import org.apache.poi.hpsf.SummaryInformation; import org.apache.poi.poifs.crypt.EncryptionInfo; -import org.apache.poi.poifs.filesystem.DirectoryEntry; import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.DocumentInputStream; -import org.apache.poi.poifs.filesystem.Entry; -import org.apache.poi.poifs.filesystem.EntryUtils; import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; +import org.apache.poi.poifs.filesystem.OPOIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem; -import org.apache.poi.util.Internal; import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogger; @@ -45,8 +42,6 @@ import org.apache.poi.util.POILogger; * This holds the common functionality for all POI * Document classes. * Currently, this relates to Document Information Properties - * - * @author Nick Burch */ public abstract class POIDocument { /** Holds metadata on our document */ @@ -72,20 +67,23 @@ public abstract class POIDocument { } /** - * @deprecated use {@link POIDocument#POIDocument(DirectoryNode)} instead + * Constructs from an old-style OPOIFS */ - @Deprecated - protected POIDocument(DirectoryNode dir, POIFSFileSystem fs) { - this.directory = dir; - } - - protected POIDocument(POIFSFileSystem fs) { + protected POIDocument(OPOIFSFileSystem fs) { this(fs.getRoot()); } - + /** + * Constructs from an old-style OPOIFS + */ protected POIDocument(NPOIFSFileSystem fs) { this(fs.getRoot()); } + /** + * Constructs from the default POIFS + */ + protected POIDocument(POIFSFileSystem fs) { + this(fs.getRoot()); + } /** * Fetch the Document Summary Information of the document @@ -179,12 +177,13 @@ public abstract class POIDocument { protected PropertySet getPropertySet(String setName, EncryptionInfo encryptionInfo) { DirectoryNode dirNode = directory; + NPOIFSFileSystem encPoifs = null; if (encryptionInfo != null) { try { InputStream is = encryptionInfo.getDecryptor().getDataStream(directory); - POIFSFileSystem poifs = new POIFSFileSystem(is); + encPoifs = new NPOIFSFileSystem(is); is.close(); - dirNode = poifs.getRoot(); + dirNode = encPoifs.getRoot(); } catch (Exception e) { logger.log(POILogger.ERROR, "Error getting encrypted property set with name " + setName, e); return null; @@ -208,6 +207,11 @@ public abstract class POIDocument { try { // Create the Property Set PropertySet set = PropertySetFactory.create(dis); + // Tidy up if needed + if (encPoifs != null) { + encPoifs.close(); + } + // Return the properties return set; } catch(IOException ie) { // Must be corrupt or something like that @@ -218,26 +222,39 @@ public abstract class POIDocument { } return null; } + + /** + * Writes out the updated standard Document Information Properties (HPSF) + * into the currently open NPOIFSFileSystem + * TODO Implement in-place update + * + * @throws IOException if an error when writing to the open + * {@link NPOIFSFileSystem} occurs + * TODO throws exception if open from stream not file + */ + protected void writeProperties() throws IOException { + throw new IllegalStateException("In-place write is not yet supported"); + } /** - * Writes out the standard Documment Information Properties (HPSF) + * Writes out the standard Document Information Properties (HPSF) * @param outFS the POIFSFileSystem to write the properties into * * @throws IOException if an error when writing to the - * {@link POIFSFileSystem} occurs + * {@link NPOIFSFileSystem} occurs */ - protected void writeProperties(POIFSFileSystem outFS) throws IOException { + protected void writeProperties(NPOIFSFileSystem outFS) throws IOException { writeProperties(outFS, null); } /** - * Writes out the standard Documment Information Properties (HPSF) - * @param outFS the POIFSFileSystem to write the properties into + * Writes out the standard Document Information Properties (HPSF) + * @param outFS the NPOIFSFileSystem to write the properties into * @param writtenEntries a list of POIFS entries to add the property names too * * @throws IOException if an error when writing to the - * {@link POIFSFileSystem} occurs + * {@link NPOIFSFileSystem} occurs */ - protected void writeProperties(POIFSFileSystem outFS, List<String> writtenEntries) throws IOException { + protected void writeProperties(NPOIFSFileSystem outFS, List<String> writtenEntries) throws IOException { SummaryInformation si = getSummaryInformation(); if (si != null) { writePropertySet(SummaryInformation.DEFAULT_STREAM_NAME, si, outFS); @@ -258,12 +275,12 @@ public abstract class POIDocument { * Writes out a given ProperySet * @param name the (POIFS Level) name of the property to write * @param set the PropertySet to write out - * @param outFS the POIFSFileSystem to write the property into + * @param outFS the NPOIFSFileSystem to write the property into * * @throws IOException if an error when writing to the - * {@link POIFSFileSystem} occurs + * {@link NPOIFSFileSystem} occurs */ - protected void writePropertySet(String name, PropertySet set, POIFSFileSystem outFS) throws IOException { + protected void writePropertySet(String name, PropertySet set, NPOIFSFileSystem outFS) throws IOException { try { MutablePropertySet mSet = new MutablePropertySet(set); ByteArrayOutputStream bOut = new ByteArrayOutputStream(); @@ -288,55 +305,4 @@ public abstract class POIDocument { * @throws IOException thrown on errors writing to the stream */ public abstract void write(OutputStream out) throws IOException; - - /** - * Copies nodes from one POIFS to the other minus the excepts - * @param source is the source POIFS to copy from - * @param target is the target POIFS to copy to - * @param excepts is a list of Strings specifying what nodes NOT to copy - * - * @throws IOException thrown on errors writing to the target file system. - * - * @deprecated Use {@link EntryUtils#copyNodes(DirectoryEntry, DirectoryEntry, List)} instead - */ - @Deprecated - protected void copyNodes( POIFSFileSystem source, POIFSFileSystem target, - List<String> excepts ) throws IOException { - EntryUtils.copyNodes( source, target, excepts ); - } - - /** - * Copies nodes from one POIFS to the other minus the excepts - * @param sourceRoot is the source POIFS to copy from - * @param targetRoot is the target POIFS to copy to - * @param excepts is a list of Strings specifying what nodes NOT to copy - * - * @throws IOException thrown on errors writing to the target directory node. - * - * @deprecated Use {@link EntryUtils#copyNodes(DirectoryEntry, DirectoryEntry, List)} instead - */ - @Deprecated - protected void copyNodes( DirectoryNode sourceRoot, - DirectoryNode targetRoot, List<String> excepts ) throws IOException - { - EntryUtils.copyNodes( sourceRoot, targetRoot, excepts ); - } - - /** - * Copies an Entry into a target POIFS directory, recursively - * - * @param entry the entry to copy from - * @param target the entry to write to - * - * @throws IOException thrown on errors writing to the target directory entry. - * - * @deprecated Use {@link EntryUtils#copyNodeRecursively(Entry, DirectoryEntry)} instead - */ - @Internal - @Deprecated - protected void copyNodeRecursively( Entry entry, DirectoryEntry target ) - throws IOException - { - EntryUtils.copyNodeRecursively( entry, target ); - } } diff --git a/src/java/org/apache/poi/POIOLE2TextExtractor.java b/src/java/org/apache/poi/POIOLE2TextExtractor.java index c0f4cbd1d7..5dd1d755e3 100644 --- a/src/java/org/apache/poi/POIOLE2TextExtractor.java +++ b/src/java/org/apache/poi/POIOLE2TextExtractor.java @@ -20,7 +20,6 @@ import org.apache.poi.hpsf.DocumentSummaryInformation; import org.apache.poi.hpsf.SummaryInformation; import org.apache.poi.hpsf.extractor.HPSFPropertiesExtractor; import org.apache.poi.poifs.filesystem.DirectoryEntry; -import org.apache.poi.poifs.filesystem.POIFSFileSystem; /** * Common Parent for OLE2 based Text Extractors @@ -34,16 +33,28 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem; * @see org.apache.poi.hwpf.extractor.WordExtractor */ public abstract class POIOLE2TextExtractor extends POITextExtractor { + /** The POIDocument that's open */ + protected POIDocument document; + /** * Creates a new text extractor for the given document * * @param document The POIDocument to use in this extractor. */ public POIOLE2TextExtractor(POIDocument document) { - super(document); + this.document = document; } /** + * Creates a new text extractor, using the same + * document as another text extractor. Normally + * only used by properties extractors. + */ + protected POIOLE2TextExtractor(POIOLE2TextExtractor otherExtractor) { + this.document = otherExtractor.document; + } + + /** * Returns the document information metadata for the document * * @return The Document Summary Information or null @@ -81,17 +92,4 @@ public abstract class POIOLE2TextExtractor extends POITextExtractor { { return document.directory; } - - /** - * Return the underlying POIFS FileSystem of this document. - * - * @return the POIFSFileSystem that is associated with the POIDocument of this extractor. - * - * @deprecated Use {@link #getRoot()} instead - */ - @Deprecated - public POIFSFileSystem getFileSystem() - { - return document.directory.getFileSystem(); - } } diff --git a/src/java/org/apache/poi/POITextExtractor.java b/src/java/org/apache/poi/POITextExtractor.java index e18078b461..6514ad5d18 100644 --- a/src/java/org/apache/poi/POITextExtractor.java +++ b/src/java/org/apache/poi/POITextExtractor.java @@ -31,24 +31,6 @@ import java.io.IOException; * @see org.apache.poi.hwpf.extractor.WordExtractor */ public abstract class POITextExtractor implements Closeable { - /** The POIDocument that's open */ - protected POIDocument document; - - /** - * Creates a new text extractor for the given document - */ - public POITextExtractor(POIDocument document) { - this.document = document; - } - /** - * Creates a new text extractor, using the same - * document as another text extractor. Normally - * only used by properties extractors. - */ - protected POITextExtractor(POITextExtractor otherExtractor) { - this.document = otherExtractor.document; - } - /** * Retrieves all the text from the document. * How cells, paragraphs etc are separated in the text diff --git a/src/java/org/apache/poi/ddf/EscherPropertyFactory.java b/src/java/org/apache/poi/ddf/EscherPropertyFactory.java index 3dcce79b86..efea004382 100644 --- a/src/java/org/apache/poi/ddf/EscherPropertyFactory.java +++ b/src/java/org/apache/poi/ddf/EscherPropertyFactory.java @@ -82,6 +82,13 @@ public final class EscherPropertyFactory { pos += ((EscherArrayProperty)p).setArrayData(data, pos); } else { byte[] complexData = ((EscherComplexProperty)p).getComplexData(); + + int leftover = data.length-pos; + if(leftover < complexData.length){ + throw new IllegalStateException("Could not read complex escher property, lenght was " + complexData.length + ", but had only " + + leftover + " bytes left"); + } + System.arraycopy(data, pos, complexData, 0, complexData.length); pos += complexData.length; } diff --git a/src/java/org/apache/poi/hpsf/HPSFPropertiesOnlyDocument.java b/src/java/org/apache/poi/hpsf/HPSFPropertiesOnlyDocument.java index f1b9ca9629..9b0f84d470 100644 --- a/src/java/org/apache/poi/hpsf/HPSFPropertiesOnlyDocument.java +++ b/src/java/org/apache/poi/hpsf/HPSFPropertiesOnlyDocument.java @@ -24,6 +24,7 @@ import java.util.List; import org.apache.poi.POIDocument; import org.apache.poi.poifs.filesystem.EntryUtils; import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; +import org.apache.poi.poifs.filesystem.OPOIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem; /** @@ -36,6 +37,9 @@ public class HPSFPropertiesOnlyDocument extends POIDocument { public HPSFPropertiesOnlyDocument(NPOIFSFileSystem fs) { super(fs.getRoot()); } + public HPSFPropertiesOnlyDocument(OPOIFSFileSystem fs) { + super(fs); + } public HPSFPropertiesOnlyDocument(POIFSFileSystem fs) { super(fs); } @@ -44,7 +48,7 @@ public class HPSFPropertiesOnlyDocument extends POIDocument { * Write out, with any properties changes, but nothing else */ public void write(OutputStream out) throws IOException { - POIFSFileSystem fs = new POIFSFileSystem(); + NPOIFSFileSystem fs = new NPOIFSFileSystem(); // For tracking what we've written out, so far List<String> excepts = new ArrayList<String>(1); diff --git a/src/java/org/apache/poi/hpsf/Section.java b/src/java/org/apache/poi/hpsf/Section.java index 0c97a0e68a..3c8e5b7ce8 100644 --- a/src/java/org/apache/poi/hpsf/Section.java +++ b/src/java/org/apache/poi/hpsf/Section.java @@ -285,7 +285,7 @@ public class Section /* * Extract the dictionary (if available). */ - dictionary = (Map) getProperty(0); + dictionary = (Map<Long,String>) getProperty(0); } diff --git a/src/java/org/apache/poi/hpsf/extractor/HPSFPropertiesExtractor.java b/src/java/org/apache/poi/hpsf/extractor/HPSFPropertiesExtractor.java index ce5301ac60..b7967f333c 100644 --- a/src/java/org/apache/poi/hpsf/extractor/HPSFPropertiesExtractor.java +++ b/src/java/org/apache/poi/hpsf/extractor/HPSFPropertiesExtractor.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.util.Iterator; import org.apache.poi.POIDocument; +import org.apache.poi.POIOLE2TextExtractor; import org.apache.poi.POITextExtractor; import org.apache.poi.hpsf.CustomProperties; import org.apache.poi.hpsf.DocumentSummaryInformation; @@ -39,10 +40,10 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem; * build in and custom, returning them in * textual form. */ -public class HPSFPropertiesExtractor extends POITextExtractor { +public class HPSFPropertiesExtractor extends POIOLE2TextExtractor { private Closeable toClose; - public HPSFPropertiesExtractor(POITextExtractor mainExtractor) { + public HPSFPropertiesExtractor(POIOLE2TextExtractor mainExtractor) { super(mainExtractor); } public HPSFPropertiesExtractor(POIDocument doc) { @@ -57,6 +58,10 @@ public class HPSFPropertiesExtractor extends POITextExtractor { } public String getDocumentSummaryInformationText() { + if(document == null) { // event based extractor does not have a document + return ""; + } + DocumentSummaryInformation dsi = document.getDocumentSummaryInformation(); StringBuffer text = new StringBuffer(); @@ -78,6 +83,10 @@ public class HPSFPropertiesExtractor extends POITextExtractor { return text.toString(); } public String getSummaryInformationText() { + if(document == null) { // event based extractor does not have a document + return ""; + } + SummaryInformation si = document.getSummaryInformation(); // Just normal properties diff --git a/src/java/org/apache/poi/hssf/dev/BiffDrawingToXml.java b/src/java/org/apache/poi/hssf/dev/BiffDrawingToXml.java index c9f9872711..ca35c631b5 100644 --- a/src/java/org/apache/poi/hssf/dev/BiffDrawingToXml.java +++ b/src/java/org/apache/poi/hssf/dev/BiffDrawingToXml.java @@ -34,7 +34,7 @@ import org.apache.poi.hssf.record.DrawingGroupRecord; import org.apache.poi.hssf.record.EscherAggregate;
import org.apache.poi.hssf.usermodel.HSSFPatriarch;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
/**
* Utility for representing drawings contained in a binary Excel file as a XML tree
@@ -138,7 +138,7 @@ public class BiffDrawingToXml { }
public static void writeToFile(OutputStream fos, InputStream xlsWorkbook, boolean excludeWorkbookRecords, String[] params) throws IOException {
- POIFSFileSystem fs = new POIFSFileSystem(xlsWorkbook);
+ NPOIFSFileSystem fs = new NPOIFSFileSystem(xlsWorkbook);
HSSFWorkbook workbook = new HSSFWorkbook(fs);
InternalWorkbook internalWorkbook = getInternalWorkbook(workbook);
DrawingGroupRecord r = (DrawingGroupRecord) internalWorkbook.findFirstRecordBySid(DrawingGroupRecord.sid);
diff --git a/src/java/org/apache/poi/hssf/dev/BiffViewer.java b/src/java/org/apache/poi/hssf/dev/BiffViewer.java index 5451b27899..3afd25a4ac 100644 --- a/src/java/org/apache/poi/hssf/dev/BiffViewer.java +++ b/src/java/org/apache/poi/hssf/dev/BiffViewer.java @@ -17,13 +17,63 @@ package org.apache.poi.hssf.dev; -import java.io.*; +import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintStream; +import java.io.Writer; import java.util.ArrayList; import java.util.List; import org.apache.poi.hssf.record.*; import org.apache.poi.hssf.record.RecordInputStream.LeftoverDataException; -import org.apache.poi.hssf.record.chart.*; +import org.apache.poi.hssf.record.chart.AreaFormatRecord; +import org.apache.poi.hssf.record.chart.AreaRecord; +import org.apache.poi.hssf.record.chart.AxisLineFormatRecord; +import org.apache.poi.hssf.record.chart.AxisOptionsRecord; +import org.apache.poi.hssf.record.chart.AxisParentRecord; +import org.apache.poi.hssf.record.chart.AxisRecord; +import org.apache.poi.hssf.record.chart.AxisUsedRecord; +import org.apache.poi.hssf.record.chart.BarRecord; +import org.apache.poi.hssf.record.chart.BeginRecord; +import org.apache.poi.hssf.record.chart.CatLabRecord; +import org.apache.poi.hssf.record.chart.CategorySeriesAxisRecord; +import org.apache.poi.hssf.record.chart.ChartEndBlockRecord; +import org.apache.poi.hssf.record.chart.ChartEndObjectRecord; +import org.apache.poi.hssf.record.chart.ChartFRTInfoRecord; +import org.apache.poi.hssf.record.chart.ChartFormatRecord; +import org.apache.poi.hssf.record.chart.ChartRecord; +import org.apache.poi.hssf.record.chart.ChartStartBlockRecord; +import org.apache.poi.hssf.record.chart.ChartStartObjectRecord; +import org.apache.poi.hssf.record.chart.DatRecord; +import org.apache.poi.hssf.record.chart.DataFormatRecord; +import org.apache.poi.hssf.record.chart.DefaultDataLabelTextPropertiesRecord; +import org.apache.poi.hssf.record.chart.EndRecord; +import org.apache.poi.hssf.record.chart.FontBasisRecord; +import org.apache.poi.hssf.record.chart.FontIndexRecord; +import org.apache.poi.hssf.record.chart.FrameRecord; +import org.apache.poi.hssf.record.chart.LegendRecord; +import org.apache.poi.hssf.record.chart.LineFormatRecord; +import org.apache.poi.hssf.record.chart.LinkedDataRecord; +import org.apache.poi.hssf.record.chart.ObjectLinkRecord; +import org.apache.poi.hssf.record.chart.PlotAreaRecord; +import org.apache.poi.hssf.record.chart.PlotGrowthRecord; +import org.apache.poi.hssf.record.chart.SeriesIndexRecord; +import org.apache.poi.hssf.record.chart.SeriesListRecord; +import org.apache.poi.hssf.record.chart.SeriesRecord; +import org.apache.poi.hssf.record.chart.SeriesTextRecord; +import org.apache.poi.hssf.record.chart.SeriesToChartGroupRecord; +import org.apache.poi.hssf.record.chart.SheetPropertiesRecord; +import org.apache.poi.hssf.record.chart.TextRecord; +import org.apache.poi.hssf.record.chart.TickRecord; +import org.apache.poi.hssf.record.chart.UnitsRecord; +import org.apache.poi.hssf.record.chart.ValueRangeRecord; import org.apache.poi.hssf.record.pivottable.DataItemRecord; import org.apache.poi.hssf.record.pivottable.ExtendedPivotTableViewFieldsRecord; import org.apache.poi.hssf.record.pivottable.PageItemRecord; @@ -32,330 +82,330 @@ import org.apache.poi.hssf.record.pivottable.ViewDefinitionRecord; import org.apache.poi.hssf.record.pivottable.ViewFieldsRecord; import org.apache.poi.hssf.record.pivottable.ViewSourceRecord; import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.poifs.filesystem.POIFSFileSystem; +import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndian; /** * Utillity for reading in BIFF8 records and displaying data from them. - * - *@author Andrew C. Oliver (acoliver at apache dot org) - *@author Glen Stampoultzis (glens at apache.org) - *@see #main + * @see #main */ public final class BiffViewer { - static final char[] NEW_LINE_CHARS = System.getProperty("line.separator").toCharArray(); + static final char[] NEW_LINE_CHARS = System.getProperty("line.separator").toCharArray(); private BiffViewer() { - // no instances of this class - } - - /** - * Create an array of records from an input stream - * - *@param is the InputStream from which the records will be obtained - *@return an array of Records created from the InputStream - *@exception RecordFormatException on error processing the InputStream - */ - public static Record[] createRecords(InputStream is, PrintStream ps, BiffRecordListener recListener, boolean dumpInterpretedRecords) - throws RecordFormatException { - List<Record> temp = new ArrayList<Record>(); - - RecordInputStream recStream = new RecordInputStream(is); - while (true) { - boolean hasNext; - try { - hasNext = recStream.hasNextRecord(); - } catch (LeftoverDataException e) { - e.printStackTrace(); - System.err.println("Discarding " + recStream.remaining() + " bytes and continuing"); - recStream.readRemainder(); - hasNext = recStream.hasNextRecord(); - } - if (!hasNext) { - break; - } - recStream.nextRecord(); - if (recStream.getSid() == 0) { - continue; - } - Record record; - if (dumpInterpretedRecords) { - record = createRecord (recStream); - if (record.getSid() == ContinueRecord.sid) { - continue; - } - temp.add(record); - - if (dumpInterpretedRecords) { - for (String header : recListener.getRecentHeaders()) { - ps.println(header); - } - ps.print(record.toString()); - } - } else { - recStream.readRemainder(); - } - ps.println(); - } - Record[] result = new Record[temp.size()]; - temp.toArray(result); - return result; - } - - - /** - * Essentially a duplicate of RecordFactory. Kept separate as not to screw - * up non-debug operations. - * - */ - private static Record createRecord(RecordInputStream in) { - switch (in.getSid()) { - case AreaFormatRecord.sid: return new AreaFormatRecord(in); - case AreaRecord.sid: return new AreaRecord(in); - case ArrayRecord.sid: return new ArrayRecord(in); - case AxisLineFormatRecord.sid: return new AxisLineFormatRecord(in); - case AxisOptionsRecord.sid: return new AxisOptionsRecord(in); - case AxisParentRecord.sid: return new AxisParentRecord(in); - case AxisRecord.sid: return new AxisRecord(in); - case AxisUsedRecord.sid: return new AxisUsedRecord(in); - case AutoFilterInfoRecord.sid: return new AutoFilterInfoRecord(in); - case BOFRecord.sid: return new BOFRecord(in); - case BackupRecord.sid: return new BackupRecord(in); - case BarRecord.sid: return new BarRecord(in); - case BeginRecord.sid: return new BeginRecord(in); - case BlankRecord.sid: return new BlankRecord(in); - case BookBoolRecord.sid: return new BookBoolRecord(in); - case BoolErrRecord.sid: return new BoolErrRecord(in); - case BottomMarginRecord.sid: return new BottomMarginRecord(in); - case BoundSheetRecord.sid: return new BoundSheetRecord(in); - case CFHeaderRecord.sid: return new CFHeaderRecord(in); - case CFRuleRecord.sid: return new CFRuleRecord(in); - case CalcCountRecord.sid: return new CalcCountRecord(in); - case CalcModeRecord.sid: return new CalcModeRecord(in); - case CategorySeriesAxisRecord.sid: return new CategorySeriesAxisRecord(in); - case ChartFormatRecord.sid: return new ChartFormatRecord(in); - case ChartRecord.sid: return new ChartRecord(in); - case CodepageRecord.sid: return new CodepageRecord(in); - case ColumnInfoRecord.sid: return new ColumnInfoRecord(in); - case ContinueRecord.sid: return new ContinueRecord(in); - case CountryRecord.sid: return new CountryRecord(in); - case DBCellRecord.sid: return new DBCellRecord(in); - case DSFRecord.sid: return new DSFRecord(in); - case DatRecord.sid: return new DatRecord(in); - case DataFormatRecord.sid: return new DataFormatRecord(in); - case DateWindow1904Record.sid: return new DateWindow1904Record(in); - case DConRefRecord.sid: return new DConRefRecord(in); - case DefaultColWidthRecord.sid:return new DefaultColWidthRecord(in); - case DefaultDataLabelTextPropertiesRecord.sid: return new DefaultDataLabelTextPropertiesRecord(in); - case DefaultRowHeightRecord.sid: return new DefaultRowHeightRecord(in); - case DeltaRecord.sid: return new DeltaRecord(in); - case DimensionsRecord.sid: return new DimensionsRecord(in); - case DrawingGroupRecord.sid: return new DrawingGroupRecord(in); - case DrawingRecordForBiffViewer.sid: return new DrawingRecordForBiffViewer(in); - case DrawingSelectionRecord.sid: return new DrawingSelectionRecord(in); - case DVRecord.sid: return new DVRecord(in); - case DVALRecord.sid: return new DVALRecord(in); - case EOFRecord.sid: return new EOFRecord(in); - case EndRecord.sid: return new EndRecord(in); - case ExtSSTRecord.sid: return new ExtSSTRecord(in); - case ExtendedFormatRecord.sid: return new ExtendedFormatRecord(in); - case ExternSheetRecord.sid: return new ExternSheetRecord(in); - case ExternalNameRecord.sid: return new ExternalNameRecord(in); - case FeatRecord.sid: return new FeatRecord(in); - case FeatHdrRecord.sid: return new FeatHdrRecord(in); - case FilePassRecord.sid: return new FilePassRecord(in); - case FileSharingRecord.sid: return new FileSharingRecord(in); - case FnGroupCountRecord.sid: return new FnGroupCountRecord(in); - case FontBasisRecord.sid: return new FontBasisRecord(in); - case FontIndexRecord.sid: return new FontIndexRecord(in); - case FontRecord.sid: return new FontRecord(in); - case FooterRecord.sid: return new FooterRecord(in); - case FormatRecord.sid: return new FormatRecord(in); - case FormulaRecord.sid: return new FormulaRecord(in); - case FrameRecord.sid: return new FrameRecord(in); - case GridsetRecord.sid: return new GridsetRecord(in); - case GutsRecord.sid: return new GutsRecord(in); - case HCenterRecord.sid: return new HCenterRecord(in); - case HeaderRecord.sid: return new HeaderRecord(in); - case HideObjRecord.sid: return new HideObjRecord(in); - case HorizontalPageBreakRecord.sid: return new HorizontalPageBreakRecord(in); - case HyperlinkRecord.sid: return new HyperlinkRecord(in); - case IndexRecord.sid: return new IndexRecord(in); - case InterfaceEndRecord.sid: return InterfaceEndRecord.create(in); - case InterfaceHdrRecord.sid: return new InterfaceHdrRecord(in); - case IterationRecord.sid: return new IterationRecord(in); - case LabelRecord.sid: return new LabelRecord(in); - case LabelSSTRecord.sid: return new LabelSSTRecord(in); - case LeftMarginRecord.sid: return new LeftMarginRecord(in); - case LegendRecord.sid: return new LegendRecord(in); - case LineFormatRecord.sid: return new LineFormatRecord(in); - case LinkedDataRecord.sid: return new LinkedDataRecord(in); - case MMSRecord.sid: return new MMSRecord(in); - case MergeCellsRecord.sid: return new MergeCellsRecord(in); - case MulBlankRecord.sid: return new MulBlankRecord(in); - case MulRKRecord.sid: return new MulRKRecord(in); - case NameRecord.sid: return new NameRecord(in); - case NameCommentRecord.sid: return new NameCommentRecord(in); - case NoteRecord.sid: return new NoteRecord(in); - case NumberRecord.sid: return new NumberRecord(in); - case ObjRecord.sid: return new ObjRecord(in); - case ObjectLinkRecord.sid: return new ObjectLinkRecord(in); - case PaletteRecord.sid: return new PaletteRecord(in); - case PaneRecord.sid: return new PaneRecord(in); - case PasswordRecord.sid: return new PasswordRecord(in); - case PasswordRev4Record.sid: return new PasswordRev4Record(in); - case PlotAreaRecord.sid: return new PlotAreaRecord(in); - case PlotGrowthRecord.sid: return new PlotGrowthRecord(in); - case PrecisionRecord.sid: return new PrecisionRecord(in); - case PrintGridlinesRecord.sid: return new PrintGridlinesRecord(in); - case PrintHeadersRecord.sid: return new PrintHeadersRecord(in); - case PrintSetupRecord.sid: return new PrintSetupRecord(in); - case ProtectRecord.sid: return new ProtectRecord(in); - case ProtectionRev4Record.sid: return new ProtectionRev4Record(in); - case RKRecord.sid: return new RKRecord(in); - case RecalcIdRecord.sid: return new RecalcIdRecord(in); - case RefModeRecord.sid: return new RefModeRecord(in); - case RefreshAllRecord.sid: return new RefreshAllRecord(in); - case RightMarginRecord.sid: return new RightMarginRecord(in); - case RowRecord.sid: return new RowRecord(in); - case SCLRecord.sid: return new SCLRecord(in); - case SSTRecord.sid: return new SSTRecord(in); - case SaveRecalcRecord.sid: return new SaveRecalcRecord(in); - case SelectionRecord.sid: return new SelectionRecord(in); - case SeriesIndexRecord.sid: return new SeriesIndexRecord(in); - case SeriesListRecord.sid: return new SeriesListRecord(in); - case SeriesRecord.sid: return new SeriesRecord(in); - case SeriesTextRecord.sid: return new SeriesTextRecord(in); - case SeriesToChartGroupRecord.sid: return new SeriesToChartGroupRecord(in); - case SharedFormulaRecord.sid: return new SharedFormulaRecord(in); - case SheetPropertiesRecord.sid:return new SheetPropertiesRecord(in); - case StringRecord.sid: return new StringRecord(in); - case StyleRecord.sid: return new StyleRecord(in); - case SupBookRecord.sid: return new SupBookRecord(in); - case TabIdRecord.sid: return new TabIdRecord(in); - case TableStylesRecord.sid: return new TableStylesRecord(in); - case TableRecord.sid: return new TableRecord(in); - case TextObjectRecord.sid: return new TextObjectRecord(in); - case TextRecord.sid: return new TextRecord(in); - case TickRecord.sid: return new TickRecord(in); - case TopMarginRecord.sid: return new TopMarginRecord(in); - case UncalcedRecord.sid: return new UncalcedRecord(in); - case UnitsRecord.sid: return new UnitsRecord(in); - case UseSelFSRecord.sid: return new UseSelFSRecord(in); - case VCenterRecord.sid: return new VCenterRecord(in); - case ValueRangeRecord.sid: return new ValueRangeRecord(in); - case VerticalPageBreakRecord.sid: return new VerticalPageBreakRecord(in); - case WSBoolRecord.sid: return new WSBoolRecord(in); - case WindowOneRecord.sid: return new WindowOneRecord(in); - case WindowProtectRecord.sid: return new WindowProtectRecord(in); - case WindowTwoRecord.sid: return new WindowTwoRecord(in); - case WriteAccessRecord.sid: return new WriteAccessRecord(in); - case WriteProtectRecord.sid: return new WriteProtectRecord(in); - - // chart - case CatLabRecord.sid: return new CatLabRecord(in); - case ChartEndBlockRecord.sid: return new ChartEndBlockRecord(in); - case ChartEndObjectRecord.sid: return new ChartEndObjectRecord(in); - case ChartFRTInfoRecord.sid: return new ChartFRTInfoRecord(in); - case ChartStartBlockRecord.sid: return new ChartStartBlockRecord(in); - case ChartStartObjectRecord.sid: return new ChartStartObjectRecord(in); - - // pivot table - case StreamIDRecord.sid: return new StreamIDRecord(in); - case ViewSourceRecord.sid: return new ViewSourceRecord(in); - case PageItemRecord.sid: return new PageItemRecord(in); - case ViewDefinitionRecord.sid: return new ViewDefinitionRecord(in); - case ViewFieldsRecord.sid: return new ViewFieldsRecord(in); - case DataItemRecord.sid: return new DataItemRecord(in); - case ExtendedPivotTableViewFieldsRecord.sid: return new ExtendedPivotTableViewFieldsRecord(in); - } - return new UnknownRecord(in); - } - - private static final class CommandArgs { - - private final boolean _biffhex; - private final boolean _noint; - private final boolean _out; - private final boolean _rawhex; - private final boolean _noHeader; - private final File _file; - - private CommandArgs(boolean biffhex, boolean noint, boolean out, boolean rawhex, boolean noHeader, File file) { - _biffhex = biffhex; - _noint = noint; - _out = out; - _rawhex = rawhex; - _file = file; - _noHeader = noHeader; - } - - public static CommandArgs parse(String[] args) throws CommandParseException { - int nArgs = args.length; - boolean biffhex = false; - boolean noint = false; - boolean out = false; - boolean rawhex = false; - boolean noheader = false; - File file = null; - for (int i=0; i<nArgs; i++) { - String arg = args[i]; - if (arg.startsWith("--")) { - if ("--biffhex".equals(arg)) { - biffhex = true; - } else if ("--noint".equals(arg)) { - noint = true; - } else if ("--out".equals(arg)) { - out = true; - } else if ("--escher".equals(arg)) { - System.setProperty("poi.deserialize.escher", "true"); - } else if ("--rawhex".equals(arg)) { - rawhex = true; - } else if ("--noheader".equals(arg)) { - noheader = true; - } else { - throw new CommandParseException("Unexpected option '" + arg + "'"); - } - continue; - } - file = new File(arg); - if (!file.exists()) { - throw new CommandParseException("Specified file '" + arg + "' does not exist"); - } - if (i+1<nArgs) { - throw new CommandParseException("File name must be the last arg"); - } - } - if (file == null) { - throw new CommandParseException("Biff viewer needs a filename"); - } - return new CommandArgs(biffhex, noint, out, rawhex, noheader, file); - } - public boolean shouldDumpBiffHex() { - return _biffhex; - } - public boolean shouldDumpRecordInterpretations() { - return !_noint; - } - public boolean shouldOutputToFile() { - return _out; - } - public boolean shouldOutputRawHexOnly() { - return _rawhex; - } - public boolean suppressHeader() { - return _noHeader; - } - public File getFile() { - return _file; - } - } - private static final class CommandParseException extends Exception { - public CommandParseException(String msg) { - super(msg); - } - } + // no instances of this class + } + + /** + * Create an array of records from an input stream + * + *@param is the InputStream from which the records will be obtained + *@return an array of Records created from the InputStream + *@exception RecordFormatException on error processing the InputStream + */ + public static Record[] createRecords(InputStream is, PrintStream ps, BiffRecordListener recListener, boolean dumpInterpretedRecords) + throws RecordFormatException { + List<Record> temp = new ArrayList<Record>(); + + RecordInputStream recStream = new RecordInputStream(is); + while (true) { + boolean hasNext; + try { + hasNext = recStream.hasNextRecord(); + } catch (LeftoverDataException e) { + e.printStackTrace(); + System.err.println("Discarding " + recStream.remaining() + " bytes and continuing"); + recStream.readRemainder(); + hasNext = recStream.hasNextRecord(); + } + if (!hasNext) { + break; + } + recStream.nextRecord(); + if (recStream.getSid() == 0) { + continue; + } + Record record; + if (dumpInterpretedRecords) { + record = createRecord (recStream); + if (record.getSid() == ContinueRecord.sid) { + continue; + } + temp.add(record); + + if (dumpInterpretedRecords) { + for (String header : recListener.getRecentHeaders()) { + ps.println(header); + } + ps.print(record.toString()); + } + } else { + recStream.readRemainder(); + } + ps.println(); + } + Record[] result = new Record[temp.size()]; + temp.toArray(result); + return result; + } + + + /** + * Essentially a duplicate of RecordFactory. Kept separate as not to screw + * up non-debug operations. + * + */ + private static Record createRecord(RecordInputStream in) { + switch (in.getSid()) { + case AreaFormatRecord.sid: return new AreaFormatRecord(in); + case AreaRecord.sid: return new AreaRecord(in); + case ArrayRecord.sid: return new ArrayRecord(in); + case AxisLineFormatRecord.sid: return new AxisLineFormatRecord(in); + case AxisOptionsRecord.sid: return new AxisOptionsRecord(in); + case AxisParentRecord.sid: return new AxisParentRecord(in); + case AxisRecord.sid: return new AxisRecord(in); + case AxisUsedRecord.sid: return new AxisUsedRecord(in); + case AutoFilterInfoRecord.sid: return new AutoFilterInfoRecord(in); + case BOFRecord.sid: return new BOFRecord(in); + case BackupRecord.sid: return new BackupRecord(in); + case BarRecord.sid: return new BarRecord(in); + case BeginRecord.sid: return new BeginRecord(in); + case BlankRecord.sid: return new BlankRecord(in); + case BookBoolRecord.sid: return new BookBoolRecord(in); + case BoolErrRecord.sid: return new BoolErrRecord(in); + case BottomMarginRecord.sid: return new BottomMarginRecord(in); + case BoundSheetRecord.sid: return new BoundSheetRecord(in); + case CFHeaderRecord.sid: return new CFHeaderRecord(in); + case CFHeader12Record.sid: return new CFHeader12Record(in); + case CFRuleRecord.sid: return new CFRuleRecord(in); + case CFRule12Record.sid: return new CFRule12Record(in); + // TODO Add CF Ex, and remove from UnknownRecord + case CalcCountRecord.sid: return new CalcCountRecord(in); + case CalcModeRecord.sid: return new CalcModeRecord(in); + case CategorySeriesAxisRecord.sid:return new CategorySeriesAxisRecord(in); + case ChartFormatRecord.sid: return new ChartFormatRecord(in); + case ChartRecord.sid: return new ChartRecord(in); + case CodepageRecord.sid: return new CodepageRecord(in); + case ColumnInfoRecord.sid: return new ColumnInfoRecord(in); + case ContinueRecord.sid: return new ContinueRecord(in); + case CountryRecord.sid: return new CountryRecord(in); + case DBCellRecord.sid: return new DBCellRecord(in); + case DSFRecord.sid: return new DSFRecord(in); + case DatRecord.sid: return new DatRecord(in); + case DataFormatRecord.sid: return new DataFormatRecord(in); + case DateWindow1904Record.sid: return new DateWindow1904Record(in); + case DConRefRecord.sid: return new DConRefRecord(in); + case DefaultColWidthRecord.sid: return new DefaultColWidthRecord(in); + case DefaultDataLabelTextPropertiesRecord.sid: return new DefaultDataLabelTextPropertiesRecord(in); + case DefaultRowHeightRecord.sid: return new DefaultRowHeightRecord(in); + case DeltaRecord.sid: return new DeltaRecord(in); + case DimensionsRecord.sid: return new DimensionsRecord(in); + case DrawingGroupRecord.sid: return new DrawingGroupRecord(in); + case DrawingRecordForBiffViewer.sid: return new DrawingRecordForBiffViewer(in); + case DrawingSelectionRecord.sid: return new DrawingSelectionRecord(in); + case DVRecord.sid: return new DVRecord(in); + case DVALRecord.sid: return new DVALRecord(in); + case EOFRecord.sid: return new EOFRecord(in); + case EndRecord.sid: return new EndRecord(in); + case ExtSSTRecord.sid: return new ExtSSTRecord(in); + case ExtendedFormatRecord.sid: return new ExtendedFormatRecord(in); + case ExternSheetRecord.sid: return new ExternSheetRecord(in); + case ExternalNameRecord.sid: return new ExternalNameRecord(in); + case FeatRecord.sid: return new FeatRecord(in); + case FeatHdrRecord.sid: return new FeatHdrRecord(in); + case FilePassRecord.sid: return new FilePassRecord(in); + case FileSharingRecord.sid: return new FileSharingRecord(in); + case FnGroupCountRecord.sid: return new FnGroupCountRecord(in); + case FontBasisRecord.sid: return new FontBasisRecord(in); + case FontIndexRecord.sid: return new FontIndexRecord(in); + case FontRecord.sid: return new FontRecord(in); + case FooterRecord.sid: return new FooterRecord(in); + case FormatRecord.sid: return new FormatRecord(in); + case FormulaRecord.sid: return new FormulaRecord(in); + case FrameRecord.sid: return new FrameRecord(in); + case GridsetRecord.sid: return new GridsetRecord(in); + case GutsRecord.sid: return new GutsRecord(in); + case HCenterRecord.sid: return new HCenterRecord(in); + case HeaderRecord.sid: return new HeaderRecord(in); + case HideObjRecord.sid: return new HideObjRecord(in); + case HorizontalPageBreakRecord.sid: return new HorizontalPageBreakRecord(in); + case HyperlinkRecord.sid: return new HyperlinkRecord(in); + case IndexRecord.sid: return new IndexRecord(in); + case InterfaceEndRecord.sid: return InterfaceEndRecord.create(in); + case InterfaceHdrRecord.sid: return new InterfaceHdrRecord(in); + case IterationRecord.sid: return new IterationRecord(in); + case LabelRecord.sid: return new LabelRecord(in); + case LabelSSTRecord.sid: return new LabelSSTRecord(in); + case LeftMarginRecord.sid: return new LeftMarginRecord(in); + case LegendRecord.sid: return new LegendRecord(in); + case LineFormatRecord.sid: return new LineFormatRecord(in); + case LinkedDataRecord.sid: return new LinkedDataRecord(in); + case MMSRecord.sid: return new MMSRecord(in); + case MergeCellsRecord.sid: return new MergeCellsRecord(in); + case MulBlankRecord.sid: return new MulBlankRecord(in); + case MulRKRecord.sid: return new MulRKRecord(in); + case NameRecord.sid: return new NameRecord(in); + case NameCommentRecord.sid: return new NameCommentRecord(in); + case NoteRecord.sid: return new NoteRecord(in); + case NumberRecord.sid: return new NumberRecord(in); + case ObjRecord.sid: return new ObjRecord(in); + case ObjectLinkRecord.sid: return new ObjectLinkRecord(in); + case PaletteRecord.sid: return new PaletteRecord(in); + case PaneRecord.sid: return new PaneRecord(in); + case PasswordRecord.sid: return new PasswordRecord(in); + case PasswordRev4Record.sid: return new PasswordRev4Record(in); + case PlotAreaRecord.sid: return new PlotAreaRecord(in); + case PlotGrowthRecord.sid: return new PlotGrowthRecord(in); + case PrecisionRecord.sid: return new PrecisionRecord(in); + case PrintGridlinesRecord.sid: return new PrintGridlinesRecord(in); + case PrintHeadersRecord.sid: return new PrintHeadersRecord(in); + case PrintSetupRecord.sid: return new PrintSetupRecord(in); + case ProtectRecord.sid: return new ProtectRecord(in); + case ProtectionRev4Record.sid: return new ProtectionRev4Record(in); + case RKRecord.sid: return new RKRecord(in); + case RecalcIdRecord.sid: return new RecalcIdRecord(in); + case RefModeRecord.sid: return new RefModeRecord(in); + case RefreshAllRecord.sid: return new RefreshAllRecord(in); + case RightMarginRecord.sid: return new RightMarginRecord(in); + case RowRecord.sid: return new RowRecord(in); + case SCLRecord.sid: return new SCLRecord(in); + case SSTRecord.sid: return new SSTRecord(in); + case SaveRecalcRecord.sid: return new SaveRecalcRecord(in); + case SelectionRecord.sid: return new SelectionRecord(in); + case SeriesIndexRecord.sid: return new SeriesIndexRecord(in); + case SeriesListRecord.sid: return new SeriesListRecord(in); + case SeriesRecord.sid: return new SeriesRecord(in); + case SeriesTextRecord.sid: return new SeriesTextRecord(in); + case SeriesToChartGroupRecord.sid:return new SeriesToChartGroupRecord(in); + case SharedFormulaRecord.sid: return new SharedFormulaRecord(in); + case SheetPropertiesRecord.sid: return new SheetPropertiesRecord(in); + case StringRecord.sid: return new StringRecord(in); + case StyleRecord.sid: return new StyleRecord(in); + case SupBookRecord.sid: return new SupBookRecord(in); + case TabIdRecord.sid: return new TabIdRecord(in); + case TableStylesRecord.sid: return new TableStylesRecord(in); + case TableRecord.sid: return new TableRecord(in); + case TextObjectRecord.sid: return new TextObjectRecord(in); + case TextRecord.sid: return new TextRecord(in); + case TickRecord.sid: return new TickRecord(in); + case TopMarginRecord.sid: return new TopMarginRecord(in); + case UncalcedRecord.sid: return new UncalcedRecord(in); + case UnitsRecord.sid: return new UnitsRecord(in); + case UseSelFSRecord.sid: return new UseSelFSRecord(in); + case VCenterRecord.sid: return new VCenterRecord(in); + case ValueRangeRecord.sid: return new ValueRangeRecord(in); + case VerticalPageBreakRecord.sid: return new VerticalPageBreakRecord(in); + case WSBoolRecord.sid: return new WSBoolRecord(in); + case WindowOneRecord.sid: return new WindowOneRecord(in); + case WindowProtectRecord.sid: return new WindowProtectRecord(in); + case WindowTwoRecord.sid: return new WindowTwoRecord(in); + case WriteAccessRecord.sid: return new WriteAccessRecord(in); + case WriteProtectRecord.sid: return new WriteProtectRecord(in); + + // chart + case CatLabRecord.sid: return new CatLabRecord(in); + case ChartEndBlockRecord.sid: return new ChartEndBlockRecord(in); + case ChartEndObjectRecord.sid: return new ChartEndObjectRecord(in); + case ChartFRTInfoRecord.sid: return new ChartFRTInfoRecord(in); + case ChartStartBlockRecord.sid: return new ChartStartBlockRecord(in); + case ChartStartObjectRecord.sid: return new ChartStartObjectRecord(in); + + // pivot table + case StreamIDRecord.sid: return new StreamIDRecord(in); + case ViewSourceRecord.sid: return new ViewSourceRecord(in); + case PageItemRecord.sid: return new PageItemRecord(in); + case ViewDefinitionRecord.sid: return new ViewDefinitionRecord(in); + case ViewFieldsRecord.sid: return new ViewFieldsRecord(in); + case DataItemRecord.sid: return new DataItemRecord(in); + case ExtendedPivotTableViewFieldsRecord.sid: return new ExtendedPivotTableViewFieldsRecord(in); + } + return new UnknownRecord(in); + } + + private static final class CommandArgs { + + private final boolean _biffhex; + private final boolean _noint; + private final boolean _out; + private final boolean _rawhex; + private final boolean _noHeader; + private final File _file; + + private CommandArgs(boolean biffhex, boolean noint, boolean out, boolean rawhex, boolean noHeader, File file) { + _biffhex = biffhex; + _noint = noint; + _out = out; + _rawhex = rawhex; + _file = file; + _noHeader = noHeader; + } + + public static CommandArgs parse(String[] args) throws CommandParseException { + int nArgs = args.length; + boolean biffhex = false; + boolean noint = false; + boolean out = false; + boolean rawhex = false; + boolean noheader = false; + File file = null; + for (int i=0; i<nArgs; i++) { + String arg = args[i]; + if (arg.startsWith("--")) { + if ("--biffhex".equals(arg)) { + biffhex = true; + } else if ("--noint".equals(arg)) { + noint = true; + } else if ("--out".equals(arg)) { + out = true; + } else if ("--escher".equals(arg)) { + System.setProperty("poi.deserialize.escher", "true"); + } else if ("--rawhex".equals(arg)) { + rawhex = true; + } else if ("--noheader".equals(arg)) { + noheader = true; + } else { + throw new CommandParseException("Unexpected option '" + arg + "'"); + } + continue; + } + file = new File(arg); + if (!file.exists()) { + throw new CommandParseException("Specified file '" + arg + "' does not exist"); + } + if (i+1<nArgs) { + throw new CommandParseException("File name must be the last arg"); + } + } + if (file == null) { + throw new CommandParseException("Biff viewer needs a filename"); + } + return new CommandArgs(biffhex, noint, out, rawhex, noheader, file); + } + public boolean shouldDumpBiffHex() { + return _biffhex; + } + public boolean shouldDumpRecordInterpretations() { + return !_noint; + } + public boolean shouldOutputToFile() { + return _out; + } + public boolean shouldOutputRawHexOnly() { + return _rawhex; + } + public boolean suppressHeader() { + return _noHeader; + } + public File getFile() { + return _file; + } + } + private static final class CommandParseException extends Exception { + public CommandParseException(String msg) { + super(msg); + } + } /** * Method main with 1 argument just run straight biffview against given @@ -420,7 +470,7 @@ public final class BiffViewer { protected static InputStream getPOIFSInputStream(File file) throws IOException, FileNotFoundException { - POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(file)); + NPOIFSFileSystem fs = new NPOIFSFileSystem(new FileInputStream(file)); String workbookName = HSSFWorkbook.getWorkbookDirEntryName(fs.getRoot()); return fs.createDocumentInputStream(workbookName); } diff --git a/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java b/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java index 45ab8d8131..4d0b894e01 100644 --- a/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java +++ b/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java @@ -19,6 +19,7 @@ package org.apache.poi.hssf.eventusermodel; import java.io.InputStream; import java.io.IOException; +import java.util.Set; import org.apache.poi.hssf.eventusermodel.HSSFUserException; import org.apache.poi.hssf.record.*; @@ -56,11 +57,24 @@ public class HSSFEventFactory { * @param req an Instance of HSSFRequest which has your registered listeners * @param dir a DirectoryNode containing your workbook */ - public void processWorkbookEvents(HSSFRequest req, DirectoryNode dir) throws IOException { - InputStream in = dir.createDocumentInputStream("Workbook"); - - processEvents(req, in); - } + public void processWorkbookEvents(HSSFRequest req, DirectoryNode dir) throws IOException { + // some old documents have "WORKBOOK" or "BOOK" + final String name; + Set<String> entryNames = dir.getEntryNames(); + if (entryNames.contains("Workbook")) { + name = "Workbook"; + } else if (entryNames.contains("WORKBOOK")) { + name = "WORKBOOK"; + } else if (entryNames.contains("BOOK")) { + name = "BOOK"; + } else { + name = "Workbook"; + } + + InputStream in = dir.createDocumentInputStream(name); + + processEvents(req, in); + } /** * Processes a file into essentially record events. diff --git a/src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java b/src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java index 889de20b4c..4220ca2614 100644 --- a/src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java +++ b/src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; +import org.apache.poi.POIDocument; import org.apache.poi.POIOLE2TextExtractor; import org.apache.poi.hpsf.DocumentSummaryInformation; import org.apache.poi.hpsf.SummaryInformation; @@ -75,7 +76,7 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor implements or public EventBasedExcelExtractor( DirectoryNode dir ) { - super( null ); + super( (POIDocument)null ); _dir = dir; } @@ -84,16 +85,6 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor implements or } /** - * Return the underlying POIFS FileSystem of - * this document. - * - * @deprecated Use {@link #getRoot()} instead - */ - public POIFSFileSystem getFileSystem() { - return _dir.getFileSystem(); - } - - /** * Would return the document information metadata for the document, * if we supported it */ diff --git a/src/java/org/apache/poi/hssf/model/InternalWorkbook.java b/src/java/org/apache/poi/hssf/model/InternalWorkbook.java index 3c3b91b148..a2670978ea 100644 --- a/src/java/org/apache/poi/hssf/model/InternalWorkbook.java +++ b/src/java/org/apache/poi/hssf/model/InternalWorkbook.java @@ -774,11 +774,12 @@ public final class InternalWorkbook { } } - // also tell the LinkTable about the removed sheet - // +1 because we already removed it from the count of sheets! - for(int i = sheetIndex+1;i < getNumSheets()+1;i++) { - // also update the link-table as otherwise references might point at invalid sheets - linkTable.removeSheet(i); + if (linkTable != null) { + // also tell the LinkTable about the removed sheet + // +1 because we already removed it from the count of sheets! + for(int i = sheetIndex+1;i < getNumSheets()+1;i++) { + linkTable.removeSheet(i); + } } } diff --git a/src/java/org/apache/poi/hssf/record/CFHeader12Record.java b/src/java/org/apache/poi/hssf/record/CFHeader12Record.java new file mode 100644 index 0000000000..89c4421de5 --- /dev/null +++ b/src/java/org/apache/poi/hssf/record/CFHeader12Record.java @@ -0,0 +1,88 @@ +/* ==================================================================== + 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.hssf.record; + +import org.apache.poi.hssf.record.common.FtrHeader; +import org.apache.poi.hssf.record.common.FutureRecord; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.util.LittleEndianOutput; + +/** + * Conditional Formatting Header v12 record CFHEADER12 (0x0879), + * for conditional formattings introduced in Excel 2007 and newer. + */ +public final class CFHeader12Record extends CFHeaderBase implements FutureRecord { + public static final short sid = 0x0879; + + private FtrHeader futureHeader; + + /** Creates new CFHeaderRecord */ + public CFHeader12Record() { + createEmpty(); + futureHeader = new FtrHeader(); + futureHeader.setRecordType(sid); + } + public CFHeader12Record(CellRangeAddress[] regions, int nRules) { + super(regions, nRules); + futureHeader = new FtrHeader(); + futureHeader.setRecordType(sid); + } + public CFHeader12Record(RecordInputStream in) { + futureHeader = new FtrHeader(in); + read(in); + } + + @Override + protected String getRecordName() { + return "CFHEADER12"; + } + + protected int getDataSize() { + return FtrHeader.getDataSize() + super.getDataSize(); + } + + public void serialize(LittleEndianOutput out) { + // Sync the associated range + futureHeader.setAssociatedRange(getEnclosingCellRange()); + // Write the future header first + futureHeader.serialize(out); + // Then the rest of the CF Header details + super.serialize(out); + } + + public short getSid() { + return sid; + } + + public short getFutureRecordType() { + return futureHeader.getRecordType(); + } + public FtrHeader getFutureHeader() { + return futureHeader; + } + public CellRangeAddress getAssociatedRange() { + return futureHeader.getAssociatedRange(); + } + + public Object clone() { + CFHeader12Record result = new CFHeader12Record(); + result.futureHeader = (FtrHeader)futureHeader.clone(); + super.copyTo(result); + return result; + } +} diff --git a/src/java/org/apache/poi/hssf/record/CFHeaderBase.java b/src/java/org/apache/poi/hssf/record/CFHeaderBase.java new file mode 100644 index 0000000000..4e40a34613 --- /dev/null +++ b/src/java/org/apache/poi/hssf/record/CFHeaderBase.java @@ -0,0 +1,153 @@ +/* ==================================================================== + 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.hssf.record; + +import org.apache.poi.hssf.record.cf.CellRangeUtil; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.CellRangeAddressList; +import org.apache.poi.util.LittleEndianOutput; + +/** + * Parent of Conditional Formatting Header records, + * {@link CFHeaderRecord} and {@link CFHeader12Record}. + */ +public abstract class CFHeaderBase extends StandardRecord { + private int field_1_numcf; + private int field_2_need_recalculation_and_id; + private CellRangeAddress field_3_enclosing_cell_range; + private CellRangeAddressList field_4_cell_ranges; + + /** Creates new CFHeaderBase */ + protected CFHeaderBase() { + } + protected CFHeaderBase(CellRangeAddress[] regions, int nRules) { + CellRangeAddress[] unmergedRanges = regions; + CellRangeAddress[] mergeCellRanges = CellRangeUtil.mergeCellRanges(unmergedRanges); + setCellRanges(mergeCellRanges); + field_1_numcf = nRules; + } + + protected void createEmpty() { + field_3_enclosing_cell_range = new CellRangeAddress(0, 0, 0, 0); + field_4_cell_ranges = new CellRangeAddressList(); + } + protected void read(RecordInputStream in) { + field_1_numcf = in.readShort(); + field_2_need_recalculation_and_id = in.readShort(); + field_3_enclosing_cell_range = new CellRangeAddress(in); + field_4_cell_ranges = new CellRangeAddressList(in); + } + + public int getNumberOfConditionalFormats() { + return field_1_numcf; + } + public void setNumberOfConditionalFormats(int n) { + field_1_numcf=n; + } + + public boolean getNeedRecalculation() { + // Held on the 1st bit + return field_2_need_recalculation_and_id % 2 == 1; + } + public void setNeedRecalculation(boolean b) { + // held on the first bit + if (b == getNeedRecalculation()) return; + if (b) field_2_need_recalculation_and_id++; + else field_2_need_recalculation_and_id--; + } + + public int getID() { + // Remaining 15 bits of field 2 + return field_2_need_recalculation_and_id>>1; + } + public void setID(int id) { + // Remaining 15 bits of field 2 + boolean needsRecalc = getNeedRecalculation(); + field_2_need_recalculation_and_id = (id<<1); + if (needsRecalc) field_2_need_recalculation_and_id++; + } + + public CellRangeAddress getEnclosingCellRange() { + return field_3_enclosing_cell_range; + } + public void setEnclosingCellRange(CellRangeAddress cr) { + field_3_enclosing_cell_range = cr; + } + + /** + * Set cell ranges list to a single cell range and + * modify the enclosing cell range accordingly. + * @param cellRanges - list of CellRange objects + */ + public void setCellRanges(CellRangeAddress[] cellRanges) { + if(cellRanges == null) { + throw new IllegalArgumentException("cellRanges must not be null"); + } + CellRangeAddressList cral = new CellRangeAddressList(); + CellRangeAddress enclosingRange = null; + for (int i = 0; i < cellRanges.length; i++) { + CellRangeAddress cr = cellRanges[i]; + enclosingRange = CellRangeUtil.createEnclosingCellRange(cr, enclosingRange); + cral.addCellRangeAddress(cr); + } + field_3_enclosing_cell_range = enclosingRange; + field_4_cell_ranges = cral; + } + + public CellRangeAddress[] getCellRanges() { + return field_4_cell_ranges.getCellRangeAddresses(); + } + + protected abstract String getRecordName(); + public String toString() { + StringBuffer buffer = new StringBuffer(); + + buffer.append("[").append(getRecordName()).append("]\n"); + buffer.append("\t.numCF = ").append(getNumberOfConditionalFormats()).append("\n"); + buffer.append("\t.needRecalc = ").append(getNeedRecalculation()).append("\n"); + buffer.append("\t.id = ").append(getID()).append("\n"); + buffer.append("\t.enclosingCellRange= ").append(getEnclosingCellRange()).append("\n"); + buffer.append("\t.cfranges=["); + for( int i=0; i<field_4_cell_ranges.countRanges(); i++) { + buffer.append(i==0?"":",").append(field_4_cell_ranges.getCellRangeAddress(i).toString()); + } + buffer.append("]\n"); + buffer.append("[/").append(getRecordName()).append("]\n"); + return buffer.toString(); + } + + protected int getDataSize() { + return 4 // 2 short fields + + CellRangeAddress.ENCODED_SIZE + + field_4_cell_ranges.getSize(); + } + + public void serialize(LittleEndianOutput out) { + out.writeShort(field_1_numcf); + out.writeShort(field_2_need_recalculation_and_id); + field_3_enclosing_cell_range.serialize(out); + field_4_cell_ranges.serialize(out); + } + + protected void copyTo(CFHeaderBase result) { + result.field_1_numcf = field_1_numcf; + result.field_2_need_recalculation_and_id = field_2_need_recalculation_and_id; + result.field_3_enclosing_cell_range = field_3_enclosing_cell_range.copy(); + result.field_4_cell_ranges = field_4_cell_ranges.copy(); + } +} diff --git a/src/java/org/apache/poi/hssf/record/CFHeaderRecord.java b/src/java/org/apache/poi/hssf/record/CFHeaderRecord.java index eb17ee2758..a456224a70 100644 --- a/src/java/org/apache/poi/hssf/record/CFHeaderRecord.java +++ b/src/java/org/apache/poi/hssf/record/CFHeaderRecord.java @@ -17,144 +17,39 @@ package org.apache.poi.hssf.record; -import org.apache.poi.hssf.record.cf.CellRangeUtil; import org.apache.poi.ss.util.CellRangeAddress; -import org.apache.poi.ss.util.CellRangeAddressList; -import org.apache.poi.util.LittleEndianOutput; /** - * Conditional Formatting Header record CFHEADER (0x01B0) - * - * @author Dmitriy Kumshayev + * Conditional Formatting Header record CFHEADER (0x01B0). + * Used to describe a {@link CFRuleRecord}. + * @see CFHeader12Record */ -public final class CFHeaderRecord extends StandardRecord { - public static final short sid = 0x01B0; - - private int field_1_numcf; - private int field_2_need_recalculation; - private CellRangeAddress field_3_enclosing_cell_range; - private CellRangeAddressList field_4_cell_ranges; - - /** Creates new CFHeaderRecord */ - public CFHeaderRecord() - { - field_4_cell_ranges = new CellRangeAddressList(); - } - public CFHeaderRecord(CellRangeAddress[] regions, int nRules) { - CellRangeAddress[] unmergedRanges = regions; - CellRangeAddress[] mergeCellRanges = CellRangeUtil.mergeCellRanges(unmergedRanges); - setCellRanges(mergeCellRanges); - field_1_numcf = nRules; - } - - public CFHeaderRecord(RecordInputStream in) - { - field_1_numcf = in.readShort(); - field_2_need_recalculation = in.readShort(); - field_3_enclosing_cell_range = new CellRangeAddress(in); - field_4_cell_ranges = new CellRangeAddressList(in); - } - - public int getNumberOfConditionalFormats() - { - return field_1_numcf; - } - public void setNumberOfConditionalFormats(int n) - { - field_1_numcf=n; - } - - public boolean getNeedRecalculation() - { - return field_2_need_recalculation==1?true:false; - } - - public void setNeedRecalculation(boolean b) - { - field_2_need_recalculation=b?1:0; - } - - public CellRangeAddress getEnclosingCellRange() - { - return field_3_enclosing_cell_range; - } - - public void setEnclosingCellRange(CellRangeAddress cr) - { - field_3_enclosing_cell_range = cr; - } - - /** - * Set cell ranges list to a single cell range and - * modify the enclosing cell range accordingly. - * @param cellRanges - list of CellRange objects - */ - public void setCellRanges(CellRangeAddress[] cellRanges) - { - if(cellRanges == null) - { - throw new IllegalArgumentException("cellRanges must not be null"); - } - CellRangeAddressList cral = new CellRangeAddressList(); - CellRangeAddress enclosingRange = null; - for (int i = 0; i < cellRanges.length; i++) - { - CellRangeAddress cr = cellRanges[i]; - enclosingRange = CellRangeUtil.createEnclosingCellRange(cr, enclosingRange); - cral.addCellRangeAddress(cr); - } - field_3_enclosing_cell_range = enclosingRange; - field_4_cell_ranges = cral; - } - - public CellRangeAddress[] getCellRanges() { - return field_4_cell_ranges.getCellRangeAddresses(); - } - - public String toString() - { - StringBuffer buffer = new StringBuffer(); - - buffer.append("[CFHEADER]\n"); - buffer.append(" .id = ").append(Integer.toHexString(sid)).append("\n"); - buffer.append(" .numCF = ").append(getNumberOfConditionalFormats()).append("\n"); - buffer.append(" .needRecalc = ").append(getNeedRecalculation()).append("\n"); - buffer.append(" .enclosingCellRange= ").append(getEnclosingCellRange()).append("\n"); - buffer.append(" .cfranges=["); - for( int i=0; i<field_4_cell_ranges.countRanges(); i++) - { - buffer.append(i==0?"":",").append(field_4_cell_ranges.getCellRangeAddress(i).toString()); - } - buffer.append("]\n"); - buffer.append("[/CFHEADER]\n"); - return buffer.toString(); - } - - protected int getDataSize() { - return 4 // 2 short fields - + CellRangeAddress.ENCODED_SIZE - + field_4_cell_ranges.getSize(); - } - - public void serialize(LittleEndianOutput out) { - - out.writeShort(field_1_numcf); - out.writeShort(field_2_need_recalculation); - field_3_enclosing_cell_range.serialize(out); - field_4_cell_ranges.serialize(out); - } - - public short getSid() { - return sid; - } - - public Object clone() - { - CFHeaderRecord result = new CFHeaderRecord(); - result.field_1_numcf = field_1_numcf; - result.field_2_need_recalculation = field_2_need_recalculation; - result.field_3_enclosing_cell_range = field_3_enclosing_cell_range; - result.field_4_cell_ranges = field_4_cell_ranges.copy(); - return result; - } +public final class CFHeaderRecord extends CFHeaderBase { + public static final short sid = 0x01B0; + + /** Creates new CFHeaderRecord */ + public CFHeaderRecord() { + createEmpty(); + } + public CFHeaderRecord(CellRangeAddress[] regions, int nRules) { + super(regions, nRules); + } + + public CFHeaderRecord(RecordInputStream in) { + read(in); + } + + protected String getRecordName() { + return "CFHEADER"; + } + + public short getSid() { + return sid; + } + + public Object clone() { + CFHeaderRecord result = new CFHeaderRecord(); + super.copyTo(result); + return result; + } } diff --git a/src/java/org/apache/poi/hssf/record/CFRule12Record.java b/src/java/org/apache/poi/hssf/record/CFRule12Record.java new file mode 100644 index 0000000000..c9d0f174b9 --- /dev/null +++ b/src/java/org/apache/poi/hssf/record/CFRule12Record.java @@ -0,0 +1,365 @@ +/* ==================================================================== + 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.hssf.record; + +import java.util.Arrays; + +import org.apache.poi.hssf.record.cf.IconMultiStateFormatting; +import org.apache.poi.hssf.record.cf.Threshold; +import org.apache.poi.hssf.record.common.FtrHeader; +import org.apache.poi.hssf.record.common.FutureRecord; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.ss.formula.Formula; +import org.apache.poi.ss.formula.ptg.Ptg; +import org.apache.poi.ss.usermodel.IconMultiStateFormatting.IconSet; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.util.HexDump; +import org.apache.poi.util.LittleEndianOutput; +import org.apache.poi.util.POILogger; + +/** + * Conditional Formatting v12 Rule Record (0x087A). + * + * <p>This is for newer-style Excel conditional formattings, + * from Excel 2007 onwards. + * + * <p>{@link CFRuleRecord} is used where the condition type is + * {@link #CONDITION_TYPE_CELL_VALUE_IS} or {@link #CONDITION_TYPE_FORMULA}, + * this is only used for the other types + */ +public final class CFRule12Record extends CFRuleBase implements FutureRecord { + public static final short sid = 0x087A; + + private FtrHeader futureHeader; + private int ext_formatting_length; + private byte[] ext_formatting_data; + private Formula formula_scale; + private byte ext_opts; + private int priority; + private int template_type; + private byte template_param_length; + private byte[] template_params; + + private IconMultiStateFormatting multistate; + + // TODO Parse these + private byte[] gradient_data; + private byte[] databar_data; + private byte[] filter_data; + + /** Creates new CFRuleRecord */ + private CFRule12Record(byte conditionType, byte comparisonOperation) { + super(conditionType, comparisonOperation); + setDefaults(); + } + + private CFRule12Record(byte conditionType, byte comparisonOperation, Ptg[] formula1, Ptg[] formula2, Ptg[] formulaScale) { + super(conditionType, comparisonOperation, formula1, formula2); + setDefaults(); + this.formula_scale = Formula.create(formulaScale); + } + private void setDefaults() { + futureHeader = new FtrHeader(); + futureHeader.setRecordType(sid); + + ext_formatting_length = 0; + ext_formatting_data = new byte[4]; + + formula_scale = Formula.create(Ptg.EMPTY_PTG_ARRAY); + + ext_opts = 0; + priority = 0; + template_type = getConditionType(); + template_param_length = 16; + template_params = new byte[template_param_length]; + } + + /** + * Creates a new comparison operation rule + */ + public static CFRule12Record create(HSSFSheet sheet, String formulaText) { + Ptg[] formula1 = parseFormula(formulaText, sheet); + return new CFRule12Record(CONDITION_TYPE_FORMULA, ComparisonOperator.NO_COMPARISON, + formula1, null, null); + } + /** + * Creates a new comparison operation rule + */ + public static CFRule12Record create(HSSFSheet sheet, byte comparisonOperation, + String formulaText1, String formulaText2) { + Ptg[] formula1 = parseFormula(formulaText1, sheet); + Ptg[] formula2 = parseFormula(formulaText2, sheet); + return new CFRule12Record(CONDITION_TYPE_CELL_VALUE_IS, comparisonOperation, + formula1, formula2, null); + } + /** + * Creates a new comparison operation rule + */ + public static CFRule12Record create(HSSFSheet sheet, byte comparisonOperation, + String formulaText1, String formulaText2, String formulaTextScale) { + Ptg[] formula1 = parseFormula(formulaText1, sheet); + Ptg[] formula2 = parseFormula(formulaText2, sheet); + Ptg[] formula3 = parseFormula(formulaTextScale, sheet); + return new CFRule12Record(CONDITION_TYPE_CELL_VALUE_IS, comparisonOperation, + formula1, formula2, formula3); + } + /** + * Creates a new Icon Set / Multi-State formatting + */ + public static CFRule12Record create(HSSFSheet sheet, IconSet iconSet) { + Threshold[] ts = new Threshold[iconSet.num]; + for (int i=0; i<ts.length; i++) { + ts[i] = new Threshold(); + } + + CFRule12Record r = new CFRule12Record(CONDITION_TYPE_COLOR_SCALE, + ComparisonOperator.NO_COMPARISON); + IconMultiStateFormatting imf = r.createMultiStateFormatting(); + imf.setIconSet(iconSet); + imf.setThresholds(ts); + return r; + } + // TODO Static creators for the other record types + + public CFRule12Record(RecordInputStream in) { + futureHeader = new FtrHeader(in); + setConditionType(in.readByte()); + setComparisonOperation(in.readByte()); + int field_3_formula1_len = in.readUShort(); + int field_4_formula2_len = in.readUShort(); + + ext_formatting_length = in.readInt(); + ext_formatting_data = new byte[0]; + if (ext_formatting_length == 0) { + // 2 bytes reserved + in.readUShort(); + } else { + int len = readFormatOptions(in); + if (len < ext_formatting_length) { + ext_formatting_data = new byte[ext_formatting_length-len]; + in.readFully(ext_formatting_data); + } + } + + setFormula1(Formula.read(field_3_formula1_len, in)); + setFormula2(Formula.read(field_4_formula2_len, in)); + + int formula_scale_len = in.readUShort(); + formula_scale = Formula.read(formula_scale_len, in); + + ext_opts = in.readByte(); + priority = in.readUShort(); + template_type = in.readUShort(); + template_param_length = in.readByte(); + if (template_param_length == 0 || template_param_length == 16) { + template_params = new byte[template_param_length]; + in.readFully(template_params); + } else { + logger.log(POILogger.WARN, "CF Rule v12 template params length should be 0 or 16, found " + template_param_length); + in.readRemainder(); + } + + byte type = getConditionType(); + if (type == CONDITION_TYPE_COLOR_SCALE) { + gradient_data = in.readRemainder(); + } else if (type == CONDITION_TYPE_DATA_BAR) { + databar_data = in.readRemainder(); + } else if (type == CONDITION_TYPE_FILTER) { + filter_data = in.readRemainder(); + } else if (type == CONDITION_TYPE_ICON_SET) { + multistate = new IconMultiStateFormatting(in); + } + } + + public boolean containsMultiStateBlock() { + return (multistate != null); + } + public IconMultiStateFormatting getMultiStateFormatting() { + return multistate; + } + public IconMultiStateFormatting createMultiStateFormatting() { + if (multistate != null) return multistate; + + // Convert, setup and return + setConditionType(CONDITION_TYPE_ICON_SET); + multistate = new IconMultiStateFormatting(); + return multistate; + } + + /** + * get the stack of the scale expression as a list + * + * @return list of tokens (casts stack to a list and returns it!) + * this method can return null is we are unable to create Ptgs from + * existing excel file + * callers should check for null! + */ + public Ptg[] getParsedExpressionScale() { + return formula_scale.getTokens(); + } + public void setParsedExpressionScale(Ptg[] ptgs) { + formula_scale = Formula.create(ptgs); + } + + public short getSid() { + return sid; + } + + /** + * called by the class that is responsible for writing this sucker. + * Subclasses should implement this so that their data is passed back in a + * byte array. + * + * @param out the stream to write to + */ + public void serialize(LittleEndianOutput out) { + futureHeader.serialize(out); + + int formula1Len=getFormulaSize(getFormula1()); + int formula2Len=getFormulaSize(getFormula2()); + + out.writeByte(getConditionType()); + out.writeByte(getComparisonOperation()); + out.writeShort(formula1Len); + out.writeShort(formula2Len); + + // TODO Update ext_formatting_length + if (ext_formatting_length == 0) { + out.writeInt(0); + out.writeShort(0); + } else { + out.writeInt(ext_formatting_length); + serializeFormattingBlock(out); + out.write(ext_formatting_data); + } + + getFormula1().serializeTokens(out); + getFormula2().serializeTokens(out); + out.writeShort(getFormulaSize(formula_scale)); + formula_scale.serializeTokens(out); + + out.writeByte(ext_opts); + out.writeShort(priority); + out.writeShort(template_type); + out.writeByte(template_param_length); + out.write(template_params); + + byte type = getConditionType(); + if (type == CONDITION_TYPE_COLOR_SCALE) { + out.write(gradient_data); + } else if (type == CONDITION_TYPE_DATA_BAR) { + out.write(databar_data); + } else if (type == CONDITION_TYPE_FILTER) { + out.write(filter_data); + } else if (type == CONDITION_TYPE_ICON_SET) { + multistate.serialize(out); + } + } + + protected int getDataSize() { + int len = FtrHeader.getDataSize() + 6; + if (ext_formatting_length == 0) { + len += 6; + } else { + len += 4 + getFormattingBlockSize() + ext_formatting_data.length; + } + len += getFormulaSize(getFormula1()); + len += getFormulaSize(getFormula2()); + len += 2 + getFormulaSize(formula_scale); + len += 6 + template_params.length; + + byte type = getConditionType(); + if (type == CONDITION_TYPE_COLOR_SCALE) { + len += gradient_data.length; + } else if (type == CONDITION_TYPE_DATA_BAR) { + len += databar_data.length; + } else if (type == CONDITION_TYPE_FILTER) { + len += filter_data.length; + } else if (type == CONDITION_TYPE_ICON_SET) { + len += multistate.getDataLength(); + } + return len; + } + + public String toString() { + StringBuffer buffer = new StringBuffer(); + buffer.append("[CFRULE12]\n"); + buffer.append(" .condition_type=").append(getConditionType()).append("\n"); + buffer.append(" .dxfn12_length =0x").append(Integer.toHexString(ext_formatting_length)).append("\n"); + buffer.append(" .option_flags =0x").append(Integer.toHexString(getOptions())).append("\n"); + if (containsFontFormattingBlock()) { + buffer.append(_fontFormatting.toString()).append("\n"); + } + if (containsBorderFormattingBlock()) { + buffer.append(_borderFormatting.toString()).append("\n"); + } + if (containsPatternFormattingBlock()) { + buffer.append(_patternFormatting.toString()).append("\n"); + } + buffer.append(" .dxfn12_ext=").append(HexDump.toHex(ext_formatting_data)).append("\n"); + buffer.append(" .formula_1 =").append(Arrays.toString(getFormula1().getTokens())).append("\n"); + buffer.append(" .formula_2 =").append(Arrays.toString(getFormula2().getTokens())).append("\n"); + buffer.append(" .formula_S =").append(Arrays.toString(formula_scale.getTokens())).append("\n"); + buffer.append(" .ext_opts =").append(ext_opts).append("\n"); + buffer.append(" .priority =").append(priority).append("\n"); + buffer.append(" .template_type =").append(template_type).append("\n"); + buffer.append(" .template_params=").append(HexDump.toHex(template_params)).append("\n"); + buffer.append(" .gradient_data =").append(HexDump.toHex(gradient_data)).append("\n"); + buffer.append(" .databar_data =").append(HexDump.toHex(databar_data)).append("\n"); + buffer.append(" .filter_data =").append(HexDump.toHex(filter_data)).append("\n"); + if (multistate != null) { + buffer.append(multistate); + } + buffer.append("[/CFRULE12]\n"); + return buffer.toString(); + } + + public Object clone() { + CFRule12Record rec = new CFRule12Record(getConditionType(), getComparisonOperation()); + rec.futureHeader.setAssociatedRange(futureHeader.getAssociatedRange().copy()); + + super.copyTo(rec); + + rec.ext_formatting_length = ext_formatting_length; + rec.ext_formatting_data = new byte[ext_formatting_length]; + System.arraycopy(ext_formatting_data, 0, rec.ext_formatting_data, 0, ext_formatting_length); + + rec.formula_scale = formula_scale.copy(); + + rec.ext_opts = ext_opts; + rec.priority = priority; + rec.template_type = template_type; + rec.template_param_length = template_param_length; + rec.template_params = new byte[template_param_length]; + System.arraycopy(template_params, 0, rec.template_params, 0, template_param_length); + + // TODO Clone the rgbCT data like Gradients, Databars etc + + return rec; + } + + public short getFutureRecordType() { + return futureHeader.getRecordType(); + } + public FtrHeader getFutureHeader() { + return futureHeader; + } + public CellRangeAddress getAssociatedRange() { + return futureHeader.getAssociatedRange(); + } +} diff --git a/src/java/org/apache/poi/hssf/record/CFRuleBase.java b/src/java/org/apache/poi/hssf/record/CFRuleBase.java new file mode 100644 index 0000000000..7dfcc376fd --- /dev/null +++ b/src/java/org/apache/poi/hssf/record/CFRuleBase.java @@ -0,0 +1,455 @@ +/* ==================================================================== + 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.hssf.record; + +import org.apache.poi.hssf.model.HSSFFormulaParser; +import org.apache.poi.hssf.record.cf.BorderFormatting; +import org.apache.poi.hssf.record.cf.FontFormatting; +import org.apache.poi.hssf.record.cf.PatternFormatting; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.ss.formula.Formula; +import org.apache.poi.ss.formula.FormulaType; +import org.apache.poi.ss.formula.ptg.Ptg; +import org.apache.poi.util.BitField; +import org.apache.poi.util.BitFieldFactory; +import org.apache.poi.util.LittleEndianOutput; +import org.apache.poi.util.POILogFactory; +import org.apache.poi.util.POILogger; + +/** + * Conditional Formatting Rules. This can hold old-style rules + * + * + * <p>This is for the older-style Excel conditional formattings, + * new-style (Excel 2007+) also make use of {@link CFRule12Record} + * and {@link CFExRuleRecord} for their rules. + */ +public abstract class CFRuleBase extends StandardRecord { + public static final class ComparisonOperator { + public static final byte NO_COMPARISON = 0; + public static final byte BETWEEN = 1; + public static final byte NOT_BETWEEN = 2; + public static final byte EQUAL = 3; + public static final byte NOT_EQUAL = 4; + public static final byte GT = 5; + public static final byte LT = 6; + public static final byte GE = 7; + public static final byte LE = 8; + private static final byte max_operator = 8; + } + protected static final POILogger logger = POILogFactory.getLogger(CFRuleBase.class); + + private byte condition_type; + // The only kinds that CFRuleRecord handles + public static final byte CONDITION_TYPE_CELL_VALUE_IS = 1; + public static final byte CONDITION_TYPE_FORMULA = 2; + // These are CFRule12Rule only + public static final byte CONDITION_TYPE_COLOR_SCALE = 3; + public static final byte CONDITION_TYPE_DATA_BAR = 4; + public static final byte CONDITION_TYPE_FILTER = 5; + public static final byte CONDITION_TYPE_ICON_SET = 6; + + private byte comparison_operator; + + public static final int TEMPLATE_CELL_VALUE = 0x0000; + public static final int TEMPLATE_FORMULA = 0x0001; + public static final int TEMPLATE_COLOR_SCALE_FORMATTING = 0x0002; + public static final int TEMPLATE_DATA_BAR_FORMATTING = 0x0003; + public static final int TEMPLATE_ICON_SET_FORMATTING = 0x0004; + public static final int TEMPLATE_FILTER = 0x0005; + public static final int TEMPLATE_UNIQUE_VALUES = 0x0007; + public static final int TEMPLATE_CONTAINS_TEXT = 0x0008; + public static final int TEMPLATE_CONTAINS_BLANKS = 0x0009; + public static final int TEMPLATE_CONTAINS_NO_BLANKS = 0x000A; + public static final int TEMPLATE_CONTAINS_ERRORS = 0x000B; + public static final int TEMPLATE_CONTAINS_NO_ERRORS = 0x000C; + public static final int TEMPLATE_TODAY = 0x000F; + public static final int TEMPLATE_TOMORROW = 0x0010; + public static final int TEMPLATE_YESTERDAY = 0x0011; + public static final int TEMPLATE_LAST_7_DAYS = 0x0012; + public static final int TEMPLATE_LAST_MONTH = 0x0013; + public static final int TEMPLATE_NEXT_MONTH = 0x0014; + public static final int TEMPLATE_THIS_WEEK = 0x0015; + public static final int TEMPLATE_NEXT_WEEK = 0x0016; + public static final int TEMPLATE_LAST_WEEK = 0x0017; + public static final int TEMPLATE_THIS_MONTH = 0x0018; + public static final int TEMPLATE_ABOVE_AVERAGE = 0x0019; + public static final int TEMPLATE_BELOW_AVERAGE = 0x001A; + public static final int TEMPLATE_DUPLICATE_VALUES = 0x001B; + public static final int TEMPLATE_ABOVE_OR_EQUAL_TO_AVERAGE = 0x001D; + public static final int TEMPLATE_BELOW_OR_EQUAL_TO_AVERAGE = 0x001E; + + static final BitField modificationBits = bf(0x003FFFFF); // Bits: font,align,bord,patt,prot + static final BitField alignHor = bf(0x00000001); // 0 = Horizontal alignment modified + static final BitField alignVer = bf(0x00000002); // 0 = Vertical alignment modified + static final BitField alignWrap = bf(0x00000004); // 0 = Text wrapped flag modified + static final BitField alignRot = bf(0x00000008); // 0 = Text rotation modified + static final BitField alignJustLast = bf(0x00000010); // 0 = Justify last line flag modified + static final BitField alignIndent = bf(0x00000020); // 0 = Indentation modified + static final BitField alignShrin = bf(0x00000040); // 0 = Shrink to fit flag modified + static final BitField mergeCell = bf(0x00000080); // Normally 1, 0 = Merge Cell flag modified + static final BitField protLocked = bf(0x00000100); // 0 = Cell locked flag modified + static final BitField protHidden = bf(0x00000200); // 0 = Cell hidden flag modified + static final BitField bordLeft = bf(0x00000400); // 0 = Left border style and colour modified + static final BitField bordRight = bf(0x00000800); // 0 = Right border style and colour modified + static final BitField bordTop = bf(0x00001000); // 0 = Top border style and colour modified + static final BitField bordBot = bf(0x00002000); // 0 = Bottom border style and colour modified + static final BitField bordTlBr = bf(0x00004000); // 0 = Top-left to bottom-right border flag modified + static final BitField bordBlTr = bf(0x00008000); // 0 = Bottom-left to top-right border flag modified + static final BitField pattStyle = bf(0x00010000); // 0 = Pattern style modified + static final BitField pattCol = bf(0x00020000); // 0 = Pattern colour modified + static final BitField pattBgCol = bf(0x00040000); // 0 = Pattern background colour modified + static final BitField notUsed2 = bf(0x00380000); // Always 111 (ifmt / ifnt / 1) + static final BitField undocumented = bf(0x03C00000); // Undocumented bits + static final BitField fmtBlockBits = bf(0x7C000000); // Bits: font,align,bord,patt,prot + static final BitField font = bf(0x04000000); // 1 = Record contains font formatting block + static final BitField align = bf(0x08000000); // 1 = Record contains alignment formatting block + static final BitField bord = bf(0x10000000); // 1 = Record contains border formatting block + static final BitField patt = bf(0x20000000); // 1 = Record contains pattern formatting block + static final BitField prot = bf(0x40000000); // 1 = Record contains protection formatting block + static final BitField alignTextDir = bf(0x80000000); // 0 = Text direction modified + + private static BitField bf(int i) { + return BitFieldFactory.getInstance(i); + } + + protected int formatting_options; + protected short formatting_not_used; // TODO Decode this properly + + protected FontFormatting _fontFormatting; + protected BorderFormatting _borderFormatting; + protected PatternFormatting _patternFormatting; + + private Formula formula1; + private Formula formula2; + + /** Creates new CFRuleRecord */ + protected CFRuleBase(byte conditionType, byte comparisonOperation) { + setConditionType(conditionType); + setComparisonOperation(comparisonOperation); + formula1 = Formula.create(Ptg.EMPTY_PTG_ARRAY); + formula2 = Formula.create(Ptg.EMPTY_PTG_ARRAY); + } + protected CFRuleBase(byte conditionType, byte comparisonOperation, Ptg[] formula1, Ptg[] formula2) { + this(conditionType, comparisonOperation); + this.formula1 = Formula.create(formula1); + this.formula2 = Formula.create(formula2); + } + protected CFRuleBase() {} + + protected int readFormatOptions(RecordInputStream in) { + formatting_options = in.readInt(); + formatting_not_used = in.readShort(); + + int len = 6; + + if (containsFontFormattingBlock()) { + _fontFormatting = new FontFormatting(in); + len += _fontFormatting.getDataLength(); + } + + if (containsBorderFormattingBlock()) { + _borderFormatting = new BorderFormatting(in); + len += _borderFormatting.getDataLength(); + } + + if (containsPatternFormattingBlock()) { + _patternFormatting = new PatternFormatting(in); + len += _patternFormatting.getDataLength(); + } + + return len; + } + + public byte getConditionType() { + return condition_type; + } + protected void setConditionType(byte condition_type) { + if ((this instanceof CFRuleRecord)) { + if (condition_type == CONDITION_TYPE_CELL_VALUE_IS || + condition_type == CONDITION_TYPE_FORMULA) { + // Good, valid combination + } else { + throw new IllegalArgumentException("CFRuleRecord only accepts Value-Is and Formula types"); + } + } + this.condition_type = condition_type; + } + + public void setComparisonOperation(byte operation) { + if (operation < 0 || operation > ComparisonOperator.max_operator) + throw new IllegalArgumentException( + "Valid operators are only in the range 0 to " +ComparisonOperator.max_operator); + + this.comparison_operator = operation; + } + public byte getComparisonOperation() { + return comparison_operator; + } + + public boolean containsFontFormattingBlock() { + return getOptionFlag(font); + } + public void setFontFormatting(FontFormatting fontFormatting) { + _fontFormatting = fontFormatting; + setOptionFlag(fontFormatting != null, font); + } + public FontFormatting getFontFormatting() { + if( containsFontFormattingBlock()) { + return _fontFormatting; + } + return null; + } + + public boolean containsAlignFormattingBlock() { + return getOptionFlag(align); + } + public void setAlignFormattingUnchanged() { + setOptionFlag(false,align); + } + + public boolean containsBorderFormattingBlock() { + return getOptionFlag(bord); + } + public void setBorderFormatting(BorderFormatting borderFormatting) { + _borderFormatting = borderFormatting; + setOptionFlag(borderFormatting != null, bord); + } + public BorderFormatting getBorderFormatting() { + if( containsBorderFormattingBlock()) { + return _borderFormatting; + } + return null; + } + + public boolean containsPatternFormattingBlock() { + return getOptionFlag(patt); + } + public void setPatternFormatting(PatternFormatting patternFormatting) { + _patternFormatting = patternFormatting; + setOptionFlag(patternFormatting!=null, patt); + } + public PatternFormatting getPatternFormatting() { + if( containsPatternFormattingBlock()) + { + return _patternFormatting; + } + return null; + } + + public boolean containsProtectionFormattingBlock() { + return getOptionFlag(prot); + } + public void setProtectionFormattingUnchanged() { + setOptionFlag(false,prot); + } + + /** + * get the option flags + * + * @return bit mask + */ + public int getOptions() { + return formatting_options; + } + + private boolean isModified(BitField field) { + return !field.isSet(formatting_options); + } + private void setModified(boolean modified, BitField field) { + formatting_options = field.setBoolean(formatting_options, !modified); + } + + public boolean isLeftBorderModified() { + return isModified(bordLeft); + } + public void setLeftBorderModified(boolean modified) { + setModified(modified,bordLeft); + } + + public boolean isRightBorderModified() { + return isModified(bordRight); + } + public void setRightBorderModified(boolean modified) + { + setModified(modified,bordRight); + } + + public boolean isTopBorderModified() { + return isModified(bordTop); + } + public void setTopBorderModified(boolean modified) { + setModified(modified,bordTop); + } + + public boolean isBottomBorderModified() { + return isModified(bordBot); + } + public void setBottomBorderModified(boolean modified) { + setModified(modified,bordBot); + } + + public boolean isTopLeftBottomRightBorderModified() { + return isModified(bordTlBr); + } + public void setTopLeftBottomRightBorderModified(boolean modified) { + setModified(modified,bordTlBr); + } + + public boolean isBottomLeftTopRightBorderModified() { + return isModified(bordBlTr); + } + public void setBottomLeftTopRightBorderModified(boolean modified) { + setModified(modified,bordBlTr); + } + + public boolean isPatternStyleModified() { + return isModified(pattStyle); + } + public void setPatternStyleModified(boolean modified) { + setModified(modified,pattStyle); + } + + public boolean isPatternColorModified() { + return isModified(pattCol); + } + public void setPatternColorModified(boolean modified) { + setModified(modified,pattCol); + } + + public boolean isPatternBackgroundColorModified() { + return isModified(pattBgCol); + } + public void setPatternBackgroundColorModified(boolean modified) { + setModified(modified,pattBgCol); + } + + private boolean getOptionFlag(BitField field) { + return field.isSet(formatting_options); + } + private void setOptionFlag(boolean flag, BitField field) { + formatting_options = field.setBoolean(formatting_options, flag); + } + + protected int getFormattingBlockSize() { + return 6 + + (containsFontFormattingBlock()?_fontFormatting.getRawRecord().length:0)+ + (containsBorderFormattingBlock()?8:0)+ + (containsPatternFormattingBlock()?4:0); + } + protected void serializeFormattingBlock(LittleEndianOutput out) { + out.writeInt(formatting_options); + out.writeShort(formatting_not_used); + + if (containsFontFormattingBlock()) { + byte[] fontFormattingRawRecord = _fontFormatting.getRawRecord(); + out.write(fontFormattingRawRecord); + } + + if (containsBorderFormattingBlock()) { + _borderFormatting.serialize(out); + } + + if (containsPatternFormattingBlock()) { + _patternFormatting.serialize(out); + } + } + + /** + * get the stack of the 1st expression as a list + * + * @return list of tokens (casts stack to a list and returns it!) + * this method can return null is we are unable to create Ptgs from + * existing excel file + * callers should check for null! + */ + public Ptg[] getParsedExpression1() { + return formula1.getTokens(); + } + public void setParsedExpression1(Ptg[] ptgs) { + formula1 = Formula.create(ptgs); + } + protected Formula getFormula1() { + return formula1; + } + protected void setFormula1(Formula formula1) { + this.formula1 = formula1; + } + + /** + * get the stack of the 2nd expression as a list + * + * @return array of {@link Ptg}s, possibly <code>null</code> + */ + public Ptg[] getParsedExpression2() { + return Formula.getTokens(formula2); + } + public void setParsedExpression2(Ptg[] ptgs) { + formula2 = Formula.create(ptgs); + } + protected Formula getFormula2() { + return formula2; + } + protected void setFormula2(Formula formula2) { + this.formula2 = formula2; + } + + /** + * @param formula must not be <code>null</code> + * @return encoded size of the formula tokens (does not include 2 bytes for ushort length) + */ + protected static int getFormulaSize(Formula formula) { + return formula.getEncodedTokenSize(); + } + + /** + * TODO - parse conditional format formulas properly i.e. produce tRefN and tAreaN instead of tRef and tArea + * this call will produce the wrong results if the formula contains any cell references + * One approach might be to apply the inverse of SharedFormulaRecord.convertSharedFormulas(Stack, int, int) + * Note - two extra parameters (rowIx & colIx) will be required. They probably come from one of the Region objects. + * + * @return <code>null</code> if <tt>formula</tt> was null. + */ + public static Ptg[] parseFormula(String formula, HSSFSheet sheet) { + if(formula == null) { + return null; + } + int sheetIndex = sheet.getWorkbook().getSheetIndex(sheet); + return HSSFFormulaParser.parse(formula, sheet.getWorkbook(), FormulaType.CELL, sheetIndex); + } + + protected void copyTo(CFRuleBase rec) { + rec.condition_type = condition_type; + rec.comparison_operator = comparison_operator; + + rec.formatting_options = formatting_options; + rec.formatting_not_used = formatting_not_used; + if (containsFontFormattingBlock()) { + rec._fontFormatting = (FontFormatting) _fontFormatting.clone(); + } + if (containsBorderFormattingBlock()) { + rec._borderFormatting = (BorderFormatting) _borderFormatting.clone(); + } + if (containsPatternFormattingBlock()) { + rec._patternFormatting = (PatternFormatting) _patternFormatting.clone(); + } + + rec.setFormula1(getFormula1().copy()); + rec.setFormula2(getFormula2().copy()); + } +} diff --git a/src/java/org/apache/poi/hssf/record/CFRuleRecord.java b/src/java/org/apache/poi/hssf/record/CFRuleRecord.java index 4cf83efce0..52678c0fda 100644 --- a/src/java/org/apache/poi/hssf/record/CFRuleRecord.java +++ b/src/java/org/apache/poi/hssf/record/CFRuleRecord.java @@ -19,512 +19,129 @@ package org.apache.poi.hssf.record; import java.util.Arrays; -import org.apache.poi.hssf.model.HSSFFormulaParser; -import org.apache.poi.hssf.record.cf.BorderFormatting; -import org.apache.poi.hssf.record.cf.FontFormatting; -import org.apache.poi.hssf.record.cf.PatternFormatting; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.ss.formula.Formula; -import org.apache.poi.ss.formula.FormulaType; import org.apache.poi.ss.formula.ptg.Ptg; -import org.apache.poi.util.BitField; -import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.LittleEndianOutput; /** - * Conditional Formatting Rule Record (0x01B1).<br/> - * - * @author Dmitriy Kumshayev + * Conditional Formatting Rule Record (0x01B1). + * + * <p>This is for the older-style Excel conditional formattings, + * new-style (Excel 2007+) also make use of {@link CFRule12Record} + * and {@link CFExRuleRecord} for their rules. */ -public final class CFRuleRecord extends StandardRecord { +public final class CFRuleRecord extends CFRuleBase { + public static final short sid = 0x01B1; - public static final short sid = 0x01B1; - - public static final class ComparisonOperator { - public static final byte NO_COMPARISON = 0; - public static final byte BETWEEN = 1; - public static final byte NOT_BETWEEN = 2; - public static final byte EQUAL = 3; - public static final byte NOT_EQUAL = 4; - public static final byte GT = 5; - public static final byte LT = 6; - public static final byte GE = 7; - public static final byte LE = 8; - } - - private byte field_1_condition_type; - public static final byte CONDITION_TYPE_CELL_VALUE_IS = 1; - public static final byte CONDITION_TYPE_FORMULA = 2; - - private byte field_2_comparison_operator; - - private int field_5_options; - - private static final BitField modificationBits = bf(0x003FFFFF); // Bits: font,align,bord,patt,prot - private static final BitField alignHor = bf(0x00000001); // 0 = Horizontal alignment modified - private static final BitField alignVer = bf(0x00000002); // 0 = Vertical alignment modified - private static final BitField alignWrap = bf(0x00000004); // 0 = Text wrapped flag modified - private static final BitField alignRot = bf(0x00000008); // 0 = Text rotation modified - private static final BitField alignJustLast = bf(0x00000010); // 0 = Justify last line flag modified - private static final BitField alignIndent = bf(0x00000020); // 0 = Indentation modified - private static final BitField alignShrin = bf(0x00000040); // 0 = Shrink to fit flag modified - private static final BitField notUsed1 = bf(0x00000080); // Always 1 - private static final BitField protLocked = bf(0x00000100); // 0 = Cell locked flag modified - private static final BitField protHidden = bf(0x00000200); // 0 = Cell hidden flag modified - private static final BitField bordLeft = bf(0x00000400); // 0 = Left border style and colour modified - private static final BitField bordRight = bf(0x00000800); // 0 = Right border style and colour modified - private static final BitField bordTop = bf(0x00001000); // 0 = Top border style and colour modified - private static final BitField bordBot = bf(0x00002000); // 0 = Bottom border style and colour modified - private static final BitField bordTlBr = bf(0x00004000); // 0 = Top-left to bottom-right border flag modified - private static final BitField bordBlTr = bf(0x00008000); // 0 = Bottom-left to top-right border flag modified - private static final BitField pattStyle = bf(0x00010000); // 0 = Pattern style modified - private static final BitField pattCol = bf(0x00020000); // 0 = Pattern colour modified - private static final BitField pattBgCol = bf(0x00040000); // 0 = Pattern background colour modified - private static final BitField notUsed2 = bf(0x00380000); // Always 111 - private static final BitField undocumented = bf(0x03C00000); // Undocumented bits - private static final BitField fmtBlockBits = bf(0x7C000000); // Bits: font,align,bord,patt,prot - private static final BitField font = bf(0x04000000); // 1 = Record contains font formatting block - private static final BitField align = bf(0x08000000); // 1 = Record contains alignment formatting block - private static final BitField bord = bf(0x10000000); // 1 = Record contains border formatting block - private static final BitField patt = bf(0x20000000); // 1 = Record contains pattern formatting block - private static final BitField prot = bf(0x40000000); // 1 = Record contains protection formatting block - private static final BitField alignTextDir = bf(0x80000000); // 0 = Text direction modified - - - private static BitField bf(int i) { - return BitFieldFactory.getInstance(i); - } - - private short field_6_not_used; - - private FontFormatting _fontFormatting; - - private BorderFormatting _borderFormatting; - - private PatternFormatting _patternFormatting; - - private Formula field_17_formula1; - private Formula field_18_formula2; - - /** Creates new CFRuleRecord */ - private CFRuleRecord(byte conditionType, byte comparisonOperation) - { - field_1_condition_type=conditionType; - field_2_comparison_operator=comparisonOperation; - - // Set modification flags to 1: by default options are not modified - field_5_options = modificationBits.setValue(field_5_options, -1); - // Set formatting block flags to 0 (no formatting blocks) - field_5_options = fmtBlockBits.setValue(field_5_options, 0); - field_5_options = undocumented.clear(field_5_options); - - field_6_not_used = (short)0x8002; // Excel seems to write this value, but it doesn't seem to care what it reads - _fontFormatting=null; - _borderFormatting=null; - _patternFormatting=null; - field_17_formula1=Formula.create(Ptg.EMPTY_PTG_ARRAY); - field_18_formula2=Formula.create(Ptg.EMPTY_PTG_ARRAY); - } + /** Creates new CFRuleRecord */ + private CFRuleRecord(byte conditionType, byte comparisonOperation) { + super(conditionType, comparisonOperation); + setDefaults(); + } - private CFRuleRecord(byte conditionType, byte comparisonOperation, Ptg[] formula1, Ptg[] formula2) { - this(conditionType, comparisonOperation); - field_17_formula1 = Formula.create(formula1); - field_18_formula2 = Formula.create(formula2); - } + private CFRuleRecord(byte conditionType, byte comparisonOperation, Ptg[] formula1, Ptg[] formula2) { + super(conditionType, comparisonOperation, formula1, formula2); + setDefaults(); + } + private void setDefaults() { + // Set modification flags to 1: by default options are not modified + formatting_options = modificationBits.setValue(formatting_options, -1); + // Set formatting block flags to 0 (no formatting blocks) + formatting_options = fmtBlockBits.setValue(formatting_options, 0); + formatting_options = undocumented.clear(formatting_options); + + formatting_not_used = (short)0x8002; // Excel seems to write this value, but it doesn't seem to care what it reads + _fontFormatting = null; + _borderFormatting = null; + _patternFormatting = null; + } - /** - * Creates a new comparison operation rule - */ + /** + * Creates a new comparison operation rule + */ public static CFRuleRecord create(HSSFSheet sheet, String formulaText) { Ptg[] formula1 = parseFormula(formulaText, sheet); return new CFRuleRecord(CONDITION_TYPE_FORMULA, ComparisonOperator.NO_COMPARISON, formula1, null); } - /** - * Creates a new comparison operation rule - */ - public static CFRuleRecord create(HSSFSheet sheet, byte comparisonOperation, - String formulaText1, String formulaText2) { - Ptg[] formula1 = parseFormula(formulaText1, sheet); - Ptg[] formula2 = parseFormula(formulaText2, sheet); - return new CFRuleRecord(CONDITION_TYPE_CELL_VALUE_IS, comparisonOperation, formula1, formula2); - } - - public CFRuleRecord(RecordInputStream in) { - field_1_condition_type = in.readByte(); - field_2_comparison_operator = in.readByte(); - int field_3_formula1_len = in.readUShort(); - int field_4_formula2_len = in.readUShort(); - field_5_options = in.readInt(); - field_6_not_used = in.readShort(); - - if (containsFontFormattingBlock()) { - _fontFormatting = new FontFormatting(in); - } - - if (containsBorderFormattingBlock()) { - _borderFormatting = new BorderFormatting(in); - } - - if (containsPatternFormattingBlock()) { - _patternFormatting = new PatternFormatting(in); - } - - // "You may not use unions, intersections or array constants in Conditional Formatting criteria" - field_17_formula1 = Formula.read(field_3_formula1_len, in); - field_18_formula2 = Formula.read(field_4_formula2_len, in); - } - - public byte getConditionType() - { - return field_1_condition_type; - } - - public boolean containsFontFormattingBlock() - { - return getOptionFlag(font); - } - public void setFontFormatting(FontFormatting fontFormatting) - { - _fontFormatting = fontFormatting; - setOptionFlag(fontFormatting != null, font); - } - public FontFormatting getFontFormatting() - { - if( containsFontFormattingBlock()) - { - return _fontFormatting; - } - return null; - } - - public boolean containsAlignFormattingBlock() - { - return getOptionFlag(align); - } - public void setAlignFormattingUnchanged() - { - setOptionFlag(false,align); - } - - public boolean containsBorderFormattingBlock() - { - return getOptionFlag(bord); - } - public void setBorderFormatting(BorderFormatting borderFormatting) - { - _borderFormatting = borderFormatting; - setOptionFlag(borderFormatting != null, bord); - } - public BorderFormatting getBorderFormatting() - { - if( containsBorderFormattingBlock()) - { - return _borderFormatting; - } - return null; - } - - public boolean containsPatternFormattingBlock() - { - return getOptionFlag(patt); - } - public void setPatternFormatting(PatternFormatting patternFormatting) - { - _patternFormatting = patternFormatting; - setOptionFlag(patternFormatting!=null, patt); - } - public PatternFormatting getPatternFormatting() - { - if( containsPatternFormattingBlock()) - { - return _patternFormatting; - } - return null; - } - - public boolean containsProtectionFormattingBlock() - { - return getOptionFlag(prot); - } - public void setProtectionFormattingUnchanged() - { - setOptionFlag(false,prot); - } - - public void setComparisonOperation(byte operation) - { - field_2_comparison_operator = operation; - } - - public byte getComparisonOperation() - { - return field_2_comparison_operator; - } - - - /** - * get the option flags - * - * @return bit mask - */ - public int getOptions() - { - return field_5_options; - } - - private boolean isModified(BitField field) - { - return !field.isSet(field_5_options); - } - - private void setModified(boolean modified, BitField field) - { - field_5_options = field.setBoolean(field_5_options, !modified); - } - - public boolean isLeftBorderModified() - { - return isModified(bordLeft); - } - - public void setLeftBorderModified(boolean modified) - { - setModified(modified,bordLeft); - } - - public boolean isRightBorderModified() - { - return isModified(bordRight); - } - - public void setRightBorderModified(boolean modified) - { - setModified(modified,bordRight); - } - - public boolean isTopBorderModified() - { - return isModified(bordTop); - } - - public void setTopBorderModified(boolean modified) - { - setModified(modified,bordTop); - } - - public boolean isBottomBorderModified() - { - return isModified(bordBot); - } - - public void setBottomBorderModified(boolean modified) - { - setModified(modified,bordBot); - } - - public boolean isTopLeftBottomRightBorderModified() - { - return isModified(bordTlBr); - } - - public void setTopLeftBottomRightBorderModified(boolean modified) - { - setModified(modified,bordTlBr); - } - - public boolean isBottomLeftTopRightBorderModified() - { - return isModified(bordBlTr); - } - - public void setBottomLeftTopRightBorderModified(boolean modified) - { - setModified(modified,bordBlTr); - } - - public boolean isPatternStyleModified() - { - return isModified(pattStyle); - } - - public void setPatternStyleModified(boolean modified) - { - setModified(modified,pattStyle); - } - - public boolean isPatternColorModified() - { - return isModified(pattCol); - } - - public void setPatternColorModified(boolean modified) - { - setModified(modified,pattCol); - } - - public boolean isPatternBackgroundColorModified() - { - return isModified(pattBgCol); - } - - public void setPatternBackgroundColorModified(boolean modified) - { - setModified(modified,pattBgCol); - } - - private boolean getOptionFlag(BitField field) - { - return field.isSet(field_5_options); - } - - private void setOptionFlag(boolean flag, BitField field) - { - field_5_options = field.setBoolean(field_5_options, flag); - } - - /** - * get the stack of the 1st expression as a list - * - * @return list of tokens (casts stack to a list and returns it!) - * this method can return null is we are unable to create Ptgs from - * existing excel file - * callers should check for null! - */ - - public Ptg[] getParsedExpression1() - { - return field_17_formula1.getTokens(); - } - public void setParsedExpression1(Ptg[] ptgs) { - field_17_formula1 = Formula.create(ptgs); - } - - /** - * get the stack of the 2nd expression as a list - * - * @return array of {@link Ptg}s, possibly <code>null</code> - */ - public Ptg[] getParsedExpression2() { - return Formula.getTokens(field_18_formula2); - } - public void setParsedExpression2(Ptg[] ptgs) { - field_18_formula2 = Formula.create(ptgs); - } - - public short getSid() - { - return sid; - } - - /** - * @param ptgs must not be <code>null</code> - * @return encoded size of the formula tokens (does not include 2 bytes for ushort length) - */ - private static int getFormulaSize(Formula formula) { - return formula.getEncodedTokenSize(); - } - - /** - * called by the class that is responsible for writing this sucker. - * Subclasses should implement this so that their data is passed back in a - * byte array. - * - * @param out the stream to write to - */ - public void serialize(LittleEndianOutput out) { - - int formula1Len=getFormulaSize(field_17_formula1); - int formula2Len=getFormulaSize(field_18_formula2); - - out.writeByte(field_1_condition_type); - out.writeByte(field_2_comparison_operator); - out.writeShort(formula1Len); - out.writeShort(formula2Len); - out.writeInt(field_5_options); - out.writeShort(field_6_not_used); - - if (containsFontFormattingBlock()) { - byte[] fontFormattingRawRecord = _fontFormatting.getRawRecord(); - out.write(fontFormattingRawRecord); - } - - if (containsBorderFormattingBlock()) { - _borderFormatting.serialize(out); - } - - if (containsPatternFormattingBlock()) { - _patternFormatting.serialize(out); - } - - field_17_formula1.serializeTokens(out); - field_18_formula2.serializeTokens(out); - } + /** + * Creates a new comparison operation rule + */ + public static CFRuleRecord create(HSSFSheet sheet, byte comparisonOperation, + String formulaText1, String formulaText2) { + Ptg[] formula1 = parseFormula(formulaText1, sheet); + Ptg[] formula2 = parseFormula(formulaText2, sheet); + return new CFRuleRecord(CONDITION_TYPE_CELL_VALUE_IS, comparisonOperation, formula1, formula2); + } - protected int getDataSize() { - int i = 12 + - (containsFontFormattingBlock()?_fontFormatting.getRawRecord().length:0)+ - (containsBorderFormattingBlock()?8:0)+ - (containsPatternFormattingBlock()?4:0)+ - getFormulaSize(field_17_formula1)+ - getFormulaSize(field_18_formula2); - return i - ; - } + public CFRuleRecord(RecordInputStream in) { + setConditionType(in.readByte()); + setComparisonOperation(in.readByte()); + int field_3_formula1_len = in.readUShort(); + int field_4_formula2_len = in.readUShort(); + readFormatOptions(in); + // "You may not use unions, intersections or array constants in Conditional Formatting criteria" + setFormula1(Formula.read(field_3_formula1_len, in)); + setFormula2(Formula.read(field_4_formula2_len, in)); + } - public String toString() { - StringBuffer buffer = new StringBuffer(); - buffer.append("[CFRULE]\n"); - buffer.append(" .condition_type =").append(field_1_condition_type).append("\n"); - buffer.append(" OPTION FLAGS=0x").append(Integer.toHexString(getOptions())).append("\n"); - if (containsFontFormattingBlock()) { - buffer.append(_fontFormatting.toString()).append("\n"); - } - if (containsBorderFormattingBlock()) { - buffer.append(_borderFormatting.toString()).append("\n"); - } - if (containsPatternFormattingBlock()) { - buffer.append(_patternFormatting.toString()).append("\n"); - } - buffer.append(" Formula 1 =").append(Arrays.toString(field_17_formula1.getTokens())).append("\n"); - buffer.append(" Formula 2 =").append(Arrays.toString(field_18_formula2.getTokens())).append("\n"); - buffer.append("[/CFRULE]\n"); - return buffer.toString(); - } + public short getSid() { + return sid; + } - public Object clone() { - CFRuleRecord rec = new CFRuleRecord(field_1_condition_type, field_2_comparison_operator); - rec.field_5_options = field_5_options; - rec.field_6_not_used = field_6_not_used; - if (containsFontFormattingBlock()) { - rec._fontFormatting = (FontFormatting) _fontFormatting.clone(); - } - if (containsBorderFormattingBlock()) { - rec._borderFormatting = (BorderFormatting) _borderFormatting.clone(); - } - if (containsPatternFormattingBlock()) { - rec._patternFormatting = (PatternFormatting) _patternFormatting.clone(); - } - rec.field_17_formula1 = field_17_formula1.copy(); - rec.field_18_formula2 = field_18_formula2.copy(); + /** + * called by the class that is responsible for writing this sucker. + * Subclasses should implement this so that their data is passed back in a + * byte array. + * + * @param out the stream to write to + */ + public void serialize(LittleEndianOutput out) { + int formula1Len=getFormulaSize(getFormula1()); + int formula2Len=getFormulaSize(getFormula2()); + + out.writeByte(getConditionType()); + out.writeByte(getComparisonOperation()); + out.writeShort(formula1Len); + out.writeShort(formula2Len); + + serializeFormattingBlock(out); + + getFormula1().serializeTokens(out); + getFormula2().serializeTokens(out); + } - return rec; - } + protected int getDataSize() { + return 6 + getFormattingBlockSize() + + getFormulaSize(getFormula1())+ + getFormulaSize(getFormula2()); + } - /** - * TODO - parse conditional format formulas properly i.e. produce tRefN and tAreaN instead of tRef and tArea - * this call will produce the wrong results if the formula contains any cell references - * One approach might be to apply the inverse of SharedFormulaRecord.convertSharedFormulas(Stack, int, int) - * Note - two extra parameters (rowIx & colIx) will be required. They probably come from one of the Region objects. - * - * @return <code>null</code> if <tt>formula</tt> was null. - */ - private static Ptg[] parseFormula(String formula, HSSFSheet sheet) { - if(formula == null) { - return null; + public String toString() { + StringBuffer buffer = new StringBuffer(); + buffer.append("[CFRULE]\n"); + buffer.append(" .condition_type =").append(getConditionType()).append("\n"); + buffer.append(" OPTION FLAGS=0x").append(Integer.toHexString(getOptions())).append("\n"); + if (containsFontFormattingBlock()) { + buffer.append(_fontFormatting.toString()).append("\n"); } - int sheetIndex = sheet.getWorkbook().getSheetIndex(sheet); - return HSSFFormulaParser.parse(formula, sheet.getWorkbook(), FormulaType.CELL, sheetIndex); + if (containsBorderFormattingBlock()) { + buffer.append(_borderFormatting.toString()).append("\n"); + } + if (containsPatternFormattingBlock()) { + buffer.append(_patternFormatting.toString()).append("\n"); + } + buffer.append(" Formula 1 =").append(Arrays.toString(getFormula1().getTokens())).append("\n"); + buffer.append(" Formula 2 =").append(Arrays.toString(getFormula2().getTokens())).append("\n"); + buffer.append("[/CFRULE]\n"); + return buffer.toString(); + } + + public Object clone() { + CFRuleRecord rec = new CFRuleRecord(getConditionType(), getComparisonOperation()); + super.copyTo(rec); + return rec; } } diff --git a/src/java/org/apache/poi/hssf/record/FeatRecord.java b/src/java/org/apache/poi/hssf/record/FeatRecord.java index 572d6959d9..fd583a3d78 100644 --- a/src/java/org/apache/poi/hssf/record/FeatRecord.java +++ b/src/java/org/apache/poi/hssf/record/FeatRecord.java @@ -34,8 +34,11 @@ import org.apache.poi.util.POILogger; * up with a {@link FeatHdrRecord}. */ public final class FeatRecord extends StandardRecord { - private static POILogger logger = POILogFactory.getLogger(FeatRecord.class); - public final static short sid = 0x0868; + private static POILogger logger = POILogFactory.getLogger(FeatRecord.class); + public final static short sid = 0x0868; + // SIDs from newer versions + public final static short v11_sid = 0x0872; + public final static short v12_sid = 0x0878; private FtrHeader futureHeader; diff --git a/src/java/org/apache/poi/hssf/record/NameCommentRecord.java b/src/java/org/apache/poi/hssf/record/NameCommentRecord.java index ed33c2d1f2..6b3c8d0bd5 100644 --- a/src/java/org/apache/poi/hssf/record/NameCommentRecord.java +++ b/src/java/org/apache/poi/hssf/record/NameCommentRecord.java @@ -62,17 +62,27 @@ public final class NameCommentRecord extends StandardRecord { out.writeShort(field_4_name_length); out.writeShort(field_5_comment_length); - out.writeByte(0); - StringUtil.putCompressedUnicode(field_6_name_text, out); - out.writeByte(0); - StringUtil.putCompressedUnicode(field_7_comment_text, out); + boolean isNameMultiByte = StringUtil.hasMultibyte(field_6_name_text); + out.writeByte(isNameMultiByte ? 1 : 0); + if (isNameMultiByte) { + StringUtil.putUnicodeLE(field_6_name_text, out); + } else { + StringUtil.putCompressedUnicode(field_6_name_text, out); + } + boolean isCommentMultiByte = StringUtil.hasMultibyte(field_7_comment_text); + out.writeByte(isCommentMultiByte ? 1 : 0); + if (isCommentMultiByte) { + StringUtil.putUnicodeLE(field_7_comment_text, out); + } else { + StringUtil.putCompressedUnicode(field_7_comment_text, out); + } } @Override protected int getDataSize() { return 18 // 4 shorts + 1 long + 2 spurious 'nul's - + field_6_name_text.length() - + field_7_comment_text.length(); + + (StringUtil.hasMultibyte(field_6_name_text) ? field_6_name_text.length()*2 : field_6_name_text.length()) + + (StringUtil.hasMultibyte(field_7_comment_text) ? field_7_comment_text.length()*2 : field_7_comment_text.length()); } /** @@ -86,10 +96,16 @@ public final class NameCommentRecord extends StandardRecord { final int field_4_name_length = in.readShort(); final int field_5_comment_length = in.readShort(); - in.readByte(); //spurious NUL - field_6_name_text = StringUtil.readCompressedUnicode(in, field_4_name_length); - in.readByte(); //spurious NUL - field_7_comment_text = StringUtil.readCompressedUnicode(in, field_5_comment_length); + if (in.readByte() == 0) { + field_6_name_text = StringUtil.readCompressedUnicode(in, field_4_name_length); + } else { + field_6_name_text = StringUtil.readUnicodeLE(in, field_4_name_length); + } + if (in.readByte() == 0) { + field_7_comment_text = StringUtil.readCompressedUnicode(in, field_5_comment_length); + } else { + field_7_comment_text = StringUtil.readUnicodeLE(in, field_5_comment_length); + } } /** diff --git a/src/java/org/apache/poi/hssf/record/NameRecord.java b/src/java/org/apache/poi/hssf/record/NameRecord.java index 904133ce64..2f7f81899b 100644 --- a/src/java/org/apache/poi/hssf/record/NameRecord.java +++ b/src/java/org/apache/poi/hssf/record/NameRecord.java @@ -411,11 +411,12 @@ public final class NameRecord extends ContinuableRecord { * @return extern sheet index */ public int getExternSheetNumber(){ - if (field_13_name_definition.getEncodedSize() < 1) { + Ptg[] tokens = field_13_name_definition.getTokens(); + if (tokens.length == 0) { return 0; } - Ptg ptg = field_13_name_definition.getTokens()[0]; + Ptg ptg = tokens[0]; if (ptg.getClass() == Area3DPtg.class){ return ((Area3DPtg) ptg).getExternSheetIndex(); diff --git a/src/java/org/apache/poi/hssf/record/RecordFactory.java b/src/java/org/apache/poi/hssf/record/RecordFactory.java index 3a1f7acca3..c1a0f5707e 100644 --- a/src/java/org/apache/poi/hssf/record/RecordFactory.java +++ b/src/java/org/apache/poi/hssf/record/RecordFactory.java @@ -62,425 +62,420 @@ import org.apache.poi.hssf.record.pivottable.ViewSourceRecord; * Description: Takes a stream and outputs an array of Record objects.<P> * * @see org.apache.poi.hssf.eventmodel.EventRecordFactory - * @author Andrew C. Oliver (acoliver at apache dot org) - * @author Marc Johnson (mjohnson at apache dot org) - * @author Glen Stampoultzis (glens at apache.org) - * @author Csaba Nagy (ncsaba at yahoo dot com) */ public final class RecordFactory { - private static final int NUM_RECORDS = 512; - - private interface I_RecordCreator { - Record create(RecordInputStream in); - - Class<? extends Record> getRecordClass(); - } - private static final class ReflectionConstructorRecordCreator implements I_RecordCreator { - - private final Constructor<? extends Record> _c; - public ReflectionConstructorRecordCreator(Constructor<? extends Record> c) { - _c = c; - } - public Record create(RecordInputStream in) { - Object[] args = { in, }; - try { - return _c.newInstance(args); - } catch (IllegalArgumentException e) { - throw new RuntimeException(e); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (InvocationTargetException e) { - Throwable t = e.getTargetException(); - if (t instanceof RecordFormatException) { - throw (RecordFormatException)t; - } else if (t instanceof EncryptedDocumentException) { - throw (EncryptedDocumentException)t; - } else { - throw new RecordFormatException("Unable to construct record instance" , t); - } - } - } - public Class<? extends Record> getRecordClass() { - return _c.getDeclaringClass(); - } - } - /** - * A "create" method is used instead of the usual constructor if the created record might - * be of a different class to the declaring class. - */ - private static final class ReflectionMethodRecordCreator implements I_RecordCreator { - - private final Method _m; - public ReflectionMethodRecordCreator(Method m) { - _m = m; - } - public Record create(RecordInputStream in) { - Object[] args = { in, }; - try { - return (Record) _m.invoke(null, args); - } catch (IllegalArgumentException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (InvocationTargetException e) { - throw new RecordFormatException("Unable to construct record instance" , e.getTargetException()); - } - } - @SuppressWarnings("unchecked") - public Class<? extends Record> getRecordClass() { - return (Class<? extends Record>) _m.getDeclaringClass(); - } - } - - - private static final Class<?>[] CONSTRUCTOR_ARGS = { RecordInputStream.class, }; - - /** - * contains the classes for all the records we want to parse.<br/> - * Note - this most but not *every* subclass of Record. - */ - @SuppressWarnings("unchecked") - private static final Class<? extends Record>[] recordClasses = new Class[] { - ArrayRecord.class, + private static final int NUM_RECORDS = 512; + + private interface I_RecordCreator { + Record create(RecordInputStream in); + + Class<? extends Record> getRecordClass(); + } + private static final class ReflectionConstructorRecordCreator implements I_RecordCreator { + + private final Constructor<? extends Record> _c; + public ReflectionConstructorRecordCreator(Constructor<? extends Record> c) { + _c = c; + } + public Record create(RecordInputStream in) { + Object[] args = { in, }; + try { + return _c.newInstance(args); + } catch (IllegalArgumentException e) { + throw new RuntimeException(e); + } catch (InstantiationException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + Throwable t = e.getTargetException(); + if (t instanceof RecordFormatException) { + throw (RecordFormatException)t; + } else if (t instanceof EncryptedDocumentException) { + throw (EncryptedDocumentException)t; + } else { + throw new RecordFormatException("Unable to construct record instance" , t); + } + } + } + public Class<? extends Record> getRecordClass() { + return _c.getDeclaringClass(); + } + } + /** + * A "create" method is used instead of the usual constructor if the created record might + * be of a different class to the declaring class. + */ + private static final class ReflectionMethodRecordCreator implements I_RecordCreator { + private final Method _m; + public ReflectionMethodRecordCreator(Method m) { + _m = m; + } + public Record create(RecordInputStream in) { + Object[] args = { in, }; + try { + return (Record) _m.invoke(null, args); + } catch (IllegalArgumentException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + throw new RecordFormatException("Unable to construct record instance" , e.getTargetException()); + } + } + @SuppressWarnings("unchecked") + public Class<? extends Record> getRecordClass() { + return (Class<? extends Record>) _m.getDeclaringClass(); + } + } + + private static final Class<?>[] CONSTRUCTOR_ARGS = { RecordInputStream.class, }; + + /** + * contains the classes for all the records we want to parse.<br/> + * Note - this most but not *every* subclass of Record. + */ + @SuppressWarnings("unchecked") + private static final Class<? extends Record>[] recordClasses = new Class[] { + ArrayRecord.class, AutoFilterInfoRecord.class, BackupRecord.class, - BlankRecord.class, - BOFRecord.class, - BookBoolRecord.class, - BoolErrRecord.class, - BottomMarginRecord.class, - BoundSheetRecord.class, - CalcCountRecord.class, - CalcModeRecord.class, - CFHeaderRecord.class, - CFRuleRecord.class, - ChartRecord.class, - ChartTitleFormatRecord.class, - CodepageRecord.class, - ColumnInfoRecord.class, - ContinueRecord.class, - CountryRecord.class, - CRNCountRecord.class, - CRNRecord.class, - DateWindow1904Record.class, - DBCellRecord.class, - DConRefRecord.class, - DefaultColWidthRecord.class, - DefaultRowHeightRecord.class, - DeltaRecord.class, - DimensionsRecord.class, - DrawingGroupRecord.class, - DrawingRecord.class, - DrawingSelectionRecord.class, - DSFRecord.class, - DVALRecord.class, - DVRecord.class, - EOFRecord.class, - ExtendedFormatRecord.class, - ExternalNameRecord.class, - ExternSheetRecord.class, - ExtSSTRecord.class, - FeatRecord.class, - FeatHdrRecord.class, - FilePassRecord.class, - FileSharingRecord.class, - FnGroupCountRecord.class, - FontRecord.class, - FooterRecord.class, - FormatRecord.class, - FormulaRecord.class, - GridsetRecord.class, - GutsRecord.class, - HCenterRecord.class, - HeaderRecord.class, + BlankRecord.class, + BOFRecord.class, + BookBoolRecord.class, + BoolErrRecord.class, + BottomMarginRecord.class, + BoundSheetRecord.class, + CalcCountRecord.class, + CalcModeRecord.class, + CFHeaderRecord.class, + CFHeader12Record.class, + CFRuleRecord.class, + CFRule12Record.class, + ChartRecord.class, + ChartTitleFormatRecord.class, + CodepageRecord.class, + ColumnInfoRecord.class, + ContinueRecord.class, + CountryRecord.class, + CRNCountRecord.class, + CRNRecord.class, + DateWindow1904Record.class, + DBCellRecord.class, + DConRefRecord.class, + DefaultColWidthRecord.class, + DefaultRowHeightRecord.class, + DeltaRecord.class, + DimensionsRecord.class, + DrawingGroupRecord.class, + DrawingRecord.class, + DrawingSelectionRecord.class, + DSFRecord.class, + DVALRecord.class, + DVRecord.class, + EOFRecord.class, + ExtendedFormatRecord.class, + ExternalNameRecord.class, + ExternSheetRecord.class, + ExtSSTRecord.class, + FeatRecord.class, + FeatHdrRecord.class, + FilePassRecord.class, + FileSharingRecord.class, + FnGroupCountRecord.class, + FontRecord.class, + FooterRecord.class, + FormatRecord.class, + FormulaRecord.class, + GridsetRecord.class, + GutsRecord.class, + HCenterRecord.class, + HeaderRecord.class, HeaderFooterRecord.class, - HideObjRecord.class, - HorizontalPageBreakRecord.class, - HyperlinkRecord.class, - IndexRecord.class, - InterfaceEndRecord.class, - InterfaceHdrRecord.class, - IterationRecord.class, - LabelRecord.class, - LabelSSTRecord.class, - LeftMarginRecord.class, - LegendRecord.class, - MergeCellsRecord.class, - MMSRecord.class, - MulBlankRecord.class, - MulRKRecord.class, - NameRecord.class, - NameCommentRecord.class, - NoteRecord.class, - NumberRecord.class, - ObjectProtectRecord.class, - ObjRecord.class, - PaletteRecord.class, - PaneRecord.class, - PasswordRecord.class, - PasswordRev4Record.class, - PrecisionRecord.class, - PrintGridlinesRecord.class, - PrintHeadersRecord.class, - PrintSetupRecord.class, - ProtectionRev4Record.class, - ProtectRecord.class, - RecalcIdRecord.class, - RefModeRecord.class, - RefreshAllRecord.class, - RightMarginRecord.class, - RKRecord.class, - RowRecord.class, - SaveRecalcRecord.class, - ScenarioProtectRecord.class, - SelectionRecord.class, - SeriesRecord.class, - SeriesTextRecord.class, - SharedFormulaRecord.class, - SSTRecord.class, - StringRecord.class, - StyleRecord.class, - SupBookRecord.class, - TabIdRecord.class, - TableRecord.class, - TableStylesRecord.class, - TextObjectRecord.class, - TopMarginRecord.class, - UncalcedRecord.class, - UseSelFSRecord.class, - UserSViewBegin.class, - UserSViewEnd.class, - ValueRangeRecord.class, - VCenterRecord.class, - VerticalPageBreakRecord.class, - WindowOneRecord.class, - WindowProtectRecord.class, - WindowTwoRecord.class, - WriteAccessRecord.class, - WriteProtectRecord.class, - WSBoolRecord.class, - - // chart records - BeginRecord.class, - ChartFRTInfoRecord.class, - ChartStartBlockRecord.class, - ChartEndBlockRecord.class, -// TODO ChartFormatRecord.class, - ChartStartObjectRecord.class, - ChartEndObjectRecord.class, - CatLabRecord.class, - DataFormatRecord.class, - EndRecord.class, - LinkedDataRecord.class, - SeriesToChartGroupRecord.class, - - // pivot table records - DataItemRecord.class, - ExtendedPivotTableViewFieldsRecord.class, - PageItemRecord.class, - StreamIDRecord.class, - ViewDefinitionRecord.class, - ViewFieldsRecord.class, - ViewSourceRecord.class, - }; - - /** - * cache of the recordsToMap(); - */ - private static final Map<Integer, I_RecordCreator> _recordCreatorsById = recordsToMap(recordClasses); - - private static short[] _allKnownRecordSIDs; - - /** - * Debug / diagnosis method<br/> - * Gets the POI implementation class for a given <tt>sid</tt>. Only a subset of the any BIFF - * records are actually interpreted by POI. A few others are known but not interpreted - * (see {@link UnknownRecord#getBiffName(int)}). - * @return the POI implementation class for the specified record <tt>sid</tt>. - * <code>null</code> if the specified record is not interpreted by POI. - */ - public static Class<? extends Record> getRecordClass(int sid) { - I_RecordCreator rc = _recordCreatorsById.get(Integer.valueOf(sid)); - if (rc == null) { - return null; - } - return rc.getRecordClass(); - } - /** - * create a record, if there are MUL records than multiple records - * are returned digested into the non-mul form. - */ - public static Record [] createRecord(RecordInputStream in) { - - Record record = createSingleRecord(in); - if (record instanceof DBCellRecord) { - // Not needed by POI. Regenerated from scratch by POI when spreadsheet is written - return new Record[] { null, }; - } - if (record instanceof RKRecord) { - return new Record[] { convertToNumberRecord((RKRecord) record), }; - } - if (record instanceof MulRKRecord) { - return convertRKRecords((MulRKRecord)record); - } - return new Record[] { record, }; - } - - public static Record createSingleRecord(RecordInputStream in) { - I_RecordCreator constructor = _recordCreatorsById.get(Integer.valueOf(in.getSid())); - - if (constructor == null) { - return new UnknownRecord(in); - } - - return constructor.create(in); - } - - /** - * RK record is a slightly smaller alternative to NumberRecord - * POI likes NumberRecord better - */ - public static NumberRecord convertToNumberRecord(RKRecord rk) { - NumberRecord num = new NumberRecord(); - - num.setColumn(rk.getColumn()); - num.setRow(rk.getRow()); - num.setXFIndex(rk.getXFIndex()); - num.setValue(rk.getRKNumber()); - return num; - } - - /** - * Converts a {@link MulRKRecord} into an equivalent array of {@link NumberRecord}s - */ - public static NumberRecord[] convertRKRecords(MulRKRecord mrk) { - NumberRecord[] mulRecs = new NumberRecord[mrk.getNumColumns()]; - for (int k = 0; k < mrk.getNumColumns(); k++) { - NumberRecord nr = new NumberRecord(); - - nr.setColumn((short) (k + mrk.getFirstColumn())); - nr.setRow(mrk.getRow()); - nr.setXFIndex(mrk.getXFAt(k)); - nr.setValue(mrk.getRKNumberAt(k)); - mulRecs[k] = nr; - } - return mulRecs; - } - - /** - * Converts a {@link MulBlankRecord} into an equivalent array of {@link BlankRecord}s - */ - public static BlankRecord[] convertBlankRecords(MulBlankRecord mbk) { - BlankRecord[] mulRecs = new BlankRecord[mbk.getNumColumns()]; - for (int k = 0; k < mbk.getNumColumns(); k++) { - BlankRecord br = new BlankRecord(); - - br.setColumn((short) (k + mbk.getFirstColumn())); - br.setRow(mbk.getRow()); - br.setXFIndex(mbk.getXFAt(k)); - mulRecs[k] = br; - } - return mulRecs; - } - - /** - * @return an array of all the SIDS for all known records - */ - public static short[] getAllKnownRecordSIDs() { - if (_allKnownRecordSIDs == null) { - short[] results = new short[ _recordCreatorsById.size() ]; - int i = 0; - - for (Iterator<Integer> iterator = _recordCreatorsById.keySet().iterator(); iterator.hasNext(); ) { - Integer sid = iterator.next(); - - results[i++] = sid.shortValue(); - } - Arrays.sort(results); - _allKnownRecordSIDs = results; - } - - return _allKnownRecordSIDs.clone(); - } - - /** - * gets the record constructors and sticks them in the map by SID - * @return map of SIDs to short,short,byte[] constructors for Record classes - * most of org.apache.poi.hssf.record.* - */ - private static Map<Integer, I_RecordCreator> recordsToMap(Class<? extends Record> [] records) { - Map<Integer, I_RecordCreator> result = new HashMap<Integer, I_RecordCreator>(); - Set<Class<?>> uniqueRecClasses = new HashSet<Class<?>>(records.length * 3 / 2); - - for (int i = 0; i < records.length; i++) { - - Class<? extends Record> recClass = records[ i ]; - if(!Record.class.isAssignableFrom(recClass)) { - throw new RuntimeException("Invalid record sub-class (" + recClass.getName() + ")"); - } - if(Modifier.isAbstract(recClass.getModifiers())) { - throw new RuntimeException("Invalid record class (" + recClass.getName() + ") - must not be abstract"); - } - if(!uniqueRecClasses.add(recClass)) { - throw new RuntimeException("duplicate record class (" + recClass.getName() + ")"); - } - - int sid; - try { - sid = recClass.getField("sid").getShort(null); - } catch (Exception illegalArgumentException) { - throw new RecordFormatException( - "Unable to determine record types"); - } - Integer key = Integer.valueOf(sid); - if (result.containsKey(key)) { - Class<?> prevClass = result.get(key).getRecordClass(); - throw new RuntimeException("duplicate record sid 0x" + Integer.toHexString(sid).toUpperCase() - + " for classes (" + recClass.getName() + ") and (" + prevClass.getName() + ")"); - } - result.put(key, getRecordCreator(recClass)); - } -// result.put(Integer.valueOf(0x0406), result.get(Integer.valueOf(0x06))); - return result; - } - - private static I_RecordCreator getRecordCreator(Class<? extends Record> recClass) { - try { - Constructor<? extends Record> constructor; - constructor = recClass.getConstructor(CONSTRUCTOR_ARGS); - return new ReflectionConstructorRecordCreator(constructor); - } catch (NoSuchMethodException e) { - // fall through and look for other construction methods - } - try { - Method m = recClass.getDeclaredMethod("create", CONSTRUCTOR_ARGS); - return new ReflectionMethodRecordCreator(m); - } catch (NoSuchMethodException e) { - throw new RuntimeException("Failed to find constructor or create method for (" + recClass.getName() + ")."); - } - } - /** - * Create an array of records from an input stream - * - * @param in the InputStream from which the records will be obtained - * - * @return an array of Records created from the InputStream - * - * @exception RecordFormatException on error processing the InputStream - */ - public static List<Record> createRecords(InputStream in) throws RecordFormatException { - - List<Record> records = new ArrayList<Record>(NUM_RECORDS); - - RecordFactoryInputStream recStream = new RecordFactoryInputStream(in, true); - - Record record; - while ((record = recStream.nextRecord())!=null) { - records.add(record); - } - - return records; - } + HideObjRecord.class, + HorizontalPageBreakRecord.class, + HyperlinkRecord.class, + IndexRecord.class, + InterfaceEndRecord.class, + InterfaceHdrRecord.class, + IterationRecord.class, + LabelRecord.class, + LabelSSTRecord.class, + LeftMarginRecord.class, + LegendRecord.class, + MergeCellsRecord.class, + MMSRecord.class, + MulBlankRecord.class, + MulRKRecord.class, + NameRecord.class, + NameCommentRecord.class, + NoteRecord.class, + NumberRecord.class, + ObjectProtectRecord.class, + ObjRecord.class, + PaletteRecord.class, + PaneRecord.class, + PasswordRecord.class, + PasswordRev4Record.class, + PrecisionRecord.class, + PrintGridlinesRecord.class, + PrintHeadersRecord.class, + PrintSetupRecord.class, + ProtectionRev4Record.class, + ProtectRecord.class, + RecalcIdRecord.class, + RefModeRecord.class, + RefreshAllRecord.class, + RightMarginRecord.class, + RKRecord.class, + RowRecord.class, + SaveRecalcRecord.class, + ScenarioProtectRecord.class, + SelectionRecord.class, + SeriesRecord.class, + SeriesTextRecord.class, + SharedFormulaRecord.class, + SSTRecord.class, + StringRecord.class, + StyleRecord.class, + SupBookRecord.class, + TabIdRecord.class, + TableRecord.class, + TableStylesRecord.class, + TextObjectRecord.class, + TopMarginRecord.class, + UncalcedRecord.class, + UseSelFSRecord.class, + UserSViewBegin.class, + UserSViewEnd.class, + ValueRangeRecord.class, + VCenterRecord.class, + VerticalPageBreakRecord.class, + WindowOneRecord.class, + WindowProtectRecord.class, + WindowTwoRecord.class, + WriteAccessRecord.class, + WriteProtectRecord.class, + WSBoolRecord.class, + + // chart records + BeginRecord.class, + ChartFRTInfoRecord.class, + ChartStartBlockRecord.class, + ChartEndBlockRecord.class, + // TODO ChartFormatRecord.class, + ChartStartObjectRecord.class, + ChartEndObjectRecord.class, + CatLabRecord.class, + DataFormatRecord.class, + EndRecord.class, + LinkedDataRecord.class, + SeriesToChartGroupRecord.class, + + // pivot table records + DataItemRecord.class, + ExtendedPivotTableViewFieldsRecord.class, + PageItemRecord.class, + StreamIDRecord.class, + ViewDefinitionRecord.class, + ViewFieldsRecord.class, + ViewSourceRecord.class, + }; + + /** + * cache of the recordsToMap(); + */ + private static final Map<Integer, I_RecordCreator> _recordCreatorsById = recordsToMap(recordClasses); + + private static short[] _allKnownRecordSIDs; + + /** + * Debug / diagnosis method<br/> + * Gets the POI implementation class for a given <tt>sid</tt>. Only a subset of the any BIFF + * records are actually interpreted by POI. A few others are known but not interpreted + * (see {@link UnknownRecord#getBiffName(int)}). + * @return the POI implementation class for the specified record <tt>sid</tt>. + * <code>null</code> if the specified record is not interpreted by POI. + */ + public static Class<? extends Record> getRecordClass(int sid) { + I_RecordCreator rc = _recordCreatorsById.get(Integer.valueOf(sid)); + if (rc == null) { + return null; + } + return rc.getRecordClass(); + } + /** + * create a record, if there are MUL records than multiple records + * are returned digested into the non-mul form. + */ + public static Record [] createRecord(RecordInputStream in) { + Record record = createSingleRecord(in); + if (record instanceof DBCellRecord) { + // Not needed by POI. Regenerated from scratch by POI when spreadsheet is written + return new Record[] { null, }; + } + if (record instanceof RKRecord) { + return new Record[] { convertToNumberRecord((RKRecord) record), }; + } + if (record instanceof MulRKRecord) { + return convertRKRecords((MulRKRecord)record); + } + return new Record[] { record, }; + } + + public static Record createSingleRecord(RecordInputStream in) { + I_RecordCreator constructor = _recordCreatorsById.get(Integer.valueOf(in.getSid())); + + if (constructor == null) { + return new UnknownRecord(in); + } + + return constructor.create(in); + } + + /** + * RK record is a slightly smaller alternative to NumberRecord + * POI likes NumberRecord better + */ + public static NumberRecord convertToNumberRecord(RKRecord rk) { + NumberRecord num = new NumberRecord(); + + num.setColumn(rk.getColumn()); + num.setRow(rk.getRow()); + num.setXFIndex(rk.getXFIndex()); + num.setValue(rk.getRKNumber()); + return num; + } + + /** + * Converts a {@link MulRKRecord} into an equivalent array of {@link NumberRecord}s + */ + public static NumberRecord[] convertRKRecords(MulRKRecord mrk) { + NumberRecord[] mulRecs = new NumberRecord[mrk.getNumColumns()]; + for (int k = 0; k < mrk.getNumColumns(); k++) { + NumberRecord nr = new NumberRecord(); + + nr.setColumn((short) (k + mrk.getFirstColumn())); + nr.setRow(mrk.getRow()); + nr.setXFIndex(mrk.getXFAt(k)); + nr.setValue(mrk.getRKNumberAt(k)); + mulRecs[k] = nr; + } + return mulRecs; + } + + /** + * Converts a {@link MulBlankRecord} into an equivalent array of {@link BlankRecord}s + */ + public static BlankRecord[] convertBlankRecords(MulBlankRecord mbk) { + BlankRecord[] mulRecs = new BlankRecord[mbk.getNumColumns()]; + for (int k = 0; k < mbk.getNumColumns(); k++) { + BlankRecord br = new BlankRecord(); + + br.setColumn((short) (k + mbk.getFirstColumn())); + br.setRow(mbk.getRow()); + br.setXFIndex(mbk.getXFAt(k)); + mulRecs[k] = br; + } + return mulRecs; + } + + /** + * @return an array of all the SIDS for all known records + */ + public static short[] getAllKnownRecordSIDs() { + if (_allKnownRecordSIDs == null) { + short[] results = new short[ _recordCreatorsById.size() ]; + int i = 0; + + for (Iterator<Integer> iterator = _recordCreatorsById.keySet().iterator(); iterator.hasNext(); ) { + Integer sid = iterator.next(); + + results[i++] = sid.shortValue(); + } + Arrays.sort(results); + _allKnownRecordSIDs = results; + } + + return _allKnownRecordSIDs.clone(); + } + + /** + * gets the record constructors and sticks them in the map by SID + * @return map of SIDs to short,short,byte[] constructors for Record classes + * most of org.apache.poi.hssf.record.* + */ + private static Map<Integer, I_RecordCreator> recordsToMap(Class<? extends Record> [] records) { + Map<Integer, I_RecordCreator> result = new HashMap<Integer, I_RecordCreator>(); + Set<Class<?>> uniqueRecClasses = new HashSet<Class<?>>(records.length * 3 / 2); + + for (int i = 0; i < records.length; i++) { + + Class<? extends Record> recClass = records[ i ]; + if(!Record.class.isAssignableFrom(recClass)) { + throw new RuntimeException("Invalid record sub-class (" + recClass.getName() + ")"); + } + if(Modifier.isAbstract(recClass.getModifiers())) { + throw new RuntimeException("Invalid record class (" + recClass.getName() + ") - must not be abstract"); + } + if(!uniqueRecClasses.add(recClass)) { + throw new RuntimeException("duplicate record class (" + recClass.getName() + ")"); + } + + int sid; + try { + sid = recClass.getField("sid").getShort(null); + } catch (Exception illegalArgumentException) { + throw new RecordFormatException( + "Unable to determine record types"); + } + Integer key = Integer.valueOf(sid); + if (result.containsKey(key)) { + Class<?> prevClass = result.get(key).getRecordClass(); + throw new RuntimeException("duplicate record sid 0x" + Integer.toHexString(sid).toUpperCase() + + " for classes (" + recClass.getName() + ") and (" + prevClass.getName() + ")"); + } + result.put(key, getRecordCreator(recClass)); + } + // result.put(Integer.valueOf(0x0406), result.get(Integer.valueOf(0x06))); + return result; + } + + private static I_RecordCreator getRecordCreator(Class<? extends Record> recClass) { + try { + Constructor<? extends Record> constructor; + constructor = recClass.getConstructor(CONSTRUCTOR_ARGS); + return new ReflectionConstructorRecordCreator(constructor); + } catch (NoSuchMethodException e) { + // fall through and look for other construction methods + } + try { + Method m = recClass.getDeclaredMethod("create", CONSTRUCTOR_ARGS); + return new ReflectionMethodRecordCreator(m); + } catch (NoSuchMethodException e) { + throw new RuntimeException("Failed to find constructor or create method for (" + recClass.getName() + ")."); + } + } + /** + * Create an array of records from an input stream + * + * @param in the InputStream from which the records will be obtained + * + * @return an array of Records created from the InputStream + * + * @exception RecordFormatException on error processing the InputStream + */ + public static List<Record> createRecords(InputStream in) throws RecordFormatException { + + List<Record> records = new ArrayList<Record>(NUM_RECORDS); + + RecordFactoryInputStream recStream = new RecordFactoryInputStream(in, true); + + Record record; + while ((record = recStream.nextRecord())!=null) { + records.add(record); + } + + return records; + } } diff --git a/src/java/org/apache/poi/hssf/record/RecordInputStream.java b/src/java/org/apache/poi/hssf/record/RecordInputStream.java index 9f0b16e184..9de7d68895 100644 --- a/src/java/org/apache/poi/hssf/record/RecordInputStream.java +++ b/src/java/org/apache/poi/hssf/record/RecordInputStream.java @@ -52,8 +52,17 @@ public final class RecordInputStream implements LittleEndianInput { public static final class LeftoverDataException extends RuntimeException { public LeftoverDataException(int sid, int remainingByteCount) { super("Initialisation of record 0x" + Integer.toHexString(sid).toUpperCase() - + " left " + remainingByteCount + " bytes remaining still to be read."); + + "(" + getRecordName(sid) + ") left " + remainingByteCount + + " bytes remaining still to be read."); } + + private static String getRecordName(int sid) { + Class<? extends Record> recordClass = RecordFactory.getRecordClass(sid); + if(recordClass == null) { + return null; + } + return recordClass.getSimpleName(); + } } /** Header {@link LittleEndianInput} facet of the wrapped {@link InputStream} */ diff --git a/src/java/org/apache/poi/hssf/record/RowRecord.java b/src/java/org/apache/poi/hssf/record/RowRecord.java index 75d3f99b13..ffbf9c7539 100644 --- a/src/java/org/apache/poi/hssf/record/RowRecord.java +++ b/src/java/org/apache/poi/hssf/record/RowRecord.java @@ -64,6 +64,9 @@ public final class RowRecord extends StandardRecord { // bit 15 is unused public RowRecord(int rowNumber) { + if(rowNumber < 0) { + throw new IllegalArgumentException("Invalid row number (" + rowNumber + ")"); + } field_1_row_number = rowNumber; field_4_height = (short)0xFF; field_5_optimize = ( short ) 0; @@ -76,6 +79,9 @@ public final class RowRecord extends StandardRecord { public RowRecord(RecordInputStream in) { field_1_row_number = in.readUShort(); + if(field_1_row_number < 0) { + throw new IllegalArgumentException("Invalid row number " + field_1_row_number + " found in InputStream"); + } field_2_first_col = in.readShort(); field_3_last_col = in.readShort(); field_4_height = in.readShort(); diff --git a/src/java/org/apache/poi/hssf/record/UnknownRecord.java b/src/java/org/apache/poi/hssf/record/UnknownRecord.java index 6b46247e23..f87953aba3 100644 --- a/src/java/org/apache/poi/hssf/record/UnknownRecord.java +++ b/src/java/org/apache/poi/hssf/record/UnknownRecord.java @@ -179,8 +179,10 @@ public final class UnknownRecord extends StandardRecord { case SHEETPROTECTION_0867: return "SHEETPROTECTION"; case 0x086B: return "DATALABEXTCONTENTS"; case 0x086C: return "CELLWATCH"; + case FeatRecord.v11_sid: return "SHARED FEATURE v11"; case 0x0874: return "DROPDOWNOBJIDS"; case 0x0876: return "DCONN"; + case FeatRecord.v12_sid: return "SHARED FEATURE v12"; case 0x087B: return "CFEX"; case 0x087C: return "XFCRC"; case 0x087D: return "XFEXT"; @@ -194,15 +196,21 @@ public final class UnknownRecord extends StandardRecord { case 0x089A: return "MTRSETTINGS"; case 0x089B: return "COMPRESSPICTURES"; case HEADER_FOOTER_089C: return "HEADERFOOTER"; + case 0x089D: return "CRTLAYOUT12"; + case 0x089E: return "CRTMLFRT"; + case 0x089F: return "CRTMLFRTCONTINUE"; case 0x08A1: return "SHAPEPROPSSTREAM"; case 0x08A3: return "FORCEFULLCALCULATION"; case 0x08A4: return "SHAPEPROPSSTREAM"; case 0x08A5: return "TEXTPROPSSTREAM"; case 0x08A6: return "RICHTEXTSTREAM"; + case 0x08A7: return "CRTLAYOUT12A"; case 0x08C8: return "PLV{Mac Excel}"; - - + + case 0x1001: return "UNITS"; + case 0x1006: return "CHARTDATAFORMAT"; + case 0x1007: return "CHARTLINEFORMAT"; } if (isObservedButUnknown(sid)) { return "UNKNOWN-" + Integer.toHexString(sid).toUpperCase(); @@ -215,6 +223,7 @@ public final class UnknownRecord extends StandardRecord { * @return <code>true</code> if the unknown record id has been observed in POI unit tests */ private static boolean isObservedButUnknown(int sid) { + // TODO Look up more of these in the latest [MS-XLS] doc and move to getBiffName switch (sid) { case 0x0033: // contains 2 bytes of data: 0x0001 or 0x0003 @@ -227,13 +236,7 @@ public final class UnknownRecord extends StandardRecord { // Written by Excel 2007 // rawData is multiple of 12 bytes long // appears after last cell value record and before WINDOW2 or drawing records - case 0x089D: - case 0x089E: - case 0x08A7: - case 0x1001: - case 0x1006: - case 0x1007: case 0x1009: case 0x100A: case 0x100B: diff --git a/src/java/org/apache/poi/hssf/record/aggregates/CFRecordsAggregate.java b/src/java/org/apache/poi/hssf/record/aggregates/CFRecordsAggregate.java index d9d64123a6..c43e4f5aee 100644 --- a/src/java/org/apache/poi/hssf/record/aggregates/CFRecordsAggregate.java +++ b/src/java/org/apache/poi/hssf/record/aggregates/CFRecordsAggregate.java @@ -21,7 +21,11 @@ import java.util.ArrayList; import java.util.List; import org.apache.poi.hssf.model.RecordStream; +import org.apache.poi.hssf.record.CFHeader12Record; +import org.apache.poi.hssf.record.CFHeaderBase; import org.apache.poi.hssf.record.CFHeaderRecord; +import org.apache.poi.hssf.record.CFRule12Record; +import org.apache.poi.hssf.record.CFRuleBase; import org.apache.poi.hssf.record.CFRuleRecord; import org.apache.poi.hssf.record.Record; import org.apache.poi.ss.formula.FormulaShifter; @@ -38,212 +42,240 @@ import org.apache.poi.util.POILogger; * <p>Note that Excel versions before 2007 can only cope with a maximum of 3 * Conditional Formatting rules per sheet. Excel 2007 or newer can cope with * unlimited numbers, as can Apache OpenOffice. This is an Excel limitation, - * not a file format one.</p> + * not a file format one.</p> */ public final class CFRecordsAggregate extends RecordAggregate { - /** Excel 97-2003 allows up to 3 conditional formating rules */ - private static final int MAX_97_2003_CONDTIONAL_FORMAT_RULES = 3; - private static final POILogger logger = POILogFactory.getLogger(CFRecordsAggregate.class); - - private final CFHeaderRecord header; - - /** List of CFRuleRecord objects */ - private final List<CFRuleRecord> rules; - - private CFRecordsAggregate(CFHeaderRecord pHeader, CFRuleRecord[] pRules) { - if(pHeader == null) { - throw new IllegalArgumentException("header must not be null"); - } - if(pRules == null) { - throw new IllegalArgumentException("rules must not be null"); - } - if(pRules.length > MAX_97_2003_CONDTIONAL_FORMAT_RULES) { - logger.log(POILogger.WARN, "Excel versions before 2007 require that " - + "No more than " + MAX_97_2003_CONDTIONAL_FORMAT_RULES - + " rules may be specified, " + pRules.length + " were found," - + " this file will cause problems with old Excel versions"); - } - if (pRules.length != pHeader.getNumberOfConditionalFormats()) { - throw new RuntimeException("Mismatch number of rules"); - } - header = pHeader; - rules = new ArrayList<CFRuleRecord>(3); - for (int i = 0; i < pRules.length; i++) { - rules.add(pRules[i]); - } - } - - public CFRecordsAggregate(CellRangeAddress[] regions, CFRuleRecord[] rules) { - this(new CFHeaderRecord(regions, rules.length), rules); - } - - /** - * Create CFRecordsAggregate from a list of CF Records - * @param rs - the stream to read from - * @return CFRecordsAggregate object - */ - public static CFRecordsAggregate createCFAggregate(RecordStream rs) { - Record rec = rs.getNext(); - if (rec.getSid() != CFHeaderRecord.sid) { - throw new IllegalStateException("next record sid was " + rec.getSid() - + " instead of " + CFHeaderRecord.sid + " as expected"); - } - - CFHeaderRecord header = (CFHeaderRecord)rec; - int nRules = header.getNumberOfConditionalFormats(); - - CFRuleRecord[] rules = new CFRuleRecord[nRules]; - for (int i = 0; i < rules.length; i++) { - rules[i] = (CFRuleRecord) rs.getNext(); - } - - return new CFRecordsAggregate(header, rules); - } - - /** - * Create a deep clone of the record - */ - public CFRecordsAggregate cloneCFAggregate() - { - - CFRuleRecord[] newRecs = new CFRuleRecord[rules.size()]; - for (int i = 0; i < newRecs.length; i++) { - newRecs[i] = (CFRuleRecord) getRule(i).clone(); - } - return new CFRecordsAggregate((CFHeaderRecord) header.clone(), newRecs); - } - - /** - * @return the header. Never <code>null</code>. - */ - public CFHeaderRecord getHeader() - { - return header; - } - - private void checkRuleIndex(int idx) { - if(idx < 0 || idx >= rules.size()) { - throw new IllegalArgumentException("Bad rule record index (" + idx - + ") nRules=" + rules.size()); - } - } - public CFRuleRecord getRule(int idx) { - checkRuleIndex(idx); - return rules.get(idx); - } - public void setRule(int idx, CFRuleRecord r) { - if (r == null) { - throw new IllegalArgumentException("r must not be null"); - } - checkRuleIndex(idx); - rules.set(idx, r); - } - public void addRule(CFRuleRecord r) { - if (r == null) { - throw new IllegalArgumentException("r must not be null"); - } - if(rules.size() >= MAX_97_2003_CONDTIONAL_FORMAT_RULES) { + /** Excel 97-2003 allows up to 3 conditional formating rules */ + private static final int MAX_97_2003_CONDTIONAL_FORMAT_RULES = 3; + private static final POILogger logger = POILogFactory.getLogger(CFRecordsAggregate.class); + + private final CFHeaderBase header; + + /** List of CFRuleRecord objects */ + private final List<CFRuleBase> rules; + + private CFRecordsAggregate(CFHeaderBase pHeader, CFRuleBase[] pRules) { + if(pHeader == null) { + throw new IllegalArgumentException("header must not be null"); + } + if(pRules == null) { + throw new IllegalArgumentException("rules must not be null"); + } + if(pRules.length > MAX_97_2003_CONDTIONAL_FORMAT_RULES) { + logger.log(POILogger.WARN, "Excel versions before 2007 require that " + + "No more than " + MAX_97_2003_CONDTIONAL_FORMAT_RULES + + " rules may be specified, " + pRules.length + " were found," + + " this file will cause problems with old Excel versions"); + } + if (pRules.length != pHeader.getNumberOfConditionalFormats()) { + throw new RuntimeException("Mismatch number of rules"); + } + header = pHeader; + rules = new ArrayList<CFRuleBase>(pRules.length); + for (int i = 0; i < pRules.length; i++) { + checkRuleType(pRules[i]); + rules.add(pRules[i]); + } + } + + public CFRecordsAggregate(CellRangeAddress[] regions, CFRuleBase[] rules) { + this(createHeader(regions, rules), rules); + } + private static CFHeaderBase createHeader(CellRangeAddress[] regions, CFRuleBase[] rules) { + if (rules.length == 0 || rules[0] instanceof CFRuleRecord) { + return new CFHeaderRecord(regions, rules.length); + } + return new CFHeader12Record(regions, rules.length); + } + + /** + * Create CFRecordsAggregate from a list of CF Records + * @param rs - the stream to read from + * @return CFRecordsAggregate object + */ + public static CFRecordsAggregate createCFAggregate(RecordStream rs) { + Record rec = rs.getNext(); + if (rec.getSid() != CFHeaderRecord.sid && + rec.getSid() != CFHeader12Record.sid) { + throw new IllegalStateException("next record sid was " + rec.getSid() + + " instead of " + CFHeaderRecord.sid + " or " + + CFHeader12Record.sid + " as expected"); + } + + CFHeaderBase header = (CFHeaderBase)rec; + int nRules = header.getNumberOfConditionalFormats(); + + CFRuleBase[] rules = new CFRuleBase[nRules]; + for (int i = 0; i < rules.length; i++) { + rules[i] = (CFRuleBase) rs.getNext(); + } + + return new CFRecordsAggregate(header, rules); + } + + /** + * Create a deep clone of the record + */ + public CFRecordsAggregate cloneCFAggregate() { + CFRuleBase[] newRecs = new CFRuleBase[rules.size()]; + for (int i = 0; i < newRecs.length; i++) { + newRecs[i] = (CFRuleRecord) getRule(i).clone(); + } + return new CFRecordsAggregate((CFHeaderBase)header.clone(), newRecs); + } + + /** + * @return the header. Never <code>null</code>. + */ + public CFHeaderBase getHeader() { + return header; + } + + private void checkRuleIndex(int idx) { + if(idx < 0 || idx >= rules.size()) { + throw new IllegalArgumentException("Bad rule record index (" + idx + + ") nRules=" + rules.size()); + } + } + private void checkRuleType(CFRuleBase r) { + if (header instanceof CFHeaderRecord && + r instanceof CFRuleRecord) { + return; + } + if (header instanceof CFHeader12Record && + r instanceof CFRule12Record) { + return; + } + throw new IllegalArgumentException("Header and Rule must both be CF or both be CF12, can't mix"); + } + + public CFRuleBase getRule(int idx) { + checkRuleIndex(idx); + return rules.get(idx); + } + public void setRule(int idx, CFRuleBase r) { + if (r == null) { + throw new IllegalArgumentException("r must not be null"); + } + checkRuleIndex(idx); + checkRuleType(r); + rules.set(idx, r); + } + public void addRule(CFRuleBase r) { + if (r == null) { + throw new IllegalArgumentException("r must not be null"); + } + if(rules.size() >= MAX_97_2003_CONDTIONAL_FORMAT_RULES) { logger.log(POILogger.WARN, "Excel versions before 2007 cannot cope with" - + " any more than " + MAX_97_2003_CONDTIONAL_FORMAT_RULES + + " any more than " + MAX_97_2003_CONDTIONAL_FORMAT_RULES + " - this file will cause problems with old Excel versions"); - } - rules.add(r); - header.setNumberOfConditionalFormats(rules.size()); - } - public int getNumberOfRules() { - return rules.size(); - } - - /** - * String representation of CFRecordsAggregate - */ - public String toString() - { - StringBuffer buffer = new StringBuffer(); - - buffer.append("[CF]\n"); - if( header != null ) - { - buffer.append(header.toString()); - } - for(int i=0; i<rules.size(); i++) - { - CFRuleRecord cfRule = rules.get(i); - buffer.append(cfRule.toString()); - } - buffer.append("[/CF]\n"); - return buffer.toString(); - } - - public void visitContainedRecords(RecordVisitor rv) { - rv.visitRecord(header); - for(int i=0; i<rules.size(); i++) { - CFRuleRecord rule = rules.get(i); - rv.visitRecord(rule); - } - } - - /** - * @return <code>false</code> if this whole {@link CFHeaderRecord} / {@link CFRuleRecord}s should be deleted - */ - public boolean updateFormulasAfterCellShift(FormulaShifter shifter, int currentExternSheetIx) { - CellRangeAddress[] cellRanges = header.getCellRanges(); - boolean changed = false; - List<CellRangeAddress> temp = new ArrayList<CellRangeAddress>(); - for (int i = 0; i < cellRanges.length; i++) { - CellRangeAddress craOld = cellRanges[i]; - CellRangeAddress craNew = shiftRange(shifter, craOld, currentExternSheetIx); - if (craNew == null) { - changed = true; - continue; - } - temp.add(craNew); - if (craNew != craOld) { - changed = true; - } - } - - if (changed) { - int nRanges = temp.size(); - if (nRanges == 0) { - return false; - } - CellRangeAddress[] newRanges = new CellRangeAddress[nRanges]; - temp.toArray(newRanges); - header.setCellRanges(newRanges); - } - - for(int i=0; i<rules.size(); i++) { - CFRuleRecord rule = rules.get(i); - Ptg[] ptgs; - ptgs = rule.getParsedExpression1(); - if (ptgs != null && shifter.adjustFormula(ptgs, currentExternSheetIx)) { - rule.setParsedExpression1(ptgs); - } - ptgs = rule.getParsedExpression2(); - if (ptgs != null && shifter.adjustFormula(ptgs, currentExternSheetIx)) { - rule.setParsedExpression2(ptgs); - } - } - return true; - } - - private static CellRangeAddress shiftRange(FormulaShifter shifter, CellRangeAddress cra, int currentExternSheetIx) { - // FormulaShifter works well in terms of Ptgs - so convert CellRangeAddress to AreaPtg (and back) here - AreaPtg aptg = new AreaPtg(cra.getFirstRow(), cra.getLastRow(), cra.getFirstColumn(), cra.getLastColumn(), false, false, false, false); - Ptg[] ptgs = { aptg, }; - - if (!shifter.adjustFormula(ptgs, currentExternSheetIx)) { - return cra; - } - Ptg ptg0 = ptgs[0]; - if (ptg0 instanceof AreaPtg) { - AreaPtg bptg = (AreaPtg) ptg0; - return new CellRangeAddress(bptg.getFirstRow(), bptg.getLastRow(), bptg.getFirstColumn(), bptg.getLastColumn()); - } - if (ptg0 instanceof AreaErrPtg) { - return null; - } - throw new IllegalStateException("Unexpected shifted ptg class (" + ptg0.getClass().getName() + ")"); - } + } + checkRuleType(r); + rules.add(r); + header.setNumberOfConditionalFormats(rules.size()); + } + public int getNumberOfRules() { + return rules.size(); + } + + /** + * String representation of CFRecordsAggregate + */ + public String toString() { + StringBuffer buffer = new StringBuffer(); + String type = "CF"; + if (header instanceof CFHeader12Record) { + type = "CF12"; + } + + buffer.append("[").append(type).append("]\n"); + if( header != null ) { + buffer.append(header.toString()); + } + for(int i=0; i<rules.size(); i++) { + CFRuleBase cfRule = rules.get(i); + buffer.append(cfRule.toString()); + } + buffer.append("[/").append(type).append("]\n"); + return buffer.toString(); + } + + public void visitContainedRecords(RecordVisitor rv) { + rv.visitRecord(header); + for(int i=0; i<rules.size(); i++) { + CFRuleBase rule = rules.get(i); + rv.visitRecord(rule); + } + } + + /** + * @return <code>false</code> if this whole {@link CFHeaderRecord} / {@link CFRuleRecord}s should be deleted + */ + public boolean updateFormulasAfterCellShift(FormulaShifter shifter, int currentExternSheetIx) { + CellRangeAddress[] cellRanges = header.getCellRanges(); + boolean changed = false; + List<CellRangeAddress> temp = new ArrayList<CellRangeAddress>(); + for (int i = 0; i < cellRanges.length; i++) { + CellRangeAddress craOld = cellRanges[i]; + CellRangeAddress craNew = shiftRange(shifter, craOld, currentExternSheetIx); + if (craNew == null) { + changed = true; + continue; + } + temp.add(craNew); + if (craNew != craOld) { + changed = true; + } + } + + if (changed) { + int nRanges = temp.size(); + if (nRanges == 0) { + return false; + } + CellRangeAddress[] newRanges = new CellRangeAddress[nRanges]; + temp.toArray(newRanges); + header.setCellRanges(newRanges); + } + + for(int i=0; i<rules.size(); i++) { + CFRuleBase rule = rules.get(i); + Ptg[] ptgs; + ptgs = rule.getParsedExpression1(); + if (ptgs != null && shifter.adjustFormula(ptgs, currentExternSheetIx)) { + rule.setParsedExpression1(ptgs); + } + ptgs = rule.getParsedExpression2(); + if (ptgs != null && shifter.adjustFormula(ptgs, currentExternSheetIx)) { + rule.setParsedExpression2(ptgs); + } + if (rule instanceof CFRule12Record) { + CFRule12Record rule12 = (CFRule12Record)rule; + ptgs = rule12.getParsedExpressionScale(); + if (ptgs != null && shifter.adjustFormula(ptgs, currentExternSheetIx)) { + rule12.setParsedExpressionScale(ptgs); + } + } + } + return true; + } + + private static CellRangeAddress shiftRange(FormulaShifter shifter, CellRangeAddress cra, int currentExternSheetIx) { + // FormulaShifter works well in terms of Ptgs - so convert CellRangeAddress to AreaPtg (and back) here + AreaPtg aptg = new AreaPtg(cra.getFirstRow(), cra.getLastRow(), cra.getFirstColumn(), cra.getLastColumn(), false, false, false, false); + Ptg[] ptgs = { aptg, }; + + if (!shifter.adjustFormula(ptgs, currentExternSheetIx)) { + return cra; + } + Ptg ptg0 = ptgs[0]; + if (ptg0 instanceof AreaPtg) { + AreaPtg bptg = (AreaPtg) ptg0; + return new CellRangeAddress(bptg.getFirstRow(), bptg.getLastRow(), bptg.getFirstColumn(), bptg.getLastColumn()); + } + if (ptg0 instanceof AreaErrPtg) { + return null; + } + throw new IllegalStateException("Unexpected shifted ptg class (" + ptg0.getClass().getName() + ")"); + } } diff --git a/src/java/org/apache/poi/hssf/record/aggregates/ConditionalFormattingTable.java b/src/java/org/apache/poi/hssf/record/aggregates/ConditionalFormattingTable.java index 33a2f7b294..e4721ca338 100644 --- a/src/java/org/apache/poi/hssf/record/aggregates/ConditionalFormattingTable.java +++ b/src/java/org/apache/poi/hssf/record/aggregates/ConditionalFormattingTable.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.List; import org.apache.poi.hssf.model.RecordStream; +import org.apache.poi.hssf.record.CFHeader12Record; import org.apache.poi.hssf.record.CFHeaderRecord; import org.apache.poi.ss.formula.FormulaShifter; @@ -28,11 +29,8 @@ import org.apache.poi.ss.formula.FormulaShifter; * Holds all the conditional formatting for a workbook sheet.<p/> * * See OOO exelfileformat.pdf sec 4.12 'Conditional Formatting Table' - * - * @author Josh Micich */ public final class ConditionalFormattingTable extends RecordAggregate { - private final List<CFRecordsAggregate> _cfHeaders; /** @@ -45,7 +43,8 @@ public final class ConditionalFormattingTable extends RecordAggregate { public ConditionalFormattingTable(RecordStream rs) { List<CFRecordsAggregate> temp = new ArrayList<CFRecordsAggregate>(); - while (rs.peekNextClass() == CFHeaderRecord.class) { + while (rs.peekNextClass() == CFHeaderRecord.class || + rs.peekNextClass() == CFHeader12Record.class) { temp.add(CFRecordsAggregate.createCFAggregate(rs)); } _cfHeaders = temp; @@ -62,6 +61,7 @@ public final class ConditionalFormattingTable extends RecordAggregate { * @return index of the newly added CF header aggregate */ public int add(CFRecordsAggregate cfAggregate) { + cfAggregate.getHeader().setID(_cfHeaders.size()); _cfHeaders.add(cfAggregate); return _cfHeaders.size() - 1; } diff --git a/src/java/org/apache/poi/hssf/record/cf/BorderFormatting.java b/src/java/org/apache/poi/hssf/record/cf/BorderFormatting.java index e9eca99258..ef003d5366 100644 --- a/src/java/org/apache/poi/hssf/record/cf/BorderFormatting.java +++ b/src/java/org/apache/poi/hssf/record/cf/BorderFormatting.java @@ -25,11 +25,8 @@ import org.apache.poi.util.LittleEndianOutput; /** * Border Formatting Block of the Conditional Formatting Rule Record. - * - * @author Dmitriy Kumshayev */ public final class BorderFormatting { - /** No border */ public final static short BORDER_NONE = 0x0; /** Thin border */ @@ -89,6 +86,9 @@ public final class BorderFormatting { field_14_border_styles2 = in.readInt(); } + public int getDataLength() { + return 8; + } /** * set the type of border to use for the left border of the cell diff --git a/src/java/org/apache/poi/hssf/record/cf/CellRangeUtil.java b/src/java/org/apache/poi/hssf/record/cf/CellRangeUtil.java index d1532a94d6..cde666a8ed 100644 --- a/src/java/org/apache/poi/hssf/record/cf/CellRangeUtil.java +++ b/src/java/org/apache/poi/hssf/record/cf/CellRangeUtil.java @@ -23,97 +23,93 @@ import java.util.List; import org.apache.poi.ss.util.CellRangeAddress; /** - * - * @author Dmitriy Kumshayev + * TODO Should this move to org.apache.poi.ss.util ? */ -public final class CellRangeUtil -{ - - private CellRangeUtil() { - // no instance of this class - } - - public static final int NO_INTERSECTION = 1; - public static final int OVERLAP = 2; - /** first range is within the second range */ - public static final int INSIDE = 3; - /** first range encloses or is equal to the second */ - public static final int ENCLOSES = 4; - - /** - * Intersect this range with the specified range. - * - * @param crB - the specified range - * @return code which reflects how the specified range is related to this range.<br/> - * Possible return codes are: - * NO_INTERSECTION - the specified range is outside of this range;<br/> - * OVERLAP - both ranges partially overlap;<br/> - * INSIDE - the specified range is inside of this one<br/> - * ENCLOSES - the specified range encloses (possibly exactly the same as) this range<br/> - */ - public static int intersect(CellRangeAddress crA, CellRangeAddress crB ) - { - - int firstRow = crB.getFirstRow(); - int lastRow = crB.getLastRow(); - int firstCol = crB.getFirstColumn(); - int lastCol = crB.getLastColumn(); - - if - ( +public final class CellRangeUtil { + private CellRangeUtil() { + // no instance of this class + } + + public static final int NO_INTERSECTION = 1; + public static final int OVERLAP = 2; + /** first range is within the second range */ + public static final int INSIDE = 3; + /** first range encloses or is equal to the second */ + public static final int ENCLOSES = 4; + + /** + * Intersect this range with the specified range. + * + * @param crB - the specified range + * @return code which reflects how the specified range is related to this range.<br/> + * Possible return codes are: + * NO_INTERSECTION - the specified range is outside of this range;<br/> + * OVERLAP - both ranges partially overlap;<br/> + * INSIDE - the specified range is inside of this one<br/> + * ENCLOSES - the specified range encloses (possibly exactly the same as) this range<br/> + */ + public static int intersect(CellRangeAddress crA, CellRangeAddress crB ) + { + + int firstRow = crB.getFirstRow(); + int lastRow = crB.getLastRow(); + int firstCol = crB.getFirstColumn(); + int lastCol = crB.getLastColumn(); + + if + ( gt(crA.getFirstRow(),lastRow) || lt(crA.getLastRow(),firstRow) || gt(crA.getFirstColumn(),lastCol) || lt(crA.getLastColumn(),firstCol) - ) - { - return NO_INTERSECTION; - } - else if( contains(crA, crB) ) - { - return INSIDE; - } - else if( contains(crB, crA)) - { - return ENCLOSES; - } - else - { - return OVERLAP; - } - - } - - /** - * Do all possible cell merges between cells of the list so that:<br> - * <li>if a cell range is completely inside of another cell range, it gets removed from the list - * <li>if two cells have a shared border, merge them into one bigger cell range - * @param cellRanges - * @return updated List of cell ranges - */ - public static CellRangeAddress[] mergeCellRanges(CellRangeAddress[] cellRanges) { - if(cellRanges.length < 1) { - return cellRanges; - } + ) + { + return NO_INTERSECTION; + } + else if( contains(crA, crB) ) + { + return INSIDE; + } + else if( contains(crB, crA)) + { + return ENCLOSES; + } + else + { + return OVERLAP; + } + } + + /** + * Do all possible cell merges between cells of the list so that:<br> + * <li>if a cell range is completely inside of another cell range, it gets removed from the list + * <li>if two cells have a shared border, merge them into one bigger cell range + * @param cellRanges + * @return updated List of cell ranges + */ + public static CellRangeAddress[] mergeCellRanges(CellRangeAddress[] cellRanges) { + if(cellRanges.length < 1) { + return cellRanges; + } List<CellRangeAddress> lst = new ArrayList<CellRangeAddress>(); for(CellRangeAddress cr : cellRanges) { lst.add(cr); } List<CellRangeAddress> temp = mergeCellRanges(lst); - return toArray(temp); - } + return toArray(temp); + } - private static List<CellRangeAddress> mergeCellRanges(List<CellRangeAddress> cellRangeList) - { - // loop until either only one item is left or we did not merge anything any more + private static List<CellRangeAddress> mergeCellRanges(List<CellRangeAddress> cellRangeList) + { + // loop until either only one item is left or we did not merge anything any more while (cellRangeList.size() > 1) { boolean somethingGotMerged = false; // look at all cell-ranges for (int i = 0; i < cellRangeList.size(); i++) { CellRangeAddress range1 = cellRangeList.get(i); - + // compare each cell range to all other cell-ranges for (int j = i + 1; j < cellRangeList.size(); j++) { CellRangeAddress range2 = cellRangeList.get(j); @@ -139,16 +135,16 @@ public final class CellRangeUtil } } - return cellRangeList; - } - - /** - * @return the new range(s) to replace the supplied ones. <code>null</code> if no merge is possible - */ - private static CellRangeAddress[] mergeRanges(CellRangeAddress range1, CellRangeAddress range2) { - int x = intersect(range1, range2); - switch(x) - { + return cellRangeList; + } + + /** + * @return the new range(s) to replace the supplied ones. <code>null</code> if no merge is possible + */ + private static CellRangeAddress[] mergeRanges(CellRangeAddress range1, CellRangeAddress range2) { + int x = intersect(range1, range2); + switch(x) + { case CellRangeUtil.NO_INTERSECTION: // nothing in common: at most they could be adjacent to each other and thus form a single bigger area if(hasExactSharedBorder(range1, range2)) { @@ -171,108 +167,103 @@ public final class CellRangeUtil throw new RuntimeException("unexpected intersection result (" + x + ")"); } - - private static CellRangeAddress[] toArray(List<CellRangeAddress> temp) { - CellRangeAddress[] result = new CellRangeAddress[temp.size()]; - temp.toArray(result); - return result; - } + private static CellRangeAddress[] toArray(List<CellRangeAddress> temp) { + CellRangeAddress[] result = new CellRangeAddress[temp.size()]; + temp.toArray(result); + return result; + } + /** + * Check if the specified range is located inside of this cell range. + * + * @param crB + * @return true if this cell range contains the argument range inside if it's area + */ + public static boolean contains(CellRangeAddress crA, CellRangeAddress crB) + { + int firstRow = crB.getFirstRow(); + int lastRow = crB.getLastRow(); + int firstCol = crB.getFirstColumn(); + int lastCol = crB.getLastColumn(); + return le(crA.getFirstRow(), firstRow) && ge(crA.getLastRow(), lastRow) + && le(crA.getFirstColumn(), firstCol) && ge(crA.getLastColumn(), lastCol); + } + /** + * Check if the two cell ranges have a shared border. + * + * @return <code>true</code> if the ranges have a complete shared border (i.e. + * the two ranges together make a simple rectangular region. + */ + public static boolean hasExactSharedBorder(CellRangeAddress crA, CellRangeAddress crB) { + int oFirstRow = crB.getFirstRow(); + int oLastRow = crB.getLastRow(); + int oFirstCol = crB.getFirstColumn(); + int oLastCol = crB.getLastColumn(); - /** - * Check if the specified range is located inside of this cell range. - * - * @param crB - * @return true if this cell range contains the argument range inside if it's area - */ - public static boolean contains(CellRangeAddress crA, CellRangeAddress crB) - { - int firstRow = crB.getFirstRow(); - int lastRow = crB.getLastRow(); - int firstCol = crB.getFirstColumn(); - int lastCol = crB.getLastColumn(); - return le(crA.getFirstRow(), firstRow) && ge(crA.getLastRow(), lastRow) - && le(crA.getFirstColumn(), firstCol) && ge(crA.getLastColumn(), lastCol); - } - - /** - * Check if the two cell ranges have a shared border. - * - * @return <code>true</code> if the ranges have a complete shared border (i.e. - * the two ranges together make a simple rectangular region. - */ - public static boolean hasExactSharedBorder(CellRangeAddress crA, CellRangeAddress crB) { - int oFirstRow = crB.getFirstRow(); - int oLastRow = crB.getLastRow(); - int oFirstCol = crB.getFirstColumn(); - int oLastCol = crB.getLastColumn(); - - if (crA.getFirstRow() > 0 && crA.getFirstRow()-1 == oLastRow || - oFirstRow > 0 && oFirstRow-1 == crA.getLastRow()) { - // ranges have a horizontal border in common - // make sure columns are identical: - return crA.getFirstColumn() == oFirstCol && crA.getLastColumn() == oLastCol; - } + if (crA.getFirstRow() > 0 && crA.getFirstRow()-1 == oLastRow || + oFirstRow > 0 && oFirstRow-1 == crA.getLastRow()) { + // ranges have a horizontal border in common + // make sure columns are identical: + return crA.getFirstColumn() == oFirstCol && crA.getLastColumn() == oLastCol; + } - if (crA.getFirstColumn()>0 && crA.getFirstColumn() - 1 == oLastCol || - oFirstCol>0 && crA.getLastColumn() == oFirstCol -1) { - // ranges have a vertical border in common - // make sure rows are identical: - return crA.getFirstRow() == oFirstRow && crA.getLastRow() == oLastRow; - } - return false; - } - - /** - * Create an enclosing CellRange for the two cell ranges. - * - * @return enclosing CellRange - */ - public static CellRangeAddress createEnclosingCellRange(CellRangeAddress crA, CellRangeAddress crB) { - if( crB == null) { - return crA.copy(); - } - - return - new CellRangeAddress( - lt(crB.getFirstRow(), crA.getFirstRow()) ?crB.getFirstRow() :crA.getFirstRow(), - gt(crB.getLastRow(), crA.getLastRow()) ?crB.getLastRow() :crA.getLastRow(), - lt(crB.getFirstColumn(),crA.getFirstColumn())?crB.getFirstColumn():crA.getFirstColumn(), - gt(crB.getLastColumn(), crA.getLastColumn()) ?crB.getLastColumn() :crA.getLastColumn() - ); - - } - - /** - * @return true if a < b - */ - private static boolean lt(int a, int b) - { - return a == -1 ? false : (b == -1 ? true : a < b); - } - - /** - * @return true if a <= b - */ - private static boolean le(int a, int b) - { - return a == b || lt(a,b); - } - - /** - * @return true if a > b - */ - private static boolean gt(int a, int b) - { - return lt(b,a); - } + if (crA.getFirstColumn()>0 && crA.getFirstColumn() - 1 == oLastCol || + oFirstCol>0 && crA.getLastColumn() == oFirstCol -1) { + // ranges have a vertical border in common + // make sure rows are identical: + return crA.getFirstRow() == oFirstRow && crA.getLastRow() == oLastRow; + } + return false; + } - /** - * @return true if a >= b - */ - private static boolean ge(int a, int b) - { - return !lt(a,b); - } + /** + * Create an enclosing CellRange for the two cell ranges. + * + * @return enclosing CellRange + */ + public static CellRangeAddress createEnclosingCellRange(CellRangeAddress crA, CellRangeAddress crB) { + if( crB == null) { + return crA.copy(); + } + + return new CellRangeAddress( + lt(crB.getFirstRow(), crA.getFirstRow()) ?crB.getFirstRow() :crA.getFirstRow(), + gt(crB.getLastRow(), crA.getLastRow()) ?crB.getLastRow() :crA.getLastRow(), + lt(crB.getFirstColumn(),crA.getFirstColumn())?crB.getFirstColumn():crA.getFirstColumn(), + gt(crB.getLastColumn(), crA.getLastColumn()) ?crB.getLastColumn() :crA.getLastColumn() + ); + } + + /** + * @return true if a < b + */ + private static boolean lt(int a, int b) + { + return a == -1 ? false : (b == -1 ? true : a < b); + } + + /** + * @return true if a <= b + */ + private static boolean le(int a, int b) + { + return a == b || lt(a,b); + } + + /** + * @return true if a > b + */ + private static boolean gt(int a, int b) + { + return lt(b,a); + } + + /** + * @return true if a >= b + */ + private static boolean ge(int a, int b) + { + return !lt(a,b); + } } diff --git a/src/java/org/apache/poi/hssf/record/cf/FontFormatting.java b/src/java/org/apache/poi/hssf/record/cf/FontFormatting.java index be7aafac0e..59c49d8a42 100644 --- a/src/java/org/apache/poi/hssf/record/cf/FontFormatting.java +++ b/src/java/org/apache/poi/hssf/record/cf/FontFormatting.java @@ -25,525 +25,523 @@ import org.apache.poi.util.LittleEndian; /** * Font Formatting Block of the Conditional Formatting Rule Record. - * - * @author Dmitriy Kumshayev */ -public final class FontFormatting -{ - private byte[] _rawData; - - private static final int OFFSET_FONT_NAME = 0; - private static final int OFFSET_FONT_HEIGHT = 64; - private static final int OFFSET_FONT_OPTIONS = 68; - private static final int OFFSET_FONT_WEIGHT = 72; - private static final int OFFSET_ESCAPEMENT_TYPE = 74; - private static final int OFFSET_UNDERLINE_TYPE = 76; - private static final int OFFSET_FONT_COLOR_INDEX = 80; - private static final int OFFSET_OPTION_FLAGS = 88; - private static final int OFFSET_ESCAPEMENT_TYPE_MODIFIED = 92; - private static final int OFFSET_UNDERLINE_TYPE_MODIFIED = 96; - private static final int OFFSET_FONT_WEIGHT_MODIFIED = 100; - private static final int OFFSET_NOT_USED1 = 104; - private static final int OFFSET_NOT_USED2 = 108; - private static final int OFFSET_NOT_USED3 = 112; // for some reason Excel always writes 0x7FFFFFFF at this offset - private static final int OFFSET_FONT_FORMATING_END = 116; - private static final int RAW_DATA_SIZE = 118; - - - public final static int FONT_CELL_HEIGHT_PRESERVED = 0xFFFFFFFF; - - // FONT OPTIONS MASKS - private static final BitField posture = BitFieldFactory.getInstance(0x00000002); - private static final BitField outline = BitFieldFactory.getInstance(0x00000008); - private static final BitField shadow = BitFieldFactory.getInstance(0x00000010); - private static final BitField cancellation = BitFieldFactory.getInstance(0x00000080); - - // OPTION FLAGS MASKS - - private static final BitField styleModified = BitFieldFactory.getInstance(0x00000002); - private static final BitField outlineModified = BitFieldFactory.getInstance(0x00000008); - private static final BitField shadowModified = BitFieldFactory.getInstance(0x00000010); - private static final BitField cancellationModified = BitFieldFactory.getInstance(0x00000080); - - /** Escapement type - None */ - public static final short SS_NONE = 0; - /** Escapement type - Superscript */ - public static final short SS_SUPER = 1; - /** Escapement type - Subscript */ - public static final short SS_SUB = 2; - /** Underline type - None */ - public static final byte U_NONE = 0; - /** Underline type - Single */ - public static final byte U_SINGLE = 1; - /** Underline type - Double */ - public static final byte U_DOUBLE = 2; - /** Underline type - Single Accounting */ - public static final byte U_SINGLE_ACCOUNTING = 0x21; - /** Underline type - Double Accounting */ - public static final byte U_DOUBLE_ACCOUNTING = 0x22; - /** Normal boldness (not bold) */ - private static final short FONT_WEIGHT_NORMAL = 0x190; - - /** - * Bold boldness (bold) - */ - private static final short FONT_WEIGHT_BOLD = 0x2bc; - - private FontFormatting(byte[] rawData) { - _rawData = rawData; - } - - public FontFormatting() - { - this(new byte[RAW_DATA_SIZE]); - - setFontHeight(-1); - setItalic(false); - setFontWieghtModified(false); - setOutline(false); - setShadow(false); - setStrikeout(false); - setEscapementType((short)0); - setUnderlineType((byte)0); - setFontColorIndex((short)-1); - - setFontStyleModified(false); - setFontOutlineModified(false); - setFontShadowModified(false); - setFontCancellationModified(false); - - setEscapementTypeModified(false); - setUnderlineTypeModified(false); - - setShort(OFFSET_FONT_NAME, 0); - setInt(OFFSET_NOT_USED1, 0x00000001); - setInt(OFFSET_NOT_USED2, 0x00000000); - setInt(OFFSET_NOT_USED3, 0x7FFFFFFF);// for some reason Excel always writes 0x7FFFFFFF at this offset - setShort(OFFSET_FONT_FORMATING_END, 0x0001); - } - - /** Creates new FontFormatting */ - public FontFormatting(RecordInputStream in) - { - this(new byte[RAW_DATA_SIZE]); - for (int i = 0; i < _rawData.length; i++) - { - _rawData[i] = in.readByte(); - } - } - - private short getShort(int offset) { - return LittleEndian.getShort( _rawData, offset); - } - private void setShort(int offset, int value) { - LittleEndian.putShort( _rawData, offset, (short)value); - } - private int getInt(int offset) { - return LittleEndian.getInt( _rawData, offset); - } - private void setInt(int offset, int value) { - LittleEndian.putInt( _rawData, offset, value); - } - - public byte[] getRawRecord() - { - return _rawData; - } - - /** - * sets the height of the font in 1/20th point units - * - * - * @param height fontheight (in points/20); or -1 to preserve the cell font height - */ - - public void setFontHeight(int height) - { - setInt(OFFSET_FONT_HEIGHT, height); - } - - /** - * gets the height of the font in 1/20th point units - * - * @return fontheight (in points/20); or -1 if not modified - */ - public int getFontHeight() - { - return getInt(OFFSET_FONT_HEIGHT); - } - - private void setFontOption(boolean option, BitField field) - { - int options = getInt(OFFSET_FONT_OPTIONS); - options = field.setBoolean(options, option); - setInt(OFFSET_FONT_OPTIONS, options); - } - - private boolean getFontOption(BitField field) - { - int options = getInt(OFFSET_FONT_OPTIONS); - return field.isSet(options); - } - - /** - * set the font to be italics or not - * - * @param italic - whether the font is italics or not - * @see #setFontOption(boolean, org.apache.poi.util.BitField) - */ - - public void setItalic(boolean italic) - { - setFontOption(italic, posture); - } - - /** - * get whether the font is to be italics or not - * - * @return italics - whether the font is italics or not - * @see #getFontOption(org.apache.poi.util.BitField) - */ - - public boolean isItalic() - { - return getFontOption(posture); - } - - public void setOutline(boolean on) - { - setFontOption(on, outline); - } - - public boolean isOutlineOn() - { - return getFontOption(outline); - } - - public void setShadow(boolean on) - { - setFontOption(on, shadow); - } - - public boolean isShadowOn() - { - return getFontOption(shadow); - } - - /** - * set the font to be stricken out or not - * - * @param strike - whether the font is stricken out or not - */ - - public void setStrikeout(boolean strike) - { - setFontOption(strike, cancellation); - } - - /** - * get whether the font is to be stricken out or not - * - * @return strike - whether the font is stricken out or not - * @see #getFontOption(org.apache.poi.util.BitField) - */ - - public boolean isStruckout() - { - return getFontOption(cancellation); - } - - /** - * set the font weight (100-1000dec or 0x64-0x3e8). Default is - * 0x190 for normal and 0x2bc for bold - * - * @param bw - a number between 100-1000 for the fonts "boldness" - */ - - private void setFontWeight(short pbw) - { - short bw = pbw; - if( bw<100) { bw=100; } - if( bw>1000){ bw=1000; } - setShort(OFFSET_FONT_WEIGHT, bw); - } - - /** - * set the font weight to bold (weight=700) or to normal(weight=400) boldness. - * - * @param bold - set font weight to bold if true; to normal otherwise - */ - public void setBold(boolean bold) - { - setFontWeight(bold?FONT_WEIGHT_BOLD:FONT_WEIGHT_NORMAL); - } - - /** - * get the font weight for this font (100-1000dec or 0x64-0x3e8). Default is - * 0x190 for normal and 0x2bc for bold - * - * @return bw - a number between 100-1000 for the fonts "boldness" - */ - - public short getFontWeight() - { - return getShort(OFFSET_FONT_WEIGHT); - } - - /** - * get whether the font weight is set to bold or not - * - * @return bold - whether the font is bold or not - */ - - public boolean isBold() - { - return getFontWeight()==FONT_WEIGHT_BOLD; - } - - /** - * get the type of super or subscript for the font - * - * @return super or subscript option - * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#SS_NONE - * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#SS_SUPER - * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#SS_SUB - */ - public short getEscapementType() - { - return getShort(OFFSET_ESCAPEMENT_TYPE); - } - - /** - * set the escapement type for the font - * - * @param escapementType super or subscript option - * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#SS_NONE - * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#SS_SUPER - * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#SS_SUB - */ - public void setEscapementType( short escapementType) - { - setShort(OFFSET_ESCAPEMENT_TYPE, escapementType); - } - - /** - * get the type of underlining for the font - * - * @return font underlining type - * - * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#U_NONE - * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#U_SINGLE - * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#U_DOUBLE - * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#U_SINGLE_ACCOUNTING - * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#U_DOUBLE_ACCOUNTING - */ - - public short getUnderlineType() - { - return getShort(OFFSET_UNDERLINE_TYPE); - } - - /** - * set the type of underlining type for the font - * - * @param underlineType underline option - * - * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#U_NONE - * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#U_SINGLE - * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#U_DOUBLE - * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#U_SINGLE_ACCOUNTING - * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#U_DOUBLE_ACCOUNTING - */ - public void setUnderlineType( short underlineType) - { - setShort(OFFSET_UNDERLINE_TYPE, underlineType); - } - - - public short getFontColorIndex() - { - return (short)getInt(OFFSET_FONT_COLOR_INDEX); - } - - public void setFontColorIndex(short fci ) - { - setInt(OFFSET_FONT_COLOR_INDEX,fci); - } - - private boolean getOptionFlag(BitField field) - { - int optionFlags = getInt(OFFSET_OPTION_FLAGS); - int value = field.getValue(optionFlags); - return value==0? true : false ; - } - - private void setOptionFlag(boolean modified, BitField field) - { - int value = modified? 0 : 1; - int optionFlags = getInt(OFFSET_OPTION_FLAGS); - optionFlags = field.setValue(optionFlags, value); - setInt(OFFSET_OPTION_FLAGS, optionFlags); - } - - - public boolean isFontStyleModified() - { - return getOptionFlag(styleModified); - } - - - public void setFontStyleModified(boolean modified) - { - setOptionFlag(modified, styleModified); - } - - public boolean isFontOutlineModified() - { - return getOptionFlag(outlineModified); - } - - public void setFontOutlineModified(boolean modified) - { - setOptionFlag(modified, outlineModified); - } - - public boolean isFontShadowModified() - { - return getOptionFlag(shadowModified); - } - - public void setFontShadowModified(boolean modified) - { - setOptionFlag(modified, shadowModified); - } - public void setFontCancellationModified(boolean modified) - { - setOptionFlag(modified, cancellationModified); - } - - public boolean isFontCancellationModified() - { - return getOptionFlag(cancellationModified); - } - - public void setEscapementTypeModified(boolean modified) - { - int value = modified? 0 : 1; - setInt(OFFSET_ESCAPEMENT_TYPE_MODIFIED, value); - } - public boolean isEscapementTypeModified() - { - int escapementModified = getInt(OFFSET_ESCAPEMENT_TYPE_MODIFIED); - return escapementModified == 0; - } - - public void setUnderlineTypeModified(boolean modified) - { - int value = modified? 0 : 1; - setInt(OFFSET_UNDERLINE_TYPE_MODIFIED, value); - } - - public boolean isUnderlineTypeModified() - { - int underlineModified = getInt(OFFSET_UNDERLINE_TYPE_MODIFIED); - return underlineModified == 0; - } - - public void setFontWieghtModified(boolean modified) - { - int value = modified? 0 : 1; - setInt(OFFSET_FONT_WEIGHT_MODIFIED, value); - } - - public boolean isFontWeightModified() - { - int fontStyleModified = getInt(OFFSET_FONT_WEIGHT_MODIFIED); - return fontStyleModified == 0; - } - - public String toString() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(" [Font Formatting]\n"); - - buffer.append(" .font height = ").append(getFontHeight()).append(" twips\n"); - - if( isFontStyleModified() ) - { - buffer.append(" .font posture = ").append(isItalic()?"Italic":"Normal").append("\n"); - } - else - { - buffer.append(" .font posture = ]not modified]").append("\n"); - } - - if( isFontOutlineModified() ) - { - buffer.append(" .font outline = ").append(isOutlineOn()).append("\n"); - } - else - { - buffer.append(" .font outline is not modified\n"); - } - - if( isFontShadowModified() ) - { - buffer.append(" .font shadow = ").append(isShadowOn()).append("\n"); - } - else - { - buffer.append(" .font shadow is not modified\n"); - } - - if( isFontCancellationModified() ) - { - buffer.append(" .font strikeout = ").append(isStruckout()).append("\n"); - } - else - { - buffer.append(" .font strikeout is not modified\n"); - } - - if( isFontStyleModified() ) - { - buffer.append(" .font weight = "). - append(getFontWeight()). - append( - getFontWeight() == FONT_WEIGHT_NORMAL ? "(Normal)" - : getFontWeight() == FONT_WEIGHT_BOLD ? "(Bold)" : "0x"+Integer.toHexString(getFontWeight())). - append("\n"); - } - else - { - buffer.append(" .font weight = ]not modified]").append("\n"); - } - - if( isEscapementTypeModified() ) - { - buffer.append(" .escapement type = ").append(getEscapementType()).append("\n"); - } - else - { - buffer.append(" .escapement type is not modified\n"); - } - - if( isUnderlineTypeModified() ) - { - buffer.append(" .underline type = ").append(getUnderlineType()).append("\n"); - } - else - { - buffer.append(" .underline type is not modified\n"); - } - buffer.append(" .color index = ").append("0x"+Integer.toHexString(getFontColorIndex()).toUpperCase()).append("\n"); - - buffer.append(" [/Font Formatting]\n"); - return buffer.toString(); - } - - public Object clone() - { - byte[] rawData = _rawData.clone(); - return new FontFormatting(rawData); - } +public final class FontFormatting { + private byte[] _rawData; + + private static final int OFFSET_FONT_NAME = 0; + private static final int OFFSET_FONT_HEIGHT = 64; + private static final int OFFSET_FONT_OPTIONS = 68; + private static final int OFFSET_FONT_WEIGHT = 72; + private static final int OFFSET_ESCAPEMENT_TYPE = 74; + private static final int OFFSET_UNDERLINE_TYPE = 76; + private static final int OFFSET_FONT_COLOR_INDEX = 80; + private static final int OFFSET_OPTION_FLAGS = 88; + private static final int OFFSET_ESCAPEMENT_TYPE_MODIFIED = 92; + private static final int OFFSET_UNDERLINE_TYPE_MODIFIED = 96; + private static final int OFFSET_FONT_WEIGHT_MODIFIED = 100; + private static final int OFFSET_NOT_USED1 = 104; + private static final int OFFSET_NOT_USED2 = 108; + private static final int OFFSET_NOT_USED3 = 112; // for some reason Excel always writes 0x7FFFFFFF at this offset + private static final int OFFSET_FONT_FORMATING_END = 116; + private static final int RAW_DATA_SIZE = 118; + + + public final static int FONT_CELL_HEIGHT_PRESERVED = 0xFFFFFFFF; + + // FONT OPTIONS MASKS + private static final BitField posture = BitFieldFactory.getInstance(0x00000002); + private static final BitField outline = BitFieldFactory.getInstance(0x00000008); + private static final BitField shadow = BitFieldFactory.getInstance(0x00000010); + private static final BitField cancellation = BitFieldFactory.getInstance(0x00000080); + + // OPTION FLAGS MASKS + + private static final BitField styleModified = BitFieldFactory.getInstance(0x00000002); + private static final BitField outlineModified = BitFieldFactory.getInstance(0x00000008); + private static final BitField shadowModified = BitFieldFactory.getInstance(0x00000010); + private static final BitField cancellationModified = BitFieldFactory.getInstance(0x00000080); + + /** Escapement type - None */ + public static final short SS_NONE = 0; + /** Escapement type - Superscript */ + public static final short SS_SUPER = 1; + /** Escapement type - Subscript */ + public static final short SS_SUB = 2; + /** Underline type - None */ + public static final byte U_NONE = 0; + /** Underline type - Single */ + public static final byte U_SINGLE = 1; + /** Underline type - Double */ + public static final byte U_DOUBLE = 2; + /** Underline type - Single Accounting */ + public static final byte U_SINGLE_ACCOUNTING = 0x21; + /** Underline type - Double Accounting */ + public static final byte U_DOUBLE_ACCOUNTING = 0x22; + /** Normal boldness (not bold) */ + private static final short FONT_WEIGHT_NORMAL = 0x190; + + /** + * Bold boldness (bold) + */ + private static final short FONT_WEIGHT_BOLD = 0x2bc; + + private FontFormatting(byte[] rawData) { + _rawData = rawData; + } + + public FontFormatting() + { + this(new byte[RAW_DATA_SIZE]); + + setFontHeight(-1); + setItalic(false); + setFontWieghtModified(false); + setOutline(false); + setShadow(false); + setStrikeout(false); + setEscapementType((short)0); + setUnderlineType((byte)0); + setFontColorIndex((short)-1); + + setFontStyleModified(false); + setFontOutlineModified(false); + setFontShadowModified(false); + setFontCancellationModified(false); + + setEscapementTypeModified(false); + setUnderlineTypeModified(false); + + setShort(OFFSET_FONT_NAME, 0); + setInt(OFFSET_NOT_USED1, 0x00000001); + setInt(OFFSET_NOT_USED2, 0x00000000); + setInt(OFFSET_NOT_USED3, 0x7FFFFFFF);// for some reason Excel always writes 0x7FFFFFFF at this offset + setShort(OFFSET_FONT_FORMATING_END, 0x0001); + } + + /** Creates new FontFormatting */ + public FontFormatting(RecordInputStream in) + { + this(new byte[RAW_DATA_SIZE]); + for (int i = 0; i < _rawData.length; i++) + { + _rawData[i] = in.readByte(); + } + } + + private short getShort(int offset) { + return LittleEndian.getShort( _rawData, offset); + } + private void setShort(int offset, int value) { + LittleEndian.putShort( _rawData, offset, (short)value); + } + private int getInt(int offset) { + return LittleEndian.getInt( _rawData, offset); + } + private void setInt(int offset, int value) { + LittleEndian.putInt( _rawData, offset, value); + } + + public byte[] getRawRecord() + { + return _rawData; + } + + public int getDataLength() { + return RAW_DATA_SIZE; + } + + /** + * sets the height of the font in 1/20th point units + * + * + * @param height fontheight (in points/20); or -1 to preserve the cell font height + */ + + public void setFontHeight(int height) + { + setInt(OFFSET_FONT_HEIGHT, height); + } + + /** + * gets the height of the font in 1/20th point units + * + * @return fontheight (in points/20); or -1 if not modified + */ + public int getFontHeight() + { + return getInt(OFFSET_FONT_HEIGHT); + } + + private void setFontOption(boolean option, BitField field) + { + int options = getInt(OFFSET_FONT_OPTIONS); + options = field.setBoolean(options, option); + setInt(OFFSET_FONT_OPTIONS, options); + } + + private boolean getFontOption(BitField field) + { + int options = getInt(OFFSET_FONT_OPTIONS); + return field.isSet(options); + } + + /** + * set the font to be italics or not + * + * @param italic - whether the font is italics or not + * @see #setFontOption(boolean, org.apache.poi.util.BitField) + */ + + public void setItalic(boolean italic) + { + setFontOption(italic, posture); + } + + /** + * get whether the font is to be italics or not + * + * @return italics - whether the font is italics or not + * @see #getFontOption(org.apache.poi.util.BitField) + */ + + public boolean isItalic() + { + return getFontOption(posture); + } + + public void setOutline(boolean on) + { + setFontOption(on, outline); + } + + public boolean isOutlineOn() + { + return getFontOption(outline); + } + + public void setShadow(boolean on) + { + setFontOption(on, shadow); + } + + public boolean isShadowOn() + { + return getFontOption(shadow); + } + + /** + * set the font to be stricken out or not + * + * @param strike - whether the font is stricken out or not + */ + public void setStrikeout(boolean strike) + { + setFontOption(strike, cancellation); + } + + /** + * get whether the font is to be stricken out or not + * + * @return strike - whether the font is stricken out or not + * @see #getFontOption(org.apache.poi.util.BitField) + */ + public boolean isStruckout() + { + return getFontOption(cancellation); + } + + /** + * set the font weight (100-1000dec or 0x64-0x3e8). Default is + * 0x190 for normal and 0x2bc for bold + * + * @param bw - a number between 100-1000 for the fonts "boldness" + */ + + private void setFontWeight(short pbw) + { + short bw = pbw; + if( bw<100) { bw=100; } + if( bw>1000){ bw=1000; } + setShort(OFFSET_FONT_WEIGHT, bw); + } + + /** + * set the font weight to bold (weight=700) or to normal(weight=400) boldness. + * + * @param bold - set font weight to bold if true; to normal otherwise + */ + public void setBold(boolean bold) + { + setFontWeight(bold?FONT_WEIGHT_BOLD:FONT_WEIGHT_NORMAL); + } + + /** + * get the font weight for this font (100-1000dec or 0x64-0x3e8). Default is + * 0x190 for normal and 0x2bc for bold + * + * @return bw - a number between 100-1000 for the fonts "boldness" + */ + + public short getFontWeight() + { + return getShort(OFFSET_FONT_WEIGHT); + } + + /** + * get whether the font weight is set to bold or not + * + * @return bold - whether the font is bold or not + */ + + public boolean isBold() + { + return getFontWeight()==FONT_WEIGHT_BOLD; + } + + /** + * get the type of super or subscript for the font + * + * @return super or subscript option + * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#SS_NONE + * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#SS_SUPER + * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#SS_SUB + */ + public short getEscapementType() + { + return getShort(OFFSET_ESCAPEMENT_TYPE); + } + + /** + * set the escapement type for the font + * + * @param escapementType super or subscript option + * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#SS_NONE + * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#SS_SUPER + * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#SS_SUB + */ + public void setEscapementType( short escapementType) + { + setShort(OFFSET_ESCAPEMENT_TYPE, escapementType); + } + + /** + * get the type of underlining for the font + * + * @return font underlining type + * + * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#U_NONE + * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#U_SINGLE + * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#U_DOUBLE + * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#U_SINGLE_ACCOUNTING + * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#U_DOUBLE_ACCOUNTING + */ + public short getUnderlineType() + { + return getShort(OFFSET_UNDERLINE_TYPE); + } + + /** + * set the type of underlining type for the font + * + * @param underlineType underline option + * + * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#U_NONE + * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#U_SINGLE + * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#U_DOUBLE + * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#U_SINGLE_ACCOUNTING + * @see org.apache.poi.hssf.usermodel.HSSFFontFormatting#U_DOUBLE_ACCOUNTING + */ + public void setUnderlineType( short underlineType) + { + setShort(OFFSET_UNDERLINE_TYPE, underlineType); + } + + + public short getFontColorIndex() + { + return (short)getInt(OFFSET_FONT_COLOR_INDEX); + } + + public void setFontColorIndex(short fci ) + { + setInt(OFFSET_FONT_COLOR_INDEX,fci); + } + + private boolean getOptionFlag(BitField field) { + int optionFlags = getInt(OFFSET_OPTION_FLAGS); + int value = field.getValue(optionFlags); + return value==0? true : false ; + } + + private void setOptionFlag(boolean modified, BitField field) + { + int value = modified? 0 : 1; + int optionFlags = getInt(OFFSET_OPTION_FLAGS); + optionFlags = field.setValue(optionFlags, value); + setInt(OFFSET_OPTION_FLAGS, optionFlags); + } + + + public boolean isFontStyleModified() + { + return getOptionFlag(styleModified); + } + + + public void setFontStyleModified(boolean modified) + { + setOptionFlag(modified, styleModified); + } + + public boolean isFontOutlineModified() + { + return getOptionFlag(outlineModified); + } + + public void setFontOutlineModified(boolean modified) + { + setOptionFlag(modified, outlineModified); + } + + public boolean isFontShadowModified() + { + return getOptionFlag(shadowModified); + } + + public void setFontShadowModified(boolean modified) + { + setOptionFlag(modified, shadowModified); + } + public void setFontCancellationModified(boolean modified) + { + setOptionFlag(modified, cancellationModified); + } + + public boolean isFontCancellationModified() + { + return getOptionFlag(cancellationModified); + } + + public void setEscapementTypeModified(boolean modified) + { + int value = modified? 0 : 1; + setInt(OFFSET_ESCAPEMENT_TYPE_MODIFIED, value); + } + public boolean isEscapementTypeModified() + { + int escapementModified = getInt(OFFSET_ESCAPEMENT_TYPE_MODIFIED); + return escapementModified == 0; + } + + public void setUnderlineTypeModified(boolean modified) + { + int value = modified? 0 : 1; + setInt(OFFSET_UNDERLINE_TYPE_MODIFIED, value); + } + + public boolean isUnderlineTypeModified() + { + int underlineModified = getInt(OFFSET_UNDERLINE_TYPE_MODIFIED); + return underlineModified == 0; + } + + public void setFontWieghtModified(boolean modified) + { + int value = modified? 0 : 1; + setInt(OFFSET_FONT_WEIGHT_MODIFIED, value); + } + + public boolean isFontWeightModified() + { + int fontStyleModified = getInt(OFFSET_FONT_WEIGHT_MODIFIED); + return fontStyleModified == 0; + } + + public String toString() + { + StringBuffer buffer = new StringBuffer(); + buffer.append(" [Font Formatting]\n"); + + buffer.append(" .font height = ").append(getFontHeight()).append(" twips\n"); + + if( isFontStyleModified() ) + { + buffer.append(" .font posture = ").append(isItalic()?"Italic":"Normal").append("\n"); + } + else + { + buffer.append(" .font posture = ]not modified]").append("\n"); + } + + if( isFontOutlineModified() ) + { + buffer.append(" .font outline = ").append(isOutlineOn()).append("\n"); + } + else + { + buffer.append(" .font outline is not modified\n"); + } + + if( isFontShadowModified() ) + { + buffer.append(" .font shadow = ").append(isShadowOn()).append("\n"); + } + else + { + buffer.append(" .font shadow is not modified\n"); + } + + if( isFontCancellationModified() ) + { + buffer.append(" .font strikeout = ").append(isStruckout()).append("\n"); + } + else + { + buffer.append(" .font strikeout is not modified\n"); + } + + if( isFontStyleModified() ) + { + buffer.append(" .font weight = "). + append(getFontWeight()). + append( + getFontWeight() == FONT_WEIGHT_NORMAL ? "(Normal)" + : getFontWeight() == FONT_WEIGHT_BOLD ? "(Bold)" + : "0x"+Integer.toHexString(getFontWeight())). + append("\n"); + } + else + { + buffer.append(" .font weight = ]not modified]").append("\n"); + } + + if( isEscapementTypeModified() ) + { + buffer.append(" .escapement type = ").append(getEscapementType()).append("\n"); + } + else + { + buffer.append(" .escapement type is not modified\n"); + } + + if( isUnderlineTypeModified() ) + { + buffer.append(" .underline type = ").append(getUnderlineType()).append("\n"); + } + else + { + buffer.append(" .underline type is not modified\n"); + } + buffer.append(" .color index = ").append("0x"+Integer.toHexString(getFontColorIndex()).toUpperCase()).append("\n"); + + buffer.append(" [/Font Formatting]\n"); + return buffer.toString(); + } + + public Object clone() + { + byte[] rawData = _rawData.clone(); + return new FontFormatting(rawData); + } } diff --git a/src/java/org/apache/poi/hssf/record/cf/IconMultiStateFormatting.java b/src/java/org/apache/poi/hssf/record/cf/IconMultiStateFormatting.java new file mode 100644 index 0000000000..f405c031e0 --- /dev/null +++ b/src/java/org/apache/poi/hssf/record/cf/IconMultiStateFormatting.java @@ -0,0 +1,139 @@ +/* ==================================================================== + 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.hssf.record.cf; + +import org.apache.poi.ss.usermodel.IconMultiStateFormatting.IconSet; +import org.apache.poi.util.BitField; +import org.apache.poi.util.BitFieldFactory; +import org.apache.poi.util.LittleEndianInput; +import org.apache.poi.util.LittleEndianOutput; +import org.apache.poi.util.POILogFactory; +import org.apache.poi.util.POILogger; + +/** + * Icon / Multi-State Conditional Formatting Rule Record. + */ +public final class IconMultiStateFormatting implements Cloneable { + private static POILogger log = POILogFactory.getLogger(IconMultiStateFormatting.class); + + private IconSet iconSet; + private byte options; + private Threshold[] thresholds; + + private static BitField iconOnly = BitFieldFactory.getInstance(0x01); + private static BitField reversed = BitFieldFactory.getInstance(0x04); + + public IconMultiStateFormatting() { + iconSet = IconSet.GYR_3_TRAFFIC_LIGHTS; + options = 0; + thresholds = new Threshold[iconSet.num]; + } + public IconMultiStateFormatting(LittleEndianInput in) { + in.readShort(); // Ignored + in.readByte(); // Reserved + int num = in.readByte(); + int set = in.readByte(); + iconSet = IconSet.byId(set); + if (iconSet.num != num) { + log.log(POILogger.WARN, "Inconsistent Icon Set defintion, found " + iconSet + " but defined as " + num + " entries"); + } + options = in.readByte(); + + thresholds = new Threshold[iconSet.num]; + for (int i=0; i<thresholds.length; i++) { + thresholds[i] = new Threshold(in); + } + } + + public IconSet getIconSet() { + return iconSet; + } + public void setIconSet(IconSet set) { + this.iconSet = set; + } + + public Threshold[] getThresholds() { + return thresholds; + } + public void setThresholds(Threshold[] thresholds) { + this.thresholds = thresholds; + } + + public boolean isIconOnly() { + return getOptionFlag(iconOnly); + } + public void setIconOnly(boolean only) { + setOptionFlag(only, iconOnly); + } + + public boolean isReversed() { + return getOptionFlag(reversed); + } + public void setReversed(boolean rev) { + setOptionFlag(rev, reversed); + } + + private boolean getOptionFlag(BitField field) { + int value = field.getValue(options); + return value==0 ? false : true; + } + private void setOptionFlag(boolean option, BitField field) { + options = field.setByteBoolean(options, option); + } + + public String toString() { + StringBuffer buffer = new StringBuffer(); + buffer.append(" [Icon Formatting]\n"); + buffer.append(" .icon_set = ").append(iconSet).append("\n"); + buffer.append(" .icon_only= ").append(isIconOnly()).append("\n"); + buffer.append(" .reversed = ").append(isReversed()).append("\n"); + for (Threshold t : thresholds) { + buffer.append(t.toString()); + } + buffer.append(" [/Icon Formatting]\n"); + return buffer.toString(); + } + + public Object clone() { + IconMultiStateFormatting rec = new IconMultiStateFormatting(); + rec.iconSet = iconSet; + rec.options = options; + rec.thresholds = new Threshold[thresholds.length]; + System.arraycopy(thresholds, 0, rec.thresholds, 0, thresholds.length); + return rec; + } + + public int getDataLength() { + int len = 6; + for (Threshold t : thresholds) { + len += t.getDataLength(); + } + return len; + } + + public void serialize(LittleEndianOutput out) { + out.writeShort(0); + out.writeByte(0); + out.writeByte(iconSet.num); + out.writeByte(iconSet.id); + out.writeByte(options); + for (Threshold t : thresholds) { + t.serialize(out); + } + } +} diff --git a/src/java/org/apache/poi/hssf/record/cf/PatternFormatting.java b/src/java/org/apache/poi/hssf/record/cf/PatternFormatting.java index 2587157f78..3e18eace9b 100644 --- a/src/java/org/apache/poi/hssf/record/cf/PatternFormatting.java +++ b/src/java/org/apache/poi/hssf/record/cf/PatternFormatting.java @@ -24,8 +24,6 @@ import org.apache.poi.util.LittleEndianOutput; /** * Pattern Formatting Block of the Conditional Formatting Rule Record. - * - * @author Dmitriy Kumshayev */ public final class PatternFormatting implements Cloneable { /** No background */ @@ -89,6 +87,10 @@ public final class PatternFormatting implements Cloneable { field_16_pattern_color_indexes = in.readUShort(); } + public int getDataLength() { + return 4; + } + /** * setting fill pattern * diff --git a/src/java/org/apache/poi/hssf/record/cf/Threshold.java b/src/java/org/apache/poi/hssf/record/cf/Threshold.java new file mode 100644 index 0000000000..462027807c --- /dev/null +++ b/src/java/org/apache/poi/hssf/record/cf/Threshold.java @@ -0,0 +1,146 @@ +/* ==================================================================== + 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.hssf.record.cf; + +import java.util.Arrays; + +import org.apache.poi.ss.formula.Formula; +import org.apache.poi.ss.formula.ptg.Ptg; +import org.apache.poi.ss.usermodel.ConditionalFormattingThreshold.RangeType; +import org.apache.poi.util.LittleEndianInput; +import org.apache.poi.util.LittleEndianOutput; + +/** + * Threshold / value for changes in Conditional Formatting + */ +public final class Threshold { + /** + * Cell values that are equal to the threshold value do not pass the threshold + */ + public static final byte EQUALS_EXCLUDE = 0; + /** + * Cell values that are equal to the threshold value pass the threshold. + */ + public static final byte EQUALS_INCLUDE = 1; + + private byte type; + private Formula formula; + private Double value; + private byte equals; + + public Threshold() { + type = (byte)RangeType.NUMBER.id; + formula = Formula.create(null); + value = 0d; + } + + /** Creates new Threshold */ + public Threshold(LittleEndianInput in) { + type = in.readByte(); + short formulaLen = in.readShort(); + if (formulaLen > 0) { + formula = Formula.read(formulaLen, in); + } else { + formula = Formula.create(null); + } + // Value is only there for non-formula, non min/max thresholds + if (formulaLen == 0 && type != RangeType.MIN.id && + type != RangeType.MAX.id) { + value = in.readDouble(); + } + equals = in.readByte(); + // Reserved, 4 bytes, all 0 + in.readInt(); + } + + public byte getType() { + return type; + } + public void setType(byte type) { + this.type = type; + } + public void setType(int type) { + this.type = (byte)type; + } + + protected Formula getFormula() { + return formula; + } + public Ptg[] getParsedExpression() { + return formula.getTokens(); + } + public void setParsedExpression(Ptg[] ptgs) { + formula = Formula.create(ptgs); + } + + public Double getValue() { + return value; + } + public void setValue(Double value) { + this.value = value; + } + + public byte getEquals() { + return equals; + } + public void setEquals(byte equals) { + this.equals = equals; + } + + public int getDataLength() { + int len = 1 + formula.getEncodedSize(); + if (value != null) { + len += 8; + } + len += 5; + return len; + } + + public String toString() { + StringBuffer buffer = new StringBuffer(); + buffer.append(" [CF Threshold]\n"); + buffer.append(" .type = ").append(Integer.toHexString(type)).append("\n"); + buffer.append(" .formula = ").append(Arrays.toString(formula.getTokens())).append("\n"); + buffer.append(" .value = ").append(value).append("\n"); + buffer.append(" [/CF Threshold]\n"); + return buffer.toString(); + } + + public Object clone() { + Threshold rec = new Threshold(); + rec.type = type; + rec.formula = formula; + rec.value = value; + rec.equals = equals; + return rec; + } + + public void serialize(LittleEndianOutput out) { + out.writeByte(type); + if (formula.getTokens().length == 0) { + out.writeShort(0); + } else { + formula.serialize(out); + } + if (value != null) { + out.writeDouble(value); + } + out.writeByte(equals); + out.writeInt(0); // Reserved + } +} diff --git a/src/java/org/apache/poi/hssf/record/common/FtrHeader.java b/src/java/org/apache/poi/hssf/record/common/FtrHeader.java index dc2d4e26e9..dba24f084a 100644 --- a/src/java/org/apache/poi/hssf/record/common/FtrHeader.java +++ b/src/java/org/apache/poi/hssf/record/common/FtrHeader.java @@ -18,6 +18,7 @@ package org.apache.poi.hssf.record.common; import org.apache.poi.hssf.record.RecordInputStream; +import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.util.LittleEndianOutput; /** @@ -28,62 +29,69 @@ import org.apache.poi.util.LittleEndianOutput; * beyond those of a traditional record. */ public final class FtrHeader { - /** This MUST match the type on the containing record */ - private short recordType; - /** This is a FrtFlags */ - private short grbitFrt; - /** MUST be 8 bytes and all zero */ - private byte[] reserved; + /** This MUST match the type on the containing record */ + private short recordType; + /** This is a FrtFlags */ + private short grbitFrt; + /** The range of cells the parent record applies to, or 0 if N/A */ + private CellRangeAddress associatedRange; - public FtrHeader() { - reserved = new byte[8]; - } + public FtrHeader() { + associatedRange = new CellRangeAddress(0, 0, 0, 0); + } - public FtrHeader(RecordInputStream in) { - recordType = in.readShort(); - grbitFrt = in.readShort(); - - reserved = new byte[8]; - in.read(reserved, 0, 8); - } + public FtrHeader(RecordInputStream in) { + recordType = in.readShort(); + grbitFrt = in.readShort(); - public String toString() { - StringBuffer buffer = new StringBuffer(); - buffer.append(" [FUTURE HEADER]\n"); - buffer.append(" Type " + recordType); - buffer.append(" Flags " + grbitFrt); - buffer.append(" [/FUTURE HEADER]\n"); - return buffer.toString(); - } + associatedRange = new CellRangeAddress(in); + } - public void serialize(LittleEndianOutput out) { - out.writeShort(recordType); - out.writeShort(grbitFrt); - out.write(reserved); - } + public String toString() { + StringBuffer buffer = new StringBuffer(); + buffer.append(" [FUTURE HEADER]\n"); + buffer.append(" Type " + recordType); + buffer.append(" Flags " + grbitFrt); + buffer.append(" [/FUTURE HEADER]\n"); + return buffer.toString(); + } - public static int getDataSize() { - return 12; - } + public void serialize(LittleEndianOutput out) { + out.writeShort(recordType); + out.writeShort(grbitFrt); + associatedRange.serialize(out); + } - public short getRecordType() { - return recordType; - } - public void setRecordType(short recordType) { - this.recordType = recordType; - } + public static int getDataSize() { + return 12; + } - public short getGrbitFrt() { - return grbitFrt; - } - public void setGrbitFrt(short grbitFrt) { - this.grbitFrt = grbitFrt; - } + public short getRecordType() { + return recordType; + } + public void setRecordType(short recordType) { + this.recordType = recordType; + } - public byte[] getReserved() { - return reserved; - } - public void setReserved(byte[] reserved) { - this.reserved = reserved; - } + public short getGrbitFrt() { + return grbitFrt; + } + public void setGrbitFrt(short grbitFrt) { + this.grbitFrt = grbitFrt; + } + + public CellRangeAddress getAssociatedRange() { + return associatedRange; + } + public void setAssociatedRange(CellRangeAddress associatedRange) { + this.associatedRange = associatedRange; + } + + public Object clone() { + FtrHeader result = new FtrHeader(); + result.recordType = recordType; + result.grbitFrt = grbitFrt; + result.associatedRange = associatedRange.copy(); + return result; + } }
\ No newline at end of file diff --git a/src/java/org/apache/poi/hssf/record/common/FutureRecord.java b/src/java/org/apache/poi/hssf/record/common/FutureRecord.java new file mode 100644 index 0000000000..65a26cca73 --- /dev/null +++ b/src/java/org/apache/poi/hssf/record/common/FutureRecord.java @@ -0,0 +1,30 @@ +/* ==================================================================== + 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.hssf.record.common; + +import org.apache.poi.ss.util.CellRangeAddress; + +/** + * Title: Future Record, a newer (largely Excel 2007+) record + * which contains a Future Record Header ({@link FtrHeader}) + */ +public interface FutureRecord { + public short getFutureRecordType(); + public FtrHeader getFutureHeader(); + public CellRangeAddress getAssociatedRange(); +}
\ No newline at end of file diff --git a/src/java/org/apache/poi/hssf/record/crypto/Biff8DecryptingStream.java b/src/java/org/apache/poi/hssf/record/crypto/Biff8DecryptingStream.java index f52a15d814..564174b609 100644 --- a/src/java/org/apache/poi/hssf/record/crypto/Biff8DecryptingStream.java +++ b/src/java/org/apache/poi/hssf/record/crypto/Biff8DecryptingStream.java @@ -95,7 +95,7 @@ public final class Biff8DecryptingStream implements BiffHeaderInput, LittleEndia public int readUByte() { - return _cipher.xorByte(_le.readUByte()); + return readByte() & 0xFF; } public byte readByte() { return (byte) _cipher.xorByte(_le.readUByte()); @@ -103,7 +103,7 @@ public final class Biff8DecryptingStream implements BiffHeaderInput, LittleEndia public int readUShort() { - return _cipher.xorShort(_le.readUShort()); + return readShort() & 0xFFFF; } public short readShort() { return (short) _cipher.xorShort(_le.readUShort()); diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFBorderFormatting.java b/src/java/org/apache/poi/hssf/usermodel/HSSFBorderFormatting.java index 0e2cb9d208..c5c9964563 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFBorderFormatting.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFBorderFormatting.java @@ -17,196 +17,246 @@ package org.apache.poi.hssf.usermodel; -import org.apache.poi.hssf.record.CFRuleRecord; +import org.apache.poi.hssf.record.CFRuleBase; import org.apache.poi.hssf.record.cf.BorderFormatting; +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.ss.usermodel.Color; /** * High level representation for Border Formatting component * of Conditional Formatting settings */ -public final class HSSFBorderFormatting implements org.apache.poi.ss.usermodel.BorderFormatting -{ - private final CFRuleRecord cfRuleRecord; - private final BorderFormatting borderFormatting; - - protected HSSFBorderFormatting(CFRuleRecord cfRuleRecord) - { - this.cfRuleRecord = cfRuleRecord; - this.borderFormatting = cfRuleRecord.getBorderFormatting(); - } - - protected BorderFormatting getBorderFormattingBlock() - { - return borderFormatting; - } - - public short getBorderBottom() - { - return (short)borderFormatting.getBorderBottom(); - } - - public short getBorderDiagonal() - { - return (short)borderFormatting.getBorderDiagonal(); - } - - public short getBorderLeft() - { - return (short)borderFormatting.getBorderLeft(); - } - - public short getBorderRight() - { - return (short)borderFormatting.getBorderRight(); - } - - public short getBorderTop() - { - return (short)borderFormatting.getBorderTop(); - } - - public short getBottomBorderColor() - { - return (short)borderFormatting.getBottomBorderColor(); - } - - public short getDiagonalBorderColor() - { - return (short)borderFormatting.getDiagonalBorderColor(); - } - - public short getLeftBorderColor() - { - return (short)borderFormatting.getLeftBorderColor(); - } - - public short getRightBorderColor() - { - return (short)borderFormatting.getRightBorderColor(); - } - - public short getTopBorderColor() - { - return (short)borderFormatting.getTopBorderColor(); - } - - public boolean isBackwardDiagonalOn() - { - return borderFormatting.isBackwardDiagonalOn(); - } - - public boolean isForwardDiagonalOn() - { - return borderFormatting.isForwardDiagonalOn(); - } - - public void setBackwardDiagonalOn(boolean on) - { - borderFormatting.setBackwardDiagonalOn(on); - if( on ) - { - cfRuleRecord.setTopLeftBottomRightBorderModified(on); - } - } - - public void setBorderBottom(short border) - { - borderFormatting.setBorderBottom(border); - if( border != 0) - { - cfRuleRecord.setBottomBorderModified(true); - } - } - - public void setBorderDiagonal(short border) - { - borderFormatting.setBorderDiagonal(border); - if( border != 0) - { - cfRuleRecord.setBottomLeftTopRightBorderModified(true); - cfRuleRecord.setTopLeftBottomRightBorderModified(true); - } - } - - public void setBorderLeft(short border) - { - borderFormatting.setBorderLeft(border); - if( border != 0) - { - cfRuleRecord.setLeftBorderModified(true); - } - } - - public void setBorderRight(short border) - { - borderFormatting.setBorderRight(border); - if( border != 0) - { - cfRuleRecord.setRightBorderModified(true); - } - } - - public void setBorderTop(short border) - { - borderFormatting.setBorderTop(border); - if( border != 0) - { - cfRuleRecord.setTopBorderModified(true); - } - } - - public void setBottomBorderColor(short color) - { - borderFormatting.setBottomBorderColor(color); - if( color != 0) - { - cfRuleRecord.setBottomBorderModified(true); - } - } - - public void setDiagonalBorderColor(short color) - { - borderFormatting.setDiagonalBorderColor(color); - if( color != 0) - { - cfRuleRecord.setBottomLeftTopRightBorderModified(true); - cfRuleRecord.setTopLeftBottomRightBorderModified(true); - } - } - - public void setForwardDiagonalOn(boolean on) - { - borderFormatting.setForwardDiagonalOn(on); - if( on ) - { - cfRuleRecord.setBottomLeftTopRightBorderModified(on); - } - } - - public void setLeftBorderColor(short color) - { - borderFormatting.setLeftBorderColor(color); - if( color != 0) - { - cfRuleRecord.setLeftBorderModified(true); - } - } - - public void setRightBorderColor(short color) - { - borderFormatting.setRightBorderColor(color); - if( color != 0) - { - cfRuleRecord.setRightBorderModified(true); - } - } - - public void setTopBorderColor(short color) - { - borderFormatting.setTopBorderColor(color); - if( color != 0) - { - cfRuleRecord.setTopBorderModified(true); - } - } +public final class HSSFBorderFormatting implements org.apache.poi.ss.usermodel.BorderFormatting { + private final HSSFWorkbook workbook; + private final CFRuleBase cfRuleRecord; + private final BorderFormatting borderFormatting; + + protected HSSFBorderFormatting(CFRuleBase cfRuleRecord, HSSFWorkbook workbook) { + this.workbook = workbook; + this.cfRuleRecord = cfRuleRecord; + this.borderFormatting = cfRuleRecord.getBorderFormatting(); + } + + protected BorderFormatting getBorderFormattingBlock() { + return borderFormatting; + } + + public short getBorderBottom() { + return (short)borderFormatting.getBorderBottom(); + } + + public short getBorderDiagonal() { + return (short)borderFormatting.getBorderDiagonal(); + } + + public short getBorderLeft() { + return (short)borderFormatting.getBorderLeft(); + } + + public short getBorderRight() { + return (short)borderFormatting.getBorderRight(); + } + + public short getBorderTop() { + return (short)borderFormatting.getBorderTop(); + } + + public short getBottomBorderColor() { + return (short)borderFormatting.getBottomBorderColor(); + } + public HSSFColor getBottomBorderColorColor() { + return workbook.getCustomPalette().getColor( + borderFormatting.getBottomBorderColor() + ); + } + + public short getDiagonalBorderColor() { + return (short)borderFormatting.getDiagonalBorderColor(); + } + public HSSFColor getDiagonalBorderColorColor() { + return workbook.getCustomPalette().getColor( + borderFormatting.getDiagonalBorderColor() + ); + } + + public short getLeftBorderColor() { + return (short)borderFormatting.getLeftBorderColor(); + } + public HSSFColor getLeftBorderColorColor() { + return workbook.getCustomPalette().getColor( + borderFormatting.getLeftBorderColor() + ); + } + + public short getRightBorderColor() { + return (short)borderFormatting.getRightBorderColor(); + } + public HSSFColor getRightBorderColorColor() { + return workbook.getCustomPalette().getColor( + borderFormatting.getRightBorderColor() + ); + } + + public short getTopBorderColor() { + return (short)borderFormatting.getTopBorderColor(); + } + public HSSFColor getTopBorderColorColor() { + return workbook.getCustomPalette().getColor( + borderFormatting.getTopBorderColor() + ); + } + + public boolean isBackwardDiagonalOn() { + return borderFormatting.isBackwardDiagonalOn(); + } + public boolean isForwardDiagonalOn() { + return borderFormatting.isForwardDiagonalOn(); + } + + public void setBackwardDiagonalOn(boolean on) { + borderFormatting.setBackwardDiagonalOn(on); + if (on) { + cfRuleRecord.setTopLeftBottomRightBorderModified(on); + } + } + public void setForwardDiagonalOn(boolean on) { + borderFormatting.setForwardDiagonalOn(on); + if (on) { + cfRuleRecord.setBottomLeftTopRightBorderModified(on); + } + } + + public void setBorderBottom(short border) { + borderFormatting.setBorderBottom(border); + if (border != 0) { + cfRuleRecord.setBottomBorderModified(true); + } else { + cfRuleRecord.setBottomBorderModified(false); + } + } + + public void setBorderDiagonal(short border) { + borderFormatting.setBorderDiagonal(border); + if (border != 0) { + cfRuleRecord.setBottomLeftTopRightBorderModified(true); + cfRuleRecord.setTopLeftBottomRightBorderModified(true); + } else { + cfRuleRecord.setBottomLeftTopRightBorderModified(false); + cfRuleRecord.setTopLeftBottomRightBorderModified(false); + } + } + + public void setBorderLeft(short border) { + borderFormatting.setBorderLeft(border); + if (border != 0) { + cfRuleRecord.setLeftBorderModified(true); + } else { + cfRuleRecord.setLeftBorderModified(false); + } + } + + public void setBorderRight(short border) { + borderFormatting.setBorderRight(border); + if (border != 0) { + cfRuleRecord.setRightBorderModified(true); + } else { + cfRuleRecord.setRightBorderModified(false); + } + } + + public void setBorderTop(short border) { + borderFormatting.setBorderTop(border); + if (border != 0) { + cfRuleRecord.setTopBorderModified(true); + } else { + cfRuleRecord.setTopBorderModified(false); + } + } + + public void setBottomBorderColor(short color) { + borderFormatting.setBottomBorderColor(color); + if (color != 0) { + cfRuleRecord.setBottomBorderModified(true); + } else { + cfRuleRecord.setBottomBorderModified(false); + } + } + public void setBottomBorderColor(Color color) { + HSSFColor hcolor = HSSFColor.toHSSFColor(color); + if (hcolor == null) { + setBottomBorderColor((short)0); + } else { + setBottomBorderColor(hcolor.getIndex()); + } + } + + public void setDiagonalBorderColor(short color) { + borderFormatting.setDiagonalBorderColor(color); + if (color != 0) { + cfRuleRecord.setBottomLeftTopRightBorderModified(true); + cfRuleRecord.setTopLeftBottomRightBorderModified(true); + } else { + cfRuleRecord.setBottomLeftTopRightBorderModified(false); + cfRuleRecord.setTopLeftBottomRightBorderModified(false); + } + } + public void setDiagonalBorderColor(Color color) { + HSSFColor hcolor = HSSFColor.toHSSFColor(color); + if (hcolor == null) { + setDiagonalBorderColor((short)0); + } else { + setDiagonalBorderColor(hcolor.getIndex()); + } + } + + public void setLeftBorderColor(short color) { + borderFormatting.setLeftBorderColor(color); + if (color != 0) { + cfRuleRecord.setLeftBorderModified(true); + } else { + cfRuleRecord.setLeftBorderModified(false); + } + } + public void setLeftBorderColor(Color color) { + HSSFColor hcolor = HSSFColor.toHSSFColor(color); + if (hcolor == null) { + setLeftBorderColor((short)0); + } else { + setLeftBorderColor(hcolor.getIndex()); + } + } + + public void setRightBorderColor(short color) { + borderFormatting.setRightBorderColor(color); + if (color != 0) { + cfRuleRecord.setRightBorderModified(true); + } else { + cfRuleRecord.setRightBorderModified(false); + } + } + public void setRightBorderColor(Color color) { + HSSFColor hcolor = HSSFColor.toHSSFColor(color); + if (hcolor == null) { + setRightBorderColor((short)0); + } else { + setRightBorderColor(hcolor.getIndex()); + } + } + + public void setTopBorderColor(short color) { + borderFormatting.setTopBorderColor(color); + if (color != 0) { + cfRuleRecord.setTopBorderModified(true); + } else { + cfRuleRecord.setTopBorderModified(false); + } + } + public void setTopBorderColor(Color color) { + HSSFColor hcolor = HSSFColor.toHSSFColor(color); + if (hcolor == null) { + setTopBorderColor((short)0); + } else { + setTopBorderColor(hcolor.getIndex()); + } + } } diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java index e5de299a04..b1e8b7a008 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java @@ -538,18 +538,17 @@ public class HSSFCell implements Cell { public void setCellValue(RichTextString value) { - HSSFRichTextString hvalue = (HSSFRichTextString) value; int row=_record.getRow(); short col=_record.getColumn(); short styleIndex=_record.getXFIndex(); - if (hvalue == null) + if (value == null) { notifyFormulaChanging(); setCellType(CELL_TYPE_BLANK, false, row, col, styleIndex); return; } - if(hvalue.length() > SpreadsheetVersion.EXCEL97.getMaxTextLength()){ + if(value.length() > SpreadsheetVersion.EXCEL97.getMaxTextLength()){ throw new IllegalArgumentException("The maximum length of cell contents (text) is 32,767 characters"); } @@ -557,7 +556,7 @@ public class HSSFCell implements Cell { // Set the 'pre-evaluated result' for the formula // note - formulas do not preserve text formatting. FormulaRecordAggregate fr = (FormulaRecordAggregate) _record; - fr.setCachedStringResult(hvalue.getString()); + fr.setCachedStringResult(value.getString()); // Update our local cache to the un-formatted version _stringValue = new HSSFRichTextString(value.getString()); @@ -573,6 +572,7 @@ public class HSSFCell implements Cell { } int index = 0; + HSSFRichTextString hvalue = (HSSFRichTextString) value; UnicodeString str = hvalue.getUnicodeString(); index = _book.getWorkbook().addSSTString(str); (( LabelSSTRecord ) _record).setSSTIndex(index); diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFComment.java b/src/java/org/apache/poi/hssf/usermodel/HSSFComment.java index 81de3a41d0..4e71ac2b83 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFComment.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFComment.java @@ -129,10 +129,13 @@ public class HSSFComment extends HSSFTextbox implements Comment { @Override void setShapeId(int shapeId) { + if(shapeId > 65535) { + throw new IllegalArgumentException("Cannot add more than " + 65535 + " shapes"); + } super.setShapeId(shapeId); CommonObjectDataSubRecord cod = (CommonObjectDataSubRecord) getObjRecord().getSubRecords().get(0); - cod.setObjectId((short) (shapeId % 1024)); - _note.setShapeId(shapeId % 1024); + cod.setObjectId(shapeId); + _note.setShapeId(shapeId); } /** diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormatting.java b/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormatting.java index b0f1474bf1..e5792770c0 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormatting.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormatting.java @@ -16,7 +16,7 @@ ==================================================================== */ package org.apache.poi.hssf.usermodel; -import org.apache.poi.hssf.record.CFRuleRecord; +import org.apache.poi.hssf.record.CFRuleBase; import org.apache.poi.hssf.record.aggregates.CFRecordsAggregate; import org.apache.poi.ss.usermodel.ConditionalFormatting; import org.apache.poi.ss.usermodel.ConditionalFormattingRule; @@ -73,91 +73,84 @@ import org.apache.poi.ss.util.CellRangeAddress; * sheet.addConditionalFormatting(regions, rule); * </PRE> */ -public final class HSSFConditionalFormatting implements ConditionalFormatting -{ - private final HSSFWorkbook _workbook; - private final CFRecordsAggregate cfAggregate; +public final class HSSFConditionalFormatting implements ConditionalFormatting { + private final HSSFSheet sheet; + private final CFRecordsAggregate cfAggregate; - HSSFConditionalFormatting(HSSFWorkbook workbook, CFRecordsAggregate cfAggregate) - { - if(workbook == null) { - throw new IllegalArgumentException("workbook must not be null"); - } - if(cfAggregate == null) { - throw new IllegalArgumentException("cfAggregate must not be null"); - } - _workbook = workbook; - this.cfAggregate = cfAggregate; - } - CFRecordsAggregate getCFRecordsAggregate() { - return cfAggregate; - } + HSSFConditionalFormatting(HSSFSheet sheet, CFRecordsAggregate cfAggregate) { + if(sheet == null) { + throw new IllegalArgumentException("sheet must not be null"); + } + if(cfAggregate == null) { + throw new IllegalArgumentException("cfAggregate must not be null"); + } + this.sheet = sheet; + this.cfAggregate = cfAggregate; + } + CFRecordsAggregate getCFRecordsAggregate() { + return cfAggregate; + } - /** - * @deprecated (Aug-2008) use {@link HSSFConditionalFormatting#getFormattingRanges()} - */ - public org.apache.poi.ss.util.Region[] getFormattingRegions() - { - CellRangeAddress[] cellRanges = getFormattingRanges(); - return org.apache.poi.ss.util.Region.convertCellRangesToRegions(cellRanges); - } - /** - * @return array of <tt>CellRangeAddress</tt>s. never <code>null</code> - */ - public CellRangeAddress[] getFormattingRanges() { - return cfAggregate.getHeader().getCellRanges(); - } + /** + * @deprecated (Aug-2008) use {@link HSSFConditionalFormatting#getFormattingRanges()} + */ + public org.apache.poi.ss.util.Region[] getFormattingRegions() { + CellRangeAddress[] cellRanges = getFormattingRanges(); + return org.apache.poi.ss.util.Region.convertCellRangesToRegions(cellRanges); + } + /** + * @return array of <tt>CellRangeAddress</tt>s. never <code>null</code> + */ + public CellRangeAddress[] getFormattingRanges() { + return cfAggregate.getHeader().getCellRanges(); + } - /** - * Replaces an existing Conditional Formatting rule at position idx. - * Excel allows to create up to 3 Conditional Formatting rules. - * This method can be useful to modify existing Conditional Formatting rules. - * - * @param idx position of the rule. Should be between 0 and 2. - * @param cfRule - Conditional Formatting rule - */ - public void setRule(int idx, HSSFConditionalFormattingRule cfRule) - { - cfAggregate.setRule(idx, cfRule.getCfRuleRecord()); - } + /** + * Replaces an existing Conditional Formatting rule at position idx. + * Older versions of Excel only allow up to 3 Conditional Formatting rules, + * and will ignore rules beyond that, while newer versions are fine. + * This method can be useful to modify existing Conditional Formatting rules. + * + * @param idx position of the rule. Should be between 0 and 2 for older Excel versions + * @param cfRule - Conditional Formatting rule + */ + public void setRule(int idx, HSSFConditionalFormattingRule cfRule) { + cfAggregate.setRule(idx, cfRule.getCfRuleRecord()); + } public void setRule(int idx, ConditionalFormattingRule cfRule){ setRule(idx, (HSSFConditionalFormattingRule)cfRule); } - /** - * add a Conditional Formatting rule. - * Excel allows to create up to 3 Conditional Formatting rules. - * @param cfRule - Conditional Formatting rule - */ - public void addRule(HSSFConditionalFormattingRule cfRule) - { - cfAggregate.addRule(cfRule.getCfRuleRecord()); - } + /** + * add a Conditional Formatting rule. + * Excel allows to create up to 3 Conditional Formatting rules. + * @param cfRule - Conditional Formatting rule + */ + public void addRule(HSSFConditionalFormattingRule cfRule) { + cfAggregate.addRule(cfRule.getCfRuleRecord()); + } public void addRule(ConditionalFormattingRule cfRule){ addRule((HSSFConditionalFormattingRule)cfRule); } - /** - * @return the Conditional Formatting rule at position idx. - */ - public HSSFConditionalFormattingRule getRule(int idx) - { - CFRuleRecord ruleRecord = cfAggregate.getRule(idx); - return new HSSFConditionalFormattingRule(_workbook, ruleRecord); - } + /** + * @return the Conditional Formatting rule at position idx. + */ + public HSSFConditionalFormattingRule getRule(int idx) { + CFRuleBase ruleRecord = cfAggregate.getRule(idx); + return new HSSFConditionalFormattingRule(sheet, ruleRecord); + } - /** - * @return number of Conditional Formatting rules. - */ - public int getNumberOfRules() - { - return cfAggregate.getNumberOfRules(); - } + /** + * @return number of Conditional Formatting rules. + */ + public int getNumberOfRules() { + return cfAggregate.getNumberOfRules(); + } - public String toString() - { - return cfAggregate.toString(); - } + public String toString() { + return cfAggregate.toString(); + } } diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingRule.java b/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingRule.java index 6d881132fb..a999488d38 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingRule.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingRule.java @@ -18,12 +18,16 @@ package org.apache.poi.hssf.usermodel; import org.apache.poi.hssf.model.HSSFFormulaParser; +import org.apache.poi.hssf.record.CFRule12Record; +import org.apache.poi.hssf.record.CFRuleBase; +import org.apache.poi.hssf.record.CFRuleBase.ComparisonOperator; import org.apache.poi.hssf.record.CFRuleRecord; -import org.apache.poi.hssf.record.CFRuleRecord.ComparisonOperator; import org.apache.poi.hssf.record.cf.BorderFormatting; import org.apache.poi.hssf.record.cf.FontFormatting; +import org.apache.poi.hssf.record.cf.IconMultiStateFormatting; import org.apache.poi.hssf.record.cf.PatternFormatting; import org.apache.poi.ss.formula.ptg.Ptg; +import org.apache.poi.ss.usermodel.ConditionType; import org.apache.poi.ss.usermodel.ConditionalFormattingRule; /** @@ -32,178 +36,224 @@ import org.apache.poi.ss.usermodel.ConditionalFormattingRule; * It allows to specify formula based conditions for the Conditional Formatting * and the formatting settings such as font, border and pattern. */ -public final class HSSFConditionalFormattingRule implements ConditionalFormattingRule -{ - private static final byte CELL_COMPARISON = CFRuleRecord.CONDITION_TYPE_CELL_VALUE_IS; - - private final CFRuleRecord cfRuleRecord; - private final HSSFWorkbook workbook; - - HSSFConditionalFormattingRule(HSSFWorkbook pWorkbook, CFRuleRecord pRuleRecord) { - if (pWorkbook == null) { - throw new IllegalArgumentException("pWorkbook must not be null"); - } - if (pRuleRecord == null) { - throw new IllegalArgumentException("pRuleRecord must not be null"); - } - workbook = pWorkbook; - cfRuleRecord = pRuleRecord; - } - - CFRuleRecord getCfRuleRecord() - { - return cfRuleRecord; - } - - private HSSFFontFormatting getFontFormatting(boolean create) - { - FontFormatting fontFormatting = cfRuleRecord.getFontFormatting(); - if ( fontFormatting != null) - { - cfRuleRecord.setFontFormatting(fontFormatting); - return new HSSFFontFormatting(cfRuleRecord); - } - else if( create ) - { - fontFormatting = new FontFormatting(); - cfRuleRecord.setFontFormatting(fontFormatting); - return new HSSFFontFormatting(cfRuleRecord); - } - else - { - return null; - } - } - - /** - * @return - font formatting object if defined, <code>null</code> otherwise - */ - public HSSFFontFormatting getFontFormatting() - { - return getFontFormatting(false); - } - /** - * create a new font formatting structure if it does not exist, - * otherwise just return existing object. - * @return - font formatting object, never returns <code>null</code>. - */ - public HSSFFontFormatting createFontFormatting() - { - return getFontFormatting(true); - } - - private HSSFBorderFormatting getBorderFormatting(boolean create) - { - BorderFormatting borderFormatting = cfRuleRecord.getBorderFormatting(); - if ( borderFormatting != null) - { - cfRuleRecord.setBorderFormatting(borderFormatting); - return new HSSFBorderFormatting(cfRuleRecord); - } - else if( create ) - { - borderFormatting = new BorderFormatting(); - cfRuleRecord.setBorderFormatting(borderFormatting); - return new HSSFBorderFormatting(cfRuleRecord); - } - else - { - return null; - } - } - /** - * @return - border formatting object if defined, <code>null</code> otherwise - */ - public HSSFBorderFormatting getBorderFormatting() - { - return getBorderFormatting(false); - } - /** - * create a new border formatting structure if it does not exist, - * otherwise just return existing object. - * @return - border formatting object, never returns <code>null</code>. - */ - public HSSFBorderFormatting createBorderFormatting() - { - return getBorderFormatting(true); - } - - private HSSFPatternFormatting getPatternFormatting(boolean create) - { - PatternFormatting patternFormatting = cfRuleRecord.getPatternFormatting(); - if ( patternFormatting != null) - { - cfRuleRecord.setPatternFormatting(patternFormatting); - return new HSSFPatternFormatting(cfRuleRecord); - } - else if( create ) - { - patternFormatting = new PatternFormatting(); - cfRuleRecord.setPatternFormatting(patternFormatting); - return new HSSFPatternFormatting(cfRuleRecord); - } - else - { - return null; - } - } - - /** - * @return - pattern formatting object if defined, <code>null</code> otherwise - */ - public HSSFPatternFormatting getPatternFormatting() - { - return getPatternFormatting(false); - } - /** - * create a new pattern formatting structure if it does not exist, - * otherwise just return existing object. - * @return - pattern formatting object, never returns <code>null</code>. - */ - public HSSFPatternFormatting createPatternFormatting() - { - return getPatternFormatting(true); - } - - /** - * @return - the conditiontype for the cfrule - */ - public byte getConditionType() { - return cfRuleRecord.getConditionType(); - } - - /** - * @return - the comparisionoperatation for the cfrule - */ - public byte getComparisonOperation() { - return cfRuleRecord.getComparisonOperation(); - } - - public String getFormula1() - { - return toFormulaString(cfRuleRecord.getParsedExpression1()); - } - - public String getFormula2() - { - byte conditionType = cfRuleRecord.getConditionType(); - if (conditionType == CELL_COMPARISON) { - byte comparisonOperation = cfRuleRecord.getComparisonOperation(); - switch(comparisonOperation) - { - case ComparisonOperator.BETWEEN: - case ComparisonOperator.NOT_BETWEEN: - return toFormulaString(cfRuleRecord.getParsedExpression2()); - } - } - return null; - } - - private String toFormulaString(Ptg[] parsedExpression) - { - if(parsedExpression ==null) { - return null; - } - return HSSFFormulaParser.toFormulaString(workbook, parsedExpression); - } +public final class HSSFConditionalFormattingRule implements ConditionalFormattingRule { + private static final byte CELL_COMPARISON = CFRuleRecord.CONDITION_TYPE_CELL_VALUE_IS; + + private final CFRuleBase cfRuleRecord; + private final HSSFWorkbook workbook; + private final HSSFSheet sheet; + + HSSFConditionalFormattingRule(HSSFSheet pSheet, CFRuleBase pRuleRecord) { + if (pSheet == null) { + throw new IllegalArgumentException("pSheet must not be null"); + } + if (pRuleRecord == null) { + throw new IllegalArgumentException("pRuleRecord must not be null"); + } + sheet = pSheet; + workbook = pSheet.getWorkbook(); + cfRuleRecord = pRuleRecord; + } + + CFRuleBase getCfRuleRecord() + { + return cfRuleRecord; + } + + private HSSFFontFormatting getFontFormatting(boolean create) + { + FontFormatting fontFormatting = cfRuleRecord.getFontFormatting(); + if ( fontFormatting != null) + { + cfRuleRecord.setFontFormatting(fontFormatting); + return new HSSFFontFormatting(cfRuleRecord, workbook); + } + else if( create ) + { + fontFormatting = new FontFormatting(); + cfRuleRecord.setFontFormatting(fontFormatting); + return new HSSFFontFormatting(cfRuleRecord, workbook); + } + else + { + return null; + } + } + + /** + * @return - font formatting object if defined, <code>null</code> otherwise + */ + public HSSFFontFormatting getFontFormatting() + { + return getFontFormatting(false); + } + /** + * create a new font formatting structure if it does not exist, + * otherwise just return existing object. + * @return - font formatting object, never returns <code>null</code>. + */ + public HSSFFontFormatting createFontFormatting() + { + return getFontFormatting(true); + } + + private HSSFBorderFormatting getBorderFormatting(boolean create) + { + BorderFormatting borderFormatting = cfRuleRecord.getBorderFormatting(); + if ( borderFormatting != null) + { + cfRuleRecord.setBorderFormatting(borderFormatting); + return new HSSFBorderFormatting(cfRuleRecord, workbook); + } + else if( create ) + { + borderFormatting = new BorderFormatting(); + cfRuleRecord.setBorderFormatting(borderFormatting); + return new HSSFBorderFormatting(cfRuleRecord, workbook); + } + else + { + return null; + } + } + /** + * @return - border formatting object if defined, <code>null</code> otherwise + */ + public HSSFBorderFormatting getBorderFormatting() + { + return getBorderFormatting(false); + } + /** + * create a new border formatting structure if it does not exist, + * otherwise just return existing object. + * @return - border formatting object, never returns <code>null</code>. + */ + public HSSFBorderFormatting createBorderFormatting() + { + return getBorderFormatting(true); + } + + private HSSFPatternFormatting getPatternFormatting(boolean create) + { + PatternFormatting patternFormatting = cfRuleRecord.getPatternFormatting(); + if ( patternFormatting != null) + { + cfRuleRecord.setPatternFormatting(patternFormatting); + return new HSSFPatternFormatting(cfRuleRecord, workbook); + } + else if( create ) + { + patternFormatting = new PatternFormatting(); + cfRuleRecord.setPatternFormatting(patternFormatting); + return new HSSFPatternFormatting(cfRuleRecord, workbook); + } + else + { + return null; + } + } + + /** + * @return - pattern formatting object if defined, <code>null</code> otherwise + */ + public HSSFPatternFormatting getPatternFormatting() + { + return getPatternFormatting(false); + } + /** + * create a new pattern formatting structure if it does not exist, + * otherwise just return existing object. + * @return - pattern formatting object, never returns <code>null</code>. + */ + public HSSFPatternFormatting createPatternFormatting() + { + return getPatternFormatting(true); + } + + private HSSFIconMultiStateFormatting getMultiStateFormatting(boolean create) { + if (cfRuleRecord instanceof CFRule12Record) { + // Good + } else { + if (create) throw new IllegalArgumentException("Can't convert a CF into a CF12 record"); + return null; + } + CFRule12Record cfRule12Record = (CFRule12Record)cfRuleRecord; + IconMultiStateFormatting iconFormatting = cfRule12Record.getMultiStateFormatting(); + if (iconFormatting != null) + { + return new HSSFIconMultiStateFormatting(cfRule12Record, sheet); + } + else if( create ) + { + iconFormatting = cfRule12Record.createMultiStateFormatting(); + return new HSSFIconMultiStateFormatting(cfRule12Record, sheet); + } + else + { + return null; + } + } + + /** + * @return icon / multi-state formatting object if defined, <code>null</code> otherwise + */ + public HSSFIconMultiStateFormatting getMultiStateFormatting() { + return getMultiStateFormatting(false); + } + + /** + * create a new icon / multi-state formatting object if it does not exist, + * otherwise just return the existing object. + */ + public HSSFIconMultiStateFormatting createMultiStateFormatting() { + return getMultiStateFormatting(true); + } + + /** + * @return - the conditiontype for the cfrule + */ + public byte getConditionType() { + return cfRuleRecord.getConditionType(); + } + /** + * @return - the conditiontype for the cfrule + */ + public ConditionType getConditionTypeType() { + return ConditionType.forId(getConditionType()); + } + + /** + * @return - the comparisionoperatation for the cfrule + */ + public byte getComparisonOperation() { + return cfRuleRecord.getComparisonOperation(); + } + + public String getFormula1() + { + return toFormulaString(cfRuleRecord.getParsedExpression1()); + } + + public String getFormula2() { + byte conditionType = cfRuleRecord.getConditionType(); + if (conditionType == CELL_COMPARISON) { + byte comparisonOperation = cfRuleRecord.getComparisonOperation(); + switch(comparisonOperation) { + case ComparisonOperator.BETWEEN: + case ComparisonOperator.NOT_BETWEEN: + return toFormulaString(cfRuleRecord.getParsedExpression2()); + } + } + return null; + } + + protected String toFormulaString(Ptg[] parsedExpression) { + return toFormulaString(parsedExpression, workbook); + } + protected static String toFormulaString(Ptg[] parsedExpression, HSSFWorkbook workbook) { + if(parsedExpression == null || parsedExpression.length == 0) { + return null; + } + return HSSFFormulaParser.toFormulaString(workbook, parsedExpression); + } } diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingThreshold.java b/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingThreshold.java new file mode 100644 index 0000000000..4ab124c05c --- /dev/null +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingThreshold.java @@ -0,0 +1,63 @@ +/* ==================================================================== + 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.hssf.usermodel; + +import static org.apache.poi.hssf.record.CFRuleBase.parseFormula; +import static org.apache.poi.hssf.usermodel.HSSFConditionalFormattingRule.toFormulaString; + +import org.apache.poi.hssf.record.cf.Threshold; + +/** + * High level representation for Icon / Multi-State / Databar / + * Colour Scale change thresholds + */ +public final class HSSFConditionalFormattingThreshold implements org.apache.poi.ss.usermodel.ConditionalFormattingThreshold { + private final Threshold threshold; + private final HSSFSheet sheet; + private final HSSFWorkbook workbook; + + protected HSSFConditionalFormattingThreshold(Threshold threshold, HSSFSheet sheet) { + this.threshold = threshold; + this.sheet = sheet; + this.workbook = sheet.getWorkbook(); + } + protected Threshold getThreshold() { + return threshold; + } + + public RangeType getRangeType() { + return RangeType.byId(threshold.getType()); + } + public void setRangeType(RangeType type) { + threshold.setType((byte)type.id); + } + + public String getFormula() { + return toFormulaString(threshold.getParsedExpression(), workbook); + } + public void setFormula(String formula) { + threshold.setParsedExpression(parseFormula(formula, sheet)); + } + + public Double getValue() { + return threshold.getValue(); + } + public void setValue(Double value) { + threshold.setValue(value); + } +} diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFFontFormatting.java b/src/java/org/apache/poi/hssf/usermodel/HSSFFontFormatting.java index 598ea9c024..07f5fd4727 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFFontFormatting.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFFontFormatting.java @@ -17,382 +17,388 @@ package org.apache.poi.hssf.usermodel; -import org.apache.poi.hssf.record.CFRuleRecord; +import org.apache.poi.hssf.record.CFRuleBase; import org.apache.poi.hssf.record.cf.FontFormatting; +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.ss.usermodel.Color; /** * High level representation for Font Formatting component * of Conditional Formatting settings */ -public final class HSSFFontFormatting implements org.apache.poi.ss.usermodel.FontFormatting -{ - - /** Underline type - None */ - public final static byte U_NONE = FontFormatting.U_NONE; - /** Underline type - Single */ - public final static byte U_SINGLE = FontFormatting.U_SINGLE; - /** Underline type - Double */ - public final static byte U_DOUBLE = FontFormatting.U_DOUBLE; - /** Underline type - Single Accounting */ - public final static byte U_SINGLE_ACCOUNTING = FontFormatting.U_SINGLE_ACCOUNTING; - /** Underline type - Double Accounting */ - public final static byte U_DOUBLE_ACCOUNTING = FontFormatting.U_DOUBLE_ACCOUNTING; - - private final FontFormatting fontFormatting; - - protected HSSFFontFormatting(CFRuleRecord cfRuleRecord) - { - this.fontFormatting = cfRuleRecord.getFontFormatting(); - } - - protected FontFormatting getFontFormattingBlock() - { - return fontFormatting; - } - - /** - * get the type of super or subscript for the font - * - * @return super or subscript option - * @see #SS_NONE - * @see #SS_SUPER - * @see #SS_SUB - */ - public short getEscapementType() - { - return fontFormatting.getEscapementType(); - } - - /** - * @return font color index - */ - public short getFontColorIndex() - { - return fontFormatting.getFontColorIndex(); - } - - /** - * gets the height of the font in 1/20th point units - * - * @return fontheight (in points/20); or -1 if not modified - */ - public int getFontHeight() - { - return fontFormatting.getFontHeight(); - } - - /** - * get the font weight for this font (100-1000dec or 0x64-0x3e8). Default is - * 0x190 for normal and 0x2bc for bold - * - * @return bw - a number between 100-1000 for the fonts "boldness" - */ - - public short getFontWeight() - { - return fontFormatting.getFontWeight(); - } - - /** - * @see org.apache.poi.hssf.record.cf.FontFormatting#getRawRecord() - */ - protected byte[] getRawRecord() - { - return fontFormatting.getRawRecord(); - } - - /** - * get the type of underlining for the font - * - * @return font underlining type - * - * @see #U_NONE - * @see #U_SINGLE - * @see #U_DOUBLE - * @see #U_SINGLE_ACCOUNTING - * @see #U_DOUBLE_ACCOUNTING - */ - public short getUnderlineType() - { - return fontFormatting.getUnderlineType(); - } - - /** - * get whether the font weight is set to bold or not - * - * @return bold - whether the font is bold or not - */ - public boolean isBold() - { - return fontFormatting.isFontWeightModified() && fontFormatting.isBold(); - } - - /** - * @return true if escapement type was modified from default - */ - public boolean isEscapementTypeModified() - { - return fontFormatting.isEscapementTypeModified(); - } - - /** - * @return true if font cancellation was modified from default - */ - public boolean isFontCancellationModified() - { - return fontFormatting.isFontCancellationModified(); - } - - /** - * @return true if font outline type was modified from default - */ - public boolean isFontOutlineModified() - { - return fontFormatting.isFontOutlineModified(); - } - - /** - * @return true if font shadow type was modified from default - */ - public boolean isFontShadowModified() - { - return fontFormatting.isFontShadowModified(); - } - - /** - * @return true if font style was modified from default - */ - public boolean isFontStyleModified() - { - return fontFormatting.isFontStyleModified(); - } - - /** - * @return true if font style was set to <i>italic</i> - */ - public boolean isItalic() - { - return fontFormatting.isFontStyleModified() && fontFormatting.isItalic(); - } - - /** - * @return true if font outline is on - */ - public boolean isOutlineOn() - { - return fontFormatting.isFontOutlineModified() && fontFormatting.isOutlineOn(); - } - - /** - * @return true if font shadow is on - */ - public boolean isShadowOn() - { - return fontFormatting.isFontOutlineModified() && fontFormatting.isShadowOn(); - } - - /** - * @return true if font strikeout is on - */ - public boolean isStruckout() - { - return fontFormatting.isFontCancellationModified() && fontFormatting.isStruckout(); - } - - /** - * @return true if font underline type was modified from default - */ - public boolean isUnderlineTypeModified() - { - return fontFormatting.isUnderlineTypeModified(); - } - - /** - * @return true if font weight was modified from default - */ - public boolean isFontWeightModified() - { - return fontFormatting.isFontWeightModified(); - } - - /** - * set font style options. - * - * @param italic - if true, set posture style to italic, otherwise to normal - * @param bold if true, set font weight to bold, otherwise to normal - */ - - public void setFontStyle(boolean italic, boolean bold) - { - boolean modified = italic || bold; - fontFormatting.setItalic(italic); - fontFormatting.setBold(bold); - fontFormatting.setFontStyleModified(modified); - fontFormatting.setFontWieghtModified(modified); - } - - /** - * set font style options to default values (non-italic, non-bold) - */ - public void resetFontStyle() - { - setFontStyle(false,false); - } - - /** - * set the escapement type for the font - * - * @param escapementType super or subscript option - * @see #SS_NONE - * @see #SS_SUPER - * @see #SS_SUB - */ - public void setEscapementType(short escapementType) - { - switch(escapementType) - { - case HSSFFontFormatting.SS_SUB: - case HSSFFontFormatting.SS_SUPER: - fontFormatting.setEscapementType(escapementType); - fontFormatting.setEscapementTypeModified(true); - break; - case HSSFFontFormatting.SS_NONE: - fontFormatting.setEscapementType(escapementType); - fontFormatting.setEscapementTypeModified(false); - break; - default: - } - } - - /** - * @param modified - * @see org.apache.poi.hssf.record.cf.FontFormatting#setEscapementTypeModified(boolean) - */ - public void setEscapementTypeModified(boolean modified) - { - fontFormatting.setEscapementTypeModified(modified); - } - - /** - * @param modified - * @see org.apache.poi.hssf.record.cf.FontFormatting#setFontCancellationModified(boolean) - */ - public void setFontCancellationModified(boolean modified) - { - fontFormatting.setFontCancellationModified(modified); - } - - /** - * @param fci - * @see org.apache.poi.hssf.record.cf.FontFormatting#setFontColorIndex(short) - */ - public void setFontColorIndex(short fci) - { - fontFormatting.setFontColorIndex(fci); - } - - /** - * @param height - * @see org.apache.poi.hssf.record.cf.FontFormatting#setFontHeight(int) - */ - public void setFontHeight(int height) - { - fontFormatting.setFontHeight(height); - } - - /** - * @param modified - * @see org.apache.poi.hssf.record.cf.FontFormatting#setFontOutlineModified(boolean) - */ - public void setFontOutlineModified(boolean modified) - { - fontFormatting.setFontOutlineModified(modified); - } - - /** - * @param modified - * @see org.apache.poi.hssf.record.cf.FontFormatting#setFontShadowModified(boolean) - */ - public void setFontShadowModified(boolean modified) - { - fontFormatting.setFontShadowModified(modified); - } - - /** - * @param modified - * @see org.apache.poi.hssf.record.cf.FontFormatting#setFontStyleModified(boolean) - */ - public void setFontStyleModified(boolean modified) - { - fontFormatting.setFontStyleModified(modified); - } - - /** - * @param on - * @see org.apache.poi.hssf.record.cf.FontFormatting#setOutline(boolean) - */ - public void setOutline(boolean on) - { - fontFormatting.setOutline(on); - fontFormatting.setFontOutlineModified(on); - } - - /** - * @param on - * @see org.apache.poi.hssf.record.cf.FontFormatting#setShadow(boolean) - */ - public void setShadow(boolean on) - { - fontFormatting.setShadow(on); - fontFormatting.setFontShadowModified(on); - } - - /** - * @param strike - * @see org.apache.poi.hssf.record.cf.FontFormatting#setStrikeout(boolean) - */ - public void setStrikeout(boolean strike) - { - fontFormatting.setStrikeout(strike); - fontFormatting.setFontCancellationModified(strike); - } - - /** - * set the type of underlining type for the font - * - * @param underlineType super or subscript option - * - * @see #U_NONE - * @see #U_SINGLE - * @see #U_DOUBLE - * @see #U_SINGLE_ACCOUNTING - * @see #U_DOUBLE_ACCOUNTING - */ - public void setUnderlineType(short underlineType) - { - switch(underlineType) - { - case HSSFFontFormatting.U_SINGLE: - case HSSFFontFormatting.U_DOUBLE: - case HSSFFontFormatting.U_SINGLE_ACCOUNTING: - case HSSFFontFormatting.U_DOUBLE_ACCOUNTING: - fontFormatting.setUnderlineType(underlineType); - setUnderlineTypeModified(true); - break; - - case HSSFFontFormatting.U_NONE: - fontFormatting.setUnderlineType(underlineType); - setUnderlineTypeModified(false); - break; - default: - } - } - - /** - * @param modified - * @see org.apache.poi.hssf.record.cf.FontFormatting#setUnderlineTypeModified(boolean) - */ - public void setUnderlineTypeModified(boolean modified) - { - fontFormatting.setUnderlineTypeModified(modified); - } +public final class HSSFFontFormatting implements org.apache.poi.ss.usermodel.FontFormatting { + /** Underline type - None */ + public final static byte U_NONE = FontFormatting.U_NONE; + /** Underline type - Single */ + public final static byte U_SINGLE = FontFormatting.U_SINGLE; + /** Underline type - Double */ + public final static byte U_DOUBLE = FontFormatting.U_DOUBLE; + /** Underline type - Single Accounting */ + public final static byte U_SINGLE_ACCOUNTING = FontFormatting.U_SINGLE_ACCOUNTING; + /** Underline type - Double Accounting */ + public final static byte U_DOUBLE_ACCOUNTING = FontFormatting.U_DOUBLE_ACCOUNTING; + + private final FontFormatting fontFormatting; + private final HSSFWorkbook workbook; + + protected HSSFFontFormatting(CFRuleBase cfRuleRecord, HSSFWorkbook workbook) { + this.fontFormatting = cfRuleRecord.getFontFormatting(); + this.workbook = workbook; + } + + protected FontFormatting getFontFormattingBlock() { + return fontFormatting; + } + + /** + * get the type of super or subscript for the font + * + * @return super or subscript option + * @see #SS_NONE + * @see #SS_SUPER + * @see #SS_SUB + */ + public short getEscapementType() + { + return fontFormatting.getEscapementType(); + } + + /** + * @return font color index + */ + public short getFontColorIndex() + { + return fontFormatting.getFontColorIndex(); + } + + public HSSFColor getFontColor() { + return workbook.getCustomPalette().getColor( + getFontColorIndex() + ); + } + + public void setFontColor(Color color) { + HSSFColor hcolor = HSSFColor.toHSSFColor(color); + if (hcolor == null) { + fontFormatting.setFontColorIndex((short)0); + } else { + fontFormatting.setFontColorIndex(hcolor.getIndex()); + } + } + + /** + * gets the height of the font in 1/20th point units + * + * @return fontheight (in points/20); or -1 if not modified + */ + public int getFontHeight() { + return fontFormatting.getFontHeight(); + } + + /** + * get the font weight for this font (100-1000dec or 0x64-0x3e8). Default is + * 0x190 for normal and 0x2bc for bold + * + * @return bw - a number between 100-1000 for the fonts "boldness" + */ + public short getFontWeight() { + return fontFormatting.getFontWeight(); + } + + /** + * @see org.apache.poi.hssf.record.cf.FontFormatting#getRawRecord() + */ + protected byte[] getRawRecord() { + return fontFormatting.getRawRecord(); + } + + /** + * get the type of underlining for the font + * + * @return font underlining type + * + * @see #U_NONE + * @see #U_SINGLE + * @see #U_DOUBLE + * @see #U_SINGLE_ACCOUNTING + * @see #U_DOUBLE_ACCOUNTING + */ + public short getUnderlineType() + { + return fontFormatting.getUnderlineType(); + } + + /** + * get whether the font weight is set to bold or not + * + * @return bold - whether the font is bold or not + */ + public boolean isBold() + { + return fontFormatting.isFontWeightModified() && fontFormatting.isBold(); + } + + /** + * @return true if escapement type was modified from default + */ + public boolean isEscapementTypeModified() + { + return fontFormatting.isEscapementTypeModified(); + } + + /** + * @return true if font cancellation was modified from default + */ + public boolean isFontCancellationModified() + { + return fontFormatting.isFontCancellationModified(); + } + + /** + * @return true if font outline type was modified from default + */ + public boolean isFontOutlineModified() + { + return fontFormatting.isFontOutlineModified(); + } + + /** + * @return true if font shadow type was modified from default + */ + public boolean isFontShadowModified() + { + return fontFormatting.isFontShadowModified(); + } + + /** + * @return true if font style was modified from default + */ + public boolean isFontStyleModified() + { + return fontFormatting.isFontStyleModified(); + } + + /** + * @return true if font style was set to <i>italic</i> + */ + public boolean isItalic() + { + return fontFormatting.isFontStyleModified() && fontFormatting.isItalic(); + } + + /** + * @return true if font outline is on + */ + public boolean isOutlineOn() + { + return fontFormatting.isFontOutlineModified() && fontFormatting.isOutlineOn(); + } + + /** + * @return true if font shadow is on + */ + public boolean isShadowOn() + { + return fontFormatting.isFontOutlineModified() && fontFormatting.isShadowOn(); + } + + /** + * @return true if font strikeout is on + */ + public boolean isStruckout() + { + return fontFormatting.isFontCancellationModified() && fontFormatting.isStruckout(); + } + + /** + * @return true if font underline type was modified from default + */ + public boolean isUnderlineTypeModified() + { + return fontFormatting.isUnderlineTypeModified(); + } + + /** + * @return true if font weight was modified from default + */ + public boolean isFontWeightModified() + { + return fontFormatting.isFontWeightModified(); + } + + /** + * set font style options. + * + * @param italic - if true, set posture style to italic, otherwise to normal + * @param bold if true, set font weight to bold, otherwise to normal + */ + + public void setFontStyle(boolean italic, boolean bold) + { + boolean modified = italic || bold; + fontFormatting.setItalic(italic); + fontFormatting.setBold(bold); + fontFormatting.setFontStyleModified(modified); + fontFormatting.setFontWieghtModified(modified); + } + + /** + * set font style options to default values (non-italic, non-bold) + */ + public void resetFontStyle() + { + setFontStyle(false,false); + } + + /** + * set the escapement type for the font + * + * @param escapementType super or subscript option + * @see #SS_NONE + * @see #SS_SUPER + * @see #SS_SUB + */ + public void setEscapementType(short escapementType) { + switch(escapementType) { + case HSSFFontFormatting.SS_SUB: + case HSSFFontFormatting.SS_SUPER: + fontFormatting.setEscapementType(escapementType); + fontFormatting.setEscapementTypeModified(true); + break; + case HSSFFontFormatting.SS_NONE: + fontFormatting.setEscapementType(escapementType); + fontFormatting.setEscapementTypeModified(false); + break; + default: + } + } + + /** + * @param modified + * @see org.apache.poi.hssf.record.cf.FontFormatting#setEscapementTypeModified(boolean) + */ + public void setEscapementTypeModified(boolean modified) { + fontFormatting.setEscapementTypeModified(modified); + } + + /** + * @param modified + * @see org.apache.poi.hssf.record.cf.FontFormatting#setFontCancellationModified(boolean) + */ + public void setFontCancellationModified(boolean modified) + { + fontFormatting.setFontCancellationModified(modified); + } + + /** + * @param fci + * @see org.apache.poi.hssf.record.cf.FontFormatting#setFontColorIndex(short) + */ + public void setFontColorIndex(short fci) + { + fontFormatting.setFontColorIndex(fci); + } + + /** + * @param height + * @see org.apache.poi.hssf.record.cf.FontFormatting#setFontHeight(int) + */ + public void setFontHeight(int height) + { + fontFormatting.setFontHeight(height); + } + + /** + * @param modified + * @see org.apache.poi.hssf.record.cf.FontFormatting#setFontOutlineModified(boolean) + */ + public void setFontOutlineModified(boolean modified) + { + fontFormatting.setFontOutlineModified(modified); + } + + /** + * @param modified + * @see org.apache.poi.hssf.record.cf.FontFormatting#setFontShadowModified(boolean) + */ + public void setFontShadowModified(boolean modified) + { + fontFormatting.setFontShadowModified(modified); + } + + /** + * @param modified + * @see org.apache.poi.hssf.record.cf.FontFormatting#setFontStyleModified(boolean) + */ + public void setFontStyleModified(boolean modified) + { + fontFormatting.setFontStyleModified(modified); + } + + /** + * @param on + * @see org.apache.poi.hssf.record.cf.FontFormatting#setOutline(boolean) + */ + public void setOutline(boolean on) + { + fontFormatting.setOutline(on); + fontFormatting.setFontOutlineModified(on); + } + + /** + * @param on + * @see org.apache.poi.hssf.record.cf.FontFormatting#setShadow(boolean) + */ + public void setShadow(boolean on) + { + fontFormatting.setShadow(on); + fontFormatting.setFontShadowModified(on); + } + + /** + * @param strike + * @see org.apache.poi.hssf.record.cf.FontFormatting#setStrikeout(boolean) + */ + public void setStrikeout(boolean strike) + { + fontFormatting.setStrikeout(strike); + fontFormatting.setFontCancellationModified(strike); + } + + /** + * set the type of underlining type for the font + * + * @param underlineType super or subscript option + * + * @see #U_NONE + * @see #U_SINGLE + * @see #U_DOUBLE + * @see #U_SINGLE_ACCOUNTING + * @see #U_DOUBLE_ACCOUNTING + */ + public void setUnderlineType(short underlineType) { + switch(underlineType) { + case HSSFFontFormatting.U_SINGLE: + case HSSFFontFormatting.U_DOUBLE: + case HSSFFontFormatting.U_SINGLE_ACCOUNTING: + case HSSFFontFormatting.U_DOUBLE_ACCOUNTING: + fontFormatting.setUnderlineType(underlineType); + setUnderlineTypeModified(true); + break; + + case HSSFFontFormatting.U_NONE: + fontFormatting.setUnderlineType(underlineType); + setUnderlineTypeModified(false); + break; + default: + } + } + + /** + * @param modified + * @see org.apache.poi.hssf.record.cf.FontFormatting#setUnderlineTypeModified(boolean) + */ + public void setUnderlineTypeModified(boolean modified) + { + fontFormatting.setUnderlineTypeModified(modified); + } } diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFIconMultiStateFormatting.java b/src/java/org/apache/poi/hssf/usermodel/HSSFIconMultiStateFormatting.java new file mode 100644 index 0000000000..e93d5c918f --- /dev/null +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFIconMultiStateFormatting.java @@ -0,0 +1,81 @@ +/* ==================================================================== + 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.hssf.usermodel; + +import org.apache.poi.hssf.record.CFRule12Record; +import org.apache.poi.hssf.record.cf.IconMultiStateFormatting; +import org.apache.poi.hssf.record.cf.Threshold; +import org.apache.poi.ss.usermodel.ConditionalFormattingThreshold; + +/** + * High level representation for Icon / Multi-State Formatting + * component of Conditional Formatting settings + */ +public final class HSSFIconMultiStateFormatting implements org.apache.poi.ss.usermodel.IconMultiStateFormatting { + private final HSSFSheet sheet; + private final CFRule12Record cfRule12Record; + private final IconMultiStateFormatting iconFormatting; + + protected HSSFIconMultiStateFormatting(CFRule12Record cfRule12Record, HSSFSheet sheet) { + this.sheet = sheet; + this.cfRule12Record = cfRule12Record; + this.iconFormatting = this.cfRule12Record.getMultiStateFormatting(); + } + + public IconSet getIconSet() { + return iconFormatting.getIconSet(); + } + public void setIconSet(IconSet set) { + iconFormatting.setIconSet(set); + } + + public boolean isIconOnly() { + return iconFormatting.isIconOnly(); + } + public void setIconOnly(boolean only) { + iconFormatting.setIconOnly(only); + } + + public boolean isReversed() { + return iconFormatting.isReversed(); + } + public void setReversed(boolean reversed) { + iconFormatting.setReversed(reversed); + } + + public HSSFConditionalFormattingThreshold[] getThresholds() { + Threshold[] t = iconFormatting.getThresholds(); + HSSFConditionalFormattingThreshold[] ht = new HSSFConditionalFormattingThreshold[t.length]; + for (int i=0; i<t.length; i++) { + ht[i] = new HSSFConditionalFormattingThreshold(t[i], sheet); + } + return ht; + } + + public void setThresholds(ConditionalFormattingThreshold[] thresholds) { + Threshold[] t = new Threshold[thresholds.length]; + for (int i=0; i<t.length; i++) { + t[i] = ((HSSFConditionalFormattingThreshold)thresholds[i]).getThreshold(); + } + iconFormatting.setThresholds(t); + } + + public HSSFConditionalFormattingThreshold createThreshold() { + return new HSSFConditionalFormattingThreshold(new Threshold(), sheet); + } +} diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java b/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java index 2c162b9703..667c83cc89 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java @@ -45,7 +45,6 @@ import org.apache.poi.hssf.record.ObjRecord; import org.apache.poi.hssf.util.CellReference; import org.apache.poi.poifs.filesystem.DirectoryEntry; import org.apache.poi.poifs.filesystem.DirectoryNode; -import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.ss.usermodel.Chart; import org.apache.poi.ss.usermodel.ClientAnchor; import org.apache.poi.ss.usermodel.Drawing; diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFPatternFormatting.java b/src/java/org/apache/poi/hssf/usermodel/HSSFPatternFormatting.java index 0430342868..1f521c509e 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFPatternFormatting.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFPatternFormatting.java @@ -17,88 +17,116 @@ package org.apache.poi.hssf.usermodel; -import org.apache.poi.hssf.record.CFRuleRecord; +import org.apache.poi.hssf.record.CFRuleBase; import org.apache.poi.hssf.record.cf.PatternFormatting; +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.ss.usermodel.Color; /** * High level representation for Conditional Formatting settings */ -public class HSSFPatternFormatting implements org.apache.poi.ss.usermodel.PatternFormatting -{ - private final CFRuleRecord cfRuleRecord; - private final PatternFormatting patternFormatting; - - protected HSSFPatternFormatting(CFRuleRecord cfRuleRecord) - { - this.cfRuleRecord = cfRuleRecord; - this.patternFormatting = cfRuleRecord.getPatternFormatting(); - } - - protected PatternFormatting getPatternFormattingBlock() - { - return patternFormatting; - } - - /** - * @see org.apache.poi.hssf.record.cf.PatternFormatting#getFillBackgroundColor() - */ - public short getFillBackgroundColor() - { - return (short)patternFormatting.getFillBackgroundColor(); - } - - /** - * @see org.apache.poi.hssf.record.cf.PatternFormatting#getFillForegroundColor() - */ - public short getFillForegroundColor() - { - return (short)patternFormatting.getFillForegroundColor(); - } - - /** - * @see org.apache.poi.hssf.record.cf.PatternFormatting#getFillPattern() - */ - public short getFillPattern() - { - return (short)patternFormatting.getFillPattern(); - } - - /** - * @param bg - * @see org.apache.poi.hssf.record.cf.PatternFormatting#setFillBackgroundColor(int) - */ - public void setFillBackgroundColor(short bg) - { - patternFormatting.setFillBackgroundColor(bg); - if( bg != 0) - { - cfRuleRecord.setPatternBackgroundColorModified(true); - } - } - - /** - * @param fg - * @see org.apache.poi.hssf.record.cf.PatternFormatting#setFillForegroundColor(int) - */ - public void setFillForegroundColor(short fg) - { - patternFormatting.setFillForegroundColor(fg); - if( fg != 0) - { - cfRuleRecord.setPatternColorModified(true); - } - } - - /** - * @param fp - * @see org.apache.poi.hssf.record.cf.PatternFormatting#setFillPattern(int) - */ - public void setFillPattern(short fp) - { - patternFormatting.setFillPattern(fp); - if( fp != 0) - { - cfRuleRecord.setPatternStyleModified(true); - } - } +public class HSSFPatternFormatting implements org.apache.poi.ss.usermodel.PatternFormatting { + private final HSSFWorkbook workbook; + private final CFRuleBase cfRuleRecord; + private final PatternFormatting patternFormatting; + + protected HSSFPatternFormatting(CFRuleBase cfRuleRecord, HSSFWorkbook workbook) { + this.workbook = workbook; + this.cfRuleRecord = cfRuleRecord; + this.patternFormatting = cfRuleRecord.getPatternFormatting(); + } + + protected PatternFormatting getPatternFormattingBlock() + { + return patternFormatting; + } + + public HSSFColor getFillBackgroundColorColor() { + return workbook.getCustomPalette().getColor(getFillBackgroundColor()); + } + + public HSSFColor getFillForegroundColorColor() { + return workbook.getCustomPalette().getColor(getFillForegroundColor()); + } + + /** + * @see org.apache.poi.hssf.record.cf.PatternFormatting#getFillBackgroundColor() + */ + public short getFillBackgroundColor() + { + return (short)patternFormatting.getFillBackgroundColor(); + } + + /** + * @see org.apache.poi.hssf.record.cf.PatternFormatting#getFillForegroundColor() + */ + public short getFillForegroundColor() + { + return (short)patternFormatting.getFillForegroundColor(); + } + + /** + * @see org.apache.poi.hssf.record.cf.PatternFormatting#getFillPattern() + */ + public short getFillPattern() + { + return (short)patternFormatting.getFillPattern(); + } + + public void setFillBackgroundColor(Color bg) { + HSSFColor hcolor = HSSFColor.toHSSFColor(bg); + if (hcolor == null) { + setFillBackgroundColor((short)0); + } else { + setFillBackgroundColor(hcolor.getIndex()); + } + } + + public void setFillForegroundColor(Color fg) { + HSSFColor hcolor = HSSFColor.toHSSFColor(fg); + if (hcolor == null) { + setFillForegroundColor((short)0); + } else { + setFillForegroundColor(hcolor.getIndex()); + } + } + + /** + * @param bg + * @see org.apache.poi.hssf.record.cf.PatternFormatting#setFillBackgroundColor(int) + */ + public void setFillBackgroundColor(short bg) + { + patternFormatting.setFillBackgroundColor(bg); + if( bg != 0) + { + cfRuleRecord.setPatternBackgroundColorModified(true); + } + } + + /** + * @param fg + * @see org.apache.poi.hssf.record.cf.PatternFormatting#setFillForegroundColor(int) + */ + public void setFillForegroundColor(short fg) + { + patternFormatting.setFillForegroundColor(fg); + if( fg != 0) + { + cfRuleRecord.setPatternColorModified(true); + } + } + + /** + * @param fp + * @see org.apache.poi.hssf.record.cf.PatternFormatting#setFillPattern(int) + */ + public void setFillPattern(short fp) + { + patternFormatting.setFillPattern(fp); + if( fp != 0) + { + cfRuleRecord.setPatternStyleModified(true); + } + } } diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFShapeFactory.java b/src/java/org/apache/poi/hssf/usermodel/HSSFShapeFactory.java index 3e82fbe181..ef1b13b22d 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFShapeFactory.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFShapeFactory.java @@ -29,13 +29,6 @@ import java.util.Map; * Factory class for producing Excel Shapes from Escher records
*/
public class HSSFShapeFactory {
-
- private final static short OBJECT_TYPE_LINE = 1;
- private final static short OBJECT_TYPE_RECTANGLE = 2;
- private final static short OBJECT_TYPE_OVAL = 3;
- private final static short OBJECT_TYPE_ARC = 4;
- private final static short OBJECT_TYPE_PICTURE = 8;
-
/**
* build shape tree from escher container
* @param container root escher container from which escher records must be taken
@@ -81,7 +74,7 @@ public class HSSFShapeFactory { return;
}
CommonObjectDataSubRecord cmo = (CommonObjectDataSubRecord) objRecord.getSubRecords().get(0);
- HSSFShape shape;
+ final HSSFShape shape;
switch (cmo.getObjectType()) {
case CommonObjectDataSubRecord.OBJECT_TYPE_PICTURE:
shape = new HSSFPicture(container, objRecord);
@@ -97,11 +90,15 @@ public class HSSFShapeFactory { break;
case CommonObjectDataSubRecord.OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING:
EscherOptRecord optRecord = container.getChildById(EscherOptRecord.RECORD_ID);
- EscherProperty property = optRecord.lookup(EscherProperties.GEOMETRY__VERTICES);
- if (null != property) {
- shape = new HSSFPolygon(container, objRecord, txtRecord);
+ if(optRecord == null) {
+ shape = new HSSFSimpleShape(container, objRecord, txtRecord);
} else {
- shape = new HSSFSimpleShape(container, objRecord, txtRecord);
+ EscherProperty property = optRecord.lookup(EscherProperties.GEOMETRY__VERTICES);
+ if (null != property) {
+ shape = new HSSFPolygon(container, objRecord, txtRecord);
+ } else {
+ shape = new HSSFSimpleShape(container, objRecord, txtRecord);
+ }
}
break;
case CommonObjectDataSubRecord.OBJECT_TYPE_TEXT:
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java index 8458152fed..268a680d60 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java @@ -868,6 +868,17 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { } /** + * @return the list of merged regions + */ + public List<CellRangeAddress> getMergedRegions() { + List<CellRangeAddress> addresses = new ArrayList<CellRangeAddress>(); + for (int i=0; i < _sheet.getNumMergedRegions(); i++) { + addresses.add(_sheet.getMergedRegionAt(i)); + } + return addresses; + } + + /** * @return an iterator of the PHYSICAL rows. Meaning the 3rd element may not * be the third row if say for instance the second row is undefined. * Call getRowNum() on each row if you care which one it is. diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheetConditionalFormatting.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheetConditionalFormatting.java index ce6bf76b66..deca836a0c 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheetConditionalFormatting.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheetConditionalFormatting.java @@ -17,142 +17,156 @@ package org.apache.poi.hssf.usermodel; +import org.apache.poi.hssf.record.CFRule12Record; +import org.apache.poi.hssf.record.CFRuleBase; import org.apache.poi.hssf.record.CFRuleRecord; import org.apache.poi.hssf.record.aggregates.CFRecordsAggregate; import org.apache.poi.hssf.record.aggregates.ConditionalFormattingTable; +import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.usermodel.ConditionalFormatting; import org.apache.poi.ss.usermodel.ConditionalFormattingRule; +import org.apache.poi.ss.usermodel.IconMultiStateFormatting.IconSet; import org.apache.poi.ss.usermodel.SheetConditionalFormatting; import org.apache.poi.ss.util.CellRangeAddress; -import org.apache.poi.ss.SpreadsheetVersion; /** * The 'Conditional Formatting' facet of <tt>HSSFSheet</tt> */ public final class HSSFSheetConditionalFormatting implements SheetConditionalFormatting { + private final HSSFSheet _sheet; + private final ConditionalFormattingTable _conditionalFormattingTable; - private final HSSFSheet _sheet; - private final ConditionalFormattingTable _conditionalFormattingTable; - - /* package */ HSSFSheetConditionalFormatting(HSSFSheet sheet) { - _sheet = sheet; - _conditionalFormattingTable = sheet.getSheet().getConditionalFormattingTable(); - } - - /** - * A factory method allowing to create a conditional formatting rule - * with a cell comparison operator<p/> - * TODO - formulas containing cell references are currently not parsed properly - * - * @param comparisonOperation - a constant value from - * <tt>{@link org.apache.poi.hssf.record.CFRuleRecord.ComparisonOperator}</tt>: <p> - * <ul> - * <li>BETWEEN</li> - * <li>NOT_BETWEEN</li> - * <li>EQUAL</li> - * <li>NOT_EQUAL</li> - * <li>GT</li> - * <li>LT</li> - * <li>GE</li> - * <li>LE</li> - * </ul> - * </p> - * @param formula1 - formula for the valued, compared with the cell - * @param formula2 - second formula (only used with - * {@link org.apache.poi.hssf.record.CFRuleRecord.ComparisonOperator#BETWEEN}) and - * {@link org.apache.poi.hssf.record.CFRuleRecord.ComparisonOperator#NOT_BETWEEN} operations) - */ - public HSSFConditionalFormattingRule createConditionalFormattingRule( - byte comparisonOperation, - String formula1, - String formula2) { - - HSSFWorkbook wb = _sheet.getWorkbook(); - CFRuleRecord rr = CFRuleRecord.create(_sheet, comparisonOperation, formula1, formula2); - return new HSSFConditionalFormattingRule(wb, rr); - } + /* package */ HSSFSheetConditionalFormatting(HSSFSheet sheet) { + _sheet = sheet; + _conditionalFormattingTable = sheet.getSheet().getConditionalFormattingTable(); + } + /** + * A factory method allowing to create a conditional formatting rule + * with a cell comparison operator<p/> + * TODO - formulas containing cell references are currently not parsed properly + * + * @param comparisonOperation - a constant value from + * <tt>{@link org.apache.poi.hssf.record.CFRuleRecord.ComparisonOperator}</tt>: <p> + * <ul> + * <li>BETWEEN</li> + * <li>NOT_BETWEEN</li> + * <li>EQUAL</li> + * <li>NOT_EQUAL</li> + * <li>GT</li> + * <li>LT</li> + * <li>GE</li> + * <li>LE</li> + * </ul> + * </p> + * @param formula1 - formula for the valued, compared with the cell + * @param formula2 - second formula (only used with + * {@link org.apache.poi.hssf.record.CFRuleRecord.ComparisonOperator#BETWEEN}) and + * {@link org.apache.poi.hssf.record.CFRuleRecord.ComparisonOperator#NOT_BETWEEN} operations) + */ public HSSFConditionalFormattingRule createConditionalFormattingRule( byte comparisonOperation, - String formula1) { + String formula1, + String formula2) { + CFRuleRecord rr = CFRuleRecord.create(_sheet, comparisonOperation, formula1, formula2); + return new HSSFConditionalFormattingRule(_sheet, rr); + } - HSSFWorkbook wb = _sheet.getWorkbook(); + public HSSFConditionalFormattingRule createConditionalFormattingRule( + byte comparisonOperation, + String formula1) { CFRuleRecord rr = CFRuleRecord.create(_sheet, comparisonOperation, formula1, null); - return new HSSFConditionalFormattingRule(wb, rr); - } - - /** - * A factory method allowing to create a conditional formatting rule with a formula.<br> - * - * The formatting rules are applied by Excel when the value of the formula not equal to 0.<p/> - * TODO - formulas containing cell references are currently not parsed properly - * @param formula - formula for the valued, compared with the cell - */ - public HSSFConditionalFormattingRule createConditionalFormattingRule(String formula) { - HSSFWorkbook wb = _sheet.getWorkbook(); - CFRuleRecord rr = CFRuleRecord.create(_sheet, formula); - return new HSSFConditionalFormattingRule(wb, rr); - } - - /** - * Adds a copy of HSSFConditionalFormatting object to the sheet - * <p>This method could be used to copy HSSFConditionalFormatting object - * from one sheet to another. For example: - * <pre> - * HSSFConditionalFormatting cf = sheet.getConditionalFormattingAt(index); - * newSheet.addConditionalFormatting(cf); - * </pre> - * - * @param cf HSSFConditionalFormatting object - * @return index of the new Conditional Formatting object - */ - public int addConditionalFormatting( HSSFConditionalFormatting cf ) { - CFRecordsAggregate cfraClone = cf.getCFRecordsAggregate().cloneCFAggregate(); - - return _conditionalFormattingTable.add(cfraClone); - } + return new HSSFConditionalFormattingRule(_sheet, rr); + } + + /** + * A factory method allowing to create a conditional formatting rule with a formula.<br> + * + * The formatting rules are applied by Excel when the value of the formula not equal to 0.<p/> + * TODO - formulas containing cell references are currently not parsed properly + * @param formula - formula for the valued, compared with the cell + */ + public HSSFConditionalFormattingRule createConditionalFormattingRule(String formula) { + CFRuleRecord rr = CFRuleRecord.create(_sheet, formula); + return new HSSFConditionalFormattingRule(_sheet, rr); + } + + /** + * A factory method allowing the creation of conditional formatting + * rules using an Icon Set / Multi-State formatting. + * The thresholds for it will be created, but will be empty + * and require configuring with + * {@link HSSFConditionalFormattingRule#getMultiStateFormatting()} + * then + * {@link HSSFIconMultiStateFormatting#getThresholds()} + */ + public HSSFConditionalFormattingRule createConditionalFormattingRule( + IconSet iconSet) { + CFRule12Record rr = CFRule12Record.create(_sheet, iconSet); + return new HSSFConditionalFormattingRule(_sheet, rr); + } + + // TODO Support types beyond CELL_VALUE_IS and FORMULA and ICONs + + /** + * Adds a copy of HSSFConditionalFormatting object to the sheet + * <p>This method could be used to copy HSSFConditionalFormatting object + * from one sheet to another. For example: + * <pre> + * HSSFConditionalFormatting cf = sheet.getConditionalFormattingAt(index); + * newSheet.addConditionalFormatting(cf); + * </pre> + * + * @param cf HSSFConditionalFormatting object + * @return index of the new Conditional Formatting object + */ + public int addConditionalFormatting( HSSFConditionalFormatting cf ) { + CFRecordsAggregate cfraClone = cf.getCFRecordsAggregate().cloneCFAggregate(); + + return _conditionalFormattingTable.add(cfraClone); + } public int addConditionalFormatting( ConditionalFormatting cf ) { return addConditionalFormatting((HSSFConditionalFormatting)cf); } - /** - * @deprecated use <tt>CellRangeAddress</tt> instead of <tt>Region</tt> - */ - public int addConditionalFormatting(org.apache.poi.ss.util.Region[] regions, HSSFConditionalFormattingRule[] cfRules) { - return addConditionalFormatting(org.apache.poi.ss.util.Region.convertRegionsToCellRanges(regions), cfRules); - } - /** - * Allows to add a new Conditional Formatting set to the sheet. - * - * @param regions - list of rectangular regions to apply conditional formatting rules - * @param cfRules - set of up to three conditional formatting rules - * - * @return index of the newly created Conditional Formatting object - */ - public int addConditionalFormatting(CellRangeAddress[] regions, HSSFConditionalFormattingRule[] cfRules) { - if (regions == null) { - throw new IllegalArgumentException("regions must not be null"); - } - for(CellRangeAddress range : regions) range.validate(SpreadsheetVersion.EXCEL97); - - if (cfRules == null) { - throw new IllegalArgumentException("cfRules must not be null"); - } - if (cfRules.length == 0) { - throw new IllegalArgumentException("cfRules must not be empty"); - } - if (cfRules.length > 3) { - throw new IllegalArgumentException("Number of rules must not exceed 3"); - } - - CFRuleRecord[] rules = new CFRuleRecord[cfRules.length]; - for (int i = 0; i != cfRules.length; i++) { - rules[i] = cfRules[i].getCfRuleRecord(); - } - CFRecordsAggregate cfra = new CFRecordsAggregate(regions, rules); - return _conditionalFormattingTable.add(cfra); - } + /** + * @deprecated use <tt>CellRangeAddress</tt> instead of <tt>Region</tt> + */ + public int addConditionalFormatting(org.apache.poi.ss.util.Region[] regions, HSSFConditionalFormattingRule[] cfRules) { + return addConditionalFormatting(org.apache.poi.ss.util.Region.convertRegionsToCellRanges(regions), cfRules); + } + /** + * Allows to add a new Conditional Formatting set to the sheet. + * + * @param regions - list of rectangular regions to apply conditional formatting rules + * @param cfRules - set of up to three conditional formatting rules + * + * @return index of the newly created Conditional Formatting object + */ + public int addConditionalFormatting(CellRangeAddress[] regions, HSSFConditionalFormattingRule[] cfRules) { + if (regions == null) { + throw new IllegalArgumentException("regions must not be null"); + } + for(CellRangeAddress range : regions) range.validate(SpreadsheetVersion.EXCEL97); + + if (cfRules == null) { + throw new IllegalArgumentException("cfRules must not be null"); + } + if (cfRules.length == 0) { + throw new IllegalArgumentException("cfRules must not be empty"); + } + if (cfRules.length > 3) { + throw new IllegalArgumentException("Number of rules must not exceed 3"); + } + + CFRuleBase[] rules = new CFRuleBase[cfRules.length]; + for (int i = 0; i != cfRules.length; i++) { + rules[i] = cfRules[i].getCfRuleRecord(); + } + CFRecordsAggregate cfra = new CFRecordsAggregate(regions, rules); + return _conditionalFormattingTable.add(cfra); + } public int addConditionalFormatting(CellRangeAddress[] regions, ConditionalFormattingRule[] cfRules) { HSSFConditionalFormattingRule[] hfRules; @@ -164,70 +178,61 @@ public final class HSSFSheetConditionalFormatting implements SheetConditionalFor return addConditionalFormatting(regions, hfRules); } - public int addConditionalFormatting(CellRangeAddress[] regions, - HSSFConditionalFormattingRule rule1) - { - return addConditionalFormatting(regions, - rule1 == null ? null : new HSSFConditionalFormattingRule[] - { - rule1 - }); - } + public int addConditionalFormatting(CellRangeAddress[] regions, + HSSFConditionalFormattingRule rule1) { + return addConditionalFormatting(regions, rule1 == null ? + null : new HSSFConditionalFormattingRule[] { rule1 } + ); + } public int addConditionalFormatting(CellRangeAddress[] regions, - ConditionalFormattingRule rule1) - { + ConditionalFormattingRule rule1) { return addConditionalFormatting(regions, (HSSFConditionalFormattingRule)rule1); } - public int addConditionalFormatting(CellRangeAddress[] regions, - HSSFConditionalFormattingRule rule1, - HSSFConditionalFormattingRule rule2) - { - return addConditionalFormatting(regions, - new HSSFConditionalFormattingRule[] - { - rule1, rule2 - }); - } + public int addConditionalFormatting(CellRangeAddress[] regions, + HSSFConditionalFormattingRule rule1, + HSSFConditionalFormattingRule rule2) { + return addConditionalFormatting(regions, + new HSSFConditionalFormattingRule[] { rule1, rule2 }); + } public int addConditionalFormatting(CellRangeAddress[] regions, ConditionalFormattingRule rule1, - ConditionalFormattingRule rule2) - { + ConditionalFormattingRule rule2) { return addConditionalFormatting(regions, (HSSFConditionalFormattingRule)rule1, (HSSFConditionalFormattingRule)rule2 - ); - } - - /** - * gets Conditional Formatting object at a particular index - * - * @param index - * of the Conditional Formatting object to fetch - * @return Conditional Formatting object - */ - public HSSFConditionalFormatting getConditionalFormattingAt(int index) { - CFRecordsAggregate cf = _conditionalFormattingTable.get(index); - if (cf == null) { - return null; - } - return new HSSFConditionalFormatting(_sheet.getWorkbook(), cf); - } - - /** - * @return number of Conditional Formatting objects of the sheet - */ - public int getNumConditionalFormattings() { - return _conditionalFormattingTable.size(); - } - - /** - * removes a Conditional Formatting object by index - * @param index of a Conditional Formatting object to remove - */ - public void removeConditionalFormatting(int index) { - _conditionalFormattingTable.remove(index); - } + ); + } + + /** + * gets Conditional Formatting object at a particular index + * + * @param index + * of the Conditional Formatting object to fetch + * @return Conditional Formatting object + */ + public HSSFConditionalFormatting getConditionalFormattingAt(int index) { + CFRecordsAggregate cf = _conditionalFormattingTable.get(index); + if (cf == null) { + return null; + } + return new HSSFConditionalFormatting(_sheet, cf); + } + + /** + * @return number of Conditional Formatting objects of the sheet + */ + public int getNumConditionalFormattings() { + return _conditionalFormattingTable.size(); + } + + /** + * removes a Conditional Formatting object by index + * @param index of a Conditional Formatting object to remove + */ + public void removeConditionalFormatting(int index) { + _conditionalFormattingTable.remove(index); + } } diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java index 503ed64d6c..65ec1a33e5 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java @@ -65,6 +65,7 @@ import org.apache.poi.hssf.record.UnknownRecord; import org.apache.poi.hssf.record.aggregates.RecordAggregate.RecordVisitor; import org.apache.poi.hssf.record.common.UnicodeString; import org.apache.poi.hssf.util.CellReference; +import org.apache.poi.poifs.crypt.Decryptor; import org.apache.poi.poifs.filesystem.DirectoryEntry; import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.EntryUtils; @@ -205,6 +206,19 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss public HSSFWorkbook(POIFSFileSystem fs) throws IOException { this(fs,true); } + /** + * Given a POI POIFSFileSystem object, read in its Workbook along + * with all related nodes, and populate the high and low level models. + * <p>This calls {@link #HSSFWorkbook(POIFSFileSystem, boolean)} with + * preserve nodes set to true. + * + * @see #HSSFWorkbook(POIFSFileSystem, boolean) + * @see org.apache.poi.poifs.filesystem.POIFSFileSystem + * @exception IOException if the stream cannot be read + */ + public HSSFWorkbook(NPOIFSFileSystem fs) throws IOException { + this(fs.getRoot(),true); + } /** * Given a POI POIFSFileSystem object, read in its Workbook and populate @@ -248,7 +262,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss // check for an encrypted .xlsx file - they get OLE2 wrapped try { - directory.getEntry("EncryptedPackage"); + directory.getEntry(Decryptor.DEFAULT_POIFS_ENTRY); throw new EncryptedDocumentException("The supplied spreadsheet seems to be an Encrypted .xlsx file. " + "It must be decrypted before use by XSSF, it cannot be used by HSSF"); } catch (FileNotFoundException e) { @@ -378,7 +392,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss public HSSFWorkbook(InputStream s, boolean preserveNodes) throws IOException { - this(new POIFSFileSystem(s), preserveNodes); + this(new NPOIFSFileSystem(s).getRoot(), preserveNodes); } /** @@ -1276,7 +1290,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss throws IOException { byte[] bytes = getBytes(); - POIFSFileSystem fs = new POIFSFileSystem(); + NPOIFSFileSystem fs = new NPOIFSFileSystem(); // For tracking what we've written out, used if we're // going to be preserving nodes @@ -1843,7 +1857,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss throws IOException { // check if we were created by POIFS otherwise create a new dummy POIFS for storing the package data if (directory == null) { - directory = new POIFSFileSystem().getRoot(); + directory = new NPOIFSFileSystem().getRoot(); preserveNodes = true; } diff --git a/src/java/org/apache/poi/hssf/util/HSSFColor.java b/src/java/org/apache/poi/hssf/util/HSSFColor.java index f438e1b001..d7a1cb587e 100644 --- a/src/java/org/apache/poi/hssf/util/HSSFColor.java +++ b/src/java/org/apache/poi/hssf/util/HSSFColor.java @@ -204,6 +204,13 @@ public class HSSFColor implements Color { { return BLACK.hexString; } + + public static HSSFColor toHSSFColor(Color color) { + if (color != null && !(color instanceof HSSFColor)) { + throw new IllegalArgumentException("Only HSSFColor objects are supported"); + } + return (HSSFColor)color; + } /** * Class BLACK diff --git a/src/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java b/src/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java index 8a2bf00454..2c5716d2a5 100644 --- a/src/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java +++ b/src/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java @@ -16,6 +16,8 @@ ==================================================================== */
package org.apache.poi.poifs.crypt;
+import static org.apache.poi.poifs.crypt.Decryptor.DEFAULT_POIFS_ENTRY;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -132,8 +134,8 @@ public abstract class ChunkedCipherOutputStream extends FilterOutputStream { super.close();
int oleStreamSize = (int)(fileOut.length()+LittleEndianConsts.LONG_SIZE);
- calculateChecksum(fileOut, oleStreamSize);
- dir.createDocument("EncryptedPackage", oleStreamSize, new EncryptedPackageWriter());
+ calculateChecksum(fileOut, (int)_pos);
+ dir.createDocument(DEFAULT_POIFS_ENTRY, oleStreamSize, new EncryptedPackageWriter());
createEncryptionInfoEntry(dir, fileOut);
} catch (GeneralSecurityException e) {
throw new IOException(e);
diff --git a/src/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java b/src/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java index 0c80c6c2b3..f6477fb9b5 100644 --- a/src/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java +++ b/src/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java @@ -36,7 +36,7 @@ public class DataSpaceMapUtils { public static void addDefaultDataSpace(DirectoryEntry dir) throws IOException {
DataSpaceMapEntry dsme = new DataSpaceMapEntry(
new int[]{ 0 }
- , new String[]{ "EncryptedPackage" }
+ , new String[]{ Decryptor.DEFAULT_POIFS_ENTRY }
, "StrongEncryptionDataSpace"
);
DataSpaceMap dsm = new DataSpaceMap(new DataSpaceMapEntry[]{dsme});
diff --git a/src/java/org/apache/poi/poifs/crypt/Decryptor.java b/src/java/org/apache/poi/poifs/crypt/Decryptor.java index af449290e8..eb94dca983 100644 --- a/src/java/org/apache/poi/poifs/crypt/Decryptor.java +++ b/src/java/org/apache/poi/poifs/crypt/Decryptor.java @@ -25,10 +25,12 @@ import javax.crypto.SecretKey; import org.apache.poi.EncryptedDocumentException; import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; +import org.apache.poi.poifs.filesystem.OPOIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem; public abstract class Decryptor { public static final String DEFAULT_PASSWORD="VelvetSweatshop"; + public static final String DEFAULT_POIFS_ENTRY="EncryptedPackage"; protected final EncryptionInfoBuilder builder; private SecretKey secretKey; @@ -83,7 +85,9 @@ public abstract class Decryptor { public InputStream getDataStream(NPOIFSFileSystem fs) throws IOException, GeneralSecurityException { return getDataStream(fs.getRoot()); } - + public InputStream getDataStream(OPOIFSFileSystem fs) throws IOException, GeneralSecurityException { + return getDataStream(fs.getRoot()); + } public InputStream getDataStream(POIFSFileSystem fs) throws IOException, GeneralSecurityException { return getDataStream(fs.getRoot()); } diff --git a/src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java b/src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java index 0418befe23..3aafb90cac 100644 --- a/src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java +++ b/src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java @@ -26,6 +26,7 @@ import java.io.IOException; import org.apache.poi.EncryptedDocumentException; import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; +import org.apache.poi.poifs.filesystem.OPOIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.util.BitField; import org.apache.poi.util.BitFieldFactory; @@ -68,14 +69,27 @@ public class EncryptionInfo { public static BitField flagAES = BitFieldFactory.getInstance(0x20); + /** + * Opens for decryption + */ public EncryptionInfo(POIFSFileSystem fs) throws IOException { this(fs.getRoot()); } - + /** + * Opens for decryption + */ + public EncryptionInfo(OPOIFSFileSystem fs) throws IOException { + this(fs.getRoot()); + } + /** + * Opens for decryption + */ public EncryptionInfo(NPOIFSFileSystem fs) throws IOException { this(fs.getRoot()); } - + /** + * Opens for decryption + */ public EncryptionInfo(DirectoryNode dir) throws IOException { this(dir.createDocumentInputStream("EncryptionInfo"), false); } @@ -131,7 +145,7 @@ public class EncryptionInfo { } /** - * @deprecated use constructor without fs parameter + * @deprecated Use {@link #EncryptionInfo(EncryptionMode)} (fs parameter no longer required) */ @Deprecated public EncryptionInfo(POIFSFileSystem fs, EncryptionMode encryptionMode) { @@ -139,7 +153,7 @@ public class EncryptionInfo { } /** - * @deprecated use constructor without fs parameter + * @deprecated Use {@link #EncryptionInfo(EncryptionMode)} (fs parameter no longer required) */ @Deprecated public EncryptionInfo(NPOIFSFileSystem fs, EncryptionMode encryptionMode) { @@ -147,7 +161,7 @@ public class EncryptionInfo { } /** - * @deprecated use constructor without dir parameter + * @deprecated Use {@link #EncryptionInfo(EncryptionMode)} (dir parameter no longer required) */ @Deprecated public EncryptionInfo(DirectoryNode dir, EncryptionMode encryptionMode) { @@ -155,7 +169,7 @@ public class EncryptionInfo { } /** - * @deprecated use constructor without fs parameter + * @deprecated use {@link #EncryptionInfo(EncryptionMode, CipherAlgorithm, HashAlgorithm, int, int, ChainingMode)} */ @Deprecated public EncryptionInfo( @@ -171,7 +185,7 @@ public class EncryptionInfo { } /** - * @deprecated use constructor without fs parameter + * @deprecated use {@link #EncryptionInfo(EncryptionMode, CipherAlgorithm, HashAlgorithm, int, int, ChainingMode)} */ @Deprecated public EncryptionInfo( @@ -187,7 +201,7 @@ public class EncryptionInfo { } /** - * @deprecated use constructor without dir parameter + * @deprecated use {@link #EncryptionInfo(EncryptionMode, CipherAlgorithm, HashAlgorithm, int, int, ChainingMode)} */ @Deprecated public EncryptionInfo( @@ -202,6 +216,11 @@ public class EncryptionInfo { this(encryptionMode, cipherAlgorithm, hashAlgorithm, keyBits, blockSize, chainingMode); } + /** + * Prepares for encryption, using the given Encryption Mode, and + * all other parameters as default. + * @see #EncryptionInfo(EncryptionMode, CipherAlgorithm, HashAlgorithm, int, int, ChainingMode) + */ public EncryptionInfo(EncryptionMode encryptionMode) { this(encryptionMode, null, null, -1, -1, null); } diff --git a/src/java/org/apache/poi/poifs/crypt/Encryptor.java b/src/java/org/apache/poi/poifs/crypt/Encryptor.java index abfd693306..d40f8ae5d9 100644 --- a/src/java/org/apache/poi/poifs/crypt/Encryptor.java +++ b/src/java/org/apache/poi/poifs/crypt/Encryptor.java @@ -24,9 +24,11 @@ import javax.crypto.SecretKey; import org.apache.poi.poifs.filesystem.DirectoryNode;
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.OPOIFSFileSystem;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
public abstract class Encryptor {
+ protected static final String DEFAULT_POIFS_ENTRY = Decryptor.DEFAULT_POIFS_ENTRY;
private SecretKey secretKey;
/**
@@ -50,7 +52,9 @@ public abstract class Encryptor { public OutputStream getDataStream(NPOIFSFileSystem fs) throws IOException, GeneralSecurityException {
return getDataStream(fs.getRoot());
}
-
+ public OutputStream getDataStream(OPOIFSFileSystem fs) throws IOException, GeneralSecurityException {
+ return getDataStream(fs.getRoot());
+ }
public OutputStream getDataStream(POIFSFileSystem fs) throws IOException, GeneralSecurityException {
return getDataStream(fs.getRoot());
}
diff --git a/src/java/org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4Decryptor.java b/src/java/org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4Decryptor.java index 40eab54e3a..a2d3d6f0e1 100644 --- a/src/java/org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4Decryptor.java +++ b/src/java/org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4Decryptor.java @@ -118,7 +118,7 @@ public class BinaryRC4Decryptor extends Decryptor { public InputStream getDataStream(DirectoryNode dir) throws IOException,
GeneralSecurityException {
- DocumentInputStream dis = dir.createDocumentInputStream("EncryptedPackage");
+ DocumentInputStream dis = dir.createDocumentInputStream(DEFAULT_POIFS_ENTRY);
_length = dis.readLong();
BinaryRC4CipherInputStream cipherStream = new BinaryRC4CipherInputStream(dis, _length);
return cipherStream;
@@ -131,4 +131,4 @@ public class BinaryRC4Decryptor extends Decryptor { return _length;
}
-}
\ No newline at end of file +}
diff --git a/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java b/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java index c1ae13ceeb..1e470d7263 100644 --- a/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java +++ b/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java @@ -40,7 +40,7 @@ import org.apache.poi.poifs.crypt.HashAlgorithm; import org.apache.poi.poifs.filesystem.DirectoryNode;
import org.apache.poi.poifs.filesystem.DocumentInputStream;
import org.apache.poi.poifs.filesystem.DocumentNode;
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.BoundedInputStream;
@@ -200,7 +200,7 @@ public class CryptoAPIDecryptor extends Decryptor { @SuppressWarnings("unused")
public InputStream getDataStream(DirectoryNode dir)
throws IOException, GeneralSecurityException {
- POIFSFileSystem fsOut = new POIFSFileSystem();
+ NPOIFSFileSystem fsOut = new NPOIFSFileSystem();
DocumentNode es = (DocumentNode) dir.getEntry("EncryptedSummary");
DocumentInputStream dis = dir.createDocumentInputStream(es);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -240,6 +240,7 @@ public class CryptoAPIDecryptor extends Decryptor { sbis = null;
bos.reset();
fsOut.writeFilesystem(bos);
+ fsOut.close();
_length = bos.size();
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
return bis;
diff --git a/src/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java b/src/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java index 2b2c75b520..1d6ddd398e 100644 --- a/src/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java +++ b/src/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java @@ -123,7 +123,7 @@ public class StandardDecryptor extends Decryptor { } public InputStream getDataStream(DirectoryNode dir) throws IOException { - DocumentInputStream dis = dir.createDocumentInputStream("EncryptedPackage"); + DocumentInputStream dis = dir.createDocumentInputStream(DEFAULT_POIFS_ENTRY); _length = dis.readLong(); diff --git a/src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptor.java b/src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptor.java index 7049c715de..ae6304fbb5 100644 --- a/src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptor.java +++ b/src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptor.java @@ -166,7 +166,7 @@ public class StandardEncryptor extends Encryptor { void writeToPOIFS() throws IOException {
int oleStreamSize = (int)(fileOut.length()+LittleEndianConsts.LONG_SIZE);
- dir.createDocument("EncryptedPackage", oleStreamSize, this);
+ dir.createDocument(DEFAULT_POIFS_ENTRY, oleStreamSize, this);
// TODO: any properties???
}
diff --git a/src/java/org/apache/poi/poifs/dev/POIFSDump.java b/src/java/org/apache/poi/poifs/dev/POIFSDump.java index ace19d8d18..ce7d9e441a 100644 --- a/src/java/org/apache/poi/poifs/dev/POIFSDump.java +++ b/src/java/org/apache/poi/poifs/dev/POIFSDump.java @@ -16,27 +16,54 @@ ==================================================================== */ package org.apache.poi.poifs.dev; -import org.apache.poi.poifs.filesystem.*; - -import java.io.FileInputStream; import java.io.File; -import java.io.IOException; +import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.lang.reflect.Field; +import java.nio.ByteBuffer; import java.util.Iterator; +import org.apache.poi.poifs.common.POIFSConstants; +import org.apache.poi.poifs.filesystem.DirectoryEntry; +import org.apache.poi.poifs.filesystem.DocumentInputStream; +import org.apache.poi.poifs.filesystem.DocumentNode; +import org.apache.poi.poifs.filesystem.Entry; +import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; +import org.apache.poi.poifs.filesystem.NPOIFSStream; +import org.apache.poi.poifs.property.NPropertyTable; +import org.apache.poi.poifs.storage.HeaderBlock; + /** - * * Dump internal structure of a OLE2 file into file system - * - * @author Yegor Kozlov */ public class POIFSDump { - public static void main(String[] args) throws Exception { + if (args.length == 0) { + System.err.println("Must specify at least one file to dump"); + System.exit(1); + } + + boolean dumpProps = false, dumpMini = false; for (int i = 0; i < args.length; i++) { + if (args[i].equalsIgnoreCase("-dumprops") || + args[i].equalsIgnoreCase("-dump-props") || + args[i].equalsIgnoreCase("-dump-properties")) { + dumpProps = true; + continue; + } + if (args[i].equalsIgnoreCase("-dumpmini") || + args[i].equalsIgnoreCase("-dump-mini") || + args[i].equalsIgnoreCase("-dump-ministream") || + args[i].equalsIgnoreCase("-dump-mini-stream")) { + dumpMini = true; + continue; + } + System.out.println("Dumping " + args[i]); FileInputStream is = new FileInputStream(args[i]); - POIFSFileSystem fs = new POIFSFileSystem(is); + NPOIFSFileSystem fs = new NPOIFSFileSystem(is); is.close(); DirectoryEntry root = fs.getRoot(); @@ -44,13 +71,39 @@ public class POIFSDump { file.mkdir(); dump(root, file); + + if (dumpProps) { + HeaderBlock header = getHeaderBlock(fs); + dump(fs, header.getPropertyStart(), "properties", file); + } + if (dumpMini) { + NPropertyTable props = getPropertyTable(fs); + int startBlock = props.getRoot().getStartBlock(); + if (startBlock == POIFSConstants.END_OF_CHAIN) { + System.err.println("No Mini Stream in file"); + } else { + dump(fs, startBlock, "mini-stream", file); + } + } } } - + + protected static HeaderBlock getHeaderBlock(NPOIFSFileSystem fs) throws Exception { + Field headerF = NPOIFSFileSystem.class.getDeclaredField("_header"); + headerF.setAccessible(true); + HeaderBlock header = (HeaderBlock)headerF.get(fs); + return header; + } + protected static NPropertyTable getPropertyTable(NPOIFSFileSystem fs) throws Exception { + Field ptF = NPOIFSFileSystem.class.getDeclaredField("_property_table"); + ptF.setAccessible(true); + NPropertyTable table = (NPropertyTable)ptF.get(fs); + return table; + } public static void dump(DirectoryEntry root, File parent) throws IOException { - for(Iterator it = root.getEntries(); it.hasNext();){ - Entry entry = (Entry)it.next(); + for(Iterator<Entry> it = root.getEntries(); it.hasNext();){ + Entry entry = it.next(); if(entry instanceof DocumentNode){ DocumentNode node = (DocumentNode)entry; DocumentInputStream is = new DocumentInputStream(node); @@ -58,9 +111,12 @@ public class POIFSDump { is.read(bytes); is.close(); - FileOutputStream out = new FileOutputStream(new File(parent, node.getName().trim())); - out.write(bytes); - out.close(); + OutputStream out = new FileOutputStream(new File(parent, node.getName().trim())); + try { + out.write(bytes); + } finally { + out.close(); + } } else if (entry instanceof DirectoryEntry){ DirectoryEntry dir = (DirectoryEntry)entry; File file = new File(parent, entry.getName()); @@ -71,4 +127,17 @@ public class POIFSDump { } } } + public static void dump(NPOIFSFileSystem fs, int startBlock, String name, File parent) throws IOException { + File file = new File(parent, name); + FileOutputStream out = new FileOutputStream(file); + NPOIFSStream stream = new NPOIFSStream(fs, startBlock); + + byte[] b = new byte[fs.getBigBlockSize()]; + for (ByteBuffer bb : stream) { + int len = bb.remaining(); + bb.get(b); + out.write(b, 0, len); + } + out.close(); + } } diff --git a/src/java/org/apache/poi/poifs/dev/POIFSHeaderDumper.java b/src/java/org/apache/poi/poifs/dev/POIFSHeaderDumper.java index 78ed986a40..e321c8b9b7 100644 --- a/src/java/org/apache/poi/poifs/dev/POIFSHeaderDumper.java +++ b/src/java/org/apache/poi/poifs/dev/POIFSHeaderDumper.java @@ -24,9 +24,10 @@ import java.lang.reflect.Method; import org.apache.poi.poifs.common.POIFSBigBlockSize; import org.apache.poi.poifs.common.POIFSConstants; +import org.apache.poi.poifs.property.DirectoryProperty; +import org.apache.poi.poifs.property.Property; import org.apache.poi.poifs.property.PropertyTable; import org.apache.poi.poifs.storage.BlockAllocationTableReader; -import org.apache.poi.poifs.storage.BlockList; import org.apache.poi.poifs.storage.HeaderBlock; import org.apache.poi.poifs.storage.ListManagedBlock; import org.apache.poi.poifs.storage.RawDataBlockList; @@ -42,111 +43,146 @@ import org.apache.poi.util.IntList; * down the source of corruption in a file. */ public class POIFSHeaderDumper { - /** - * Display the entries of multiple POIFS files - * - * @param args the names of the files to be displayed - */ - public static void main(final String args[]) throws Exception { - if (args.length == 0) { - System.err.println("Must specify at least one file to view"); - System.exit(1); - } - - for (int j = 0; j < args.length; j++) { - viewFile(args[j]); - } - } - - public static void viewFile(final String filename) throws Exception { - InputStream inp = new FileInputStream(filename); - - // Header - HeaderBlock header_block = new HeaderBlock(inp); - displayHeader(header_block); - - // Raw blocks - POIFSBigBlockSize bigBlockSize = header_block.getBigBlockSize(); - RawDataBlockList data_blocks = new RawDataBlockList(inp, bigBlockSize); - displayRawBlocksSummary(data_blocks); - - // Main FAT Table - BlockAllocationTableReader batReader = - new BlockAllocationTableReader( - header_block.getBigBlockSize(), - header_block.getBATCount(), - header_block.getBATArray(), - header_block.getXBATCount(), - header_block.getXBATIndex(), - data_blocks); - displayBATReader(batReader); - - // Properties Table - PropertyTable properties = - new PropertyTable(header_block, data_blocks); - - // Mini Fat - BlockList sbat = - SmallBlockTableReader.getSmallDocumentBlocks( - bigBlockSize, data_blocks, properties.getRoot(), - header_block.getSBATStart() - ); - } - - public static void displayHeader(HeaderBlock header_block) throws Exception { - System.out.println("Header Details:"); - System.out.println(" Block size: " + header_block.getBigBlockSize().getBigBlockSize()); - System.out.println(" BAT (FAT) header blocks: " + header_block.getBATArray().length); - System.out.println(" BAT (FAT) block count: " + header_block.getBATCount()); - System.out.println(" XBAT (FAT) block count: " + header_block.getXBATCount()); - System.out.println(" XBAT (FAT) block 1 at: " + header_block.getXBATIndex()); - System.out.println(" SBAT (MiniFAT) block count: " + header_block.getSBATCount()); - System.out.println(" SBAT (MiniFAT) block 1 at: " + header_block.getSBATStart()); - System.out.println(" Property table at: " + header_block.getPropertyStart()); - System.out.println(""); - } - - public static void displayRawBlocksSummary(RawDataBlockList data_blocks) throws Exception { - System.out.println("Raw Blocks Details:"); - System.out.println(" Number of blocks: " + data_blocks.blockCount()); - - Method gbm = data_blocks.getClass().getSuperclass().getDeclaredMethod("get", int.class); - gbm.setAccessible(true); - - for(int i=0; i<Math.min(16, data_blocks.blockCount()); i++) { - ListManagedBlock block = (ListManagedBlock)gbm.invoke(data_blocks, Integer.valueOf(i)); - byte[] data = new byte[Math.min(48, block.getData().length)]; - System.arraycopy(block.getData(), 0, data, 0, data.length); - - System.out.println(" Block #" + i + ":"); - System.out.println(HexDump.dump(data, 0, 0)); - } - - System.out.println(""); - } - - public static void displayBATReader(BlockAllocationTableReader batReader) throws Exception { - System.out.println("Sectors, as referenced from the FAT:"); - Field entriesF = batReader.getClass().getDeclaredField("_entries"); - entriesF.setAccessible(true); - IntList entries = (IntList)entriesF.get(batReader); - - for(int i=0; i<entries.size(); i++) { - int bn = entries.get(i); - String bnS = Integer.toString(bn); - if(bn == POIFSConstants.END_OF_CHAIN) { - bnS = "End Of Chain"; - } else if(bn == POIFSConstants.DIFAT_SECTOR_BLOCK) { - bnS = "DI Fat Block"; - } else if(bn == POIFSConstants.FAT_SECTOR_BLOCK) { - bnS = "Normal Fat Block"; - } else if(bn == POIFSConstants.UNUSED_BLOCK) { - bnS = "Block Not Used (Free)"; - } - - System.out.println(" Block # " + i + " -> " + bnS); - } - - System.out.println(""); - } + /** + * Display the entries of multiple POIFS files + * + * @param args the names of the files to be displayed + */ + public static void main(final String args[]) throws Exception { + if (args.length == 0) { + System.err.println("Must specify at least one file to view"); + System.exit(1); + } + + for (int j = 0; j < args.length; j++) { + viewFile(args[j]); + } + } + + public static void viewFile(final String filename) throws Exception { + System.out.println("Dumping headers from: " + filename); + InputStream inp = new FileInputStream(filename); + + // Header + HeaderBlock header_block = new HeaderBlock(inp); + displayHeader(header_block); + + // Raw blocks + POIFSBigBlockSize bigBlockSize = header_block.getBigBlockSize(); + RawDataBlockList data_blocks = new RawDataBlockList(inp, bigBlockSize); + displayRawBlocksSummary(data_blocks); + + // Main FAT Table + BlockAllocationTableReader batReader = + new BlockAllocationTableReader( + header_block.getBigBlockSize(), + header_block.getBATCount(), + header_block.getBATArray(), + header_block.getXBATCount(), + header_block.getXBATIndex(), + data_blocks); + displayBATReader("Big Blocks", batReader); + + // Properties Table + PropertyTable properties = + new PropertyTable(header_block, data_blocks); + + // Mini Fat + BlockAllocationTableReader sbatReader = + SmallBlockTableReader._getSmallDocumentBlockReader( + bigBlockSize, data_blocks, properties.getRoot(), + header_block.getSBATStart() + ); + displayBATReader("Small Blocks", sbatReader); + + // Summary of the properties + displayPropertiesSummary(properties); + } + + public static void displayHeader(HeaderBlock header_block) throws Exception { + System.out.println("Header Details:"); + System.out.println(" Block size: " + header_block.getBigBlockSize().getBigBlockSize()); + System.out.println(" BAT (FAT) header blocks: " + header_block.getBATArray().length); + System.out.println(" BAT (FAT) block count: " + header_block.getBATCount()); + if (header_block.getBATCount() > 0) + System.out.println(" BAT (FAT) block 1 at: " + header_block.getBATArray()[0]); + System.out.println(" XBAT (FAT) block count: " + header_block.getXBATCount()); + System.out.println(" XBAT (FAT) block 1 at: " + header_block.getXBATIndex()); + System.out.println(" SBAT (MiniFAT) block count: " + header_block.getSBATCount()); + System.out.println(" SBAT (MiniFAT) block 1 at: " + header_block.getSBATStart()); + System.out.println(" Property table at: " + header_block.getPropertyStart()); + System.out.println(""); + } + + public static void displayRawBlocksSummary(RawDataBlockList data_blocks) throws Exception { + System.out.println("Raw Blocks Details:"); + System.out.println(" Number of blocks: " + data_blocks.blockCount()); + + Method gbm = data_blocks.getClass().getSuperclass().getDeclaredMethod("get", int.class); + gbm.setAccessible(true); + + for(int i=0; i<Math.min(16, data_blocks.blockCount()); i++) { + ListManagedBlock block = (ListManagedBlock)gbm.invoke(data_blocks, Integer.valueOf(i)); + byte[] data = new byte[Math.min(48, block.getData().length)]; + System.arraycopy(block.getData(), 0, data, 0, data.length); + + System.out.println(" Block #" + i + ":"); + System.out.println(HexDump.dump(data, 0, 0)); + } + + System.out.println(""); + } + + public static void displayBATReader(String type, BlockAllocationTableReader batReader) throws Exception { + System.out.println("Sectors, as referenced from the "+type+" FAT:"); + Field entriesF = batReader.getClass().getDeclaredField("_entries"); + entriesF.setAccessible(true); + IntList entries = (IntList)entriesF.get(batReader); + + for(int i=0; i<entries.size(); i++) { + int bn = entries.get(i); + String bnS = Integer.toString(bn); + if(bn == POIFSConstants.END_OF_CHAIN) { + bnS = "End Of Chain"; + } else if(bn == POIFSConstants.DIFAT_SECTOR_BLOCK) { + bnS = "DI Fat Block"; + } else if(bn == POIFSConstants.FAT_SECTOR_BLOCK) { + bnS = "Normal Fat Block"; + } else if(bn == POIFSConstants.UNUSED_BLOCK) { + bnS = "Block Not Used (Free)"; + } + + System.out.println(" Block # " + i + " -> " + bnS); + } + + System.out.println(""); + } + + public static void displayPropertiesSummary(PropertyTable properties) { + System.out.println("Mini Stream starts at " + properties.getRoot().getStartBlock()); + System.out.println("Mini Stream length is " + properties.getRoot().getSize()); + System.out.println(); + + System.out.println("Properties and their block start:"); + displayProperties(properties.getRoot(), ""); + System.out.println(""); + } + public static void displayProperties(DirectoryProperty prop, String indent) { + String nextIndent = indent + " "; + System.out.println(indent + "-> " + prop.getName()); + for (Property cp : prop) { + if (cp instanceof DirectoryProperty) { + displayProperties((DirectoryProperty)cp, nextIndent); + } else { + System.out.println(nextIndent + "=> " + cp.getName()); + System.out.print(nextIndent + " " + cp.getSize() + " bytes in "); + if (cp.shouldUseSmallBlocks()) { + System.out.print("mini"); + } else { + System.out.print("main"); + } + System.out.println(" stream, starts at " + cp.getStartBlock()); + } + } + } } diff --git a/src/java/org/apache/poi/poifs/dev/POIFSViewer.java b/src/java/org/apache/poi/poifs/dev/POIFSViewer.java index 8b81734265..4614376db2 100644 --- a/src/java/org/apache/poi/poifs/dev/POIFSViewer.java +++ b/src/java/org/apache/poi/poifs/dev/POIFSViewer.java @@ -19,12 +19,12 @@ package org.apache.poi.poifs.dev; -import java.io.FileInputStream; +import java.io.File; import java.io.IOException; import java.util.Iterator; import java.util.List; -import org.apache.poi.poifs.filesystem.POIFSFileSystem; +import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; /** * A simple viewer for POIFS files @@ -76,10 +76,10 @@ public class POIFSViewer try { POIFSViewable fs = - new POIFSFileSystem(new FileInputStream(filename)); - List<String> strings = POIFSViewEngine.inspectViewable(fs, true, + new NPOIFSFileSystem(new File(filename)); + List<String> strings = POIFSViewEngine.inspectViewable(fs, true, 0, " "); - Iterator<String> iter = strings.iterator(); + Iterator<String> iter = strings.iterator(); while (iter.hasNext()) { diff --git a/src/java/org/apache/poi/poifs/eventfilesystem/POIFSReader.java b/src/java/org/apache/poi/poifs/eventfilesystem/POIFSReader.java index 567527523e..a288709185 100644 --- a/src/java/org/apache/poi/poifs/eventfilesystem/POIFSReader.java +++ b/src/java/org/apache/poi/poifs/eventfilesystem/POIFSReader.java @@ -24,7 +24,7 @@ import java.io.*; import java.util.*; import org.apache.poi.poifs.filesystem.DocumentInputStream; -import org.apache.poi.poifs.filesystem.POIFSDocument; +import org.apache.poi.poifs.filesystem.OPOIFSDocument; import org.apache.poi.poifs.filesystem.POIFSDocumentPath; import org.apache.poi.poifs.property.DirectoryProperty; import org.apache.poi.poifs.property.Property; @@ -240,19 +240,19 @@ public class POIFSReader if (listeners.hasNext()) { - int size = property.getSize(); - POIFSDocument document = null; + int size = property.getSize(); + OPOIFSDocument document = null; if (property.shouldUseSmallBlocks()) { document = - new POIFSDocument(name, small_blocks + new OPOIFSDocument(name, small_blocks .fetchBlocks(startBlock, -1), size); } else { document = - new POIFSDocument(name, big_blocks + new OPOIFSDocument(name, big_blocks .fetchBlocks(startBlock, -1), size); } while (listeners.hasNext()) diff --git a/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java b/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java index 8d39bbfa24..9be71a5ccf 100644 --- a/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java +++ b/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java @@ -37,8 +37,6 @@ import org.apache.poi.poifs.property.Property; /** * Simple implementation of DirectoryEntry - * - * @author Marc Johnson (mjohnson at apache dot org) */ public class DirectoryNode extends EntryNode @@ -50,9 +48,9 @@ public class DirectoryNode // Our list of entries, kept sorted to preserve order private ArrayList<Entry> _entries; - // Only one of these two will exist - // the POIFSFileSystem we belong to - private POIFSFileSystem _ofilesystem; + // Only one of these two will exist + // the OPOIFSFileSystem we belong to + private OPOIFSFileSystem _ofilesystem; // the NPOIFSFileSytem we belong to private NPOIFSFileSystem _nfilesystem; @@ -64,11 +62,11 @@ public class DirectoryNode * is intended strictly for the internal use of this package * * @param property the DirectoryProperty for this DirectoryEntry - * @param filesystem the POIFSFileSystem we belong to + * @param filesystem the OPOIFSFileSystem we belong to * @param parent the parent of this entry */ DirectoryNode(final DirectoryProperty property, - final POIFSFileSystem filesystem, + final OPOIFSFileSystem filesystem, final DirectoryNode parent) { this(property, parent, filesystem, (NPOIFSFileSystem)null); @@ -86,12 +84,12 @@ public class DirectoryNode final NPOIFSFileSystem nfilesystem, final DirectoryNode parent) { - this(property, parent, (POIFSFileSystem)null, nfilesystem); + this(property, parent, (OPOIFSFileSystem)null, nfilesystem); } private DirectoryNode(final DirectoryProperty property, final DirectoryNode parent, - final POIFSFileSystem ofilesystem, + final OPOIFSFileSystem ofilesystem, final NPOIFSFileSystem nfilesystem) { super(property, parent); @@ -148,12 +146,24 @@ public class DirectoryNode /** * @return the filesystem that this belongs to */ - public POIFSFileSystem getFileSystem() + public NPOIFSFileSystem getFileSystem() + { + return _nfilesystem; + } + + /** + * If this is OPOIFS based, return the NPOIFSFileSystem + * that this belong to, otherwise Null if NPOIFS based + * @return the filesystem that this belongs to + */ + public OPOIFSFileSystem getOFileSystem() { return _ofilesystem; } /** + * If this is NPOIFS based, return the NPOIFSFileSystem + * that this belong to, otherwise Null if OPOIFS based * @return the filesystem that this belongs to */ public NPOIFSFileSystem getNFileSystem() @@ -210,7 +220,7 @@ public class DirectoryNode * * @exception IOException */ - DocumentEntry createDocument(final POIFSDocument document) + DocumentEntry createDocument(final OPOIFSDocument document) throws IOException { DocumentProperty property = document.getDocumentProperty(); @@ -411,7 +421,7 @@ public class DirectoryNode if(_nfilesystem != null) { return createDocument(new NPOIFSDocument(name, _nfilesystem, stream)); } else { - return createDocument(new POIFSDocument(name, stream)); + return createDocument(new OPOIFSDocument(name, stream)); } } @@ -434,7 +444,7 @@ public class DirectoryNode if(_nfilesystem != null) { return createDocument(new NPOIFSDocument(name, size, _nfilesystem, writer)); } else { - return createDocument(new POIFSDocument(name, size, _path, writer)); + return createDocument(new OPOIFSDocument(name, size, _path, writer)); } } diff --git a/src/java/org/apache/poi/poifs/filesystem/DocumentInputStream.java b/src/java/org/apache/poi/poifs/filesystem/DocumentInputStream.java index 6c6b6100c0..82959c7ffa 100644 --- a/src/java/org/apache/poi/poifs/filesystem/DocumentInputStream.java +++ b/src/java/org/apache/poi/poifs/filesystem/DocumentInputStream.java @@ -58,7 +58,7 @@ public class DocumentInputStream extends InputStream implements LittleEndianInpu if(documentNode.getDocument() != null) { delegate = new ODocumentInputStream(document); - } else if(parentNode.getFileSystem() != null) { + } else if(parentNode.getOFileSystem() != null) { delegate = new ODocumentInputStream(document); } else if(parentNode.getNFileSystem() != null) { delegate = new NDocumentInputStream(document); @@ -72,7 +72,7 @@ public class DocumentInputStream extends InputStream implements LittleEndianInpu * * @param document the Document to be read */ - public DocumentInputStream(POIFSDocument document) { + public DocumentInputStream(OPOIFSDocument document) { delegate = new ODocumentInputStream(document); } diff --git a/src/java/org/apache/poi/poifs/filesystem/DocumentNode.java b/src/java/org/apache/poi/poifs/filesystem/DocumentNode.java index 9caafb7668..7a5bf69009 100644 --- a/src/java/org/apache/poi/poifs/filesystem/DocumentNode.java +++ b/src/java/org/apache/poi/poifs/filesystem/DocumentNode.java @@ -27,18 +27,15 @@ import org.apache.poi.poifs.dev.POIFSViewable; import org.apache.poi.poifs.property.DocumentProperty; /** - * Simple implementation of DocumentEntry - * - * @author Marc Johnson (mjohnson at apache dot org) + * Simple implementation of DocumentEntry for OPOIFS */ - public class DocumentNode extends EntryNode implements DocumentEntry, POIFSViewable { // underlying POIFSDocument instance - private POIFSDocument _document; + private OPOIFSDocument _document; /** * create a DocumentNode. This method is not public by design; it @@ -59,8 +56,7 @@ public class DocumentNode * * @return the internal POIFSDocument */ - - POIFSDocument getDocument() + OPOIFSDocument getDocument() { return _document; } diff --git a/src/java/org/apache/poi/poifs/filesystem/EntryUtils.java b/src/java/org/apache/poi/poifs/filesystem/EntryUtils.java index 4bce0641ab..d8a55563a2 100644 --- a/src/java/org/apache/poi/poifs/filesystem/EntryUtils.java +++ b/src/java/org/apache/poi/poifs/filesystem/EntryUtils.java @@ -124,8 +124,21 @@ public class EntryUtils * @param target * is the target POIFS to copy to */ - public static void copyNodes( POIFSFileSystem source, - POIFSFileSystem target ) throws IOException + public static void copyNodes( OPOIFSFileSystem source, + OPOIFSFileSystem target ) throws IOException + { + copyNodes( source.getRoot(), target.getRoot() ); + } + /** + * Copies all nodes from one POIFS to the other + * + * @param source + * is the source POIFS to copy from + * @param target + * is the target POIFS to copy to + */ + public static void copyNodes( NPOIFSFileSystem source, + NPOIFSFileSystem target ) throws IOException { copyNodes( source.getRoot(), target.getRoot() ); } @@ -140,8 +153,26 @@ public class EntryUtils * @param target is the target POIFS to copy to * @param excepts is a list of Entry Names to be excluded from the copy */ - public static void copyNodes( POIFSFileSystem source, - POIFSFileSystem target, List<String> excepts ) throws IOException + public static void copyNodes( OPOIFSFileSystem source, + OPOIFSFileSystem target, List<String> excepts ) throws IOException + { + copyNodes( + new FilteringDirectoryNode(source.getRoot(), excepts), + new FilteringDirectoryNode(target.getRoot(), excepts) + ); + } + /** + * Copies nodes from one POIFS to the other, minus the excepts. + * This delegates the filtering work to {@link FilteringDirectoryNode}, + * so excepts can be of the form "NodeToExclude" or + * "FilteringDirectory/ExcludedChildNode" + * + * @param source is the source POIFS to copy from + * @param target is the target POIFS to copy to + * @param excepts is a list of Entry Names to be excluded from the copy + */ + public static void copyNodes( NPOIFSFileSystem source, + NPOIFSFileSystem target, List<String> excepts ) throws IOException { copyNodes( new FilteringDirectoryNode(source.getRoot(), excepts), diff --git a/src/java/org/apache/poi/poifs/filesystem/NPOIFSDocument.java b/src/java/org/apache/poi/poifs/filesystem/NPOIFSDocument.java index 7846ed0dfc..c94e427b92 100644 --- a/src/java/org/apache/poi/poifs/filesystem/NPOIFSDocument.java +++ b/src/java/org/apache/poi/poifs/filesystem/NPOIFSDocument.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteBuffer; +import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -143,8 +144,17 @@ public final class NPOIFSDocument implements POIFSViewable { os.write(buf, 0, readBytes); } - os.close(); + // Pad to the end of the block with -1s + int usedInBlock = length % _block_size; + if (usedInBlock != 0 && usedInBlock != _block_size) { + int toBlockEnd = _block_size - usedInBlock; + byte[] padding = new byte[toBlockEnd]; + Arrays.fill(padding, (byte)0xFF); + os.write(padding); + } + // Tidy and return the length + os.close(); return length; } diff --git a/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java b/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java index f21f6a39a0..c27ba3cd14 100644 --- a/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java +++ b/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java @@ -36,6 +36,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; +import org.apache.poi.EmptyFileException; import org.apache.poi.poifs.common.POIFSBigBlockSize; import org.apache.poi.poifs.common.POIFSConstants; import org.apache.poi.poifs.dev.POIFSViewable; @@ -114,17 +115,18 @@ public class NPOIFSFileSystem extends BlockStore { this(true); - // Mark us as having a single empty BAT at offset 0 + // Reserve block 0 for the start of the Properties Table + // Create a single empty BAT, at pop that at offset 1 _header.setBATCount(1); - _header.setBATArray(new int[] { 0 }); + _header.setBATArray(new int[] { 1 }); BATBlock bb = BATBlock.createEmptyBATBlock(bigBlockSize, false); - bb.setOurBlockIndex(0); + bb.setOurBlockIndex(1); _bat_blocks.add(bb); - setNextBlock(0, POIFSConstants.FAT_SECTOR_BLOCK); - setNextBlock(1, POIFSConstants.END_OF_CHAIN); + setNextBlock(0, POIFSConstants.END_OF_CHAIN); + setNextBlock(1, POIFSConstants.FAT_SECTOR_BLOCK); - _property_table.setStartBlock(POIFSConstants.END_OF_CHAIN); + _property_table.setStartBlock(0); } /** @@ -210,6 +212,9 @@ public class NPOIFSFileSystem extends BlockStore try { // Initialize the datasource if (srcFile != null) { + if (srcFile.length() == 0) + throw new EmptyFileException(); + FileBackedDataSource d = new FileBackedDataSource(srcFile, readOnly); channel = d.getChannel(); _data = d; @@ -236,7 +241,10 @@ public class NPOIFSFileSystem extends BlockStore // TODO Decide if we can handle these better whilst // still sticking to the iterator contract if(closeChannelOnError) { - channel.close(); + if (channel != null) { + channel.close(); + channel = null; + } } throw e; } @@ -370,6 +378,15 @@ public class NPOIFSFileSystem extends BlockStore } /** + * Checks if the supplied first 8 bytes of a stream / file + * has a POIFS (OLE2) header. + */ + public static boolean hasPOIFSHeader(byte[] header8Bytes) { + LongField signature = new LongField(HeaderBlockConstants._signature_offset, header8Bytes); + return (signature.get() == HeaderBlockConstants._signature); + } + + /** * Read and process the PropertiesTable and the * FAT / XFAT blocks, so that we're ready to * work with the file @@ -420,7 +437,7 @@ public class NPOIFSFileSystem extends BlockStore List<BATBlock> sbats = new ArrayList<BATBlock>(); _mini_store = new NPOIFSMiniStore(this, _property_table.getRoot(), sbats, _header); nextAt = _header.getSBATStart(); - for(int i=0; i<_header.getSBATCount(); i++) { + for(int i=0; i<_header.getSBATCount() && nextAt != POIFSConstants.END_OF_CHAIN; i++) { loopDetector.claim(nextAt); ByteBuffer fatData = getBlockAt(nextAt); sfat = BATBlock.createBATBlock(bigBlockSize, fatData); @@ -749,6 +766,10 @@ public class NPOIFSFileSystem extends BlockStore * to their backing blocks */ private void syncWithDataSource() throws IOException { + // Mini Stream + SBATs first, as mini-stream details have + // to be stored in the Root Property + _mini_store.syncWithDataSource(); + // Properties NPOIFSStream propStream = new NPOIFSStream(this, _header.getPropertyStart()); _property_table.preWrite(); @@ -769,9 +790,6 @@ public class NPOIFSFileSystem extends BlockStore ByteBuffer block = getBlockAt(bat.getOurBlockIndex()); BlockAllocationTableWriter.writeBlock(bat, block); } - - // SBATs - _mini_store.syncWithDataSource(); } /** diff --git a/src/java/org/apache/poi/poifs/filesystem/NPOIFSMiniStore.java b/src/java/org/apache/poi/poifs/filesystem/NPOIFSMiniStore.java index 308ae15c74..b784058bc5 100644 --- a/src/java/org/apache/poi/poifs/filesystem/NPOIFSMiniStore.java +++ b/src/java/org/apache/poi/poifs/filesystem/NPOIFSMiniStore.java @@ -242,12 +242,24 @@ public class NPOIFSMiniStore extends BlockStore } /** - * Writes the SBATs to their backing blocks + * Writes the SBATs to their backing blocks, and updates + * the mini-stream size in the properties. Stream size is + * based on full blocks used, not the data within the streams */ protected void syncWithDataSource() throws IOException { - for(BATBlock sbat : _sbat_blocks) { + int blocksUsed = 0; + for (BATBlock sbat : _sbat_blocks) { ByteBuffer block = _filesystem.getBlockAt(sbat.getOurBlockIndex()); BlockAllocationTableWriter.writeBlock(sbat, block); + + if (!sbat.hasFreeSectors()) { + blocksUsed += _filesystem.getBigBlockSizeDetails().getBATEntriesPerBlock(); + } else { + blocksUsed += sbat.getUsedSectors(false); + } } + // Set the size on the root in terms of the number of SBAT blocks + // RootProperty.setSize does the sbat -> bytes conversion for us + _filesystem._get_property_table().getRoot().setSize(blocksUsed); } } diff --git a/src/java/org/apache/poi/poifs/filesystem/NPOIFSStream.java b/src/java/org/apache/poi/poifs/filesystem/NPOIFSStream.java index 5d444b8cb9..da24fc3836 100644 --- a/src/java/org/apache/poi/poifs/filesystem/NPOIFSStream.java +++ b/src/java/org/apache/poi/poifs/filesystem/NPOIFSStream.java @@ -256,8 +256,10 @@ public class NPOIFSStream implements Iterable<ByteBuffer> NPOIFSStream toFree = new NPOIFSStream(blockStore, nextBlock); toFree.free(loopDetector); - // Mark the end of the stream - blockStore.setNextBlock(prevBlock, POIFSConstants.END_OF_CHAIN); + // Mark the end of the stream, if we have any data + if (prevBlock != POIFSConstants.END_OF_CHAIN) { + blockStore.setNextBlock(prevBlock, POIFSConstants.END_OF_CHAIN); + } } } } diff --git a/src/java/org/apache/poi/poifs/filesystem/ODocumentInputStream.java b/src/java/org/apache/poi/poifs/filesystem/ODocumentInputStream.java index a1bc5da95f..858e2d9d9b 100644 --- a/src/java/org/apache/poi/poifs/filesystem/ODocumentInputStream.java +++ b/src/java/org/apache/poi/poifs/filesystem/ODocumentInputStream.java @@ -23,9 +23,7 @@ import org.apache.poi.poifs.storage.DataInputBlock; /** * This class provides methods to read a DocumentEntry managed by a - * {@link POIFSFileSystem} instance. - * - * @author Marc Johnson (mjohnson at apache dot org) + * {@link OPOIFSFileSystem} instance. */ public final class ODocumentInputStream extends DocumentInputStream { /** current offset into the Document */ @@ -41,7 +39,7 @@ public final class ODocumentInputStream extends DocumentInputStream { private boolean _closed; /** the actual Document */ - private POIFSDocument _document; + private OPOIFSDocument _document; /** the data block containing the current stream pointer */ private DataInputBlock _currentBlock; @@ -59,7 +57,7 @@ public final class ODocumentInputStream extends DocumentInputStream { throw new IOException("Cannot open internal document storage"); } DocumentNode documentNode = (DocumentNode)document; - if(documentNode.getDocument() == null) { + if (documentNode.getDocument() == null) { throw new IOException("Cannot open internal document storage"); } @@ -76,7 +74,7 @@ public final class ODocumentInputStream extends DocumentInputStream { * * @param document the Document to be read */ - public ODocumentInputStream(POIFSDocument document) { + public ODocumentInputStream(OPOIFSDocument document) { _current_offset = 0; _marked_offset = 0; _document_size = document.getSize(); diff --git a/src/java/org/apache/poi/poifs/filesystem/POIFSDocument.java b/src/java/org/apache/poi/poifs/filesystem/OPOIFSDocument.java index c6b35fd880..05b21baeaa 100644 --- a/src/java/org/apache/poi/poifs/filesystem/POIFSDocument.java +++ b/src/java/org/apache/poi/poifs/filesystem/OPOIFSDocument.java @@ -40,11 +40,10 @@ import org.apache.poi.poifs.storage.SmallDocumentBlock; import org.apache.poi.util.HexDump; /** - * This class manages a document in the POIFS filesystem. - * - * @author Marc Johnson (mjohnson at apache dot org) + * This class manages a document in a old-style + * OPOIFS filesystem. */ -public final class POIFSDocument implements BATManaged, BlockWritable, POIFSViewable { +public final class OPOIFSDocument implements BATManaged, BlockWritable, POIFSViewable { private static final DocumentBlock[] EMPTY_BIG_BLOCK_ARRAY = { }; private static final SmallDocumentBlock[] EMPTY_SMALL_BLOCK_ARRAY = { }; private DocumentProperty _property; @@ -63,7 +62,7 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView * @param blocks the big blocks making up the POIFSDocument * @param length the actual length of the POIFSDocument */ - public POIFSDocument(String name, RawDataBlock[] blocks, int length) throws IOException { + public OPOIFSDocument(String name, RawDataBlock[] blocks, int length) throws IOException { _size = length; if(blocks.length == 0) { _bigBigBlockSize = POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS; @@ -104,7 +103,7 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView * @param blocks the small blocks making up the POIFSDocument * @param length the actual length of the POIFSDocument */ - public POIFSDocument(String name, SmallDocumentBlock[] blocks, int length) { + public OPOIFSDocument(String name, SmallDocumentBlock[] blocks, int length) { _size = length; if(blocks.length == 0) { @@ -126,7 +125,7 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView * @param blocks the small blocks making up the POIFSDocument * @param length the actual length of the POIFSDocument */ - public POIFSDocument(String name, POIFSBigBlockSize bigBlockSize, ListManagedBlock[] blocks, int length) throws IOException { + public OPOIFSDocument(String name, POIFSBigBlockSize bigBlockSize, ListManagedBlock[] blocks, int length) throws IOException { _size = length; _bigBigBlockSize = bigBlockSize; _property = new DocumentProperty(name, _size); @@ -139,7 +138,7 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView _small_store = new SmallBlockStore(bigBlockSize,EMPTY_SMALL_BLOCK_ARRAY); } } - public POIFSDocument(String name, ListManagedBlock[] blocks, int length) throws IOException { + public OPOIFSDocument(String name, ListManagedBlock[] blocks, int length) throws IOException { this(name, POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS, blocks, length); } @@ -149,7 +148,7 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView * @param name the name of the POIFSDocument * @param stream the InputStream we read data from */ - public POIFSDocument(String name, POIFSBigBlockSize bigBlockSize, InputStream stream) throws IOException { + public OPOIFSDocument(String name, POIFSBigBlockSize bigBlockSize, InputStream stream) throws IOException { List<DocumentBlock> blocks = new ArrayList<DocumentBlock>(); _size = 0; @@ -178,7 +177,7 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView _small_store = new SmallBlockStore(bigBlockSize,EMPTY_SMALL_BLOCK_ARRAY); } } - public POIFSDocument(String name, InputStream stream) throws IOException { + public OPOIFSDocument(String name, InputStream stream) throws IOException { this(name, POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS, stream); } @@ -190,7 +189,7 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView * @param path the path of the POIFSDocument * @param writer the writer who will eventually write the document contents */ - public POIFSDocument(String name, int size, POIFSBigBlockSize bigBlockSize, POIFSDocumentPath path, POIFSWriterListener writer) { + public OPOIFSDocument(String name, int size, POIFSBigBlockSize bigBlockSize, POIFSDocumentPath path, POIFSWriterListener writer) { _size = size; _bigBigBlockSize = bigBlockSize; _property = new DocumentProperty(name, _size); @@ -203,14 +202,14 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView _big_store = new BigBlockStore(_bigBigBlockSize, path, name, size, writer); } } - public POIFSDocument(String name, int size, POIFSDocumentPath path, POIFSWriterListener writer) { + public OPOIFSDocument(String name, int size, POIFSDocumentPath path, POIFSWriterListener writer) { this(name, size, POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS, path, writer); } /** * @return array of SmallDocumentBlocks; may be empty, cannot be null */ - public BlockWritable[] getSmallBlocks() { + public SmallDocumentBlock[] getSmallBlocks() { return _small_store.getBlocks(); } diff --git a/src/java/org/apache/poi/poifs/filesystem/OPOIFSFileSystem.java b/src/java/org/apache/poi/poifs/filesystem/OPOIFSFileSystem.java new file mode 100644 index 0000000000..19abc48abe --- /dev/null +++ b/src/java/org/apache/poi/poifs/filesystem/OPOIFSFileSystem.java @@ -0,0 +1,607 @@ + +/* ==================================================================== + 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.poifs.filesystem; + +import java.io.ByteArrayInputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import org.apache.poi.poifs.common.POIFSBigBlockSize; +import org.apache.poi.poifs.common.POIFSConstants; +import org.apache.poi.poifs.dev.POIFSViewable; +import org.apache.poi.poifs.property.DirectoryProperty; +import org.apache.poi.poifs.property.Property; +import org.apache.poi.poifs.property.PropertyTable; +import org.apache.poi.poifs.storage.BATBlock; +import org.apache.poi.poifs.storage.BlockAllocationTableReader; +import org.apache.poi.poifs.storage.BlockAllocationTableWriter; +import org.apache.poi.poifs.storage.BlockList; +import org.apache.poi.poifs.storage.BlockWritable; +import org.apache.poi.poifs.storage.HeaderBlock; +import org.apache.poi.poifs.storage.HeaderBlockConstants; +import org.apache.poi.poifs.storage.HeaderBlockWriter; +import org.apache.poi.poifs.storage.RawDataBlockList; +import org.apache.poi.poifs.storage.SmallBlockTableReader; +import org.apache.poi.poifs.storage.SmallBlockTableWriter; +import org.apache.poi.util.CloseIgnoringInputStream; +import org.apache.poi.util.IOUtils; +import org.apache.poi.util.LongField; +import org.apache.poi.util.POILogFactory; +import org.apache.poi.util.POILogger; + +/** + * <p>This is the main class of the POIFS system; it manages the entire + * life cycle of the filesystem.</p> + * <p>This is the older version, which uses more memory, and doesn't + * support in-place writes.</p> + */ +public class OPOIFSFileSystem + implements POIFSViewable +{ + private static final POILogger _logger = + POILogFactory.getLogger(OPOIFSFileSystem.class); + + /** + * Convenience method for clients that want to avoid the auto-close behaviour of the constructor. + */ + public static InputStream createNonClosingInputStream(InputStream is) { + return new CloseIgnoringInputStream(is); + } + + private PropertyTable _property_table; + private List<OPOIFSDocument> _documents; + private DirectoryNode _root; + + /** + * What big block size the file uses. Most files + * use 512 bytes, but a few use 4096 + */ + private POIFSBigBlockSize bigBlockSize = + POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS; + + /** + * Constructor, intended for writing + */ + public OPOIFSFileSystem() + { + HeaderBlock header_block = new HeaderBlock(bigBlockSize); + _property_table = new PropertyTable(header_block); + _documents = new ArrayList<OPOIFSDocument>(); + _root = null; + } + + /** + * Create a OPOIFSFileSystem from an <tt>InputStream</tt>. Normally the stream is read until + * EOF. The stream is always closed.<p/> + * + * Some streams are usable after reaching EOF (typically those that return <code>true</code> + * for <tt>markSupported()</tt>). In the unlikely case that the caller has such a stream + * <i>and</i> needs to use it after this constructor completes, a work around is to wrap the + * stream in order to trap the <tt>close()</tt> call. A convenience method ( + * <tt>createNonClosingInputStream()</tt>) has been provided for this purpose: + * <pre> + * InputStream wrappedStream = OPOIFSFileSystem.createNonClosingInputStream(is); + * HSSFWorkbook wb = new HSSFWorkbook(wrappedStream); + * is.reset(); + * doSomethingElse(is); + * </pre> + * Note also the special case of <tt>ByteArrayInputStream</tt> for which the <tt>close()</tt> + * method does nothing. + * <pre> + * ByteArrayInputStream bais = ... + * HSSFWorkbook wb = new HSSFWorkbook(bais); // calls bais.close() ! + * bais.reset(); // no problem + * doSomethingElse(bais); + * </pre> + * + * @param stream the InputStream from which to read the data + * + * @exception IOException on errors reading, or on invalid data + */ + + public OPOIFSFileSystem(InputStream stream) + throws IOException + { + this(); + boolean success = false; + + HeaderBlock header_block; + RawDataBlockList data_blocks; + try { + // read the header block from the stream + header_block = new HeaderBlock(stream); + bigBlockSize = header_block.getBigBlockSize(); + + // read the rest of the stream into blocks + data_blocks = new RawDataBlockList(stream, bigBlockSize); + success = true; + } finally { + closeInputStream(stream, success); + } + + + // set up the block allocation table (necessary for the + // data_blocks to be manageable + new BlockAllocationTableReader(header_block.getBigBlockSize(), + header_block.getBATCount(), + header_block.getBATArray(), + header_block.getXBATCount(), + header_block.getXBATIndex(), + data_blocks); + + // get property table from the document + PropertyTable properties = + new PropertyTable(header_block, data_blocks); + + // init documents + processProperties( + SmallBlockTableReader.getSmallDocumentBlocks( + bigBlockSize, data_blocks, properties.getRoot(), + header_block.getSBATStart() + ), + data_blocks, + properties.getRoot().getChildren(), + null, + header_block.getPropertyStart() + ); + + // For whatever reason CLSID of root is always 0. + getRoot().setStorageClsid(properties.getRoot().getStorageClsid()); + } + /** + * @param stream the stream to be closed + * @param success <code>false</code> if an exception is currently being thrown in the calling method + */ + protected void closeInputStream(InputStream stream, boolean success) { + + if(stream.markSupported() && !(stream instanceof ByteArrayInputStream)) { + String msg = "POIFS is closing the supplied input stream of type (" + + stream.getClass().getName() + ") which supports mark/reset. " + + "This will be a problem for the caller if the stream will still be used. " + + "If that is the case the caller should wrap the input stream to avoid this close logic. " + + "This warning is only temporary and will not be present in future versions of POI."; + _logger.log(POILogger.WARN, msg); + } + try { + stream.close(); + } catch (IOException e) { + if(success) { + throw new RuntimeException(e); + } + // else not success? Try block did not complete normally + // just print stack trace and leave original ex to be thrown + e.printStackTrace(); + } + } + + /** + * Checks that the supplied InputStream (which MUST + * support mark and reset, or be a PushbackInputStream) + * has a POIFS (OLE2) header at the start of it. + * If your InputStream does not support mark / reset, + * then wrap it in a PushBackInputStream, then be + * sure to always use that, and not the original! + * @param inp An InputStream which supports either mark/reset, or is a PushbackInputStream + */ + public static boolean hasPOIFSHeader(InputStream inp) throws IOException { + // We want to peek at the first 8 bytes + byte[] header = IOUtils.peekFirst8Bytes(inp); + return hasPOIFSHeader(header); + } + /** + * Checks if the supplied first 8 bytes of a stream / file + * has a POIFS (OLE2) header. + */ + public static boolean hasPOIFSHeader(byte[] header8Bytes) { + LongField signature = new LongField(HeaderBlockConstants._signature_offset, header8Bytes); + + // Did it match the signature? + return (signature.get() == HeaderBlockConstants._signature); + } + + /** + * Create a new document to be added to the root directory + * + * @param stream the InputStream from which the document's data + * will be obtained + * @param name the name of the new POIFSDocument + * + * @return the new DocumentEntry + * + * @exception IOException on error creating the new POIFSDocument + */ + + public DocumentEntry createDocument(final InputStream stream, + final String name) + throws IOException + { + return getRoot().createDocument(name, stream); + } + + /** + * create a new DocumentEntry in the root entry; the data will be + * provided later + * + * @param name the name of the new DocumentEntry + * @param size the size of the new DocumentEntry + * @param writer the writer of the new DocumentEntry + * + * @return the new DocumentEntry + * + * @exception IOException + */ + + public DocumentEntry createDocument(final String name, final int size, + final POIFSWriterListener writer) + throws IOException + { + return getRoot().createDocument(name, size, writer); + } + + /** + * create a new DirectoryEntry in the root directory + * + * @param name the name of the new DirectoryEntry + * + * @return the new DirectoryEntry + * + * @exception IOException on name duplication + */ + + public DirectoryEntry createDirectory(final String name) + throws IOException + { + return getRoot().createDirectory(name); + } + + /** + * Write the filesystem out + * + * @param stream the OutputStream to which the filesystem will be + * written + * + * @exception IOException thrown on errors writing to the stream + */ + + public void writeFilesystem(final OutputStream stream) + throws IOException + { + + // get the property table ready + _property_table.preWrite(); + + // create the small block store, and the SBAT + SmallBlockTableWriter sbtw = + new SmallBlockTableWriter(bigBlockSize, _documents, _property_table.getRoot()); + + // create the block allocation table + BlockAllocationTableWriter bat = + new BlockAllocationTableWriter(bigBlockSize); + + // create a list of BATManaged objects: the documents plus the + // property table and the small block table + List<Object> bm_objects = new ArrayList<Object>(); + + bm_objects.addAll(_documents); + bm_objects.add(_property_table); + bm_objects.add(sbtw); + bm_objects.add(sbtw.getSBAT()); + + // walk the list, allocating space for each and assigning each + // a starting block number + Iterator<Object> iter = bm_objects.iterator(); + + while (iter.hasNext()) + { + BATManaged bmo = ( BATManaged ) iter.next(); + int block_count = bmo.countBlocks(); + + if (block_count != 0) + { + bmo.setStartBlock(bat.allocateSpace(block_count)); + } + else + { + + // Either the BATManaged object is empty or its data + // is composed of SmallBlocks; in either case, + // allocating space in the BAT is inappropriate + } + } + + // allocate space for the block allocation table and take its + // starting block + int batStartBlock = bat.createBlocks(); + + // get the extended block allocation table blocks + HeaderBlockWriter header_block_writer = new HeaderBlockWriter(bigBlockSize); + BATBlock[] xbat_blocks = + header_block_writer.setBATBlocks(bat.countBlocks(), + batStartBlock); + + // set the property table start block + header_block_writer.setPropertyStart(_property_table.getStartBlock()); + + // set the small block allocation table start block + header_block_writer.setSBATStart(sbtw.getSBAT().getStartBlock()); + + // set the small block allocation table block count + header_block_writer.setSBATBlockCount(sbtw.getSBATBlockCount()); + + // the header is now properly initialized. Make a list of + // writers (the header block, followed by the documents, the + // property table, the small block store, the small block + // allocation table, the block allocation table, and the + // extended block allocation table blocks) + List<Object> writers = new ArrayList<Object>(); + + writers.add(header_block_writer); + writers.addAll(_documents); + writers.add(_property_table); + writers.add(sbtw); + writers.add(sbtw.getSBAT()); + writers.add(bat); + for (int j = 0; j < xbat_blocks.length; j++) + { + writers.add(xbat_blocks[ j ]); + } + + // now, write everything out + iter = writers.iterator(); + while (iter.hasNext()) + { + BlockWritable writer = ( BlockWritable ) iter.next(); + + writer.writeBlocks(stream); + } + } + + /** + * read in a file and write it back out again + * + * @param args names of the files; arg[ 0 ] is the input file, + * arg[ 1 ] is the output file + * + * @exception IOException + */ + + public static void main(String args[]) + throws IOException + { + if (args.length != 2) + { + System.err.println( + "two arguments required: input filename and output filename"); + System.exit(1); + } + FileInputStream istream = new FileInputStream(args[ 0 ]); + FileOutputStream ostream = new FileOutputStream(args[ 1 ]); + + new OPOIFSFileSystem(istream).writeFilesystem(ostream); + istream.close(); + ostream.close(); + } + + /** + * get the root entry + * + * @return the root entry + */ + + public DirectoryNode getRoot() + { + if (_root == null) + { + _root = new DirectoryNode(_property_table.getRoot(), this, null); + } + return _root; + } + + /** + * open a document in the root entry's list of entries + * + * @param documentName the name of the document to be opened + * + * @return a newly opened DocumentInputStream + * + * @exception IOException if the document does not exist or the + * name is that of a DirectoryEntry + */ + + public DocumentInputStream createDocumentInputStream( + final String documentName) + throws IOException + { + return getRoot().createDocumentInputStream(documentName); + } + + /** + * add a new POIFSDocument + * + * @param document the POIFSDocument being added + */ + + void addDocument(final OPOIFSDocument document) + { + _documents.add(document); + _property_table.addProperty(document.getDocumentProperty()); + } + + /** + * add a new DirectoryProperty + * + * @param directory the DirectoryProperty being added + */ + + void addDirectory(final DirectoryProperty directory) + { + _property_table.addProperty(directory); + } + + /** + * remove an entry + * + * @param entry to be removed + */ + + void remove(EntryNode entry) + { + _property_table.removeProperty(entry.getProperty()); + if (entry.isDocumentEntry()) + { + _documents.remove((( DocumentNode ) entry).getDocument()); + } + } + + private void processProperties(final BlockList small_blocks, + final BlockList big_blocks, + final Iterator<Property> properties, + final DirectoryNode dir, + final int headerPropertiesStartAt) + throws IOException + { + while (properties.hasNext()) + { + Property property = properties.next(); + String name = property.getName(); + DirectoryNode parent = (dir == null) + ? (( DirectoryNode ) getRoot()) + : dir; + + if (property.isDirectory()) + { + DirectoryNode new_dir = + ( DirectoryNode ) parent.createDirectory(name); + + new_dir.setStorageClsid( property.getStorageClsid() ); + + processProperties( + small_blocks, big_blocks, + (( DirectoryProperty ) property).getChildren(), + new_dir, headerPropertiesStartAt); + } + else + { + int startBlock = property.getStartBlock(); + int size = property.getSize(); + OPOIFSDocument document = null; + + if (property.shouldUseSmallBlocks()) + { + document = + new OPOIFSDocument(name, + small_blocks.fetchBlocks(startBlock, headerPropertiesStartAt), + size); + } + else + { + document = + new OPOIFSDocument(name, + big_blocks.fetchBlocks(startBlock, headerPropertiesStartAt), + size); + } + parent.createDocument(document); + } + } + } + + /* ********** START begin implementation of POIFSViewable ********** */ + + /** + * Get an array of objects, some of which may implement + * POIFSViewable + * + * @return an array of Object; may not be null, but may be empty + */ + + public Object [] getViewableArray() + { + if (preferArray()) + { + return (( POIFSViewable ) getRoot()).getViewableArray(); + } + return new Object[ 0 ]; + } + + /** + * Get an Iterator of objects, some of which may implement + * POIFSViewable + * + * @return an Iterator; may not be null, but may have an empty + * back end store + */ + + public Iterator<Object> getViewableIterator() + { + if (!preferArray()) + { + return (( POIFSViewable ) getRoot()).getViewableIterator(); + } + return Collections.emptyList().iterator(); + } + + /** + * Give viewers a hint as to whether to call getViewableArray or + * getViewableIterator + * + * @return true if a viewer should call getViewableArray, false if + * a viewer should call getViewableIterator + */ + + public boolean preferArray() + { + return (( POIFSViewable ) getRoot()).preferArray(); + } + + /** + * Provides a short description of the object, to be used when a + * POIFSViewable object has not provided its contents. + * + * @return short description + */ + + public String getShortDescription() + { + return "POIFS FileSystem"; + } + + /** + * @return The Big Block size, normally 512 bytes, sometimes 4096 bytes + */ + public int getBigBlockSize() { + return bigBlockSize.getBigBlockSize(); + } + /** + * @return The Big Block size, normally 512 bytes, sometimes 4096 bytes + */ + public POIFSBigBlockSize getBigBlockSizeDetails() { + return bigBlockSize; + } + + /* ********** END begin implementation of POIFSViewable ********** */ +} // end public class OPOIFSFileSystem + diff --git a/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java b/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java index 7169d91f9e..5afb4eb8fc 100644 --- a/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java +++ b/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java @@ -19,44 +19,22 @@ package org.apache.poi.poifs.filesystem; -import java.io.ByteArrayInputStream; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; -import java.io.PushbackInputStream; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import org.apache.poi.poifs.common.POIFSBigBlockSize; -import org.apache.poi.poifs.common.POIFSConstants; import org.apache.poi.poifs.dev.POIFSViewable; -import org.apache.poi.poifs.property.DirectoryProperty; -import org.apache.poi.poifs.property.Property; -import org.apache.poi.poifs.property.PropertyTable; -import org.apache.poi.poifs.storage.*; import org.apache.poi.util.CloseIgnoringInputStream; -import org.apache.poi.util.IOUtils; -import org.apache.poi.util.LongField; -import org.apache.poi.util.POILogFactory; -import org.apache.poi.util.POILogger; /** - * This is the main class of the POIFS system; it manages the entire - * life cycle of the filesystem. - * - * @author Marc Johnson (mjohnson at apache dot org) + * Transition class for the move from {@link POIFSFileSystem} to + * {@link OPOIFSFileSystem}, and from {@link NPOIFSFileSystem} to + * {@link POIFSFileSystem}. Currently, this is OPOIFS-powered */ public class POIFSFileSystem + extends NPOIFSFileSystem // TODO Temporary workaround during #56791 implements POIFSViewable { - private static final POILogger _logger = - POILogFactory.getLogger(POIFSFileSystem.class); - /** * Convenience method for clients that want to avoid the auto-close behaviour of the constructor. */ @@ -64,26 +42,12 @@ public class POIFSFileSystem return new CloseIgnoringInputStream(is); } - private PropertyTable _property_table; - private List<POIFSViewable> _documents; - private DirectoryNode _root; - - /** - * What big block size the file uses. Most files - * use 512 bytes, but a few use 4096 - */ - private POIFSBigBlockSize bigBlockSize = - POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS; - /** * Constructor, intended for writing */ public POIFSFileSystem() { - HeaderBlock header_block = new HeaderBlock(bigBlockSize); - _property_table = new PropertyTable(header_block); - _documents = new ArrayList<POIFSViewable>(); - _root = null; + super(); } /** @@ -118,76 +82,7 @@ public class POIFSFileSystem public POIFSFileSystem(InputStream stream) throws IOException { - this(); - boolean success = false; - - HeaderBlock header_block; - RawDataBlockList data_blocks; - try { - // read the header block from the stream - header_block = new HeaderBlock(stream); - bigBlockSize = header_block.getBigBlockSize(); - - // read the rest of the stream into blocks - data_blocks = new RawDataBlockList(stream, bigBlockSize); - success = true; - } finally { - closeInputStream(stream, success); - } - - - // set up the block allocation table (necessary for the - // data_blocks to be manageable - new BlockAllocationTableReader(header_block.getBigBlockSize(), - header_block.getBATCount(), - header_block.getBATArray(), - header_block.getXBATCount(), - header_block.getXBATIndex(), - data_blocks); - - // get property table from the document - PropertyTable properties = - new PropertyTable(header_block, data_blocks); - - // init documents - processProperties( - SmallBlockTableReader.getSmallDocumentBlocks( - bigBlockSize, data_blocks, properties.getRoot(), - header_block.getSBATStart() - ), - data_blocks, - properties.getRoot().getChildren(), - null, - header_block.getPropertyStart() - ); - - // For whatever reason CLSID of root is always 0. - getRoot().setStorageClsid(properties.getRoot().getStorageClsid()); - } - /** - * @param stream the stream to be closed - * @param success <code>false</code> if an exception is currently being thrown in the calling method - */ - private void closeInputStream(InputStream stream, boolean success) { - - if(stream.markSupported() && !(stream instanceof ByteArrayInputStream)) { - String msg = "POIFS is closing the supplied input stream of type (" - + stream.getClass().getName() + ") which supports mark/reset. " - + "This will be a problem for the caller if the stream will still be used. " - + "If that is the case the caller should wrap the input stream to avoid this close logic. " - + "This warning is only temporary and will not be present in future versions of POI."; - _logger.log(POILogger.WARN, msg); - } - try { - stream.close(); - } catch (IOException e) { - if(success) { - throw new RuntimeException(e); - } - // else not success? Try block did not complete normally - // just print stack trace and leave original ex to be thrown - e.printStackTrace(); - } + super(stream); } /** @@ -200,180 +95,14 @@ public class POIFSFileSystem * @param inp An InputStream which supports either mark/reset, or is a PushbackInputStream */ public static boolean hasPOIFSHeader(InputStream inp) throws IOException { - // We want to peek at the first 8 bytes - inp.mark(8); - - byte[] header = new byte[8]; - IOUtils.readFully(inp, header); - LongField signature = new LongField(HeaderBlockConstants._signature_offset, header); - - // Wind back those 8 bytes - if(inp instanceof PushbackInputStream) { - PushbackInputStream pin = (PushbackInputStream)inp; - pin.unread(header); - } else { - inp.reset(); - } - - // Did it match the signature? - return (signature.get() == HeaderBlockConstants._signature); - } - - /** - * Create a new document to be added to the root directory - * - * @param stream the InputStream from which the document's data - * will be obtained - * @param name the name of the new POIFSDocument - * - * @return the new DocumentEntry - * - * @exception IOException on error creating the new POIFSDocument - */ - - public DocumentEntry createDocument(final InputStream stream, - final String name) - throws IOException - { - return getRoot().createDocument(name, stream); + return NPOIFSFileSystem.hasPOIFSHeader(inp); } - /** - * create a new DocumentEntry in the root entry; the data will be - * provided later - * - * @param name the name of the new DocumentEntry - * @param size the size of the new DocumentEntry - * @param writer the writer of the new DocumentEntry - * - * @return the new DocumentEntry - * - * @exception IOException + * Checks if the supplied first 8 bytes of a stream / file + * has a POIFS (OLE2) header. */ - - public DocumentEntry createDocument(final String name, final int size, - final POIFSWriterListener writer) - throws IOException - { - return getRoot().createDocument(name, size, writer); - } - - /** - * create a new DirectoryEntry in the root directory - * - * @param name the name of the new DirectoryEntry - * - * @return the new DirectoryEntry - * - * @exception IOException on name duplication - */ - - public DirectoryEntry createDirectory(final String name) - throws IOException - { - return getRoot().createDirectory(name); - } - - /** - * Write the filesystem out - * - * @param stream the OutputStream to which the filesystem will be - * written - * - * @exception IOException thrown on errors writing to the stream - */ - - public void writeFilesystem(final OutputStream stream) - throws IOException - { - - // get the property table ready - _property_table.preWrite(); - - // create the small block store, and the SBAT - SmallBlockTableWriter sbtw = - new SmallBlockTableWriter(bigBlockSize, _documents, _property_table.getRoot()); - - // create the block allocation table - BlockAllocationTableWriter bat = - new BlockAllocationTableWriter(bigBlockSize); - - // create a list of BATManaged objects: the documents plus the - // property table and the small block table - List<Object> bm_objects = new ArrayList<Object>(); - - bm_objects.addAll(_documents); - bm_objects.add(_property_table); - bm_objects.add(sbtw); - bm_objects.add(sbtw.getSBAT()); - - // walk the list, allocating space for each and assigning each - // a starting block number - Iterator<Object> iter = bm_objects.iterator(); - - while (iter.hasNext()) - { - BATManaged bmo = ( BATManaged ) iter.next(); - int block_count = bmo.countBlocks(); - - if (block_count != 0) - { - bmo.setStartBlock(bat.allocateSpace(block_count)); - } - else - { - - // Either the BATManaged object is empty or its data - // is composed of SmallBlocks; in either case, - // allocating space in the BAT is inappropriate - } - } - - // allocate space for the block allocation table and take its - // starting block - int batStartBlock = bat.createBlocks(); - - // get the extended block allocation table blocks - HeaderBlockWriter header_block_writer = new HeaderBlockWriter(bigBlockSize); - BATBlock[] xbat_blocks = - header_block_writer.setBATBlocks(bat.countBlocks(), - batStartBlock); - - // set the property table start block - header_block_writer.setPropertyStart(_property_table.getStartBlock()); - - // set the small block allocation table start block - header_block_writer.setSBATStart(sbtw.getSBAT().getStartBlock()); - - // set the small block allocation table block count - header_block_writer.setSBATBlockCount(sbtw.getSBATBlockCount()); - - // the header is now properly initialized. Make a list of - // writers (the header block, followed by the documents, the - // property table, the small block store, the small block - // allocation table, the block allocation table, and the - // extended block allocation table blocks) - List<Object> writers = new ArrayList<Object>(); - - writers.add(header_block_writer); - writers.addAll(_documents); - writers.add(_property_table); - writers.add(sbtw); - writers.add(sbtw.getSBAT()); - writers.add(bat); - for (int j = 0; j < xbat_blocks.length; j++) - { - writers.add(xbat_blocks[ j ]); - } - - // now, write everything out - iter = writers.iterator(); - while (iter.hasNext()) - { - BlockWritable writer = ( BlockWritable ) iter.next(); - - writer.writeBlocks(stream); - } + public static boolean hasPOIFSHeader(byte[] header8Bytes) { + return NPOIFSFileSystem.hasPOIFSHeader(header8Bytes); } /** @@ -388,216 +117,7 @@ public class POIFSFileSystem public static void main(String args[]) throws IOException { - if (args.length != 2) - { - System.err.println( - "two arguments required: input filename and output filename"); - System.exit(1); - } - FileInputStream istream = new FileInputStream(args[ 0 ]); - FileOutputStream ostream = new FileOutputStream(args[ 1 ]); - - new POIFSFileSystem(istream).writeFilesystem(ostream); - istream.close(); - ostream.close(); - } - - /** - * get the root entry - * - * @return the root entry - */ - - public DirectoryNode getRoot() - { - if (_root == null) - { - _root = new DirectoryNode(_property_table.getRoot(), this, null); - } - return _root; - } - - /** - * open a document in the root entry's list of entries - * - * @param documentName the name of the document to be opened - * - * @return a newly opened DocumentInputStream - * - * @exception IOException if the document does not exist or the - * name is that of a DirectoryEntry - */ - - public DocumentInputStream createDocumentInputStream( - final String documentName) - throws IOException - { - return getRoot().createDocumentInputStream(documentName); - } - - /** - * add a new POIFSDocument - * - * @param document the POIFSDocument being added - */ - - void addDocument(final POIFSDocument document) - { - _documents.add(document); - _property_table.addProperty(document.getDocumentProperty()); + OPOIFSFileSystem.main(args); } - - /** - * add a new DirectoryProperty - * - * @param directory the DirectoryProperty being added - */ - - void addDirectory(final DirectoryProperty directory) - { - _property_table.addProperty(directory); - } - - /** - * remove an entry - * - * @param entry to be removed - */ - - void remove(EntryNode entry) - { - _property_table.removeProperty(entry.getProperty()); - if (entry.isDocumentEntry()) - { - _documents.remove((( DocumentNode ) entry).getDocument()); - } - } - - private void processProperties(final BlockList small_blocks, - final BlockList big_blocks, - final Iterator<Property> properties, - final DirectoryNode dir, - final int headerPropertiesStartAt) - throws IOException - { - while (properties.hasNext()) - { - Property property = properties.next(); - String name = property.getName(); - DirectoryNode parent = (dir == null) - ? (( DirectoryNode ) getRoot()) - : dir; - - if (property.isDirectory()) - { - DirectoryNode new_dir = - ( DirectoryNode ) parent.createDirectory(name); - - new_dir.setStorageClsid( property.getStorageClsid() ); - - processProperties( - small_blocks, big_blocks, - (( DirectoryProperty ) property).getChildren(), - new_dir, headerPropertiesStartAt); - } - else - { - int startBlock = property.getStartBlock(); - int size = property.getSize(); - POIFSDocument document = null; - - if (property.shouldUseSmallBlocks()) - { - document = - new POIFSDocument(name, - small_blocks.fetchBlocks(startBlock, headerPropertiesStartAt), - size); - } - else - { - document = - new POIFSDocument(name, - big_blocks.fetchBlocks(startBlock, headerPropertiesStartAt), - size); - } - parent.createDocument(document); - } - } - } - - /* ********** START begin implementation of POIFSViewable ********** */ - - /** - * Get an array of objects, some of which may implement - * POIFSViewable - * - * @return an array of Object; may not be null, but may be empty - */ - - public Object [] getViewableArray() - { - if (preferArray()) - { - return (( POIFSViewable ) getRoot()).getViewableArray(); - } - return new Object[ 0 ]; - } - - /** - * Get an Iterator of objects, some of which may implement - * POIFSViewable - * - * @return an Iterator; may not be null, but may have an empty - * back end store - */ - - public Iterator<Object> getViewableIterator() - { - if (!preferArray()) - { - return (( POIFSViewable ) getRoot()).getViewableIterator(); - } - return Collections.emptyList().iterator(); - } - - /** - * Give viewers a hint as to whether to call getViewableArray or - * getViewableIterator - * - * @return true if a viewer should call getViewableArray, false if - * a viewer should call getViewableIterator - */ - - public boolean preferArray() - { - return (( POIFSViewable ) getRoot()).preferArray(); - } - - /** - * Provides a short description of the object, to be used when a - * POIFSViewable object has not provided its contents. - * - * @return short description - */ - - public String getShortDescription() - { - return "POIFS FileSystem"; - } - - /** - * @return The Big Block size, normally 512 bytes, sometimes 4096 bytes - */ - public int getBigBlockSize() { - return bigBlockSize.getBigBlockSize(); - } - /** - * @return The Big Block size, normally 512 bytes, sometimes 4096 bytes - */ - public POIFSBigBlockSize getBigBlockSizeDetails() { - return bigBlockSize; - } - - /* ********** END begin implementation of POIFSViewable ********** */ -} // end public class POIFSFileSystem +} diff --git a/src/java/org/apache/poi/poifs/property/DirectoryProperty.java b/src/java/org/apache/poi/poifs/property/DirectoryProperty.java index a73221af24..d86e73ada1 100644 --- a/src/java/org/apache/poi/poifs/property/DirectoryProperty.java +++ b/src/java/org/apache/poi/poifs/property/DirectoryProperty.java @@ -28,10 +28,8 @@ import java.util.Set; /** * Directory property - * - * @author Marc Johnson (mjohnson at apache dot org) */ -public class DirectoryProperty extends Property implements Parent { // TODO - fix instantiable superclass +public class DirectoryProperty extends Property implements Parent, Iterable<Property> { // TODO - fix instantiable superclass /** List of Property instances */ private List<Property> _children; @@ -241,6 +239,13 @@ public class DirectoryProperty extends Property implements Parent { // TODO - fi { return _children.iterator(); } + /** + * Get an iterator over the children of this Parent, alias for + * {@link #getChildren()} which supports foreach use + */ + public Iterator<Property> iterator() { + return getChildren(); + } /** * Add a new child to the collection of children diff --git a/src/java/org/apache/poi/poifs/property/DocumentProperty.java b/src/java/org/apache/poi/poifs/property/DocumentProperty.java index 67c8b03073..3ba3c0889b 100644 --- a/src/java/org/apache/poi/poifs/property/DocumentProperty.java +++ b/src/java/org/apache/poi/poifs/property/DocumentProperty.java @@ -19,12 +19,10 @@ package org.apache.poi.poifs.property; -import org.apache.poi.poifs.filesystem.POIFSDocument; +import org.apache.poi.poifs.filesystem.OPOIFSDocument; /** * Trivial extension of Property for POIFSDocuments - * - * @author Marc Johnson (mjohnson at apache dot org) */ public class DocumentProperty @@ -32,7 +30,7 @@ public class DocumentProperty { // the POIFSDocument this property is associated with - private POIFSDocument _document; + private OPOIFSDocument _document; /** * Constructor @@ -72,7 +70,7 @@ public class DocumentProperty * @param doc the associated POIFSDocument */ - public void setDocument(POIFSDocument doc) + public void setDocument(OPOIFSDocument doc) { _document = doc; } @@ -83,7 +81,7 @@ public class DocumentProperty * @return the associated document */ - public POIFSDocument getDocument() + public OPOIFSDocument getDocument() { return _document; } diff --git a/src/java/org/apache/poi/poifs/property/PropertyTable.java b/src/java/org/apache/poi/poifs/property/PropertyTable.java index 45a9734158..75ca4a03b3 100644 --- a/src/java/org/apache/poi/poifs/property/PropertyTable.java +++ b/src/java/org/apache/poi/poifs/property/PropertyTable.java @@ -21,14 +21,13 @@ import java.io.IOException; import java.io.OutputStream; import org.apache.poi.poifs.common.POIFSBigBlockSize; -import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.poifs.storage.BlockWritable; import org.apache.poi.poifs.storage.HeaderBlock; import org.apache.poi.poifs.storage.PropertyBlock; import org.apache.poi.poifs.storage.RawDataBlockList; /** - * This class embodies the Property Table for the {@link POIFSFileSystem}; + * This class embodies the Property Table for the {@link org.apache.poi.poifs.filesystem.POIFSFileSystem}; * this is basically the directory for all of the documents in the * filesystem. * diff --git a/src/java/org/apache/poi/poifs/property/PropertyTableBase.java b/src/java/org/apache/poi/poifs/property/PropertyTableBase.java index b3690c5c24..477cf036d8 100644 --- a/src/java/org/apache/poi/poifs/property/PropertyTableBase.java +++ b/src/java/org/apache/poi/poifs/property/PropertyTableBase.java @@ -111,6 +111,11 @@ public abstract class PropertyTableBase implements BATManaged { while (!children.empty()) { Property property = children.pop(); + if (property == null) + { + // unknown / unsupported / corrupted property, skip + continue; + } root.addChild(property); if (property.isDirectory()) diff --git a/src/java/org/apache/poi/poifs/property/RootProperty.java b/src/java/org/apache/poi/poifs/property/RootProperty.java index b934a2601b..5a8f3d52ef 100644 --- a/src/java/org/apache/poi/poifs/property/RootProperty.java +++ b/src/java/org/apache/poi/poifs/property/RootProperty.java @@ -22,8 +22,6 @@ import org.apache.poi.poifs.storage.SmallDocumentBlock; /** * Root property - * - * @author Marc Johnson (mjohnson at apache dot org) */ public final class RootProperty extends DirectoryProperty { private static final String NAME = "Root Entry"; diff --git a/src/java/org/apache/poi/poifs/storage/BATBlock.java b/src/java/org/apache/poi/poifs/storage/BATBlock.java index 8712e65f6f..53099644ac 100644 --- a/src/java/org/apache/poi/poifs/storage/BATBlock.java +++ b/src/java/org/apache/poi/poifs/storage/BATBlock.java @@ -30,8 +30,6 @@ import org.apache.poi.util.LittleEndian; /** * A block of block allocation table entries. BATBlocks are created * only through a static factory method: createBATBlocks. - * - * @author Marc Johnson (mjohnson at apache dot org) */ public final class BATBlock extends BigBlock { /** @@ -301,6 +299,21 @@ public final class BATBlock extends BigBlock { public boolean hasFreeSectors() { return _has_free_sectors; } + /** + * How many sectors in this block are taken? + * Note that calling {@link #hasFreeSectors()} is much quicker + */ + public int getUsedSectors(boolean isAnXBAT) { + int usedSectors = 0; + int toCheck = _values.length; + if (isAnXBAT) toCheck--; // Last is a chain location + for(int k=0; k<toCheck; k++) { + if(_values[k] != POIFSConstants.UNUSED_BLOCK) { + usedSectors ++; + } + } + return usedSectors; + } public int getValueAt(int relativeOffset) { if(relativeOffset >= _values.length) { diff --git a/src/java/org/apache/poi/poifs/storage/SmallBlockTableReader.java b/src/java/org/apache/poi/poifs/storage/SmallBlockTableReader.java index 8b6efd36e8..2f9528318d 100644 --- a/src/java/org/apache/poi/poifs/storage/SmallBlockTableReader.java +++ b/src/java/org/apache/poi/poifs/storage/SmallBlockTableReader.java @@ -25,13 +25,66 @@ import org.apache.poi.poifs.property.RootProperty; /** * This class implements reading the small document block list from an * existing file - * - * @author Marc Johnson (mjohnson at apache dot org) */ public final class SmallBlockTableReader { + private static BlockList prepareSmallDocumentBlocks( + final POIFSBigBlockSize bigBlockSize, + final RawDataBlockList blockList, final RootProperty root, + final int sbatStart) + throws IOException + { + // Fetch the blocks which hold the Small Blocks stream + ListManagedBlock [] smallBlockBlocks = + blockList.fetchBlocks(root.getStartBlock(), -1); + + // Turn that into a list + BlockList list =new SmallDocumentBlockList( + SmallDocumentBlock.extract(bigBlockSize, smallBlockBlocks)); + + return list; + } + private static BlockAllocationTableReader prepareReader( + final POIFSBigBlockSize bigBlockSize, + final RawDataBlockList blockList, final BlockList list, + final RootProperty root, final int sbatStart) + throws IOException + { + // Process the SBAT and blocks + return new BlockAllocationTableReader(bigBlockSize, + blockList.fetchBlocks(sbatStart, -1), + list); + } + + /** + * Fetch the small document block reader from an existing file, normally + * needed for debugging and low level dumping. You should typically call + * {@link #getSmallDocumentBlocks(POIFSBigBlockSize, RawDataBlockList, RootProperty, int)} + * instead. + * + * @param blockList the raw data from which the small block table + * will be extracted + * @param root the root property (which contains the start block + * and small block table size) + * @param sbatStart the start block of the SBAT + * + * @return the small document block reader + * + * @exception IOException + */ + public static BlockAllocationTableReader _getSmallDocumentBlockReader( + final POIFSBigBlockSize bigBlockSize, + final RawDataBlockList blockList, final RootProperty root, + final int sbatStart) + throws IOException + { + BlockList list = prepareSmallDocumentBlocks( + bigBlockSize, blockList, root, sbatStart); + return prepareReader( + bigBlockSize, blockList, list, root, sbatStart); + } /** - * fetch the small document block list from an existing file + * Fetch the small document block list from an existing file * * @param blockList the raw data from which the small block table * will be extracted @@ -49,18 +102,9 @@ public final class SmallBlockTableReader { final int sbatStart) throws IOException { - // Fetch the blocks which hold the Small Blocks stream - ListManagedBlock [] smallBlockBlocks = - blockList.fetchBlocks(root.getStartBlock(), -1); - - // Turn that into a list - BlockList list =new SmallDocumentBlockList( - SmallDocumentBlock.extract(bigBlockSize, smallBlockBlocks)); - - // Process - new BlockAllocationTableReader(bigBlockSize, - blockList.fetchBlocks(sbatStart, -1), - list); + BlockList list = prepareSmallDocumentBlocks( + bigBlockSize, blockList, root, sbatStart); + prepareReader(bigBlockSize, blockList, list, root, sbatStart); return list; } } diff --git a/src/java/org/apache/poi/poifs/storage/SmallBlockTableWriter.java b/src/java/org/apache/poi/poifs/storage/SmallBlockTableWriter.java index 2db7bf4c73..9c98bb4595 100644 --- a/src/java/org/apache/poi/poifs/storage/SmallBlockTableWriter.java +++ b/src/java/org/apache/poi/poifs/storage/SmallBlockTableWriter.java @@ -22,7 +22,7 @@ package org.apache.poi.poifs.storage; import org.apache.poi.poifs.common.POIFSBigBlockSize; import org.apache.poi.poifs.common.POIFSConstants; import org.apache.poi.poifs.filesystem.BATManaged; -import org.apache.poi.poifs.filesystem.POIFSDocument; +import org.apache.poi.poifs.filesystem.OPOIFSDocument; import org.apache.poi.poifs.property.RootProperty; import java.util.*; @@ -40,7 +40,7 @@ public class SmallBlockTableWriter implements BlockWritable, BATManaged { private BlockAllocationTableWriter _sbat; - private List _small_blocks; + private List<SmallDocumentBlock> _small_blocks; private int _big_block_count; private RootProperty _root; @@ -50,20 +50,17 @@ public class SmallBlockTableWriter * @param documents a List of POIFSDocument instances * @param root the Filesystem's root property */ - public SmallBlockTableWriter(final POIFSBigBlockSize bigBlockSize, - final List documents, + final List<OPOIFSDocument> documents, final RootProperty root) { _sbat = new BlockAllocationTableWriter(bigBlockSize); - _small_blocks = new ArrayList(); + _small_blocks = new ArrayList<SmallDocumentBlock>(); _root = root; - Iterator iter = documents.iterator(); - while (iter.hasNext()) + for (OPOIFSDocument doc : documents) { - POIFSDocument doc = ( POIFSDocument ) iter.next(); - BlockWritable[] blocks = doc.getSmallBlocks(); + SmallDocumentBlock[] blocks = doc.getSmallBlocks(); if (blocks.length != 0) { @@ -143,11 +140,8 @@ public class SmallBlockTableWriter public void writeBlocks(final OutputStream stream) throws IOException { - Iterator iter = _small_blocks.iterator(); - - while (iter.hasNext()) - { - (( BlockWritable ) iter.next()).writeBlocks(stream); + for (BlockWritable block : _small_blocks) { + block.writeBlocks(stream); } } diff --git a/src/java/org/apache/poi/poifs/storage/SmallDocumentBlock.java b/src/java/org/apache/poi/poifs/storage/SmallDocumentBlock.java index 8c726caa0a..d09bf9ecf5 100644 --- a/src/java/org/apache/poi/poifs/storage/SmallDocumentBlock.java +++ b/src/java/org/apache/poi/poifs/storage/SmallDocumentBlock.java @@ -29,8 +29,6 @@ import org.apache.poi.poifs.common.POIFSBigBlockSize; /** * Storage for documents that are too small to use regular * DocumentBlocks for their data - * - * @author Marc Johnson (mjohnson at apache dot org) */ public final class SmallDocumentBlock implements BlockWritable, ListManagedBlock { private static final int BLOCK_SHIFT = 6; @@ -49,7 +47,7 @@ public final class SmallDocumentBlock implements BlockWritable, ListManagedBlock System.arraycopy(data, index * _block_size, _data, 0, _block_size); } - private SmallDocumentBlock(final POIFSBigBlockSize bigBlockSize) + protected SmallDocumentBlock(final POIFSBigBlockSize bigBlockSize) { _bigBlockSize = bigBlockSize; _blocks_per_big_block = getBlocksPerBigBlock(bigBlockSize); @@ -110,7 +108,7 @@ public final class SmallDocumentBlock implements BlockWritable, ListManagedBlock * * @return number of big blocks the list encompasses */ - public static int fill(POIFSBigBlockSize bigBlockSize, List blocks) + public static int fill(POIFSBigBlockSize bigBlockSize, List<SmallDocumentBlock> blocks) { int _blocks_per_big_block = getBlocksPerBigBlock(bigBlockSize); @@ -168,12 +166,12 @@ public final class SmallDocumentBlock implements BlockWritable, ListManagedBlock * * @return a List of SmallDocumentBlock's extracted from the input */ - public static List extract(POIFSBigBlockSize bigBlockSize, ListManagedBlock [] blocks) + public static List<SmallDocumentBlock> extract(POIFSBigBlockSize bigBlockSize, ListManagedBlock [] blocks) throws IOException { int _blocks_per_big_block = getBlocksPerBigBlock(bigBlockSize); - List sdbs = new ArrayList(); + List<SmallDocumentBlock> sdbs = new ArrayList<SmallDocumentBlock>(); for (int j = 0; j < blocks.length; j++) { @@ -204,6 +202,11 @@ public final class SmallDocumentBlock implements BlockWritable, ListManagedBlock { return size * _block_size; } + + protected int getSmallBlocksPerBigBlock() + { + return _blocks_per_big_block; + } private static SmallDocumentBlock makeEmptySmallDocumentBlock(POIFSBigBlockSize bigBlockSize) { diff --git a/src/java/org/apache/poi/poifs/storage/SmallDocumentBlockList.java b/src/java/org/apache/poi/poifs/storage/SmallDocumentBlockList.java index a510f8e8f7..cc6bb7c17f 100644 --- a/src/java/org/apache/poi/poifs/storage/SmallDocumentBlockList.java +++ b/src/java/org/apache/poi/poifs/storage/SmallDocumentBlockList.java @@ -23,24 +23,19 @@ import java.util.*; /** * A list of SmallDocumentBlocks instances, and methods to manage the list - * - * @author Marc Johnson (mjohnson at apache dot org) */ - public class SmallDocumentBlockList extends BlockListImpl { - /** * Constructor SmallDocumentBlockList * * @param blocks a list of SmallDocumentBlock instances */ - public SmallDocumentBlockList(final List blocks) + public SmallDocumentBlockList(final List<SmallDocumentBlock> blocks) { - setBlocks(( SmallDocumentBlock [] ) blocks - .toArray(new SmallDocumentBlock[ blocks.size() ])); + setBlocks(blocks.toArray(new SmallDocumentBlock[blocks.size()])); } -} // end public class SmallDocumentBlockList +} diff --git a/src/java/org/apache/poi/sl/draw/DrawAutoShape.java b/src/java/org/apache/poi/sl/draw/DrawAutoShape.java new file mode 100644 index 0000000000..6af2b4b9c1 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/DrawAutoShape.java @@ -0,0 +1,27 @@ +/* ====================================================================
+ 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.sl.draw;
+
+import org.apache.poi.sl.usermodel.*;
+
+
+public class DrawAutoShape<T extends AutoShape<? extends TextParagraph<? extends TextRun>>> extends DrawTextShape<T> {
+ public DrawAutoShape(T shape) {
+ super(shape);
+ }
+}
diff --git a/src/java/org/apache/poi/sl/draw/DrawBackground.java b/src/java/org/apache/poi/sl/draw/DrawBackground.java new file mode 100644 index 0000000000..35c844d8d0 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/DrawBackground.java @@ -0,0 +1,60 @@ +/* ====================================================================
+ 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.sl.draw;
+
+import java.awt.*;
+import java.awt.geom.Rectangle2D;
+
+import org.apache.poi.sl.usermodel.*;
+import org.apache.poi.sl.usermodel.Shape;
+
+
+public class DrawBackground<T extends Background> extends DrawShape<T> {
+ public DrawBackground(T shape) {
+ super(shape);
+ }
+
+ public void draw(Graphics2D graphics) {
+ Dimension pg = shape.getSheet().getSlideShow().getPageSize();
+ final Rectangle2D anchor = new Rectangle2D.Double(0, 0, pg.getWidth(), pg.getHeight());
+
+ PlaceableShape ps = new PlaceableShape(){
+ public ShapeContainer<? extends Shape> getParent() { return null; }
+ public Rectangle2D getAnchor() { return anchor; }
+ public void setAnchor(Rectangle2D anchor) {}
+ public double getRotation() { return 0; }
+ public void setRotation(double theta) {}
+ public void setFlipHorizontal(boolean flip) {}
+ public void setFlipVertical(boolean flip) {}
+ public boolean getFlipHorizontal() { return false; }
+ public boolean getFlipVertical() { return false; }
+ };
+
+ DrawFactory drawFact = DrawFactory.getInstance(graphics);
+ DrawPaint dp = drawFact.getPaint(ps);
+ Paint fill = dp.getPaint(graphics, shape.getFillStyle().getPaint());
+ Rectangle2D anchor2 = getAnchor(graphics, anchor);
+
+ if(fill != null) {
+ graphics.setPaint(fill);
+ graphics.fill(anchor2);
+ }
+ }
+
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/DrawConnectorShape.java b/src/java/org/apache/poi/sl/draw/DrawConnectorShape.java new file mode 100644 index 0000000000..0fee07cf6d --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/DrawConnectorShape.java @@ -0,0 +1,26 @@ +/* ====================================================================
+ 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.sl.draw;
+
+import org.apache.poi.sl.usermodel.*;
+
+public class DrawConnectorShape<T extends ConnectorShape> extends DrawSimpleShape<T> {
+ public DrawConnectorShape(T shape) {
+ super(shape);
+ }
+}
diff --git a/src/java/org/apache/poi/sl/draw/DrawFactory.java b/src/java/org/apache/poi/sl/draw/DrawFactory.java new file mode 100644 index 0000000000..97b3f52147 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/DrawFactory.java @@ -0,0 +1,148 @@ +/* ====================================================================
+ 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.sl.draw;
+
+import static org.apache.poi.sl.draw.Drawable.DRAW_FACTORY;
+
+import java.awt.Graphics2D;
+import java.awt.font.TextLayout;
+import java.text.AttributedString;
+
+import org.apache.poi.sl.usermodel.*;
+
+public class DrawFactory {
+ protected static ThreadLocal<DrawFactory> defaultFactory = new ThreadLocal<DrawFactory>();
+
+ /**
+ * Set a custom draw factory for the current thread.
+ * This is a fallback, for operations where usercode can't set a graphics context.
+ * Preferably use the rendering hint {@link Drawable#DRAW_FACTORY} to set the factory.
+ *
+ * @param factory
+ */
+ public static void setDefaultFactory(DrawFactory factory) {
+ defaultFactory.set(factory);
+ }
+
+ public static DrawFactory getInstance(Graphics2D graphics) {
+ // first try to find the factory over the rendering hint
+ DrawFactory factory = null;
+ boolean isHint = false;
+ if (graphics != null) {
+ factory = (DrawFactory)graphics.getRenderingHint(DRAW_FACTORY);
+ isHint = (factory != null);
+ }
+ // secondly try the thread local default
+ if (factory == null) {
+ factory = defaultFactory.get();
+ }
+ // and at last, use the default factory
+ if (factory == null) {
+ factory = new DrawFactory();
+ }
+ if (graphics != null && !isHint) {
+ graphics.setRenderingHint(DRAW_FACTORY, factory);
+ }
+ return factory;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Drawable getDrawable(Shape shape) {
+ if (shape instanceof TextBox) {
+ return getDrawable((TextBox<? extends TextParagraph<? extends TextRun>>)shape);
+ } else if (shape instanceof FreeformShape) {
+ return getDrawable((FreeformShape<? extends TextParagraph<? extends TextRun>>)shape);
+ } else if (shape instanceof TextShape) {
+ return getDrawable((TextShape<? extends TextParagraph<? extends TextRun>>)shape);
+ } else if (shape instanceof GroupShape) {
+ return getDrawable((GroupShape<? extends Shape>)shape);
+ } else if (shape instanceof PictureShape) {
+ return getDrawable((PictureShape)shape);
+ } else if (shape instanceof Background) {
+ return getDrawable((Background)shape);
+ } else if (shape instanceof ConnectorShape) {
+ return getDrawable((ConnectorShape)shape);
+ } else if (shape instanceof TableShape) {
+ return getDrawable((TableShape)shape);
+ } else if (shape instanceof Slide) {
+ return getDrawable((Slide<? extends Shape, ? extends SlideShow, ? extends Notes<?,?>>)shape);
+ } else if (shape instanceof MasterSheet) {
+ return getDrawable((MasterSheet<? extends Shape, ? extends SlideShow>)shape);
+ } else if (shape instanceof Sheet) {
+ return getDrawable((Sheet<? extends Shape, ? extends SlideShow>)shape);
+ }
+
+ throw new IllegalArgumentException("Unsupported shape type: "+shape.getClass());
+ }
+
+ public <T extends Slide<? extends Shape, ? extends SlideShow, ? extends Notes<?,?>>> DrawSlide<T> getDrawable(T sheet) {
+ return new DrawSlide<T>(sheet);
+ }
+
+ public <T extends Sheet<? extends Shape, ? extends SlideShow>> DrawSheet<T> getDrawable(T sheet) {
+ return new DrawSheet<T>(sheet);
+ }
+
+ public <T extends MasterSheet<? extends Shape, ? extends SlideShow>> DrawMasterSheet<T> getDrawable(T sheet) {
+ return new DrawMasterSheet<T>(sheet);
+ }
+
+ public <T extends TextBox<? extends TextParagraph<?>>> DrawTextBox<T> getDrawable(T shape) {
+ return new DrawTextBox<T>(shape);
+ }
+
+ public <T extends FreeformShape<? extends TextParagraph<? extends TextRun>>> DrawFreeformShape<T> getDrawable(T shape) {
+ return new DrawFreeformShape<T>(shape);
+ }
+
+ public <T extends ConnectorShape> DrawConnectorShape<T> getDrawable(T shape) {
+ return new DrawConnectorShape<T>(shape);
+ }
+
+ public <T extends TableShape> DrawTableShape<T> getDrawable(T shape) {
+ return new DrawTableShape<T>(shape);
+ }
+
+ public <T extends TextShape<? extends TextParagraph<? extends TextRun>>> DrawTextShape<T> getDrawable(T shape) {
+ return new DrawTextShape<T>(shape);
+ }
+
+ public <T extends GroupShape<? extends Shape>> DrawGroupShape<T> getDrawable(T shape) {
+ return new DrawGroupShape<T>(shape);
+ }
+
+ public <T extends PictureShape> DrawPictureShape<T> getDrawable(T shape) {
+ return new DrawPictureShape<T>(shape);
+ }
+
+ public <T extends TextRun> DrawTextParagraph<T> getDrawable(TextParagraph<T> paragraph) {
+ return new DrawTextParagraph<T>(paragraph);
+ }
+
+ public <T extends Background> DrawBackground<T> getDrawable(T shape) {
+ return new DrawBackground<T>(shape);
+ }
+
+ public DrawTextFragment getTextFragment(TextLayout layout, AttributedString str) {
+ return new DrawTextFragment(layout, str);
+ }
+
+ public DrawPaint getPaint(PlaceableShape shape) {
+ return new DrawPaint(shape);
+ }
+}
diff --git a/src/java/org/apache/poi/sl/draw/DrawFontManager.java b/src/java/org/apache/poi/sl/draw/DrawFontManager.java new file mode 100644 index 0000000000..9c49489ffc --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/DrawFontManager.java @@ -0,0 +1,38 @@ +/*
+ * ====================================================================
+ * 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.sl.draw;
+
+/**
+ * Manages fonts when rendering slides.
+ *
+ * Use this class to handle unknown / missing fonts or to substitute fonts
+ */
+public interface DrawFontManager {
+
+ /**
+ * select a font to be used to paint text
+ *
+ * @param typeface the font family as defined in the .pptx file.
+ * This can be unknown or missing in the graphic environment.
+ *
+ * @return the font to be used to paint text
+ */
+ String getRendererableFont(String typeface, int pitchFamily);
+}
diff --git a/src/java/org/apache/poi/sl/draw/DrawFreeformShape.java b/src/java/org/apache/poi/sl/draw/DrawFreeformShape.java new file mode 100644 index 0000000000..b8dd7c3f20 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/DrawFreeformShape.java @@ -0,0 +1,26 @@ +/* ====================================================================
+ 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.sl.draw;
+
+import org.apache.poi.sl.usermodel.*;
+
+public class DrawFreeformShape<T extends FreeformShape<? extends TextParagraph<? extends TextRun>>> extends DrawAutoShape<T> {
+ public DrawFreeformShape(T shape) {
+ super(shape);
+ }
+}
diff --git a/src/java/org/apache/poi/sl/draw/DrawGroupShape.java b/src/java/org/apache/poi/sl/draw/DrawGroupShape.java new file mode 100644 index 0000000000..60af5f710e --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/DrawGroupShape.java @@ -0,0 +1,70 @@ +/* ====================================================================
+ 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.sl.draw;
+
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+
+import org.apache.poi.sl.usermodel.*;
+
+
+public class DrawGroupShape<T extends GroupShape<? extends Shape>> extends DrawShape<T> implements Drawable {
+
+ public DrawGroupShape(T shape) {
+ super(shape);
+ }
+
+ public void draw(Graphics2D graphics) {
+
+ // the coordinate system of this group of shape
+ Rectangle2D interior = shape.getInteriorAnchor();
+ // anchor of this group relative to the parent shape
+ Rectangle2D exterior = shape.getAnchor();
+
+ AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);
+ AffineTransform tx0 = new AffineTransform(tx);
+
+ double scaleX = interior.getWidth() == 0. ? 1.0 : exterior.getWidth() / interior.getWidth();
+ double scaleY = interior.getHeight() == 0. ? 1.0 : exterior.getHeight() / interior.getHeight();
+
+ tx.translate(exterior.getX(), exterior.getY());
+ tx.scale(scaleX, scaleY);
+ tx.translate(-interior.getX(), -interior.getY());
+
+ DrawFactory drawFact = DrawFactory.getInstance(graphics);
+ AffineTransform at2 = graphics.getTransform();
+
+ for (Shape child : shape) {
+ // remember the initial transform and restore it after we are done with the drawing
+ AffineTransform at = graphics.getTransform();
+ graphics.setRenderingHint(Drawable.GSAVE, true);
+
+ Drawable draw = drawFact.getDrawable(child);
+ draw.applyTransform(graphics);
+ draw.draw(graphics);
+
+ // restore the coordinate system
+ graphics.setTransform(at);
+ graphics.setRenderingHint(Drawable.GRESTORE, true);
+ }
+
+ graphics.setTransform(at2);
+ graphics.setRenderingHint(Drawable.GROUP_TRANSFORM, tx0);
+ }
+}
diff --git a/src/java/org/apache/poi/sl/draw/DrawMasterSheet.java b/src/java/org/apache/poi/sl/draw/DrawMasterSheet.java new file mode 100644 index 0000000000..6b5d0781df --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/DrawMasterSheet.java @@ -0,0 +1,38 @@ +/* ====================================================================
+ 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.sl.draw;
+
+import org.apache.poi.sl.usermodel.*;
+
+
+public class DrawMasterSheet<T extends MasterSheet<? extends Shape, ? extends SlideShow>> extends DrawSheet<T> {
+
+ public DrawMasterSheet(T sheet) {
+ super(sheet);
+ }
+
+ /**
+ * Checks if this <code>sheet</code> displays the specified shape.
+ *
+ * Subclasses can override it and skip certain shapes from drawings,
+ * for instance, slide masters and layouts don't display placeholders
+ */
+ protected boolean canDraw(Shape shape){
+ return !(shape instanceof SimpleShape) || !((SimpleShape)shape).isPlaceholder();
+ }
+}
diff --git a/src/java/org/apache/poi/sl/draw/DrawPaint.java b/src/java/org/apache/poi/sl/draw/DrawPaint.java new file mode 100644 index 0000000000..16562b82a0 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/DrawPaint.java @@ -0,0 +1,444 @@ +/* ====================================================================
+ 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.sl.draw;
+
+import static org.apache.poi.sl.usermodel.PaintStyle.TRANSPARENT_PAINT;
+
+import java.awt.*;
+import java.awt.MultipleGradientPaint.ColorSpaceType;
+import java.awt.MultipleGradientPaint.CycleMethod;
+import java.awt.geom.*;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.poi.sl.usermodel.*;
+import org.apache.poi.sl.usermodel.PaintStyle.GradientPaint;
+import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
+import org.apache.poi.sl.usermodel.PaintStyle.TexturePaint;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
+
+
+/**
+ * This class handles color transformations
+ *
+ * @see HSL code taken from <a href="https://tips4java.wordpress.com/2009/07/05/hsl-color/">Java Tips Weblog</a>
+ */
+public class DrawPaint {
+ // HSL code is public domain - see https://tips4java.wordpress.com/contact-us/
+
+ private final static POILogger LOG = POILogFactory.getLogger(DrawPaint.class);
+
+ protected PlaceableShape shape;
+
+ public DrawPaint(PlaceableShape shape) {
+ this.shape = shape;
+ }
+
+ public static SolidPaint createSolidPaint(final Color color) {
+ return new SolidPaint() {
+ public ColorStyle getSolidColor() {
+ return new ColorStyle(){
+ public Color getColor() { return color; }
+ public int getAlpha() { return -1; }
+ public int getLumOff() { return -1; }
+ public int getLumMod() { return -1; }
+ public int getShade() { return -1; }
+ public int getTint() { return -1; }
+ };
+ }
+ };
+ }
+
+ public Paint getPaint(Graphics2D graphics, PaintStyle paint) {
+ if (paint instanceof SolidPaint) {
+ return getSolidPaint((SolidPaint)paint, graphics);
+ } else if (paint instanceof GradientPaint) {
+ return getGradientPaint((GradientPaint)paint, graphics);
+ } else if (paint instanceof TexturePaint) {
+ return getTexturePaint((TexturePaint)paint, graphics);
+ }
+ return null;
+ }
+
+ protected Paint getSolidPaint(SolidPaint fill, Graphics2D graphics) {
+ return applyColorTransform(fill.getSolidColor());
+ }
+
+ protected Paint getGradientPaint(GradientPaint fill, Graphics2D graphics) {
+ switch (fill.getGradientType()) {
+ case linear:
+ return createLinearGradientPaint(fill, graphics);
+ case circular:
+ return createRadialGradientPaint(fill, graphics);
+ case shape:
+ return createPathGradientPaint(fill, graphics);
+ default:
+ throw new UnsupportedOperationException("gradient fill of type "+fill+" not supported.");
+ }
+ }
+
+ protected Paint getTexturePaint(TexturePaint fill, Graphics2D graphics) {
+ InputStream is = fill.getImageData();
+ if (is == null) return TRANSPARENT_PAINT.getSolidColor().getColor();
+ assert(graphics != null);
+
+ ImageRenderer renderer = (ImageRenderer)graphics.getRenderingHint(Drawable.IMAGE_RENDERER);
+ if (renderer == null) renderer = new ImageRenderer();
+
+ try {
+ renderer.loadImage(fill.getImageData(), fill.getContentType());
+ } catch (IOException e) {
+ LOG.log(POILogger.ERROR, "Can't load image data - using transparent color", e);
+ return TRANSPARENT_PAINT.getSolidColor().getColor();
+ }
+
+ int alpha = fill.getAlpha();
+ if (alpha != -1) {
+ renderer.setAlpha(alpha/100000.f);
+ }
+
+ Dimension dim = renderer.getDimension();
+ Rectangle2D textAnchor = new Rectangle2D.Double(0, 0, dim.getWidth(), dim.getHeight());
+ Paint paint = new java.awt.TexturePaint(renderer.getImage(), textAnchor);
+
+ return paint;
+ }
+
+ /**
+ * Convert color transformations in {@link ColorStyle} to a {@link Color} instance
+ */
+ public static Color applyColorTransform(ColorStyle color){
+ Color result = color.getColor();
+
+ if (result == null || color.getAlpha() == 100) {
+ return TRANSPARENT_PAINT.getSolidColor().getColor();
+ }
+
+ result = applyAlpha(result, color);
+ result = applyLuminance(result, color);
+ result = applyShade(result, color);
+ result = applyTint(result, color);
+
+ return result;
+ }
+
+ protected static Color applyAlpha(Color c, ColorStyle fc) {
+ int alpha = c.getAlpha();
+ return (alpha == 255) ? c : new Color(c.getRed(), c.getGreen(), c.getBlue(), alpha);
+ }
+
+ /**
+ * Apply lumMod / lumOff adjustments
+ *
+ * @param c the color to modify
+ * @param lumMod luminance modulation in the range [0..100000]
+ * @param lumOff luminance offset in the range [0..100000]
+ * @return modified color
+ *
+ * @see <a href="https://msdn.microsoft.com/en-us/library/dd560821%28v=office.12%29.aspx">Using Office Open XML to Customize Document Formatting in the 2007 Office System</a>
+ */
+ protected static Color applyLuminance(Color c, ColorStyle fc) {
+ int lumMod = fc.getLumMod();
+ if (lumMod == -1) lumMod = 100000;
+
+ int lumOff = fc.getLumOff();
+ if (lumOff == -1) lumOff = 0;
+
+ if (lumMod == 100000 && lumOff == 0) return c;
+
+ // The lumMod value is the percent luminance. A lumMod value of "60000",
+ // is 60% of the luminance of the original color.
+ // When the color is a shade of the original theme color, the lumMod
+ // attribute is the only one of the tags shown here that appears.
+ // The <a:lumOff> tag appears after the <a:lumMod> tag when the color is a
+ // tint of the original. The lumOff value always equals 1-lumMod, which is used in the tint calculation
+ //
+ // Despite having different ways to display the tint and shade percentages,
+ // all of the programs use the same method to calculate the resulting color.
+ // Convert the original RGB value to HSL ... and then adjust the luminance (L)
+ // with one of the following equations before converting the HSL value back to RGB.
+ // (The % tint in the following equations refers to the tint, themetint, themeshade,
+ // or lumMod values, as applicable.)
+ //
+ // For a shade, the equation is luminance * %tint.
+ //
+ // For a tint, the equation is luminance * %tint + (1-%tint).
+ // (Note that 1-%tint is equal to the lumOff value in DrawingML.)
+
+ double fLumOff = lumOff / 100000d;
+ double fLumMod = lumMod / 100000d;
+
+ double hsl[] = RGB2HSL(c);
+ hsl[2] = hsl[2]*fLumMod+fLumOff;
+
+ Color c2 = HSL2RGB(hsl[0], hsl[1], hsl[2], c.getAlpha()/255d);
+ return c2;
+ }
+
+ /**
+ * This algorithm returns result different from PowerPoint.
+ * TODO: revisit and improve
+ */
+ protected static Color applyShade(Color c, ColorStyle fc) {
+ int shade = fc.getShade();
+ if (shade == -1) return c;
+
+ float fshade = shade / 100000.f;
+
+ float red = c.getRed() * fshade;
+ float green = c.getGreen() * fshade;
+ float blue = c.getGreen() * fshade;
+
+ return new Color(Math.round(red), Math.round(green), Math.round(blue), c.getAlpha());
+ }
+
+ /**
+ * This algorithm returns result different from PowerPoint.
+ * TODO: revisit and improve
+ */
+ protected static Color applyTint(Color c, ColorStyle fc) {
+ int tint = fc.getTint();
+ if (tint == -1) return c;
+
+ float ftint = tint / 100000.f;
+
+ float red = ftint * c.getRed() + (1.f - ftint) * 255.f;
+ float green = ftint * c.getGreen() + (1.f - ftint) * 255.f;
+ float blue = ftint * c.getBlue() + (1.f - ftint) * 255.f;
+
+ return new Color(Math.round(red), Math.round(green), Math.round(blue), c.getAlpha());
+ }
+
+
+ protected Paint createLinearGradientPaint(GradientPaint fill, Graphics2D graphics) {
+ double angle = fill.getGradientAngle();
+ Rectangle2D anchor = DrawShape.getAnchor(graphics, shape);
+
+ AffineTransform at = AffineTransform.getRotateInstance(
+ Math.toRadians(angle),
+ anchor.getX() + anchor.getWidth() / 2,
+ anchor.getY() + anchor.getHeight() / 2);
+
+ double diagonal = Math.sqrt(anchor.getHeight() * anchor.getHeight() + anchor.getWidth() * anchor.getWidth());
+ Point2D p1 = new Point2D.Double(anchor.getX() + anchor.getWidth() / 2 - diagonal / 2,
+ anchor.getY() + anchor.getHeight() / 2);
+ p1 = at.transform(p1, null);
+
+ Point2D p2 = new Point2D.Double(anchor.getX() + anchor.getWidth(), anchor.getY() + anchor.getHeight() / 2);
+ p2 = at.transform(p2, null);
+
+ snapToAnchor(p1, anchor);
+ snapToAnchor(p2, anchor);
+
+ float[] fractions = fill.getGradientFractions();
+ Color[] colors = new Color[fractions.length];
+
+ int i = 0;
+ for (ColorStyle fc : fill.getGradientColors()) {
+ colors[i++] = applyColorTransform(fc);
+ }
+
+ AffineTransform grAt = new AffineTransform();
+ if(fill.isRotatedWithShape()) {
+ double rotation = shape.getRotation();
+ if (rotation != 0.) {
+ double centerX = anchor.getX() + anchor.getWidth() / 2;
+ double centerY = anchor.getY() + anchor.getHeight() / 2;
+
+ grAt.translate(centerX, centerY);
+ grAt.rotate(Math.toRadians(-rotation));
+ grAt.translate(-centerX, -centerY);
+ }
+ }
+
+ return new LinearGradientPaint
+ (p1, p2, fractions, colors, CycleMethod.NO_CYCLE, ColorSpaceType.SRGB, grAt);
+ }
+
+ protected Paint createRadialGradientPaint(GradientPaint fill, Graphics2D graphics) {
+ Rectangle2D anchor = DrawShape.getAnchor(graphics, shape);
+
+ Point2D pCenter = new Point2D.Double(anchor.getX() + anchor.getWidth()/2,
+ anchor.getY() + anchor.getHeight()/2);
+
+ float radius = (float)Math.max(anchor.getWidth(), anchor.getHeight());
+
+ float[] fractions = fill.getGradientFractions();
+ Color[] colors = new Color[fractions.length];
+
+ int i=0;
+ for (ColorStyle fc : fill.getGradientColors()) {
+ colors[i++] = applyColorTransform(fc);
+ }
+
+ return new RadialGradientPaint(pCenter, radius, fractions, colors);
+ }
+
+ protected Paint createPathGradientPaint(GradientPaint fill, Graphics2D graphics) {
+ // currently we ignore an eventually center setting
+
+ float[] fractions = fill.getGradientFractions();
+ Color[] colors = new Color[fractions.length];
+
+ int i=0;
+ for (ColorStyle fc : fill.getGradientColors()) {
+ colors[i++] = applyColorTransform(fc);
+ }
+
+ return new PathGradientPaint(colors, fractions);
+ }
+
+ protected void snapToAnchor(Point2D p, Rectangle2D anchor) {
+ if (p.getX() < anchor.getX()) {
+ p.setLocation(anchor.getX(), p.getY());
+ } else if (p.getX() > (anchor.getX() + anchor.getWidth())) {
+ p.setLocation(anchor.getX() + anchor.getWidth(), p.getY());
+ }
+
+ if (p.getY() < anchor.getY()) {
+ p.setLocation(p.getX(), anchor.getY());
+ } else if (p.getY() > (anchor.getY() + anchor.getHeight())) {
+ p.setLocation(p.getX(), anchor.getY() + anchor.getHeight());
+ }
+ }
+
+ /**
+ * Convert HSL values to a RGB Color.
+ *
+ * @param h Hue is specified as degrees in the range 0 - 360.
+ * @param s Saturation is specified as a percentage in the range 1 - 100.
+ * @param l Luminance is specified as a percentage in the range 1 - 100.
+ * @param alpha the alpha value between 0 - 1
+ *
+ * @returns the RGB Color object
+ */
+ private static Color HSL2RGB(double h, double s, double l, double alpha) {
+ if (s <0.0f || s > 100.0f) {
+ String message = "Color parameter outside of expected range - Saturation";
+ throw new IllegalArgumentException( message );
+ }
+
+ if (l <0.0f || l > 100.0f) {
+ String message = "Color parameter outside of expected range - Luminance";
+ throw new IllegalArgumentException( message );
+ }
+
+ if (alpha <0.0f || alpha > 1.0f) {
+ String message = "Color parameter outside of expected range - Alpha";
+ throw new IllegalArgumentException( message );
+ }
+
+ // Formula needs all values between 0 - 1.
+
+ h = h % 360.0f;
+ h /= 360f;
+ s /= 100f;
+ l /= 100f;
+
+ double q = (l < 0.5d)
+ ? l * (1d + s)
+ : (l + s) - (s * l);
+
+ double p = 2d * l - q;
+
+ double r = Math.max(0, HUE2RGB(p, q, h + (1.0d / 3.0d)));
+ double g = Math.max(0, HUE2RGB(p, q, h));
+ double b = Math.max(0, HUE2RGB(p, q, h - (1.0d / 3.0d)));
+
+ r = Math.min(r, 1.0d);
+ g = Math.min(g, 1.0d);
+ b = Math.min(b, 1.0d);
+
+ return new Color((float)r, (float)g, (float)b, (float)alpha);
+ }
+
+ private static double HUE2RGB(double p, double q, double h) {
+ if (h < 0d) h += 1d;
+
+ if (h > 1d) h -= 1d;
+
+ if (6d * h < 1d) {
+ return p + ((q - p) * 6d * h);
+ }
+
+ if (2d * h < 1d) {
+ return q;
+ }
+
+ if (3d * h < 2d) {
+ return p + ( (q - p) * 6d * ((2.0d / 3.0d) - h) );
+ }
+
+ return p;
+ }
+
+
+ /**
+ * Convert a RGB Color to it corresponding HSL values.
+ *
+ * @return an array containing the 3 HSL values.
+ */
+ private static double[] RGB2HSL(Color color)
+ {
+ // Get RGB values in the range 0 - 1
+
+ float[] rgb = color.getRGBColorComponents( null );
+ double r = rgb[0];
+ double g = rgb[1];
+ double b = rgb[2];
+
+ // Minimum and Maximum RGB values are used in the HSL calculations
+
+ double min = Math.min(r, Math.min(g, b));
+ double max = Math.max(r, Math.max(g, b));
+
+ // Calculate the Hue
+
+ double h = 0;
+
+ if (max == min) {
+ h = 0;
+ } else if (max == r) {
+ h = ((60d * (g - b) / (max - min)) + 360d) % 360d;
+ } else if (max == g) {
+ h = (60d * (b - r) / (max - min)) + 120d;
+ } else if (max == b) {
+ h = (60d * (r - g) / (max - min)) + 240d;
+ }
+
+ // Calculate the Luminance
+
+ double l = (max + min) / 2d;
+
+ // Calculate the Saturation
+
+ double s = 0;
+
+ if (max == min) {
+ s = 0;
+ } else if (l <= .5d) {
+ s = (max - min) / (max + min);
+ } else {
+ s = (max - min) / (2d - max - min);
+ }
+
+ return new double[] {h, s * 100, l * 100};
+ }
+
+}
\ No newline at end of file diff --git a/src/java/org/apache/poi/sl/draw/DrawPictureShape.java b/src/java/org/apache/poi/sl/draw/DrawPictureShape.java new file mode 100644 index 0000000000..3d00b4ec6b --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/DrawPictureShape.java @@ -0,0 +1,54 @@ +/* ====================================================================
+ 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.sl.draw;
+
+import java.awt.Graphics2D;
+import java.awt.Insets;
+import java.awt.geom.Rectangle2D;
+import java.io.IOException;
+
+import org.apache.poi.sl.usermodel.PictureData;
+import org.apache.poi.sl.usermodel.PictureShape;
+
+
+public class DrawPictureShape<T extends PictureShape> extends DrawSimpleShape<T> {
+ public DrawPictureShape(T shape) {
+ super(shape);
+ }
+
+ @Override
+ public void drawContent(Graphics2D graphics) {
+ PictureData data = shape.getPictureData();
+ if(data == null) return;
+
+ ImageRenderer renderer = (ImageRenderer)graphics.getRenderingHint(Drawable.IMAGE_RENDERER);
+ if (renderer == null) renderer = new ImageRenderer();
+
+ Rectangle2D anchor = getAnchor(graphics, shape);
+
+ Insets insets = shape.getClipping();
+
+ try {
+ renderer.loadImage(data.getData(), data.getContentType());
+ renderer.drawImage(graphics, anchor, insets);
+ } catch (IOException e) {
+ // TODO: draw specific runtime exception?
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/src/java/org/apache/poi/sl/draw/DrawShape.java b/src/java/org/apache/poi/sl/draw/DrawShape.java new file mode 100644 index 0000000000..13ef4292a3 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/DrawShape.java @@ -0,0 +1,143 @@ +/* ====================================================================
+ 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.sl.draw;
+
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+
+import org.apache.poi.sl.usermodel.PlaceableShape;
+import org.apache.poi.sl.usermodel.Shape;
+
+
+public class DrawShape<T extends Shape> implements Drawable {
+
+ protected final T shape;
+
+ public DrawShape(T shape) {
+ this.shape = shape;
+ }
+
+ /**
+ * Apply 2-D transforms before drawing this shape. This includes rotation and flipping.
+ *
+ * @param graphics the graphics whos transform matrix will be modified
+ */
+ public void applyTransform(Graphics2D graphics) {
+ if (!(shape instanceof PlaceableShape)) return;
+
+ PlaceableShape ps = (PlaceableShape)shape;
+ AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);
+ if (tx == null) tx = new AffineTransform();
+ final Rectangle2D anchor = tx.createTransformedShape(ps.getAnchor()).getBounds2D();
+
+ // rotation
+ double rotation = ps.getRotation();
+ if (rotation != 0.) {
+ // PowerPoint rotates shapes relative to the geometric center
+ double centerX = anchor.getCenterX();
+ double centerY = anchor.getCenterY();
+
+ // normalize rotation
+ rotation %= 360.;
+ if (rotation < 0) rotation += 360.;
+
+ int quadrant = (((int)rotation+45)/90)%4;
+ double scaleX = 1.0, scaleY = 1.0;
+
+ // scale to bounding box (bug #53176)
+ if (quadrant == 1 || quadrant == 3) {
+ // In quadrant 1 and 3, which is basically a shape in a more or less portrait orientation
+ // (45-135 degrees and 225-315 degrees), we need to first rotate the shape by a multiple
+ // of 90 degrees and then resize the bounding box to its original bbox. After that we can
+ // rotate the shape to the exact rotation amount.
+ // It's strange that you'll need to rotate the shape back and forth again, but you can
+ // think of it, as if you paint the shape on a canvas. First you rotate the canvas, which might
+ // be already (differently) scaled, so you can paint the shape in its default orientation
+ // and later on, turn it around again to compare it with its original size ...
+
+ AffineTransform txs;
+ if (ps.getClass().getCanonicalName().toLowerCase().contains("hslf")) {
+ txs = new AffineTransform(tx);
+ } else {
+ // this handling is only based on try and error ... not sure why xslf is handled differently.
+ txs = new AffineTransform();
+ txs.translate(centerX, centerY);
+ txs.rotate(Math.PI/2.); // actually doesn't matter if +/- 90 degrees
+ txs.translate(-centerX, -centerY);
+ txs.concatenate(tx);
+ }
+
+ txs.translate(centerX, centerY);
+ txs.rotate(Math.PI/2.);
+ txs.translate(-centerX, -centerY);
+
+ Rectangle2D anchor2 = txs.createTransformedShape(ps.getAnchor()).getBounds2D();
+
+ scaleX = anchor.getWidth() == 0. ? 1.0 : anchor.getWidth() / anchor2.getWidth();
+ scaleY = anchor.getHeight() == 0. ? 1.0 : anchor.getHeight() / anchor2.getHeight();
+ } else {
+ quadrant = 0;
+ }
+
+ // transformation is applied reversed ...
+ graphics.translate(centerX, centerY);
+ graphics.rotate(Math.toRadians(rotation-quadrant*90.));
+ graphics.scale(scaleX, scaleY);
+ graphics.rotate(Math.toRadians(quadrant*90));
+ graphics.translate(-centerX, -centerY);
+ }
+
+ //flip horizontal
+ if (ps.getFlipHorizontal()) {
+ graphics.translate(anchor.getX() + anchor.getWidth(), anchor.getY());
+ graphics.scale(-1, 1);
+ graphics.translate(-anchor.getX(), -anchor.getY());
+ }
+
+ //flip vertical
+ if (ps.getFlipVertical()) {
+ graphics.translate(anchor.getX(), anchor.getY() + anchor.getHeight());
+ graphics.scale(1, -1);
+ graphics.translate(-anchor.getX(), -anchor.getY());
+ }
+ }
+
+
+ public void draw(Graphics2D graphics) {
+ }
+
+ public void drawContent(Graphics2D context) {
+ }
+
+ public static Rectangle2D getAnchor(Graphics2D graphics, PlaceableShape shape) {
+ return getAnchor(graphics, shape.getAnchor());
+ }
+
+ public static Rectangle2D getAnchor(Graphics2D graphics, Rectangle2D anchor) {
+ if(graphics == null) {
+ return anchor;
+ }
+
+ AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);
+ if(tx != null) {
+ anchor = tx.createTransformedShape(anchor).getBounds2D();
+ }
+ return anchor;
+ }
+}
diff --git a/src/java/org/apache/poi/sl/draw/DrawSheet.java b/src/java/org/apache/poi/sl/draw/DrawSheet.java new file mode 100644 index 0000000000..e4c7e185e8 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/DrawSheet.java @@ -0,0 +1,91 @@ +/* ====================================================================
+ 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.sl.draw;
+
+import java.awt.Dimension;
+import java.awt.Color;
+import java.awt.Graphics2D;
+
+import java.awt.geom.AffineTransform;
+
+import org.apache.poi.sl.usermodel.*;
+
+
+public class DrawSheet<T extends Sheet<? extends Shape, ? extends SlideShow>> implements Drawable {
+
+ protected final T sheet;
+
+ public DrawSheet(T sheet) {
+ this.sheet = sheet;
+ }
+
+ public void draw(Graphics2D graphics) {
+ Dimension dim = sheet.getSlideShow().getPageSize();
+ Color whiteTrans = new Color(1f,1f,1f,0f);
+ graphics.setColor(whiteTrans);
+ graphics.fillRect(0, 0, (int)dim.getWidth(), (int)dim.getHeight());
+
+ DrawFactory drawFact = DrawFactory.getInstance(graphics);
+ MasterSheet<? extends Shape, ? extends SlideShow> master = sheet.getMasterSheet();
+
+ if(sheet.getFollowMasterGraphics() && master != null) {
+ Drawable drawer = drawFact.getDrawable(master);
+ drawer.draw(graphics);
+ }
+
+ graphics.setRenderingHint(Drawable.GROUP_TRANSFORM, new AffineTransform());
+
+ for (Shape shape : sheet.getShapes()) {
+ if(!canDraw(shape)) continue;
+
+ // remember the initial transform and restore it after we are done with drawing
+ AffineTransform at = graphics.getTransform();
+
+ // concrete implementations can make sense of this hint,
+ // for example PSGraphics2D or PDFGraphics2D would call gsave() / grestore
+ graphics.setRenderingHint(Drawable.GSAVE, true);
+
+ // apply rotation and flipping
+ Drawable drawer = drawFact.getDrawable(shape);
+ drawer.applyTransform(graphics);
+ // draw stuff
+ drawer.draw(graphics);
+
+ // restore the coordinate system
+ graphics.setTransform(at);
+
+ graphics.setRenderingHint(Drawable.GRESTORE, true);
+ }
+ }
+
+ public void applyTransform(Graphics2D context) {
+ }
+
+ public void drawContent(Graphics2D context) {
+ }
+
+ /**
+ * Checks if this <code>sheet</code> displays the specified shape.
+ *
+ * Subclasses can override it and skip certain shapes from drawings,
+ * for instance, slide masters and layouts don't display placeholders
+ */
+ protected boolean canDraw(Shape shape){
+ return true;
+ }
+}
diff --git a/src/java/org/apache/poi/sl/draw/DrawSimpleShape.java b/src/java/org/apache/poi/sl/draw/DrawSimpleShape.java new file mode 100644 index 0000000000..e674166090 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/DrawSimpleShape.java @@ -0,0 +1,420 @@ +/* ====================================================================
+ 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.sl.draw;
+
+import java.awt.*;
+import java.awt.geom.*;
+import java.io.*;
+import java.nio.charset.Charset;
+import java.util.*;
+import java.util.List;
+
+import javax.xml.bind.*;
+import javax.xml.stream.*;
+import javax.xml.stream.EventFilter;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.poi.sl.draw.binding.CTCustomGeometry2D;
+import org.apache.poi.sl.draw.geom.*;
+import org.apache.poi.sl.usermodel.*;
+import org.apache.poi.sl.usermodel.LineDecoration.DecorationSize;
+import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
+import org.apache.poi.sl.usermodel.StrokeStyle.*;
+import org.apache.poi.util.Units;
+
+
+public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {
+
+ public DrawSimpleShape(T shape) {
+ super(shape);
+ }
+
+ @Override
+ public void draw(Graphics2D graphics) {
+// RenderableShape rShape = new RenderableShape(this);
+// rShape.render(graphics);
+
+ DrawPaint drawPaint = DrawFactory.getInstance(graphics).getPaint(shape);
+ Paint fill = drawPaint.getPaint(graphics, shape.getFillStyle().getPaint());
+ Paint line = drawPaint.getPaint(graphics, shape.getStrokeStyle().getPaint());
+ BasicStroke stroke = getStroke(); // the stroke applies both to the shadow and the shape
+ graphics.setStroke(stroke);
+
+ Collection<Outline> elems = computeOutlines(graphics);
+
+ // first paint the shadow
+ drawShadow(graphics, elems, fill, line);
+
+ // then fill the shape interior
+ if (fill != null) {
+ graphics.setPaint(fill);
+ for (Outline o : elems) {
+ if (o.getPath().isFilled()){
+ java.awt.Shape s = o.getOutline();
+ graphics.setRenderingHint(Drawable.GRADIENT_SHAPE, s);
+ graphics.fill(s);
+ }
+ }
+ }
+
+ // then draw any content within this shape (text, image, etc.)
+ drawContent(graphics);
+
+ // then stroke the shape outline
+ if(line != null) {
+ graphics.setPaint(line);
+ for(Outline o : elems){
+ if(o.getPath().isStroked()){
+ java.awt.Shape s = o.getOutline();
+ graphics.setRenderingHint(Drawable.GRADIENT_SHAPE, s);
+ graphics.draw(s);
+ }
+ }
+ }
+
+ // draw line decorations
+ drawDecoration(graphics, line, stroke);
+ }
+
+ protected void drawDecoration(Graphics2D graphics, Paint line, BasicStroke stroke) {
+ if(line == null) return;
+ graphics.setPaint(line);
+
+ List<Outline> lst = new ArrayList<Outline>();
+ LineDecoration deco = shape.getLineDecoration();
+ Outline head = getHeadDecoration(graphics, deco, stroke);
+ if (head != null) lst.add(head);
+ Outline tail = getTailDecoration(graphics, deco, stroke);
+ if (tail != null) lst.add(tail);
+
+
+ for(Outline o : lst){
+ java.awt.Shape s = o.getOutline();
+ Path p = o.getPath();
+ graphics.setRenderingHint(Drawable.GRADIENT_SHAPE, s);
+
+ if(p.isFilled()) graphics.fill(s);
+ if(p.isStroked()) graphics.draw(s);
+ }
+ }
+
+ protected Outline getTailDecoration(Graphics2D graphics, LineDecoration deco, BasicStroke stroke) {
+ DecorationSize tailLength = deco.getTailLength();
+ DecorationSize tailWidth = deco.getTailWidth();
+
+ double lineWidth = Math.max(2.5, stroke.getLineWidth());
+
+ Rectangle2D anchor = getAnchor(graphics, shape);
+ double x2 = anchor.getX() + anchor.getWidth(),
+ y2 = anchor.getY() + anchor.getHeight();
+
+ double alpha = Math.atan(anchor.getHeight() / anchor.getWidth());
+
+ AffineTransform at = new AffineTransform();
+ java.awt.Shape shape = null;
+ Path p = null;
+ Rectangle2D bounds;
+ double scaleY = Math.pow(2, tailWidth.ordinal());
+ double scaleX = Math.pow(2, tailLength.ordinal());
+ switch (deco.getTailShape()) {
+ case OVAL:
+ p = new Path();
+ shape = new Ellipse2D.Double(0, 0, lineWidth * scaleX, lineWidth * scaleY);
+ bounds = shape.getBounds2D();
+ at.translate(x2 - bounds.getWidth() / 2, y2 - bounds.getHeight() / 2);
+ at.rotate(alpha, bounds.getX() + bounds.getWidth() / 2, bounds.getY() + bounds.getHeight() / 2);
+ break;
+ case ARROW:
+ p = new Path();
+ GeneralPath arrow = new GeneralPath();
+ arrow.moveTo((float) (-lineWidth * 3), (float) (-lineWidth * 2));
+ arrow.lineTo(0, 0);
+ arrow.lineTo((float) (-lineWidth * 3), (float) (lineWidth * 2));
+ shape = arrow;
+ at.translate(x2, y2);
+ at.rotate(alpha);
+ break;
+ case TRIANGLE:
+ p = new Path();
+ scaleY = tailWidth.ordinal() + 1;
+ scaleX = tailLength.ordinal() + 1;
+ GeneralPath triangle = new GeneralPath();
+ triangle.moveTo((float) (-lineWidth * scaleX), (float) (-lineWidth * scaleY / 2));
+ triangle.lineTo(0, 0);
+ triangle.lineTo((float) (-lineWidth * scaleX), (float) (lineWidth * scaleY / 2));
+ triangle.closePath();
+ shape = triangle;
+ at.translate(x2, y2);
+ at.rotate(alpha);
+ break;
+ default:
+ break;
+ }
+
+ if (shape != null) {
+ shape = at.createTransformedShape(shape);
+ }
+ return shape == null ? null : new Outline(shape, p);
+ }
+
+ Outline getHeadDecoration(Graphics2D graphics, LineDecoration deco, BasicStroke stroke) {
+ DecorationSize headLength = deco.getHeadLength();
+ DecorationSize headWidth = deco.getHeadWidth();
+
+ double lineWidth = Math.max(2.5, stroke.getLineWidth());
+
+ Rectangle2D anchor = getAnchor(graphics, shape);
+ double x1 = anchor.getX(),
+ y1 = anchor.getY();
+
+ double alpha = Math.atan(anchor.getHeight() / anchor.getWidth());
+
+ AffineTransform at = new AffineTransform();
+ java.awt.Shape shape = null;
+ Path p = null;
+ Rectangle2D bounds;
+ double scaleY = 1;
+ double scaleX = 1;
+ switch (deco.getHeadShape()) {
+ case OVAL:
+ p = new Path();
+ shape = new Ellipse2D.Double(0, 0, lineWidth * scaleX, lineWidth * scaleY);
+ bounds = shape.getBounds2D();
+ at.translate(x1 - bounds.getWidth() / 2, y1 - bounds.getHeight() / 2);
+ at.rotate(alpha, bounds.getX() + bounds.getWidth() / 2, bounds.getY() + bounds.getHeight() / 2);
+ break;
+ case STEALTH:
+ case ARROW:
+ p = new Path(false, true);
+ GeneralPath arrow = new GeneralPath();
+ arrow.moveTo((float) (lineWidth * 3 * scaleX), (float) (-lineWidth * scaleY * 2));
+ arrow.lineTo(0, 0);
+ arrow.lineTo((float) (lineWidth * 3 * scaleX), (float) (lineWidth * scaleY * 2));
+ shape = arrow;
+ at.translate(x1, y1);
+ at.rotate(alpha);
+ break;
+ case TRIANGLE:
+ p = new Path();
+ scaleY = headWidth.ordinal() + 1;
+ scaleX = headLength.ordinal() + 1;
+ GeneralPath triangle = new GeneralPath();
+ triangle.moveTo((float) (lineWidth * scaleX), (float) (-lineWidth * scaleY / 2));
+ triangle.lineTo(0, 0);
+ triangle.lineTo((float) (lineWidth * scaleX), (float) (lineWidth * scaleY / 2));
+ triangle.closePath();
+ shape = triangle;
+ at.translate(x1, y1);
+ at.rotate(alpha);
+ break;
+ default:
+ break;
+ }
+
+ if (shape != null) {
+ shape = at.createTransformedShape(shape);
+ }
+ return shape == null ? null : new Outline(shape, p);
+ }
+
+ public BasicStroke getStroke() {
+ StrokeStyle strokeStyle = shape.getStrokeStyle();
+
+ float lineWidth = (float) strokeStyle.getLineWidth();
+ if (lineWidth == 0.0f) lineWidth = 0.25f; // Both PowerPoint and OOo draw zero-length lines as 0.25pt
+
+ LineDash lineDash = strokeStyle.getLineDash();
+ if (lineDash == null) {
+ lineDash = LineDash.SOLID;
+ }
+
+ int dashPatI[] = lineDash.pattern;
+ final float dash_phase = 0;
+ float[] dashPatF = null;
+ if (dashPatI != null) {
+ dashPatF = new float[dashPatI.length];
+ for (int i=0; i<dashPatI.length; i++) {
+ dashPatF[i] = dashPatI[i]*Math.max(1, lineWidth);
+ }
+ }
+
+ LineCap lineCapE = strokeStyle.getLineCap();
+ if (lineCapE == null) lineCapE = LineCap.FLAT;
+ int lineCap;
+ switch (lineCapE) {
+ case ROUND:
+ lineCap = BasicStroke.CAP_ROUND;
+ break;
+ case SQUARE:
+ lineCap = BasicStroke.CAP_SQUARE;
+ break;
+ default:
+ case FLAT:
+ lineCap = BasicStroke.CAP_BUTT;
+ break;
+ }
+
+ int lineJoin = BasicStroke.JOIN_ROUND;
+
+ return new BasicStroke(lineWidth, lineCap, lineJoin, lineWidth, dashPatF, dash_phase);
+ }
+
+ protected void drawShadow(
+ Graphics2D graphics
+ , Collection<Outline> outlines
+ , Paint fill
+ , Paint line
+ ) {
+ Shadow shadow = shape.getShadow();
+ if (shadow == null || (fill == null && line == null)) return;
+
+ SolidPaint shadowPaint = shadow.getFillStyle();
+ Color shadowColor = DrawPaint.applyColorTransform(shadowPaint.getSolidColor());
+
+ double shapeRotation = shape.getRotation();
+ if(shape.getFlipVertical()) {
+ shapeRotation += 180;
+ }
+ double angle = shadow.getAngle() - shapeRotation;
+ double dist = shadow.getDistance();
+ double dx = dist * Math.cos(Math.toRadians(angle));
+ double dy = dist * Math.sin(Math.toRadians(angle));
+
+ graphics.translate(dx, dy);
+
+ for(Outline o : outlines){
+ java.awt.Shape s = o.getOutline();
+ Path p = o.getPath();
+ graphics.setRenderingHint(Drawable.GRADIENT_SHAPE, s);
+ graphics.setPaint(shadowColor);
+
+ if(fill != null && p.isFilled()){
+ graphics.fill(s);
+ } else if (line != null && p.isStroked()) {
+ graphics.draw(s);
+ }
+ }
+
+ graphics.translate(-dx, -dy);
+ }
+
+ protected static CustomGeometry getCustomGeometry(String name) {
+ return getCustomGeometry(name, null);
+ }
+
+ protected static CustomGeometry getCustomGeometry(String name, Graphics2D graphics) {
+ @SuppressWarnings("unchecked")
+ Map<String, CustomGeometry> presets = (graphics == null)
+ ? null
+ : (Map<String, CustomGeometry>)graphics.getRenderingHint(Drawable.PRESET_GEOMETRY_CACHE);
+
+ if (presets == null) {
+ presets = new HashMap<String,CustomGeometry>();
+ if (graphics != null) {
+ graphics.setRenderingHint(Drawable.PRESET_GEOMETRY_CACHE, presets);
+ }
+
+ String packageName = "org.apache.poi.sl.draw.binding";
+ InputStream presetIS = Drawable.class.getResourceAsStream("presetShapeDefinitions.xml");
+ Reader xml = new InputStreamReader( presetIS, Charset.forName("UTF-8") );
+
+ // StAX:
+ EventFilter startElementFilter = new EventFilter() {
+ @Override
+ public boolean accept(XMLEvent event) {
+ return event.isStartElement();
+ }
+ };
+
+ try {
+ XMLInputFactory staxFactory = XMLInputFactory.newInstance();
+ XMLEventReader staxReader = staxFactory.createXMLEventReader(xml);
+ XMLEventReader staxFiltRd = staxFactory.createFilteredReader(staxReader, startElementFilter);
+ // Ignore StartElement:
+ staxFiltRd.nextEvent();
+ // JAXB:
+ JAXBContext jaxbContext = JAXBContext.newInstance(packageName);
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+
+ while (staxFiltRd.peek() != null) {
+ StartElement evRoot = (StartElement)staxFiltRd.peek();
+ String cusName = evRoot.getName().getLocalPart();
+ // XMLEvent ev = staxReader.nextEvent();
+ JAXBElement<org.apache.poi.sl.draw.binding.CTCustomGeometry2D> el = unmarshaller.unmarshal(staxReader, CTCustomGeometry2D.class);
+ CTCustomGeometry2D cusGeom = el.getValue();
+
+ presets.put(cusName, new CustomGeometry(cusGeom));
+ }
+ } catch (Exception e) {
+ throw new RuntimeException("Unable to load preset geometries.", e);
+ }
+ }
+
+ return presets.get(name);
+ }
+
+ protected Collection<Outline> computeOutlines(Graphics2D graphics) {
+
+ List<Outline> lst = new ArrayList<Outline>();
+ CustomGeometry geom = shape.getGeometry();
+ if(geom == null) {
+ return lst;
+ }
+
+ Rectangle2D anchor = getAnchor(graphics, shape);
+ for (Path p : geom) {
+
+ double w = p.getW() == -1 ? anchor.getWidth() * Units.EMU_PER_POINT : p.getW();
+ double h = p.getH() == -1 ? anchor.getHeight() * Units.EMU_PER_POINT : p.getH();
+
+ // the guides in the shape definitions are all defined relative to each other,
+ // so we build the path starting from (0,0).
+ final Rectangle2D pathAnchor = new Rectangle2D.Double(0,0,w,h);
+
+ Context ctx = new Context(geom, pathAnchor, shape);
+
+ java.awt.Shape gp = p.getPath(ctx);
+
+ // translate the result to the canvas coordinates in points
+ AffineTransform at = new AffineTransform();
+ at.translate(anchor.getX(), anchor.getY());
+
+ double scaleX, scaleY;
+ if (p.getW() != -1) {
+ scaleX = anchor.getWidth() / p.getW();
+ } else {
+ scaleX = 1.0 / Units.EMU_PER_POINT;
+ }
+ if (p.getH() != -1) {
+ scaleY = anchor.getHeight() / p.getH();
+ } else {
+ scaleY = 1.0 / Units.EMU_PER_POINT;
+ }
+
+ at.scale(scaleX, scaleY);
+
+ java.awt.Shape canvasShape = at.createTransformedShape(gp);
+
+ lst.add(new Outline(canvasShape, p));
+ }
+
+ return lst;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/DrawSlide.java b/src/java/org/apache/poi/sl/draw/DrawSlide.java new file mode 100644 index 0000000000..cfa316738e --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/DrawSlide.java @@ -0,0 +1,41 @@ +/* ====================================================================
+ 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.sl.draw;
+
+import java.awt.Graphics2D;
+
+import org.apache.poi.sl.usermodel.*;
+
+
+public class DrawSlide<T extends Slide<? extends Shape, ? extends SlideShow, ? extends Notes<?,?>>> extends DrawSheet<T> {
+
+ public DrawSlide(T slide) {
+ super(slide);
+ }
+
+ public void draw(Graphics2D graphics) {
+ Background bg = sheet.getBackground();
+ if(bg != null) {
+ DrawFactory drawFact = DrawFactory.getInstance(graphics);
+ Drawable db = drawFact.getDrawable(bg);
+ db.draw(graphics);
+ }
+
+ super.draw(graphics);
+ }
+}
diff --git a/src/java/org/apache/poi/sl/draw/DrawTableShape.java b/src/java/org/apache/poi/sl/draw/DrawTableShape.java new file mode 100644 index 0000000000..ceb6450d0b --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/DrawTableShape.java @@ -0,0 +1,27 @@ +/* ====================================================================
+ 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.sl.draw;
+
+import org.apache.poi.sl.usermodel.*;
+
+public class DrawTableShape<T extends TableShape> extends DrawShape<T> {
+ // to be implemented ...
+ public DrawTableShape(T shape) {
+ super(shape);
+ }
+}
diff --git a/src/java/org/apache/poi/sl/draw/DrawTextBox.java b/src/java/org/apache/poi/sl/draw/DrawTextBox.java new file mode 100644 index 0000000000..89d69223ff --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/DrawTextBox.java @@ -0,0 +1,26 @@ +/* ====================================================================
+ 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.sl.draw;
+
+import org.apache.poi.sl.usermodel.*;
+
+public class DrawTextBox<T extends TextBox<? extends TextParagraph<? extends TextRun>>> extends DrawAutoShape<T> {
+ public DrawTextBox(T shape) {
+ super(shape);
+ }
+}
diff --git a/src/java/org/apache/poi/sl/draw/DrawTextFragment.java b/src/java/org/apache/poi/sl/draw/DrawTextFragment.java new file mode 100644 index 0000000000..acb6b4c766 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/DrawTextFragment.java @@ -0,0 +1,105 @@ +/* ====================================================================
+ 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.sl.draw;
+
+import java.awt.Graphics2D;
+import java.awt.font.TextLayout;
+import java.text.*;
+
+public class DrawTextFragment implements Drawable {
+ final TextLayout layout;
+ final AttributedString str;
+ double x, y;
+
+ public DrawTextFragment(TextLayout layout, AttributedString str) {
+ this.layout = layout;
+ this.str = str;
+ }
+
+ public void setPosition(double x, double y) {
+ // TODO: replace it, by applyTransform????
+ this.x = x;
+ this.y = y;
+ }
+
+ public void draw(Graphics2D graphics){
+ if(str == null) {
+ return;
+ }
+
+ double yBaseline = y + layout.getAscent();
+
+ Integer textMode = (Integer)graphics.getRenderingHint(Drawable.TEXT_RENDERING_MODE);
+ if(textMode != null && textMode == Drawable.TEXT_AS_SHAPES){
+ layout.draw(graphics, (float)x, (float)yBaseline);
+ } else {
+ graphics.drawString(str.getIterator(), (float)x, (float)yBaseline );
+ }
+ }
+
+ public void applyTransform(Graphics2D graphics) {
+ }
+
+ public void drawContent(Graphics2D graphics) {
+ }
+
+ public TextLayout getLayout() {
+ return layout;
+ }
+
+ public AttributedString getAttributedString() {
+ return str;
+ }
+
+ /**
+ * @return full height of this text run which is sum of ascent, descent and leading
+ */
+ public float getHeight(){
+ double h = Math.ceil(layout.getAscent()) + Math.ceil(layout.getDescent()) + layout.getLeading();
+ return (float)h;
+ }
+
+ /**
+ *
+ * @return width if this text run
+ */
+ public float getWidth(){
+ return layout.getAdvance();
+ }
+
+ /**
+ *
+ * @return the string to be painted
+ */
+ public String getString(){
+ if (str == null) return "";
+
+ AttributedCharacterIterator it = str.getIterator();
+ StringBuilder buf = new StringBuilder();
+ for (char c = it.first(); c != CharacterIterator.DONE; c = it.next()) {
+ buf.append(c);
+ }
+ return buf.toString();
+ }
+
+ @Override
+ public String toString(){
+ return "[" + getClass().getSimpleName() + "] " + getString();
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java b/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java new file mode 100644 index 0000000000..e2db501e85 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java @@ -0,0 +1,462 @@ +/* ====================================================================
+ 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.sl.draw;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.font.*;
+import java.awt.geom.Rectangle2D;
+import java.text.*;
+import java.text.AttributedCharacterIterator.Attribute;
+import java.util.*;
+
+import org.apache.poi.sl.usermodel.*;
+import org.apache.poi.sl.usermodel.TextParagraph.BulletStyle;
+import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
+import org.apache.poi.sl.usermodel.TextRun.TextCap;
+import org.apache.poi.util.Units;
+
+public class DrawTextParagraph<T extends TextRun> implements Drawable {
+ protected TextParagraph<T> paragraph;
+ double x, y;
+ protected List<DrawTextFragment> lines = new ArrayList<DrawTextFragment>();
+ protected String rawText;
+ protected DrawTextFragment bullet;
+ protected int autoNbrIdx = 0;
+
+ /**
+ * the highest line in this paragraph. Used for line spacing.
+ */
+ protected double maxLineHeight;
+
+ public DrawTextParagraph(TextParagraph<T> paragraph) {
+ this.paragraph = paragraph;
+ }
+
+ public void setPosition(double x, double y) {
+ // TODO: replace it, by applyTransform????
+ this.x = x;
+ this.y = y;
+ }
+
+ public double getY() {
+ return y;
+ }
+
+ /**
+ * Sets the auto numbering index of the handled paragraph
+ * @param index the auto numbering index
+ */
+ public void setAutoNumberingIdx(int index) {
+ autoNbrIdx = index;
+ }
+
+ public void draw(Graphics2D graphics){
+ if (lines.isEmpty()) return;
+
+ Insets2D insets = paragraph.getParentShape().getInsets();
+ double leftInset = insets.left;
+ double rightInset = insets.right;
+ double penY = y;
+
+ boolean firstLine = true;
+ int indentLevel = paragraph.getIndentLevel();
+ Double leftMargin = paragraph.getLeftMargin();
+ if (leftMargin == null) {
+ // if the marL attribute is omitted, then a value of 347663 is implied
+ leftMargin = Units.toPoints(347663*(indentLevel+1));
+ }
+ Double indent = paragraph.getIndent();
+ if (indent == null) {
+ indent = Units.toPoints(347663*indentLevel);
+ }
+ Double rightMargin = paragraph.getRightMargin();
+ if (rightMargin == null) {
+ rightMargin = 0d;
+ }
+
+ //The vertical line spacing
+ Double spacing = paragraph.getLineSpacing();
+ if (spacing == null) spacing = 100d;
+
+ for(DrawTextFragment line : lines){
+ double penX;
+
+ if(firstLine) {
+ if (!isEmptyParagraph()) {
+ // TODO: find out character style for empty, but bulleted/numbered lines
+ bullet = getBullet(graphics, line.getAttributedString().getIterator());
+ }
+
+ if (bullet != null){
+ bullet.setPosition(x + indent, penY);
+ bullet.draw(graphics);
+ // don't let text overlay the bullet and advance by the bullet width
+ double bulletWidth = bullet.getLayout().getAdvance() + 1;
+ penX = x + Math.max(leftMargin, indent+bulletWidth);
+ } else {
+ penX = x + indent;
+ }
+ } else {
+ penX = x + leftMargin;
+ }
+
+ Rectangle2D anchor = DrawShape.getAnchor(graphics, paragraph.getParentShape());
+
+ TextAlign ta = paragraph.getTextAlign();
+ if (ta == null) ta = TextAlign.LEFT;
+ switch (ta) {
+ case CENTER:
+ penX += (anchor.getWidth() - leftMargin - line.getWidth() - leftInset - rightInset) / 2;
+ break;
+ case RIGHT:
+ penX += (anchor.getWidth() - line.getWidth() - leftInset - rightInset);
+ break;
+ default:
+ break;
+ }
+
+ line.setPosition(penX, penY);
+ line.draw(graphics);
+
+ if(spacing > 0) {
+ // If linespacing >= 0, then linespacing is a percentage of normal line height.
+ penY += spacing*0.01* line.getHeight();
+ } else {
+ // negative value means absolute spacing in points
+ penY += -spacing;
+ }
+
+ firstLine = false;
+ }
+
+ y = penY - y;
+ }
+
+ public float getFirstLineHeight() {
+ return (lines.isEmpty()) ? 0 : lines.get(0).getHeight();
+ }
+
+ public float getLastLineHeight() {
+ return (lines.isEmpty()) ? 0 : lines.get(lines.size()-1).getHeight();
+ }
+
+ public boolean isEmptyParagraph() {
+ return (lines.isEmpty() || rawText.trim().isEmpty());
+ }
+
+ public void applyTransform(Graphics2D graphics) {
+ }
+
+ public void drawContent(Graphics2D graphics) {
+ }
+
+ /**
+ * break text into lines, each representing a line of text that fits in the wrapping width
+ *
+ * @param graphics
+ */
+ protected void breakText(Graphics2D graphics){
+ lines.clear();
+
+ DrawFactory fact = DrawFactory.getInstance(graphics);
+ StringBuilder text = new StringBuilder();
+ AttributedString at = getAttributedString(graphics, text);
+ boolean emptyParagraph = ("".equals(text.toString().trim()));
+
+ AttributedCharacterIterator it = at.getIterator();
+ LineBreakMeasurer measurer = new LineBreakMeasurer(it, graphics.getFontRenderContext());
+ for (;;) {
+ int startIndex = measurer.getPosition();
+
+ double wrappingWidth = getWrappingWidth(lines.size() == 0, graphics) + 1; // add a pixel to compensate rounding errors
+ // shape width can be smaller that the sum of insets (this was proved by a test file)
+ if(wrappingWidth < 0) wrappingWidth = 1;
+
+ int nextBreak = text.indexOf("\n", startIndex + 1);
+ if(nextBreak == -1) nextBreak = it.getEndIndex();
+
+ TextLayout layout = measurer.nextLayout((float)wrappingWidth, nextBreak, true);
+ if (layout == null) {
+ // layout can be null if the entire word at the current position
+ // does not fit within the wrapping width. Try with requireNextWord=false.
+ layout = measurer.nextLayout((float)wrappingWidth, nextBreak, false);
+ }
+
+ if(layout == null) {
+ // exit if can't break any more
+ break;
+ }
+
+ int endIndex = measurer.getPosition();
+ // skip over new line breaks (we paint 'clear' text runs not starting or ending with \n)
+ if(endIndex < it.getEndIndex() && text.charAt(endIndex) == '\n'){
+ measurer.setPosition(endIndex + 1);
+ }
+
+ TextAlign hAlign = paragraph.getTextAlign();
+ if(hAlign == TextAlign.JUSTIFY || hAlign == TextAlign.JUSTIFY_LOW) {
+ layout = layout.getJustifiedLayout((float)wrappingWidth);
+ }
+
+ AttributedString str = (emptyParagraph)
+ ? null // we will not paint empty paragraphs
+ : new AttributedString(it, startIndex, endIndex);
+ DrawTextFragment line = fact.getTextFragment(layout, str);
+ lines.add(line);
+
+ maxLineHeight = Math.max(maxLineHeight, line.getHeight());
+
+ if(endIndex == it.getEndIndex()) break;
+ }
+
+ rawText = text.toString();
+ }
+
+ protected DrawTextFragment getBullet(Graphics2D graphics, AttributedCharacterIterator firstLineAttr) {
+ BulletStyle bulletStyle = paragraph.getBulletStyle();
+ if (bulletStyle == null) return null;
+
+ String buCharacter;
+ AutoNumberingScheme ans = bulletStyle.getAutoNumberingScheme();
+ if (ans != null) {
+ buCharacter = ans.format(autoNbrIdx);
+ } else {
+ buCharacter = bulletStyle.getBulletCharacter();
+ }
+ if (buCharacter == null) return null;
+
+ String buFont = bulletStyle.getBulletFont();
+ if (buFont == null) buFont = paragraph.getDefaultFontFamily();
+ assert(buFont != null);
+
+ Color buColor = bulletStyle.getBulletFontColor();
+ if (buColor == null) buColor = (Color)firstLineAttr.getAttribute(TextAttribute.FOREGROUND);
+
+ float fontSize = (Float)firstLineAttr.getAttribute(TextAttribute.SIZE);
+ Double buSz = bulletStyle.getBulletFontSize();
+ if (buSz == null) buSz = 100d;
+ if (buSz > 0) fontSize *= buSz* 0.01;
+ else fontSize = (float)-buSz;
+
+
+ AttributedString str = new AttributedString(buCharacter);
+ str.addAttribute(TextAttribute.FOREGROUND, buColor);
+ str.addAttribute(TextAttribute.FAMILY, buFont);
+ str.addAttribute(TextAttribute.SIZE, fontSize);
+
+ TextLayout layout = new TextLayout(str.getIterator(), graphics.getFontRenderContext());
+ DrawFactory fact = DrawFactory.getInstance(graphics);
+ return fact.getTextFragment(layout, str);
+ }
+
+ protected String getRenderableText(TextRun tr) {
+ StringBuilder buf = new StringBuilder();
+ TextCap cap = tr.getTextCap();
+ String tabs = null;
+ for (char c : tr.getRawText().toCharArray()) {
+ if(c == '\t') {
+ if (tabs == null) {
+ tabs = tab2space(tr);
+ }
+ buf.append(tabs);
+ continue;
+ }
+
+ switch (cap) {
+ case ALL: c = Character.toUpperCase(c); break;
+ case SMALL: c = Character.toLowerCase(c); break;
+ case NONE: break;
+ }
+
+ buf.append(c);
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ * Replace a tab with the effective number of white spaces.
+ */
+ private String tab2space(TextRun tr) {
+ AttributedString string = new AttributedString(" ");
+ String typeFace = tr.getFontFamily();
+ if (typeFace == null) typeFace = "Lucida Sans";
+ string.addAttribute(TextAttribute.FAMILY, typeFace);
+
+ Double fs = tr.getFontSize();
+ if (fs == null) fs = 12d;
+ string.addAttribute(TextAttribute.SIZE, fs.floatValue());
+
+ TextLayout l = new TextLayout(string.getIterator(), new FontRenderContext(null, true, true));
+ double wspace = l.getAdvance();
+
+ Double tabSz = paragraph.getDefaultTabSize();
+ if (tabSz == null) tabSz = wspace*4;
+
+ int numSpaces = (int)Math.ceil(tabSz / wspace);
+ StringBuilder buf = new StringBuilder();
+ for(int i = 0; i < numSpaces; i++) {
+ buf.append(' ');
+ }
+ return buf.toString();
+ }
+
+
+ /**
+ * Returns wrapping width to break lines in this paragraph
+ *
+ * @param firstLine whether the first line is breaking
+ *
+ * @return wrapping width in points
+ */
+ protected double getWrappingWidth(boolean firstLine, Graphics2D graphics){
+ // internal margins for the text box
+
+ Insets2D insets = paragraph.getParentShape().getInsets();
+ double leftInset = insets.left;
+ double rightInset = insets.right;
+
+ Rectangle2D anchor = DrawShape.getAnchor(graphics, paragraph.getParentShape());
+
+ int indentLevel = paragraph.getIndentLevel();
+ Double leftMargin = paragraph.getLeftMargin();
+ if (leftMargin == null) {
+ // if the marL attribute is omitted, then a value of 347663 is implied
+ leftMargin = Units.toPoints(347663*(indentLevel+1));
+ }
+ Double indent = paragraph.getIndent();
+ if (indent == null) {
+ indent = Units.toPoints(347663*indentLevel);
+ }
+ Double rightMargin = paragraph.getRightMargin();
+ if (rightMargin == null) {
+ rightMargin = 0d;
+ }
+
+ double width;
+ TextShape<? extends TextParagraph<T>> ts = paragraph.getParentShape();
+ if (!ts.getWordWrap()) {
+ // if wordWrap == false then we return the advance to the right border of the sheet
+ width = ts.getSheet().getSlideShow().getPageSize().getWidth() - anchor.getX();
+ } else {
+ width = anchor.getWidth() - leftInset - rightInset - leftMargin - rightMargin;
+ if (firstLine) {
+ if (bullet != null){
+ if (indent > 0) width -= indent;
+ } else {
+ if (indent > 0) width -= indent; // first line indentation
+ else if (indent < 0) { // hanging indentation: the first line start at the left margin
+ width += leftMargin;
+ }
+ }
+ }
+ }
+
+ return width;
+ }
+
+ private static class AttributedStringData {
+ Attribute attribute;
+ Object value;
+ int beginIndex, endIndex;
+ AttributedStringData(Attribute attribute, Object value, int beginIndex, int endIndex) {
+ this.attribute = attribute;
+ this.value = value;
+ this.beginIndex = beginIndex;
+ this.endIndex = endIndex;
+ }
+ }
+
+ protected AttributedString getAttributedString(Graphics2D graphics, StringBuilder text){
+ List<AttributedStringData> attList = new ArrayList<AttributedStringData>();
+ if (text == null) text = new StringBuilder();
+
+ DrawFontManager fontHandler = (DrawFontManager)graphics.getRenderingHint(Drawable.FONT_HANDLER);
+
+ for (TextRun run : paragraph){
+ String runText = getRenderableText(run);
+ // skip empty runs
+ if (runText.isEmpty()) continue;
+
+ int beginIndex = text.length();
+ text.append(runText);
+ int endIndex = text.length();
+
+ Color fgColor = run.getFontColor();
+ if (fgColor == null) fgColor = Color.BLACK;
+ attList.add(new AttributedStringData(TextAttribute.FOREGROUND, fgColor, beginIndex, endIndex));
+
+ // user can pass an custom object to convert fonts
+ String fontFamily = run.getFontFamily();
+ @SuppressWarnings("unchecked")
+ Map<String,String> fontMap = (Map<String,String>)graphics.getRenderingHint(Drawable.FONT_MAP);
+ if (fontMap != null && fontMap.containsKey(fontFamily)) {
+ fontFamily = fontMap.get(fontFamily);
+ }
+ if(fontHandler != null) {
+ fontFamily = fontHandler.getRendererableFont(fontFamily, run.getPitchAndFamily());
+ }
+ if (fontFamily == null) {
+ fontFamily = paragraph.getDefaultFontFamily();
+ }
+ attList.add(new AttributedStringData(TextAttribute.FAMILY, fontFamily, beginIndex, endIndex));
+
+ Double fontSz = run.getFontSize();
+ if (fontSz == null) fontSz = paragraph.getDefaultFontSize();
+ attList.add(new AttributedStringData(TextAttribute.SIZE, fontSz.floatValue(), beginIndex, endIndex));
+
+ if(run.isBold()) {
+ attList.add(new AttributedStringData(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD, beginIndex, endIndex));
+ }
+ if(run.isItalic()) {
+ attList.add(new AttributedStringData(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE, beginIndex, endIndex));
+ }
+ if(run.isUnderlined()) {
+ attList.add(new AttributedStringData(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, beginIndex, endIndex));
+ attList.add(new AttributedStringData(TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.UNDERLINE_LOW_TWO_PIXEL, beginIndex, endIndex));
+ }
+ if(run.isStrikethrough()) {
+ attList.add(new AttributedStringData(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON, beginIndex, endIndex));
+ }
+ if(run.isSubscript()) {
+ attList.add(new AttributedStringData(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUB, beginIndex, endIndex));
+ }
+ if(run.isSuperscript()) {
+ attList.add(new AttributedStringData(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER, beginIndex, endIndex));
+ }
+ }
+
+ // ensure that the paragraph contains at least one character
+ // We need this trick to correctly measure text
+ if (text.length() == 0) {
+ Double fontSz = paragraph.getDefaultFontSize();
+ text.append(" ");
+ attList.add(new AttributedStringData(TextAttribute.SIZE, fontSz.floatValue(), 0, 1));
+ }
+
+ AttributedString string = new AttributedString(text.toString());
+ for (AttributedStringData asd : attList) {
+ string.addAttribute(asd.attribute, asd.value, asd.beginIndex, asd.endIndex);
+ }
+
+ return string;
+ }
+
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/DrawTextShape.java b/src/java/org/apache/poi/sl/draw/DrawTextShape.java new file mode 100644 index 0000000000..5862ac598c --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/DrawTextShape.java @@ -0,0 +1,179 @@ +/* ====================================================================
+ 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.sl.draw;
+
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.util.*;
+
+import org.apache.poi.sl.usermodel.*;
+import org.apache.poi.sl.usermodel.TextParagraph.BulletStyle;
+import org.apache.poi.util.JvmBugs;
+
+public class DrawTextShape<T extends TextShape<? extends TextParagraph<? extends TextRun>>> extends DrawSimpleShape<T> {
+
+ public DrawTextShape(T shape) {
+ super(shape);
+ }
+
+ @Override
+ public void drawContent(Graphics2D graphics) {
+ Rectangle2D anchor = DrawShape.getAnchor(graphics, shape);
+ Insets2D insets = shape.getInsets();
+ double x = anchor.getX() + insets.left;
+ double y = anchor.getY();
+
+ // remember the initial transform
+ AffineTransform tx = graphics.getTransform();
+
+ // Transform of text in flipped shapes is special.
+ // At this point the flip and rotation transform is already applied
+ // (see DrawShape#applyTransform ), but we need to restore it to avoid painting "upside down".
+ // See Bugzilla 54210.
+
+ if(shape.getFlipVertical()){
+ graphics.translate(anchor.getX(), anchor.getY() + anchor.getHeight());
+ graphics.scale(1, -1);
+ graphics.translate(-anchor.getX(), -anchor.getY());
+
+ // text in vertically flipped shapes is rotated by 180 degrees
+ double centerX = anchor.getX() + anchor.getWidth()/2;
+ double centerY = anchor.getY() + anchor.getHeight()/2;
+ graphics.translate(centerX, centerY);
+ graphics.rotate(Math.toRadians(180));
+ graphics.translate(-centerX, -centerY);
+ }
+
+ // Horizontal flipping applies only to shape outline and not to the text in the shape.
+ // Applying flip second time restores the original not-flipped transform
+ if(shape.getFlipHorizontal()){
+ graphics.translate(anchor.getX() + anchor.getWidth(), anchor.getY());
+ graphics.scale(-1, 1);
+ graphics.translate(-anchor.getX() , -anchor.getY());
+ }
+
+
+ // first dry-run to calculate the total height of the text
+ double textHeight = shape.getTextHeight();
+
+ switch (shape.getVerticalAlignment()){
+ case TOP:
+ y += insets.top;
+ break;
+ case BOTTOM:
+ y += anchor.getHeight() - textHeight - insets.bottom;
+ break;
+ default:
+ case MIDDLE:
+ double delta = anchor.getHeight() - textHeight - insets.top - insets.bottom;
+ y += insets.top + delta/2;
+ break;
+ }
+
+ drawParagraphs(graphics, x, y);
+
+ // restore the transform
+ graphics.setTransform(tx);
+ }
+
+ /**
+ * paint the paragraphs starting from top left (x,y)
+ *
+ * @return the vertical advance, i.e. the cumulative space occupied by the text
+ */
+ public double drawParagraphs(Graphics2D graphics, double x, double y) {
+ DrawFactory fact = DrawFactory.getInstance(graphics);
+ Insets2D shapePadding = shape.getInsets();
+
+ double y0 = y;
+ Iterator<? extends TextParagraph<? extends TextRun>> paragraphs = shape.iterator();
+
+ boolean isFirstLine = true;
+ for (int autoNbrIdx=0; paragraphs.hasNext(); autoNbrIdx++){
+ TextParagraph<? extends TextRun> p = paragraphs.next();
+ DrawTextParagraph<? extends TextRun> dp = fact.getDrawable(p);
+ BulletStyle bs = p.getBulletStyle();
+ if (bs == null || bs.getAutoNumberingScheme() == null) {
+ autoNbrIdx = -1;
+ } else {
+ Integer startAt = bs.getAutoNumberingStartAt();
+ if (startAt == null) startAt = 1;
+ // TODO: handle reset auto number indexes
+ if (startAt > autoNbrIdx) autoNbrIdx = startAt;
+ }
+ dp.setAutoNumberingIdx(autoNbrIdx);
+ dp.breakText(graphics);
+
+ if (!isFirstLine) {
+ // the amount of vertical white space before the paragraph
+ Double spaceBefore = p.getSpaceBefore();
+ if (spaceBefore == null) spaceBefore = 0d;
+ if(spaceBefore > 0) {
+ // positive value means percentage spacing of the height of the first line, e.g.
+ // the higher the first line, the bigger the space before the paragraph
+ y += spaceBefore*0.01*dp.getFirstLineHeight();
+ } else {
+ // negative value means the absolute spacing in points
+ y += -spaceBefore;
+ }
+ }
+ isFirstLine = false;
+
+ dp.setPosition(x, y);
+ dp.draw(graphics);
+ y += dp.getY();
+
+ if (paragraphs.hasNext()) {
+ Double spaceAfter = p.getSpaceAfter();
+ if (spaceAfter == null) spaceAfter = 0d;
+ if(spaceAfter > 0) {
+ // positive value means percentage spacing of the height of the last line, e.g.
+ // the higher the last line, the bigger the space after the paragraph
+ y += spaceAfter*0.01*dp.getLastLineHeight();
+ } else {
+ // negative value means the absolute spacing in points
+ y += -spaceAfter;
+ }
+ }
+ }
+ return y - y0;
+ }
+
+ /**
+ * Compute the cumulative height occupied by the text
+ */
+ public double getTextHeight(){
+ // dry-run in a 1x1 image and return the vertical advance
+ BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
+ Graphics2D graphics = img.createGraphics();
+ fixFonts(graphics);
+ return drawParagraphs(graphics, 0, 0);
+ }
+
+ @SuppressWarnings("unchecked")
+ private static void fixFonts(Graphics2D graphics) {
+ if (!JvmBugs.hasLineBreakMeasurerBug()) return;
+ Map<String,String> fontMap = (Map<String,String>)graphics.getRenderingHint(Drawable.FONT_MAP);
+ if (fontMap == null) fontMap = new HashMap<String,String>();
+ fontMap.put("Calibri", "Lucida Sans");
+ fontMap.put("Cambria", "Lucida Bright");
+ graphics.setRenderingHint(Drawable.FONT_MAP, fontMap);
+ }
+}
diff --git a/src/java/org/apache/poi/sl/draw/Drawable.java b/src/java/org/apache/poi/sl/draw/Drawable.java new file mode 100644 index 0000000000..54128b82c6 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/Drawable.java @@ -0,0 +1,140 @@ +/* ====================================================================
+ 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.sl.draw;
+
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+
+import org.apache.poi.util.Internal;
+
+
+public interface Drawable {
+ class DrawableHint extends RenderingHints.Key {
+ protected DrawableHint(int id) {
+ super(id);
+ }
+
+ public boolean isCompatibleValue(Object val) {
+ return true;
+ }
+
+ public String toString() {
+ switch (intKey()) {
+ case 1: return "DRAW_FACTORY";
+ case 2: return "GROUP_TRANSFORM";
+ case 3: return "IMAGE_RENDERER";
+ case 4: return "TEXT_RENDERING_MODE";
+ case 5: return "GRADIENT_SHAPE";
+ case 6: return "PRESET_GEOMETRY_CACHE";
+ case 7: return "FONT_HANDLER";
+ case 8: return "FONT_FALLBACK";
+ case 9: return "FONT_MAP";
+ case 10: return "GSAVE";
+ case 11: return "GRESTORE";
+ default: return "UNKNOWN_ID "+intKey();
+ }
+ }
+ }
+
+ /**
+ * {@link DrawFactory} which will be used to draw objects into this graphics context
+ */
+ DrawableHint DRAW_FACTORY = new DrawableHint(1);
+
+ /**
+ * Key will be internally used to store affine transformation temporarily within group shapes
+ */
+ @Internal
+ DrawableHint GROUP_TRANSFORM = new DrawableHint(2);
+
+ /**
+ * Use a custom image renderer of an instance of {@link ImageRenderer}
+ */
+ DrawableHint IMAGE_RENDERER = new DrawableHint(3);
+
+ /**
+ * how to render text:
+ *
+ * {@link #TEXT_AS_CHARACTERS} (default) means to draw via
+ * {@link java.awt.Graphics2D#drawString(java.text.AttributedCharacterIterator, float, float)}.
+ * This mode draws text as characters. Use it if the target graphics writes the actual
+ * character codes instead of glyph outlines (PDFGraphics2D, SVGGraphics2D, etc.)
+ *
+ * {@link #TEXT_AS_SHAPES} means to render via
+ * {@link java.awt.font.TextLayout#draw(java.awt.Graphics2D, float, float)}.
+ * This mode draws glyphs as shapes and provides some advanced capabilities such as
+ * justification and font substitution. Use it if the target graphics is an image.
+ *
+ */
+ DrawableHint TEXT_RENDERING_MODE = new DrawableHint(4);
+
+ /**
+ * PathGradientPaint needs the shape to be set.
+ * It will be achieved through setting it in the rendering hints
+ */
+ DrawableHint GRADIENT_SHAPE = new DrawableHint(5);
+
+
+ /**
+ * Internal key for caching the preset geometries
+ */
+ DrawableHint PRESET_GEOMETRY_CACHE = new DrawableHint(6);
+
+ /**
+ * draw text via {@link java.awt.Graphics2D#drawString(java.text.AttributedCharacterIterator, float, float)}
+ */
+ int TEXT_AS_CHARACTERS = 1;
+
+ /**
+ * draw text via {@link java.awt.font.TextLayout#draw(java.awt.Graphics2D, float, float)}
+ */
+ int TEXT_AS_SHAPES = 2;
+
+ /**
+ * Use this object to resolve unknown / missing fonts when rendering slides
+ */
+ DrawableHint FONT_HANDLER = new DrawableHint(7);
+ DrawableHint FONT_FALLBACK = new DrawableHint(8);
+ DrawableHint FONT_MAP = new DrawableHint(9);
+
+ DrawableHint GSAVE = new DrawableHint(10);
+ DrawableHint GRESTORE = new DrawableHint(11);
+
+
+
+ /**
+ * Apply 2-D transforms before drawing this shape. This includes rotation and flipping.
+ *
+ * @param graphics the graphics whos transform matrix will be modified
+ */
+ void applyTransform(Graphics2D graphics);
+
+ /**
+ * Draw this shape into the supplied canvas
+ *
+ * @param graphics the graphics to draw into
+ */
+ void draw(Graphics2D graphics);
+
+ /**
+ * draw any content within this shape (image, text, etc.).
+ *
+ * @param graphics the graphics to draw into
+ */
+ void drawContent(Graphics2D graphics);
+}
diff --git a/src/java/org/apache/poi/sl/draw/ImageRenderer.java b/src/java/org/apache/poi/sl/draw/ImageRenderer.java new file mode 100644 index 0000000000..87561aedd4 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/ImageRenderer.java @@ -0,0 +1,192 @@ +/*
+ * ====================================================================
+ * 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.sl.draw;
+
+import java.awt.*;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.RescaleOp;
+import java.io.*;
+
+import javax.imageio.ImageIO;
+
+/**
+ * For now this class renders only images supported by the javax.imageio.ImageIO
+ * framework. Subclasses can override this class to support other formats, for
+ * example, use Apache Batik to render WMF, PICT can be rendered using Apple QuickTime API for Java:
+ *
+ * <pre>
+ * <code>
+ * public class MyImageRendener extends ImageRendener {
+ * InputStream data;
+ *
+ * public boolean drawImage(Graphics2D graphics,Rectangle2D anchor,Insets clip) {
+ * // draw image
+ * DataInputStream is = new DataInputStream(data);
+ * org.apache.batik.transcoder.wmf.tosvg.WMFRecordStore wmfStore =
+ * new org.apache.batik.transcoder.wmf.tosvg.WMFRecordStore();
+ * try {
+ * wmfStore.read(is);
+ * } catch (IOException e){
+ * return;
+ * }
+ *
+ * float scale = (float)anchor.width/wmfStore.getWidthPixels();
+ *
+ * org.apache.batik.transcoder.wmf.tosvg.WMFPainter painter =
+ * new org.apache.batik.transcoder.wmf.tosvg.WMFPainter(wmfStore, 0, 0, scale);
+ * graphics.translate(anchor.x, anchor.y);
+ * painter.paint(graphics);
+ * }
+ *
+ * public void loadImage(InputStream data, String contentType) throws IOException {
+ * if ("image/wmf".equals(contentType)) {
+ * this.data = data;
+ * // use Apache Batik to handle WMF
+ * } else {
+ * super.loadImage(data,contentType);
+ * }
+ * }
+ * }
+ * </code>
+ * </pre>
+ *
+ * and then pass this class to your instance of java.awt.Graphics2D:
+ *
+ * <pre>
+ * <code>
+ * graphics.setRenderingHint(Drawable.IMAGE_RENDERER, new MyImageRendener());
+ * </code>
+ * </pre>
+ */
+public class ImageRenderer {
+ protected BufferedImage img;
+
+ /**
+ * Load and buffer the image
+ *
+ * @param data the raw image stream
+ * @param contentType the content type
+ */
+ public void loadImage(InputStream data, String contentType) throws IOException {
+ img = convertBufferedImage(ImageIO.read(data));
+ }
+
+ /**
+ * Load and buffer the image
+ *
+ * @param data the raw image stream
+ * @param contentType the content type
+ */
+ public void loadImage(byte data[], String contentType) throws IOException {
+ img = convertBufferedImage(ImageIO.read(new ByteArrayInputStream(data)));
+ }
+
+ protected static BufferedImage convertBufferedImage(BufferedImage img) {
+ BufferedImage bi = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_ARGB);
+ Graphics g = bi.getGraphics();
+ g.drawImage(img, 0, 0, null);
+ g.dispose();
+ return bi;
+ }
+
+
+ /**
+ * @return the buffered image
+ */
+ public BufferedImage getImage() {
+ return img;
+ }
+
+ /**
+ * @return the dimension of the buffered image
+ */
+ public Dimension getDimension() {
+ return (img == null)
+ ? new Dimension(0,0)
+ : new Dimension(img.getWidth(),img.getHeight());
+ }
+
+ /**
+ * @param alpha the alpha [0..1] to be added to the image (possibly already containing an alpha channel)
+ */
+ public void setAlpha(double alpha) {
+ if (img == null) return;
+
+ Dimension dim = getDimension();
+ BufferedImage newImg = new BufferedImage((int)dim.getWidth(), (int)dim.getHeight(), BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g = newImg.createGraphics();
+ RescaleOp op = new RescaleOp(new float[]{1.0f, 1.0f, 1.0f, (float)alpha}, new float[]{0,0,0,0}, null);
+ g.drawImage(img, op, 0, 0);
+ g.dispose();
+
+ img = newImg;
+ }
+
+
+ /**
+ * Render picture data into the supplied graphics
+ *
+ * @return true if the picture data was successfully rendered
+ */
+ public boolean drawImage(
+ Graphics2D graphics,
+ Rectangle2D anchor) {
+ return drawImage(graphics, anchor, null);
+ }
+
+ /**
+ * Render picture data into the supplied graphics
+ *
+ * @return true if the picture data was successfully rendered
+ */
+ public boolean drawImage(
+ Graphics2D graphics,
+ Rectangle2D anchor,
+ Insets clip) {
+ if (img == null) return false;
+
+ boolean isClipped = true;
+ if (clip == null) {
+ isClipped = false;
+ clip = new Insets(0,0,0,0);
+ }
+
+ int iw = img.getWidth();
+ int ih = img.getHeight();
+
+
+ double cw = (100000-clip.left-clip.right) / 100000.0;
+ double ch = (100000-clip.top-clip.bottom) / 100000.0;
+ double sx = anchor.getWidth()/(iw*cw);
+ double sy = anchor.getHeight()/(ih*ch);
+ double tx = anchor.getX()-(iw*sx*clip.left/100000.0);
+ double ty = anchor.getY()-(ih*sy*clip.top/100000.0);
+
+ AffineTransform at = new AffineTransform(sx, 0, 0, sy, tx, ty) ;
+
+ Shape clipOld = graphics.getClip();
+ if (isClipped) graphics.clip(anchor.getBounds2D());
+ graphics.drawRenderedImage(img, at);
+ graphics.setClip(clipOld);
+
+ return true;
+ }
+}
diff --git a/src/java/org/apache/poi/sl/draw/PathGradientPaint.java b/src/java/org/apache/poi/sl/draw/PathGradientPaint.java new file mode 100644 index 0000000000..c5ad799f4c --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/PathGradientPaint.java @@ -0,0 +1,186 @@ +/* ====================================================================
+ 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.sl.draw;
+
+import java.awt.*;
+import java.awt.MultipleGradientPaint.ColorSpaceType;
+import java.awt.MultipleGradientPaint.CycleMethod;
+import java.awt.geom.*;
+import java.awt.image.*;
+
+class PathGradientPaint implements Paint {
+
+ // http://asserttrue.blogspot.de/2010/01/how-to-iimplement-custom-paint-in-50.html
+ protected final Color colors[];
+ protected final float fractions[];
+ protected final int capStyle;
+ protected final int joinStyle;
+ protected final int transparency;
+
+
+ public PathGradientPaint(Color colors[], float fractions[]) {
+ this(colors,fractions,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND);
+ }
+
+ public PathGradientPaint(Color colors[], float fractions[], int capStyle, int joinStyle) {
+ this.colors = colors;
+ this.fractions = fractions;
+ this.capStyle = capStyle;
+ this.joinStyle = joinStyle;
+
+ // determine transparency
+ boolean opaque = true;
+ for (int i = 0; i < colors.length; i++){
+ opaque = opaque && (colors[i].getAlpha() == 0xff);
+ }
+ this.transparency = opaque ? OPAQUE : TRANSLUCENT;
+ }
+
+ public PaintContext createContext(ColorModel cm,
+ Rectangle deviceBounds,
+ Rectangle2D userBounds,
+ AffineTransform transform,
+ RenderingHints hints) {
+ return new PathGradientContext(cm, deviceBounds, userBounds, transform, hints);
+ }
+
+ public int getTransparency() {
+ return transparency;
+ }
+
+ class PathGradientContext implements PaintContext {
+ protected final Rectangle deviceBounds;
+ protected final Rectangle2D userBounds;
+ protected final AffineTransform xform;
+ protected final RenderingHints hints;
+
+ /**
+ * for POI: the shape will be only known when the subclasses determines the concrete implementation
+ * in the draw/-content method, so we need to postpone the setting/creation as long as possible
+ **/
+ protected final Shape shape;
+ protected final PaintContext pCtx;
+ protected final int gradientSteps;
+ WritableRaster raster;
+
+ public PathGradientContext(
+ ColorModel cm
+ , Rectangle deviceBounds
+ , Rectangle2D userBounds
+ , AffineTransform xform
+ , RenderingHints hints
+ ) {
+ shape = (Shape)hints.get(Drawable.GRADIENT_SHAPE);
+ if (shape == null) {
+ throw new IllegalPathStateException("PathGradientPaint needs a shape to be set via the rendering hint PathGradientPaint.GRADIANT_SHAPE.");
+ }
+
+ this.deviceBounds = deviceBounds;
+ this.userBounds = userBounds;
+ this.xform = xform;
+ this.hints = hints;
+
+ gradientSteps = getGradientSteps(shape);
+
+ Point2D start = new Point2D.Double(0, 0);
+ Point2D end = new Point2D.Double(gradientSteps, 0);
+ LinearGradientPaint gradientPaint = new LinearGradientPaint(start, end, fractions, colors, CycleMethod.NO_CYCLE, ColorSpaceType.SRGB, new AffineTransform());
+
+ Rectangle bounds = new Rectangle(0, 0, gradientSteps, 1);
+ pCtx = gradientPaint.createContext(cm, bounds, bounds, new AffineTransform(), hints);
+ }
+
+ public void dispose() {}
+
+ public ColorModel getColorModel() {
+ return pCtx.getColorModel();
+ }
+
+ public Raster getRaster(int xOffset, int yOffset, int w, int h) {
+ ColorModel cm = getColorModel();
+ if (raster == null) createRaster();
+
+ // TODO: eventually use caching here
+ WritableRaster childRaster = cm.createCompatibleWritableRaster(w, h);
+ Rectangle2D childRect = new Rectangle2D.Double(xOffset, yOffset, w, h);
+ if (!childRect.intersects(deviceBounds)) {
+ // usually doesn't happen ...
+ return childRaster;
+ }
+
+ Rectangle2D destRect = new Rectangle2D.Double();
+ Rectangle2D.intersect(childRect, deviceBounds, destRect);
+ int dx = (int)(destRect.getX()-deviceBounds.getX());
+ int dy = (int)(destRect.getY()-deviceBounds.getY());
+ int dw = (int)destRect.getWidth();
+ int dh = (int)destRect.getHeight();
+ Object data = raster.getDataElements(dx, dy, dw, dh, null);
+ dx = (int)(destRect.getX()-childRect.getX());
+ dy = (int)(destRect.getY()-childRect.getY());
+ childRaster.setDataElements(dx, dy, dw, dh, data);
+
+ return childRaster;
+ }
+
+ protected int getGradientSteps(Shape shape) {
+ Rectangle rect = shape.getBounds();
+ int lower = 1;
+ int upper = (int)(Math.max(rect.getWidth(),rect.getHeight())/2.0);
+ while (lower < upper-1) {
+ int mid = lower + (upper - lower) / 2;
+ BasicStroke bs = new BasicStroke(mid, capStyle, joinStyle);
+ Area area = new Area(bs.createStrokedShape(shape));
+ if (area.isSingular()) {
+ upper = mid;
+ } else {
+ lower = mid;
+ }
+ }
+ return upper;
+ }
+
+
+
+ protected void createRaster() {
+ ColorModel cm = getColorModel();
+ raster = cm.createCompatibleWritableRaster((int)deviceBounds.getWidth(), (int)deviceBounds.getHeight());
+ BufferedImage img = new BufferedImage(cm, raster, false, null);
+ Graphics2D graphics = img.createGraphics();
+ graphics.setRenderingHints(hints);
+ graphics.translate(-deviceBounds.getX(), -deviceBounds.getY());
+ graphics.transform(xform);
+
+ Raster img2 = pCtx.getRaster(0, 0, gradientSteps, 1);
+ int rgb[] = new int[cm.getNumComponents()];
+
+ for (int i = gradientSteps-1; i>=0; i--) {
+ img2.getPixel(i, 0, rgb);
+ Color c = new Color(rgb[0],rgb[1],rgb[2]);
+ if (rgb.length == 4) {
+ // it doesn't work to use just a color with transparency ...
+ graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, rgb[3]/255.0f));
+ }
+ graphics.setStroke(new BasicStroke(i+1, capStyle, joinStyle));
+ graphics.setColor(c);
+ graphics.draw(shape);
+ }
+
+ graphics.dispose();
+ }
+ }
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTAdjPoint2D.java b/src/java/org/apache/poi/sl/draw/binding/CTAdjPoint2D.java new file mode 100644 index 0000000000..d7fc0ae07f --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTAdjPoint2D.java @@ -0,0 +1,109 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_AdjPoint2D complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_AdjPoint2D">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="x" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
+ * <attribute name="y" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_AdjPoint2D", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTAdjPoint2D {
+
+ @XmlAttribute(name = "x", required = true)
+ protected String x;
+ @XmlAttribute(name = "y", required = true)
+ protected String y;
+
+ /**
+ * Gets the value of the x property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getX() {
+ return x;
+ }
+
+ /**
+ * Sets the value of the x property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setX(String value) {
+ this.x = value;
+ }
+
+ public boolean isSetX() {
+ return (this.x!= null);
+ }
+
+ /**
+ * Gets the value of the y property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getY() {
+ return y;
+ }
+
+ /**
+ * Sets the value of the y property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setY(String value) {
+ this.y = value;
+ }
+
+ public boolean isSetY() {
+ return (this.y!= null);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTAdjustHandleList.java b/src/java/org/apache/poi/sl/draw/binding/CTAdjustHandleList.java new file mode 100644 index 0000000000..d684cccb74 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTAdjustHandleList.java @@ -0,0 +1,99 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_AdjustHandleList complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_AdjustHandleList">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <choice maxOccurs="unbounded" minOccurs="0">
+ * <element name="ahXY" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_XYAdjustHandle"/>
+ * <element name="ahPolar" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_PolarAdjustHandle"/>
+ * </choice>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_AdjustHandleList", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "ahXYOrAhPolar"
+})
+public class CTAdjustHandleList {
+
+ @XmlElements({
+ @XmlElement(name = "ahXY", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTXYAdjustHandle.class),
+ @XmlElement(name = "ahPolar", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTPolarAdjustHandle.class)
+ })
+ protected List<Object> ahXYOrAhPolar;
+
+ /**
+ * Gets the value of the ahXYOrAhPolar property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the ahXYOrAhPolar property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getAhXYOrAhPolar().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link CTXYAdjustHandle }
+ * {@link CTPolarAdjustHandle }
+ *
+ *
+ */
+ public List<Object> getAhXYOrAhPolar() {
+ if (ahXYOrAhPolar == null) {
+ ahXYOrAhPolar = new ArrayList<Object>();
+ }
+ return this.ahXYOrAhPolar;
+ }
+
+ public boolean isSetAhXYOrAhPolar() {
+ return ((this.ahXYOrAhPolar!= null)&&(!this.ahXYOrAhPolar.isEmpty()));
+ }
+
+ public void unsetAhXYOrAhPolar() {
+ this.ahXYOrAhPolar = null;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTAngle.java b/src/java/org/apache/poi/sl/draw/binding/CTAngle.java new file mode 100644 index 0000000000..2da2373e25 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTAngle.java @@ -0,0 +1,70 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_Angle complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Angle">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="val" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Angle" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_Angle", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTAngle {
+
+ @XmlAttribute(name = "val", required = true)
+ protected int val;
+
+ /**
+ * Gets the value of the val property.
+ *
+ */
+ public int getVal() {
+ return val;
+ }
+
+ /**
+ * Sets the value of the val property.
+ *
+ */
+ public void setVal(int value) {
+ this.val = value;
+ }
+
+ public boolean isSetVal() {
+ return true;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTColor.java b/src/java/org/apache/poi/sl/draw/binding/CTColor.java new file mode 100644 index 0000000000..dd3cca3602 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTColor.java @@ -0,0 +1,237 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_Color complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Color">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <group ref="{http://schemas.openxmlformats.org/drawingml/2006/main}EG_ColorChoice"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_Color", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "scrgbClr",
+ "srgbClr",
+ "hslClr",
+ "sysClr",
+ "schemeClr",
+ "prstClr"
+})
+public class CTColor {
+
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected CTScRgbColor scrgbClr;
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected CTSRgbColor srgbClr;
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected CTHslColor hslClr;
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected CTSystemColor sysClr;
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected CTSchemeColor schemeClr;
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected CTPresetColor prstClr;
+
+ /**
+ * Gets the value of the scrgbClr property.
+ *
+ * @return
+ * possible object is
+ * {@link CTScRgbColor }
+ *
+ */
+ public CTScRgbColor getScrgbClr() {
+ return scrgbClr;
+ }
+
+ /**
+ * Sets the value of the scrgbClr property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTScRgbColor }
+ *
+ */
+ public void setScrgbClr(CTScRgbColor value) {
+ this.scrgbClr = value;
+ }
+
+ public boolean isSetScrgbClr() {
+ return (this.scrgbClr!= null);
+ }
+
+ /**
+ * Gets the value of the srgbClr property.
+ *
+ * @return
+ * possible object is
+ * {@link CTSRgbColor }
+ *
+ */
+ public CTSRgbColor getSrgbClr() {
+ return srgbClr;
+ }
+
+ /**
+ * Sets the value of the srgbClr property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTSRgbColor }
+ *
+ */
+ public void setSrgbClr(CTSRgbColor value) {
+ this.srgbClr = value;
+ }
+
+ public boolean isSetSrgbClr() {
+ return (this.srgbClr!= null);
+ }
+
+ /**
+ * Gets the value of the hslClr property.
+ *
+ * @return
+ * possible object is
+ * {@link CTHslColor }
+ *
+ */
+ public CTHslColor getHslClr() {
+ return hslClr;
+ }
+
+ /**
+ * Sets the value of the hslClr property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTHslColor }
+ *
+ */
+ public void setHslClr(CTHslColor value) {
+ this.hslClr = value;
+ }
+
+ public boolean isSetHslClr() {
+ return (this.hslClr!= null);
+ }
+
+ /**
+ * Gets the value of the sysClr property.
+ *
+ * @return
+ * possible object is
+ * {@link CTSystemColor }
+ *
+ */
+ public CTSystemColor getSysClr() {
+ return sysClr;
+ }
+
+ /**
+ * Sets the value of the sysClr property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTSystemColor }
+ *
+ */
+ public void setSysClr(CTSystemColor value) {
+ this.sysClr = value;
+ }
+
+ public boolean isSetSysClr() {
+ return (this.sysClr!= null);
+ }
+
+ /**
+ * Gets the value of the schemeClr property.
+ *
+ * @return
+ * possible object is
+ * {@link CTSchemeColor }
+ *
+ */
+ public CTSchemeColor getSchemeClr() {
+ return schemeClr;
+ }
+
+ /**
+ * Sets the value of the schemeClr property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTSchemeColor }
+ *
+ */
+ public void setSchemeClr(CTSchemeColor value) {
+ this.schemeClr = value;
+ }
+
+ public boolean isSetSchemeClr() {
+ return (this.schemeClr!= null);
+ }
+
+ /**
+ * Gets the value of the prstClr property.
+ *
+ * @return
+ * possible object is
+ * {@link CTPresetColor }
+ *
+ */
+ public CTPresetColor getPrstClr() {
+ return prstClr;
+ }
+
+ /**
+ * Sets the value of the prstClr property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTPresetColor }
+ *
+ */
+ public void setPrstClr(CTPresetColor value) {
+ this.prstClr = value;
+ }
+
+ public boolean isSetPrstClr() {
+ return (this.prstClr!= null);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTColorMRU.java b/src/java/org/apache/poi/sl/draw/binding/CTColorMRU.java new file mode 100644 index 0000000000..8ec68ba085 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTColorMRU.java @@ -0,0 +1,106 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_ColorMRU complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_ColorMRU">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <group ref="{http://schemas.openxmlformats.org/drawingml/2006/main}EG_ColorChoice" maxOccurs="10" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_ColorMRU", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "egColorChoice"
+})
+public class CTColorMRU {
+
+ @XmlElements({
+ @XmlElement(name = "scrgbClr", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTScRgbColor.class),
+ @XmlElement(name = "srgbClr", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTSRgbColor.class),
+ @XmlElement(name = "hslClr", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTHslColor.class),
+ @XmlElement(name = "sysClr", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTSystemColor.class),
+ @XmlElement(name = "schemeClr", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTSchemeColor.class),
+ @XmlElement(name = "prstClr", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTPresetColor.class)
+ })
+ protected List<Object> egColorChoice;
+
+ /**
+ * Gets the value of the egColorChoice property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the egColorChoice property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getEGColorChoice().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link CTScRgbColor }
+ * {@link CTSRgbColor }
+ * {@link CTHslColor }
+ * {@link CTSystemColor }
+ * {@link CTSchemeColor }
+ * {@link CTPresetColor }
+ *
+ *
+ */
+ public List<Object> getEGColorChoice() {
+ if (egColorChoice == null) {
+ egColorChoice = new ArrayList<Object>();
+ }
+ return this.egColorChoice;
+ }
+
+ public boolean isSetEGColorChoice() {
+ return ((this.egColorChoice!= null)&&(!this.egColorChoice.isEmpty()));
+ }
+
+ public void unsetEGColorChoice() {
+ this.egColorChoice = null;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTComplementTransform.java b/src/java/org/apache/poi/sl/draw/binding/CTComplementTransform.java new file mode 100644 index 0000000000..dd1a56c0b9 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTComplementTransform.java @@ -0,0 +1,46 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_ComplementTransform complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_ComplementTransform">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_ComplementTransform", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTComplementTransform {
+
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTConnection.java b/src/java/org/apache/poi/sl/draw/binding/CTConnection.java new file mode 100644 index 0000000000..f5d5e17268 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTConnection.java @@ -0,0 +1,95 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_Connection complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Connection">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="id" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_DrawingElementId" />
+ * <attribute name="idx" use="required" type="{http://www.w3.org/2001/XMLSchema}unsignedInt" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_Connection", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTConnection {
+
+ @XmlAttribute(name = "id", required = true)
+ protected long id;
+ @XmlAttribute(name = "idx", required = true)
+ @XmlSchemaType(name = "unsignedInt")
+ protected long idx;
+
+ /**
+ * Gets the value of the id property.
+ *
+ */
+ public long getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ */
+ public void setId(long value) {
+ this.id = value;
+ }
+
+ public boolean isSetId() {
+ return true;
+ }
+
+ /**
+ * Gets the value of the idx property.
+ *
+ */
+ public long getIdx() {
+ return idx;
+ }
+
+ /**
+ * Sets the value of the idx property.
+ *
+ */
+ public void setIdx(long value) {
+ this.idx = value;
+ }
+
+ public boolean isSetIdx() {
+ return true;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTConnectionSite.java b/src/java/org/apache/poi/sl/draw/binding/CTConnectionSite.java new file mode 100644 index 0000000000..eae59a0f0a --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTConnectionSite.java @@ -0,0 +1,114 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_ConnectionSite complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_ConnectionSite">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="pos" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_AdjPoint2D"/>
+ * </sequence>
+ * <attribute name="ang" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjAngle" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_ConnectionSite", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "pos"
+})
+public class CTConnectionSite {
+
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", required = true)
+ protected CTAdjPoint2D pos;
+ @XmlAttribute(name = "ang", required = true)
+ protected String ang;
+
+ /**
+ * Gets the value of the pos property.
+ *
+ * @return
+ * possible object is
+ * {@link CTAdjPoint2D }
+ *
+ */
+ public CTAdjPoint2D getPos() {
+ return pos;
+ }
+
+ /**
+ * Sets the value of the pos property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTAdjPoint2D }
+ *
+ */
+ public void setPos(CTAdjPoint2D value) {
+ this.pos = value;
+ }
+
+ public boolean isSetPos() {
+ return (this.pos!= null);
+ }
+
+ /**
+ * Gets the value of the ang property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getAng() {
+ return ang;
+ }
+
+ /**
+ * Sets the value of the ang property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setAng(String value) {
+ this.ang = value;
+ }
+
+ public boolean isSetAng() {
+ return (this.ang!= null);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTConnectionSiteList.java b/src/java/org/apache/poi/sl/draw/binding/CTConnectionSiteList.java new file mode 100644 index 0000000000..a3c98898c4 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTConnectionSiteList.java @@ -0,0 +1,93 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_ConnectionSiteList complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_ConnectionSiteList">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="cxn" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_ConnectionSite" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_ConnectionSiteList", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "cxn"
+})
+public class CTConnectionSiteList {
+
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected List<CTConnectionSite> cxn;
+
+ /**
+ * Gets the value of the cxn property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the cxn property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getCxn().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link CTConnectionSite }
+ *
+ *
+ */
+ public List<CTConnectionSite> getCxn() {
+ if (cxn == null) {
+ cxn = new ArrayList<CTConnectionSite>();
+ }
+ return this.cxn;
+ }
+
+ public boolean isSetCxn() {
+ return ((this.cxn!= null)&&(!this.cxn.isEmpty()));
+ }
+
+ public void unsetCxn() {
+ this.cxn = null;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTCustomGeometry2D.java b/src/java/org/apache/poi/sl/draw/binding/CTCustomGeometry2D.java new file mode 100644 index 0000000000..d6856ee637 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTCustomGeometry2D.java @@ -0,0 +1,242 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_CustomGeometry2D complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_CustomGeometry2D">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="avLst" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_GeomGuideList" minOccurs="0"/>
+ * <element name="gdLst" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_GeomGuideList" minOccurs="0"/>
+ * <element name="ahLst" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_AdjustHandleList" minOccurs="0"/>
+ * <element name="cxnLst" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_ConnectionSiteList" minOccurs="0"/>
+ * <element name="rect" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_GeomRect" minOccurs="0"/>
+ * <element name="pathLst" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Path2DList"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_CustomGeometry2D", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "avLst",
+ "gdLst",
+ "ahLst",
+ "cxnLst",
+ "rect",
+ "pathLst"
+})
+public class CTCustomGeometry2D {
+
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected CTGeomGuideList avLst;
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected CTGeomGuideList gdLst;
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected CTAdjustHandleList ahLst;
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected CTConnectionSiteList cxnLst;
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected CTGeomRect rect;
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", required = true)
+ protected CTPath2DList pathLst;
+
+ /**
+ * Gets the value of the avLst property.
+ *
+ * @return
+ * possible object is
+ * {@link CTGeomGuideList }
+ *
+ */
+ public CTGeomGuideList getAvLst() {
+ return avLst;
+ }
+
+ /**
+ * Sets the value of the avLst property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTGeomGuideList }
+ *
+ */
+ public void setAvLst(CTGeomGuideList value) {
+ this.avLst = value;
+ }
+
+ public boolean isSetAvLst() {
+ return (this.avLst!= null);
+ }
+
+ /**
+ * Gets the value of the gdLst property.
+ *
+ * @return
+ * possible object is
+ * {@link CTGeomGuideList }
+ *
+ */
+ public CTGeomGuideList getGdLst() {
+ return gdLst;
+ }
+
+ /**
+ * Sets the value of the gdLst property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTGeomGuideList }
+ *
+ */
+ public void setGdLst(CTGeomGuideList value) {
+ this.gdLst = value;
+ }
+
+ public boolean isSetGdLst() {
+ return (this.gdLst!= null);
+ }
+
+ /**
+ * Gets the value of the ahLst property.
+ *
+ * @return
+ * possible object is
+ * {@link CTAdjustHandleList }
+ *
+ */
+ public CTAdjustHandleList getAhLst() {
+ return ahLst;
+ }
+
+ /**
+ * Sets the value of the ahLst property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTAdjustHandleList }
+ *
+ */
+ public void setAhLst(CTAdjustHandleList value) {
+ this.ahLst = value;
+ }
+
+ public boolean isSetAhLst() {
+ return (this.ahLst!= null);
+ }
+
+ /**
+ * Gets the value of the cxnLst property.
+ *
+ * @return
+ * possible object is
+ * {@link CTConnectionSiteList }
+ *
+ */
+ public CTConnectionSiteList getCxnLst() {
+ return cxnLst;
+ }
+
+ /**
+ * Sets the value of the cxnLst property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTConnectionSiteList }
+ *
+ */
+ public void setCxnLst(CTConnectionSiteList value) {
+ this.cxnLst = value;
+ }
+
+ public boolean isSetCxnLst() {
+ return (this.cxnLst!= null);
+ }
+
+ /**
+ * Gets the value of the rect property.
+ *
+ * @return
+ * possible object is
+ * {@link CTGeomRect }
+ *
+ */
+ public CTGeomRect getRect() {
+ return rect;
+ }
+
+ /**
+ * Sets the value of the rect property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTGeomRect }
+ *
+ */
+ public void setRect(CTGeomRect value) {
+ this.rect = value;
+ }
+
+ public boolean isSetRect() {
+ return (this.rect!= null);
+ }
+
+ /**
+ * Gets the value of the pathLst property.
+ *
+ * @return
+ * possible object is
+ * {@link CTPath2DList }
+ *
+ */
+ public CTPath2DList getPathLst() {
+ return pathLst;
+ }
+
+ /**
+ * Sets the value of the pathLst property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTPath2DList }
+ *
+ */
+ public void setPathLst(CTPath2DList value) {
+ this.pathLst = value;
+ }
+
+ public boolean isSetPathLst() {
+ return (this.pathLst!= null);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTEmbeddedWAVAudioFile.java b/src/java/org/apache/poi/sl/draw/binding/CTEmbeddedWAVAudioFile.java new file mode 100644 index 0000000000..8787125f47 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTEmbeddedWAVAudioFile.java @@ -0,0 +1,152 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_EmbeddedWAVAudioFile complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_EmbeddedWAVAudioFile">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute ref="{http://schemas.openxmlformats.org/officeDocument/2006/relationships}embed use="required""/>
+ * <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" default="" />
+ * <attribute name="builtIn" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_EmbeddedWAVAudioFile", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTEmbeddedWAVAudioFile {
+
+ @XmlAttribute(name = "embed", namespace = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", required = true)
+ protected String embed;
+ @XmlAttribute(name = "name")
+ protected String name;
+ @XmlAttribute(name = "builtIn")
+ protected Boolean builtIn;
+
+ /**
+ * Embedded Audio File Relationship ID
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getEmbed() {
+ return embed;
+ }
+
+ /**
+ * Sets the value of the embed property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setEmbed(String value) {
+ this.embed = value;
+ }
+
+ public boolean isSetEmbed() {
+ return (this.embed!= null);
+ }
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getName() {
+ if (name == null) {
+ return "";
+ } else {
+ return name;
+ }
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setName(String value) {
+ this.name = value;
+ }
+
+ public boolean isSetName() {
+ return (this.name!= null);
+ }
+
+ /**
+ * Gets the value of the builtIn property.
+ *
+ * @return
+ * possible object is
+ * {@link Boolean }
+ *
+ */
+ public boolean isBuiltIn() {
+ if (builtIn == null) {
+ return false;
+ } else {
+ return builtIn;
+ }
+ }
+
+ /**
+ * Sets the value of the builtIn property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Boolean }
+ *
+ */
+ public void setBuiltIn(boolean value) {
+ this.builtIn = value;
+ }
+
+ public boolean isSetBuiltIn() {
+ return (this.builtIn!= null);
+ }
+
+ public void unsetBuiltIn() {
+ this.builtIn = null;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTFixedPercentage.java b/src/java/org/apache/poi/sl/draw/binding/CTFixedPercentage.java new file mode 100644 index 0000000000..d1ed283f5d --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTFixedPercentage.java @@ -0,0 +1,70 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_FixedPercentage complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_FixedPercentage">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="val" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_FixedPercentage" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_FixedPercentage", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTFixedPercentage {
+
+ @XmlAttribute(name = "val", required = true)
+ protected int val;
+
+ /**
+ * Gets the value of the val property.
+ *
+ */
+ public int getVal() {
+ return val;
+ }
+
+ /**
+ * Sets the value of the val property.
+ *
+ */
+ public void setVal(int value) {
+ this.val = value;
+ }
+
+ public boolean isSetVal() {
+ return true;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTGammaTransform.java b/src/java/org/apache/poi/sl/draw/binding/CTGammaTransform.java new file mode 100644 index 0000000000..7cf6cb195c --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTGammaTransform.java @@ -0,0 +1,46 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_GammaTransform complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_GammaTransform">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_GammaTransform", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTGammaTransform {
+
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTGeomGuide.java b/src/java/org/apache/poi/sl/draw/binding/CTGeomGuide.java new file mode 100644 index 0000000000..5622e4c28d --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTGeomGuide.java @@ -0,0 +1,112 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+/**
+ * <p>Java class for CT_GeomGuide complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_GeomGuide">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="name" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_GeomGuideName" />
+ * <attribute name="fmla" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_GeomGuideFormula" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_GeomGuide", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTGeomGuide {
+
+ @XmlAttribute(name = "name", required = true)
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ protected String name;
+ @XmlAttribute(name = "fmla", required = true)
+ protected String fmla;
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setName(String value) {
+ this.name = value;
+ }
+
+ public boolean isSetName() {
+ return (this.name!= null);
+ }
+
+ /**
+ * Gets the value of the fmla property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getFmla() {
+ return fmla;
+ }
+
+ /**
+ * Sets the value of the fmla property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setFmla(String value) {
+ this.fmla = value;
+ }
+
+ public boolean isSetFmla() {
+ return (this.fmla!= null);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTGeomGuideList.java b/src/java/org/apache/poi/sl/draw/binding/CTGeomGuideList.java new file mode 100644 index 0000000000..4490933b4f --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTGeomGuideList.java @@ -0,0 +1,93 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_GeomGuideList complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_GeomGuideList">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="gd" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_GeomGuide" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_GeomGuideList", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "gd"
+})
+public class CTGeomGuideList {
+
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected List<CTGeomGuide> gd;
+
+ /**
+ * Gets the value of the gd property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the gd property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getGd().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link CTGeomGuide }
+ *
+ *
+ */
+ public List<CTGeomGuide> getGd() {
+ if (gd == null) {
+ gd = new ArrayList<CTGeomGuide>();
+ }
+ return this.gd;
+ }
+
+ public boolean isSetGd() {
+ return ((this.gd!= null)&&(!this.gd.isEmpty()));
+ }
+
+ public void unsetGd() {
+ this.gd = null;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTGeomRect.java b/src/java/org/apache/poi/sl/draw/binding/CTGeomRect.java new file mode 100644 index 0000000000..3198f0410e --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTGeomRect.java @@ -0,0 +1,171 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_GeomRect complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_GeomRect">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="l" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
+ * <attribute name="t" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
+ * <attribute name="r" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
+ * <attribute name="b" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_GeomRect", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTGeomRect {
+
+ @XmlAttribute(name = "l", required = true)
+ protected String l;
+ @XmlAttribute(name = "t", required = true)
+ protected String t;
+ @XmlAttribute(name = "r", required = true)
+ protected String r;
+ @XmlAttribute(name = "b", required = true)
+ protected String b;
+
+ /**
+ * Gets the value of the l property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getL() {
+ return l;
+ }
+
+ /**
+ * Sets the value of the l property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setL(String value) {
+ this.l = value;
+ }
+
+ public boolean isSetL() {
+ return (this.l!= null);
+ }
+
+ /**
+ * Gets the value of the t property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getT() {
+ return t;
+ }
+
+ /**
+ * Sets the value of the t property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setT(String value) {
+ this.t = value;
+ }
+
+ public boolean isSetT() {
+ return (this.t!= null);
+ }
+
+ /**
+ * Gets the value of the r property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getR() {
+ return r;
+ }
+
+ /**
+ * Sets the value of the r property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setR(String value) {
+ this.r = value;
+ }
+
+ public boolean isSetR() {
+ return (this.r!= null);
+ }
+
+ /**
+ * Gets the value of the b property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getB() {
+ return b;
+ }
+
+ /**
+ * Sets the value of the b property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setB(String value) {
+ this.b = value;
+ }
+
+ public boolean isSetB() {
+ return (this.b!= null);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTGrayscaleTransform.java b/src/java/org/apache/poi/sl/draw/binding/CTGrayscaleTransform.java new file mode 100644 index 0000000000..643db025a2 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTGrayscaleTransform.java @@ -0,0 +1,46 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_GrayscaleTransform complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_GrayscaleTransform">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_GrayscaleTransform", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTGrayscaleTransform {
+
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTGroupTransform2D.java b/src/java/org/apache/poi/sl/draw/binding/CTGroupTransform2D.java new file mode 100644 index 0000000000..f06e1d8f99 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTGroupTransform2D.java @@ -0,0 +1,296 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_GroupTransform2D complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_GroupTransform2D">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="off" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Point2D" minOccurs="0"/>
+ * <element name="ext" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_PositiveSize2D" minOccurs="0"/>
+ * <element name="chOff" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Point2D" minOccurs="0"/>
+ * <element name="chExt" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_PositiveSize2D" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="rot" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Angle" default="0" />
+ * <attribute name="flipH" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
+ * <attribute name="flipV" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_GroupTransform2D", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "off",
+ "ext",
+ "chOff",
+ "chExt"
+})
+public class CTGroupTransform2D {
+
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected CTPoint2D off;
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected CTPositiveSize2D ext;
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected CTPoint2D chOff;
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected CTPositiveSize2D chExt;
+ @XmlAttribute(name = "rot")
+ protected Integer rot;
+ @XmlAttribute(name = "flipH")
+ protected Boolean flipH;
+ @XmlAttribute(name = "flipV")
+ protected Boolean flipV;
+
+ /**
+ * Gets the value of the off property.
+ *
+ * @return
+ * possible object is
+ * {@link CTPoint2D }
+ *
+ */
+ public CTPoint2D getOff() {
+ return off;
+ }
+
+ /**
+ * Sets the value of the off property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTPoint2D }
+ *
+ */
+ public void setOff(CTPoint2D value) {
+ this.off = value;
+ }
+
+ public boolean isSetOff() {
+ return (this.off!= null);
+ }
+
+ /**
+ * Gets the value of the ext property.
+ *
+ * @return
+ * possible object is
+ * {@link CTPositiveSize2D }
+ *
+ */
+ public CTPositiveSize2D getExt() {
+ return ext;
+ }
+
+ /**
+ * Sets the value of the ext property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTPositiveSize2D }
+ *
+ */
+ public void setExt(CTPositiveSize2D value) {
+ this.ext = value;
+ }
+
+ public boolean isSetExt() {
+ return (this.ext!= null);
+ }
+
+ /**
+ * Gets the value of the chOff property.
+ *
+ * @return
+ * possible object is
+ * {@link CTPoint2D }
+ *
+ */
+ public CTPoint2D getChOff() {
+ return chOff;
+ }
+
+ /**
+ * Sets the value of the chOff property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTPoint2D }
+ *
+ */
+ public void setChOff(CTPoint2D value) {
+ this.chOff = value;
+ }
+
+ public boolean isSetChOff() {
+ return (this.chOff!= null);
+ }
+
+ /**
+ * Gets the value of the chExt property.
+ *
+ * @return
+ * possible object is
+ * {@link CTPositiveSize2D }
+ *
+ */
+ public CTPositiveSize2D getChExt() {
+ return chExt;
+ }
+
+ /**
+ * Sets the value of the chExt property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTPositiveSize2D }
+ *
+ */
+ public void setChExt(CTPositiveSize2D value) {
+ this.chExt = value;
+ }
+
+ public boolean isSetChExt() {
+ return (this.chExt!= null);
+ }
+
+ /**
+ * Gets the value of the rot property.
+ *
+ * @return
+ * possible object is
+ * {@link Integer }
+ *
+ */
+ public int getRot() {
+ if (rot == null) {
+ return 0;
+ } else {
+ return rot;
+ }
+ }
+
+ /**
+ * Sets the value of the rot property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Integer }
+ *
+ */
+ public void setRot(int value) {
+ this.rot = value;
+ }
+
+ public boolean isSetRot() {
+ return (this.rot!= null);
+ }
+
+ public void unsetRot() {
+ this.rot = null;
+ }
+
+ /**
+ * Gets the value of the flipH property.
+ *
+ * @return
+ * possible object is
+ * {@link Boolean }
+ *
+ */
+ public boolean isFlipH() {
+ if (flipH == null) {
+ return false;
+ } else {
+ return flipH;
+ }
+ }
+
+ /**
+ * Sets the value of the flipH property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Boolean }
+ *
+ */
+ public void setFlipH(boolean value) {
+ this.flipH = value;
+ }
+
+ public boolean isSetFlipH() {
+ return (this.flipH!= null);
+ }
+
+ public void unsetFlipH() {
+ this.flipH = null;
+ }
+
+ /**
+ * Gets the value of the flipV property.
+ *
+ * @return
+ * possible object is
+ * {@link Boolean }
+ *
+ */
+ public boolean isFlipV() {
+ if (flipV == null) {
+ return false;
+ } else {
+ return flipV;
+ }
+ }
+
+ /**
+ * Sets the value of the flipV property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Boolean }
+ *
+ */
+ public void setFlipV(boolean value) {
+ this.flipV = value;
+ }
+
+ public boolean isSetFlipV() {
+ return (this.flipV!= null);
+ }
+
+ public void unsetFlipV() {
+ this.flipV = null;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTHslColor.java b/src/java/org/apache/poi/sl/draw/binding/CTHslColor.java new file mode 100644 index 0000000000..376d423ee3 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTHslColor.java @@ -0,0 +1,221 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlElementRefs;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_HslColor complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_HslColor">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <group ref="{http://schemas.openxmlformats.org/drawingml/2006/main}EG_ColorTransform" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="hue" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_PositiveFixedAngle" />
+ * <attribute name="sat" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Percentage" />
+ * <attribute name="lum" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Percentage" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_HslColor", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "egColorTransform"
+})
+public class CTHslColor {
+
+ @XmlElementRefs({
+ @XmlElementRef(name = "red", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "greenMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "gamma", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "hueMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "hueOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "invGamma", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "gray", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "comp", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "lumMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "green", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "inv", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "satMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "sat", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "alphaOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "greenOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "redOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "blueOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "alphaMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "lumOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "blueMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "satOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "lum", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "alpha", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "tint", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "blue", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "redMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "hue", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "shade", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false)
+ })
+ protected List<JAXBElement<?>> egColorTransform;
+ @XmlAttribute(name = "hue", required = true)
+ protected int hue;
+ @XmlAttribute(name = "sat", required = true)
+ protected int sat;
+ @XmlAttribute(name = "lum", required = true)
+ protected int lum;
+
+ /**
+ * Gets the value of the egColorTransform property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the egColorTransform property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getEGColorTransform().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTGammaTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTAngle }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTInverseGammaTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTGrayscaleTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTComplementTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTInverseTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTFixedPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedAngle }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}
+ *
+ *
+ */
+ public List<JAXBElement<?>> getEGColorTransform() {
+ if (egColorTransform == null) {
+ egColorTransform = new ArrayList<JAXBElement<?>>();
+ }
+ return this.egColorTransform;
+ }
+
+ public boolean isSetEGColorTransform() {
+ return ((this.egColorTransform!= null)&&(!this.egColorTransform.isEmpty()));
+ }
+
+ public void unsetEGColorTransform() {
+ this.egColorTransform = null;
+ }
+
+ /**
+ * Gets the value of the hue property.
+ *
+ */
+ public int getHue() {
+ return hue;
+ }
+
+ /**
+ * Sets the value of the hue property.
+ *
+ */
+ public void setHue(int value) {
+ this.hue = value;
+ }
+
+ public boolean isSetHue() {
+ return true;
+ }
+
+ /**
+ * Gets the value of the sat property.
+ *
+ */
+ public int getSat() {
+ return sat;
+ }
+
+ /**
+ * Sets the value of the sat property.
+ *
+ */
+ public void setSat(int value) {
+ this.sat = value;
+ }
+
+ public boolean isSetSat() {
+ return true;
+ }
+
+ /**
+ * Gets the value of the lum property.
+ *
+ */
+ public int getLum() {
+ return lum;
+ }
+
+ /**
+ * Sets the value of the lum property.
+ *
+ */
+ public void setLum(int value) {
+ this.lum = value;
+ }
+
+ public boolean isSetLum() {
+ return true;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTHyperlink.java b/src/java/org/apache/poi/sl/draw/binding/CTHyperlink.java new file mode 100644 index 0000000000..0c89f392ac --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTHyperlink.java @@ -0,0 +1,403 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_Hyperlink complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Hyperlink">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="snd" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_EmbeddedWAVAudioFile" minOccurs="0"/>
+ * <element name="extLst" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_OfficeArtExtensionList" minOccurs="0"/>
+ * </sequence>
+ * <attribute ref="{http://schemas.openxmlformats.org/officeDocument/2006/relationships}id"/>
+ * <attribute name="invalidUrl" type="{http://www.w3.org/2001/XMLSchema}string" default="" />
+ * <attribute name="action" type="{http://www.w3.org/2001/XMLSchema}string" default="" />
+ * <attribute name="tgtFrame" type="{http://www.w3.org/2001/XMLSchema}string" default="" />
+ * <attribute name="tooltip" type="{http://www.w3.org/2001/XMLSchema}string" default="" />
+ * <attribute name="history" type="{http://www.w3.org/2001/XMLSchema}boolean" default="true" />
+ * <attribute name="highlightClick" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
+ * <attribute name="endSnd" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_Hyperlink", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "snd",
+ "extLst"
+})
+public class CTHyperlink {
+
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected CTEmbeddedWAVAudioFile snd;
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected CTOfficeArtExtensionList extLst;
+ @XmlAttribute(name = "id", namespace = "http://schemas.openxmlformats.org/officeDocument/2006/relationships")
+ protected String id;
+ @XmlAttribute(name = "invalidUrl")
+ protected String invalidUrl;
+ @XmlAttribute(name = "action")
+ protected String action;
+ @XmlAttribute(name = "tgtFrame")
+ protected String tgtFrame;
+ @XmlAttribute(name = "tooltip")
+ protected String tooltip;
+ @XmlAttribute(name = "history")
+ protected Boolean history;
+ @XmlAttribute(name = "highlightClick")
+ protected Boolean highlightClick;
+ @XmlAttribute(name = "endSnd")
+ protected Boolean endSnd;
+
+ /**
+ * Gets the value of the snd property.
+ *
+ * @return
+ * possible object is
+ * {@link CTEmbeddedWAVAudioFile }
+ *
+ */
+ public CTEmbeddedWAVAudioFile getSnd() {
+ return snd;
+ }
+
+ /**
+ * Sets the value of the snd property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTEmbeddedWAVAudioFile }
+ *
+ */
+ public void setSnd(CTEmbeddedWAVAudioFile value) {
+ this.snd = value;
+ }
+
+ public boolean isSetSnd() {
+ return (this.snd!= null);
+ }
+
+ /**
+ * Gets the value of the extLst property.
+ *
+ * @return
+ * possible object is
+ * {@link CTOfficeArtExtensionList }
+ *
+ */
+ public CTOfficeArtExtensionList getExtLst() {
+ return extLst;
+ }
+
+ /**
+ * Sets the value of the extLst property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTOfficeArtExtensionList }
+ *
+ */
+ public void setExtLst(CTOfficeArtExtensionList value) {
+ this.extLst = value;
+ }
+
+ public boolean isSetExtLst() {
+ return (this.extLst!= null);
+ }
+
+ /**
+ * Drawing Object Hyperlink Target
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setId(String value) {
+ this.id = value;
+ }
+
+ public boolean isSetId() {
+ return (this.id!= null);
+ }
+
+ /**
+ * Gets the value of the invalidUrl property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getInvalidUrl() {
+ if (invalidUrl == null) {
+ return "";
+ } else {
+ return invalidUrl;
+ }
+ }
+
+ /**
+ * Sets the value of the invalidUrl property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setInvalidUrl(String value) {
+ this.invalidUrl = value;
+ }
+
+ public boolean isSetInvalidUrl() {
+ return (this.invalidUrl!= null);
+ }
+
+ /**
+ * Gets the value of the action property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getAction() {
+ if (action == null) {
+ return "";
+ } else {
+ return action;
+ }
+ }
+
+ /**
+ * Sets the value of the action property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setAction(String value) {
+ this.action = value;
+ }
+
+ public boolean isSetAction() {
+ return (this.action!= null);
+ }
+
+ /**
+ * Gets the value of the tgtFrame property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getTgtFrame() {
+ if (tgtFrame == null) {
+ return "";
+ } else {
+ return tgtFrame;
+ }
+ }
+
+ /**
+ * Sets the value of the tgtFrame property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setTgtFrame(String value) {
+ this.tgtFrame = value;
+ }
+
+ public boolean isSetTgtFrame() {
+ return (this.tgtFrame!= null);
+ }
+
+ /**
+ * Gets the value of the tooltip property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getTooltip() {
+ if (tooltip == null) {
+ return "";
+ } else {
+ return tooltip;
+ }
+ }
+
+ /**
+ * Sets the value of the tooltip property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setTooltip(String value) {
+ this.tooltip = value;
+ }
+
+ public boolean isSetTooltip() {
+ return (this.tooltip!= null);
+ }
+
+ /**
+ * Gets the value of the history property.
+ *
+ * @return
+ * possible object is
+ * {@link Boolean }
+ *
+ */
+ public boolean isHistory() {
+ if (history == null) {
+ return true;
+ } else {
+ return history;
+ }
+ }
+
+ /**
+ * Sets the value of the history property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Boolean }
+ *
+ */
+ public void setHistory(boolean value) {
+ this.history = value;
+ }
+
+ public boolean isSetHistory() {
+ return (this.history!= null);
+ }
+
+ public void unsetHistory() {
+ this.history = null;
+ }
+
+ /**
+ * Gets the value of the highlightClick property.
+ *
+ * @return
+ * possible object is
+ * {@link Boolean }
+ *
+ */
+ public boolean isHighlightClick() {
+ if (highlightClick == null) {
+ return false;
+ } else {
+ return highlightClick;
+ }
+ }
+
+ /**
+ * Sets the value of the highlightClick property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Boolean }
+ *
+ */
+ public void setHighlightClick(boolean value) {
+ this.highlightClick = value;
+ }
+
+ public boolean isSetHighlightClick() {
+ return (this.highlightClick!= null);
+ }
+
+ public void unsetHighlightClick() {
+ this.highlightClick = null;
+ }
+
+ /**
+ * Gets the value of the endSnd property.
+ *
+ * @return
+ * possible object is
+ * {@link Boolean }
+ *
+ */
+ public boolean isEndSnd() {
+ if (endSnd == null) {
+ return false;
+ } else {
+ return endSnd;
+ }
+ }
+
+ /**
+ * Sets the value of the endSnd property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Boolean }
+ *
+ */
+ public void setEndSnd(boolean value) {
+ this.endSnd = value;
+ }
+
+ public boolean isSetEndSnd() {
+ return (this.endSnd!= null);
+ }
+
+ public void unsetEndSnd() {
+ this.endSnd = null;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTInverseGammaTransform.java b/src/java/org/apache/poi/sl/draw/binding/CTInverseGammaTransform.java new file mode 100644 index 0000000000..eaff064d70 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTInverseGammaTransform.java @@ -0,0 +1,46 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_InverseGammaTransform complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_InverseGammaTransform">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_InverseGammaTransform", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTInverseGammaTransform {
+
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTInverseTransform.java b/src/java/org/apache/poi/sl/draw/binding/CTInverseTransform.java new file mode 100644 index 0000000000..84af625337 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTInverseTransform.java @@ -0,0 +1,46 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_InverseTransform complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_InverseTransform">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_InverseTransform", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTInverseTransform {
+
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTOfficeArtExtension.java b/src/java/org/apache/poi/sl/draw/binding/CTOfficeArtExtension.java new file mode 100644 index 0000000000..ec864d3b53 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTOfficeArtExtension.java @@ -0,0 +1,122 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.w3c.dom.Element;
+
+
+/**
+ * <p>Java class for CT_OfficeArtExtension complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_OfficeArtExtension">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <any processContents='lax'/>
+ * </sequence>
+ * <attribute name="uri" type="{http://www.w3.org/2001/XMLSchema}token" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_OfficeArtExtension", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "any"
+})
+public class CTOfficeArtExtension {
+
+ @XmlAnyElement(lax = true)
+ protected Object any;
+ @XmlAttribute(name = "uri")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlSchemaType(name = "token")
+ protected String uri;
+
+ /**
+ * Gets the value of the any property.
+ *
+ * @return
+ * possible object is
+ * {@link Object }
+ * {@link Element }
+ *
+ */
+ public Object getAny() {
+ return any;
+ }
+
+ /**
+ * Sets the value of the any property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Object }
+ * {@link Element }
+ *
+ */
+ public void setAny(Object value) {
+ this.any = value;
+ }
+
+ public boolean isSetAny() {
+ return (this.any!= null);
+ }
+
+ /**
+ * Gets the value of the uri property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getUri() {
+ return uri;
+ }
+
+ /**
+ * Sets the value of the uri property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setUri(String value) {
+ this.uri = value;
+ }
+
+ public boolean isSetUri() {
+ return (this.uri!= null);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTOfficeArtExtensionList.java b/src/java/org/apache/poi/sl/draw/binding/CTOfficeArtExtensionList.java new file mode 100644 index 0000000000..f0b54cb180 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTOfficeArtExtensionList.java @@ -0,0 +1,93 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_OfficeArtExtensionList complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_OfficeArtExtensionList">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <group ref="{http://schemas.openxmlformats.org/drawingml/2006/main}EG_OfficeArtExtensionList"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_OfficeArtExtensionList", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "ext"
+})
+public class CTOfficeArtExtensionList {
+
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected List<CTOfficeArtExtension> ext;
+
+ /**
+ * Gets the value of the ext property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the ext property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getExt().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link CTOfficeArtExtension }
+ *
+ *
+ */
+ public List<CTOfficeArtExtension> getExt() {
+ if (ext == null) {
+ ext = new ArrayList<CTOfficeArtExtension>();
+ }
+ return this.ext;
+ }
+
+ public boolean isSetExt() {
+ return ((this.ext!= null)&&(!this.ext.isEmpty()));
+ }
+
+ public void unsetExt() {
+ this.ext = null;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTPath2D.java b/src/java/org/apache/poi/sl/draw/binding/CTPath2D.java new file mode 100644 index 0000000000..5294812967 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTPath2D.java @@ -0,0 +1,303 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_Path2D complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Path2D">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <choice maxOccurs="unbounded" minOccurs="0">
+ * <element name="close" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Path2DClose"/>
+ * <element name="moveTo" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Path2DMoveTo"/>
+ * <element name="lnTo" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Path2DLineTo"/>
+ * <element name="arcTo" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Path2DArcTo"/>
+ * <element name="quadBezTo" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Path2DQuadBezierTo"/>
+ * <element name="cubicBezTo" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Path2DCubicBezierTo"/>
+ * </choice>
+ * <attribute name="w" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_PositiveCoordinate" default="0" />
+ * <attribute name="h" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_PositiveCoordinate" default="0" />
+ * <attribute name="fill" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_PathFillMode" default="norm" />
+ * <attribute name="stroke" type="{http://www.w3.org/2001/XMLSchema}boolean" default="true" />
+ * <attribute name="extrusionOk" type="{http://www.w3.org/2001/XMLSchema}boolean" default="true" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_Path2D", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "closeOrMoveToOrLnTo"
+})
+public class CTPath2D {
+
+ @XmlElements({
+ @XmlElement(name = "close", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTPath2DClose.class),
+ @XmlElement(name = "moveTo", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTPath2DMoveTo.class),
+ @XmlElement(name = "lnTo", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTPath2DLineTo.class),
+ @XmlElement(name = "arcTo", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTPath2DArcTo.class),
+ @XmlElement(name = "quadBezTo", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTPath2DQuadBezierTo.class),
+ @XmlElement(name = "cubicBezTo", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = CTPath2DCubicBezierTo.class)
+ })
+ protected List<Object> closeOrMoveToOrLnTo;
+ @XmlAttribute(name = "w")
+ protected Long w;
+ @XmlAttribute(name = "h")
+ protected Long h;
+ @XmlAttribute(name = "fill")
+ protected STPathFillMode fill;
+ @XmlAttribute(name = "stroke")
+ protected Boolean stroke;
+ @XmlAttribute(name = "extrusionOk")
+ protected Boolean extrusionOk;
+
+ /**
+ * Gets the value of the closeOrMoveToOrLnTo property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the closeOrMoveToOrLnTo property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getCloseOrMoveToOrLnTo().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link CTPath2DClose }
+ * {@link CTPath2DMoveTo }
+ * {@link CTPath2DLineTo }
+ * {@link CTPath2DArcTo }
+ * {@link CTPath2DQuadBezierTo }
+ * {@link CTPath2DCubicBezierTo }
+ *
+ *
+ */
+ public List<Object> getCloseOrMoveToOrLnTo() {
+ if (closeOrMoveToOrLnTo == null) {
+ closeOrMoveToOrLnTo = new ArrayList<Object>();
+ }
+ return this.closeOrMoveToOrLnTo;
+ }
+
+ public boolean isSetCloseOrMoveToOrLnTo() {
+ return ((this.closeOrMoveToOrLnTo!= null)&&(!this.closeOrMoveToOrLnTo.isEmpty()));
+ }
+
+ public void unsetCloseOrMoveToOrLnTo() {
+ this.closeOrMoveToOrLnTo = null;
+ }
+
+ /**
+ * Gets the value of the w property.
+ *
+ * @return
+ * possible object is
+ * {@link Long }
+ *
+ */
+ public long getW() {
+ if (w == null) {
+ return 0L;
+ } else {
+ return w;
+ }
+ }
+
+ /**
+ * Sets the value of the w property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Long }
+ *
+ */
+ public void setW(long value) {
+ this.w = value;
+ }
+
+ public boolean isSetW() {
+ return (this.w!= null);
+ }
+
+ public void unsetW() {
+ this.w = null;
+ }
+
+ /**
+ * Gets the value of the h property.
+ *
+ * @return
+ * possible object is
+ * {@link Long }
+ *
+ */
+ public long getH() {
+ if (h == null) {
+ return 0L;
+ } else {
+ return h;
+ }
+ }
+
+ /**
+ * Sets the value of the h property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Long }
+ *
+ */
+ public void setH(long value) {
+ this.h = value;
+ }
+
+ public boolean isSetH() {
+ return (this.h!= null);
+ }
+
+ public void unsetH() {
+ this.h = null;
+ }
+
+ /**
+ * Gets the value of the fill property.
+ *
+ * @return
+ * possible object is
+ * {@link STPathFillMode }
+ *
+ */
+ public STPathFillMode getFill() {
+ if (fill == null) {
+ return STPathFillMode.NORM;
+ } else {
+ return fill;
+ }
+ }
+
+ /**
+ * Sets the value of the fill property.
+ *
+ * @param value
+ * allowed object is
+ * {@link STPathFillMode }
+ *
+ */
+ public void setFill(STPathFillMode value) {
+ this.fill = value;
+ }
+
+ public boolean isSetFill() {
+ return (this.fill!= null);
+ }
+
+ /**
+ * Gets the value of the stroke property.
+ *
+ * @return
+ * possible object is
+ * {@link Boolean }
+ *
+ */
+ public boolean isStroke() {
+ if (stroke == null) {
+ return true;
+ } else {
+ return stroke;
+ }
+ }
+
+ /**
+ * Sets the value of the stroke property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Boolean }
+ *
+ */
+ public void setStroke(boolean value) {
+ this.stroke = value;
+ }
+
+ public boolean isSetStroke() {
+ return (this.stroke!= null);
+ }
+
+ public void unsetStroke() {
+ this.stroke = null;
+ }
+
+ /**
+ * Gets the value of the extrusionOk property.
+ *
+ * @return
+ * possible object is
+ * {@link Boolean }
+ *
+ */
+ public boolean isExtrusionOk() {
+ if (extrusionOk == null) {
+ return true;
+ } else {
+ return extrusionOk;
+ }
+ }
+
+ /**
+ * Sets the value of the extrusionOk property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Boolean }
+ *
+ */
+ public void setExtrusionOk(boolean value) {
+ this.extrusionOk = value;
+ }
+
+ public boolean isSetExtrusionOk() {
+ return (this.extrusionOk!= null);
+ }
+
+ public void unsetExtrusionOk() {
+ this.extrusionOk = null;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTPath2DArcTo.java b/src/java/org/apache/poi/sl/draw/binding/CTPath2DArcTo.java new file mode 100644 index 0000000000..5464ee4d14 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTPath2DArcTo.java @@ -0,0 +1,171 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_Path2DArcTo complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Path2DArcTo">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="wR" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
+ * <attribute name="hR" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
+ * <attribute name="stAng" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjAngle" />
+ * <attribute name="swAng" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjAngle" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_Path2DArcTo", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTPath2DArcTo {
+
+ @XmlAttribute(name = "wR", required = true)
+ protected String wr;
+ @XmlAttribute(name = "hR", required = true)
+ protected String hr;
+ @XmlAttribute(name = "stAng", required = true)
+ protected String stAng;
+ @XmlAttribute(name = "swAng", required = true)
+ protected String swAng;
+
+ /**
+ * Gets the value of the wr property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getWR() {
+ return wr;
+ }
+
+ /**
+ * Sets the value of the wr property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setWR(String value) {
+ this.wr = value;
+ }
+
+ public boolean isSetWR() {
+ return (this.wr!= null);
+ }
+
+ /**
+ * Gets the value of the hr property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getHR() {
+ return hr;
+ }
+
+ /**
+ * Sets the value of the hr property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setHR(String value) {
+ this.hr = value;
+ }
+
+ public boolean isSetHR() {
+ return (this.hr!= null);
+ }
+
+ /**
+ * Gets the value of the stAng property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getStAng() {
+ return stAng;
+ }
+
+ /**
+ * Sets the value of the stAng property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setStAng(String value) {
+ this.stAng = value;
+ }
+
+ public boolean isSetStAng() {
+ return (this.stAng!= null);
+ }
+
+ /**
+ * Gets the value of the swAng property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getSwAng() {
+ return swAng;
+ }
+
+ /**
+ * Sets the value of the swAng property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setSwAng(String value) {
+ this.swAng = value;
+ }
+
+ public boolean isSetSwAng() {
+ return (this.swAng!= null);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTPath2DClose.java b/src/java/org/apache/poi/sl/draw/binding/CTPath2DClose.java new file mode 100644 index 0000000000..a60f98bb67 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTPath2DClose.java @@ -0,0 +1,46 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_Path2DClose complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Path2DClose">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_Path2DClose", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTPath2DClose {
+
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTPath2DCubicBezierTo.java b/src/java/org/apache/poi/sl/draw/binding/CTPath2DCubicBezierTo.java new file mode 100644 index 0000000000..e1818fa5db --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTPath2DCubicBezierTo.java @@ -0,0 +1,93 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_Path2DCubicBezierTo complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Path2DCubicBezierTo">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="pt" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_AdjPoint2D" maxOccurs="3" minOccurs="3"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_Path2DCubicBezierTo", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "pt"
+})
+public class CTPath2DCubicBezierTo {
+
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", required = true)
+ protected List<CTAdjPoint2D> pt;
+
+ /**
+ * Gets the value of the pt property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the pt property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getPt().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link CTAdjPoint2D }
+ *
+ *
+ */
+ public List<CTAdjPoint2D> getPt() {
+ if (pt == null) {
+ pt = new ArrayList<CTAdjPoint2D>();
+ }
+ return this.pt;
+ }
+
+ public boolean isSetPt() {
+ return ((this.pt!= null)&&(!this.pt.isEmpty()));
+ }
+
+ public void unsetPt() {
+ this.pt = null;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTPath2DLineTo.java b/src/java/org/apache/poi/sl/draw/binding/CTPath2DLineTo.java new file mode 100644 index 0000000000..9c6d1b39a8 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTPath2DLineTo.java @@ -0,0 +1,82 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_Path2DLineTo complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Path2DLineTo">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="pt" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_AdjPoint2D"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_Path2DLineTo", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "pt"
+})
+public class CTPath2DLineTo {
+
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", required = true)
+ protected CTAdjPoint2D pt;
+
+ /**
+ * Gets the value of the pt property.
+ *
+ * @return
+ * possible object is
+ * {@link CTAdjPoint2D }
+ *
+ */
+ public CTAdjPoint2D getPt() {
+ return pt;
+ }
+
+ /**
+ * Sets the value of the pt property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTAdjPoint2D }
+ *
+ */
+ public void setPt(CTAdjPoint2D value) {
+ this.pt = value;
+ }
+
+ public boolean isSetPt() {
+ return (this.pt!= null);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTPath2DList.java b/src/java/org/apache/poi/sl/draw/binding/CTPath2DList.java new file mode 100644 index 0000000000..cd31a0ba57 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTPath2DList.java @@ -0,0 +1,93 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_Path2DList complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Path2DList">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="path" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Path2D" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_Path2DList", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "path"
+})
+public class CTPath2DList {
+
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected List<CTPath2D> path;
+
+ /**
+ * Gets the value of the path property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the path property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getPath().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link CTPath2D }
+ *
+ *
+ */
+ public List<CTPath2D> getPath() {
+ if (path == null) {
+ path = new ArrayList<CTPath2D>();
+ }
+ return this.path;
+ }
+
+ public boolean isSetPath() {
+ return ((this.path!= null)&&(!this.path.isEmpty()));
+ }
+
+ public void unsetPath() {
+ this.path = null;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTPath2DMoveTo.java b/src/java/org/apache/poi/sl/draw/binding/CTPath2DMoveTo.java new file mode 100644 index 0000000000..f5e210f768 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTPath2DMoveTo.java @@ -0,0 +1,82 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_Path2DMoveTo complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Path2DMoveTo">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="pt" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_AdjPoint2D"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_Path2DMoveTo", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "pt"
+})
+public class CTPath2DMoveTo {
+
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", required = true)
+ protected CTAdjPoint2D pt;
+
+ /**
+ * Gets the value of the pt property.
+ *
+ * @return
+ * possible object is
+ * {@link CTAdjPoint2D }
+ *
+ */
+ public CTAdjPoint2D getPt() {
+ return pt;
+ }
+
+ /**
+ * Sets the value of the pt property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTAdjPoint2D }
+ *
+ */
+ public void setPt(CTAdjPoint2D value) {
+ this.pt = value;
+ }
+
+ public boolean isSetPt() {
+ return (this.pt!= null);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTPath2DQuadBezierTo.java b/src/java/org/apache/poi/sl/draw/binding/CTPath2DQuadBezierTo.java new file mode 100644 index 0000000000..b588775245 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTPath2DQuadBezierTo.java @@ -0,0 +1,93 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_Path2DQuadBezierTo complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Path2DQuadBezierTo">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="pt" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_AdjPoint2D" maxOccurs="2" minOccurs="2"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_Path2DQuadBezierTo", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "pt"
+})
+public class CTPath2DQuadBezierTo {
+
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", required = true)
+ protected List<CTAdjPoint2D> pt;
+
+ /**
+ * Gets the value of the pt property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the pt property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getPt().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link CTAdjPoint2D }
+ *
+ *
+ */
+ public List<CTAdjPoint2D> getPt() {
+ if (pt == null) {
+ pt = new ArrayList<CTAdjPoint2D>();
+ }
+ return this.pt;
+ }
+
+ public boolean isSetPt() {
+ return ((this.pt!= null)&&(!this.pt.isEmpty()));
+ }
+
+ public void unsetPt() {
+ this.pt = null;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTPercentage.java b/src/java/org/apache/poi/sl/draw/binding/CTPercentage.java new file mode 100644 index 0000000000..e1a74b53e5 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTPercentage.java @@ -0,0 +1,70 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_Percentage complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Percentage">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="val" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Percentage" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_Percentage", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTPercentage {
+
+ @XmlAttribute(name = "val", required = true)
+ protected int val;
+
+ /**
+ * Gets the value of the val property.
+ *
+ */
+ public int getVal() {
+ return val;
+ }
+
+ /**
+ * Sets the value of the val property.
+ *
+ */
+ public void setVal(int value) {
+ this.val = value;
+ }
+
+ public boolean isSetVal() {
+ return true;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTPoint2D.java b/src/java/org/apache/poi/sl/draw/binding/CTPoint2D.java new file mode 100644 index 0000000000..06cbfbc7aa --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTPoint2D.java @@ -0,0 +1,93 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_Point2D complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Point2D">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="x" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Coordinate" />
+ * <attribute name="y" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Coordinate" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_Point2D", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTPoint2D {
+
+ @XmlAttribute(name = "x", required = true)
+ protected long x;
+ @XmlAttribute(name = "y", required = true)
+ protected long y;
+
+ /**
+ * Gets the value of the x property.
+ *
+ */
+ public long getX() {
+ return x;
+ }
+
+ /**
+ * Sets the value of the x property.
+ *
+ */
+ public void setX(long value) {
+ this.x = value;
+ }
+
+ public boolean isSetX() {
+ return true;
+ }
+
+ /**
+ * Gets the value of the y property.
+ *
+ */
+ public long getY() {
+ return y;
+ }
+
+ /**
+ * Sets the value of the y property.
+ *
+ */
+ public void setY(long value) {
+ this.y = value;
+ }
+
+ public boolean isSetY() {
+ return true;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTPoint3D.java b/src/java/org/apache/poi/sl/draw/binding/CTPoint3D.java new file mode 100644 index 0000000000..3cbeb670f9 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTPoint3D.java @@ -0,0 +1,116 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_Point3D complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Point3D">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="x" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Coordinate" />
+ * <attribute name="y" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Coordinate" />
+ * <attribute name="z" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Coordinate" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_Point3D", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTPoint3D {
+
+ @XmlAttribute(name = "x", required = true)
+ protected long x;
+ @XmlAttribute(name = "y", required = true)
+ protected long y;
+ @XmlAttribute(name = "z", required = true)
+ protected long z;
+
+ /**
+ * Gets the value of the x property.
+ *
+ */
+ public long getX() {
+ return x;
+ }
+
+ /**
+ * Sets the value of the x property.
+ *
+ */
+ public void setX(long value) {
+ this.x = value;
+ }
+
+ public boolean isSetX() {
+ return true;
+ }
+
+ /**
+ * Gets the value of the y property.
+ *
+ */
+ public long getY() {
+ return y;
+ }
+
+ /**
+ * Sets the value of the y property.
+ *
+ */
+ public void setY(long value) {
+ this.y = value;
+ }
+
+ public boolean isSetY() {
+ return true;
+ }
+
+ /**
+ * Gets the value of the z property.
+ *
+ */
+ public long getZ() {
+ return z;
+ }
+
+ /**
+ * Sets the value of the z property.
+ *
+ */
+ public void setZ(long value) {
+ this.z = value;
+ }
+
+ public boolean isSetZ() {
+ return true;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTPolarAdjustHandle.java b/src/java/org/apache/poi/sl/draw/binding/CTPolarAdjustHandle.java new file mode 100644 index 0000000000..646dad5b58 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTPolarAdjustHandle.java @@ -0,0 +1,273 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+/**
+ * <p>Java class for CT_PolarAdjustHandle complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_PolarAdjustHandle">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="pos" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_AdjPoint2D"/>
+ * </sequence>
+ * <attribute name="gdRefR" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_GeomGuideName" />
+ * <attribute name="minR" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
+ * <attribute name="maxR" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
+ * <attribute name="gdRefAng" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_GeomGuideName" />
+ * <attribute name="minAng" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjAngle" />
+ * <attribute name="maxAng" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjAngle" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_PolarAdjustHandle", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "pos"
+})
+public class CTPolarAdjustHandle {
+
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", required = true)
+ protected CTAdjPoint2D pos;
+ @XmlAttribute(name = "gdRefR")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ protected String gdRefR;
+ @XmlAttribute(name = "minR")
+ protected String minR;
+ @XmlAttribute(name = "maxR")
+ protected String maxR;
+ @XmlAttribute(name = "gdRefAng")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ protected String gdRefAng;
+ @XmlAttribute(name = "minAng")
+ protected String minAng;
+ @XmlAttribute(name = "maxAng")
+ protected String maxAng;
+
+ /**
+ * Gets the value of the pos property.
+ *
+ * @return
+ * possible object is
+ * {@link CTAdjPoint2D }
+ *
+ */
+ public CTAdjPoint2D getPos() {
+ return pos;
+ }
+
+ /**
+ * Sets the value of the pos property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTAdjPoint2D }
+ *
+ */
+ public void setPos(CTAdjPoint2D value) {
+ this.pos = value;
+ }
+
+ public boolean isSetPos() {
+ return (this.pos!= null);
+ }
+
+ /**
+ * Gets the value of the gdRefR property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getGdRefR() {
+ return gdRefR;
+ }
+
+ /**
+ * Sets the value of the gdRefR property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setGdRefR(String value) {
+ this.gdRefR = value;
+ }
+
+ public boolean isSetGdRefR() {
+ return (this.gdRefR!= null);
+ }
+
+ /**
+ * Gets the value of the minR property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMinR() {
+ return minR;
+ }
+
+ /**
+ * Sets the value of the minR property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMinR(String value) {
+ this.minR = value;
+ }
+
+ public boolean isSetMinR() {
+ return (this.minR!= null);
+ }
+
+ /**
+ * Gets the value of the maxR property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMaxR() {
+ return maxR;
+ }
+
+ /**
+ * Sets the value of the maxR property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMaxR(String value) {
+ this.maxR = value;
+ }
+
+ public boolean isSetMaxR() {
+ return (this.maxR!= null);
+ }
+
+ /**
+ * Gets the value of the gdRefAng property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getGdRefAng() {
+ return gdRefAng;
+ }
+
+ /**
+ * Sets the value of the gdRefAng property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setGdRefAng(String value) {
+ this.gdRefAng = value;
+ }
+
+ public boolean isSetGdRefAng() {
+ return (this.gdRefAng!= null);
+ }
+
+ /**
+ * Gets the value of the minAng property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMinAng() {
+ return minAng;
+ }
+
+ /**
+ * Sets the value of the minAng property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMinAng(String value) {
+ this.minAng = value;
+ }
+
+ public boolean isSetMinAng() {
+ return (this.minAng!= null);
+ }
+
+ /**
+ * Gets the value of the maxAng property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMaxAng() {
+ return maxAng;
+ }
+
+ /**
+ * Sets the value of the maxAng property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMaxAng(String value) {
+ this.maxAng = value;
+ }
+
+ public boolean isSetMaxAng() {
+ return (this.maxAng!= null);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTPositiveFixedAngle.java b/src/java/org/apache/poi/sl/draw/binding/CTPositiveFixedAngle.java new file mode 100644 index 0000000000..962db95137 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTPositiveFixedAngle.java @@ -0,0 +1,70 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_PositiveFixedAngle complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_PositiveFixedAngle">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="val" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_PositiveFixedAngle" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_PositiveFixedAngle", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTPositiveFixedAngle {
+
+ @XmlAttribute(name = "val", required = true)
+ protected int val;
+
+ /**
+ * Gets the value of the val property.
+ *
+ */
+ public int getVal() {
+ return val;
+ }
+
+ /**
+ * Sets the value of the val property.
+ *
+ */
+ public void setVal(int value) {
+ this.val = value;
+ }
+
+ public boolean isSetVal() {
+ return true;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTPositiveFixedPercentage.java b/src/java/org/apache/poi/sl/draw/binding/CTPositiveFixedPercentage.java new file mode 100644 index 0000000000..001f01adce --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTPositiveFixedPercentage.java @@ -0,0 +1,70 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_PositiveFixedPercentage complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_PositiveFixedPercentage">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="val" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_PositiveFixedPercentage" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_PositiveFixedPercentage", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTPositiveFixedPercentage {
+
+ @XmlAttribute(name = "val", required = true)
+ protected int val;
+
+ /**
+ * Gets the value of the val property.
+ *
+ */
+ public int getVal() {
+ return val;
+ }
+
+ /**
+ * Sets the value of the val property.
+ *
+ */
+ public void setVal(int value) {
+ this.val = value;
+ }
+
+ public boolean isSetVal() {
+ return true;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTPositivePercentage.java b/src/java/org/apache/poi/sl/draw/binding/CTPositivePercentage.java new file mode 100644 index 0000000000..8fc61f301f --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTPositivePercentage.java @@ -0,0 +1,70 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_PositivePercentage complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_PositivePercentage">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="val" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_PositivePercentage" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_PositivePercentage", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTPositivePercentage {
+
+ @XmlAttribute(name = "val", required = true)
+ protected int val;
+
+ /**
+ * Gets the value of the val property.
+ *
+ */
+ public int getVal() {
+ return val;
+ }
+
+ /**
+ * Sets the value of the val property.
+ *
+ */
+ public void setVal(int value) {
+ this.val = value;
+ }
+
+ public boolean isSetVal() {
+ return true;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTPositiveSize2D.java b/src/java/org/apache/poi/sl/draw/binding/CTPositiveSize2D.java new file mode 100644 index 0000000000..c8d76e6e56 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTPositiveSize2D.java @@ -0,0 +1,93 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_PositiveSize2D complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_PositiveSize2D">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="cx" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_PositiveCoordinate" />
+ * <attribute name="cy" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_PositiveCoordinate" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_PositiveSize2D", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTPositiveSize2D {
+
+ @XmlAttribute(name = "cx", required = true)
+ protected long cx;
+ @XmlAttribute(name = "cy", required = true)
+ protected long cy;
+
+ /**
+ * Gets the value of the cx property.
+ *
+ */
+ public long getCx() {
+ return cx;
+ }
+
+ /**
+ * Sets the value of the cx property.
+ *
+ */
+ public void setCx(long value) {
+ this.cx = value;
+ }
+
+ public boolean isSetCx() {
+ return true;
+ }
+
+ /**
+ * Gets the value of the cy property.
+ *
+ */
+ public long getCy() {
+ return cy;
+ }
+
+ /**
+ * Sets the value of the cy property.
+ *
+ */
+ public void setCy(long value) {
+ this.cy = value;
+ }
+
+ public boolean isSetCy() {
+ return true;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTPresetColor.java b/src/java/org/apache/poi/sl/draw/binding/CTPresetColor.java new file mode 100644 index 0000000000..e240a711a0 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTPresetColor.java @@ -0,0 +1,183 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlElementRefs;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_PresetColor complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_PresetColor">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <group ref="{http://schemas.openxmlformats.org/drawingml/2006/main}EG_ColorTransform" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="val" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_PresetColorVal" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_PresetColor", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "egColorTransform"
+})
+public class CTPresetColor {
+
+ @XmlElementRefs({
+ @XmlElementRef(name = "redOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "invGamma", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "blueOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "greenOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "green", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "alphaMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "inv", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "gray", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "blueMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "alpha", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "shade", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "lumOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "hueMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "blue", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "comp", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "alphaOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "hueOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "satOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "hue", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "sat", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "red", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "redMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "tint", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "greenMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "gamma", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "satMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "lumMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "lum", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false)
+ })
+ protected List<JAXBElement<?>> egColorTransform;
+ @XmlAttribute(name = "val")
+ protected STPresetColorVal val;
+
+ /**
+ * Gets the value of the egColorTransform property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the egColorTransform property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getEGColorTransform().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTInverseGammaTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTInverseTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTGrayscaleTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTComplementTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTFixedPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTAngle }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedAngle }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTGammaTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ *
+ *
+ */
+ public List<JAXBElement<?>> getEGColorTransform() {
+ if (egColorTransform == null) {
+ egColorTransform = new ArrayList<JAXBElement<?>>();
+ }
+ return this.egColorTransform;
+ }
+
+ public boolean isSetEGColorTransform() {
+ return ((this.egColorTransform!= null)&&(!this.egColorTransform.isEmpty()));
+ }
+
+ public void unsetEGColorTransform() {
+ this.egColorTransform = null;
+ }
+
+ /**
+ * Gets the value of the val property.
+ *
+ * @return
+ * possible object is
+ * {@link STPresetColorVal }
+ *
+ */
+ public STPresetColorVal getVal() {
+ return val;
+ }
+
+ /**
+ * Sets the value of the val property.
+ *
+ * @param value
+ * allowed object is
+ * {@link STPresetColorVal }
+ *
+ */
+ public void setVal(STPresetColorVal value) {
+ this.val = value;
+ }
+
+ public boolean isSetVal() {
+ return (this.val!= null);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTPresetGeometry2D.java b/src/java/org/apache/poi/sl/draw/binding/CTPresetGeometry2D.java new file mode 100644 index 0000000000..b55b02ea07 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTPresetGeometry2D.java @@ -0,0 +1,114 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_PresetGeometry2D complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_PresetGeometry2D">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="avLst" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_GeomGuideList" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="prst" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_ShapeType" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_PresetGeometry2D", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "avLst"
+})
+public class CTPresetGeometry2D {
+
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected CTGeomGuideList avLst;
+ @XmlAttribute(name = "prst", required = true)
+ protected STShapeType prst;
+
+ /**
+ * Gets the value of the avLst property.
+ *
+ * @return
+ * possible object is
+ * {@link CTGeomGuideList }
+ *
+ */
+ public CTGeomGuideList getAvLst() {
+ return avLst;
+ }
+
+ /**
+ * Sets the value of the avLst property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTGeomGuideList }
+ *
+ */
+ public void setAvLst(CTGeomGuideList value) {
+ this.avLst = value;
+ }
+
+ public boolean isSetAvLst() {
+ return (this.avLst!= null);
+ }
+
+ /**
+ * Gets the value of the prst property.
+ *
+ * @return
+ * possible object is
+ * {@link STShapeType }
+ *
+ */
+ public STShapeType getPrst() {
+ return prst;
+ }
+
+ /**
+ * Sets the value of the prst property.
+ *
+ * @param value
+ * allowed object is
+ * {@link STShapeType }
+ *
+ */
+ public void setPrst(STShapeType value) {
+ this.prst = value;
+ }
+
+ public boolean isSetPrst() {
+ return (this.prst!= null);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTPresetTextShape.java b/src/java/org/apache/poi/sl/draw/binding/CTPresetTextShape.java new file mode 100644 index 0000000000..f7082b353b --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTPresetTextShape.java @@ -0,0 +1,114 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_PresetTextShape complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_PresetTextShape">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="avLst" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_GeomGuideList" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="prst" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_TextShapeType" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_PresetTextShape", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "avLst"
+})
+public class CTPresetTextShape {
+
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected CTGeomGuideList avLst;
+ @XmlAttribute(name = "prst", required = true)
+ protected STTextShapeType prst;
+
+ /**
+ * Gets the value of the avLst property.
+ *
+ * @return
+ * possible object is
+ * {@link CTGeomGuideList }
+ *
+ */
+ public CTGeomGuideList getAvLst() {
+ return avLst;
+ }
+
+ /**
+ * Sets the value of the avLst property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTGeomGuideList }
+ *
+ */
+ public void setAvLst(CTGeomGuideList value) {
+ this.avLst = value;
+ }
+
+ public boolean isSetAvLst() {
+ return (this.avLst!= null);
+ }
+
+ /**
+ * Gets the value of the prst property.
+ *
+ * @return
+ * possible object is
+ * {@link STTextShapeType }
+ *
+ */
+ public STTextShapeType getPrst() {
+ return prst;
+ }
+
+ /**
+ * Sets the value of the prst property.
+ *
+ * @param value
+ * allowed object is
+ * {@link STTextShapeType }
+ *
+ */
+ public void setPrst(STTextShapeType value) {
+ this.prst = value;
+ }
+
+ public boolean isSetPrst() {
+ return (this.prst!= null);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTRatio.java b/src/java/org/apache/poi/sl/draw/binding/CTRatio.java new file mode 100644 index 0000000000..3a951c1f1f --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTRatio.java @@ -0,0 +1,93 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_Ratio complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Ratio">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="n" use="required" type="{http://www.w3.org/2001/XMLSchema}long" />
+ * <attribute name="d" use="required" type="{http://www.w3.org/2001/XMLSchema}long" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_Ratio", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTRatio {
+
+ @XmlAttribute(name = "n", required = true)
+ protected long n;
+ @XmlAttribute(name = "d", required = true)
+ protected long d;
+
+ /**
+ * Gets the value of the n property.
+ *
+ */
+ public long getN() {
+ return n;
+ }
+
+ /**
+ * Sets the value of the n property.
+ *
+ */
+ public void setN(long value) {
+ this.n = value;
+ }
+
+ public boolean isSetN() {
+ return true;
+ }
+
+ /**
+ * Gets the value of the d property.
+ *
+ */
+ public long getD() {
+ return d;
+ }
+
+ /**
+ * Sets the value of the d property.
+ *
+ */
+ public void setD(long value) {
+ this.d = value;
+ }
+
+ public boolean isSetD() {
+ return true;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTRelativeRect.java b/src/java/org/apache/poi/sl/draw/binding/CTRelativeRect.java new file mode 100644 index 0000000000..e332bd83c9 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTRelativeRect.java @@ -0,0 +1,203 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_RelativeRect complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_RelativeRect">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="l" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Percentage" default="0" />
+ * <attribute name="t" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Percentage" default="0" />
+ * <attribute name="r" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Percentage" default="0" />
+ * <attribute name="b" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Percentage" default="0" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_RelativeRect", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTRelativeRect {
+
+ @XmlAttribute(name = "l")
+ protected Integer l;
+ @XmlAttribute(name = "t")
+ protected Integer t;
+ @XmlAttribute(name = "r")
+ protected Integer r;
+ @XmlAttribute(name = "b")
+ protected Integer b;
+
+ /**
+ * Gets the value of the l property.
+ *
+ * @return
+ * possible object is
+ * {@link Integer }
+ *
+ */
+ public int getL() {
+ if (l == null) {
+ return 0;
+ } else {
+ return l;
+ }
+ }
+
+ /**
+ * Sets the value of the l property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Integer }
+ *
+ */
+ public void setL(int value) {
+ this.l = value;
+ }
+
+ public boolean isSetL() {
+ return (this.l!= null);
+ }
+
+ public void unsetL() {
+ this.l = null;
+ }
+
+ /**
+ * Gets the value of the t property.
+ *
+ * @return
+ * possible object is
+ * {@link Integer }
+ *
+ */
+ public int getT() {
+ if (t == null) {
+ return 0;
+ } else {
+ return t;
+ }
+ }
+
+ /**
+ * Sets the value of the t property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Integer }
+ *
+ */
+ public void setT(int value) {
+ this.t = value;
+ }
+
+ public boolean isSetT() {
+ return (this.t!= null);
+ }
+
+ public void unsetT() {
+ this.t = null;
+ }
+
+ /**
+ * Gets the value of the r property.
+ *
+ * @return
+ * possible object is
+ * {@link Integer }
+ *
+ */
+ public int getR() {
+ if (r == null) {
+ return 0;
+ } else {
+ return r;
+ }
+ }
+
+ /**
+ * Sets the value of the r property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Integer }
+ *
+ */
+ public void setR(int value) {
+ this.r = value;
+ }
+
+ public boolean isSetR() {
+ return (this.r!= null);
+ }
+
+ public void unsetR() {
+ this.r = null;
+ }
+
+ /**
+ * Gets the value of the b property.
+ *
+ * @return
+ * possible object is
+ * {@link Integer }
+ *
+ */
+ public int getB() {
+ if (b == null) {
+ return 0;
+ } else {
+ return b;
+ }
+ }
+
+ /**
+ * Sets the value of the b property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Integer }
+ *
+ */
+ public void setB(int value) {
+ this.b = value;
+ }
+
+ public boolean isSetB() {
+ return (this.b!= null);
+ }
+
+ public void unsetB() {
+ this.b = null;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTSRgbColor.java b/src/java/org/apache/poi/sl/draw/binding/CTSRgbColor.java new file mode 100644 index 0000000000..ef920d601a --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTSRgbColor.java @@ -0,0 +1,186 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlElementRefs;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+/**
+ * <p>Java class for CT_SRgbColor complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_SRgbColor">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <group ref="{http://schemas.openxmlformats.org/drawingml/2006/main}EG_ColorTransform" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="val" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_HexBinary3" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_SRgbColor", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "egColorTransform"
+})
+public class CTSRgbColor {
+
+ @XmlElementRefs({
+ @XmlElementRef(name = "comp", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "lumOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "gray", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "blueMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "greenMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "satMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "redMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "alphaMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "hue", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "inv", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "tint", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "lumMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "invGamma", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "shade", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "alphaOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "satOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "gamma", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "blueOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "lum", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "alpha", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "hueMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "red", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "greenOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "sat", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "green", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "redOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "hueOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "blue", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false)
+ })
+ protected List<JAXBElement<?>> egColorTransform;
+ @XmlAttribute(name = "val", required = true)
+ @XmlJavaTypeAdapter(HexBinaryAdapter.class)
+ protected byte[] val;
+
+ /**
+ * Gets the value of the egColorTransform property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the egColorTransform property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getEGColorTransform().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link JAXBElement }{@code <}{@link CTComplementTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTGrayscaleTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedAngle }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTInverseTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTInverseGammaTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTFixedPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTGammaTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTAngle }{@code >}
+ *
+ *
+ */
+ public List<JAXBElement<?>> getEGColorTransform() {
+ if (egColorTransform == null) {
+ egColorTransform = new ArrayList<JAXBElement<?>>();
+ }
+ return this.egColorTransform;
+ }
+
+ public boolean isSetEGColorTransform() {
+ return ((this.egColorTransform!= null)&&(!this.egColorTransform.isEmpty()));
+ }
+
+ public void unsetEGColorTransform() {
+ this.egColorTransform = null;
+ }
+
+ /**
+ * Gets the value of the val property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public byte[] getVal() {
+ return val;
+ }
+
+ /**
+ * Sets the value of the val property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setVal(byte[] value) {
+ this.val = value;
+ }
+
+ public boolean isSetVal() {
+ return (this.val!= null);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTScRgbColor.java b/src/java/org/apache/poi/sl/draw/binding/CTScRgbColor.java new file mode 100644 index 0000000000..335e4b2912 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTScRgbColor.java @@ -0,0 +1,221 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlElementRefs;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_ScRgbColor complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_ScRgbColor">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <group ref="{http://schemas.openxmlformats.org/drawingml/2006/main}EG_ColorTransform" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="r" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Percentage" />
+ * <attribute name="g" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Percentage" />
+ * <attribute name="b" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Percentage" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_ScRgbColor", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "egColorTransform"
+})
+public class CTScRgbColor {
+
+ @XmlElementRefs({
+ @XmlElementRef(name = "redMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "gray", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "satMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "green", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "blue", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "hueOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "sat", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "tint", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "gamma", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "inv", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "comp", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "satOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "hueMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "red", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "greenOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "hue", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "lumMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "alphaMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "lumOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "blueOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "blueMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "lum", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "redOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "greenMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "shade", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "invGamma", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "alphaOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "alpha", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false)
+ })
+ protected List<JAXBElement<?>> egColorTransform;
+ @XmlAttribute(name = "r", required = true)
+ protected int r;
+ @XmlAttribute(name = "g", required = true)
+ protected int g;
+ @XmlAttribute(name = "b", required = true)
+ protected int b;
+
+ /**
+ * Gets the value of the egColorTransform property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the egColorTransform property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getEGColorTransform().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTGrayscaleTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTAngle }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTGammaTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTInverseTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTComplementTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedAngle }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTInverseGammaTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTFixedPercentage }{@code >}
+ *
+ *
+ */
+ public List<JAXBElement<?>> getEGColorTransform() {
+ if (egColorTransform == null) {
+ egColorTransform = new ArrayList<JAXBElement<?>>();
+ }
+ return this.egColorTransform;
+ }
+
+ public boolean isSetEGColorTransform() {
+ return ((this.egColorTransform!= null)&&(!this.egColorTransform.isEmpty()));
+ }
+
+ public void unsetEGColorTransform() {
+ this.egColorTransform = null;
+ }
+
+ /**
+ * Gets the value of the r property.
+ *
+ */
+ public int getR() {
+ return r;
+ }
+
+ /**
+ * Sets the value of the r property.
+ *
+ */
+ public void setR(int value) {
+ this.r = value;
+ }
+
+ public boolean isSetR() {
+ return true;
+ }
+
+ /**
+ * Gets the value of the g property.
+ *
+ */
+ public int getG() {
+ return g;
+ }
+
+ /**
+ * Sets the value of the g property.
+ *
+ */
+ public void setG(int value) {
+ this.g = value;
+ }
+
+ public boolean isSetG() {
+ return true;
+ }
+
+ /**
+ * Gets the value of the b property.
+ *
+ */
+ public int getB() {
+ return b;
+ }
+
+ /**
+ * Sets the value of the b property.
+ *
+ */
+ public void setB(int value) {
+ this.b = value;
+ }
+
+ public boolean isSetB() {
+ return true;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTScale2D.java b/src/java/org/apache/poi/sl/draw/binding/CTScale2D.java new file mode 100644 index 0000000000..2e8eba1940 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTScale2D.java @@ -0,0 +1,114 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_Scale2D complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Scale2D">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="sx" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Ratio"/>
+ * <element name="sy" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Ratio"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_Scale2D", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "sx",
+ "sy"
+})
+public class CTScale2D {
+
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", required = true)
+ protected CTRatio sx;
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", required = true)
+ protected CTRatio sy;
+
+ /**
+ * Gets the value of the sx property.
+ *
+ * @return
+ * possible object is
+ * {@link CTRatio }
+ *
+ */
+ public CTRatio getSx() {
+ return sx;
+ }
+
+ /**
+ * Sets the value of the sx property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTRatio }
+ *
+ */
+ public void setSx(CTRatio value) {
+ this.sx = value;
+ }
+
+ public boolean isSetSx() {
+ return (this.sx!= null);
+ }
+
+ /**
+ * Gets the value of the sy property.
+ *
+ * @return
+ * possible object is
+ * {@link CTRatio }
+ *
+ */
+ public CTRatio getSy() {
+ return sy;
+ }
+
+ /**
+ * Sets the value of the sy property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTRatio }
+ *
+ */
+ public void setSy(CTRatio value) {
+ this.sy = value;
+ }
+
+ public boolean isSetSy() {
+ return (this.sy!= null);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTSchemeColor.java b/src/java/org/apache/poi/sl/draw/binding/CTSchemeColor.java new file mode 100644 index 0000000000..7febaad838 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTSchemeColor.java @@ -0,0 +1,183 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlElementRefs;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_SchemeColor complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_SchemeColor">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <group ref="{http://schemas.openxmlformats.org/drawingml/2006/main}EG_ColorTransform" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="val" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_SchemeColorVal" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_SchemeColor", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "egColorTransform"
+})
+public class CTSchemeColor {
+
+ @XmlElementRefs({
+ @XmlElementRef(name = "lumMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "inv", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "satMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "blue", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "blueOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "shade", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "gray", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "satOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "sat", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "alphaOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "blueMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "red", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "hueMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "tint", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "green", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "greenOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "redMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "hueOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "alpha", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "alphaMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "lum", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "lumOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "redOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "gamma", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "greenMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "comp", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "hue", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "invGamma", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false)
+ })
+ protected List<JAXBElement<?>> egColorTransform;
+ @XmlAttribute(name = "val", required = true)
+ protected STSchemeColorVal val;
+
+ /**
+ * Gets the value of the egColorTransform property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the egColorTransform property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getEGColorTransform().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTInverseTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTGrayscaleTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTFixedPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTAngle }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTGammaTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTComplementTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedAngle }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTInverseGammaTransform }{@code >}
+ *
+ *
+ */
+ public List<JAXBElement<?>> getEGColorTransform() {
+ if (egColorTransform == null) {
+ egColorTransform = new ArrayList<JAXBElement<?>>();
+ }
+ return this.egColorTransform;
+ }
+
+ public boolean isSetEGColorTransform() {
+ return ((this.egColorTransform!= null)&&(!this.egColorTransform.isEmpty()));
+ }
+
+ public void unsetEGColorTransform() {
+ this.egColorTransform = null;
+ }
+
+ /**
+ * Gets the value of the val property.
+ *
+ * @return
+ * possible object is
+ * {@link STSchemeColorVal }
+ *
+ */
+ public STSchemeColorVal getVal() {
+ return val;
+ }
+
+ /**
+ * Sets the value of the val property.
+ *
+ * @param value
+ * allowed object is
+ * {@link STSchemeColorVal }
+ *
+ */
+ public void setVal(STSchemeColorVal value) {
+ this.val = value;
+ }
+
+ public boolean isSetVal() {
+ return (this.val!= null);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTSphereCoords.java b/src/java/org/apache/poi/sl/draw/binding/CTSphereCoords.java new file mode 100644 index 0000000000..a29d744465 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTSphereCoords.java @@ -0,0 +1,116 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_SphereCoords complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_SphereCoords">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="lat" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_PositiveFixedAngle" />
+ * <attribute name="lon" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_PositiveFixedAngle" />
+ * <attribute name="rev" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_PositiveFixedAngle" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_SphereCoords", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTSphereCoords {
+
+ @XmlAttribute(name = "lat", required = true)
+ protected int lat;
+ @XmlAttribute(name = "lon", required = true)
+ protected int lon;
+ @XmlAttribute(name = "rev", required = true)
+ protected int rev;
+
+ /**
+ * Gets the value of the lat property.
+ *
+ */
+ public int getLat() {
+ return lat;
+ }
+
+ /**
+ * Sets the value of the lat property.
+ *
+ */
+ public void setLat(int value) {
+ this.lat = value;
+ }
+
+ public boolean isSetLat() {
+ return true;
+ }
+
+ /**
+ * Gets the value of the lon property.
+ *
+ */
+ public int getLon() {
+ return lon;
+ }
+
+ /**
+ * Sets the value of the lon property.
+ *
+ */
+ public void setLon(int value) {
+ this.lon = value;
+ }
+
+ public boolean isSetLon() {
+ return true;
+ }
+
+ /**
+ * Gets the value of the rev property.
+ *
+ */
+ public int getRev() {
+ return rev;
+ }
+
+ /**
+ * Sets the value of the rev property.
+ *
+ */
+ public void setRev(int value) {
+ this.rev = value;
+ }
+
+ public boolean isSetRev() {
+ return true;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTSystemColor.java b/src/java/org/apache/poi/sl/draw/binding/CTSystemColor.java new file mode 100644 index 0000000000..adf0d16b2e --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTSystemColor.java @@ -0,0 +1,219 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlElementRefs;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+/**
+ * <p>Java class for CT_SystemColor complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_SystemColor">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <group ref="{http://schemas.openxmlformats.org/drawingml/2006/main}EG_ColorTransform" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="val" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_SystemColorVal" />
+ * <attribute name="lastClr" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_HexBinary3" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_SystemColor", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "egColorTransform"
+})
+public class CTSystemColor {
+
+ @XmlElementRefs({
+ @XmlElementRef(name = "alphaMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "satMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "lumMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "lum", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "sat", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "red", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "invGamma", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "greenMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "blueOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "hue", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "comp", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "lumOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "blueMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "greenOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "alphaOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "green", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "inv", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "alpha", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "shade", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "redOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "blue", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "hueMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "redMod", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "hueOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "gray", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "gamma", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "tint", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "satOff", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", type = JAXBElement.class, required = false)
+ })
+ protected List<JAXBElement<?>> egColorTransform;
+ @XmlAttribute(name = "val", required = true)
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ protected String val;
+ @XmlAttribute(name = "lastClr")
+ @XmlJavaTypeAdapter(HexBinaryAdapter.class)
+ protected byte[] lastClr;
+
+ /**
+ * Gets the value of the egColorTransform property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the egColorTransform property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getEGColorTransform().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTInverseGammaTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedAngle }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTComplementTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTFixedPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTInverseTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTAngle }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTGrayscaleTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTGammaTransform }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}
+ * {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}
+ *
+ *
+ */
+ public List<JAXBElement<?>> getEGColorTransform() {
+ if (egColorTransform == null) {
+ egColorTransform = new ArrayList<JAXBElement<?>>();
+ }
+ return this.egColorTransform;
+ }
+
+ public boolean isSetEGColorTransform() {
+ return ((this.egColorTransform!= null)&&(!this.egColorTransform.isEmpty()));
+ }
+
+ public void unsetEGColorTransform() {
+ this.egColorTransform = null;
+ }
+
+ /**
+ * Gets the value of the val property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getVal() {
+ return val;
+ }
+
+ /**
+ * Sets the value of the val property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setVal(String value) {
+ this.val = value;
+ }
+
+ public boolean isSetVal() {
+ return (this.val!= null);
+ }
+
+ /**
+ * Gets the value of the lastClr property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public byte[] getLastClr() {
+ return lastClr;
+ }
+
+ /**
+ * Sets the value of the lastClr property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setLastClr(byte[] value) {
+ this.lastClr = value;
+ }
+
+ public boolean isSetLastClr() {
+ return (this.lastClr!= null);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTTransform2D.java b/src/java/org/apache/poi/sl/draw/binding/CTTransform2D.java new file mode 100644 index 0000000000..38ec50e654 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTTransform2D.java @@ -0,0 +1,232 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_Transform2D complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Transform2D">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="off" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_Point2D" minOccurs="0"/>
+ * <element name="ext" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_PositiveSize2D" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="rot" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Angle" default="0" />
+ * <attribute name="flipH" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
+ * <attribute name="flipV" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_Transform2D", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "off",
+ "ext"
+})
+public class CTTransform2D {
+
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected CTPoint2D off;
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+ protected CTPositiveSize2D ext;
+ @XmlAttribute(name = "rot")
+ protected Integer rot;
+ @XmlAttribute(name = "flipH")
+ protected Boolean flipH;
+ @XmlAttribute(name = "flipV")
+ protected Boolean flipV;
+
+ /**
+ * Gets the value of the off property.
+ *
+ * @return
+ * possible object is
+ * {@link CTPoint2D }
+ *
+ */
+ public CTPoint2D getOff() {
+ return off;
+ }
+
+ /**
+ * Sets the value of the off property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTPoint2D }
+ *
+ */
+ public void setOff(CTPoint2D value) {
+ this.off = value;
+ }
+
+ public boolean isSetOff() {
+ return (this.off!= null);
+ }
+
+ /**
+ * Gets the value of the ext property.
+ *
+ * @return
+ * possible object is
+ * {@link CTPositiveSize2D }
+ *
+ */
+ public CTPositiveSize2D getExt() {
+ return ext;
+ }
+
+ /**
+ * Sets the value of the ext property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTPositiveSize2D }
+ *
+ */
+ public void setExt(CTPositiveSize2D value) {
+ this.ext = value;
+ }
+
+ public boolean isSetExt() {
+ return (this.ext!= null);
+ }
+
+ /**
+ * Gets the value of the rot property.
+ *
+ * @return
+ * possible object is
+ * {@link Integer }
+ *
+ */
+ public int getRot() {
+ if (rot == null) {
+ return 0;
+ } else {
+ return rot;
+ }
+ }
+
+ /**
+ * Sets the value of the rot property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Integer }
+ *
+ */
+ public void setRot(int value) {
+ this.rot = value;
+ }
+
+ public boolean isSetRot() {
+ return (this.rot!= null);
+ }
+
+ public void unsetRot() {
+ this.rot = null;
+ }
+
+ /**
+ * Gets the value of the flipH property.
+ *
+ * @return
+ * possible object is
+ * {@link Boolean }
+ *
+ */
+ public boolean isFlipH() {
+ if (flipH == null) {
+ return false;
+ } else {
+ return flipH;
+ }
+ }
+
+ /**
+ * Sets the value of the flipH property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Boolean }
+ *
+ */
+ public void setFlipH(boolean value) {
+ this.flipH = value;
+ }
+
+ public boolean isSetFlipH() {
+ return (this.flipH!= null);
+ }
+
+ public void unsetFlipH() {
+ this.flipH = null;
+ }
+
+ /**
+ * Gets the value of the flipV property.
+ *
+ * @return
+ * possible object is
+ * {@link Boolean }
+ *
+ */
+ public boolean isFlipV() {
+ if (flipV == null) {
+ return false;
+ } else {
+ return flipV;
+ }
+ }
+
+ /**
+ * Sets the value of the flipV property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Boolean }
+ *
+ */
+ public void setFlipV(boolean value) {
+ this.flipV = value;
+ }
+
+ public boolean isSetFlipV() {
+ return (this.flipV!= null);
+ }
+
+ public void unsetFlipV() {
+ this.flipV = null;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTVector3D.java b/src/java/org/apache/poi/sl/draw/binding/CTVector3D.java new file mode 100644 index 0000000000..03c5fb8e44 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTVector3D.java @@ -0,0 +1,116 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CT_Vector3D complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_Vector3D">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="dx" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Coordinate" />
+ * <attribute name="dy" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Coordinate" />
+ * <attribute name="dz" use="required" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_Coordinate" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_Vector3D", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+public class CTVector3D {
+
+ @XmlAttribute(name = "dx", required = true)
+ protected long dx;
+ @XmlAttribute(name = "dy", required = true)
+ protected long dy;
+ @XmlAttribute(name = "dz", required = true)
+ protected long dz;
+
+ /**
+ * Gets the value of the dx property.
+ *
+ */
+ public long getDx() {
+ return dx;
+ }
+
+ /**
+ * Sets the value of the dx property.
+ *
+ */
+ public void setDx(long value) {
+ this.dx = value;
+ }
+
+ public boolean isSetDx() {
+ return true;
+ }
+
+ /**
+ * Gets the value of the dy property.
+ *
+ */
+ public long getDy() {
+ return dy;
+ }
+
+ /**
+ * Sets the value of the dy property.
+ *
+ */
+ public void setDy(long value) {
+ this.dy = value;
+ }
+
+ public boolean isSetDy() {
+ return true;
+ }
+
+ /**
+ * Gets the value of the dz property.
+ *
+ */
+ public long getDz() {
+ return dz;
+ }
+
+ /**
+ * Sets the value of the dz property.
+ *
+ */
+ public void setDz(long value) {
+ this.dz = value;
+ }
+
+ public boolean isSetDz() {
+ return true;
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/CTXYAdjustHandle.java b/src/java/org/apache/poi/sl/draw/binding/CTXYAdjustHandle.java new file mode 100644 index 0000000000..85c30bac54 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/CTXYAdjustHandle.java @@ -0,0 +1,273 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+/**
+ * <p>Java class for CT_XYAdjustHandle complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CT_XYAdjustHandle">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="pos" type="{http://schemas.openxmlformats.org/drawingml/2006/main}CT_AdjPoint2D"/>
+ * </sequence>
+ * <attribute name="gdRefX" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_GeomGuideName" />
+ * <attribute name="minX" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
+ * <attribute name="maxX" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
+ * <attribute name="gdRefY" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_GeomGuideName" />
+ * <attribute name="minY" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
+ * <attribute name="maxY" type="{http://schemas.openxmlformats.org/drawingml/2006/main}ST_AdjCoordinate" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CT_XYAdjustHandle", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", propOrder = {
+ "pos"
+})
+public class CTXYAdjustHandle {
+
+ @XmlElement(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", required = true)
+ protected CTAdjPoint2D pos;
+ @XmlAttribute(name = "gdRefX")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ protected String gdRefX;
+ @XmlAttribute(name = "minX")
+ protected String minX;
+ @XmlAttribute(name = "maxX")
+ protected String maxX;
+ @XmlAttribute(name = "gdRefY")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ protected String gdRefY;
+ @XmlAttribute(name = "minY")
+ protected String minY;
+ @XmlAttribute(name = "maxY")
+ protected String maxY;
+
+ /**
+ * Gets the value of the pos property.
+ *
+ * @return
+ * possible object is
+ * {@link CTAdjPoint2D }
+ *
+ */
+ public CTAdjPoint2D getPos() {
+ return pos;
+ }
+
+ /**
+ * Sets the value of the pos property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CTAdjPoint2D }
+ *
+ */
+ public void setPos(CTAdjPoint2D value) {
+ this.pos = value;
+ }
+
+ public boolean isSetPos() {
+ return (this.pos!= null);
+ }
+
+ /**
+ * Gets the value of the gdRefX property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getGdRefX() {
+ return gdRefX;
+ }
+
+ /**
+ * Sets the value of the gdRefX property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setGdRefX(String value) {
+ this.gdRefX = value;
+ }
+
+ public boolean isSetGdRefX() {
+ return (this.gdRefX!= null);
+ }
+
+ /**
+ * Gets the value of the minX property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMinX() {
+ return minX;
+ }
+
+ /**
+ * Sets the value of the minX property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMinX(String value) {
+ this.minX = value;
+ }
+
+ public boolean isSetMinX() {
+ return (this.minX!= null);
+ }
+
+ /**
+ * Gets the value of the maxX property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMaxX() {
+ return maxX;
+ }
+
+ /**
+ * Sets the value of the maxX property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMaxX(String value) {
+ this.maxX = value;
+ }
+
+ public boolean isSetMaxX() {
+ return (this.maxX!= null);
+ }
+
+ /**
+ * Gets the value of the gdRefY property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getGdRefY() {
+ return gdRefY;
+ }
+
+ /**
+ * Sets the value of the gdRefY property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setGdRefY(String value) {
+ this.gdRefY = value;
+ }
+
+ public boolean isSetGdRefY() {
+ return (this.gdRefY!= null);
+ }
+
+ /**
+ * Gets the value of the minY property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMinY() {
+ return minY;
+ }
+
+ /**
+ * Sets the value of the minY property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMinY(String value) {
+ this.minY = value;
+ }
+
+ public boolean isSetMinY() {
+ return (this.minY!= null);
+ }
+
+ /**
+ * Gets the value of the maxY property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMaxY() {
+ return maxY;
+ }
+
+ /**
+ * Sets the value of the maxY property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMaxY(String value) {
+ this.maxY = value;
+ }
+
+ public boolean isSetMaxY() {
+ return (this.maxY!= null);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/ObjectFactory.java b/src/java/org/apache/poi/sl/draw/binding/ObjectFactory.java new file mode 100644 index 0000000000..8c6f9c217c --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/ObjectFactory.java @@ -0,0 +1,2023 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.bind.annotation.XmlRegistry;
+import javax.xml.namespace.QName;
+
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the org.apache.poi.sl.draw.binding package.
+ * <p>An ObjectFactory allows you to programatically
+ * construct new instances of the Java representation
+ * for XML content. The Java representation of XML
+ * content can consist of schema derived interfaces
+ * and classes representing the binding of schema
+ * type definitions, element declarations and model
+ * groups. Factory methods for each of these are
+ * provided in this class.
+ *
+ */
+@XmlRegistry
+public class ObjectFactory {
+
+ private final static QName _CTSRgbColorAlpha_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "alpha");
+ private final static QName _CTSRgbColorLum_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "lum");
+ private final static QName _CTSRgbColorGamma_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "gamma");
+ private final static QName _CTSRgbColorInvGamma_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "invGamma");
+ private final static QName _CTSRgbColorAlphaMod_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "alphaMod");
+ private final static QName _CTSRgbColorRedOff_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "redOff");
+ private final static QName _CTSRgbColorAlphaOff_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "alphaOff");
+ private final static QName _CTSRgbColorGreenOff_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "greenOff");
+ private final static QName _CTSRgbColorHue_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "hue");
+ private final static QName _CTSRgbColorRedMod_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "redMod");
+ private final static QName _CTSRgbColorSatOff_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "satOff");
+ private final static QName _CTSRgbColorGreenMod_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "greenMod");
+ private final static QName _CTSRgbColorSat_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "sat");
+ private final static QName _CTSRgbColorBlue_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "blue");
+ private final static QName _CTSRgbColorRed_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "red");
+ private final static QName _CTSRgbColorSatMod_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "satMod");
+ private final static QName _CTSRgbColorBlueMod_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "blueMod");
+ private final static QName _CTSRgbColorHueOff_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "hueOff");
+ private final static QName _CTSRgbColorShade_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "shade");
+ private final static QName _CTSRgbColorLumMod_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "lumMod");
+ private final static QName _CTSRgbColorInv_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "inv");
+ private final static QName _CTSRgbColorLumOff_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "lumOff");
+ private final static QName _CTSRgbColorTint_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "tint");
+ private final static QName _CTSRgbColorGreen_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "green");
+ private final static QName _CTSRgbColorComp_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "comp");
+ private final static QName _CTSRgbColorBlueOff_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "blueOff");
+ private final static QName _CTSRgbColorHueMod_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "hueMod");
+ private final static QName _CTSRgbColorGray_QNAME = new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "gray");
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.apache.poi.sl.draw.binding
+ *
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link CTPath2DQuadBezierTo }
+ *
+ */
+ public CTPath2DQuadBezierTo createCTPath2DQuadBezierTo() {
+ return new CTPath2DQuadBezierTo();
+ }
+
+ /**
+ * Create an instance of {@link CTCustomGeometry2D }
+ *
+ */
+ public CTCustomGeometry2D createCTCustomGeometry2D() {
+ return new CTCustomGeometry2D();
+ }
+
+ /**
+ * Create an instance of {@link CTPolarAdjustHandle }
+ *
+ */
+ public CTPolarAdjustHandle createCTPolarAdjustHandle() {
+ return new CTPolarAdjustHandle();
+ }
+
+ /**
+ * Create an instance of {@link CTPath2DClose }
+ *
+ */
+ public CTPath2DClose createCTPath2DClose() {
+ return new CTPath2DClose();
+ }
+
+ /**
+ * Create an instance of {@link CTPoint2D }
+ *
+ */
+ public CTPoint2D createCTPoint2D() {
+ return new CTPoint2D();
+ }
+
+ /**
+ * Create an instance of {@link CTInverseTransform }
+ *
+ */
+ public CTInverseTransform createCTInverseTransform() {
+ return new CTInverseTransform();
+ }
+
+ /**
+ * Create an instance of {@link CTPercentage }
+ *
+ */
+ public CTPercentage createCTPercentage() {
+ return new CTPercentage();
+ }
+
+ /**
+ * Create an instance of {@link CTSystemColor }
+ *
+ */
+ public CTSystemColor createCTSystemColor() {
+ return new CTSystemColor();
+ }
+
+ /**
+ * Create an instance of {@link CTConnectionSite }
+ *
+ */
+ public CTConnectionSite createCTConnectionSite() {
+ return new CTConnectionSite();
+ }
+
+ /**
+ * Create an instance of {@link CTColor }
+ *
+ */
+ public CTColor createCTColor() {
+ return new CTColor();
+ }
+
+ /**
+ * Create an instance of {@link CTPositiveFixedAngle }
+ *
+ */
+ public CTPositiveFixedAngle createCTPositiveFixedAngle() {
+ return new CTPositiveFixedAngle();
+ }
+
+ /**
+ * Create an instance of {@link CTFixedPercentage }
+ *
+ */
+ public CTFixedPercentage createCTFixedPercentage() {
+ return new CTFixedPercentage();
+ }
+
+ /**
+ * Create an instance of {@link CTHslColor }
+ *
+ */
+ public CTHslColor createCTHslColor() {
+ return new CTHslColor();
+ }
+
+ /**
+ * Create an instance of {@link CTConnection }
+ *
+ */
+ public CTConnection createCTConnection() {
+ return new CTConnection();
+ }
+
+ /**
+ * Create an instance of {@link CTPath2DLineTo }
+ *
+ */
+ public CTPath2DLineTo createCTPath2DLineTo() {
+ return new CTPath2DLineTo();
+ }
+
+ /**
+ * Create an instance of {@link CTTransform2D }
+ *
+ */
+ public CTTransform2D createCTTransform2D() {
+ return new CTTransform2D();
+ }
+
+ /**
+ * Create an instance of {@link CTPositivePercentage }
+ *
+ */
+ public CTPositivePercentage createCTPositivePercentage() {
+ return new CTPositivePercentage();
+ }
+
+ /**
+ * Create an instance of {@link CTVector3D }
+ *
+ */
+ public CTVector3D createCTVector3D() {
+ return new CTVector3D();
+ }
+
+ /**
+ * Create an instance of {@link CTSphereCoords }
+ *
+ */
+ public CTSphereCoords createCTSphereCoords() {
+ return new CTSphereCoords();
+ }
+
+ /**
+ * Create an instance of {@link CTPath2D }
+ *
+ */
+ public CTPath2D createCTPath2D() {
+ return new CTPath2D();
+ }
+
+ /**
+ * Create an instance of {@link CTGroupTransform2D }
+ *
+ */
+ public CTGroupTransform2D createCTGroupTransform2D() {
+ return new CTGroupTransform2D();
+ }
+
+ /**
+ * Create an instance of {@link CTGrayscaleTransform }
+ *
+ */
+ public CTGrayscaleTransform createCTGrayscaleTransform() {
+ return new CTGrayscaleTransform();
+ }
+
+ /**
+ * Create an instance of {@link CTRatio }
+ *
+ */
+ public CTRatio createCTRatio() {
+ return new CTRatio();
+ }
+
+ /**
+ * Create an instance of {@link CTSRgbColor }
+ *
+ */
+ public CTSRgbColor createCTSRgbColor() {
+ return new CTSRgbColor();
+ }
+
+ /**
+ * Create an instance of {@link CTGeomGuideList }
+ *
+ */
+ public CTGeomGuideList createCTGeomGuideList() {
+ return new CTGeomGuideList();
+ }
+
+ /**
+ * Create an instance of {@link CTComplementTransform }
+ *
+ */
+ public CTComplementTransform createCTComplementTransform() {
+ return new CTComplementTransform();
+ }
+
+ /**
+ * Create an instance of {@link CTPath2DCubicBezierTo }
+ *
+ */
+ public CTPath2DCubicBezierTo createCTPath2DCubicBezierTo() {
+ return new CTPath2DCubicBezierTo();
+ }
+
+ /**
+ * Create an instance of {@link CTXYAdjustHandle }
+ *
+ */
+ public CTXYAdjustHandle createCTXYAdjustHandle() {
+ return new CTXYAdjustHandle();
+ }
+
+ /**
+ * Create an instance of {@link CTPresetColor }
+ *
+ */
+ public CTPresetColor createCTPresetColor() {
+ return new CTPresetColor();
+ }
+
+ /**
+ * Create an instance of {@link CTOfficeArtExtension }
+ *
+ */
+ public CTOfficeArtExtension createCTOfficeArtExtension() {
+ return new CTOfficeArtExtension();
+ }
+
+ /**
+ * Create an instance of {@link CTSchemeColor }
+ *
+ */
+ public CTSchemeColor createCTSchemeColor() {
+ return new CTSchemeColor();
+ }
+
+ /**
+ * Create an instance of {@link CTConnectionSiteList }
+ *
+ */
+ public CTConnectionSiteList createCTConnectionSiteList() {
+ return new CTConnectionSiteList();
+ }
+
+ /**
+ * Create an instance of {@link CTPath2DArcTo }
+ *
+ */
+ public CTPath2DArcTo createCTPath2DArcTo() {
+ return new CTPath2DArcTo();
+ }
+
+ /**
+ * Create an instance of {@link CTPath2DList }
+ *
+ */
+ public CTPath2DList createCTPath2DList() {
+ return new CTPath2DList();
+ }
+
+ /**
+ * Create an instance of {@link CTAngle }
+ *
+ */
+ public CTAngle createCTAngle() {
+ return new CTAngle();
+ }
+
+ /**
+ * Create an instance of {@link CTScale2D }
+ *
+ */
+ public CTScale2D createCTScale2D() {
+ return new CTScale2D();
+ }
+
+ /**
+ * Create an instance of {@link CTPositiveSize2D }
+ *
+ */
+ public CTPositiveSize2D createCTPositiveSize2D() {
+ return new CTPositiveSize2D();
+ }
+
+ /**
+ * Create an instance of {@link CTOfficeArtExtensionList }
+ *
+ */
+ public CTOfficeArtExtensionList createCTOfficeArtExtensionList() {
+ return new CTOfficeArtExtensionList();
+ }
+
+ /**
+ * Create an instance of {@link CTHyperlink }
+ *
+ */
+ public CTHyperlink createCTHyperlink() {
+ return new CTHyperlink();
+ }
+
+ /**
+ * Create an instance of {@link CTPoint3D }
+ *
+ */
+ public CTPoint3D createCTPoint3D() {
+ return new CTPoint3D();
+ }
+
+ /**
+ * Create an instance of {@link CTInverseGammaTransform }
+ *
+ */
+ public CTInverseGammaTransform createCTInverseGammaTransform() {
+ return new CTInverseGammaTransform();
+ }
+
+ /**
+ * Create an instance of {@link CTPositiveFixedPercentage }
+ *
+ */
+ public CTPositiveFixedPercentage createCTPositiveFixedPercentage() {
+ return new CTPositiveFixedPercentage();
+ }
+
+ /**
+ * Create an instance of {@link CTGeomRect }
+ *
+ */
+ public CTGeomRect createCTGeomRect() {
+ return new CTGeomRect();
+ }
+
+ /**
+ * Create an instance of {@link CTPresetTextShape }
+ *
+ */
+ public CTPresetTextShape createCTPresetTextShape() {
+ return new CTPresetTextShape();
+ }
+
+ /**
+ * Create an instance of {@link CTColorMRU }
+ *
+ */
+ public CTColorMRU createCTColorMRU() {
+ return new CTColorMRU();
+ }
+
+ /**
+ * Create an instance of {@link CTPath2DMoveTo }
+ *
+ */
+ public CTPath2DMoveTo createCTPath2DMoveTo() {
+ return new CTPath2DMoveTo();
+ }
+
+ /**
+ * Create an instance of {@link CTEmbeddedWAVAudioFile }
+ *
+ */
+ public CTEmbeddedWAVAudioFile createCTEmbeddedWAVAudioFile() {
+ return new CTEmbeddedWAVAudioFile();
+ }
+
+ /**
+ * Create an instance of {@link CTScRgbColor }
+ *
+ */
+ public CTScRgbColor createCTScRgbColor() {
+ return new CTScRgbColor();
+ }
+
+ /**
+ * Create an instance of {@link CTPresetGeometry2D }
+ *
+ */
+ public CTPresetGeometry2D createCTPresetGeometry2D() {
+ return new CTPresetGeometry2D();
+ }
+
+ /**
+ * Create an instance of {@link CTGeomGuide }
+ *
+ */
+ public CTGeomGuide createCTGeomGuide() {
+ return new CTGeomGuide();
+ }
+
+ /**
+ * Create an instance of {@link CTRelativeRect }
+ *
+ */
+ public CTRelativeRect createCTRelativeRect() {
+ return new CTRelativeRect();
+ }
+
+ /**
+ * Create an instance of {@link CTAdjustHandleList }
+ *
+ */
+ public CTAdjustHandleList createCTAdjustHandleList() {
+ return new CTAdjustHandleList();
+ }
+
+ /**
+ * Create an instance of {@link CTAdjPoint2D }
+ *
+ */
+ public CTAdjPoint2D createCTAdjPoint2D() {
+ return new CTAdjPoint2D();
+ }
+
+ /**
+ * Create an instance of {@link CTGammaTransform }
+ *
+ */
+ public CTGammaTransform createCTGammaTransform() {
+ return new CTGammaTransform();
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "alpha", scope = CTSRgbColor.class)
+ public JAXBElement<CTPositiveFixedPercentage> createCTSRgbColorAlpha(CTPositiveFixedPercentage value) {
+ return new JAXBElement<CTPositiveFixedPercentage>(_CTSRgbColorAlpha_QNAME, CTPositiveFixedPercentage.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "lum", scope = CTSRgbColor.class)
+ public JAXBElement<CTPercentage> createCTSRgbColorLum(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorLum_QNAME, CTPercentage.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTGammaTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "gamma", scope = CTSRgbColor.class)
+ public JAXBElement<CTGammaTransform> createCTSRgbColorGamma(CTGammaTransform value) {
+ return new JAXBElement<CTGammaTransform>(_CTSRgbColorGamma_QNAME, CTGammaTransform.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTInverseGammaTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "invGamma", scope = CTSRgbColor.class)
+ public JAXBElement<CTInverseGammaTransform> createCTSRgbColorInvGamma(CTInverseGammaTransform value) {
+ return new JAXBElement<CTInverseGammaTransform>(_CTSRgbColorInvGamma_QNAME, CTInverseGammaTransform.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "alphaMod", scope = CTSRgbColor.class)
+ public JAXBElement<CTPositivePercentage> createCTSRgbColorAlphaMod(CTPositivePercentage value) {
+ return new JAXBElement<CTPositivePercentage>(_CTSRgbColorAlphaMod_QNAME, CTPositivePercentage.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "redOff", scope = CTSRgbColor.class)
+ public JAXBElement<CTPercentage> createCTSRgbColorRedOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorRedOff_QNAME, CTPercentage.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "alphaOff", scope = CTSRgbColor.class)
+ public JAXBElement<CTFixedPercentage> createCTSRgbColorAlphaOff(CTFixedPercentage value) {
+ return new JAXBElement<CTFixedPercentage>(_CTSRgbColorAlphaOff_QNAME, CTFixedPercentage.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "greenOff", scope = CTSRgbColor.class)
+ public JAXBElement<CTPercentage> createCTSRgbColorGreenOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorGreenOff_QNAME, CTPercentage.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedAngle }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "hue", scope = CTSRgbColor.class)
+ public JAXBElement<CTPositiveFixedAngle> createCTSRgbColorHue(CTPositiveFixedAngle value) {
+ return new JAXBElement<CTPositiveFixedAngle>(_CTSRgbColorHue_QNAME, CTPositiveFixedAngle.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "redMod", scope = CTSRgbColor.class)
+ public JAXBElement<CTPercentage> createCTSRgbColorRedMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorRedMod_QNAME, CTPercentage.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "satOff", scope = CTSRgbColor.class)
+ public JAXBElement<CTPercentage> createCTSRgbColorSatOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorSatOff_QNAME, CTPercentage.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "greenMod", scope = CTSRgbColor.class)
+ public JAXBElement<CTPercentage> createCTSRgbColorGreenMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorGreenMod_QNAME, CTPercentage.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "sat", scope = CTSRgbColor.class)
+ public JAXBElement<CTPercentage> createCTSRgbColorSat(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorSat_QNAME, CTPercentage.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "blue", scope = CTSRgbColor.class)
+ public JAXBElement<CTPercentage> createCTSRgbColorBlue(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorBlue_QNAME, CTPercentage.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "red", scope = CTSRgbColor.class)
+ public JAXBElement<CTPercentage> createCTSRgbColorRed(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorRed_QNAME, CTPercentage.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "satMod", scope = CTSRgbColor.class)
+ public JAXBElement<CTPercentage> createCTSRgbColorSatMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorSatMod_QNAME, CTPercentage.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "blueMod", scope = CTSRgbColor.class)
+ public JAXBElement<CTPercentage> createCTSRgbColorBlueMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorBlueMod_QNAME, CTPercentage.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTAngle }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "hueOff", scope = CTSRgbColor.class)
+ public JAXBElement<CTAngle> createCTSRgbColorHueOff(CTAngle value) {
+ return new JAXBElement<CTAngle>(_CTSRgbColorHueOff_QNAME, CTAngle.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "shade", scope = CTSRgbColor.class)
+ public JAXBElement<CTPositiveFixedPercentage> createCTSRgbColorShade(CTPositiveFixedPercentage value) {
+ return new JAXBElement<CTPositiveFixedPercentage>(_CTSRgbColorShade_QNAME, CTPositiveFixedPercentage.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "lumMod", scope = CTSRgbColor.class)
+ public JAXBElement<CTPercentage> createCTSRgbColorLumMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorLumMod_QNAME, CTPercentage.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTInverseTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "inv", scope = CTSRgbColor.class)
+ public JAXBElement<CTInverseTransform> createCTSRgbColorInv(CTInverseTransform value) {
+ return new JAXBElement<CTInverseTransform>(_CTSRgbColorInv_QNAME, CTInverseTransform.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "lumOff", scope = CTSRgbColor.class)
+ public JAXBElement<CTPercentage> createCTSRgbColorLumOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorLumOff_QNAME, CTPercentage.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "tint", scope = CTSRgbColor.class)
+ public JAXBElement<CTPositiveFixedPercentage> createCTSRgbColorTint(CTPositiveFixedPercentage value) {
+ return new JAXBElement<CTPositiveFixedPercentage>(_CTSRgbColorTint_QNAME, CTPositiveFixedPercentage.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "green", scope = CTSRgbColor.class)
+ public JAXBElement<CTPercentage> createCTSRgbColorGreen(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorGreen_QNAME, CTPercentage.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTComplementTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "comp", scope = CTSRgbColor.class)
+ public JAXBElement<CTComplementTransform> createCTSRgbColorComp(CTComplementTransform value) {
+ return new JAXBElement<CTComplementTransform>(_CTSRgbColorComp_QNAME, CTComplementTransform.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "blueOff", scope = CTSRgbColor.class)
+ public JAXBElement<CTPercentage> createCTSRgbColorBlueOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorBlueOff_QNAME, CTPercentage.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "hueMod", scope = CTSRgbColor.class)
+ public JAXBElement<CTPositivePercentage> createCTSRgbColorHueMod(CTPositivePercentage value) {
+ return new JAXBElement<CTPositivePercentage>(_CTSRgbColorHueMod_QNAME, CTPositivePercentage.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTGrayscaleTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "gray", scope = CTSRgbColor.class)
+ public JAXBElement<CTGrayscaleTransform> createCTSRgbColorGray(CTGrayscaleTransform value) {
+ return new JAXBElement<CTGrayscaleTransform>(_CTSRgbColorGray_QNAME, CTGrayscaleTransform.class, CTSRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "alpha", scope = CTSchemeColor.class)
+ public JAXBElement<CTPositiveFixedPercentage> createCTSchemeColorAlpha(CTPositiveFixedPercentage value) {
+ return new JAXBElement<CTPositiveFixedPercentage>(_CTSRgbColorAlpha_QNAME, CTPositiveFixedPercentage.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "lum", scope = CTSchemeColor.class)
+ public JAXBElement<CTPercentage> createCTSchemeColorLum(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorLum_QNAME, CTPercentage.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTGammaTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "gamma", scope = CTSchemeColor.class)
+ public JAXBElement<CTGammaTransform> createCTSchemeColorGamma(CTGammaTransform value) {
+ return new JAXBElement<CTGammaTransform>(_CTSRgbColorGamma_QNAME, CTGammaTransform.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTInverseGammaTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "invGamma", scope = CTSchemeColor.class)
+ public JAXBElement<CTInverseGammaTransform> createCTSchemeColorInvGamma(CTInverseGammaTransform value) {
+ return new JAXBElement<CTInverseGammaTransform>(_CTSRgbColorInvGamma_QNAME, CTInverseGammaTransform.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "alphaMod", scope = CTSchemeColor.class)
+ public JAXBElement<CTPositivePercentage> createCTSchemeColorAlphaMod(CTPositivePercentage value) {
+ return new JAXBElement<CTPositivePercentage>(_CTSRgbColorAlphaMod_QNAME, CTPositivePercentage.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "redOff", scope = CTSchemeColor.class)
+ public JAXBElement<CTPercentage> createCTSchemeColorRedOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorRedOff_QNAME, CTPercentage.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "alphaOff", scope = CTSchemeColor.class)
+ public JAXBElement<CTFixedPercentage> createCTSchemeColorAlphaOff(CTFixedPercentage value) {
+ return new JAXBElement<CTFixedPercentage>(_CTSRgbColorAlphaOff_QNAME, CTFixedPercentage.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "greenOff", scope = CTSchemeColor.class)
+ public JAXBElement<CTPercentage> createCTSchemeColorGreenOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorGreenOff_QNAME, CTPercentage.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedAngle }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "hue", scope = CTSchemeColor.class)
+ public JAXBElement<CTPositiveFixedAngle> createCTSchemeColorHue(CTPositiveFixedAngle value) {
+ return new JAXBElement<CTPositiveFixedAngle>(_CTSRgbColorHue_QNAME, CTPositiveFixedAngle.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "redMod", scope = CTSchemeColor.class)
+ public JAXBElement<CTPercentage> createCTSchemeColorRedMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorRedMod_QNAME, CTPercentage.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "satOff", scope = CTSchemeColor.class)
+ public JAXBElement<CTPercentage> createCTSchemeColorSatOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorSatOff_QNAME, CTPercentage.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "greenMod", scope = CTSchemeColor.class)
+ public JAXBElement<CTPercentage> createCTSchemeColorGreenMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorGreenMod_QNAME, CTPercentage.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "sat", scope = CTSchemeColor.class)
+ public JAXBElement<CTPercentage> createCTSchemeColorSat(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorSat_QNAME, CTPercentage.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "blue", scope = CTSchemeColor.class)
+ public JAXBElement<CTPercentage> createCTSchemeColorBlue(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorBlue_QNAME, CTPercentage.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "red", scope = CTSchemeColor.class)
+ public JAXBElement<CTPercentage> createCTSchemeColorRed(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorRed_QNAME, CTPercentage.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "satMod", scope = CTSchemeColor.class)
+ public JAXBElement<CTPercentage> createCTSchemeColorSatMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorSatMod_QNAME, CTPercentage.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "blueMod", scope = CTSchemeColor.class)
+ public JAXBElement<CTPercentage> createCTSchemeColorBlueMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorBlueMod_QNAME, CTPercentage.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTAngle }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "hueOff", scope = CTSchemeColor.class)
+ public JAXBElement<CTAngle> createCTSchemeColorHueOff(CTAngle value) {
+ return new JAXBElement<CTAngle>(_CTSRgbColorHueOff_QNAME, CTAngle.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "shade", scope = CTSchemeColor.class)
+ public JAXBElement<CTPositiveFixedPercentage> createCTSchemeColorShade(CTPositiveFixedPercentage value) {
+ return new JAXBElement<CTPositiveFixedPercentage>(_CTSRgbColorShade_QNAME, CTPositiveFixedPercentage.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "lumMod", scope = CTSchemeColor.class)
+ public JAXBElement<CTPercentage> createCTSchemeColorLumMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorLumMod_QNAME, CTPercentage.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTInverseTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "inv", scope = CTSchemeColor.class)
+ public JAXBElement<CTInverseTransform> createCTSchemeColorInv(CTInverseTransform value) {
+ return new JAXBElement<CTInverseTransform>(_CTSRgbColorInv_QNAME, CTInverseTransform.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "lumOff", scope = CTSchemeColor.class)
+ public JAXBElement<CTPercentage> createCTSchemeColorLumOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorLumOff_QNAME, CTPercentage.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "tint", scope = CTSchemeColor.class)
+ public JAXBElement<CTPositiveFixedPercentage> createCTSchemeColorTint(CTPositiveFixedPercentage value) {
+ return new JAXBElement<CTPositiveFixedPercentage>(_CTSRgbColorTint_QNAME, CTPositiveFixedPercentage.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "green", scope = CTSchemeColor.class)
+ public JAXBElement<CTPercentage> createCTSchemeColorGreen(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorGreen_QNAME, CTPercentage.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTComplementTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "comp", scope = CTSchemeColor.class)
+ public JAXBElement<CTComplementTransform> createCTSchemeColorComp(CTComplementTransform value) {
+ return new JAXBElement<CTComplementTransform>(_CTSRgbColorComp_QNAME, CTComplementTransform.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "blueOff", scope = CTSchemeColor.class)
+ public JAXBElement<CTPercentage> createCTSchemeColorBlueOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorBlueOff_QNAME, CTPercentage.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "hueMod", scope = CTSchemeColor.class)
+ public JAXBElement<CTPositivePercentage> createCTSchemeColorHueMod(CTPositivePercentage value) {
+ return new JAXBElement<CTPositivePercentage>(_CTSRgbColorHueMod_QNAME, CTPositivePercentage.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTGrayscaleTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "gray", scope = CTSchemeColor.class)
+ public JAXBElement<CTGrayscaleTransform> createCTSchemeColorGray(CTGrayscaleTransform value) {
+ return new JAXBElement<CTGrayscaleTransform>(_CTSRgbColorGray_QNAME, CTGrayscaleTransform.class, CTSchemeColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "alpha", scope = CTScRgbColor.class)
+ public JAXBElement<CTPositiveFixedPercentage> createCTScRgbColorAlpha(CTPositiveFixedPercentage value) {
+ return new JAXBElement<CTPositiveFixedPercentage>(_CTSRgbColorAlpha_QNAME, CTPositiveFixedPercentage.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "lum", scope = CTScRgbColor.class)
+ public JAXBElement<CTPercentage> createCTScRgbColorLum(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorLum_QNAME, CTPercentage.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTGammaTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "gamma", scope = CTScRgbColor.class)
+ public JAXBElement<CTGammaTransform> createCTScRgbColorGamma(CTGammaTransform value) {
+ return new JAXBElement<CTGammaTransform>(_CTSRgbColorGamma_QNAME, CTGammaTransform.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTInverseGammaTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "invGamma", scope = CTScRgbColor.class)
+ public JAXBElement<CTInverseGammaTransform> createCTScRgbColorInvGamma(CTInverseGammaTransform value) {
+ return new JAXBElement<CTInverseGammaTransform>(_CTSRgbColorInvGamma_QNAME, CTInverseGammaTransform.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "alphaMod", scope = CTScRgbColor.class)
+ public JAXBElement<CTPositivePercentage> createCTScRgbColorAlphaMod(CTPositivePercentage value) {
+ return new JAXBElement<CTPositivePercentage>(_CTSRgbColorAlphaMod_QNAME, CTPositivePercentage.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "redOff", scope = CTScRgbColor.class)
+ public JAXBElement<CTPercentage> createCTScRgbColorRedOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorRedOff_QNAME, CTPercentage.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "alphaOff", scope = CTScRgbColor.class)
+ public JAXBElement<CTFixedPercentage> createCTScRgbColorAlphaOff(CTFixedPercentage value) {
+ return new JAXBElement<CTFixedPercentage>(_CTSRgbColorAlphaOff_QNAME, CTFixedPercentage.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "greenOff", scope = CTScRgbColor.class)
+ public JAXBElement<CTPercentage> createCTScRgbColorGreenOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorGreenOff_QNAME, CTPercentage.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedAngle }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "hue", scope = CTScRgbColor.class)
+ public JAXBElement<CTPositiveFixedAngle> createCTScRgbColorHue(CTPositiveFixedAngle value) {
+ return new JAXBElement<CTPositiveFixedAngle>(_CTSRgbColorHue_QNAME, CTPositiveFixedAngle.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "redMod", scope = CTScRgbColor.class)
+ public JAXBElement<CTPercentage> createCTScRgbColorRedMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorRedMod_QNAME, CTPercentage.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "satOff", scope = CTScRgbColor.class)
+ public JAXBElement<CTPercentage> createCTScRgbColorSatOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorSatOff_QNAME, CTPercentage.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "greenMod", scope = CTScRgbColor.class)
+ public JAXBElement<CTPercentage> createCTScRgbColorGreenMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorGreenMod_QNAME, CTPercentage.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "sat", scope = CTScRgbColor.class)
+ public JAXBElement<CTPercentage> createCTScRgbColorSat(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorSat_QNAME, CTPercentage.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "blue", scope = CTScRgbColor.class)
+ public JAXBElement<CTPercentage> createCTScRgbColorBlue(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorBlue_QNAME, CTPercentage.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "red", scope = CTScRgbColor.class)
+ public JAXBElement<CTPercentage> createCTScRgbColorRed(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorRed_QNAME, CTPercentage.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "satMod", scope = CTScRgbColor.class)
+ public JAXBElement<CTPercentage> createCTScRgbColorSatMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorSatMod_QNAME, CTPercentage.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "blueMod", scope = CTScRgbColor.class)
+ public JAXBElement<CTPercentage> createCTScRgbColorBlueMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorBlueMod_QNAME, CTPercentage.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTAngle }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "hueOff", scope = CTScRgbColor.class)
+ public JAXBElement<CTAngle> createCTScRgbColorHueOff(CTAngle value) {
+ return new JAXBElement<CTAngle>(_CTSRgbColorHueOff_QNAME, CTAngle.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "shade", scope = CTScRgbColor.class)
+ public JAXBElement<CTPositiveFixedPercentage> createCTScRgbColorShade(CTPositiveFixedPercentage value) {
+ return new JAXBElement<CTPositiveFixedPercentage>(_CTSRgbColorShade_QNAME, CTPositiveFixedPercentage.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "lumMod", scope = CTScRgbColor.class)
+ public JAXBElement<CTPercentage> createCTScRgbColorLumMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorLumMod_QNAME, CTPercentage.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTInverseTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "inv", scope = CTScRgbColor.class)
+ public JAXBElement<CTInverseTransform> createCTScRgbColorInv(CTInverseTransform value) {
+ return new JAXBElement<CTInverseTransform>(_CTSRgbColorInv_QNAME, CTInverseTransform.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "lumOff", scope = CTScRgbColor.class)
+ public JAXBElement<CTPercentage> createCTScRgbColorLumOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorLumOff_QNAME, CTPercentage.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "tint", scope = CTScRgbColor.class)
+ public JAXBElement<CTPositiveFixedPercentage> createCTScRgbColorTint(CTPositiveFixedPercentage value) {
+ return new JAXBElement<CTPositiveFixedPercentage>(_CTSRgbColorTint_QNAME, CTPositiveFixedPercentage.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "green", scope = CTScRgbColor.class)
+ public JAXBElement<CTPercentage> createCTScRgbColorGreen(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorGreen_QNAME, CTPercentage.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTComplementTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "comp", scope = CTScRgbColor.class)
+ public JAXBElement<CTComplementTransform> createCTScRgbColorComp(CTComplementTransform value) {
+ return new JAXBElement<CTComplementTransform>(_CTSRgbColorComp_QNAME, CTComplementTransform.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "blueOff", scope = CTScRgbColor.class)
+ public JAXBElement<CTPercentage> createCTScRgbColorBlueOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorBlueOff_QNAME, CTPercentage.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "hueMod", scope = CTScRgbColor.class)
+ public JAXBElement<CTPositivePercentage> createCTScRgbColorHueMod(CTPositivePercentage value) {
+ return new JAXBElement<CTPositivePercentage>(_CTSRgbColorHueMod_QNAME, CTPositivePercentage.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTGrayscaleTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "gray", scope = CTScRgbColor.class)
+ public JAXBElement<CTGrayscaleTransform> createCTScRgbColorGray(CTGrayscaleTransform value) {
+ return new JAXBElement<CTGrayscaleTransform>(_CTSRgbColorGray_QNAME, CTGrayscaleTransform.class, CTScRgbColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "alpha", scope = CTSystemColor.class)
+ public JAXBElement<CTPositiveFixedPercentage> createCTSystemColorAlpha(CTPositiveFixedPercentage value) {
+ return new JAXBElement<CTPositiveFixedPercentage>(_CTSRgbColorAlpha_QNAME, CTPositiveFixedPercentage.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "lum", scope = CTSystemColor.class)
+ public JAXBElement<CTPercentage> createCTSystemColorLum(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorLum_QNAME, CTPercentage.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTGammaTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "gamma", scope = CTSystemColor.class)
+ public JAXBElement<CTGammaTransform> createCTSystemColorGamma(CTGammaTransform value) {
+ return new JAXBElement<CTGammaTransform>(_CTSRgbColorGamma_QNAME, CTGammaTransform.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTInverseGammaTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "invGamma", scope = CTSystemColor.class)
+ public JAXBElement<CTInverseGammaTransform> createCTSystemColorInvGamma(CTInverseGammaTransform value) {
+ return new JAXBElement<CTInverseGammaTransform>(_CTSRgbColorInvGamma_QNAME, CTInverseGammaTransform.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "alphaMod", scope = CTSystemColor.class)
+ public JAXBElement<CTPositivePercentage> createCTSystemColorAlphaMod(CTPositivePercentage value) {
+ return new JAXBElement<CTPositivePercentage>(_CTSRgbColorAlphaMod_QNAME, CTPositivePercentage.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "redOff", scope = CTSystemColor.class)
+ public JAXBElement<CTPercentage> createCTSystemColorRedOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorRedOff_QNAME, CTPercentage.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "alphaOff", scope = CTSystemColor.class)
+ public JAXBElement<CTFixedPercentage> createCTSystemColorAlphaOff(CTFixedPercentage value) {
+ return new JAXBElement<CTFixedPercentage>(_CTSRgbColorAlphaOff_QNAME, CTFixedPercentage.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "greenOff", scope = CTSystemColor.class)
+ public JAXBElement<CTPercentage> createCTSystemColorGreenOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorGreenOff_QNAME, CTPercentage.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedAngle }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "hue", scope = CTSystemColor.class)
+ public JAXBElement<CTPositiveFixedAngle> createCTSystemColorHue(CTPositiveFixedAngle value) {
+ return new JAXBElement<CTPositiveFixedAngle>(_CTSRgbColorHue_QNAME, CTPositiveFixedAngle.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "redMod", scope = CTSystemColor.class)
+ public JAXBElement<CTPercentage> createCTSystemColorRedMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorRedMod_QNAME, CTPercentage.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "satOff", scope = CTSystemColor.class)
+ public JAXBElement<CTPercentage> createCTSystemColorSatOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorSatOff_QNAME, CTPercentage.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "greenMod", scope = CTSystemColor.class)
+ public JAXBElement<CTPercentage> createCTSystemColorGreenMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorGreenMod_QNAME, CTPercentage.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "sat", scope = CTSystemColor.class)
+ public JAXBElement<CTPercentage> createCTSystemColorSat(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorSat_QNAME, CTPercentage.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "blue", scope = CTSystemColor.class)
+ public JAXBElement<CTPercentage> createCTSystemColorBlue(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorBlue_QNAME, CTPercentage.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "red", scope = CTSystemColor.class)
+ public JAXBElement<CTPercentage> createCTSystemColorRed(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorRed_QNAME, CTPercentage.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "satMod", scope = CTSystemColor.class)
+ public JAXBElement<CTPercentage> createCTSystemColorSatMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorSatMod_QNAME, CTPercentage.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "blueMod", scope = CTSystemColor.class)
+ public JAXBElement<CTPercentage> createCTSystemColorBlueMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorBlueMod_QNAME, CTPercentage.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTAngle }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "hueOff", scope = CTSystemColor.class)
+ public JAXBElement<CTAngle> createCTSystemColorHueOff(CTAngle value) {
+ return new JAXBElement<CTAngle>(_CTSRgbColorHueOff_QNAME, CTAngle.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "shade", scope = CTSystemColor.class)
+ public JAXBElement<CTPositiveFixedPercentage> createCTSystemColorShade(CTPositiveFixedPercentage value) {
+ return new JAXBElement<CTPositiveFixedPercentage>(_CTSRgbColorShade_QNAME, CTPositiveFixedPercentage.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "lumMod", scope = CTSystemColor.class)
+ public JAXBElement<CTPercentage> createCTSystemColorLumMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorLumMod_QNAME, CTPercentage.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTInverseTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "inv", scope = CTSystemColor.class)
+ public JAXBElement<CTInverseTransform> createCTSystemColorInv(CTInverseTransform value) {
+ return new JAXBElement<CTInverseTransform>(_CTSRgbColorInv_QNAME, CTInverseTransform.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "lumOff", scope = CTSystemColor.class)
+ public JAXBElement<CTPercentage> createCTSystemColorLumOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorLumOff_QNAME, CTPercentage.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "tint", scope = CTSystemColor.class)
+ public JAXBElement<CTPositiveFixedPercentage> createCTSystemColorTint(CTPositiveFixedPercentage value) {
+ return new JAXBElement<CTPositiveFixedPercentage>(_CTSRgbColorTint_QNAME, CTPositiveFixedPercentage.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "green", scope = CTSystemColor.class)
+ public JAXBElement<CTPercentage> createCTSystemColorGreen(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorGreen_QNAME, CTPercentage.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTComplementTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "comp", scope = CTSystemColor.class)
+ public JAXBElement<CTComplementTransform> createCTSystemColorComp(CTComplementTransform value) {
+ return new JAXBElement<CTComplementTransform>(_CTSRgbColorComp_QNAME, CTComplementTransform.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "blueOff", scope = CTSystemColor.class)
+ public JAXBElement<CTPercentage> createCTSystemColorBlueOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorBlueOff_QNAME, CTPercentage.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "hueMod", scope = CTSystemColor.class)
+ public JAXBElement<CTPositivePercentage> createCTSystemColorHueMod(CTPositivePercentage value) {
+ return new JAXBElement<CTPositivePercentage>(_CTSRgbColorHueMod_QNAME, CTPositivePercentage.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTGrayscaleTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "gray", scope = CTSystemColor.class)
+ public JAXBElement<CTGrayscaleTransform> createCTSystemColorGray(CTGrayscaleTransform value) {
+ return new JAXBElement<CTGrayscaleTransform>(_CTSRgbColorGray_QNAME, CTGrayscaleTransform.class, CTSystemColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "alpha", scope = CTHslColor.class)
+ public JAXBElement<CTPositiveFixedPercentage> createCTHslColorAlpha(CTPositiveFixedPercentage value) {
+ return new JAXBElement<CTPositiveFixedPercentage>(_CTSRgbColorAlpha_QNAME, CTPositiveFixedPercentage.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "lum", scope = CTHslColor.class)
+ public JAXBElement<CTPercentage> createCTHslColorLum(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorLum_QNAME, CTPercentage.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTGammaTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "gamma", scope = CTHslColor.class)
+ public JAXBElement<CTGammaTransform> createCTHslColorGamma(CTGammaTransform value) {
+ return new JAXBElement<CTGammaTransform>(_CTSRgbColorGamma_QNAME, CTGammaTransform.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTInverseGammaTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "invGamma", scope = CTHslColor.class)
+ public JAXBElement<CTInverseGammaTransform> createCTHslColorInvGamma(CTInverseGammaTransform value) {
+ return new JAXBElement<CTInverseGammaTransform>(_CTSRgbColorInvGamma_QNAME, CTInverseGammaTransform.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "alphaMod", scope = CTHslColor.class)
+ public JAXBElement<CTPositivePercentage> createCTHslColorAlphaMod(CTPositivePercentage value) {
+ return new JAXBElement<CTPositivePercentage>(_CTSRgbColorAlphaMod_QNAME, CTPositivePercentage.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "redOff", scope = CTHslColor.class)
+ public JAXBElement<CTPercentage> createCTHslColorRedOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorRedOff_QNAME, CTPercentage.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "alphaOff", scope = CTHslColor.class)
+ public JAXBElement<CTFixedPercentage> createCTHslColorAlphaOff(CTFixedPercentage value) {
+ return new JAXBElement<CTFixedPercentage>(_CTSRgbColorAlphaOff_QNAME, CTFixedPercentage.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "greenOff", scope = CTHslColor.class)
+ public JAXBElement<CTPercentage> createCTHslColorGreenOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorGreenOff_QNAME, CTPercentage.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedAngle }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "hue", scope = CTHslColor.class)
+ public JAXBElement<CTPositiveFixedAngle> createCTHslColorHue(CTPositiveFixedAngle value) {
+ return new JAXBElement<CTPositiveFixedAngle>(_CTSRgbColorHue_QNAME, CTPositiveFixedAngle.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "redMod", scope = CTHslColor.class)
+ public JAXBElement<CTPercentage> createCTHslColorRedMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorRedMod_QNAME, CTPercentage.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "satOff", scope = CTHslColor.class)
+ public JAXBElement<CTPercentage> createCTHslColorSatOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorSatOff_QNAME, CTPercentage.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "greenMod", scope = CTHslColor.class)
+ public JAXBElement<CTPercentage> createCTHslColorGreenMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorGreenMod_QNAME, CTPercentage.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "sat", scope = CTHslColor.class)
+ public JAXBElement<CTPercentage> createCTHslColorSat(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorSat_QNAME, CTPercentage.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "blue", scope = CTHslColor.class)
+ public JAXBElement<CTPercentage> createCTHslColorBlue(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorBlue_QNAME, CTPercentage.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "red", scope = CTHslColor.class)
+ public JAXBElement<CTPercentage> createCTHslColorRed(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorRed_QNAME, CTPercentage.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "satMod", scope = CTHslColor.class)
+ public JAXBElement<CTPercentage> createCTHslColorSatMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorSatMod_QNAME, CTPercentage.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "blueMod", scope = CTHslColor.class)
+ public JAXBElement<CTPercentage> createCTHslColorBlueMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorBlueMod_QNAME, CTPercentage.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTAngle }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "hueOff", scope = CTHslColor.class)
+ public JAXBElement<CTAngle> createCTHslColorHueOff(CTAngle value) {
+ return new JAXBElement<CTAngle>(_CTSRgbColorHueOff_QNAME, CTAngle.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "shade", scope = CTHslColor.class)
+ public JAXBElement<CTPositiveFixedPercentage> createCTHslColorShade(CTPositiveFixedPercentage value) {
+ return new JAXBElement<CTPositiveFixedPercentage>(_CTSRgbColorShade_QNAME, CTPositiveFixedPercentage.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "lumMod", scope = CTHslColor.class)
+ public JAXBElement<CTPercentage> createCTHslColorLumMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorLumMod_QNAME, CTPercentage.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTInverseTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "inv", scope = CTHslColor.class)
+ public JAXBElement<CTInverseTransform> createCTHslColorInv(CTInverseTransform value) {
+ return new JAXBElement<CTInverseTransform>(_CTSRgbColorInv_QNAME, CTInverseTransform.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "lumOff", scope = CTHslColor.class)
+ public JAXBElement<CTPercentage> createCTHslColorLumOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorLumOff_QNAME, CTPercentage.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "tint", scope = CTHslColor.class)
+ public JAXBElement<CTPositiveFixedPercentage> createCTHslColorTint(CTPositiveFixedPercentage value) {
+ return new JAXBElement<CTPositiveFixedPercentage>(_CTSRgbColorTint_QNAME, CTPositiveFixedPercentage.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "green", scope = CTHslColor.class)
+ public JAXBElement<CTPercentage> createCTHslColorGreen(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorGreen_QNAME, CTPercentage.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTComplementTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "comp", scope = CTHslColor.class)
+ public JAXBElement<CTComplementTransform> createCTHslColorComp(CTComplementTransform value) {
+ return new JAXBElement<CTComplementTransform>(_CTSRgbColorComp_QNAME, CTComplementTransform.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "blueOff", scope = CTHslColor.class)
+ public JAXBElement<CTPercentage> createCTHslColorBlueOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorBlueOff_QNAME, CTPercentage.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "hueMod", scope = CTHslColor.class)
+ public JAXBElement<CTPositivePercentage> createCTHslColorHueMod(CTPositivePercentage value) {
+ return new JAXBElement<CTPositivePercentage>(_CTSRgbColorHueMod_QNAME, CTPositivePercentage.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTGrayscaleTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "gray", scope = CTHslColor.class)
+ public JAXBElement<CTGrayscaleTransform> createCTHslColorGray(CTGrayscaleTransform value) {
+ return new JAXBElement<CTGrayscaleTransform>(_CTSRgbColorGray_QNAME, CTGrayscaleTransform.class, CTHslColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "alpha", scope = CTPresetColor.class)
+ public JAXBElement<CTPositiveFixedPercentage> createCTPresetColorAlpha(CTPositiveFixedPercentage value) {
+ return new JAXBElement<CTPositiveFixedPercentage>(_CTSRgbColorAlpha_QNAME, CTPositiveFixedPercentage.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "lum", scope = CTPresetColor.class)
+ public JAXBElement<CTPercentage> createCTPresetColorLum(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorLum_QNAME, CTPercentage.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTGammaTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "gamma", scope = CTPresetColor.class)
+ public JAXBElement<CTGammaTransform> createCTPresetColorGamma(CTGammaTransform value) {
+ return new JAXBElement<CTGammaTransform>(_CTSRgbColorGamma_QNAME, CTGammaTransform.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTInverseGammaTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "invGamma", scope = CTPresetColor.class)
+ public JAXBElement<CTInverseGammaTransform> createCTPresetColorInvGamma(CTInverseGammaTransform value) {
+ return new JAXBElement<CTInverseGammaTransform>(_CTSRgbColorInvGamma_QNAME, CTInverseGammaTransform.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "alphaMod", scope = CTPresetColor.class)
+ public JAXBElement<CTPositivePercentage> createCTPresetColorAlphaMod(CTPositivePercentage value) {
+ return new JAXBElement<CTPositivePercentage>(_CTSRgbColorAlphaMod_QNAME, CTPositivePercentage.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "redOff", scope = CTPresetColor.class)
+ public JAXBElement<CTPercentage> createCTPresetColorRedOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorRedOff_QNAME, CTPercentage.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "alphaOff", scope = CTPresetColor.class)
+ public JAXBElement<CTFixedPercentage> createCTPresetColorAlphaOff(CTFixedPercentage value) {
+ return new JAXBElement<CTFixedPercentage>(_CTSRgbColorAlphaOff_QNAME, CTFixedPercentage.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "greenOff", scope = CTPresetColor.class)
+ public JAXBElement<CTPercentage> createCTPresetColorGreenOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorGreenOff_QNAME, CTPercentage.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedAngle }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "hue", scope = CTPresetColor.class)
+ public JAXBElement<CTPositiveFixedAngle> createCTPresetColorHue(CTPositiveFixedAngle value) {
+ return new JAXBElement<CTPositiveFixedAngle>(_CTSRgbColorHue_QNAME, CTPositiveFixedAngle.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "redMod", scope = CTPresetColor.class)
+ public JAXBElement<CTPercentage> createCTPresetColorRedMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorRedMod_QNAME, CTPercentage.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "satOff", scope = CTPresetColor.class)
+ public JAXBElement<CTPercentage> createCTPresetColorSatOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorSatOff_QNAME, CTPercentage.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "greenMod", scope = CTPresetColor.class)
+ public JAXBElement<CTPercentage> createCTPresetColorGreenMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorGreenMod_QNAME, CTPercentage.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "sat", scope = CTPresetColor.class)
+ public JAXBElement<CTPercentage> createCTPresetColorSat(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorSat_QNAME, CTPercentage.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "blue", scope = CTPresetColor.class)
+ public JAXBElement<CTPercentage> createCTPresetColorBlue(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorBlue_QNAME, CTPercentage.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "red", scope = CTPresetColor.class)
+ public JAXBElement<CTPercentage> createCTPresetColorRed(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorRed_QNAME, CTPercentage.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "satMod", scope = CTPresetColor.class)
+ public JAXBElement<CTPercentage> createCTPresetColorSatMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorSatMod_QNAME, CTPercentage.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "blueMod", scope = CTPresetColor.class)
+ public JAXBElement<CTPercentage> createCTPresetColorBlueMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorBlueMod_QNAME, CTPercentage.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTAngle }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "hueOff", scope = CTPresetColor.class)
+ public JAXBElement<CTAngle> createCTPresetColorHueOff(CTAngle value) {
+ return new JAXBElement<CTAngle>(_CTSRgbColorHueOff_QNAME, CTAngle.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "shade", scope = CTPresetColor.class)
+ public JAXBElement<CTPositiveFixedPercentage> createCTPresetColorShade(CTPositiveFixedPercentage value) {
+ return new JAXBElement<CTPositiveFixedPercentage>(_CTSRgbColorShade_QNAME, CTPositiveFixedPercentage.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "lumMod", scope = CTPresetColor.class)
+ public JAXBElement<CTPercentage> createCTPresetColorLumMod(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorLumMod_QNAME, CTPercentage.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTInverseTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "inv", scope = CTPresetColor.class)
+ public JAXBElement<CTInverseTransform> createCTPresetColorInv(CTInverseTransform value) {
+ return new JAXBElement<CTInverseTransform>(_CTSRgbColorInv_QNAME, CTInverseTransform.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "lumOff", scope = CTPresetColor.class)
+ public JAXBElement<CTPercentage> createCTPresetColorLumOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorLumOff_QNAME, CTPercentage.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositiveFixedPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "tint", scope = CTPresetColor.class)
+ public JAXBElement<CTPositiveFixedPercentage> createCTPresetColorTint(CTPositiveFixedPercentage value) {
+ return new JAXBElement<CTPositiveFixedPercentage>(_CTSRgbColorTint_QNAME, CTPositiveFixedPercentage.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "green", scope = CTPresetColor.class)
+ public JAXBElement<CTPercentage> createCTPresetColorGreen(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorGreen_QNAME, CTPercentage.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTComplementTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "comp", scope = CTPresetColor.class)
+ public JAXBElement<CTComplementTransform> createCTPresetColorComp(CTComplementTransform value) {
+ return new JAXBElement<CTComplementTransform>(_CTSRgbColorComp_QNAME, CTComplementTransform.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "blueOff", scope = CTPresetColor.class)
+ public JAXBElement<CTPercentage> createCTPresetColorBlueOff(CTPercentage value) {
+ return new JAXBElement<CTPercentage>(_CTSRgbColorBlueOff_QNAME, CTPercentage.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTPositivePercentage }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "hueMod", scope = CTPresetColor.class)
+ public JAXBElement<CTPositivePercentage> createCTPresetColorHueMod(CTPositivePercentage value) {
+ return new JAXBElement<CTPositivePercentage>(_CTSRgbColorHueMod_QNAME, CTPositivePercentage.class, CTPresetColor.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CTGrayscaleTransform }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", name = "gray", scope = CTPresetColor.class)
+ public JAXBElement<CTGrayscaleTransform> createCTPresetColorGray(CTGrayscaleTransform value) {
+ return new JAXBElement<CTGrayscaleTransform>(_CTSRgbColorGray_QNAME, CTGrayscaleTransform.class, CTPresetColor.class, value);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/STBlackWhiteMode.java b/src/java/org/apache/poi/sl/draw/binding/STBlackWhiteMode.java new file mode 100644 index 0000000000..27262d6060 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/STBlackWhiteMode.java @@ -0,0 +1,149 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlEnumValue;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for ST_BlackWhiteMode.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * <p>
+ * <pre>
+ * <simpleType name="ST_BlackWhiteMode">
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}token">
+ * <enumeration value="clr"/>
+ * <enumeration value="auto"/>
+ * <enumeration value="gray"/>
+ * <enumeration value="ltGray"/>
+ * <enumeration value="invGray"/>
+ * <enumeration value="grayWhite"/>
+ * <enumeration value="blackGray"/>
+ * <enumeration value="blackWhite"/>
+ * <enumeration value="black"/>
+ * <enumeration value="white"/>
+ * <enumeration value="hidden"/>
+ * </restriction>
+ * </simpleType>
+ * </pre>
+ *
+ */
+@XmlType(name = "ST_BlackWhiteMode", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+@XmlEnum
+public enum STBlackWhiteMode {
+
+
+ /**
+ * Color
+ *
+ */
+ @XmlEnumValue("clr")
+ CLR("clr"),
+
+ /**
+ * Automatic
+ *
+ */
+ @XmlEnumValue("auto")
+ AUTO("auto"),
+
+ /**
+ * Gray
+ *
+ */
+ @XmlEnumValue("gray")
+ GRAY("gray"),
+
+ /**
+ * Light Gray
+ *
+ */
+ @XmlEnumValue("ltGray")
+ LT_GRAY("ltGray"),
+
+ /**
+ * Inverse Gray
+ *
+ */
+ @XmlEnumValue("invGray")
+ INV_GRAY("invGray"),
+
+ /**
+ * Gray and White
+ *
+ */
+ @XmlEnumValue("grayWhite")
+ GRAY_WHITE("grayWhite"),
+
+ /**
+ * Black and Gray
+ *
+ */
+ @XmlEnumValue("blackGray")
+ BLACK_GRAY("blackGray"),
+
+ /**
+ * Black and White
+ *
+ */
+ @XmlEnumValue("blackWhite")
+ BLACK_WHITE("blackWhite"),
+
+ /**
+ * Black
+ *
+ */
+ @XmlEnumValue("black")
+ BLACK("black"),
+
+ /**
+ * White
+ *
+ */
+ @XmlEnumValue("white")
+ WHITE("white"),
+
+ /**
+ * Hidden
+ *
+ */
+ @XmlEnumValue("hidden")
+ HIDDEN("hidden");
+ private final String value;
+
+ STBlackWhiteMode(String v) {
+ value = v;
+ }
+
+ public String value() {
+ return value;
+ }
+
+ public static STBlackWhiteMode fromValue(String v) {
+ for (STBlackWhiteMode c: STBlackWhiteMode.values()) {
+ if (c.value.equals(v)) {
+ return c;
+ }
+ }
+ throw new IllegalArgumentException(v);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/STPathFillMode.java b/src/java/org/apache/poi/sl/draw/binding/STPathFillMode.java new file mode 100644 index 0000000000..8a26458f02 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/STPathFillMode.java @@ -0,0 +1,109 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlEnumValue;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for ST_PathFillMode.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * <p>
+ * <pre>
+ * <simpleType name="ST_PathFillMode">
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}token">
+ * <enumeration value="none"/>
+ * <enumeration value="norm"/>
+ * <enumeration value="lighten"/>
+ * <enumeration value="lightenLess"/>
+ * <enumeration value="darken"/>
+ * <enumeration value="darkenLess"/>
+ * </restriction>
+ * </simpleType>
+ * </pre>
+ *
+ */
+@XmlType(name = "ST_PathFillMode", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+@XmlEnum
+public enum STPathFillMode {
+
+
+ /**
+ * No Path Fill
+ *
+ */
+ @XmlEnumValue("none")
+ NONE("none"),
+
+ /**
+ * Normal Path Fill
+ *
+ */
+ @XmlEnumValue("norm")
+ NORM("norm"),
+
+ /**
+ * Lighten Path Fill
+ *
+ */
+ @XmlEnumValue("lighten")
+ LIGHTEN("lighten"),
+
+ /**
+ * Lighten Path Fill Less
+ *
+ */
+ @XmlEnumValue("lightenLess")
+ LIGHTEN_LESS("lightenLess"),
+
+ /**
+ * Darken Path Fill
+ *
+ */
+ @XmlEnumValue("darken")
+ DARKEN("darken"),
+
+ /**
+ * Darken Path Fill Less
+ *
+ */
+ @XmlEnumValue("darkenLess")
+ DARKEN_LESS("darkenLess");
+ private final String value;
+
+ STPathFillMode(String v) {
+ value = v;
+ }
+
+ public String value() {
+ return value;
+ }
+
+ public static STPathFillMode fromValue(String v) {
+ for (STPathFillMode c: STPathFillMode.values()) {
+ if (c.value.equals(v)) {
+ return c;
+ }
+ }
+ throw new IllegalArgumentException(v);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/STPresetColorVal.java b/src/java/org/apache/poi/sl/draw/binding/STPresetColorVal.java new file mode 100644 index 0000000000..7450ac656c --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/STPresetColorVal.java @@ -0,0 +1,1181 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlEnumValue;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for ST_PresetColorVal.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * <p>
+ * <pre>
+ * <simpleType name="ST_PresetColorVal">
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}token">
+ * <enumeration value="aliceBlue"/>
+ * <enumeration value="antiqueWhite"/>
+ * <enumeration value="aqua"/>
+ * <enumeration value="aquamarine"/>
+ * <enumeration value="azure"/>
+ * <enumeration value="beige"/>
+ * <enumeration value="bisque"/>
+ * <enumeration value="black"/>
+ * <enumeration value="blanchedAlmond"/>
+ * <enumeration value="blue"/>
+ * <enumeration value="blueViolet"/>
+ * <enumeration value="brown"/>
+ * <enumeration value="burlyWood"/>
+ * <enumeration value="cadetBlue"/>
+ * <enumeration value="chartreuse"/>
+ * <enumeration value="chocolate"/>
+ * <enumeration value="coral"/>
+ * <enumeration value="cornflowerBlue"/>
+ * <enumeration value="cornsilk"/>
+ * <enumeration value="crimson"/>
+ * <enumeration value="cyan"/>
+ * <enumeration value="dkBlue"/>
+ * <enumeration value="dkCyan"/>
+ * <enumeration value="dkGoldenrod"/>
+ * <enumeration value="dkGray"/>
+ * <enumeration value="dkGreen"/>
+ * <enumeration value="dkKhaki"/>
+ * <enumeration value="dkMagenta"/>
+ * <enumeration value="dkOliveGreen"/>
+ * <enumeration value="dkOrange"/>
+ * <enumeration value="dkOrchid"/>
+ * <enumeration value="dkRed"/>
+ * <enumeration value="dkSalmon"/>
+ * <enumeration value="dkSeaGreen"/>
+ * <enumeration value="dkSlateBlue"/>
+ * <enumeration value="dkSlateGray"/>
+ * <enumeration value="dkTurquoise"/>
+ * <enumeration value="dkViolet"/>
+ * <enumeration value="deepPink"/>
+ * <enumeration value="deepSkyBlue"/>
+ * <enumeration value="dimGray"/>
+ * <enumeration value="dodgerBlue"/>
+ * <enumeration value="firebrick"/>
+ * <enumeration value="floralWhite"/>
+ * <enumeration value="forestGreen"/>
+ * <enumeration value="fuchsia"/>
+ * <enumeration value="gainsboro"/>
+ * <enumeration value="ghostWhite"/>
+ * <enumeration value="gold"/>
+ * <enumeration value="goldenrod"/>
+ * <enumeration value="gray"/>
+ * <enumeration value="green"/>
+ * <enumeration value="greenYellow"/>
+ * <enumeration value="honeydew"/>
+ * <enumeration value="hotPink"/>
+ * <enumeration value="indianRed"/>
+ * <enumeration value="indigo"/>
+ * <enumeration value="ivory"/>
+ * <enumeration value="khaki"/>
+ * <enumeration value="lavender"/>
+ * <enumeration value="lavenderBlush"/>
+ * <enumeration value="lawnGreen"/>
+ * <enumeration value="lemonChiffon"/>
+ * <enumeration value="ltBlue"/>
+ * <enumeration value="ltCoral"/>
+ * <enumeration value="ltCyan"/>
+ * <enumeration value="ltGoldenrodYellow"/>
+ * <enumeration value="ltGray"/>
+ * <enumeration value="ltGreen"/>
+ * <enumeration value="ltPink"/>
+ * <enumeration value="ltSalmon"/>
+ * <enumeration value="ltSeaGreen"/>
+ * <enumeration value="ltSkyBlue"/>
+ * <enumeration value="ltSlateGray"/>
+ * <enumeration value="ltSteelBlue"/>
+ * <enumeration value="ltYellow"/>
+ * <enumeration value="lime"/>
+ * <enumeration value="limeGreen"/>
+ * <enumeration value="linen"/>
+ * <enumeration value="magenta"/>
+ * <enumeration value="maroon"/>
+ * <enumeration value="medAquamarine"/>
+ * <enumeration value="medBlue"/>
+ * <enumeration value="medOrchid"/>
+ * <enumeration value="medPurple"/>
+ * <enumeration value="medSeaGreen"/>
+ * <enumeration value="medSlateBlue"/>
+ * <enumeration value="medSpringGreen"/>
+ * <enumeration value="medTurquoise"/>
+ * <enumeration value="medVioletRed"/>
+ * <enumeration value="midnightBlue"/>
+ * <enumeration value="mintCream"/>
+ * <enumeration value="mistyRose"/>
+ * <enumeration value="moccasin"/>
+ * <enumeration value="navajoWhite"/>
+ * <enumeration value="navy"/>
+ * <enumeration value="oldLace"/>
+ * <enumeration value="olive"/>
+ * <enumeration value="oliveDrab"/>
+ * <enumeration value="orange"/>
+ * <enumeration value="orangeRed"/>
+ * <enumeration value="orchid"/>
+ * <enumeration value="paleGoldenrod"/>
+ * <enumeration value="paleGreen"/>
+ * <enumeration value="paleTurquoise"/>
+ * <enumeration value="paleVioletRed"/>
+ * <enumeration value="papayaWhip"/>
+ * <enumeration value="peachPuff"/>
+ * <enumeration value="peru"/>
+ * <enumeration value="pink"/>
+ * <enumeration value="plum"/>
+ * <enumeration value="powderBlue"/>
+ * <enumeration value="purple"/>
+ * <enumeration value="red"/>
+ * <enumeration value="rosyBrown"/>
+ * <enumeration value="royalBlue"/>
+ * <enumeration value="saddleBrown"/>
+ * <enumeration value="salmon"/>
+ * <enumeration value="sandyBrown"/>
+ * <enumeration value="seaGreen"/>
+ * <enumeration value="seaShell"/>
+ * <enumeration value="sienna"/>
+ * <enumeration value="silver"/>
+ * <enumeration value="skyBlue"/>
+ * <enumeration value="slateBlue"/>
+ * <enumeration value="slateGray"/>
+ * <enumeration value="snow"/>
+ * <enumeration value="springGreen"/>
+ * <enumeration value="steelBlue"/>
+ * <enumeration value="tan"/>
+ * <enumeration value="teal"/>
+ * <enumeration value="thistle"/>
+ * <enumeration value="tomato"/>
+ * <enumeration value="turquoise"/>
+ * <enumeration value="violet"/>
+ * <enumeration value="wheat"/>
+ * <enumeration value="white"/>
+ * <enumeration value="whiteSmoke"/>
+ * <enumeration value="yellow"/>
+ * <enumeration value="yellowGreen"/>
+ * </restriction>
+ * </simpleType>
+ * </pre>
+ *
+ */
+@XmlType(name = "ST_PresetColorVal", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+@XmlEnum
+public enum STPresetColorVal {
+
+
+ /**
+ * Alice Blue Preset Color
+ *
+ */
+ @XmlEnumValue("aliceBlue")
+ ALICE_BLUE("aliceBlue"),
+
+ /**
+ * Antique White Preset Color
+ *
+ */
+ @XmlEnumValue("antiqueWhite")
+ ANTIQUE_WHITE("antiqueWhite"),
+
+ /**
+ * Aqua Preset Color
+ *
+ */
+ @XmlEnumValue("aqua")
+ AQUA("aqua"),
+
+ /**
+ * Aquamarine Preset Color
+ *
+ */
+ @XmlEnumValue("aquamarine")
+ AQUAMARINE("aquamarine"),
+
+ /**
+ * Azure Preset Color
+ *
+ */
+ @XmlEnumValue("azure")
+ AZURE("azure"),
+
+ /**
+ * Beige Preset Color
+ *
+ */
+ @XmlEnumValue("beige")
+ BEIGE("beige"),
+
+ /**
+ * Bisque Preset Color
+ *
+ */
+ @XmlEnumValue("bisque")
+ BISQUE("bisque"),
+
+ /**
+ * Black Preset Color
+ *
+ */
+ @XmlEnumValue("black")
+ BLACK("black"),
+
+ /**
+ * Blanched Almond Preset Color
+ *
+ */
+ @XmlEnumValue("blanchedAlmond")
+ BLANCHED_ALMOND("blanchedAlmond"),
+
+ /**
+ * Blue Preset Color
+ *
+ */
+ @XmlEnumValue("blue")
+ BLUE("blue"),
+
+ /**
+ * Blue Violet Preset Color
+ *
+ */
+ @XmlEnumValue("blueViolet")
+ BLUE_VIOLET("blueViolet"),
+
+ /**
+ * Brown Preset Color
+ *
+ */
+ @XmlEnumValue("brown")
+ BROWN("brown"),
+
+ /**
+ * Burly Wood Preset Color
+ *
+ */
+ @XmlEnumValue("burlyWood")
+ BURLY_WOOD("burlyWood"),
+
+ /**
+ * Cadet Blue Preset Color
+ *
+ */
+ @XmlEnumValue("cadetBlue")
+ CADET_BLUE("cadetBlue"),
+
+ /**
+ * Chartreuse Preset Color
+ *
+ */
+ @XmlEnumValue("chartreuse")
+ CHARTREUSE("chartreuse"),
+
+ /**
+ * Chocolate Preset Color
+ *
+ */
+ @XmlEnumValue("chocolate")
+ CHOCOLATE("chocolate"),
+
+ /**
+ * Coral Preset Color
+ *
+ */
+ @XmlEnumValue("coral")
+ CORAL("coral"),
+
+ /**
+ * Cornflower Blue Preset Color
+ *
+ */
+ @XmlEnumValue("cornflowerBlue")
+ CORNFLOWER_BLUE("cornflowerBlue"),
+
+ /**
+ * Cornsilk Preset Color
+ *
+ */
+ @XmlEnumValue("cornsilk")
+ CORNSILK("cornsilk"),
+
+ /**
+ * Crimson Preset Color
+ *
+ */
+ @XmlEnumValue("crimson")
+ CRIMSON("crimson"),
+
+ /**
+ * Cyan Preset Color
+ *
+ */
+ @XmlEnumValue("cyan")
+ CYAN("cyan"),
+
+ /**
+ * Dark Blue Preset Color
+ *
+ */
+ @XmlEnumValue("dkBlue")
+ DK_BLUE("dkBlue"),
+
+ /**
+ * Dark Cyan Preset Color
+ *
+ */
+ @XmlEnumValue("dkCyan")
+ DK_CYAN("dkCyan"),
+
+ /**
+ * Dark Goldenrod Preset Color
+ *
+ */
+ @XmlEnumValue("dkGoldenrod")
+ DK_GOLDENROD("dkGoldenrod"),
+
+ /**
+ * Dark Gray Preset Color
+ *
+ */
+ @XmlEnumValue("dkGray")
+ DK_GRAY("dkGray"),
+
+ /**
+ * Dark Green Preset Color
+ *
+ */
+ @XmlEnumValue("dkGreen")
+ DK_GREEN("dkGreen"),
+
+ /**
+ * Dark Khaki Preset Color
+ *
+ */
+ @XmlEnumValue("dkKhaki")
+ DK_KHAKI("dkKhaki"),
+
+ /**
+ * Dark Magenta Preset Color
+ *
+ */
+ @XmlEnumValue("dkMagenta")
+ DK_MAGENTA("dkMagenta"),
+
+ /**
+ * Dark Olive Green Preset Color
+ *
+ */
+ @XmlEnumValue("dkOliveGreen")
+ DK_OLIVE_GREEN("dkOliveGreen"),
+
+ /**
+ * Dark Orange Preset Color
+ *
+ */
+ @XmlEnumValue("dkOrange")
+ DK_ORANGE("dkOrange"),
+
+ /**
+ * Dark Orchid Preset Color
+ *
+ */
+ @XmlEnumValue("dkOrchid")
+ DK_ORCHID("dkOrchid"),
+
+ /**
+ * Dark Red Preset Color
+ *
+ */
+ @XmlEnumValue("dkRed")
+ DK_RED("dkRed"),
+
+ /**
+ * Dark Salmon Preset Color
+ *
+ */
+ @XmlEnumValue("dkSalmon")
+ DK_SALMON("dkSalmon"),
+
+ /**
+ * Dark Sea Green Preset Color
+ *
+ */
+ @XmlEnumValue("dkSeaGreen")
+ DK_SEA_GREEN("dkSeaGreen"),
+
+ /**
+ * Dark Slate Blue Preset Color
+ *
+ */
+ @XmlEnumValue("dkSlateBlue")
+ DK_SLATE_BLUE("dkSlateBlue"),
+
+ /**
+ * Dark Slate Gray Preset Color
+ *
+ */
+ @XmlEnumValue("dkSlateGray")
+ DK_SLATE_GRAY("dkSlateGray"),
+
+ /**
+ * Dark Turquoise Preset Color
+ *
+ */
+ @XmlEnumValue("dkTurquoise")
+ DK_TURQUOISE("dkTurquoise"),
+
+ /**
+ * Dark Violet Preset Color
+ *
+ */
+ @XmlEnumValue("dkViolet")
+ DK_VIOLET("dkViolet"),
+
+ /**
+ * Deep Pink Preset Color
+ *
+ */
+ @XmlEnumValue("deepPink")
+ DEEP_PINK("deepPink"),
+
+ /**
+ * Deep Sky Blue Preset Color
+ *
+ */
+ @XmlEnumValue("deepSkyBlue")
+ DEEP_SKY_BLUE("deepSkyBlue"),
+
+ /**
+ * Dim Gray Preset Color
+ *
+ */
+ @XmlEnumValue("dimGray")
+ DIM_GRAY("dimGray"),
+
+ /**
+ * Dodger Blue Preset Color
+ *
+ */
+ @XmlEnumValue("dodgerBlue")
+ DODGER_BLUE("dodgerBlue"),
+
+ /**
+ * Firebrick Preset Color
+ *
+ */
+ @XmlEnumValue("firebrick")
+ FIREBRICK("firebrick"),
+
+ /**
+ * Floral White Preset Color
+ *
+ */
+ @XmlEnumValue("floralWhite")
+ FLORAL_WHITE("floralWhite"),
+
+ /**
+ * Forest Green Preset Color
+ *
+ */
+ @XmlEnumValue("forestGreen")
+ FOREST_GREEN("forestGreen"),
+
+ /**
+ * Fuchsia Preset Color
+ *
+ */
+ @XmlEnumValue("fuchsia")
+ FUCHSIA("fuchsia"),
+
+ /**
+ * Gainsboro Preset Color
+ *
+ */
+ @XmlEnumValue("gainsboro")
+ GAINSBORO("gainsboro"),
+
+ /**
+ * Ghost White Preset Color
+ *
+ */
+ @XmlEnumValue("ghostWhite")
+ GHOST_WHITE("ghostWhite"),
+
+ /**
+ * Gold Preset Color
+ *
+ */
+ @XmlEnumValue("gold")
+ GOLD("gold"),
+
+ /**
+ * Goldenrod Preset Color
+ *
+ */
+ @XmlEnumValue("goldenrod")
+ GOLDENROD("goldenrod"),
+
+ /**
+ * Gray Preset Color
+ *
+ */
+ @XmlEnumValue("gray")
+ GRAY("gray"),
+
+ /**
+ * Green Preset Color
+ *
+ */
+ @XmlEnumValue("green")
+ GREEN("green"),
+
+ /**
+ * Green Yellow Preset Color
+ *
+ */
+ @XmlEnumValue("greenYellow")
+ GREEN_YELLOW("greenYellow"),
+
+ /**
+ * Honeydew Preset Color
+ *
+ */
+ @XmlEnumValue("honeydew")
+ HONEYDEW("honeydew"),
+
+ /**
+ * Hot Pink Preset Color
+ *
+ */
+ @XmlEnumValue("hotPink")
+ HOT_PINK("hotPink"),
+
+ /**
+ * Indian Red Preset Color
+ *
+ */
+ @XmlEnumValue("indianRed")
+ INDIAN_RED("indianRed"),
+
+ /**
+ * Indigo Preset Color
+ *
+ */
+ @XmlEnumValue("indigo")
+ INDIGO("indigo"),
+
+ /**
+ * Ivory Preset Color
+ *
+ */
+ @XmlEnumValue("ivory")
+ IVORY("ivory"),
+
+ /**
+ * Khaki Preset Color
+ *
+ */
+ @XmlEnumValue("khaki")
+ KHAKI("khaki"),
+
+ /**
+ * Lavender Preset Color
+ *
+ */
+ @XmlEnumValue("lavender")
+ LAVENDER("lavender"),
+
+ /**
+ * Lavender Blush Preset Color
+ *
+ */
+ @XmlEnumValue("lavenderBlush")
+ LAVENDER_BLUSH("lavenderBlush"),
+
+ /**
+ * Lawn Green Preset Color
+ *
+ */
+ @XmlEnumValue("lawnGreen")
+ LAWN_GREEN("lawnGreen"),
+
+ /**
+ * Lemon Chiffon Preset Color
+ *
+ */
+ @XmlEnumValue("lemonChiffon")
+ LEMON_CHIFFON("lemonChiffon"),
+
+ /**
+ * Light Blue Preset Color
+ *
+ */
+ @XmlEnumValue("ltBlue")
+ LT_BLUE("ltBlue"),
+
+ /**
+ * Light Coral Preset Color
+ *
+ */
+ @XmlEnumValue("ltCoral")
+ LT_CORAL("ltCoral"),
+
+ /**
+ * Light Cyan Preset Color
+ *
+ */
+ @XmlEnumValue("ltCyan")
+ LT_CYAN("ltCyan"),
+
+ /**
+ * Light Goldenrod Yellow Preset Color
+ *
+ */
+ @XmlEnumValue("ltGoldenrodYellow")
+ LT_GOLDENROD_YELLOW("ltGoldenrodYellow"),
+
+ /**
+ * Light Gray Preset Color
+ *
+ */
+ @XmlEnumValue("ltGray")
+ LT_GRAY("ltGray"),
+
+ /**
+ * Light Green Preset Color
+ *
+ */
+ @XmlEnumValue("ltGreen")
+ LT_GREEN("ltGreen"),
+
+ /**
+ * Light Pink Preset Color
+ *
+ */
+ @XmlEnumValue("ltPink")
+ LT_PINK("ltPink"),
+
+ /**
+ * Light Salmon Preset Color
+ *
+ */
+ @XmlEnumValue("ltSalmon")
+ LT_SALMON("ltSalmon"),
+
+ /**
+ * Light Sea Green Preset Color
+ *
+ */
+ @XmlEnumValue("ltSeaGreen")
+ LT_SEA_GREEN("ltSeaGreen"),
+
+ /**
+ * Light Sky Blue Preset Color
+ *
+ */
+ @XmlEnumValue("ltSkyBlue")
+ LT_SKY_BLUE("ltSkyBlue"),
+
+ /**
+ * Light Slate Gray Preset Color
+ *
+ */
+ @XmlEnumValue("ltSlateGray")
+ LT_SLATE_GRAY("ltSlateGray"),
+
+ /**
+ * Light Steel Blue Preset Color
+ *
+ */
+ @XmlEnumValue("ltSteelBlue")
+ LT_STEEL_BLUE("ltSteelBlue"),
+
+ /**
+ * Light Yellow Preset Color
+ *
+ */
+ @XmlEnumValue("ltYellow")
+ LT_YELLOW("ltYellow"),
+
+ /**
+ * Lime Preset Color
+ *
+ */
+ @XmlEnumValue("lime")
+ LIME("lime"),
+
+ /**
+ * Lime Green Preset Color
+ *
+ */
+ @XmlEnumValue("limeGreen")
+ LIME_GREEN("limeGreen"),
+
+ /**
+ * Linen Preset Color
+ *
+ */
+ @XmlEnumValue("linen")
+ LINEN("linen"),
+
+ /**
+ * Magenta Preset Color
+ *
+ */
+ @XmlEnumValue("magenta")
+ MAGENTA("magenta"),
+
+ /**
+ * Maroon Preset Color
+ *
+ */
+ @XmlEnumValue("maroon")
+ MAROON("maroon"),
+
+ /**
+ * Medium Aquamarine Preset Color
+ *
+ */
+ @XmlEnumValue("medAquamarine")
+ MED_AQUAMARINE("medAquamarine"),
+
+ /**
+ * Medium Blue Preset Color
+ *
+ */
+ @XmlEnumValue("medBlue")
+ MED_BLUE("medBlue"),
+
+ /**
+ * Medium Orchid Preset Color
+ *
+ */
+ @XmlEnumValue("medOrchid")
+ MED_ORCHID("medOrchid"),
+
+ /**
+ * Medium Purple Preset Color
+ *
+ */
+ @XmlEnumValue("medPurple")
+ MED_PURPLE("medPurple"),
+
+ /**
+ * Medium Sea Green Preset Color
+ *
+ */
+ @XmlEnumValue("medSeaGreen")
+ MED_SEA_GREEN("medSeaGreen"),
+
+ /**
+ * Medium Slate Blue Preset Color
+ *
+ */
+ @XmlEnumValue("medSlateBlue")
+ MED_SLATE_BLUE("medSlateBlue"),
+
+ /**
+ * Medium Spring Green Preset Color
+ *
+ */
+ @XmlEnumValue("medSpringGreen")
+ MED_SPRING_GREEN("medSpringGreen"),
+
+ /**
+ * Medium Turquoise Preset Color
+ *
+ */
+ @XmlEnumValue("medTurquoise")
+ MED_TURQUOISE("medTurquoise"),
+
+ /**
+ * Medium Violet Red Preset Color
+ *
+ */
+ @XmlEnumValue("medVioletRed")
+ MED_VIOLET_RED("medVioletRed"),
+
+ /**
+ * Midnight Blue Preset Color
+ *
+ */
+ @XmlEnumValue("midnightBlue")
+ MIDNIGHT_BLUE("midnightBlue"),
+
+ /**
+ * Mint Cream Preset Color
+ *
+ */
+ @XmlEnumValue("mintCream")
+ MINT_CREAM("mintCream"),
+
+ /**
+ * Misty Rose Preset Color
+ *
+ */
+ @XmlEnumValue("mistyRose")
+ MISTY_ROSE("mistyRose"),
+
+ /**
+ * Moccasin Preset Color
+ *
+ */
+ @XmlEnumValue("moccasin")
+ MOCCASIN("moccasin"),
+
+ /**
+ * Navajo White Preset Color
+ *
+ */
+ @XmlEnumValue("navajoWhite")
+ NAVAJO_WHITE("navajoWhite"),
+
+ /**
+ * Navy Preset Color
+ *
+ */
+ @XmlEnumValue("navy")
+ NAVY("navy"),
+
+ /**
+ * Old Lace Preset Color
+ *
+ */
+ @XmlEnumValue("oldLace")
+ OLD_LACE("oldLace"),
+
+ /**
+ * Olive Preset Color
+ *
+ */
+ @XmlEnumValue("olive")
+ OLIVE("olive"),
+
+ /**
+ * Olive Drab Preset Color
+ *
+ */
+ @XmlEnumValue("oliveDrab")
+ OLIVE_DRAB("oliveDrab"),
+
+ /**
+ * Orange Preset Color
+ *
+ */
+ @XmlEnumValue("orange")
+ ORANGE("orange"),
+
+ /**
+ * Orange Red Preset Color
+ *
+ */
+ @XmlEnumValue("orangeRed")
+ ORANGE_RED("orangeRed"),
+
+ /**
+ * Orchid Preset Color
+ *
+ */
+ @XmlEnumValue("orchid")
+ ORCHID("orchid"),
+
+ /**
+ * Pale Goldenrod Preset Color
+ *
+ */
+ @XmlEnumValue("paleGoldenrod")
+ PALE_GOLDENROD("paleGoldenrod"),
+
+ /**
+ * Pale Green Preset Color
+ *
+ */
+ @XmlEnumValue("paleGreen")
+ PALE_GREEN("paleGreen"),
+
+ /**
+ * Pale Turquoise Preset Color
+ *
+ */
+ @XmlEnumValue("paleTurquoise")
+ PALE_TURQUOISE("paleTurquoise"),
+
+ /**
+ * Pale Violet Red Preset Color
+ *
+ */
+ @XmlEnumValue("paleVioletRed")
+ PALE_VIOLET_RED("paleVioletRed"),
+
+ /**
+ * Papaya Whip Preset Color
+ *
+ */
+ @XmlEnumValue("papayaWhip")
+ PAPAYA_WHIP("papayaWhip"),
+
+ /**
+ * Peach Puff Preset Color
+ *
+ */
+ @XmlEnumValue("peachPuff")
+ PEACH_PUFF("peachPuff"),
+
+ /**
+ * Peru Preset Color
+ *
+ */
+ @XmlEnumValue("peru")
+ PERU("peru"),
+
+ /**
+ * Pink Preset Color
+ *
+ */
+ @XmlEnumValue("pink")
+ PINK("pink"),
+
+ /**
+ * Plum Preset Color
+ *
+ */
+ @XmlEnumValue("plum")
+ PLUM("plum"),
+
+ /**
+ * Powder Blue Preset Color
+ *
+ */
+ @XmlEnumValue("powderBlue")
+ POWDER_BLUE("powderBlue"),
+
+ /**
+ * Purple Preset Color
+ *
+ */
+ @XmlEnumValue("purple")
+ PURPLE("purple"),
+
+ /**
+ * Red Preset Color
+ *
+ */
+ @XmlEnumValue("red")
+ RED("red"),
+
+ /**
+ * Rosy Brown Preset Color
+ *
+ */
+ @XmlEnumValue("rosyBrown")
+ ROSY_BROWN("rosyBrown"),
+
+ /**
+ * Royal Blue Preset Color
+ *
+ */
+ @XmlEnumValue("royalBlue")
+ ROYAL_BLUE("royalBlue"),
+
+ /**
+ * Saddle Brown Preset Color
+ *
+ */
+ @XmlEnumValue("saddleBrown")
+ SADDLE_BROWN("saddleBrown"),
+
+ /**
+ * Salmon Preset Color
+ *
+ */
+ @XmlEnumValue("salmon")
+ SALMON("salmon"),
+
+ /**
+ * Sandy Brown Preset Color
+ *
+ */
+ @XmlEnumValue("sandyBrown")
+ SANDY_BROWN("sandyBrown"),
+
+ /**
+ * Sea Green Preset Color
+ *
+ */
+ @XmlEnumValue("seaGreen")
+ SEA_GREEN("seaGreen"),
+
+ /**
+ * Sea Shell Preset Color
+ *
+ */
+ @XmlEnumValue("seaShell")
+ SEA_SHELL("seaShell"),
+
+ /**
+ * Sienna Preset Color
+ *
+ */
+ @XmlEnumValue("sienna")
+ SIENNA("sienna"),
+
+ /**
+ * Silver Preset Color
+ *
+ */
+ @XmlEnumValue("silver")
+ SILVER("silver"),
+
+ /**
+ * Sky Blue Preset Color
+ *
+ */
+ @XmlEnumValue("skyBlue")
+ SKY_BLUE("skyBlue"),
+
+ /**
+ * Slate Blue Preset Color
+ *
+ */
+ @XmlEnumValue("slateBlue")
+ SLATE_BLUE("slateBlue"),
+
+ /**
+ * Slate Gray Preset Color
+ *
+ */
+ @XmlEnumValue("slateGray")
+ SLATE_GRAY("slateGray"),
+
+ /**
+ * Snow Preset Color
+ *
+ */
+ @XmlEnumValue("snow")
+ SNOW("snow"),
+
+ /**
+ * Spring Green Preset Color
+ *
+ */
+ @XmlEnumValue("springGreen")
+ SPRING_GREEN("springGreen"),
+
+ /**
+ * Steel Blue Preset Color
+ *
+ */
+ @XmlEnumValue("steelBlue")
+ STEEL_BLUE("steelBlue"),
+
+ /**
+ * Tan Preset Color
+ *
+ */
+ @XmlEnumValue("tan")
+ TAN("tan"),
+
+ /**
+ * Teal Preset Color
+ *
+ */
+ @XmlEnumValue("teal")
+ TEAL("teal"),
+
+ /**
+ * Thistle Preset Color
+ *
+ */
+ @XmlEnumValue("thistle")
+ THISTLE("thistle"),
+
+ /**
+ * Tomato Preset Color
+ *
+ */
+ @XmlEnumValue("tomato")
+ TOMATO("tomato"),
+
+ /**
+ * Turquoise Preset Color
+ *
+ */
+ @XmlEnumValue("turquoise")
+ TURQUOISE("turquoise"),
+
+ /**
+ * Violet Preset Color
+ *
+ */
+ @XmlEnumValue("violet")
+ VIOLET("violet"),
+
+ /**
+ * Wheat Preset Color
+ *
+ */
+ @XmlEnumValue("wheat")
+ WHEAT("wheat"),
+
+ /**
+ * White Preset Color
+ *
+ */
+ @XmlEnumValue("white")
+ WHITE("white"),
+
+ /**
+ * White Smoke Preset Color
+ *
+ */
+ @XmlEnumValue("whiteSmoke")
+ WHITE_SMOKE("whiteSmoke"),
+
+ /**
+ * Yellow Preset Color
+ *
+ */
+ @XmlEnumValue("yellow")
+ YELLOW("yellow"),
+
+ /**
+ * Yellow Green Preset Color
+ *
+ */
+ @XmlEnumValue("yellowGreen")
+ YELLOW_GREEN("yellowGreen");
+ private final String value;
+
+ STPresetColorVal(String v) {
+ value = v;
+ }
+
+ public String value() {
+ return value;
+ }
+
+ public static STPresetColorVal fromValue(String v) {
+ for (STPresetColorVal c: STPresetColorVal.values()) {
+ if (c.value.equals(v)) {
+ return c;
+ }
+ }
+ throw new IllegalArgumentException(v);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/STRectAlignment.java b/src/java/org/apache/poi/sl/draw/binding/STRectAlignment.java new file mode 100644 index 0000000000..688a166baf --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/STRectAlignment.java @@ -0,0 +1,133 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlEnumValue;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for ST_RectAlignment.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * <p>
+ * <pre>
+ * <simpleType name="ST_RectAlignment">
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}token">
+ * <enumeration value="tl"/>
+ * <enumeration value="t"/>
+ * <enumeration value="tr"/>
+ * <enumeration value="l"/>
+ * <enumeration value="ctr"/>
+ * <enumeration value="r"/>
+ * <enumeration value="bl"/>
+ * <enumeration value="b"/>
+ * <enumeration value="br"/>
+ * </restriction>
+ * </simpleType>
+ * </pre>
+ *
+ */
+@XmlType(name = "ST_RectAlignment", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+@XmlEnum
+public enum STRectAlignment {
+
+
+ /**
+ * Rectangle Alignment Enum ( Top Left )
+ *
+ */
+ @XmlEnumValue("tl")
+ TL("tl"),
+
+ /**
+ * Rectangle Alignment Enum ( Top )
+ *
+ */
+ @XmlEnumValue("t")
+ T("t"),
+
+ /**
+ * Rectangle Alignment Enum ( Top Right )
+ *
+ */
+ @XmlEnumValue("tr")
+ TR("tr"),
+
+ /**
+ * Rectangle Alignment Enum ( Left )
+ *
+ */
+ @XmlEnumValue("l")
+ L("l"),
+
+ /**
+ * Rectangle Alignment Enum ( Center )
+ *
+ */
+ @XmlEnumValue("ctr")
+ CTR("ctr"),
+
+ /**
+ * Rectangle Alignment Enum ( Right )
+ *
+ */
+ @XmlEnumValue("r")
+ R("r"),
+
+ /**
+ * Rectangle Alignment Enum ( Bottom Left )
+ *
+ */
+ @XmlEnumValue("bl")
+ BL("bl"),
+
+ /**
+ * Rectangle Alignment Enum ( Bottom )
+ *
+ */
+ @XmlEnumValue("b")
+ B("b"),
+
+ /**
+ * Rectangle Alignment Enum ( Bottom Right )
+ *
+ */
+ @XmlEnumValue("br")
+ BR("br");
+ private final String value;
+
+ STRectAlignment(String v) {
+ value = v;
+ }
+
+ public String value() {
+ return value;
+ }
+
+ public static STRectAlignment fromValue(String v) {
+ for (STRectAlignment c: STRectAlignment.values()) {
+ if (c.value.equals(v)) {
+ return c;
+ }
+ }
+ throw new IllegalArgumentException(v);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/STSchemeColorVal.java b/src/java/org/apache/poi/sl/draw/binding/STSchemeColorVal.java new file mode 100644 index 0000000000..84b88075f1 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/STSchemeColorVal.java @@ -0,0 +1,197 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlEnumValue;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for ST_SchemeColorVal.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * <p>
+ * <pre>
+ * <simpleType name="ST_SchemeColorVal">
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}token">
+ * <enumeration value="bg1"/>
+ * <enumeration value="tx1"/>
+ * <enumeration value="bg2"/>
+ * <enumeration value="tx2"/>
+ * <enumeration value="accent1"/>
+ * <enumeration value="accent2"/>
+ * <enumeration value="accent3"/>
+ * <enumeration value="accent4"/>
+ * <enumeration value="accent5"/>
+ * <enumeration value="accent6"/>
+ * <enumeration value="hlink"/>
+ * <enumeration value="folHlink"/>
+ * <enumeration value="phClr"/>
+ * <enumeration value="dk1"/>
+ * <enumeration value="lt1"/>
+ * <enumeration value="dk2"/>
+ * <enumeration value="lt2"/>
+ * </restriction>
+ * </simpleType>
+ * </pre>
+ *
+ */
+@XmlType(name = "ST_SchemeColorVal", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+@XmlEnum
+public enum STSchemeColorVal {
+
+
+ /**
+ * Background Color 1
+ *
+ */
+ @XmlEnumValue("bg1")
+ BG_1("bg1"),
+
+ /**
+ * Text Color 1
+ *
+ */
+ @XmlEnumValue("tx1")
+ TX_1("tx1"),
+
+ /**
+ * Background Color 2
+ *
+ */
+ @XmlEnumValue("bg2")
+ BG_2("bg2"),
+
+ /**
+ * Text Color 2
+ *
+ */
+ @XmlEnumValue("tx2")
+ TX_2("tx2"),
+
+ /**
+ * Accent Color 1
+ *
+ */
+ @XmlEnumValue("accent1")
+ ACCENT_1("accent1"),
+
+ /**
+ * Accent Color 2
+ *
+ */
+ @XmlEnumValue("accent2")
+ ACCENT_2("accent2"),
+
+ /**
+ * Accent Color 3
+ *
+ */
+ @XmlEnumValue("accent3")
+ ACCENT_3("accent3"),
+
+ /**
+ * Accent Color 4
+ *
+ */
+ @XmlEnumValue("accent4")
+ ACCENT_4("accent4"),
+
+ /**
+ * Accent Color 5
+ *
+ */
+ @XmlEnumValue("accent5")
+ ACCENT_5("accent5"),
+
+ /**
+ * Accent Color 6
+ *
+ */
+ @XmlEnumValue("accent6")
+ ACCENT_6("accent6"),
+
+ /**
+ * Hyperlink Color
+ *
+ */
+ @XmlEnumValue("hlink")
+ HLINK("hlink"),
+
+ /**
+ * Followed Hyperlink Color
+ *
+ */
+ @XmlEnumValue("folHlink")
+ FOL_HLINK("folHlink"),
+
+ /**
+ * Style Color
+ *
+ */
+ @XmlEnumValue("phClr")
+ PH_CLR("phClr"),
+
+ /**
+ * Dark Color 1
+ *
+ */
+ @XmlEnumValue("dk1")
+ DK_1("dk1"),
+
+ /**
+ * Light Color 1
+ *
+ */
+ @XmlEnumValue("lt1")
+ LT_1("lt1"),
+
+ /**
+ * Dark Color 2
+ *
+ */
+ @XmlEnumValue("dk2")
+ DK_2("dk2"),
+
+ /**
+ * Light Color 2
+ *
+ */
+ @XmlEnumValue("lt2")
+ LT_2("lt2");
+ private final String value;
+
+ STSchemeColorVal(String v) {
+ value = v;
+ }
+
+ public String value() {
+ return value;
+ }
+
+ public static STSchemeColorVal fromValue(String v) {
+ for (STSchemeColorVal c: STSchemeColorVal.values()) {
+ if (c.value.equals(v)) {
+ return c;
+ }
+ }
+ throw new IllegalArgumentException(v);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/STShapeType.java b/src/java/org/apache/poi/sl/draw/binding/STShapeType.java new file mode 100644 index 0000000000..559b0a1591 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/STShapeType.java @@ -0,0 +1,1557 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlEnumValue;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for ST_ShapeType.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * <p>
+ * <pre>
+ * <simpleType name="ST_ShapeType">
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}token">
+ * <enumeration value="line"/>
+ * <enumeration value="lineInv"/>
+ * <enumeration value="triangle"/>
+ * <enumeration value="rtTriangle"/>
+ * <enumeration value="rect"/>
+ * <enumeration value="diamond"/>
+ * <enumeration value="parallelogram"/>
+ * <enumeration value="trapezoid"/>
+ * <enumeration value="nonIsoscelesTrapezoid"/>
+ * <enumeration value="pentagon"/>
+ * <enumeration value="hexagon"/>
+ * <enumeration value="heptagon"/>
+ * <enumeration value="octagon"/>
+ * <enumeration value="decagon"/>
+ * <enumeration value="dodecagon"/>
+ * <enumeration value="star4"/>
+ * <enumeration value="star5"/>
+ * <enumeration value="star6"/>
+ * <enumeration value="star7"/>
+ * <enumeration value="star8"/>
+ * <enumeration value="star10"/>
+ * <enumeration value="star12"/>
+ * <enumeration value="star16"/>
+ * <enumeration value="star24"/>
+ * <enumeration value="star32"/>
+ * <enumeration value="roundRect"/>
+ * <enumeration value="round1Rect"/>
+ * <enumeration value="round2SameRect"/>
+ * <enumeration value="round2DiagRect"/>
+ * <enumeration value="snipRoundRect"/>
+ * <enumeration value="snip1Rect"/>
+ * <enumeration value="snip2SameRect"/>
+ * <enumeration value="snip2DiagRect"/>
+ * <enumeration value="plaque"/>
+ * <enumeration value="ellipse"/>
+ * <enumeration value="teardrop"/>
+ * <enumeration value="homePlate"/>
+ * <enumeration value="chevron"/>
+ * <enumeration value="pieWedge"/>
+ * <enumeration value="pie"/>
+ * <enumeration value="blockArc"/>
+ * <enumeration value="donut"/>
+ * <enumeration value="noSmoking"/>
+ * <enumeration value="rightArrow"/>
+ * <enumeration value="leftArrow"/>
+ * <enumeration value="upArrow"/>
+ * <enumeration value="downArrow"/>
+ * <enumeration value="stripedRightArrow"/>
+ * <enumeration value="notchedRightArrow"/>
+ * <enumeration value="bentUpArrow"/>
+ * <enumeration value="leftRightArrow"/>
+ * <enumeration value="upDownArrow"/>
+ * <enumeration value="leftUpArrow"/>
+ * <enumeration value="leftRightUpArrow"/>
+ * <enumeration value="quadArrow"/>
+ * <enumeration value="leftArrowCallout"/>
+ * <enumeration value="rightArrowCallout"/>
+ * <enumeration value="upArrowCallout"/>
+ * <enumeration value="downArrowCallout"/>
+ * <enumeration value="leftRightArrowCallout"/>
+ * <enumeration value="upDownArrowCallout"/>
+ * <enumeration value="quadArrowCallout"/>
+ * <enumeration value="bentArrow"/>
+ * <enumeration value="uturnArrow"/>
+ * <enumeration value="circularArrow"/>
+ * <enumeration value="leftCircularArrow"/>
+ * <enumeration value="leftRightCircularArrow"/>
+ * <enumeration value="curvedRightArrow"/>
+ * <enumeration value="curvedLeftArrow"/>
+ * <enumeration value="curvedUpArrow"/>
+ * <enumeration value="curvedDownArrow"/>
+ * <enumeration value="swooshArrow"/>
+ * <enumeration value="cube"/>
+ * <enumeration value="can"/>
+ * <enumeration value="lightningBolt"/>
+ * <enumeration value="heart"/>
+ * <enumeration value="sun"/>
+ * <enumeration value="moon"/>
+ * <enumeration value="smileyFace"/>
+ * <enumeration value="irregularSeal1"/>
+ * <enumeration value="irregularSeal2"/>
+ * <enumeration value="foldedCorner"/>
+ * <enumeration value="bevel"/>
+ * <enumeration value="frame"/>
+ * <enumeration value="halfFrame"/>
+ * <enumeration value="corner"/>
+ * <enumeration value="diagStripe"/>
+ * <enumeration value="chord"/>
+ * <enumeration value="arc"/>
+ * <enumeration value="leftBracket"/>
+ * <enumeration value="rightBracket"/>
+ * <enumeration value="leftBrace"/>
+ * <enumeration value="rightBrace"/>
+ * <enumeration value="bracketPair"/>
+ * <enumeration value="bracePair"/>
+ * <enumeration value="straightConnector1"/>
+ * <enumeration value="bentConnector2"/>
+ * <enumeration value="bentConnector3"/>
+ * <enumeration value="bentConnector4"/>
+ * <enumeration value="bentConnector5"/>
+ * <enumeration value="curvedConnector2"/>
+ * <enumeration value="curvedConnector3"/>
+ * <enumeration value="curvedConnector4"/>
+ * <enumeration value="curvedConnector5"/>
+ * <enumeration value="callout1"/>
+ * <enumeration value="callout2"/>
+ * <enumeration value="callout3"/>
+ * <enumeration value="accentCallout1"/>
+ * <enumeration value="accentCallout2"/>
+ * <enumeration value="accentCallout3"/>
+ * <enumeration value="borderCallout1"/>
+ * <enumeration value="borderCallout2"/>
+ * <enumeration value="borderCallout3"/>
+ * <enumeration value="accentBorderCallout1"/>
+ * <enumeration value="accentBorderCallout2"/>
+ * <enumeration value="accentBorderCallout3"/>
+ * <enumeration value="wedgeRectCallout"/>
+ * <enumeration value="wedgeRoundRectCallout"/>
+ * <enumeration value="wedgeEllipseCallout"/>
+ * <enumeration value="cloudCallout"/>
+ * <enumeration value="cloud"/>
+ * <enumeration value="ribbon"/>
+ * <enumeration value="ribbon2"/>
+ * <enumeration value="ellipseRibbon"/>
+ * <enumeration value="ellipseRibbon2"/>
+ * <enumeration value="leftRightRibbon"/>
+ * <enumeration value="verticalScroll"/>
+ * <enumeration value="horizontalScroll"/>
+ * <enumeration value="wave"/>
+ * <enumeration value="doubleWave"/>
+ * <enumeration value="plus"/>
+ * <enumeration value="flowChartProcess"/>
+ * <enumeration value="flowChartDecision"/>
+ * <enumeration value="flowChartInputOutput"/>
+ * <enumeration value="flowChartPredefinedProcess"/>
+ * <enumeration value="flowChartInternalStorage"/>
+ * <enumeration value="flowChartDocument"/>
+ * <enumeration value="flowChartMultidocument"/>
+ * <enumeration value="flowChartTerminator"/>
+ * <enumeration value="flowChartPreparation"/>
+ * <enumeration value="flowChartManualInput"/>
+ * <enumeration value="flowChartManualOperation"/>
+ * <enumeration value="flowChartConnector"/>
+ * <enumeration value="flowChartPunchedCard"/>
+ * <enumeration value="flowChartPunchedTape"/>
+ * <enumeration value="flowChartSummingJunction"/>
+ * <enumeration value="flowChartOr"/>
+ * <enumeration value="flowChartCollate"/>
+ * <enumeration value="flowChartSort"/>
+ * <enumeration value="flowChartExtract"/>
+ * <enumeration value="flowChartMerge"/>
+ * <enumeration value="flowChartOfflineStorage"/>
+ * <enumeration value="flowChartOnlineStorage"/>
+ * <enumeration value="flowChartMagneticTape"/>
+ * <enumeration value="flowChartMagneticDisk"/>
+ * <enumeration value="flowChartMagneticDrum"/>
+ * <enumeration value="flowChartDisplay"/>
+ * <enumeration value="flowChartDelay"/>
+ * <enumeration value="flowChartAlternateProcess"/>
+ * <enumeration value="flowChartOffpageConnector"/>
+ * <enumeration value="actionButtonBlank"/>
+ * <enumeration value="actionButtonHome"/>
+ * <enumeration value="actionButtonHelp"/>
+ * <enumeration value="actionButtonInformation"/>
+ * <enumeration value="actionButtonForwardNext"/>
+ * <enumeration value="actionButtonBackPrevious"/>
+ * <enumeration value="actionButtonEnd"/>
+ * <enumeration value="actionButtonBeginning"/>
+ * <enumeration value="actionButtonReturn"/>
+ * <enumeration value="actionButtonDocument"/>
+ * <enumeration value="actionButtonSound"/>
+ * <enumeration value="actionButtonMovie"/>
+ * <enumeration value="gear6"/>
+ * <enumeration value="gear9"/>
+ * <enumeration value="funnel"/>
+ * <enumeration value="mathPlus"/>
+ * <enumeration value="mathMinus"/>
+ * <enumeration value="mathMultiply"/>
+ * <enumeration value="mathDivide"/>
+ * <enumeration value="mathEqual"/>
+ * <enumeration value="mathNotEqual"/>
+ * <enumeration value="cornerTabs"/>
+ * <enumeration value="squareTabs"/>
+ * <enumeration value="plaqueTabs"/>
+ * <enumeration value="chartX"/>
+ * <enumeration value="chartStar"/>
+ * <enumeration value="chartPlus"/>
+ * </restriction>
+ * </simpleType>
+ * </pre>
+ *
+ */
+@XmlType(name = "ST_ShapeType", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+@XmlEnum
+public enum STShapeType {
+
+
+ /**
+ * Line Shape
+ *
+ */
+ @XmlEnumValue("line")
+ LINE("line"),
+
+ /**
+ * Line Inverse Shape
+ *
+ */
+ @XmlEnumValue("lineInv")
+ LINE_INV("lineInv"),
+
+ /**
+ * Triangle Shape
+ *
+ */
+ @XmlEnumValue("triangle")
+ TRIANGLE("triangle"),
+
+ /**
+ * Right Triangle Shape
+ *
+ */
+ @XmlEnumValue("rtTriangle")
+ RT_TRIANGLE("rtTriangle"),
+
+ /**
+ * Rectangle Shape
+ *
+ */
+ @XmlEnumValue("rect")
+ RECT("rect"),
+
+ /**
+ * Diamond Shape
+ *
+ */
+ @XmlEnumValue("diamond")
+ DIAMOND("diamond"),
+
+ /**
+ * Parallelogram Shape
+ *
+ */
+ @XmlEnumValue("parallelogram")
+ PARALLELOGRAM("parallelogram"),
+
+ /**
+ * Trapezoid Shape
+ *
+ */
+ @XmlEnumValue("trapezoid")
+ TRAPEZOID("trapezoid"),
+
+ /**
+ * Non-Isosceles Trapezoid Shape
+ *
+ */
+ @XmlEnumValue("nonIsoscelesTrapezoid")
+ NON_ISOSCELES_TRAPEZOID("nonIsoscelesTrapezoid"),
+
+ /**
+ * Pentagon Shape
+ *
+ */
+ @XmlEnumValue("pentagon")
+ PENTAGON("pentagon"),
+
+ /**
+ * Hexagon Shape
+ *
+ */
+ @XmlEnumValue("hexagon")
+ HEXAGON("hexagon"),
+
+ /**
+ * Heptagon Shape
+ *
+ */
+ @XmlEnumValue("heptagon")
+ HEPTAGON("heptagon"),
+
+ /**
+ * Octagon Shape
+ *
+ */
+ @XmlEnumValue("octagon")
+ OCTAGON("octagon"),
+
+ /**
+ * Decagon Shape
+ *
+ */
+ @XmlEnumValue("decagon")
+ DECAGON("decagon"),
+
+ /**
+ * Dodecagon Shape
+ *
+ */
+ @XmlEnumValue("dodecagon")
+ DODECAGON("dodecagon"),
+
+ /**
+ * Four Pointed Star Shape
+ *
+ */
+ @XmlEnumValue("star4")
+ STAR_4("star4"),
+
+ /**
+ * Five Pointed Star Shape
+ *
+ */
+ @XmlEnumValue("star5")
+ STAR_5("star5"),
+
+ /**
+ * Six Pointed Star Shape
+ *
+ */
+ @XmlEnumValue("star6")
+ STAR_6("star6"),
+
+ /**
+ * Seven Pointed Star Shape
+ *
+ */
+ @XmlEnumValue("star7")
+ STAR_7("star7"),
+
+ /**
+ * Eight Pointed Star Shape
+ *
+ */
+ @XmlEnumValue("star8")
+ STAR_8("star8"),
+
+ /**
+ * Ten Pointed Star Shape
+ *
+ */
+ @XmlEnumValue("star10")
+ STAR_10("star10"),
+
+ /**
+ * Twelve Pointed Star Shape
+ *
+ */
+ @XmlEnumValue("star12")
+ STAR_12("star12"),
+
+ /**
+ * Sixteen Pointed Star Shape
+ *
+ */
+ @XmlEnumValue("star16")
+ STAR_16("star16"),
+
+ /**
+ * Twenty Four Pointed Star Shape
+ *
+ */
+ @XmlEnumValue("star24")
+ STAR_24("star24"),
+
+ /**
+ * Thirty Two Pointed Star Shape
+ *
+ */
+ @XmlEnumValue("star32")
+ STAR_32("star32"),
+
+ /**
+ * Round Corner Rectangle Shape
+ *
+ */
+ @XmlEnumValue("roundRect")
+ ROUND_RECT("roundRect"),
+
+ /**
+ * One Round Corner Rectangle Shape
+ *
+ */
+ @XmlEnumValue("round1Rect")
+ ROUND_1_RECT("round1Rect"),
+
+ /**
+ * Two Same-side Round Corner Rectangle Shape
+ *
+ */
+ @XmlEnumValue("round2SameRect")
+ ROUND_2_SAME_RECT("round2SameRect"),
+
+ /**
+ * Two Diagonal Round Corner Rectangle Shape
+ *
+ */
+ @XmlEnumValue("round2DiagRect")
+ ROUND_2_DIAG_RECT("round2DiagRect"),
+
+ /**
+ * One Snip One Round Corner Rectangle Shape
+ *
+ */
+ @XmlEnumValue("snipRoundRect")
+ SNIP_ROUND_RECT("snipRoundRect"),
+
+ /**
+ * One Snip Corner Rectangle Shape
+ *
+ */
+ @XmlEnumValue("snip1Rect")
+ SNIP_1_RECT("snip1Rect"),
+
+ /**
+ * Two Same-side Snip Corner Rectangle Shape
+ *
+ */
+ @XmlEnumValue("snip2SameRect")
+ SNIP_2_SAME_RECT("snip2SameRect"),
+
+ /**
+ * Two Diagonal Snip Corner Rectangle Shape
+ *
+ */
+ @XmlEnumValue("snip2DiagRect")
+ SNIP_2_DIAG_RECT("snip2DiagRect"),
+
+ /**
+ * Plaque Shape
+ *
+ */
+ @XmlEnumValue("plaque")
+ PLAQUE("plaque"),
+
+ /**
+ * Ellipse Shape
+ *
+ */
+ @XmlEnumValue("ellipse")
+ ELLIPSE("ellipse"),
+
+ /**
+ * Teardrop Shape
+ *
+ */
+ @XmlEnumValue("teardrop")
+ TEARDROP("teardrop"),
+
+ /**
+ * Home Plate Shape
+ *
+ */
+ @XmlEnumValue("homePlate")
+ HOME_PLATE("homePlate"),
+
+ /**
+ * Chevron Shape
+ *
+ */
+ @XmlEnumValue("chevron")
+ CHEVRON("chevron"),
+
+ /**
+ * Pie Wedge Shape
+ *
+ */
+ @XmlEnumValue("pieWedge")
+ PIE_WEDGE("pieWedge"),
+
+ /**
+ * Pie Shape
+ *
+ */
+ @XmlEnumValue("pie")
+ PIE("pie"),
+
+ /**
+ * Block Arc Shape
+ *
+ */
+ @XmlEnumValue("blockArc")
+ BLOCK_ARC("blockArc"),
+
+ /**
+ * Donut Shape
+ *
+ */
+ @XmlEnumValue("donut")
+ DONUT("donut"),
+
+ /**
+ * No Smoking Shape
+ *
+ */
+ @XmlEnumValue("noSmoking")
+ NO_SMOKING("noSmoking"),
+
+ /**
+ * Right Arrow Shape
+ *
+ */
+ @XmlEnumValue("rightArrow")
+ RIGHT_ARROW("rightArrow"),
+
+ /**
+ * Left Arrow Shape
+ *
+ */
+ @XmlEnumValue("leftArrow")
+ LEFT_ARROW("leftArrow"),
+
+ /**
+ * Up Arrow Shape
+ *
+ */
+ @XmlEnumValue("upArrow")
+ UP_ARROW("upArrow"),
+
+ /**
+ * Down Arrow Shape
+ *
+ */
+ @XmlEnumValue("downArrow")
+ DOWN_ARROW("downArrow"),
+
+ /**
+ * Striped Right Arrow Shape
+ *
+ */
+ @XmlEnumValue("stripedRightArrow")
+ STRIPED_RIGHT_ARROW("stripedRightArrow"),
+
+ /**
+ * Notched Right Arrow Shape
+ *
+ */
+ @XmlEnumValue("notchedRightArrow")
+ NOTCHED_RIGHT_ARROW("notchedRightArrow"),
+
+ /**
+ * Bent Up Arrow Shape
+ *
+ */
+ @XmlEnumValue("bentUpArrow")
+ BENT_UP_ARROW("bentUpArrow"),
+
+ /**
+ * Left Right Arrow Shape
+ *
+ */
+ @XmlEnumValue("leftRightArrow")
+ LEFT_RIGHT_ARROW("leftRightArrow"),
+
+ /**
+ * Up Down Arrow Shape
+ *
+ */
+ @XmlEnumValue("upDownArrow")
+ UP_DOWN_ARROW("upDownArrow"),
+
+ /**
+ * Left Up Arrow Shape
+ *
+ */
+ @XmlEnumValue("leftUpArrow")
+ LEFT_UP_ARROW("leftUpArrow"),
+
+ /**
+ * Left Right Up Arrow Shape
+ *
+ */
+ @XmlEnumValue("leftRightUpArrow")
+ LEFT_RIGHT_UP_ARROW("leftRightUpArrow"),
+
+ /**
+ * Quad-Arrow Shape
+ *
+ */
+ @XmlEnumValue("quadArrow")
+ QUAD_ARROW("quadArrow"),
+
+ /**
+ * Callout Left Arrow Shape
+ *
+ */
+ @XmlEnumValue("leftArrowCallout")
+ LEFT_ARROW_CALLOUT("leftArrowCallout"),
+
+ /**
+ * Callout Right Arrow Shape
+ *
+ */
+ @XmlEnumValue("rightArrowCallout")
+ RIGHT_ARROW_CALLOUT("rightArrowCallout"),
+
+ /**
+ * Callout Up Arrow Shape
+ *
+ */
+ @XmlEnumValue("upArrowCallout")
+ UP_ARROW_CALLOUT("upArrowCallout"),
+
+ /**
+ * Callout Down Arrow Shape
+ *
+ */
+ @XmlEnumValue("downArrowCallout")
+ DOWN_ARROW_CALLOUT("downArrowCallout"),
+
+ /**
+ * Callout Left Right Arrow Shape
+ *
+ */
+ @XmlEnumValue("leftRightArrowCallout")
+ LEFT_RIGHT_ARROW_CALLOUT("leftRightArrowCallout"),
+
+ /**
+ * Callout Up Down Arrow Shape
+ *
+ */
+ @XmlEnumValue("upDownArrowCallout")
+ UP_DOWN_ARROW_CALLOUT("upDownArrowCallout"),
+
+ /**
+ * Callout Quad-Arrow Shape
+ *
+ */
+ @XmlEnumValue("quadArrowCallout")
+ QUAD_ARROW_CALLOUT("quadArrowCallout"),
+
+ /**
+ * Bent Arrow Shape
+ *
+ */
+ @XmlEnumValue("bentArrow")
+ BENT_ARROW("bentArrow"),
+
+ /**
+ * U-Turn Arrow Shape
+ *
+ */
+ @XmlEnumValue("uturnArrow")
+ UTURN_ARROW("uturnArrow"),
+
+ /**
+ * Circular Arrow Shape
+ *
+ */
+ @XmlEnumValue("circularArrow")
+ CIRCULAR_ARROW("circularArrow"),
+
+ /**
+ * Left Circular Arrow Shape
+ *
+ */
+ @XmlEnumValue("leftCircularArrow")
+ LEFT_CIRCULAR_ARROW("leftCircularArrow"),
+
+ /**
+ * Left Right Circular Arrow Shape
+ *
+ */
+ @XmlEnumValue("leftRightCircularArrow")
+ LEFT_RIGHT_CIRCULAR_ARROW("leftRightCircularArrow"),
+
+ /**
+ * Curved Right Arrow Shape
+ *
+ */
+ @XmlEnumValue("curvedRightArrow")
+ CURVED_RIGHT_ARROW("curvedRightArrow"),
+
+ /**
+ * Curved Left Arrow Shape
+ *
+ */
+ @XmlEnumValue("curvedLeftArrow")
+ CURVED_LEFT_ARROW("curvedLeftArrow"),
+
+ /**
+ * Curved Up Arrow Shape
+ *
+ */
+ @XmlEnumValue("curvedUpArrow")
+ CURVED_UP_ARROW("curvedUpArrow"),
+
+ /**
+ * Curved Down Arrow Shape
+ *
+ */
+ @XmlEnumValue("curvedDownArrow")
+ CURVED_DOWN_ARROW("curvedDownArrow"),
+
+ /**
+ * Swoosh Arrow Shape
+ *
+ */
+ @XmlEnumValue("swooshArrow")
+ SWOOSH_ARROW("swooshArrow"),
+
+ /**
+ * Cube Shape
+ *
+ */
+ @XmlEnumValue("cube")
+ CUBE("cube"),
+
+ /**
+ * Can Shape
+ *
+ */
+ @XmlEnumValue("can")
+ CAN("can"),
+
+ /**
+ * Lightning Bolt Shape
+ *
+ */
+ @XmlEnumValue("lightningBolt")
+ LIGHTNING_BOLT("lightningBolt"),
+
+ /**
+ * Heart Shape
+ *
+ */
+ @XmlEnumValue("heart")
+ HEART("heart"),
+
+ /**
+ * Sun Shape
+ *
+ */
+ @XmlEnumValue("sun")
+ SUN("sun"),
+
+ /**
+ * Moon Shape
+ *
+ */
+ @XmlEnumValue("moon")
+ MOON("moon"),
+
+ /**
+ * Smiley Face Shape
+ *
+ */
+ @XmlEnumValue("smileyFace")
+ SMILEY_FACE("smileyFace"),
+
+ /**
+ * Irregular Seal 1 Shape
+ *
+ */
+ @XmlEnumValue("irregularSeal1")
+ IRREGULAR_SEAL_1("irregularSeal1"),
+
+ /**
+ * Irregular Seal 2 Shape
+ *
+ */
+ @XmlEnumValue("irregularSeal2")
+ IRREGULAR_SEAL_2("irregularSeal2"),
+
+ /**
+ * Folded Corner Shape
+ *
+ */
+ @XmlEnumValue("foldedCorner")
+ FOLDED_CORNER("foldedCorner"),
+
+ /**
+ * Bevel Shape
+ *
+ */
+ @XmlEnumValue("bevel")
+ BEVEL("bevel"),
+
+ /**
+ * Frame Shape
+ *
+ */
+ @XmlEnumValue("frame")
+ FRAME("frame"),
+
+ /**
+ * Half Frame Shape
+ *
+ */
+ @XmlEnumValue("halfFrame")
+ HALF_FRAME("halfFrame"),
+
+ /**
+ * Corner Shape
+ *
+ */
+ @XmlEnumValue("corner")
+ CORNER("corner"),
+
+ /**
+ * Diagonal Stripe Shape
+ *
+ */
+ @XmlEnumValue("diagStripe")
+ DIAG_STRIPE("diagStripe"),
+
+ /**
+ * Chord Shape
+ *
+ */
+ @XmlEnumValue("chord")
+ CHORD("chord"),
+
+ /**
+ * Curved Arc Shape
+ *
+ */
+ @XmlEnumValue("arc")
+ ARC("arc"),
+
+ /**
+ * Left Bracket Shape
+ *
+ */
+ @XmlEnumValue("leftBracket")
+ LEFT_BRACKET("leftBracket"),
+
+ /**
+ * Right Bracket Shape
+ *
+ */
+ @XmlEnumValue("rightBracket")
+ RIGHT_BRACKET("rightBracket"),
+
+ /**
+ * Left Brace Shape
+ *
+ */
+ @XmlEnumValue("leftBrace")
+ LEFT_BRACE("leftBrace"),
+
+ /**
+ * Right Brace Shape
+ *
+ */
+ @XmlEnumValue("rightBrace")
+ RIGHT_BRACE("rightBrace"),
+
+ /**
+ * Bracket Pair Shape
+ *
+ */
+ @XmlEnumValue("bracketPair")
+ BRACKET_PAIR("bracketPair"),
+
+ /**
+ * Brace Pair Shape
+ *
+ */
+ @XmlEnumValue("bracePair")
+ BRACE_PAIR("bracePair"),
+
+ /**
+ * Straight Connector 1 Shape
+ *
+ */
+ @XmlEnumValue("straightConnector1")
+ STRAIGHT_CONNECTOR_1("straightConnector1"),
+
+ /**
+ * Bent Connector 2 Shape
+ *
+ */
+ @XmlEnumValue("bentConnector2")
+ BENT_CONNECTOR_2("bentConnector2"),
+
+ /**
+ * Bent Connector 3 Shape
+ *
+ */
+ @XmlEnumValue("bentConnector3")
+ BENT_CONNECTOR_3("bentConnector3"),
+
+ /**
+ * Bent Connector 4 Shape
+ *
+ */
+ @XmlEnumValue("bentConnector4")
+ BENT_CONNECTOR_4("bentConnector4"),
+
+ /**
+ * Bent Connector 5 Shape
+ *
+ */
+ @XmlEnumValue("bentConnector5")
+ BENT_CONNECTOR_5("bentConnector5"),
+
+ /**
+ * Curved Connector 2 Shape
+ *
+ */
+ @XmlEnumValue("curvedConnector2")
+ CURVED_CONNECTOR_2("curvedConnector2"),
+
+ /**
+ * Curved Connector 3 Shape
+ *
+ */
+ @XmlEnumValue("curvedConnector3")
+ CURVED_CONNECTOR_3("curvedConnector3"),
+
+ /**
+ * Curved Connector 4 Shape
+ *
+ */
+ @XmlEnumValue("curvedConnector4")
+ CURVED_CONNECTOR_4("curvedConnector4"),
+
+ /**
+ * Curved Connector 5 Shape
+ *
+ */
+ @XmlEnumValue("curvedConnector5")
+ CURVED_CONNECTOR_5("curvedConnector5"),
+
+ /**
+ * Callout 1 Shape
+ *
+ */
+ @XmlEnumValue("callout1")
+ CALLOUT_1("callout1"),
+
+ /**
+ * Callout 2 Shape
+ *
+ */
+ @XmlEnumValue("callout2")
+ CALLOUT_2("callout2"),
+
+ /**
+ * Callout 3 Shape
+ *
+ */
+ @XmlEnumValue("callout3")
+ CALLOUT_3("callout3"),
+
+ /**
+ * Callout 1 Shape
+ *
+ */
+ @XmlEnumValue("accentCallout1")
+ ACCENT_CALLOUT_1("accentCallout1"),
+
+ /**
+ * Callout 2 Shape
+ *
+ */
+ @XmlEnumValue("accentCallout2")
+ ACCENT_CALLOUT_2("accentCallout2"),
+
+ /**
+ * Callout 3 Shape
+ *
+ */
+ @XmlEnumValue("accentCallout3")
+ ACCENT_CALLOUT_3("accentCallout3"),
+
+ /**
+ * Callout 1 with Border Shape
+ *
+ */
+ @XmlEnumValue("borderCallout1")
+ BORDER_CALLOUT_1("borderCallout1"),
+
+ /**
+ * Callout 2 with Border Shape
+ *
+ */
+ @XmlEnumValue("borderCallout2")
+ BORDER_CALLOUT_2("borderCallout2"),
+
+ /**
+ * Callout 3 with Border Shape
+ *
+ */
+ @XmlEnumValue("borderCallout3")
+ BORDER_CALLOUT_3("borderCallout3"),
+
+ /**
+ * Callout 1 with Border and Accent Shape
+ *
+ */
+ @XmlEnumValue("accentBorderCallout1")
+ ACCENT_BORDER_CALLOUT_1("accentBorderCallout1"),
+
+ /**
+ * Callout 2 with Border and Accent Shape
+ *
+ */
+ @XmlEnumValue("accentBorderCallout2")
+ ACCENT_BORDER_CALLOUT_2("accentBorderCallout2"),
+
+ /**
+ * Callout 3 with Border and Accent Shape
+ *
+ */
+ @XmlEnumValue("accentBorderCallout3")
+ ACCENT_BORDER_CALLOUT_3("accentBorderCallout3"),
+
+ /**
+ * Callout Wedge Rectangle Shape
+ *
+ */
+ @XmlEnumValue("wedgeRectCallout")
+ WEDGE_RECT_CALLOUT("wedgeRectCallout"),
+
+ /**
+ * Callout Wedge Round Rectangle Shape
+ *
+ */
+ @XmlEnumValue("wedgeRoundRectCallout")
+ WEDGE_ROUND_RECT_CALLOUT("wedgeRoundRectCallout"),
+
+ /**
+ * Callout Wedge Ellipse Shape
+ *
+ */
+ @XmlEnumValue("wedgeEllipseCallout")
+ WEDGE_ELLIPSE_CALLOUT("wedgeEllipseCallout"),
+
+ /**
+ * Callout Cloud Shape
+ *
+ */
+ @XmlEnumValue("cloudCallout")
+ CLOUD_CALLOUT("cloudCallout"),
+
+ /**
+ * Cloud Shape
+ *
+ */
+ @XmlEnumValue("cloud")
+ CLOUD("cloud"),
+
+ /**
+ * Ribbon Shape
+ *
+ */
+ @XmlEnumValue("ribbon")
+ RIBBON("ribbon"),
+
+ /**
+ * Ribbon 2 Shape
+ *
+ */
+ @XmlEnumValue("ribbon2")
+ RIBBON_2("ribbon2"),
+
+ /**
+ * Ellipse Ribbon Shape
+ *
+ */
+ @XmlEnumValue("ellipseRibbon")
+ ELLIPSE_RIBBON("ellipseRibbon"),
+
+ /**
+ * Ellipse Ribbon 2 Shape
+ *
+ */
+ @XmlEnumValue("ellipseRibbon2")
+ ELLIPSE_RIBBON_2("ellipseRibbon2"),
+
+ /**
+ * Left Right Ribbon Shape
+ *
+ */
+ @XmlEnumValue("leftRightRibbon")
+ LEFT_RIGHT_RIBBON("leftRightRibbon"),
+
+ /**
+ * Vertical Scroll Shape
+ *
+ */
+ @XmlEnumValue("verticalScroll")
+ VERTICAL_SCROLL("verticalScroll"),
+
+ /**
+ * Horizontal Scroll Shape
+ *
+ */
+ @XmlEnumValue("horizontalScroll")
+ HORIZONTAL_SCROLL("horizontalScroll"),
+
+ /**
+ * Wave Shape
+ *
+ */
+ @XmlEnumValue("wave")
+ WAVE("wave"),
+
+ /**
+ * Double Wave Shape
+ *
+ */
+ @XmlEnumValue("doubleWave")
+ DOUBLE_WAVE("doubleWave"),
+
+ /**
+ * Plus Shape
+ *
+ */
+ @XmlEnumValue("plus")
+ PLUS("plus"),
+
+ /**
+ * Process Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartProcess")
+ FLOW_CHART_PROCESS("flowChartProcess"),
+
+ /**
+ * Decision Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartDecision")
+ FLOW_CHART_DECISION("flowChartDecision"),
+
+ /**
+ * Input Output Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartInputOutput")
+ FLOW_CHART_INPUT_OUTPUT("flowChartInputOutput"),
+
+ /**
+ * Predefined Process Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartPredefinedProcess")
+ FLOW_CHART_PREDEFINED_PROCESS("flowChartPredefinedProcess"),
+
+ /**
+ * Internal Storage Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartInternalStorage")
+ FLOW_CHART_INTERNAL_STORAGE("flowChartInternalStorage"),
+
+ /**
+ * Document Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartDocument")
+ FLOW_CHART_DOCUMENT("flowChartDocument"),
+
+ /**
+ * Multi-Document Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartMultidocument")
+ FLOW_CHART_MULTIDOCUMENT("flowChartMultidocument"),
+
+ /**
+ * Terminator Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartTerminator")
+ FLOW_CHART_TERMINATOR("flowChartTerminator"),
+
+ /**
+ * Preparation Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartPreparation")
+ FLOW_CHART_PREPARATION("flowChartPreparation"),
+
+ /**
+ * Manual Input Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartManualInput")
+ FLOW_CHART_MANUAL_INPUT("flowChartManualInput"),
+
+ /**
+ * Manual Operation Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartManualOperation")
+ FLOW_CHART_MANUAL_OPERATION("flowChartManualOperation"),
+
+ /**
+ * Connector Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartConnector")
+ FLOW_CHART_CONNECTOR("flowChartConnector"),
+
+ /**
+ * Punched Card Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartPunchedCard")
+ FLOW_CHART_PUNCHED_CARD("flowChartPunchedCard"),
+
+ /**
+ * Punched Tape Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartPunchedTape")
+ FLOW_CHART_PUNCHED_TAPE("flowChartPunchedTape"),
+
+ /**
+ * Summing Junction Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartSummingJunction")
+ FLOW_CHART_SUMMING_JUNCTION("flowChartSummingJunction"),
+
+ /**
+ * Or Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartOr")
+ FLOW_CHART_OR("flowChartOr"),
+
+ /**
+ * Collate Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartCollate")
+ FLOW_CHART_COLLATE("flowChartCollate"),
+
+ /**
+ * Sort Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartSort")
+ FLOW_CHART_SORT("flowChartSort"),
+
+ /**
+ * Extract Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartExtract")
+ FLOW_CHART_EXTRACT("flowChartExtract"),
+
+ /**
+ * Merge Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartMerge")
+ FLOW_CHART_MERGE("flowChartMerge"),
+
+ /**
+ * Offline Storage Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartOfflineStorage")
+ FLOW_CHART_OFFLINE_STORAGE("flowChartOfflineStorage"),
+
+ /**
+ * Online Storage Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartOnlineStorage")
+ FLOW_CHART_ONLINE_STORAGE("flowChartOnlineStorage"),
+
+ /**
+ * Magnetic Tape Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartMagneticTape")
+ FLOW_CHART_MAGNETIC_TAPE("flowChartMagneticTape"),
+
+ /**
+ * Magnetic Disk Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartMagneticDisk")
+ FLOW_CHART_MAGNETIC_DISK("flowChartMagneticDisk"),
+
+ /**
+ * Magnetic Drum Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartMagneticDrum")
+ FLOW_CHART_MAGNETIC_DRUM("flowChartMagneticDrum"),
+
+ /**
+ * Display Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartDisplay")
+ FLOW_CHART_DISPLAY("flowChartDisplay"),
+
+ /**
+ * Delay Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartDelay")
+ FLOW_CHART_DELAY("flowChartDelay"),
+
+ /**
+ * Alternate Process Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartAlternateProcess")
+ FLOW_CHART_ALTERNATE_PROCESS("flowChartAlternateProcess"),
+
+ /**
+ * Off-Page Connector Flow Shape
+ *
+ */
+ @XmlEnumValue("flowChartOffpageConnector")
+ FLOW_CHART_OFFPAGE_CONNECTOR("flowChartOffpageConnector"),
+
+ /**
+ * Blank Button Shape
+ *
+ */
+ @XmlEnumValue("actionButtonBlank")
+ ACTION_BUTTON_BLANK("actionButtonBlank"),
+
+ /**
+ * Home Button Shape
+ *
+ */
+ @XmlEnumValue("actionButtonHome")
+ ACTION_BUTTON_HOME("actionButtonHome"),
+
+ /**
+ * Help Button Shape
+ *
+ */
+ @XmlEnumValue("actionButtonHelp")
+ ACTION_BUTTON_HELP("actionButtonHelp"),
+
+ /**
+ * Information Button Shape
+ *
+ */
+ @XmlEnumValue("actionButtonInformation")
+ ACTION_BUTTON_INFORMATION("actionButtonInformation"),
+
+ /**
+ * Forward or Next Button Shape
+ *
+ */
+ @XmlEnumValue("actionButtonForwardNext")
+ ACTION_BUTTON_FORWARD_NEXT("actionButtonForwardNext"),
+
+ /**
+ * Back or Previous Button Shape
+ *
+ */
+ @XmlEnumValue("actionButtonBackPrevious")
+ ACTION_BUTTON_BACK_PREVIOUS("actionButtonBackPrevious"),
+
+ /**
+ * End Button Shape
+ *
+ */
+ @XmlEnumValue("actionButtonEnd")
+ ACTION_BUTTON_END("actionButtonEnd"),
+
+ /**
+ * Beginning Button Shape
+ *
+ */
+ @XmlEnumValue("actionButtonBeginning")
+ ACTION_BUTTON_BEGINNING("actionButtonBeginning"),
+
+ /**
+ * Return Button Shape
+ *
+ */
+ @XmlEnumValue("actionButtonReturn")
+ ACTION_BUTTON_RETURN("actionButtonReturn"),
+
+ /**
+ * Document Button Shape
+ *
+ */
+ @XmlEnumValue("actionButtonDocument")
+ ACTION_BUTTON_DOCUMENT("actionButtonDocument"),
+
+ /**
+ * Sound Button Shape
+ *
+ */
+ @XmlEnumValue("actionButtonSound")
+ ACTION_BUTTON_SOUND("actionButtonSound"),
+
+ /**
+ * Movie Button Shape
+ *
+ */
+ @XmlEnumValue("actionButtonMovie")
+ ACTION_BUTTON_MOVIE("actionButtonMovie"),
+
+ /**
+ * Gear 6 Shape
+ *
+ */
+ @XmlEnumValue("gear6")
+ GEAR_6("gear6"),
+
+ /**
+ * Gear 9 Shape
+ *
+ */
+ @XmlEnumValue("gear9")
+ GEAR_9("gear9"),
+
+ /**
+ * Funnel Shape
+ *
+ */
+ @XmlEnumValue("funnel")
+ FUNNEL("funnel"),
+
+ /**
+ * Plus Math Shape
+ *
+ */
+ @XmlEnumValue("mathPlus")
+ MATH_PLUS("mathPlus"),
+
+ /**
+ * Minus Math Shape
+ *
+ */
+ @XmlEnumValue("mathMinus")
+ MATH_MINUS("mathMinus"),
+
+ /**
+ * Multiply Math Shape
+ *
+ */
+ @XmlEnumValue("mathMultiply")
+ MATH_MULTIPLY("mathMultiply"),
+
+ /**
+ * Divide Math Shape
+ *
+ */
+ @XmlEnumValue("mathDivide")
+ MATH_DIVIDE("mathDivide"),
+
+ /**
+ * Equal Math Shape
+ *
+ */
+ @XmlEnumValue("mathEqual")
+ MATH_EQUAL("mathEqual"),
+
+ /**
+ * Not Equal Math Shape
+ *
+ */
+ @XmlEnumValue("mathNotEqual")
+ MATH_NOT_EQUAL("mathNotEqual"),
+
+ /**
+ * Corner Tabs Shape
+ *
+ */
+ @XmlEnumValue("cornerTabs")
+ CORNER_TABS("cornerTabs"),
+
+ /**
+ * Square Tabs Shape
+ *
+ */
+ @XmlEnumValue("squareTabs")
+ SQUARE_TABS("squareTabs"),
+
+ /**
+ * Plaque Tabs Shape
+ *
+ */
+ @XmlEnumValue("plaqueTabs")
+ PLAQUE_TABS("plaqueTabs"),
+
+ /**
+ * Chart X Shape
+ *
+ */
+ @XmlEnumValue("chartX")
+ CHART_X("chartX"),
+
+ /**
+ * Chart Star Shape
+ *
+ */
+ @XmlEnumValue("chartStar")
+ CHART_STAR("chartStar"),
+
+ /**
+ * Chart Plus Shape
+ *
+ */
+ @XmlEnumValue("chartPlus")
+ CHART_PLUS("chartPlus");
+ private final String value;
+
+ STShapeType(String v) {
+ value = v;
+ }
+
+ public String value() {
+ return value;
+ }
+
+ public static STShapeType fromValue(String v) {
+ for (STShapeType c: STShapeType.values()) {
+ if (c.value.equals(v)) {
+ return c;
+ }
+ }
+ throw new IllegalArgumentException(v);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/binding/STTextShapeType.java b/src/java/org/apache/poi/sl/draw/binding/STTextShapeType.java new file mode 100644 index 0000000000..f3ed4b0cf7 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/binding/STTextShapeType.java @@ -0,0 +1,389 @@ +/* ====================================================================
+ 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.sl.draw.binding;
+
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlEnumValue;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for ST_TextShapeType.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * <p>
+ * <pre>
+ * <simpleType name="ST_TextShapeType">
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}token">
+ * <enumeration value="textNoShape"/>
+ * <enumeration value="textPlain"/>
+ * <enumeration value="textStop"/>
+ * <enumeration value="textTriangle"/>
+ * <enumeration value="textTriangleInverted"/>
+ * <enumeration value="textChevron"/>
+ * <enumeration value="textChevronInverted"/>
+ * <enumeration value="textRingInside"/>
+ * <enumeration value="textRingOutside"/>
+ * <enumeration value="textArchUp"/>
+ * <enumeration value="textArchDown"/>
+ * <enumeration value="textCircle"/>
+ * <enumeration value="textButton"/>
+ * <enumeration value="textArchUpPour"/>
+ * <enumeration value="textArchDownPour"/>
+ * <enumeration value="textCirclePour"/>
+ * <enumeration value="textButtonPour"/>
+ * <enumeration value="textCurveUp"/>
+ * <enumeration value="textCurveDown"/>
+ * <enumeration value="textCanUp"/>
+ * <enumeration value="textCanDown"/>
+ * <enumeration value="textWave1"/>
+ * <enumeration value="textWave2"/>
+ * <enumeration value="textDoubleWave1"/>
+ * <enumeration value="textWave4"/>
+ * <enumeration value="textInflate"/>
+ * <enumeration value="textDeflate"/>
+ * <enumeration value="textInflateBottom"/>
+ * <enumeration value="textDeflateBottom"/>
+ * <enumeration value="textInflateTop"/>
+ * <enumeration value="textDeflateTop"/>
+ * <enumeration value="textDeflateInflate"/>
+ * <enumeration value="textDeflateInflateDeflate"/>
+ * <enumeration value="textFadeRight"/>
+ * <enumeration value="textFadeLeft"/>
+ * <enumeration value="textFadeUp"/>
+ * <enumeration value="textFadeDown"/>
+ * <enumeration value="textSlantUp"/>
+ * <enumeration value="textSlantDown"/>
+ * <enumeration value="textCascadeUp"/>
+ * <enumeration value="textCascadeDown"/>
+ * </restriction>
+ * </simpleType>
+ * </pre>
+ *
+ */
+@XmlType(name = "ST_TextShapeType", namespace = "http://schemas.openxmlformats.org/drawingml/2006/main")
+@XmlEnum
+public enum STTextShapeType {
+
+
+ /**
+ * No Text Shape
+ *
+ */
+ @XmlEnumValue("textNoShape")
+ TEXT_NO_SHAPE("textNoShape"),
+
+ /**
+ * Plain Text Shape
+ *
+ */
+ @XmlEnumValue("textPlain")
+ TEXT_PLAIN("textPlain"),
+
+ /**
+ * Stop Sign Text Shape
+ *
+ */
+ @XmlEnumValue("textStop")
+ TEXT_STOP("textStop"),
+
+ /**
+ * Triangle Text Shape
+ *
+ */
+ @XmlEnumValue("textTriangle")
+ TEXT_TRIANGLE("textTriangle"),
+
+ /**
+ * Inverted Triangle Text Shape
+ *
+ */
+ @XmlEnumValue("textTriangleInverted")
+ TEXT_TRIANGLE_INVERTED("textTriangleInverted"),
+
+ /**
+ * Chevron Text Shape
+ *
+ */
+ @XmlEnumValue("textChevron")
+ TEXT_CHEVRON("textChevron"),
+
+ /**
+ * Inverted Chevron Text Shape
+ *
+ */
+ @XmlEnumValue("textChevronInverted")
+ TEXT_CHEVRON_INVERTED("textChevronInverted"),
+
+ /**
+ * Inside Ring Text Shape
+ *
+ */
+ @XmlEnumValue("textRingInside")
+ TEXT_RING_INSIDE("textRingInside"),
+
+ /**
+ * Outside Ring Text Shape
+ *
+ */
+ @XmlEnumValue("textRingOutside")
+ TEXT_RING_OUTSIDE("textRingOutside"),
+
+ /**
+ * Upward Arch Text Shape
+ *
+ */
+ @XmlEnumValue("textArchUp")
+ TEXT_ARCH_UP("textArchUp"),
+
+ /**
+ * Downward Arch Text Shape
+ *
+ */
+ @XmlEnumValue("textArchDown")
+ TEXT_ARCH_DOWN("textArchDown"),
+
+ /**
+ * Circle Text Shape
+ *
+ */
+ @XmlEnumValue("textCircle")
+ TEXT_CIRCLE("textCircle"),
+
+ /**
+ * Button Text Shape
+ *
+ */
+ @XmlEnumValue("textButton")
+ TEXT_BUTTON("textButton"),
+
+ /**
+ * Upward Pour Arch Text Shape
+ *
+ */
+ @XmlEnumValue("textArchUpPour")
+ TEXT_ARCH_UP_POUR("textArchUpPour"),
+
+ /**
+ * Downward Pour Arch Text Shape
+ *
+ */
+ @XmlEnumValue("textArchDownPour")
+ TEXT_ARCH_DOWN_POUR("textArchDownPour"),
+
+ /**
+ * Circle Pour Text Shape
+ *
+ */
+ @XmlEnumValue("textCirclePour")
+ TEXT_CIRCLE_POUR("textCirclePour"),
+
+ /**
+ * Button Pour Text Shape
+ *
+ */
+ @XmlEnumValue("textButtonPour")
+ TEXT_BUTTON_POUR("textButtonPour"),
+
+ /**
+ * Upward Curve Text Shape
+ *
+ */
+ @XmlEnumValue("textCurveUp")
+ TEXT_CURVE_UP("textCurveUp"),
+
+ /**
+ * Downward Curve Text Shape
+ *
+ */
+ @XmlEnumValue("textCurveDown")
+ TEXT_CURVE_DOWN("textCurveDown"),
+
+ /**
+ * Upward Can Text Shape
+ *
+ */
+ @XmlEnumValue("textCanUp")
+ TEXT_CAN_UP("textCanUp"),
+
+ /**
+ * Downward Can Text Shape
+ *
+ */
+ @XmlEnumValue("textCanDown")
+ TEXT_CAN_DOWN("textCanDown"),
+
+ /**
+ * Wave 1 Text Shape
+ *
+ */
+ @XmlEnumValue("textWave1")
+ TEXT_WAVE_1("textWave1"),
+
+ /**
+ * Wave 2 Text Shape
+ *
+ */
+ @XmlEnumValue("textWave2")
+ TEXT_WAVE_2("textWave2"),
+
+ /**
+ * Double Wave 1 Text Shape
+ *
+ */
+ @XmlEnumValue("textDoubleWave1")
+ TEXT_DOUBLE_WAVE_1("textDoubleWave1"),
+
+ /**
+ * Wave 4 Text Shape
+ *
+ */
+ @XmlEnumValue("textWave4")
+ TEXT_WAVE_4("textWave4"),
+
+ /**
+ * Inflate Text Shape
+ *
+ */
+ @XmlEnumValue("textInflate")
+ TEXT_INFLATE("textInflate"),
+
+ /**
+ * Deflate Text Shape
+ *
+ */
+ @XmlEnumValue("textDeflate")
+ TEXT_DEFLATE("textDeflate"),
+
+ /**
+ * Bottom Inflate Text Shape
+ *
+ */
+ @XmlEnumValue("textInflateBottom")
+ TEXT_INFLATE_BOTTOM("textInflateBottom"),
+
+ /**
+ * Bottom Deflate Text Shape
+ *
+ */
+ @XmlEnumValue("textDeflateBottom")
+ TEXT_DEFLATE_BOTTOM("textDeflateBottom"),
+
+ /**
+ * Top Inflate Text Shape
+ *
+ */
+ @XmlEnumValue("textInflateTop")
+ TEXT_INFLATE_TOP("textInflateTop"),
+
+ /**
+ * Top Deflate Text Shape
+ *
+ */
+ @XmlEnumValue("textDeflateTop")
+ TEXT_DEFLATE_TOP("textDeflateTop"),
+
+ /**
+ * Deflate-Inflate Text Shape
+ *
+ */
+ @XmlEnumValue("textDeflateInflate")
+ TEXT_DEFLATE_INFLATE("textDeflateInflate"),
+
+ /**
+ * Deflate-Inflate-Deflate Text Shape
+ *
+ */
+ @XmlEnumValue("textDeflateInflateDeflate")
+ TEXT_DEFLATE_INFLATE_DEFLATE("textDeflateInflateDeflate"),
+
+ /**
+ * Right Fade Text Shape
+ *
+ */
+ @XmlEnumValue("textFadeRight")
+ TEXT_FADE_RIGHT("textFadeRight"),
+
+ /**
+ * Left Fade Text Shape
+ *
+ */
+ @XmlEnumValue("textFadeLeft")
+ TEXT_FADE_LEFT("textFadeLeft"),
+
+ /**
+ * Upward Fade Text Shape
+ *
+ */
+ @XmlEnumValue("textFadeUp")
+ TEXT_FADE_UP("textFadeUp"),
+
+ /**
+ * Downward Fade Text Shape
+ *
+ */
+ @XmlEnumValue("textFadeDown")
+ TEXT_FADE_DOWN("textFadeDown"),
+
+ /**
+ * Upward Slant Text Shape
+ *
+ */
+ @XmlEnumValue("textSlantUp")
+ TEXT_SLANT_UP("textSlantUp"),
+
+ /**
+ * Downward Slant Text Shape
+ *
+ */
+ @XmlEnumValue("textSlantDown")
+ TEXT_SLANT_DOWN("textSlantDown"),
+
+ /**
+ * Upward Cascade Text Shape
+ *
+ */
+ @XmlEnumValue("textCascadeUp")
+ TEXT_CASCADE_UP("textCascadeUp"),
+
+ /**
+ * Downward Cascade Text Shape
+ *
+ */
+ @XmlEnumValue("textCascadeDown")
+ TEXT_CASCADE_DOWN("textCascadeDown");
+ private final String value;
+
+ STTextShapeType(String v) {
+ value = v;
+ }
+
+ public String value() {
+ return value;
+ }
+
+ public static STTextShapeType fromValue(String v) {
+ for (STTextShapeType c: STTextShapeType.values()) {
+ if (c.value.equals(v)) {
+ return c;
+ }
+ }
+ throw new IllegalArgumentException(v);
+ }
+
+}
diff --git a/src/java/org/apache/poi/sl/draw/geom/AbsExpression.java b/src/java/org/apache/poi/sl/draw/geom/AbsExpression.java new file mode 100644 index 0000000000..0f94e14b6a --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/AbsExpression.java @@ -0,0 +1,41 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.util.regex.Matcher; + +/** + * Absolute Value Formula + * + * @author Yegor Kozlov + */ +public class AbsExpression implements Expression { + private String arg; + + AbsExpression(Matcher m){ + arg = m.group(1); + } + + public double evaluate(Context ctx){ + double val = ctx.getValue(arg); + return Math.abs(val); + } + +} diff --git a/src/java/org/apache/poi/sl/draw/geom/AddDivideExpression.java b/src/java/org/apache/poi/sl/draw/geom/AddDivideExpression.java new file mode 100644 index 0000000000..2a01de449e --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/AddDivideExpression.java @@ -0,0 +1,45 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.util.regex.Matcher; + +/** + * Add Divide Formula + * + * @author Yegor Kozlov + */ +public class AddDivideExpression implements Expression { + private String arg1, arg2, arg3; + + AddDivideExpression(Matcher m){ + arg1 = m.group(1); + arg2 = m.group(2); + arg3 = m.group(3); + } + + public double evaluate(Context ctx){ + double x = ctx.getValue(arg1); + double y = ctx.getValue(arg2); + double z = ctx.getValue(arg3); + return (x + y ) / z; + } + +} diff --git a/src/java/org/apache/poi/sl/draw/geom/AddSubtractExpression.java b/src/java/org/apache/poi/sl/draw/geom/AddSubtractExpression.java new file mode 100644 index 0000000000..5d5f1e6357 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/AddSubtractExpression.java @@ -0,0 +1,45 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.util.regex.Matcher; + +/** + * Add Subtract Formula + * + * @author Yegor Kozlov + */ +public class AddSubtractExpression implements Expression { + private String arg1, arg2, arg3; + + AddSubtractExpression(Matcher m){ + arg1 = m.group(1); + arg2 = m.group(2); + arg3 = m.group(3); + } + + public double evaluate(Context ctx){ + double x = ctx.getValue(arg1); + double y = ctx.getValue(arg2); + double z = ctx.getValue(arg3); + return (x + y ) - z; + } + +} diff --git a/src/java/org/apache/poi/sl/draw/geom/AdjustValue.java b/src/java/org/apache/poi/sl/draw/geom/AdjustValue.java new file mode 100644 index 0000000000..8a2f0a4566 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/AdjustValue.java @@ -0,0 +1,45 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import org.apache.poi.sl.draw.binding.CTGeomGuide; + +/** + * Represents a shape adjust values (see section 20.1.9.5 in the spec) + * + * @author Yegor Kozlov + */ +public class AdjustValue extends Guide { + + public AdjustValue(CTGeomGuide gd) { + super(gd.getName(), gd.getFmla()); + } + + @Override + public double evaluate(Context ctx){ + String name = getName(); + Guide adj = ctx.getAdjustValue(name); + if(adj != null) { + return adj.evaluate(ctx); + } + return super.evaluate(ctx); + } + +} diff --git a/src/java/org/apache/poi/sl/draw/geom/ArcTanExpression.java b/src/java/org/apache/poi/sl/draw/geom/ArcTanExpression.java new file mode 100644 index 0000000000..9044e8ad3a --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/ArcTanExpression.java @@ -0,0 +1,43 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.util.regex.Matcher; + +/** + * Date: 10/24/11 + * + * @author Yegor Kozlov + */ +public class ArcTanExpression implements Expression { + private String arg1, arg2; + + ArcTanExpression(Matcher m){ + arg1 = m.group(1); + arg2 = m.group(2); + } + + public double evaluate(Context ctx){ + double x = ctx.getValue(arg1); + double y = ctx.getValue(arg2); + return Math.atan(y / x); + } + +} diff --git a/src/java/org/apache/poi/sl/draw/geom/ArcToCommand.java b/src/java/org/apache/poi/sl/draw/geom/ArcToCommand.java new file mode 100644 index 0000000000..0382d7f997 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/ArcToCommand.java @@ -0,0 +1,68 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import org.apache.poi.sl.draw.binding.CTPath2DArcTo; + +import java.awt.geom.Arc2D; +import java.awt.geom.GeneralPath; +import java.awt.geom.Point2D; + +/** + * ArcTo command within a shape path in DrawingML: + * + * <arcTo wR="wr" hR="hr" stAng="stAng" swAng="swAng"/> + * + * Where <code>wr</code> and <code>wh</code> are the height and width radiuses + * of the supposed circle being used to draw the arc. This gives the circle + * a total height of (2 * hR) and a total width of (2 * wR) + * + * stAng is the <code>start</code> angle and <code></>swAng</code> is the swing angle + * + * @author Yegor Kozlov + */ +public class ArcToCommand implements PathCommand { + private String hr, wr, stAng, swAng; + + ArcToCommand(CTPath2DArcTo arc){ + hr = arc.getHR().toString(); + wr = arc.getWR().toString(); + stAng = arc.getStAng().toString(); + swAng = arc.getSwAng().toString(); + } + + public void execute(GeneralPath path, Context ctx){ + double rx = ctx.getValue(wr); + double ry = ctx.getValue(hr); + double start = ctx.getValue(stAng) / 60000; + double extent = ctx.getValue(swAng) / 60000; + Point2D pt = path.getCurrentPoint(); + double x0 = pt.getX() - rx - rx * Math.cos(Math.toRadians(start)); + double y0 = pt.getY() - ry - ry * Math.sin(Math.toRadians(start)); + + Arc2D arc = new Arc2D.Double( + x0, + y0, + 2 * rx, 2 * ry, + -start, -extent, + Arc2D.OPEN); + path.append(arc, true); + } +} diff --git a/src/java/org/apache/poi/sl/draw/geom/ClosePathCommand.java b/src/java/org/apache/poi/sl/draw/geom/ClosePathCommand.java new file mode 100644 index 0000000000..9d29062806 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/ClosePathCommand.java @@ -0,0 +1,37 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.awt.geom.GeneralPath; + +/** + * Date: 10/25/11 + * + * @author Yegor Kozlov + */ +public class ClosePathCommand implements PathCommand { + + ClosePathCommand(){ + } + + public void execute(GeneralPath path, Context ctx){ + path.closePath(); + } +} diff --git a/src/java/org/apache/poi/sl/draw/geom/Context.java b/src/java/org/apache/poi/sl/draw/geom/Context.java new file mode 100644 index 0000000000..8fd5147ed2 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/Context.java @@ -0,0 +1,74 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.awt.geom.Rectangle2D; +import java.util.HashMap; +import java.util.Map; + +/** + * Date: 10/24/11 + * + * @author Yegor Kozlov + */ +public class Context { + final Map<String, Double> _ctx = new HashMap<String, Double>(); + final IAdjustableShape _props; + final Rectangle2D _anchor; + + public Context(CustomGeometry geom, Rectangle2D anchor, IAdjustableShape props){ + _props = props; + _anchor = anchor; + for(Guide gd : geom.adjusts) evaluate(gd); + for(Guide gd : geom.guides) evaluate(gd); + } + + public Rectangle2D getShapeAnchor(){ + return _anchor; + } + + public Guide getAdjustValue(String name){ + return _props.getAdjustValue(name); + } + + public double getValue(String key){ + if(key.matches("(\\+|-)?\\d+")){ + return Double.parseDouble(key); + } + + Formula builtIn = Formula.builtInFormulas.get(key); + if(builtIn != null){ + return builtIn.evaluate(this); + } + + if(!_ctx.containsKey(key)) { + throw new RuntimeException("undefined variable: " + key); + } + + return _ctx.get(key); + } + + public double evaluate(Formula fmla){ + double result = fmla.evaluate(this); + String key = fmla.getName(); + if(key != null) _ctx.put(key, result); + return result; + } +} diff --git a/src/java/org/apache/poi/sl/draw/geom/CosExpression.java b/src/java/org/apache/poi/sl/draw/geom/CosExpression.java new file mode 100644 index 0000000000..56373d9193 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/CosExpression.java @@ -0,0 +1,43 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.util.regex.Matcher; + +/** + * Date: 10/24/11 + * + * @author Yegor Kozlov + */ +public class CosExpression implements Expression { + private String arg1, arg2; + + CosExpression(Matcher m){ + arg1 = m.group(1); + arg2 = m.group(2); + } + + public double evaluate(Context ctx){ + double x = ctx.getValue(arg1); + double y = ctx.getValue(arg2)/ 60000; + return x * Math.cos(Math.toRadians(y)); + } + +} diff --git a/src/java/org/apache/poi/sl/draw/geom/CosineArcTanExpression.java b/src/java/org/apache/poi/sl/draw/geom/CosineArcTanExpression.java new file mode 100644 index 0000000000..4bed9b72d1 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/CosineArcTanExpression.java @@ -0,0 +1,45 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.util.regex.Matcher; + +/** + * Date: 10/24/11 + * + * @author Yegor Kozlov + */ +public class CosineArcTanExpression implements Expression { + private String arg1, arg2, arg3; + + CosineArcTanExpression(Matcher m){ + arg1 = m.group(1); + arg2 = m.group(2); + arg3 = m.group(3); + } + + public double evaluate(Context ctx){ + double x = ctx.getValue(arg1); + double y = ctx.getValue(arg2); + double z = ctx.getValue(arg3); + return x*Math.cos(Math.atan(z / y)); + } + +} diff --git a/src/java/org/apache/poi/sl/draw/geom/CurveToCommand.java b/src/java/org/apache/poi/sl/draw/geom/CurveToCommand.java new file mode 100644 index 0000000000..02eeb2953e --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/CurveToCommand.java @@ -0,0 +1,52 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import org.apache.poi.sl.draw.binding.CTAdjPoint2D; + +import java.awt.geom.GeneralPath; + +/** + * Date: 10/25/11 + * + * @author Yegor Kozlov + */ +public class CurveToCommand implements PathCommand { + private String arg1, arg2, arg3, arg4, arg5, arg6; + + CurveToCommand(CTAdjPoint2D pt1, CTAdjPoint2D pt2, CTAdjPoint2D pt3){ + arg1 = pt1.getX().toString(); + arg2 = pt1.getY().toString(); + arg3 = pt2.getX().toString(); + arg4 = pt2.getY().toString(); + arg5 = pt3.getX().toString(); + arg6 = pt3.getY().toString(); + } + + public void execute(GeneralPath path, Context ctx){ + double x1 = ctx.getValue(arg1); + double y1 = ctx.getValue(arg2); + double x2 = ctx.getValue(arg3); + double y2 = ctx.getValue(arg4); + double x3 = ctx.getValue(arg5); + double y3 = ctx.getValue(arg6); + path.curveTo((float)x1, (float)y1, (float)x2, (float)y2, (float)x3, (float)y3); + } +} diff --git a/src/java/org/apache/poi/sl/draw/geom/CustomGeometry.java b/src/java/org/apache/poi/sl/draw/geom/CustomGeometry.java new file mode 100644 index 0000000000..ce1b26c498 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/CustomGeometry.java @@ -0,0 +1,82 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.util.*; + +import org.apache.poi.sl.draw.binding.*; + +/** + * Definition of a custom geometric shape + * + * @author Yegor Kozlov + */ +public class CustomGeometry implements Iterable<Path>{ + List<Guide> adjusts = new ArrayList<Guide>(); + List<Guide> guides = new ArrayList<Guide>(); + List<Path> paths = new ArrayList<Path>(); + Path textBounds; + + public CustomGeometry(CTCustomGeometry2D geom) { + CTGeomGuideList avLst = geom.getAvLst(); + if(avLst != null) { + for(CTGeomGuide gd : avLst.getGd()){ + adjusts.add(new AdjustValue(gd)); + } + } + + CTGeomGuideList gdLst = geom.getGdLst(); + if(gdLst != null) { + for(CTGeomGuide gd : gdLst.getGd()){ + guides.add(new Guide(gd)); + } + } + + CTPath2DList pathLst = geom.getPathLst(); + if(pathLst != null) { + for(CTPath2D spPath : pathLst.getPath()){ + paths.add(new Path(spPath)); + } + } + + CTGeomRect rect = geom.getRect(); + if(rect != null) { + textBounds = new Path(); + textBounds.addCommand( + new MoveToCommand(rect.getL().toString(), rect.getT().toString())); + textBounds.addCommand( + new LineToCommand(rect.getR().toString(), rect.getT().toString())); + textBounds.addCommand( + new LineToCommand(rect.getR().toString(), rect.getB().toString())); + textBounds.addCommand( + new LineToCommand(rect.getL().toString(), rect.getB().toString())); + textBounds.addCommand( + new ClosePathCommand()); + } + } + + public Iterator<Path> iterator() { + return paths.iterator(); + } + + public Path getTextBounds(){ + return textBounds; + } +} diff --git a/src/java/org/apache/poi/sl/draw/geom/Expression.java b/src/java/org/apache/poi/sl/draw/geom/Expression.java new file mode 100644 index 0000000000..2403c85a05 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/Expression.java @@ -0,0 +1,31 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +/** + * Date: 10/24/11 + * + * @author Yegor Kozlov + */ +public interface Expression { + + double evaluate(Context ctx); + +} diff --git a/src/java/org/apache/poi/sl/draw/geom/ExpressionParser.java b/src/java/org/apache/poi/sl/draw/geom/ExpressionParser.java new file mode 100644 index 0000000000..f1f0193a89 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/ExpressionParser.java @@ -0,0 +1,69 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.util.HashMap; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * A simple regexp-based parser of shape guide formulas in DrawingML + * + * @author Yegor Kozlov + */ +public class ExpressionParser { + static final HashMap<String, Class> impls = new HashMap<String, Class>(); + static { + impls.put("\\*/ +([\\-\\w]+) +([\\-\\w]+) +([\\-\\w]+)", MultiplyDivideExpression.class); + impls.put("\\+- +([\\-\\w]+) +([\\-\\w]+) +([\\-\\w]+)( 0)?", AddSubtractExpression.class); + impls.put("\\+/ +([\\-\\w]+) +([\\-\\w]+) +([\\-\\w]+)", AddDivideExpression.class); + impls.put("\\?: +([\\-\\w]+) +([\\-\\w]+) +([\\-\\w]+)", IfElseExpression.class); + impls.put("val +([\\-\\w]+)", LiteralValueExpression.class); + impls.put("abs +([\\-\\w]+)", AbsExpression.class); + impls.put("sqrt +([\\-\\w]+)", SqrtExpression.class); + impls.put("max +([\\-\\w]+) +([\\-\\w]+)", MaxExpression.class); + impls.put("min +([\\-\\w]+) +([\\-\\w]+)", MinExpression.class); + impls.put("at2 +([\\-\\w]+) +([\\-\\w]+)", ArcTanExpression.class); + impls.put("sin +([\\-\\w]+) +([\\-\\w]+)", SinExpression.class); + impls.put("cos +([\\-\\w]+) +([\\-\\w]+)", CosExpression.class); + impls.put("tan +([\\-\\w]+) +([\\-\\w]+)", TanExpression.class); + impls.put("cat2 +([\\-\\w]+) +([\\-\\w]+) +([\\-\\w]+)", CosineArcTanExpression.class); + impls.put("sat2 +([\\-\\w]+) +([\\-\\w]+) +([\\-\\w]+)", SinArcTanExpression.class); + impls.put("pin +([\\-\\w]+) +([\\-\\w]+) +([\\-\\w]+)", PinExpression.class); + impls.put("mod +([\\-\\w]+) +([\\-\\w]+) +([\\-\\w]+)", ModExpression.class); + + } + + public static Expression parse(String str){ + for(String regexp : impls.keySet()) { + Pattern ptrn = Pattern.compile(regexp); + Matcher m = ptrn.matcher(str); + if(m.matches()) { + Class c = impls.get(regexp); + try { + return (Expression)c.getDeclaredConstructor(Matcher.class).newInstance(m); + } catch (Exception e){ + throw new RuntimeException(e); + } + } + } + throw new RuntimeException("Unsupported formula: " + str); + } +} diff --git a/src/java/org/apache/poi/sl/draw/geom/Formula.java b/src/java/org/apache/poi/sl/draw/geom/Formula.java new file mode 100644 index 0000000000..47453475af --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/Formula.java @@ -0,0 +1,385 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.awt.geom.Rectangle2D; +import java.util.HashMap; +import java.util.Map; + +/** + * A guide formula in DrawingML. + * This is a base class for adjust values, geometric guides and bilt-in guides + * + * @author Yegor Kozlov + */ +public abstract class Formula { + + String getName(){ + return null; + } + + abstract double evaluate(Context ctx); + + static Map<String, Formula> builtInFormulas = new HashMap<String, Formula>(); + static { + // 3 x 360 / 4 = 270 + builtInFormulas.put("3cd4", new Formula(){ + @Override + double evaluate(Context ctx){ + return 270 * 60000; + } + + }); + + // 3 x 360 / 8 = 135 + builtInFormulas.put("3cd8", new Formula(){ + @Override + double evaluate(Context ctx){ + return 135 * 60000; + } + + }); + + // 5 x 360 / 8 = 225 + builtInFormulas.put("5cd8", new Formula(){ + @Override + double evaluate(Context ctx){ + return 270 * 60000; + } + + }); + + // 7 x 360 / 8 = 315 + builtInFormulas.put("7cd8", new Formula(){ + @Override + double evaluate(Context ctx){ + return 270 * 60000; + } + + }); + + // bottom + builtInFormulas.put("b", new Formula(){ + @Override + double evaluate(Context ctx){ + Rectangle2D anchor = ctx.getShapeAnchor(); + return anchor.getY() + anchor.getHeight(); + } + + }); + + // 360 / 2 = 180 + builtInFormulas.put("cd2", new Formula(){ + @Override + double evaluate(Context ctx){ + return 180 * 60000; + } + + }); + + // 360 / 4 = 90 + builtInFormulas.put("cd4", new Formula(){ + @Override + double evaluate(Context ctx){ + return 90 * 60000; + } + + }); + + // 360 / 8 = 45 + builtInFormulas.put("cd8", new Formula(){ + @Override + double evaluate(Context ctx){ + return 45 * 60000; + } + + }); + + // horizontal center + builtInFormulas.put("hc", new Formula(){ + @Override + double evaluate(Context ctx){ + Rectangle2D anchor = ctx.getShapeAnchor(); + return anchor.getX() + anchor.getWidth()/2; + } + + }); + + // height + builtInFormulas.put("h", new Formula(){ + @Override + double evaluate(Context ctx){ + Rectangle2D anchor = ctx.getShapeAnchor(); + return anchor.getHeight(); + } + + }); + + // height / 2 + builtInFormulas.put("hd2", new Formula(){ + @Override + double evaluate(Context ctx){ + Rectangle2D anchor = ctx.getShapeAnchor(); + return anchor.getHeight()/2; + } + + }); + + // height / 3 + builtInFormulas.put("hd3", new Formula(){ + @Override + double evaluate(Context ctx){ + Rectangle2D anchor = ctx.getShapeAnchor(); + return anchor.getHeight()/3; + } + + }); + + // height / 4 + builtInFormulas.put("hd4", new Formula(){ + @Override + double evaluate(Context ctx){ + Rectangle2D anchor = ctx.getShapeAnchor(); + return anchor.getHeight()/4; + } + + }); + + // height / 5 + builtInFormulas.put("hd5", new Formula(){ + @Override + double evaluate(Context ctx){ + Rectangle2D anchor = ctx.getShapeAnchor(); + return anchor.getHeight()/5; + } + + }); + + // height / 6 + builtInFormulas.put("hd6", new Formula(){ + @Override + double evaluate(Context ctx){ + Rectangle2D anchor = ctx.getShapeAnchor(); + return anchor.getHeight()/6; + } + + }); + + // height / 8 + builtInFormulas.put("hd8", new Formula(){ + @Override + double evaluate(Context ctx){ + Rectangle2D anchor = ctx.getShapeAnchor(); + return anchor.getHeight()/8; + } + + }); + + // left + builtInFormulas.put("l", new Formula(){ + @Override + double evaluate(Context ctx){ + Rectangle2D anchor = ctx.getShapeAnchor(); + return anchor.getX(); + } + + }); + + // long side + builtInFormulas.put("ls", new Formula(){ + @Override + double evaluate(Context ctx){ + Rectangle2D anchor = ctx.getShapeAnchor(); + return Math.max(anchor.getWidth(), anchor.getHeight()); + } + + }); + + // right + builtInFormulas.put("r", new Formula(){ + @Override + double evaluate(Context ctx){ + Rectangle2D anchor = ctx.getShapeAnchor(); + return anchor.getX() + anchor.getWidth(); + } + + }); + + // short side + builtInFormulas.put("ss", new Formula(){ + @Override + double evaluate(Context ctx){ + Rectangle2D anchor = ctx.getShapeAnchor(); + return Math.min(anchor.getWidth(), anchor.getHeight()); + } + + }); + + // short side / 2 + builtInFormulas.put("ssd2", new Formula(){ + @Override + double evaluate(Context ctx){ + Rectangle2D anchor = ctx.getShapeAnchor(); + double ss = Math.min(anchor.getWidth(), anchor.getHeight()); + return ss / 2; + } + }); + + // short side / 4 + builtInFormulas.put("ssd4", new Formula(){ + @Override + double evaluate(Context ctx){ + Rectangle2D anchor = ctx.getShapeAnchor(); + double ss = Math.min(anchor.getWidth(), anchor.getHeight()); + return ss / 4; + } + }); + + // short side / 6 + builtInFormulas.put("ssd6", new Formula(){ + @Override + double evaluate(Context ctx){ + Rectangle2D anchor = ctx.getShapeAnchor(); + double ss = Math.min(anchor.getWidth(), anchor.getHeight()); + return ss / 6; + } + }); + + // short side / 8 + builtInFormulas.put("ssd8", new Formula(){ + @Override + double evaluate(Context ctx){ + Rectangle2D anchor = ctx.getShapeAnchor(); + double ss = Math.min(anchor.getWidth(), anchor.getHeight()); + return ss / 8; + } + }); + + // short side / 16 + builtInFormulas.put("ssd16", new Formula(){ + @Override + double evaluate(Context ctx){ + Rectangle2D anchor = ctx.getShapeAnchor(); + double ss = Math.min(anchor.getWidth(), anchor.getHeight()); + return ss / 16; + } + }); + + // short side / 32 + builtInFormulas.put("ssd32", new Formula(){ + @Override + double evaluate(Context ctx){ + Rectangle2D anchor = ctx.getShapeAnchor(); + double ss = Math.min(anchor.getWidth(), anchor.getHeight()); + return ss / 32; + } + }); + + // top + builtInFormulas.put("t", new Formula(){ + @Override + double evaluate(Context ctx){ + return ctx.getShapeAnchor().getY(); + } + }); + + // vertical center + builtInFormulas.put("vc", new Formula(){ + @Override + double evaluate(Context ctx){ + Rectangle2D anchor = ctx.getShapeAnchor(); + return anchor.getY() + anchor.getHeight()/2; + } + }); + + // width + builtInFormulas.put("w", new Formula(){ + @Override + double evaluate(Context ctx){ + return ctx.getShapeAnchor().getWidth(); + } + }); + + // width / 2 + builtInFormulas.put("wd2", new Formula(){ + @Override + double evaluate(Context ctx){ + return ctx.getShapeAnchor().getWidth()/2; + } + }); + + // width / 3 + builtInFormulas.put("wd3", new Formula(){ + @Override + double evaluate(Context ctx){ + return ctx.getShapeAnchor().getWidth()/3; + } + }); + + // width / 4 + builtInFormulas.put("wd4", new Formula(){ + @Override + double evaluate(Context ctx){ + return ctx.getShapeAnchor().getWidth()/4; + } + }); + + // width / 5 + builtInFormulas.put("wd5", new Formula(){ + @Override + double evaluate(Context ctx){ + return ctx.getShapeAnchor().getWidth()/5; + } + }); + + // width / 6 + builtInFormulas.put("wd6", new Formula(){ + @Override + double evaluate(Context ctx){ + return ctx.getShapeAnchor().getWidth()/6; + } + }); + + // width / 8 + builtInFormulas.put("wd8", new Formula(){ + @Override + double evaluate(Context ctx){ + return ctx.getShapeAnchor().getWidth()/8; + } + }); + + // width / 10 + builtInFormulas.put("wd10", new Formula(){ + @Override + double evaluate(Context ctx){ + return ctx.getShapeAnchor().getWidth()/10; + } + }); + + // width / 32 + builtInFormulas.put("wd32", new Formula(){ + @Override + double evaluate(Context ctx){ + return ctx.getShapeAnchor().getWidth()/32; + } + }); + } + +} diff --git a/src/java/org/apache/poi/sl/draw/geom/Guide.java b/src/java/org/apache/poi/sl/draw/geom/Guide.java new file mode 100644 index 0000000000..f14213244b --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/Guide.java @@ -0,0 +1,58 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import org.apache.poi.sl.draw.binding.CTGeomGuide; + +/** + * Date: 10/24/11 + * + * @author Yegor Kozlov + */ +public class Guide extends Formula { + private String name, fmla; + private Expression expr; + + public Guide(CTGeomGuide gd) { + this(gd.getName(), gd.getFmla()); + } + + public Guide(String nm, String fm){ + name = nm; + fmla = fm; + expr = ExpressionParser.parse(fm); + } + + + String getName(){ + return name; + } + + String getFormula(){ + return fmla; + } + + @Override + public double evaluate(Context ctx){ + return expr.evaluate(ctx); + } + + +} diff --git a/src/java/org/apache/poi/sl/draw/geom/IAdjustableShape.java b/src/java/org/apache/poi/sl/draw/geom/IAdjustableShape.java new file mode 100644 index 0000000000..920acb82d6 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/IAdjustableShape.java @@ -0,0 +1,37 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + + +/** + * A bridge to the consumer application. + * + * To get a shape geometry one needs to pass shape bounds and adjust values. + * + * @author Yegor Kozlov + */ +public interface IAdjustableShape { + /** + * + * @param name name of a adjust value, e.g. adj1 + * @return adjust guide defined in the shape or null + */ + Guide getAdjustValue(String name); +} diff --git a/src/java/org/apache/poi/sl/draw/geom/IfElseExpression.java b/src/java/org/apache/poi/sl/draw/geom/IfElseExpression.java new file mode 100644 index 0000000000..443115a780 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/IfElseExpression.java @@ -0,0 +1,50 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.util.regex.Matcher; + +/** + * If Else Formula: + * <p> + * Arguments: 3 (fmla="?: x y z") + * Usage: "?: x y z" = if (x > 0), then y = value of this guide, + * else z = value of this guide + * </p> + * + * @author Yegor Kozlov + */ +public class IfElseExpression implements Expression { + private String arg1, arg2, arg3; + + IfElseExpression(Matcher m){ + arg1 = m.group(1); + arg2 = m.group(2); + arg3 = m.group(3); + } + + public double evaluate(Context ctx){ + double x = ctx.getValue(arg1); + double y = ctx.getValue(arg2); + double z = ctx.getValue(arg3); + return x > 0 ? y : z; + } + +} diff --git a/src/java/org/apache/poi/sl/draw/geom/LineToCommand.java b/src/java/org/apache/poi/sl/draw/geom/LineToCommand.java new file mode 100644 index 0000000000..99c5a6b20c --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/LineToCommand.java @@ -0,0 +1,49 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import org.apache.poi.sl.draw.binding.CTAdjPoint2D; + +import java.awt.geom.GeneralPath; + +/** + * Date: 10/25/11 + * + * @author Yegor Kozlov + */ +public class LineToCommand implements PathCommand { + private String arg1, arg2; + + LineToCommand(CTAdjPoint2D pt){ + arg1 = pt.getX().toString(); + arg2 = pt.getY().toString(); + } + + LineToCommand(String s1, String s2){ + arg1 = s1; + arg2 = s2; + } + + public void execute(GeneralPath path, Context ctx){ + double x = ctx.getValue(arg1); + double y = ctx.getValue(arg2); + path.lineTo((float)x, (float)y); + } +} diff --git a/src/java/org/apache/poi/sl/draw/geom/LiteralValueExpression.java b/src/java/org/apache/poi/sl/draw/geom/LiteralValueExpression.java new file mode 100644 index 0000000000..ab3abc7fd5 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/LiteralValueExpression.java @@ -0,0 +1,40 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.util.regex.Matcher; + +/** + * Date: 10/24/11 + * + * @author Yegor Kozlov + */ +public class LiteralValueExpression implements Expression { + private String arg; + + LiteralValueExpression(Matcher m){ + arg = m.group(1); + } + + public double evaluate(Context ctx){ + return ctx.getValue(arg); + } + +} diff --git a/src/java/org/apache/poi/sl/draw/geom/MaxExpression.java b/src/java/org/apache/poi/sl/draw/geom/MaxExpression.java new file mode 100644 index 0000000000..88a9c60472 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/MaxExpression.java @@ -0,0 +1,43 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.util.regex.Matcher; + +/** + * Maximum Value Formula + * + * @author Yegor Kozlov + */ +public class MaxExpression implements Expression { + private String arg1, arg2; + + MaxExpression(Matcher m){ + arg1 = m.group(1); + arg2 = m.group(2); + } + + public double evaluate(Context ctx){ + double x = ctx.getValue(arg1); + double y = ctx.getValue(arg2); + return Math.max(x, y); + } + +} diff --git a/src/java/org/apache/poi/sl/draw/geom/MinExpression.java b/src/java/org/apache/poi/sl/draw/geom/MinExpression.java new file mode 100644 index 0000000000..8c1864c5a4 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/MinExpression.java @@ -0,0 +1,43 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.util.regex.Matcher; + +/** + * Minimum Value Formula + * + * @author Yegor Kozlov + */ +public class MinExpression implements Expression { + private String arg1, arg2; + + MinExpression(Matcher m){ + arg1 = m.group(1); + arg2 = m.group(2); + } + + public double evaluate(Context ctx){ + double x = ctx.getValue(arg1); + double y = ctx.getValue(arg2); + return Math.min(x, y); + } + +} diff --git a/src/java/org/apache/poi/sl/draw/geom/ModExpression.java b/src/java/org/apache/poi/sl/draw/geom/ModExpression.java new file mode 100644 index 0000000000..ff20fc20f6 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/ModExpression.java @@ -0,0 +1,49 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.util.regex.Matcher; + +/** + * Modulo Formula: + * <p> + * Arguments: 3 (fmla="mod x y z") + * Usage: "mod x y z" = sqrt(x^2 + b^2 + c^2) = value of this guide + * </p> + * + * @author Yegor Kozlov + */ +public class ModExpression implements Expression { + private String arg1, arg2, arg3; + + ModExpression(Matcher m){ + arg1 = m.group(1); + arg2 = m.group(2); + arg3 = m.group(3); + } + + public double evaluate(Context ctx){ + double x = ctx.getValue(arg1); + double y = ctx.getValue(arg2); + double z = ctx.getValue(arg3); + return Math.sqrt(x*x + y*y + z*z); + } + +} diff --git a/src/java/org/apache/poi/sl/draw/geom/MoveToCommand.java b/src/java/org/apache/poi/sl/draw/geom/MoveToCommand.java new file mode 100644 index 0000000000..22ccd54092 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/MoveToCommand.java @@ -0,0 +1,49 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import org.apache.poi.sl.draw.binding.CTAdjPoint2D; + +import java.awt.geom.GeneralPath; + +/** + * Date: 10/25/11 + * + * @author Yegor Kozlov + */ +public class MoveToCommand implements PathCommand { + private String arg1, arg2; + + MoveToCommand(CTAdjPoint2D pt){ + arg1 = pt.getX().toString(); + arg2 = pt.getY().toString(); + } + + MoveToCommand(String s1, String s2){ + arg1 = s1; + arg2 = s2; + } + + public void execute(GeneralPath path, Context ctx){ + double x = ctx.getValue(arg1); + double y = ctx.getValue(arg2); + path.moveTo((float)x, (float)y); + } +} diff --git a/src/java/org/apache/poi/sl/draw/geom/MultiplyDivideExpression.java b/src/java/org/apache/poi/sl/draw/geom/MultiplyDivideExpression.java new file mode 100644 index 0000000000..5af0ff12c0 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/MultiplyDivideExpression.java @@ -0,0 +1,45 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.util.regex.Matcher; + +/** + * Multiply Divide Formula + * + * @author Yegor Kozlov + */ +public class MultiplyDivideExpression implements Expression { + private String arg1, arg2, arg3; + + MultiplyDivideExpression(Matcher m){ + arg1 = m.group(1); + arg2 = m.group(2); + arg3 = m.group(3); + } + + public double evaluate(Context ctx){ + double x = ctx.getValue(arg1); + double y = ctx.getValue(arg2); + double z = ctx.getValue(arg3); + return (x * y ) / z; + } + +} diff --git a/src/java/org/apache/poi/sl/draw/geom/Outline.java b/src/java/org/apache/poi/sl/draw/geom/Outline.java new file mode 100644 index 0000000000..b4ffc42573 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/Outline.java @@ -0,0 +1,45 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.awt.Shape; + +/** +* Date: 11/6/11 +* +* @author Yegor Kozlov +*/ +public class Outline { + private Shape shape; + private Path path; + + public Outline(Shape shape, Path path){ + this.shape = shape; + this.path = path; + } + + public Path getPath(){ + return path; + } + + public Shape getOutline(){ + return shape; + } +} diff --git a/src/java/org/apache/poi/sl/draw/geom/Path.java b/src/java/org/apache/poi/sl/draw/geom/Path.java new file mode 100644 index 0000000000..b496e9fc96 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/Path.java @@ -0,0 +1,117 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.awt.geom.GeneralPath; +import java.util.ArrayList; +import java.util.List; + +import org.apache.poi.sl.draw.binding.*; + +/** + * Specifies a creation path consisting of a series of moves, lines and curves + * that when combined forms a geometric shape + * + * @author Yegor Kozlov + */ +public class Path { + private final List<PathCommand> commands; + boolean _fill, _stroke; + long _w, _h; + + public Path(){ + this(true, true); + } + + public Path(boolean fill, boolean stroke){ + commands = new ArrayList<PathCommand>(); + _w = -1; + _h = -1; + _fill = fill; + _stroke = stroke; + } + + public Path(CTPath2D spPath){ + _fill = spPath.getFill() != STPathFillMode.NONE; + _stroke = spPath.isStroke(); + _w = spPath.isSetW() ? spPath.getW() : -1; + _h = spPath.isSetH() ? spPath.getH() : -1; + + commands = new ArrayList<PathCommand>(); + + for(Object ch : spPath.getCloseOrMoveToOrLnTo()){ + if(ch instanceof CTPath2DMoveTo){ + CTAdjPoint2D pt = ((CTPath2DMoveTo)ch).getPt(); + commands.add(new MoveToCommand(pt)); + } else if (ch instanceof CTPath2DLineTo){ + CTAdjPoint2D pt = ((CTPath2DLineTo)ch).getPt(); + commands.add(new LineToCommand(pt)); + } else if (ch instanceof CTPath2DArcTo){ + CTPath2DArcTo arc = (CTPath2DArcTo)ch; + commands.add(new ArcToCommand(arc)); + } else if (ch instanceof CTPath2DQuadBezierTo){ + CTPath2DQuadBezierTo bez = ((CTPath2DQuadBezierTo)ch); + CTAdjPoint2D pt1 = bez.getPt().get(0); + CTAdjPoint2D pt2 = bez.getPt().get(1); + commands.add(new QuadToCommand(pt1, pt2)); + } else if (ch instanceof CTPath2DCubicBezierTo){ + CTPath2DCubicBezierTo bez = ((CTPath2DCubicBezierTo)ch); + CTAdjPoint2D pt1 = bez.getPt().get(0); + CTAdjPoint2D pt2 = bez.getPt().get(1); + CTAdjPoint2D pt3 = bez.getPt().get(2); + commands.add(new CurveToCommand(pt1, pt2, pt3)); + } else if (ch instanceof CTPath2DClose){ + commands.add(new ClosePathCommand()); + } else { + throw new IllegalStateException("Unsupported path segment: " + ch); + } + } + } + + public void addCommand(PathCommand cmd){ + commands.add(cmd); + } + + /** + * Convert the internal represenation to java.awt.GeneralPath + */ + public GeneralPath getPath(Context ctx) { + GeneralPath path = new GeneralPath(); + for(PathCommand cmd : commands) + cmd.execute(path, ctx); + return path; + } + + public boolean isStroked(){ + return _stroke; + } + + public boolean isFilled(){ + return _fill; + } + + public long getW(){ + return _w; + } + + public long getH(){ + return _h; + } +} diff --git a/src/java/org/apache/poi/sl/draw/geom/PathCommand.java b/src/java/org/apache/poi/sl/draw/geom/PathCommand.java new file mode 100644 index 0000000000..3063ab81bc --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/PathCommand.java @@ -0,0 +1,45 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.awt.geom.GeneralPath; + +/** + * A path command in DrawingML. One of: + * + * - arcTo + * - moveTo + * - lineTo + * - cubicBezTo + * - quadBezTo + * - close + * + * + * @author Yegor Kozlov + */ +public interface PathCommand { + /** + * Execute the command an append a segment to the specified path + * + * @param path the path to append the result to + * @param ctx the context to lookup variables + */ + void execute(GeneralPath path, Context ctx); +} diff --git a/src/java/org/apache/poi/sl/draw/geom/PinExpression.java b/src/java/org/apache/poi/sl/draw/geom/PinExpression.java new file mode 100644 index 0000000000..ee0d4e5107 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/PinExpression.java @@ -0,0 +1,54 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.util.regex.Matcher; + +/** + * Pin To Formula: + * <gd name="enAng" fmla="pin 0 adj2 21599999"/> + * + * <p> + * Usage: "pin x y z" = if (y < x), then x = value of this guide + * else if (y > z), then z = value of this guide + * else y = value of this guide + * </p> + * + * @author Yegor Kozlov + */ +public class PinExpression implements Expression { + private String arg1, arg2, arg3; + + PinExpression(Matcher m){ + arg1 = m.group(1); + arg2 = m.group(2); + arg3 = m.group(3); + } + + public double evaluate(Context ctx){ + double x = ctx.getValue(arg1); + double y = ctx.getValue(arg2); + double z = ctx.getValue(arg3); + if(y < x) return x; + else if (y > z) return z; + else return y; + } + +} diff --git a/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java b/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java new file mode 100644 index 0000000000..e2caa084dd --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/PresetGeometries.java @@ -0,0 +1,113 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.io.InputStream; +import java.util.LinkedHashMap; + +import javax.xml.bind.*; +import javax.xml.stream.*; +import javax.xml.stream.events.StartElement; +import javax.xml.stream.events.XMLEvent; + +import org.apache.poi.sl.draw.binding.CTCustomGeometry2D; +import org.apache.poi.util.POILogFactory; +import org.apache.poi.util.POILogger; + +/** + * + */ +public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> { + private final static POILogger LOG = POILogFactory.getLogger(PresetGeometries.class); + protected final static String BINDING_PACKAGE = "org.apache.poi.sl.draw.binding"; + + protected static PresetGeometries _inst; + + protected PresetGeometries(){} + + @SuppressWarnings("unused") + public void init(InputStream is) throws XMLStreamException, JAXBException { + // Reader xml = new InputStreamReader( is, Charset.forName("UTF-8") ); + + + // StAX: + EventFilter startElementFilter = new EventFilter() { + @Override + public boolean accept(XMLEvent event) { + return event.isStartElement(); + } + }; + + long cntElem = 0; + XMLInputFactory staxFactory = XMLInputFactory.newInstance(); + XMLEventReader staxReader = staxFactory.createXMLEventReader(is); + XMLEventReader staxFiltRd = staxFactory.createFilteredReader(staxReader, startElementFilter); + // ignore StartElement: + XMLEvent evDoc = staxFiltRd.nextEvent(); + // JAXB: + JAXBContext jaxbContext = JAXBContext.newInstance(BINDING_PACKAGE); + Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); + + while (staxFiltRd.peek() != null) { + StartElement evRoot = (StartElement)staxFiltRd.peek(); + String name = evRoot.getName().getLocalPart(); + JAXBElement<CTCustomGeometry2D> el = unmarshaller.unmarshal(staxReader, CTCustomGeometry2D.class); + CTCustomGeometry2D cus = el.getValue(); + cntElem++; + + if(containsKey(name)) { + LOG.log(POILogger.WARN, "Duplicate definoition of " + name); + } + put(name, new CustomGeometry(cus)); + } + } + + /** + * Convert a single CustomGeometry object, i.e. from xmlbeans + */ + public static CustomGeometry convertCustomGeometry(XMLStreamReader staxReader) { + try { + JAXBContext jaxbContext = JAXBContext.newInstance(BINDING_PACKAGE); + Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); + JAXBElement<CTCustomGeometry2D> el = unmarshaller.unmarshal(staxReader, CTCustomGeometry2D.class); + return new CustomGeometry(el.getValue()); + } catch (JAXBException e) { + LOG.log(POILogger.ERROR, "Unable to parse single custom geometry", e); + return null; + } + } + + public static synchronized PresetGeometries getInstance(){ + if(_inst == null) { + _inst = new PresetGeometries(); + try { + InputStream is = PresetGeometries.class. + getResourceAsStream("presetShapeDefinitions.xml"); + _inst.init(is); + is.close(); + } catch (Exception e){ + throw new RuntimeException(e); + } + } + + return _inst; + } + +} diff --git a/src/java/org/apache/poi/sl/draw/geom/QuadToCommand.java b/src/java/org/apache/poi/sl/draw/geom/QuadToCommand.java new file mode 100644 index 0000000000..e9a9364b2d --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/QuadToCommand.java @@ -0,0 +1,48 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import org.apache.poi.sl.draw.binding.CTAdjPoint2D; + +import java.awt.geom.GeneralPath; + +/** + * Date: 10/25/11 + * + * @author Yegor Kozlov + */ +public class QuadToCommand implements PathCommand { + private String arg1, arg2, arg3, arg4; + + QuadToCommand(CTAdjPoint2D pt1, CTAdjPoint2D pt2){ + arg1 = pt1.getX().toString(); + arg2 = pt1.getY().toString(); + arg3 = pt2.getX().toString(); + arg4 = pt2.getY().toString(); + } + + public void execute(GeneralPath path, Context ctx){ + double x1 = ctx.getValue(arg1); + double y1 = ctx.getValue(arg2); + double x2 = ctx.getValue(arg3); + double y2 = ctx.getValue(arg4); + path.quadTo((float)x1, (float)y1, (float)x2, (float)y2); + } +} diff --git a/src/java/org/apache/poi/sl/draw/geom/SinArcTanExpression.java b/src/java/org/apache/poi/sl/draw/geom/SinArcTanExpression.java new file mode 100644 index 0000000000..e14acb9e60 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/SinArcTanExpression.java @@ -0,0 +1,51 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.util.regex.Matcher; + +/** + * Sine ArcTan Formula: + * <gd name="dy1" fmla="sat2 x y z"/> + * + * <p> + * Arguments: 3 (fmla="sat2 x y z") + * Usage: "sat2 x y z" = (x*sin(arctan(z / y))) = value of this guide + * </p> + * + * @author Yegor Kozlov + */ +public class SinArcTanExpression implements Expression { + private String arg1, arg2, arg3; + + SinArcTanExpression(Matcher m){ + arg1 = m.group(1); + arg2 = m.group(2); + arg3 = m.group(3); + } + + public double evaluate(Context ctx){ + double x = ctx.getValue(arg1); + double y = ctx.getValue(arg2); + double z = ctx.getValue(arg3); + return x*Math.sin(Math.atan(z / y)); + } + +} diff --git a/src/java/org/apache/poi/sl/draw/geom/SinExpression.java b/src/java/org/apache/poi/sl/draw/geom/SinExpression.java new file mode 100644 index 0000000000..ca0c110ce5 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/SinExpression.java @@ -0,0 +1,49 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.util.regex.Matcher; + +/** + * Sine Formula: + * <gd name="z" fmla="sin x y"/> + * + * <p> + * Arguments: 2 (fmla="sin x y") + * Usage: "sin x y" = (x * sin( y )) = value of this guide + * </p> + * + * @author Yegor Kozlov + */ +public class SinExpression implements Expression { + private String arg1, arg2; + + SinExpression(Matcher m){ + arg1 = m.group(1); + arg2 = m.group(2); + } + + public double evaluate(Context ctx){ + double x = ctx.getValue(arg1); + double y = ctx.getValue(arg2) / 60000; + return x * Math.sin(Math.toRadians(y)); + } + +} diff --git a/src/java/org/apache/poi/sl/draw/geom/SqrtExpression.java b/src/java/org/apache/poi/sl/draw/geom/SqrtExpression.java new file mode 100644 index 0000000000..5cdd67cc57 --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/SqrtExpression.java @@ -0,0 +1,46 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.util.regex.Matcher; + +/** + * Square Root Formula: + * <gd name="x" fmla="sqrt y"/> + * + * <p> + * Arguments: 1 (fmla="sqrt x") + * Usage: "sqrt x" = sqrt(x) = value of this guide + * </p> + * @author Yegor Kozlov + */ +public class SqrtExpression implements Expression { + private String arg; + + SqrtExpression(Matcher m){ + arg =m.group(1); + } + + public double evaluate(Context ctx){ + double val = ctx.getValue(arg); + return Math.sqrt(val); + } + +} diff --git a/src/java/org/apache/poi/sl/draw/geom/TanExpression.java b/src/java/org/apache/poi/sl/draw/geom/TanExpression.java new file mode 100644 index 0000000000..7eebdcedfa --- /dev/null +++ b/src/java/org/apache/poi/sl/draw/geom/TanExpression.java @@ -0,0 +1,50 @@ +/* + * ==================================================================== + * 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.sl.draw.geom; + +import java.util.regex.Matcher; + +/** + * Tangent Formula: + * + * <gd name="z" fmla="tan x y"/> + * + * <p> + * Arguments: 2 (fmla="tan x y") + * Usage: "tan x y" = (x * tan( y )) = value of this guide + * </p> + * + * @author Yegor Kozlov + */ +public class TanExpression implements Expression { + private String arg1, arg2; + + TanExpression(Matcher m){ + arg1 = m.group(1); + arg2 = m.group(2); + } + + public double evaluate(Context ctx){ + double x = ctx.getValue(arg1); + double y = ctx.getValue(arg2); + return x * Math.tan(Math.toRadians(y / 60000)); + } + +} diff --git a/src/java/org/apache/poi/sl/usermodel/AutoNumberingScheme.java b/src/java/org/apache/poi/sl/usermodel/AutoNumberingScheme.java new file mode 100644 index 0000000000..3a68313499 --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/AutoNumberingScheme.java @@ -0,0 +1,287 @@ +/* ====================================================================
+ 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.sl.usermodel;
+
+public enum AutoNumberingScheme {
+ /** Lowercase alphabetic character enclosed in parentheses. Example: (a), (b), (c), ... */
+ alphaLcParenBoth(0x0008, 1),
+ /** Uppercase alphabetic character enclosed in parentheses. Example: (A), (B), (C), ... */
+ alphaUcParenBoth(0x000A, 2),
+ /** Lowercase alphabetic character followed by a closing parenthesis. Example: a), b), c), ... */
+ alphaLcParenRight(0x0009, 3),
+ /** Uppercase alphabetic character followed by a closing parenthesis. Example: A), B), C), ... */
+ alphaUcParenRight(0x000B, 4),
+ /** Lowercase Latin character followed by a period. Example: a., b., c., ... */
+ alphaLcPeriod(0x0000, 5),
+ /** Uppercase Latin character followed by a period. Example: A., B., C., ... */
+ alphaUcPeriod(0x0001, 6),
+ /** Arabic numeral enclosed in parentheses. Example: (1), (2), (3), ... */
+ arabicParenBoth(0x000C, 7),
+ /** Arabic numeral followed by a closing parenthesis. Example: 1), 2), 3), ... */
+ arabicParenRight(0x0002, 8),
+ /** Arabic numeral followed by a period. Example: 1., 2., 3., ... */
+ arabicPeriod(0x0003, 9),
+ /** Arabic numeral. Example: 1, 2, 3, ... */
+ arabicPlain(0x000D, 10),
+ /** Lowercase Roman numeral enclosed in parentheses. Example: (i), (ii), (iii), ... */
+ romanLcParenBoth(0x0004, 11),
+ /** Uppercase Roman numeral enclosed in parentheses. Example: (I), (II), (III), ... */
+ romanUcParenBoth(0x000E, 12),
+ /** Lowercase Roman numeral followed by a closing parenthesis. Example: i), ii), iii), ... */
+ romanLcParenRight(0x0005, 13),
+ /** Uppercase Roman numeral followed by a closing parenthesis. Example: I), II), III), .... */
+ romanUcParenRight(0x000F, 14),
+ /** Lowercase Roman numeral followed by a period. Example: i., ii., iii., ... */
+ romanLcPeriod(0x0006, 15),
+ /** Uppercase Roman numeral followed by a period. Example: I., II., III., ... */
+ romanUcPeriod(0x0007, 16),
+ /** Double byte circle numbers. */
+ circleNumDbPlain(0x0012, 17),
+ /** Wingdings black circle numbers. */
+ circleNumWdBlackPlain(0x0014, 18),
+ /** Wingdings white circle numbers. */
+ circleNumWdWhitePlain(0x0013, 19),
+ /** Double-byte Arabic numbers with double-byte period. */
+ arabicDbPeriod(0x001D, 20),
+ /** Double-byte Arabic numbers. */
+ arabicDbPlain(0x001C, 21),
+ /** Simplified Chinese with single-byte period. */
+ ea1ChsPeriod(0x0011, 22),
+ /** Simplified Chinese. */
+ ea1ChsPlain(0x0010, 23),
+ /** Traditional Chinese with single-byte period. */
+ ea1ChtPeriod(0x0015, 24),
+ /** Traditional Chinese. */
+ ea1ChtPlain(0x0014, 25),
+ /** Japanese with double-byte period. */
+ ea1JpnChsDbPeriod(0x0026, 26),
+ /** Japanese/Korean. */
+ ea1JpnKorPlain(0x001A, 27),
+ /** Japanese/Korean with single-byte period. */
+ ea1JpnKorPeriod(0x001B, 28),
+ /** Bidi Arabic 1 (AraAlpha) with ANSI minus symbol. */
+ arabic1Minus(0x0017, 29),
+ /** Bidi Arabic 2 (AraAbjad) with ANSI minus symbol. */
+ arabic2Minus(0x0018, 30),
+ /** Bidi Hebrew 2 with ANSI minus symbol. */
+ hebrew2Minus(0x0019, 31),
+ /** Thai alphabetic character followed by a period. */
+ thaiAlphaPeriod(0x001E, 32),
+ /** Thai alphabetic character followed by a closing parenthesis. */
+ thaiAlphaParenRight(0x001F, 33),
+ /** Thai alphabetic character enclosed by parentheses. */
+ thaiAlphaParenBoth(0x0020, 34),
+ /** Thai numeral followed by a period. */
+ thaiNumPeriod(0x0021, 35),
+ /** Thai numeral followed by a closing parenthesis. */
+ thaiNumParenRight(0x0022, 36),
+ /** Thai numeral enclosed in parentheses. */
+ thaiNumParenBoth(0x0023, 37),
+ /** Hindi alphabetic character followed by a period. */
+ hindiAlphaPeriod(0x0024, 38),
+ /** Hindi numeric character followed by a period. */
+ hindiNumPeriod(0x0025, 39),
+ /** Hindi numeric character followed by a closing parenthesis. */
+ hindiNumParenRight(0x0027, 40),
+ /** Hindi alphabetic character followed by a period. */
+ hindiAlpha1Period(0x0027, 41);
+
+ public final int nativeId, ooxmlId;
+
+ AutoNumberingScheme(int nativeId, int ooxmlId) {
+ this.nativeId = nativeId;
+ this.ooxmlId = ooxmlId;
+ }
+
+ public static AutoNumberingScheme forNativeID(int nativeId) {
+ for (AutoNumberingScheme ans : values()) {
+ if (ans.nativeId == nativeId) return ans;
+ }
+ return null;
+ }
+
+ public static AutoNumberingScheme forOoxmlID(int ooxmlId) {
+ for (AutoNumberingScheme ans : values()) {
+ if (ans.ooxmlId == ooxmlId) return ans;
+ }
+ return null;
+ }
+
+ public String getDescription() {
+ switch (this) {
+ case alphaLcPeriod : return "Lowercase Latin character followed by a period. Example: a., b., c., ...";
+ case alphaUcPeriod : return "Uppercase Latin character followed by a period. Example: A., B., C., ...";
+ case arabicParenRight : return "Arabic numeral followed by a closing parenthesis. Example: 1), 2), 3), ...";
+ case arabicPeriod : return "Arabic numeral followed by a period. Example: 1., 2., 3., ...";
+ case romanLcParenBoth : return "Lowercase Roman numeral enclosed in parentheses. Example: (i), (ii), (iii), ...";
+ case romanLcParenRight : return "Lowercase Roman numeral followed by a closing parenthesis. Example: i), ii), iii), ...";
+ case romanLcPeriod : return "Lowercase Roman numeral followed by a period. Example: i., ii., iii., ...";
+ case romanUcPeriod : return "Uppercase Roman numeral followed by a period. Example: I., II., III., ...";
+ case alphaLcParenBoth : return "Lowercase alphabetic character enclosed in parentheses. Example: (a), (b), (c), ...";
+ case alphaLcParenRight : return "Lowercase alphabetic character followed by a closing parenthesis. Example: a), b), c), ...";
+ case alphaUcParenBoth : return "Uppercase alphabetic character enclosed in parentheses. Example: (A), (B), (C), ...";
+ case alphaUcParenRight : return "Uppercase alphabetic character followed by a closing parenthesis. Example: A), B), C), ...";
+ case arabicParenBoth : return "Arabic numeral enclosed in parentheses. Example: (1), (2), (3), ...";
+ case arabicPlain : return "Arabic numeral. Example: 1, 2, 3, ...";
+ case romanUcParenBoth : return "Uppercase Roman numeral enclosed in parentheses. Example: (I), (II), (III), ...";
+ case romanUcParenRight : return "Uppercase Roman numeral followed by a closing parenthesis. Example: I), II), III), ...";
+ case ea1ChsPlain : return "Simplified Chinese.";
+ case ea1ChsPeriod : return "Simplified Chinese with single-byte period.";
+ case circleNumDbPlain : return "Double byte circle numbers.";
+ case circleNumWdWhitePlain : return "Wingdings white circle numbers.";
+ case circleNumWdBlackPlain : return "Wingdings black circle numbers.";
+ case ea1ChtPlain : return "Traditional Chinese.";
+ case ea1ChtPeriod : return "Traditional Chinese with single-byte period.";
+ case arabic1Minus : return "Bidi Arabic 1 (AraAlpha) with ANSI minus symbol.";
+ case arabic2Minus : return "Bidi Arabic 2 (AraAbjad) with ANSI minus symbol.";
+ case hebrew2Minus : return "Bidi Hebrew 2 with ANSI minus symbol.";
+ case ea1JpnKorPlain : return "Japanese/Korean.";
+ case ea1JpnKorPeriod : return "Japanese/Korean with single-byte period.";
+ case arabicDbPlain : return "Double-byte Arabic numbers.";
+ case arabicDbPeriod : return "Double-byte Arabic numbers with double-byte period.";
+ case thaiAlphaPeriod : return "Thai alphabetic character followed by a period.";
+ case thaiAlphaParenRight : return "Thai alphabetic character followed by a closing parenthesis.";
+ case thaiAlphaParenBoth : return "Thai alphabetic character enclosed by parentheses.";
+ case thaiNumPeriod : return "Thai numeral followed by a period.";
+ case thaiNumParenRight : return "Thai numeral followed by a closing parenthesis.";
+ case thaiNumParenBoth : return "Thai numeral enclosed in parentheses.";
+ case hindiAlphaPeriod : return "Hindi alphabetic character followed by a period.";
+ case hindiNumPeriod : return "Hindi numeric character followed by a period.";
+ case ea1JpnChsDbPeriod : return "Japanese with double-byte period.";
+ case hindiNumParenRight : return "Hindi numeric character followed by a closing parenthesis.";
+ case hindiAlpha1Period : return "Hindi alphabetic character followed by a period.";
+ default : return "Unknown Numbered Scheme";
+ }
+ }
+
+ public String format(int value) {
+ String index = formatIndex(value);
+ String cased = formatCase(index);
+ String seperated = formatSeperator(cased);
+ return seperated;
+ }
+
+ private String formatSeperator(String cased) {
+ String name = name().toLowerCase();
+ if (name.contains("plain")) return cased;
+ if (name.contains("parenright")) return cased+")";
+ if (name.contains("parenboth")) return "("+cased+")";
+ if (name.contains("period")) return cased+".";
+ if (name.contains("minus")) return cased+"-"; // ???
+ return cased;
+ }
+
+ private String formatCase(String index) {
+ String name = name().toLowerCase();
+ if (name.contains("lc")) return index.toLowerCase();
+ if (name.contains("uc")) return index.toUpperCase();
+ return index;
+ }
+
+ private static final String ARABIC_LIST = "0123456789";
+ private static final String ALPHA_LIST = "abcdefghijklmnopqrstuvwxyz";
+ private static final String WINGDINGS_WHITE_LIST =
+ "\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089";
+ private static final String WINGDINGS_BLACK_LIST =
+ "\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094";
+ private static final String CIRCLE_DB_LIST =
+ "\u2776\u2777\u2778\u2779\u277A\u277B\u277C\u277D\u277E";
+
+ private String formatIndex(int value) {
+ String name = name().toLowerCase();
+ if (name.startsWith("roman")) {
+ return formatRomanIndex(value);
+ } else if (name.startsWith("arabic") && !name.contains("db")) {
+ return getIndexedList(value, ARABIC_LIST, false);
+ } else if (name.startsWith("alpha")) {
+ return getIndexedList(value, ALPHA_LIST, true);
+ } else if (name.contains("WdWhite")) {
+ return (value == 10) ? "\u008A"
+ : getIndexedList(value, WINGDINGS_WHITE_LIST, false);
+ } else if (name.contains("WdBlack")) {
+ return (value == 10) ? "\u0095"
+ : getIndexedList(value, WINGDINGS_BLACK_LIST, false);
+ } else if (name.contains("NumDb")) {
+ return (value == 10) ? "\u277F"
+ : getIndexedList(value, CIRCLE_DB_LIST, true);
+ } else {
+ return "?";
+ }
+ }
+
+ private static String getIndexedList(int val, String list, boolean oneBased) {
+ StringBuilder sb = new StringBuilder();
+ addIndexedChar(val, list, oneBased, sb);
+ return sb.toString();
+ }
+
+ private static void addIndexedChar(int val, String list, boolean oneBased, StringBuilder sb) {
+ if (oneBased) val -= 1;
+ final int len = list.length();
+ if (val >= len) {
+ addIndexedChar(val/len, list, oneBased, sb);
+ }
+ sb.append(list.charAt(val%len));
+ }
+
+
+ private String formatRomanIndex(int value) {
+ //M (1000), CM (900), D (500), CD (400), C (100), XC (90), L (50), XL (40), X (10), IX (9), V (5), IV (4) and I (1).
+ final int[] VALUES = new int[]{1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
+ final String[] ROMAN = new String[]{"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};
+ final String conciseList[][] = {
+ {"XLV", "VL"}, //45
+ {"XCV", "VC"}, //95
+ {"CDL", "LD"}, //450
+ {"CML", "LM"}, //950
+ {"CMVC", "LMVL"}, //995
+ {"CDXC", "LDXL"}, //490
+ {"CDVC", "LDVL"}, //495
+ {"CMXC", "LMXL"}, //990
+ {"XCIX", "VCIV"}, //99
+ {"XLIX", "VLIV"}, //49
+ {"XLIX", "IL"}, //49
+ {"XCIX", "IC"}, //99
+ {"CDXC", "XD"}, //490
+ {"CDVC", "XDV"}, //495
+ {"CDIC", "XDIX"}, //499
+ {"LMVL", "XMV"}, //995
+ {"CMIC", "XMIX"}, //999
+ {"CMXC", "XM"}, // 990
+ {"XDV", "VD"}, //495
+ {"XDIX", "VDIV"}, //499
+ {"XMV", "VM"}, // 995
+ {"XMIX", "VMIV"}, //999
+ {"VDIV", "ID"}, //499
+ {"VMIV", "IM"} //999
+ };
+
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < 13; i++) {
+ while (value >= VALUES[i]) {
+ value -= VALUES[i];
+ sb.append(ROMAN[i]);
+ }
+ }
+ String result = sb.toString();
+ for (String cc[] : conciseList) {
+ result = result.replace(cc[0], cc[1]);
+ }
+ return result;
+ }
+}
\ No newline at end of file diff --git a/src/java/org/apache/poi/sl/usermodel/AutoShape.java b/src/java/org/apache/poi/sl/usermodel/AutoShape.java new file mode 100644 index 0000000000..1bf073dfbb --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/AutoShape.java @@ -0,0 +1,21 @@ +/* ==================================================================== + 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.sl.usermodel; + +public interface AutoShape<T extends TextParagraph<? extends TextRun>> extends TextShape<T> { +} diff --git a/src/java/org/apache/poi/sl/usermodel/Background.java b/src/java/org/apache/poi/sl/usermodel/Background.java new file mode 100644 index 0000000000..8d868b8600 --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/Background.java @@ -0,0 +1,22 @@ +/* ==================================================================== + 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.sl.usermodel; + +public interface Background extends Shape { + FillStyle getFillStyle(); +} diff --git a/src/java/org/apache/poi/sl/usermodel/ColorStyle.java b/src/java/org/apache/poi/sl/usermodel/ColorStyle.java new file mode 100644 index 0000000000..9be847b36c --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/ColorStyle.java @@ -0,0 +1,69 @@ +/* ====================================================================
+ 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.sl.usermodel;
+
+import java.awt.Color;
+
+
+public interface ColorStyle {
+ Color getColor();
+
+ /**
+ * the opacity as expressed by a percentage value
+ *
+ * @return opacity in percents in the range [0..100000]
+ * or -1 if the value is not set
+ */
+ int getAlpha();
+
+ /**
+ * the luminance shift as expressed by a percentage relative to the input color
+ *
+ * @return luminance shift in percents in the range [0..100000]
+ * or -1 if the value is not set
+ */
+ int getLumOff();
+
+ /**
+ * the luminance as expressed by a percentage relative to the input color
+ *
+ * @return luminance in percents in the range [0..100000]
+ * or -1 if the value is not set
+ */
+ int getLumMod();
+
+ /**
+ * specifies a darker version of its input color.
+ * A 10% shade is 10% of the input color combined with 90% black.
+ *
+ * @return the value of the shade specified as percents in the range [0..100000]
+ * with 0% indicating minimal shade and 100% indicating maximum
+ * or -1 if the value is not set
+ */
+ int getShade();
+
+ /**
+ * specifies a lighter version of its input color.
+ * A 10% tint is 10% of the input color combined with 90% white.
+ *
+ * @return the value of the tint specified as percents in the range [0..100000]
+ * with 0% indicating minimal tint and 100% indicating maximum
+ * or -1 if the value is not set
+ */
+ int getTint();
+}
diff --git a/src/java/org/apache/poi/sl/usermodel/ConnectorShape.java b/src/java/org/apache/poi/sl/usermodel/ConnectorShape.java new file mode 100644 index 0000000000..7e2bbf065c --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/ConnectorShape.java @@ -0,0 +1,22 @@ +/* ====================================================================
+ 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.sl.usermodel;
+
+public interface ConnectorShape extends SimpleShape {
+
+}
diff --git a/src/java/org/apache/poi/sl/usermodel/FillStyle.java b/src/java/org/apache/poi/sl/usermodel/FillStyle.java new file mode 100644 index 0000000000..8414000b8b --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/FillStyle.java @@ -0,0 +1,22 @@ +/* ====================================================================
+ 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.sl.usermodel;
+
+public interface FillStyle {
+ PaintStyle getPaint();
+}
diff --git a/src/java/org/apache/poi/sl/usermodel/FontCollection.java b/src/java/org/apache/poi/sl/usermodel/FontCollection.java new file mode 100644 index 0000000000..61278f4618 --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/FontCollection.java @@ -0,0 +1,22 @@ +/* ==================================================================== + 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.sl.usermodel; + +public interface FontCollection { + +} diff --git a/src/java/org/apache/poi/sl/usermodel/FreeformShape.java b/src/java/org/apache/poi/sl/usermodel/FreeformShape.java new file mode 100644 index 0000000000..e0843a11a1 --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/FreeformShape.java @@ -0,0 +1,22 @@ +/* ====================================================================
+ 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.sl.usermodel;
+
+public interface FreeformShape<T extends TextParagraph<? extends TextRun>> extends AutoShape<T> {
+
+}
diff --git a/src/java/org/apache/poi/sl/usermodel/GroupShape.java b/src/java/org/apache/poi/sl/usermodel/GroupShape.java new file mode 100644 index 0000000000..d71bb253fe --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/GroupShape.java @@ -0,0 +1,39 @@ +/* ==================================================================== + 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.sl.usermodel; + +import java.awt.geom.Rectangle2D; + +public interface GroupShape<T extends Shape> extends Shape, ShapeContainer<T>, PlaceableShape { + + /** + * Gets the coordinate space of this group. All children are constrained + * to these coordinates. + * + * @param anchor the coordinate space of this group + */ + Rectangle2D getInteriorAnchor(); + + /** + * Sets the coordinate space of this group. All children are constrained + * to these coordinates. + * + * @param anchor the coordinate space of this group + */ + void setInteriorAnchor(Rectangle2D anchor); +} diff --git a/src/java/org/apache/poi/sl/usermodel/Hyperlink.java b/src/java/org/apache/poi/sl/usermodel/Hyperlink.java new file mode 100644 index 0000000000..cde288492c --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/Hyperlink.java @@ -0,0 +1,24 @@ +/* ==================================================================== + 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.sl.usermodel; + +/** + * A PowerPoint hyperlink + */ +public interface Hyperlink extends org.apache.poi.common.usermodel.Hyperlink { +} diff --git a/src/java/org/apache/poi/sl/usermodel/Insets2D.java b/src/java/org/apache/poi/sl/usermodel/Insets2D.java new file mode 100644 index 0000000000..04b4d77cf4 --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/Insets2D.java @@ -0,0 +1,146 @@ +/* ====================================================================
+ 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.sl.usermodel;
+
+import java.awt.Insets;
+
+/**
+ * This is a replacement for {@link java.awt.Insets} which works on doubles
+ * instead of ints
+ */
+public class Insets2D {
+
+ /**
+ * The inset from the top.
+ * This value is added to the Top of the rectangle
+ * to yield a new location for the Top.
+ */
+ public double top;
+
+ /**
+ * The inset from the left.
+ * This value is added to the Left of the rectangle
+ * to yield a new location for the Left edge.
+ */
+ public double left;
+
+ /**
+ * The inset from the bottom.
+ * This value is subtracted from the Bottom of the rectangle
+ * to yield a new location for the Bottom.
+ */
+ public double bottom;
+
+ /**
+ * The inset from the right.
+ * This value is subtracted from the Right of the rectangle
+ * to yield a new location for the Right edge.
+ */
+ public double right;
+
+ /**
+ * Creates and initializes a new <code>Insets</code> object with the
+ * specified top, left, bottom, and right insets.
+ * @param top the inset from the top.
+ * @param left the inset from the left.
+ * @param bottom the inset from the bottom.
+ * @param right the inset from the right.
+ */
+ public Insets2D(double top, double left, double bottom, double right) {
+ this.top = top;
+ this.left = left;
+ this.bottom = bottom;
+ this.right = right;
+ }
+
+ /**
+ * Set top, left, bottom, and right to the specified values
+ *
+ * @param top the inset from the top.
+ * @param left the inset from the left.
+ * @param bottom the inset from the bottom.
+ * @param right the inset from the right.
+ * @since 1.5
+ */
+ public void set(double top, double left, double bottom, double right) {
+ this.top = top;
+ this.left = left;
+ this.bottom = bottom;
+ this.right = right;
+ }
+
+ /**
+ * Checks whether two insets objects are equal. Two instances
+ * of <code>Insets</code> are equal if the four integer values
+ * of the fields <code>top</code>, <code>left</code>,
+ * <code>bottom</code>, and <code>right</code> are all equal.
+ * @return <code>true</code> if the two insets are equal;
+ * otherwise <code>false</code>.
+ * @since JDK1.1
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof Insets) {
+ Insets insets = (Insets)obj;
+ return ((top == insets.top) && (left == insets.left) &&
+ (bottom == insets.bottom) && (right == insets.right));
+ }
+ return false;
+ }
+
+ /**
+ * Returns the hash code for this Insets.
+ *
+ * @return a hash code for this Insets.
+ */
+ public int hashCode() {
+ double sum1 = left + bottom;
+ double sum2 = right + top;
+ double val1 = sum1 * (sum1 + 1)/2 + left;
+ double val2 = sum2 * (sum2 + 1)/2 + top;
+ double sum3 = val1 + val2;
+ return (int)(sum3 * (sum3 + 1)/2 + val2);
+ }
+
+ /**
+ * Returns a string representation of this <code>Insets</code> object.
+ * This method is intended to be used only for debugging purposes, and
+ * the content and format of the returned string may vary between
+ * implementations. The returned string may be empty but may not be
+ * <code>null</code>.
+ *
+ * @return a string representation of this <code>Insets</code> object.
+ */
+ public String toString() {
+ return getClass().getName() + "[top=" + top + ",left=" + left + ",bottom=" + bottom + ",right=" + right + "]";
+ }
+
+ /**
+ * Create a copy of this object.
+ * @return a copy of this <code>Insets2D</code> object.
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException e) {
+ // this shouldn't happen, since we are Cloneable
+ throw new InternalError();
+ }
+ }
+
+
+}
diff --git a/src/java/org/apache/poi/sl/usermodel/Line.java b/src/java/org/apache/poi/sl/usermodel/Line.java new file mode 100644 index 0000000000..b06764e54d --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/Line.java @@ -0,0 +1,22 @@ +/* ==================================================================== + 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.sl.usermodel; + +public interface Line<T extends TextParagraph<? extends TextRun>> extends AutoShape<T> { + +} diff --git a/src/java/org/apache/poi/sl/usermodel/LineDecoration.java b/src/java/org/apache/poi/sl/usermodel/LineDecoration.java new file mode 100644 index 0000000000..e95551c9e7 --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/LineDecoration.java @@ -0,0 +1,95 @@ +/* ====================================================================
+ 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.sl.usermodel;
+
+public interface LineDecoration {
+ /**
+ * Represents the shape decoration that appears at the ends of lines.
+ */
+ enum DecorationShape {
+ NONE(1),
+ TRIANGLE(2),
+ STEALTH(3),
+ DIAMOND(4),
+ OVAL(5),
+ ARROW(6);
+
+ public final int ooxmlId;
+
+ DecorationShape(int ooxmlId) {
+ this.ooxmlId = ooxmlId;
+ }
+
+ public static DecorationShape fromOoxmlId(int ooxmlId) {
+ for (DecorationShape ds : values()) {
+ if (ds.ooxmlId == ooxmlId) return ds;
+ }
+ return null;
+ }
+ }
+
+ enum DecorationSize {
+ SMALL(1),
+ MEDIUM(2),
+ LARGE(3);
+
+ public final int ooxmlId;
+
+ DecorationSize(int ooxmlId) {
+ this.ooxmlId = ooxmlId;
+ }
+
+ public static DecorationSize fromOoxmlId(int ooxmlId) {
+ for (DecorationSize ds : values()) {
+ if (ds.ooxmlId == ooxmlId) return ds;
+ }
+ return null;
+ }
+ }
+
+ /**
+ * @return the line start shape
+ */
+ DecorationShape getHeadShape();
+
+ /**
+ * @return the width of the start shape
+ */
+ DecorationSize getHeadWidth();
+
+ /**
+ * @return the length of the start shape
+ */
+ DecorationSize getHeadLength();
+
+ /**
+ * @return the line end shape
+ */
+ DecorationShape getTailShape();
+
+ /**
+ * @return the width of the end shape
+ */
+ DecorationSize getTailWidth();
+
+ /**
+ * @return the length of the end shape
+ */
+ DecorationSize getTailLength();
+
+}
diff --git a/src/java/org/apache/poi/sl/usermodel/MasterSheet.java b/src/java/org/apache/poi/sl/usermodel/MasterSheet.java new file mode 100644 index 0000000000..727217d3fa --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/MasterSheet.java @@ -0,0 +1,22 @@ +/* ==================================================================== + 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.sl.usermodel; + +public interface MasterSheet<T extends Shape, SS extends SlideShow> extends Sheet<T,SS> { + +} diff --git a/src/java/org/apache/poi/sl/usermodel/Notes.java b/src/java/org/apache/poi/sl/usermodel/Notes.java new file mode 100644 index 0000000000..3e4b924721 --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/Notes.java @@ -0,0 +1,24 @@ +/* ==================================================================== + 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.sl.usermodel; + +import java.util.List; + +public interface Notes<T extends Shape, SS extends SlideShow> extends Sheet<T,SS> { + List<? extends List<? extends TextParagraph<? extends TextRun>>> getTextParagraphs(); +} diff --git a/src/java/org/apache/poi/sl/usermodel/PaintStyle.java b/src/java/org/apache/poi/sl/usermodel/PaintStyle.java new file mode 100644 index 0000000000..2551201692 --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/PaintStyle.java @@ -0,0 +1,63 @@ +/* ==================================================================== + 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.sl.usermodel; + +import java.awt.Color; +import java.io.InputStream; + +import org.apache.poi.sl.draw.DrawPaint; + + + +public interface PaintStyle { + public interface SolidPaint extends PaintStyle { + ColorStyle getSolidColor(); + } + + public interface GradientPaint extends PaintStyle { + enum GradientType { linear, circular, shape } + + /** + * @return the angle of the gradient + */ + double getGradientAngle(); + ColorStyle[] getGradientColors(); + float[] getGradientFractions(); + boolean isRotatedWithShape(); + GradientType getGradientType(); + } + + public interface TexturePaint extends PaintStyle { + /** + * @return the raw image stream + */ + InputStream getImageData(); + + /** + * @return the content type of the image data + */ + String getContentType(); + + /** + * @return the alpha mask in percents [0..100000] + */ + int getAlpha(); + } + + SolidPaint TRANSPARENT_PAINT = DrawPaint.createSolidPaint(new Color(0xFF, 0xFF, 0xFF, 0)); +} diff --git a/src/java/org/apache/poi/sl/usermodel/PictureData.java b/src/java/org/apache/poi/sl/usermodel/PictureData.java new file mode 100644 index 0000000000..8697d33965 --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/PictureData.java @@ -0,0 +1,27 @@ +/* ==================================================================== + 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.sl.usermodel; + +import java.io.IOException; + +public interface PictureData { + public String getContentType(); + + public byte[] getData(); + public void setData(byte[] data) throws IOException; +} diff --git a/src/java/org/apache/poi/sl/usermodel/PictureShape.java b/src/java/org/apache/poi/sl/usermodel/PictureShape.java new file mode 100644 index 0000000000..a2c0824e0c --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/PictureShape.java @@ -0,0 +1,37 @@ +/* ==================================================================== + 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.sl.usermodel; + +import java.awt.Insets; + +public interface PictureShape extends SimpleShape { + /** + * Returns the picture data for this picture. + * + * @return the picture data for this picture. + */ + PictureData getPictureData(); + + /** + * Returns the clipping values as percent ratio relatively to the image size. + * The clipping are returned as insets converted/scaled to 100000 (=100%). + * + * @return the clipping rectangle, which is given in percent in relation to the image width/height + */ + Insets getClipping(); +} diff --git a/src/java/org/apache/poi/sl/usermodel/PlaceableShape.java b/src/java/org/apache/poi/sl/usermodel/PlaceableShape.java new file mode 100644 index 0000000000..f81a344b17 --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/PlaceableShape.java @@ -0,0 +1,84 @@ +/* ====================================================================
+ 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.sl.usermodel;
+
+import java.awt.geom.Rectangle2D;
+
+public interface PlaceableShape {
+ ShapeContainer<? extends Shape> getParent();
+
+ /**
+ * @return the position of this shape within the drawing canvas.
+ * The coordinates are expressed in points
+ */
+ Rectangle2D getAnchor();
+
+ /**
+ * @param anchor the position of this shape within the drawing canvas.
+ * The coordinates are expressed in points
+ */
+ void setAnchor(Rectangle2D anchor);
+
+ /**
+ * Rotation angle in degrees
+ * <p>
+ * Positive angles are clockwise (i.e., towards the positive y axis);
+ * negative angles are counter-clockwise (i.e., towards the negative y axis).
+ * </p>
+ *
+ * @return rotation angle in degrees
+ */
+ double getRotation();
+
+ /**
+ * Rotate this shape.
+ * <p>
+ * Positive angles are clockwise (i.e., towards the positive y axis);
+ * negative angles are counter-clockwise (i.e., towards the negative y axis).
+ * </p>
+ *
+ * @param theta the rotation angle in degrees.
+ */
+ void setRotation(double theta);
+
+ /**
+ * @param flip whether the shape is horizontally flipped
+ */
+ void setFlipHorizontal(boolean flip);
+
+ /**
+ * Whether the shape is vertically flipped
+ *
+ * @param flip whether the shape is vertically flipped
+ */
+ void setFlipVertical(boolean flip);
+
+ /**
+ * Whether the shape is horizontally flipped
+ *
+ * @return whether the shape is horizontally flipped
+ */
+ boolean getFlipHorizontal();
+
+ /**
+ * Whether the shape is vertically flipped
+ *
+ * @return whether the shape is vertically flipped
+ */
+ boolean getFlipVertical();
+}
diff --git a/src/java/org/apache/poi/sl/usermodel/Resources.java b/src/java/org/apache/poi/sl/usermodel/Resources.java new file mode 100644 index 0000000000..96170e50bd --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/Resources.java @@ -0,0 +1,29 @@ +/* ==================================================================== + 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.sl.usermodel; + +/** + * Common SlideShow resources, such as fonts, pictures + * and multimedia data + */ +public interface Resources { + public FontCollection getFontCollection(); + + public PictureData[] getPictureData(); + public int addPictureData(PictureData pict); +} diff --git a/src/java/org/apache/poi/sl/usermodel/Shadow.java b/src/java/org/apache/poi/sl/usermodel/Shadow.java new file mode 100644 index 0000000000..430dbe3840 --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/Shadow.java @@ -0,0 +1,50 @@ +/* ====================================================================
+ 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.sl.usermodel;
+
+import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
+
+
+
+public interface Shadow {
+ SimpleShape getShadowParent();
+
+ /**
+ * @return the offset of this shadow in points
+ */
+ double getDistance();
+
+ /**
+ *
+ * @return the direction to offset the shadow in angles
+ */
+ double getAngle();
+
+ /**
+ *
+ * @return the blur radius of the shadow
+ * TODO: figure out how to make sense of this property when rendering shadows
+ */
+ double getBlur();
+
+ /**
+ * @return the color of this shadow.
+ * Depending whether the parent shape is filled or stroked, this color is used to fill or stroke this shadow
+ */
+ SolidPaint getFillStyle();
+}
diff --git a/src/java/org/apache/poi/sl/usermodel/Shape.java b/src/java/org/apache/poi/sl/usermodel/Shape.java new file mode 100644 index 0000000000..4de645d41f --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/Shape.java @@ -0,0 +1,29 @@ +/* ==================================================================== + 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.sl.usermodel; + + +public interface Shape { + ShapeContainer<? extends Shape> getParent(); + + /** + * + * @return the sheet this shape belongs to + */ + Sheet<? extends Shape, ? extends SlideShow> getSheet(); +} diff --git a/src/java/org/apache/poi/sl/usermodel/ShapeContainer.java b/src/java/org/apache/poi/sl/usermodel/ShapeContainer.java new file mode 100644 index 0000000000..1741a732d3 --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/ShapeContainer.java @@ -0,0 +1,46 @@ +/* ==================================================================== + 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.sl.usermodel; + +import java.util.List; + + +public interface ShapeContainer<T extends Shape> extends Iterable<T> { + /** + * Returns an list containing all of the elements in this container in proper + * sequence (from first to last element). + * + * @return an list containing all of the elements in this container in proper + * sequence + */ + List<T> getShapes(); + + void addShape(T shape); + + /** + * Removes the specified shape from this sheet, if it is present + * (optional operation). If this sheet does not contain the element, + * it is unchanged. + * + * @param xShape shape to be removed from this sheet, if present + * @return <tt>true</tt> if this sheet contained the specified element + * @throws IllegalArgumentException if the type of the specified shape + * is incompatible with this sheet (optional) + */ + boolean removeShape(T shape); +} diff --git a/src/java/org/apache/poi/sl/usermodel/ShapeType.java b/src/java/org/apache/poi/sl/usermodel/ShapeType.java new file mode 100644 index 0000000000..91974b79df --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/ShapeType.java @@ -0,0 +1,316 @@ +/* ==================================================================== + 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.sl.usermodel; + +/** + * known preset shape geometries in PresentationML + */ +public enum ShapeType { + NOT_PRIMITIVE(-1, 0, "NotPrimitive"), + LINE(1, 20, "Line"), + LINE_INV(2, -1, null), + TRIANGLE(3, 5, "IsocelesTriangle"), + RT_TRIANGLE(4, 6, "RightTriangle"), + RECT(5, 1, "Rectangle"), + DIAMOND(6, 4, "Diamond"), + PARALLELOGRAM(7, 7, "Parallelogram"), + TRAPEZOID(8, 8, "Trapezoid"), + NON_ISOSCELES_TRAPEZOID(9, -1, null), + PENTAGON(10, 56, "Pentagon"), + HEXAGON(11, 9, "Hexagon"), + HEPTAGON(12, -1, null), + OCTAGON(13, 10, "Octagon"), + DECAGON(14, -1, null), + DODECAGON(15, -1, null), + STAR_4(16, 187, "Star4"), + STAR_5(17, 12, "Star"), // aka star in native + STAR_6(18, -1, null), + STAR_7(19, -1, null), + STAR_8(20, 58, "Star8"), + STAR_10(21, -1, null), + STAR_12(22, -1, null), + STAR_16(23, 59, "Star16"), + SEAL(23, 18, "Seal"), // same as star_16, but twice in native + STAR_24(24, 92, "Star24"), + STAR_32(25, 60, "Star32"), + ROUND_RECT(26, 2, "RoundRectangle"), + ROUND_1_RECT(27, -1, null), + ROUND_2_SAME_RECT(28, -1, null), + ROUND_2_DIAG_RECT(29, -1, null), + SNIP_ROUND_RECT(30, -1, null), + SNIP_1_RECT(31, -1, null), + SNIP_2_SAME_RECT(32, -1, null), + SNIP_2_DIAG_RECT(33, -1, null), + PLAQUE(34, 21, "Plaque"), + ELLIPSE(35, 3, "Ellipse"), + TEARDROP(36, -1, null), + HOME_PLATE(37, 15, "HomePlate"), + CHEVRON(38, 55, "Chevron"), + PIE_WEDGE(39, -1, null), + PIE(40, -1, null), + BLOCK_ARC(41, 95, "BlockArc"), + DONUT(42, 23, "Donut"), + NO_SMOKING(43, 57, "NoSmoking"), + RIGHT_ARROW(44, 13, "Arrow"), // aka arrow in native + LEFT_ARROW(45, 66, "LeftArrow"), + UP_ARROW(46, 68, "UpArrow"), + DOWN_ARROW(47, 67, "DownArrow"), + STRIPED_RIGHT_ARROW(48, 93, "StripedRightArrow"), + NOTCHED_RIGHT_ARROW(49, 94, "NotchedRightArrow"), + BENT_UP_ARROW(50, 90, "BentUpArrow"), + LEFT_RIGHT_ARROW(51, 69, "LeftRightArrow"), + UP_DOWN_ARROW(52, 70, "UpDownArrow"), + LEFT_UP_ARROW(53, 89, "LeftUpArrow"), + LEFT_RIGHT_UP_ARROW(54, 182, "LeftRightUpArrow"), + QUAD_ARROW(55, 76, "QuadArrow"), + LEFT_ARROW_CALLOUT(56, 77, "LeftArrowCallout"), + RIGHT_ARROW_CALLOUT(57, 78, "RightArrowCallout"), + UP_ARROW_CALLOUT(58, 79, "UpArrowCallout"), + DOWN_ARROW_CALLOUT(59, 80, "DownArrowCallout"), + LEFT_RIGHT_ARROW_CALLOUT(60, 81, "LeftRightArrowCallout"), + UP_DOWN_ARROW_CALLOUT(61, 82, "UpDownArrowCallout"), + QUAD_ARROW_CALLOUT(62, 83, "QuadArrowCallout"), + BENT_ARROW(63, 91, "BentArrow"), + UTURN_ARROW(64, 101, "UturnArrow"), + CIRCULAR_ARROW(65, 99, "CircularArrow"), + LEFT_CIRCULAR_ARROW(66, -1, null), + LEFT_RIGHT_CIRCULAR_ARROW(67, -1, null), + CURVED_RIGHT_ARROW(68, 102, "CurvedRightArrow"), + CURVED_LEFT_ARROW(69, 103, "CurvedLeftArrow"), + CURVED_UP_ARROW(70, 104, "CurvedUpArrow"), + CURVED_DOWN_ARROW(71, 105, "CurvedDownArrow"), + SWOOSH_ARROW(72, -1, null), + CUBE(73, 16, "Cube"), + CAN(74, 22, "Can"), + LIGHTNING_BOLT(75, 73, "LightningBolt"), + HEART(76, 74, "Heart"), + SUN(77, 183, "Sun"), + MOON(78, 184, "Moon"), + SMILEY_FACE(79, 96, "SmileyFace"), + IRREGULAR_SEAL_1(80, 71, "IrregularSeal1"), + IRREGULAR_SEAL_2(81, 72, "IrregularSeal2"), + FOLDED_CORNER(82, 65, "FoldedCorner"), + BEVEL(83, 84, "Bevel"), + FRAME(84, 75, "PictureFrame"), + HALF_FRAME(85, -1, null), + CORNER(86, -1, null), + DIAG_STRIPE(87, -1, null), + CHORD(88, -1, null), + ARC(89, 19, "Arc"), + LEFT_BRACKET(90, 85, "LeftBracket"), + RIGHT_BRACKET(91, 86, "RightBracket"), + LEFT_BRACE(92, 87, "LeftBrace"), + RIGHT_BRACE(93, 88, "RightBrace"), + BRACKET_PAIR(94, 185, "BracketPair"), + BRACE_PAIR(95, 186, "BracePair"), + STRAIGHT_CONNECTOR_1(96, 32, "StraightConnector1"), + BENT_CONNECTOR_2(97, 33, "BentConnector2"), + BENT_CONNECTOR_3(98, 34, "BentConnector3"), + BENT_CONNECTOR_4(99, 35, "BentConnector4"), + BENT_CONNECTOR_5(100, 36, "BentConnector5"), + CURVED_CONNECTOR_2(101, 37, "CurvedConnector2"), + CURVED_CONNECTOR_3(102, 38, "CurvedConnector3"), + CURVED_CONNECTOR_4(103, 39, "CurvedConnector4"), + CURVED_CONNECTOR_5(104, 40, "CurvedConnector5"), + CALLOUT_1(105, 41, "Callout1"), + CALLOUT_2(106, 42, "Callout2"), + CALLOUT_3(107, 43, "Callout3"), + ACCENT_CALLOUT_1(108, 44, "AccentCallout1"), + ACCENT_CALLOUT_2(109, 45, "AccentCallout2"), + ACCENT_CALLOUT_3(110, 46, "AccentCallout3"), + BORDER_CALLOUT_1(111, 47, "BorderCallout1"), + BORDER_CALLOUT_2(112, 48, "BorderCallout2"), + BORDER_CALLOUT_3(113, 49, "BorderCallout3"), + ACCENT_BORDER_CALLOUT_1(114, 50, "AccentBorderCallout1"), + ACCENT_BORDER_CALLOUT_2(115, 51, "AccentBorderCallout2"), + ACCENT_BORDER_CALLOUT_3(116, 52, "AccentBorderCallout3"), + WEDGE_RECT_CALLOUT(117, 61, "WedgeRectCallout"), + WEDGE_ROUND_RECT_CALLOUT(118, 62, "WedgeRRectCallout"), + WEDGE_ELLIPSE_CALLOUT(119, 63, "WedgeEllipseCallout"), + CLOUD_CALLOUT(120, 106, "CloudCallout"), + CLOUD(121, -1, null), + RIBBON(122, 53, "Ribbon"), + RIBBON_2(123, 54, "Ribbon2"), + ELLIPSE_RIBBON(124, 107, "EllipseRibbon"), + ELLIPSE_RIBBON_2(125, 108, "EllipseRibbon2"), + LEFT_RIGHT_RIBBON(126, -1, null), + VERTICAL_SCROLL(127, 97, "VerticalScroll"), + HORIZONTAL_SCROLL(128, 98, "HorizontalScroll"), + WAVE(129, 64, "Wave"), + DOUBLE_WAVE(130, 188, "DoubleWave"), + PLUS(131, 11, "Plus"), + FLOW_CHART_PROCESS(132, 109, "FlowChartProcess"), + FLOW_CHART_DECISION(133, 110, "FlowChartDecision"), + FLOW_CHART_INPUT_OUTPUT(134, 111, "FlowChartInputOutput"), + FLOW_CHART_PREDEFINED_PROCESS(135, 112, "FlowChartPredefinedProcess"), + FLOW_CHART_INTERNAL_STORAGE(136, 113, "FlowChartInternalStorage"), + FLOW_CHART_DOCUMENT(137, 114, "FlowChartDocument"), + FLOW_CHART_MULTIDOCUMENT(138, 115, "FlowChartMultidocument"), + FLOW_CHART_TERMINATOR(139, 116, "FlowChartTerminator"), + FLOW_CHART_PREPARATION(140, 117, "FlowChartPreparation"), + FLOW_CHART_MANUAL_INPUT(141, 118, "FlowChartManualInput"), + FLOW_CHART_MANUAL_OPERATION(142, 119, "FlowChartManualOperation"), + FLOW_CHART_CONNECTOR(143, 120, "FlowChartConnector"), + FLOW_CHART_PUNCHED_CARD(144, 121, "FlowChartPunchedCard"), + FLOW_CHART_PUNCHED_TAPE(145, 122, "FlowChartPunchedTape"), + FLOW_CHART_SUMMING_JUNCTION(146, 123, "FlowChartSummingJunction"), + FLOW_CHART_OR(147, 124, "FlowChartOr"), + FLOW_CHART_COLLATE(148, 125, "FlowChartCollate"), + FLOW_CHART_SORT(149, 126, "FlowChartSort"), + FLOW_CHART_EXTRACT(150, 127, "FlowChartExtract"), + FLOW_CHART_MERGE(151, 128, "FlowChartMerge"), + FLOW_CHART_OFFLINE_STORAGE(152, 129, "FlowChartOfflineStorage"), + FLOW_CHART_ONLINE_STORAGE(153, 130, "FlowChartOnlineStorage"), + FLOW_CHART_MAGNETIC_TAPE(154, 131, "FlowChartMagneticTape"), + FLOW_CHART_MAGNETIC_DISK(155, 132, "FlowChartMagneticDisk"), + FLOW_CHART_MAGNETIC_DRUM(156, 133, "FlowChartMagneticDrum"), + FLOW_CHART_DISPLAY(157, 134, "FlowChartDisplay"), + FLOW_CHART_DELAY(158, 135, "FlowChartDelay"), + FLOW_CHART_ALTERNATE_PROCESS(159, 176, "FlowChartAlternateProcess"), + FLOW_CHART_OFFPAGE_CONNECTOR(160, 177, "FlowChartOffpageConnector"), + ACTION_BUTTON_BLANK(161, 189, "ActionButtonBlank"), + ACTION_BUTTON_HOME(162, 190, "ActionButtonHome"), + ACTION_BUTTON_HELP(163, 191, "ActionButtonHelp"), + ACTION_BUTTON_INFORMATION(164, 192, "ActionButtonInformation"), + ACTION_BUTTON_FORWARD_NEXT(165, 193, "ActionButtonForwardNext"), + ACTION_BUTTON_BACK_PREVIOUS(166, 194, "ActionButtonBackPrevious"), + ACTION_BUTTON_END(167, 195, "ActionButtonEnd"), + ACTION_BUTTON_BEGINNING(168, 196, "ActionButtonBeginning"), + ACTION_BUTTON_RETURN(169, 197, "ActionButtonReturn"), + ACTION_BUTTON_DOCUMENT(170, 198, "ActionButtonDocument"), + ACTION_BUTTON_SOUND(171, 199, "ActionButtonSound"), + ACTION_BUTTON_MOVIE(172, 200, "ActionButtonMovie"), + GEAR_6(173, -1, null), + GEAR_9(174, -1, null), + FUNNEL(175, -1, null), + MATH_PLUS(176, -1, null), + MATH_MINUS(177, -1, null), + MATH_MULTIPLY(178, -1, null), + MATH_DIVIDE(179, -1, null), + MATH_EQUAL(180, -1, null), + MATH_NOT_EQUAL(181, -1, null), + CORNER_TABS(182, -1, null), + SQUARE_TABS(183, -1, null), + PLAQUE_TABS(184, -1, null), + CHART_X(185, -1, null), + CHART_STAR(186, -1, null), + CHART_PLUS(187, -1, null), + // below are shape types only found in native + NOTCHED_CIRCULAR_ARROW(-1, 100, "NotchedCircularArrow"), + THICK_ARROW(-1, 14, "ThickArrow"), + BALLOON(-1, 17, "Balloon"), + TEXT_SIMPLE(-1, 24, "TextSimple"), + TEXT_OCTAGON(-1, 25, "TextOctagon"), + TEXT_HEXAGON(-1, 26, "TextHexagon"), + TEXT_CURVE(-1, 27, "TextCurve"), + TEXT_WAVE(-1, 28, "TextWave"), + TEXT_RING(-1, 29, "TextRing"), + TEXT_ON_CURVE(-1, 30, "TextOnCurve"), + TEXT_ON_RING(-1, 31, "TextOnRing"), + TEXT_PLAIN_TEXT(-1, 136, "TextPlainText"), + TEXT_STOP(-1, 137, "TextStop"), + TEXT_TRIANGLE(-1, 138, "TextTriangle"), + TEXT_TRIANGLE_INVERTED(-1, 139, "TextTriangleInverted"), + TEXT_CHEVRON(-1, 140, "TextChevron"), + TEXT_CHEVRON_INVERTED(-1, 141, "TextChevronInverted"), + TEXT_RING_INSIDE(-1, 142, "TextRingInside"), + TEXT_RING_OUTSIDE(-1, 143, "TextRingOutside"), + TEXT_ARCH_UP_CURVE(-1, 144, "TextArchUpCurve"), + TEXT_ARCH_DOWN_CURVE(-1, 145, "TextArchDownCurve"), + TEXT_CIRCLE_CURVE(-1, 146, "TextCircleCurve"), + TEXT_BUTTON_CURVE(-1, 147, "TextButtonCurve"), + TEXT_ARCH_UP_POUR(-1, 148, "TextArchUpPour"), + TEXT_ARCH_DOWN_POUR(-1, 149, "TextArchDownPour"), + TEXT_CIRCLE_POUR(-1, 150, "TextCirclePour"), + TEXT_BUTTON_POUR(-1, 151, "TextButtonPour"), + TEXT_CURVE_UP(-1, 152, "TextCurveUp"), + TEXT_CURVE_DOWN(-1, 153, "TextCurveDown"), + TEXT_CASCADE_UP(-1, 154, "TextCascadeUp"), + TEXT_CASCADE_DOWN(-1, 155, "TextCascadeDown"), + TEXT_WAVE_1(-1, 156, "TextWave1"), + TEXT_WAVE_2(-1, 157, "TextWave2"), + TEXT_WAVE_3(-1, 158, "TextWave3"), + TEXT_WAVE_4(-1, 159, "TextWave4"), + TEXT_INFLATE(-1, 160, "TextInflate"), + TEXT_DEFLATE(-1, 161, "TextDeflate"), + TEXT_INFLATE_BOTTOM(-1, 162, "TextInflateBottom"), + TEXT_DEFLATE_BOTTOM(-1, 163, "TextDeflateBottom"), + TEXT_INFLATE_TOP(-1, 164, "TextInflateTop"), + TEXT_DEFLATE_TOP(-1, 165, "TextDeflateTop"), + TEXT_DEFLATE_INFLATE(-1, 166, "TextDeflateInflate"), + TEXT_DEFLATE_INFLATE_DEFLATE(-1, 167, "TextDeflateInflateDeflate"), + TEXT_FADE_RIGHT(-1, 168, "TextFadeRight"), + TEXT_FADE_LEFT(-1, 169, "TextFadeLeft"), + TEXT_FADE_UP(-1, 170, "TextFadeUp"), + TEXT_FADE_DOWN(-1, 171, "TextFadeDown"), + TEXT_SLANT_UP(-1, 172, "TextSlantUp"), + TEXT_SLANT_DOWN(-1, 173, "TextSlantDown"), + TEXT_CAN_UP(-1, 174, "TextCanUp"), + TEXT_CAN_DOWN(-1, 175, "TextCanDown"), + CALLOUT_90(-1, 178, "Callout90"), + ACCENT_CALLOUT_90(-1, 179, "AccentCallout90"), + BORDER_CALLOUT_90(-1, 180, "BorderCallout90"), + ACCENT_BORDER_CALLOUT_90(-1, 181, "AccentBorderCallout90"), + HOST_CONTROL(-1, 201, "HostControl"), + TEXT_BOX(-1, 202, "TextBox") + ; + + /** Preset-ID for XML-based shapes */ + public final int ooxmlId; + + /** Preset-ID for binary-based shapes */ + public final int nativeId; + + /** POI-specific name for the binary-based type */ + public final String nativeName; + + ShapeType(int ooxmlId, int nativeId, String nativeName){ + this.ooxmlId = ooxmlId; + this.nativeId = nativeId; + this.nativeName = nativeName; + } + + /** name of the presetShapeDefinit(i)on entry */ + public String getOoxmlName() { + if (this == SEAL) return STAR_16.getOoxmlName(); + if (ooxmlId == -1) { + return (name().startsWith("TEXT")) ? RECT.getOoxmlName() : null; + } + + StringBuilder sb = new StringBuilder(); + boolean toLower = true; + for (char ch : name().toCharArray()) { + if (ch == '_') { + toLower = false; + continue; + } + sb.append(toLower ? Character.toLowerCase(ch) : Character.toUpperCase(ch)); + toLower = true; + } + + return sb.toString(); + } + + public static ShapeType forId(int id, boolean isOoxmlId){ + for(ShapeType t : values()){ + if((isOoxmlId && t.ooxmlId == id) || + (!isOoxmlId && t.nativeId == id)) return t; + } + throw new IllegalArgumentException("Unknown shape type: " + id); + } +} diff --git a/src/java/org/apache/poi/sl/usermodel/Sheet.java b/src/java/org/apache/poi/sl/usermodel/Sheet.java new file mode 100644 index 0000000000..f94b7727a7 --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/Sheet.java @@ -0,0 +1,46 @@ +/* ==================================================================== + 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.sl.usermodel; + +import java.awt.Graphics2D; + + +/** + * Common parent of Slides, Notes and Masters + */ +public interface Sheet<T extends Shape, SS extends SlideShow> extends ShapeContainer<T> { + SS getSlideShow(); + + /** + * @return whether shapes on the master sheet should be shown. By default master graphics is turned off. + * Sheets that support the notion of master (slide, slideLayout) should override it and + * check this setting in the sheet XML + */ + boolean getFollowMasterGraphics(); + + MasterSheet<T,SS> getMasterSheet(); + + Background getBackground(); + + /** + * Convenience method to draw a sheet to a graphics context + * + * @param graphics + */ + void draw(Graphics2D graphics); +} diff --git a/src/java/org/apache/poi/sl/usermodel/SimpleShape.java b/src/java/org/apache/poi/sl/usermodel/SimpleShape.java new file mode 100644 index 0000000000..e4e8efe3a1 --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/SimpleShape.java @@ -0,0 +1,36 @@ +/* ==================================================================== + 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.sl.usermodel; + +import org.apache.poi.sl.draw.geom.CustomGeometry; +import org.apache.poi.sl.draw.geom.IAdjustableShape; + + +public interface SimpleShape extends Shape, IAdjustableShape, PlaceableShape { + FillStyle getFillStyle(); + LineDecoration getLineDecoration(); + StrokeStyle getStrokeStyle(); + + CustomGeometry getGeometry(); + + ShapeType getShapeType(); + + boolean isPlaceholder(); + + Shadow getShadow(); +} diff --git a/src/java/org/apache/poi/sl/usermodel/Slide.java b/src/java/org/apache/poi/sl/usermodel/Slide.java new file mode 100644 index 0000000000..7b238de176 --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/Slide.java @@ -0,0 +1,37 @@ +/* ==================================================================== + 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.sl.usermodel; + +public interface Slide<T extends Shape, SS extends SlideShow, N extends Notes<T,SS>> extends Sheet<T, SS> { + N getNotes(); + void setNotes(N notes); + + boolean getFollowMasterBackground(); + void setFollowMasterBackground(boolean follow); + + boolean getFollowMasterColourScheme(); + void setFollowMasterColourScheme(boolean follow); + + boolean getFollowMasterObjects(); + void setFollowMasterObjects(boolean follow); + + /** + * @return the 1-based slide no. + */ + int getSlideNumber(); +} diff --git a/src/java/org/apache/poi/sl/usermodel/SlideShow.java b/src/java/org/apache/poi/sl/usermodel/SlideShow.java new file mode 100644 index 0000000000..ca0ddf3918 --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/SlideShow.java @@ -0,0 +1,45 @@ +/* ==================================================================== + 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.sl.usermodel; + +import java.awt.Dimension; +import java.io.IOException; +import java.util.List; + +public interface SlideShow { + Slide<? extends Shape, ? extends SlideShow, ? extends Notes<?,?>> createSlide() throws IOException; + + List<? extends Slide<? extends Shape, ? extends SlideShow, ? extends Notes<?,?>>> getSlides(); + + MasterSheet<? extends Shape, ? extends SlideShow> createMasterSheet() throws IOException; + + /** + * Returns all slide masters. + * This doesn't include notes master and other arbitrary masters. + */ + List<? extends MasterSheet<? extends Shape, ? extends SlideShow>> getSlideMasters(); + + Resources getResources(); + + /** + * Returns the current page size + * + * @return the page size + */ + Dimension getPageSize(); +} diff --git a/src/java/org/apache/poi/sl/usermodel/StrokeStyle.java b/src/java/org/apache/poi/sl/usermodel/StrokeStyle.java new file mode 100644 index 0000000000..244173fed4 --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/StrokeStyle.java @@ -0,0 +1,129 @@ +/* ==================================================================== + 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.sl.usermodel; + +public interface StrokeStyle { + enum LineCap { + /** Rounded ends */ + ROUND(1), + /** Square protrudes by half line width */ + SQUARE(2), + /** Line ends at end point*/ + FLAT(3); + + public final int ooxmlId; + + LineCap(int ooxmlId) { + this.ooxmlId = ooxmlId; + } + + public static LineCap fromOoxmlId(int ooxmlId) { + for (LineCap lc : values()) { + if (lc.ooxmlId == ooxmlId) return lc; + } + return null; + } + } + + /** + * The line dash with pattern. + * The pattern is derived empirically on PowerPoint 2010 and needs to be multiplied + * with actual line width + */ + enum LineDash { + /** Solid (continuous) pen - native 1 */ + SOLID(1, 1, null), + /** square dot style - native 6 */ + DOT(6, 2, 1,1), + /** dash style - native 7 */ + DASH(7, 3, 3,4), + /** dash short dash - native 9*/ + DASH_DOT(9, 5, 4,3,1,3), + /** long dash style - native 8 */ + LG_DASH(8, 4, 8,3), + /** long dash short dash - native 10 */ + LG_DASH_DOT(10, 6, 8,3,1,3), + /** long dash short dash short dash - native 11 */ + LG_DASH_DOT_DOT(11, 7, 8,3,1,3,1,3), + /** PS_DASH system dash style - native 2 */ + SYS_DASH(2, 8, 2,2), + /** PS_DOT system dash style - native 3 */ + SYS_DOT(3, 9, 1,1), + /** PS_DASHDOT system dash style - native 4 */ + SYS_DASH_DOT(4, 10, 2,2,1,1), + /** PS_DASHDOTDOT system dash style / native 5 */ + SYS_DASH_DOT_DOT(5, 11, 2,2,1,1,1,1); + + public final int pattern[]; + public final int nativeId; + public final int ooxmlId; + + LineDash(int nativeId, int ooxmlId, int... pattern) { + this.nativeId = nativeId; + this.ooxmlId = ooxmlId; + this.pattern = (pattern == null || pattern.length == 0) ? null : pattern; + } + + public static LineDash fromNativeId(int nativeId) { + for (LineDash ld : values()) { + if (ld.nativeId == nativeId) return ld; + } + return null; + } + + public static LineDash fromOoxmlId(int ooxmlId) { + for (LineDash ld : values()) { + if (ld.ooxmlId == ooxmlId) return ld; + } + return null; + } + } + + enum LineCompound { + /** Single line (of width lineWidth) - native 0 / ooxml default */ + SINGLE(0), + /** Double lines of equal width - native 1 / ooxml "dbl" */ + DOUBLE(1), + /** Double lines, one thick, one thin - native 2 / ooxml "thickThin" */ + THICK_THIN(2), + /** Double lines, reverse order - native 3 / ooxml "thinThick" */ + THIN_THICK(3), + /** Three lines, thin, thick, thin - native 4 / ooxml "tri" */ + TRIPLE(4); + + public final int nativeId; + + LineCompound(int nativeId) { + this.nativeId = nativeId; + } + + public static LineCompound fromNativeId(int nativeId) { + for (LineCompound lc : values()) { + if (lc.nativeId == nativeId) return lc; + } + return null; + } + } + + + PaintStyle getPaint(); + LineCap getLineCap(); + LineDash getLineDash(); + LineCompound getLineCompound(); + double getLineWidth(); +} diff --git a/src/java/org/apache/poi/sl/usermodel/TableShape.java b/src/java/org/apache/poi/sl/usermodel/TableShape.java new file mode 100644 index 0000000000..4fda40f2df --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/TableShape.java @@ -0,0 +1,22 @@ +/* ====================================================================
+ 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.sl.usermodel;
+
+public interface TableShape extends Shape, PlaceableShape {
+ // to be defined ...
+}
diff --git a/src/java/org/apache/poi/sl/usermodel/TextBox.java b/src/java/org/apache/poi/sl/usermodel/TextBox.java new file mode 100644 index 0000000000..3fa3bbe20d --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/TextBox.java @@ -0,0 +1,21 @@ +/* ==================================================================== + 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.sl.usermodel; + +public interface TextBox<T extends TextParagraph<? extends TextRun>> extends AutoShape<T> { +} diff --git a/src/java/org/apache/poi/sl/usermodel/TextParagraph.java b/src/java/org/apache/poi/sl/usermodel/TextParagraph.java new file mode 100644 index 0000000000..a914dd7cb3 --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/TextParagraph.java @@ -0,0 +1,324 @@ +/* ====================================================================
+ 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.sl.usermodel;
+
+import java.awt.Color;
+
+
+public interface TextParagraph<T extends TextRun> extends Iterable<T> {
+
+ /**
+ * Specifies a list of text alignment types
+ */
+ public enum TextAlign {
+ /**
+ * For horizontal text, left aligned.
+ * For vertical text, top aligned.
+ */
+ LEFT,
+
+ /**
+ * For horizontal text, centered.
+ * For vertical text, middle aligned.
+ */
+ CENTER,
+
+ /**
+ * For horizontal text, right aligned.
+ * For vertical text, bottom aligned.
+ */
+ RIGHT,
+
+ /**
+ * Align text so that it is justified across the whole line. It
+ * is smart in the sense that it will not justify sentences
+ * which are short
+ *
+ * For horizontal text, flush left and right.
+ * For vertical text, flush top and bottom.
+ */
+ JUSTIFY,
+
+ /**
+ * Kashida justify low.
+ */
+ JUSTIFY_LOW,
+
+ /**
+ * Distribute space between characters.
+ */
+ DIST,
+
+ /**
+ * Thai distribution justification.
+ */
+ THAI_DIST
+ }
+
+ /**
+ *
+ */
+ public enum FontAlign {
+ AUTO,
+
+ /**
+ * Characters hang from top of line height.
+ * Also known as "Hanging"
+ */
+ TOP,
+
+ /**
+ * Characters centered within line height.
+ */
+ CENTER,
+
+ /**
+ * Place characters on font baseline.
+ * Also known as "Roman"
+ */
+ BASELINE,
+
+ /**
+ * Characters are anchored to the very bottom of a single line.
+ * This is different than BASELINE because of letters such as "g", "q", and "y".
+ * Also known as "UpholdFixed"
+ */
+ BOTTOM;
+ }
+
+ public interface BulletStyle {
+ String getBulletCharacter();
+ String getBulletFont();
+
+ /**
+ * The bullet point font size
+ * If bulletFontSize >= 0, then space is a percentage of normal line height.
+ * If bulletFontSize < 0, the absolute value in points
+ *
+ * @return the bullet point font size
+ */
+ Double getBulletFontSize();
+ Color getBulletFontColor();
+
+ AutoNumberingScheme getAutoNumberingScheme();
+ /**
+ * Index (1-based) of the first auto number value, or null if auto numbering scheme
+ * wasn't assigned.
+ */
+ Integer getAutoNumberingStartAt();
+ }
+
+ /**
+ * The amount of vertical white space before the paragraph
+ * This may be specified in two different ways, percentage spacing and font point spacing:
+ * <p>
+ * If spaceBefore >= 0, then space is a percentage of normal line height.
+ * If spaceBefore < 0, the absolute value in points
+ * </p>
+ *
+ * @return the vertical white space before the paragraph, or null if unset
+ */
+ Double getSpaceBefore();
+
+ /**
+ * Set the amount of vertical white space that will be present before the paragraph.
+ * This space is specified in either percentage or points:
+ * <p>
+ * If spaceBefore >= 0, then space is a percentage of normal line height.
+ * If spaceBefore < 0, the absolute value of linespacing is the spacing in points
+ * </p>
+ * Examples:
+ * <pre><code>
+ * // The paragraph will be formatted to have a spacing before the paragraph text.
+ * // The spacing will be 200% of the size of the largest text on each line
+ * paragraph.setSpaceBefore(200);
+ *
+ * // The spacing will be a size of 48 points
+ * paragraph.setSpaceBefore(-48.0);
+ * </code></pre>
+ *
+ * @param spaceBefore the vertical white space before the paragraph, null to unset
+ */
+ void setSpaceBefore(Double spaceBefore);
+
+ /**
+ * The amount of vertical white space after the paragraph
+ * This may be specified in two different ways, percentage spacing and font point spacing:
+ * <p>
+ * If spaceBefore >= 0, then space is a percentage of normal line height.
+ * If spaceBefore < 0, the absolute value of linespacing is the spacing in points
+ * </p>
+ *
+ * @return the vertical white space after the paragraph or null, if unset
+ */
+ Double getSpaceAfter();
+
+ /**
+ * Set the amount of vertical white space that will be present after the paragraph.
+ * This space is specified in either percentage or points:
+ * <p>
+ * If spaceAfter >= 0, then space is a percentage of normal line height.
+ * If spaceAfter < 0, the absolute value of linespacing is the spacing in points
+ * </p>
+ * Examples:
+ * <pre><code>
+ * // The paragraph will be formatted to have a spacing after the paragraph text.
+ * // The spacing will be 200% of the size of the largest text on each line
+ * paragraph.setSpaceAfter(200);
+ *
+ * // The spacing will be a size of 48 points
+ * paragraph.setSpaceAfter(-48.0);
+ * </code></pre>
+ *
+ * @param spaceAfter the vertical white space after the paragraph, null to unset
+ */
+ public void setSpaceAfter(Double spaceAfter);
+
+ /**
+ * @return the left margin (in points) of the paragraph or null, if unset
+ */
+ Double getLeftMargin();
+
+ /**
+ * Specifies the left margin of the paragraph. This is specified in addition to the text body
+ * inset and applies only to this text paragraph. That is the text body Inset and the LeftMargin
+ * attributes are additive with respect to the text position.
+ *
+ * @param leftMargin the left margin (in points) or null to unset
+ */
+ void setLeftMargin(Double leftMargin);
+
+
+ /**
+ * Specifies the right margin of the paragraph. This is specified in addition to the text body
+ * inset and applies only to this text paragraph. That is the text body Inset and the RightMargin
+ * attributes are additive with respect to the text position.
+ *
+ * The right margin is not support and therefore ignored by the HSLF implementation.
+ *
+ * @return the right margin (in points) of the paragraph or null, if unset
+ */
+ Double getRightMargin();
+
+ /**
+ * @param rightMargin the right margin (in points) of the paragraph
+ */
+ void setRightMargin(Double rightMargin);
+
+ /**
+ * @return the indent (in points) applied to the first line of text in the paragraph.
+ * or null, if unset
+ */
+ Double getIndent();
+
+ /**
+ * Specifies the indent size that will be applied to the first line of text in the paragraph.
+ *
+ * @param indent the indent (in points) applied to the first line of text in the paragraph
+ */
+ void setIndent(Double indent);
+
+
+ /**
+ * @return the text level of this paragraph (0-based). Default is 0.
+ */
+ int getIndentLevel();
+
+ /**
+ * Specifies the particular level text properties that this paragraph will follow.
+ * The value for this attribute formats the text according to the corresponding level
+ * paragraph properties defined in the SlideMaster.
+ *
+ * @param level the level (0 ... 4)
+ */
+ void setIndentLevel(int level);
+
+ /**
+ * Returns the vertical line spacing that is to be used within a paragraph.
+ * This may be specified in two different ways, percentage spacing and font point spacing:
+ * <p>
+ * If linespacing >= 0, then linespacing is a percentage of normal line height.
+ * If linespacing < 0, the absolute value of linespacing is the spacing in points
+ * </p>
+ *
+ * @return the vertical line spacing or null, if unset
+ */
+ Double getLineSpacing();
+
+ /**
+ * This element specifies the vertical line spacing that is to be used within a paragraph.
+ * This may be specified in two different ways, percentage spacing and font point spacing:
+ * <p>
+ * If linespacing >= 0, then linespacing is a percentage of normal line height
+ * If linespacing < 0, the absolute value of linespacing is the spacing in points
+ * </p>
+ * Examples:
+ * <pre><code>
+ * // spacing will be 120% of the size of the largest text on each line
+ * paragraph.setLineSpacing(120);
+ *
+ * // spacing will be 200% of the size of the largest text on each line
+ * paragraph.setLineSpacing(200);
+ *
+ * // spacing will be 48 points
+ * paragraph.setLineSpacing(-48.0);
+ * </code></pre>
+ *
+ * @param linespacing the vertical line spacing
+ */
+ void setLineSpacing(Double lineSpacing);
+
+ String getDefaultFontFamily();
+
+ /**
+ * @return the default font size, in case its not set in the textrun or null, if unset
+ */
+ Double getDefaultFontSize();
+
+ /**
+ * Returns the alignment that is applied to the paragraph.
+ *
+ * If this attribute is omitted, then a value of left is implied.
+ * @return ??? alignment that is applied to the paragraph
+ */
+ TextAlign getTextAlign();
+
+
+ /**
+ * Returns the font alignment that is applied to the paragraph.
+ *
+ * If this attribute is omitted, then null is return,
+ * user code can imply the a value of {@link FontAlign#AUTO}
+ *
+ * @return alignment that is applied to the paragraph
+ */
+ FontAlign getFontAlign();
+
+ /**
+ * @return the bullet style of the paragraph, if {@code null} then no bullets are used
+ */
+ BulletStyle getBulletStyle();
+
+ /**
+ * @return the default size for a tab character within this paragraph in points, null if unset
+ */
+ Double getDefaultTabSize();
+
+
+ TextShape<? extends TextParagraph<T>> getParentShape();
+}
diff --git a/src/java/org/apache/poi/sl/usermodel/TextRun.java b/src/java/org/apache/poi/sl/usermodel/TextRun.java new file mode 100644 index 0000000000..946bfc3217 --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/TextRun.java @@ -0,0 +1,63 @@ +/* ==================================================================== + 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.sl.usermodel; + +import java.awt.Color; + +/** + * Some text. + */ +public interface TextRun { + enum TextCap { + NONE, + SMALL, + ALL + } + + String getRawText(); + void setText(String text); + + TextCap getTextCap(); + + Color getFontColor(); + void setFontColor(Color color); + + + /** + * @return font size in points or null if font size is not set. + */ + Double getFontSize(); + + /** + * @param fontSize font size in points, if null the underlying fontsize will be unset + */ + void setFontSize(Double fontSize); + String getFontFamily(); + + boolean isBold(); + boolean isItalic(); + boolean isUnderlined(); + boolean isStrikethrough(); + boolean isSubscript(); + boolean isSuperscript(); + + /** + * @return the pitch and family id or -1 if not applicable + */ + byte getPitchAndFamily(); +} diff --git a/src/java/org/apache/poi/sl/usermodel/TextShape.java b/src/java/org/apache/poi/sl/usermodel/TextShape.java new file mode 100644 index 0000000000..927fdf1f9d --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/TextShape.java @@ -0,0 +1,128 @@ +/* ====================================================================
+ 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.sl.usermodel;
+
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+
+
+
+public interface TextShape<T extends TextParagraph<? extends TextRun>> extends SimpleShape, Iterable<T> {
+ /**
+ * Vertical Text Types
+ */
+ public enum TextDirection {
+ /**
+ * Horizontal text. This should be default.
+ */
+ HORIZONTAL,
+ /**
+ * Vertical orientation.
+ * (each line is 90 degrees rotated clockwise, so it goes
+ * from top to bottom; each next line is to the left from
+ * the previous one).
+ */
+ VERTICAL,
+ /**
+ * Vertical orientation.
+ * (each line is 270 degrees rotated clockwise, so it goes
+ * from bottom to top; each next line is to the right from
+ * the previous one).
+ */
+ VERTICAL_270,
+ /**
+ * Determines if all of the text is vertical
+ * ("one letter on top of another").
+ */
+ STACKED;
+ }
+
+ /**
+ * Specifies alist of auto-fit types.
+ * <p>
+ * Autofit specofies that a shape should be auto-fit to fully contain the text described within it.
+ * Auto-fitting is when text within a shape is scaled in order to contain all the text inside
+ * </p>
+ */
+ public enum TextAutofit {
+ /**
+ * Specifies that text within the text body should not be auto-fit to the bounding box.
+ * Auto-fitting is when text within a text box is scaled in order to remain inside
+ * the text box.
+ */
+ NONE,
+ /**
+ * Specifies that text within the text body should be normally auto-fit to the bounding box.
+ * Autofitting is when text within a text box is scaled in order to remain inside the text box.
+ *
+ * <p>
+ * <em>Example:</em> Consider the situation where a user is building a diagram and needs
+ * to have the text for each shape that they are using stay within the bounds of the shape.
+ * An easy way this might be done is by using NORMAL autofit
+ * </p>
+ */
+ NORMAL,
+ /**
+ * Specifies that a shape should be auto-fit to fully contain the text described within it.
+ * Auto-fitting is when text within a shape is scaled in order to contain all the text inside.
+ *
+ * <p>
+ * <em>Example:</em> Consider the situation where a user is building a diagram and needs to have
+ * the text for each shape that they are using stay within the bounds of the shape.
+ * An easy way this might be done is by using SHAPE autofit
+ * </p>
+ */
+ SHAPE
+ }
+
+ /**
+ * @return text shape margin
+ */
+ Insets2D getInsets();
+
+ /**
+ * Compute the cumulative height occupied by the text
+ */
+ double getTextHeight();
+
+ /**
+ * Returns the type of vertical alignment for the text.
+ *
+ * @return the type of vertical alignment
+ */
+ VerticalAlignment getVerticalAlignment();
+
+ /**
+ * Returns if the text is centered.
+ * If true and if the individual paragraph settings allow it,
+ * the whole text block will be displayed centered, i.e. its left and right
+ * margin will be maximized while still keeping the alignment of the paragraphs
+ *
+ * @return true, if the text anchor is horizontal centered
+ */
+ boolean isHorizontalCentered();
+
+ /**
+ * @return whether to wrap words within the bounding rectangle
+ */
+ boolean getWordWrap();
+
+ /**
+ * @return vertical orientation of the text
+ */
+ TextDirection getTextDirection();
+}
diff --git a/src/java/org/apache/poi/sl/usermodel/VerticalAlignment.java b/src/java/org/apache/poi/sl/usermodel/VerticalAlignment.java new file mode 100644 index 0000000000..540bf2ed51 --- /dev/null +++ b/src/java/org/apache/poi/sl/usermodel/VerticalAlignment.java @@ -0,0 +1,71 @@ +/*
+ * ====================================================================
+ * 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.sl.usermodel;
+
+/**
+ * Specifies a list of available anchoring types for text
+ *
+ * @author Yegor Kozlov
+ */
+public enum VerticalAlignment {
+ /**
+ * Anchor the text at the top of the bounding rectangle
+ */
+ TOP,
+
+ /**
+ * Anchor the text at the middle of the bounding rectangle
+ */
+ MIDDLE,
+
+ /**
+ * Anchor the text at the bottom of the bounding rectangle.
+ */
+ BOTTOM,
+
+ /**
+ * Anchor the text so that it is justified vertically.
+ * <p>
+ * When text is horizontal, this spaces out the actual lines of
+ * text and is almost always identical in behavior to
+ * {@link #DISTRIBUTED} (special case: if only 1 line, then anchored at top).
+ * </p>
+ * <p>
+ * When text is vertical, then it justifies the letters
+ * vertically. This is different than {@link #DISTRIBUTED},
+ * because in some cases such as very little text in a line,
+ * it will not justify.
+ * </p>
+ */
+ JUSTIFIED,
+
+ /**
+ * Anchor the text so that it is distributed vertically.
+ * <p>
+ * When text is horizontal, this spaces out the actual lines
+ * of text and is almost always identical in behavior to
+ * {@link #JUSTIFIED} (special case: if only 1 line, then anchored in middle).
+ * </p>
+ * <p>
+ * When text is vertical, then it distributes the letters vertically.
+ * This is different than {@link #JUSTIFIED}, because it always forces distribution
+ * of the words, even if there are only one or two words in a line.
+ */
+ DISTRIBUTED
+}
diff --git a/src/java/org/apache/poi/ss/formula/FormulaParser.java b/src/java/org/apache/poi/ss/formula/FormulaParser.java index 72ed008cf1..5124a44632 100644 --- a/src/java/org/apache/poi/ss/formula/FormulaParser.java +++ b/src/java/org/apache/poi/ss/formula/FormulaParser.java @@ -617,16 +617,16 @@ public final class FormulaParser { return new ParseNode(ptg); } - private static AreaReference createAreaRef(SimpleRangePart part1, SimpleRangePart part2) { + private AreaReference createAreaRef(SimpleRangePart part1, SimpleRangePart part2) { if (!part1.isCompatibleForArea(part2)) { throw new FormulaParseException("has incompatible parts: '" + part1.getRep() + "' and '" + part2.getRep() + "'."); } if (part1.isRow()) { - return AreaReference.getWholeRow(part1.getRep(), part2.getRep()); + return AreaReference.getWholeRow(_ssVersion, part1.getRep(), part2.getRep()); } if (part1.isColumn()) { - return AreaReference.getWholeColumn(part1.getRep(), part2.getRep()); + return AreaReference.getWholeColumn(_ssVersion, part1.getRep(), part2.getRep()); } return new AreaReference(part1.getCellReference(), part2.getCellReference()); } diff --git a/src/java/org/apache/poi/ss/formula/eval/FunctionEval.java b/src/java/org/apache/poi/ss/formula/eval/FunctionEval.java index 5ba8947067..cf88b37a62 100644 --- a/src/java/org/apache/poi/ss/formula/eval/FunctionEval.java +++ b/src/java/org/apache/poi/ss/formula/eval/FunctionEval.java @@ -27,8 +27,8 @@ import org.apache.poi.ss.formula.function.FunctionMetadataRegistry; import org.apache.poi.ss.formula.functions.*; /** - * @author Amol S. Deshmukh < amolweb at ya hoo dot com > - * @author Johan Karlsteen - added Intercept and Slope + * Mappings from the Excel functions to our evaluation implementations + * (where avilable) */ public final class FunctionEval { /** @@ -99,7 +99,7 @@ public final class FunctionEval { retval[39] = NumericFunction.MOD; retval[43] = new DStarRunner(new DMin()); - + retval[46] = AggregateFunction.VAR; retval[48] = TextFunction.TEXT; @@ -154,6 +154,7 @@ public final class FunctionEval { retval[124] = TextFunction.FIND; + retval[126] = LogicalFunction.ISERR; retval[127] = LogicalFunction.ISTEXT; retval[128] = LogicalFunction.ISNUMBER; retval[129] = LogicalFunction.ISBLANK; @@ -161,7 +162,7 @@ public final class FunctionEval { retval[FunctionID.INDIRECT] = null; // Indirect.evaluate has different signature - retval[162] = TextFunction.CLEAN; //Aniket Banerjee + retval[162] = TextFunction.CLEAN; retval[167] = new IPMT(); retval[168] = new PPMT(); retval[169] = new Counta(); @@ -177,7 +178,7 @@ public final class FunctionEval { retval[212] = NumericFunction.ROUNDUP; retval[213] = NumericFunction.ROUNDDOWN; retval[216] = new Rank(); - retval[219] = new Address(); //Aniket Banerjee + retval[219] = new Address(); retval[220] = new Days360(); retval[221] = new Today(); @@ -290,7 +291,7 @@ public final class FunctionEval { throw new IllegalArgumentException(name + " is a function from the Excel Analysis Toolpack. " + "Use AnalysisToolpack.registerFunction(String name, FreeRefFunction func) instead."); } - + throw new IllegalArgumentException("Unknown function: " + name); } diff --git a/src/java/org/apache/poi/ss/formula/eval/OperandResolver.java b/src/java/org/apache/poi/ss/formula/eval/OperandResolver.java index 8e0ea3ba85..af4cb81b31 100644 --- a/src/java/org/apache/poi/ss/formula/eval/OperandResolver.java +++ b/src/java/org/apache/poi/ss/formula/eval/OperandResolver.java @@ -57,7 +57,7 @@ public final class OperandResolver { */ public static ValueEval getSingleValue(ValueEval arg, int srcCellRow, int srcCellCol) throws EvaluationException { - ValueEval result; + final ValueEval result; if (arg instanceof RefEval) { result = chooseSingleElementFromRef((RefEval) arg); } else if (arg instanceof AreaEval) { diff --git a/src/java/org/apache/poi/ss/formula/functions/Countif.java b/src/java/org/apache/poi/ss/formula/functions/Countif.java index 6f27fdf48e..9023815c36 100644 --- a/src/java/org/apache/poi/ss/formula/functions/Countif.java +++ b/src/java/org/apache/poi/ss/formula/functions/Countif.java @@ -30,7 +30,7 @@ import org.apache.poi.ss.formula.eval.RefEval; import org.apache.poi.ss.formula.eval.StringEval; import org.apache.poi.ss.formula.eval.ValueEval; import org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate; -import org.apache.poi.ss.usermodel.ErrorConstants; +import org.apache.poi.ss.usermodel.FormulaError; /** * Implementation for the function COUNTIF @@ -254,6 +254,7 @@ public final class Countif extends Fixed2ArgFunction { // boolean values when the target(x) is a string return false; } + @SuppressWarnings("unused") StringEval se = (StringEval)x; Boolean val = parseBoolean(se.getStringValue()); if(val == null) { @@ -286,7 +287,7 @@ public final class Countif extends Fixed2ArgFunction { return evaluate(testValue - _value); } } - private static final class ErrorMatcher extends MatcherBase { + public static final class ErrorMatcher extends MatcherBase { private final int _value; @@ -296,7 +297,7 @@ public final class Countif extends Fixed2ArgFunction { } @Override protected String getValueText() { - return ErrorConstants.getText(_value); + return FormulaError.forInt(_value).getString(); } public boolean matches(ValueEval x) { @@ -306,6 +307,10 @@ public final class Countif extends Fixed2ArgFunction { } return false; } + + public int getValue() { + return _value; + } } public static final class StringMatcher extends MatcherBase { @@ -486,7 +491,7 @@ public final class Countif extends Fixed2ArgFunction { */ private static ValueEval evaluateCriteriaArg(ValueEval arg, int srcRowIndex, int srcColumnIndex) { try { - return OperandResolver.getSingleValue(arg, srcRowIndex, (short)srcColumnIndex); + return OperandResolver.getSingleValue(arg, srcRowIndex, srcColumnIndex); } catch (EvaluationException e) { return e.getErrorEval(); } diff --git a/src/java/org/apache/poi/ss/formula/functions/LogicalFunction.java b/src/java/org/apache/poi/ss/formula/functions/LogicalFunction.java index ef18dab645..c4b3e67187 100644 --- a/src/java/org/apache/poi/ss/formula/functions/LogicalFunction.java +++ b/src/java/org/apache/poi/ss/formula/functions/LogicalFunction.java @@ -90,6 +90,27 @@ public abstract class LogicalFunction extends Fixed1ArgFunction { } }; + /** + * Implementation of Excel <tt>ISERR()</tt> function.<p/> + * + * <b>Syntax</b>:<br/> + * <b>ISERR</b>(<b>value</b>)<p/> + * + * <b>value</b> The value to be tested<p/> + * + * Returns the logical value <tt>TRUE</tt> if value refers to any error value except + * <tt>'#N/A'</tt>; otherwise, it returns <tt>FALSE</tt>. + */ + public static final Function ISERR = new LogicalFunction() { + @Override + protected boolean evaluate(ValueEval arg) { + if (arg instanceof ErrorEval) { + return arg != ErrorEval.NA; + } + return false; + } + }; + /** * Implementation for Excel ISNA() function.<p/> * diff --git a/src/java/org/apache/poi/ss/formula/functions/Sumif.java b/src/java/org/apache/poi/ss/formula/functions/Sumif.java index ef381adb02..977647fd20 100644 --- a/src/java/org/apache/poi/ss/formula/functions/Sumif.java +++ b/src/java/org/apache/poi/ss/formula/functions/Sumif.java @@ -69,6 +69,12 @@ public final class Sumif extends Var2or3ArgFunction { AreaEval aeSum) { // TODO - junit to prove last arg must be srcColumnIndex and not srcRowIndex I_MatchPredicate mp = Countif.createCriteriaPredicate(arg1, srcRowIndex, srcColumnIndex); + + // handle empty cells + if(mp == null) { + return NumberEval.ZERO; + } + double result = sumMatchingCells(aeRange, mp, aeSum); return new NumberEval(result); } diff --git a/src/java/org/apache/poi/ss/formula/functions/Sumifs.java b/src/java/org/apache/poi/ss/formula/functions/Sumifs.java index 63d35439af..ebdddb69f7 100644 --- a/src/java/org/apache/poi/ss/formula/functions/Sumifs.java +++ b/src/java/org/apache/poi/ss/formula/functions/Sumifs.java @@ -20,8 +20,14 @@ package org.apache.poi.ss.formula.functions; import org.apache.poi.ss.formula.OperationEvaluationContext; -import org.apache.poi.ss.formula.eval.*; +import org.apache.poi.ss.formula.eval.AreaEval; +import org.apache.poi.ss.formula.eval.ErrorEval; +import org.apache.poi.ss.formula.eval.EvaluationException; +import org.apache.poi.ss.formula.eval.NumberEval; +import org.apache.poi.ss.formula.eval.RefEval; +import org.apache.poi.ss.formula.eval.ValueEval; import org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate; +import org.apache.poi.ss.formula.functions.Countif.ErrorMatcher; /** * Implementation for the Excel function SUMIFS<p> @@ -48,6 +54,7 @@ public final class Sumifs implements FreeRefFunction { public static final FreeRefFunction instance = new Sumifs(); public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) { + // need at least 3 arguments and need to have an odd number of arguments (sum-range plus x*(criteria_range, criteria)) if(args.length < 3 || args.length % 2 == 0) { return ErrorEval.VALUE_INVALID; } @@ -60,10 +67,12 @@ public final class Sumifs implements FreeRefFunction { I_MatchPredicate[] mp = new I_MatchPredicate[ae.length]; for(int i = 1, k=0; i < args.length; i += 2, k++){ ae[k] = convertRangeArg(args[i]); + mp[k] = Countif.createCriteriaPredicate(args[i+1], ec.getRowIndex(), ec.getColumnIndex()); } validateCriteriaRanges(ae, sumRange); + validateCriteria(mp); double result = sumMatchingCells(ae, mp, sumRange); return new NumberEval(result); @@ -76,7 +85,7 @@ public final class Sumifs implements FreeRefFunction { * Verify that each <code>criteriaRanges</code> argument contains the same number of rows and columns * as the <code>sumRange</code> argument * - * @throws EvaluationException if + * @throws EvaluationException if the ranges do not match. */ private void validateCriteriaRanges(AreaEval[] criteriaRanges, AreaEval sumRange) throws EvaluationException { for(AreaEval r : criteriaRanges){ @@ -88,6 +97,22 @@ public final class Sumifs implements FreeRefFunction { } /** + * Verify that each <code>criteria</code> predicate is valid, i.e. not an error + * + * @throws EvaluationException if there are criteria which resulted in Errors. + */ + private void validateCriteria(I_MatchPredicate[] criteria) throws EvaluationException { + for(I_MatchPredicate predicate : criteria) { + + // check for errors in predicate and return immediately using this error code + if(predicate instanceof ErrorMatcher) { + throw new EvaluationException(ErrorEval.valueOf(((ErrorMatcher)predicate).getValue())); + } + } + } + + + /** * * @param ranges criteria ranges, each range must be of the same dimensions as <code>aeSum</code> * @param predicates array of predicates, a predicate for each value in <code>ranges</code> diff --git a/src/java/org/apache/poi/ss/formula/ptg/Area3DPxg.java b/src/java/org/apache/poi/ss/formula/ptg/Area3DPxg.java index e27ccdd7a1..665ac98cfb 100644 --- a/src/java/org/apache/poi/ss/formula/ptg/Area3DPxg.java +++ b/src/java/org/apache/poi/ss/formula/ptg/Area3DPxg.java @@ -31,7 +31,7 @@ import org.apache.poi.util.LittleEndianOutput; * <p>This is XSSF only, as it stores the sheet / book references * in String form. The HSSF equivalent using indexes is {@link Area3DPtg}</p> */ -public final class Area3DPxg extends AreaPtgBase implements Pxg { +public final class Area3DPxg extends AreaPtgBase implements Pxg3D { private int externalWorkbookNumber = -1; private String firstSheetName; private String lastSheetName; diff --git a/src/java/org/apache/poi/ss/formula/ptg/AreaPtgBase.java b/src/java/org/apache/poi/ss/formula/ptg/AreaPtgBase.java index 5b77b09fed..96eda87576 100644 --- a/src/java/org/apache/poi/ss/formula/ptg/AreaPtgBase.java +++ b/src/java/org/apache/poi/ss/formula/ptg/AreaPtgBase.java @@ -17,6 +17,7 @@ package org.apache.poi.ss.formula.ptg; +import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.util.AreaReference; import org.apache.poi.ss.util.CellReference; import org.apache.poi.util.BitField; @@ -256,7 +257,7 @@ public abstract class AreaPtgBase extends OperandPtg implements AreaI { CellReference topLeft = new CellReference(getFirstRow(),getFirstColumn(),!isFirstRowRelative(),!isFirstColRelative()); CellReference botRight = new CellReference(getLastRow(),getLastColumn(),!isLastRowRelative(),!isLastColRelative()); - if(AreaReference.isWholeColumnReference(topLeft, botRight)) { + if(AreaReference.isWholeColumnReference(SpreadsheetVersion.EXCEL97, topLeft, botRight)) { return (new AreaReference(topLeft, botRight)).formatAsString(); } return topLeft.formatAsString() + ":" + botRight.formatAsString(); diff --git a/src/java/org/apache/poi/ss/formula/ptg/Pxg3D.java b/src/java/org/apache/poi/ss/formula/ptg/Pxg3D.java new file mode 100644 index 0000000000..49083fe150 --- /dev/null +++ b/src/java/org/apache/poi/ss/formula/ptg/Pxg3D.java @@ -0,0 +1,27 @@ +/* ==================================================================== + 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.ss.formula.ptg; + +/** + * An XSSF only special kind of Ptg, which stores a range of + * sheet / book references in string form. + */ +public interface Pxg3D extends Pxg { + public String getLastSheetName(); + public void setLastSheetName(String sheetName); +} diff --git a/src/java/org/apache/poi/ss/formula/ptg/Ref3DPxg.java b/src/java/org/apache/poi/ss/formula/ptg/Ref3DPxg.java index 41039cd927..3b78c5a4b0 100644 --- a/src/java/org/apache/poi/ss/formula/ptg/Ref3DPxg.java +++ b/src/java/org/apache/poi/ss/formula/ptg/Ref3DPxg.java @@ -31,7 +31,7 @@ import org.apache.poi.util.LittleEndianOutput; * <p>This is XSSF only, as it stores the sheet / book references * in String form. The HSSF equivalent using indexes is {@link Ref3DPtg}</p> */ -public final class Ref3DPxg extends RefPtgBase implements Pxg { +public final class Ref3DPxg extends RefPtgBase implements Pxg3D { private int externalWorkbookNumber = -1; private String firstSheetName; private String lastSheetName; diff --git a/src/java/org/apache/poi/ss/usermodel/BorderFormatting.java b/src/java/org/apache/poi/ss/usermodel/BorderFormatting.java index c15dc269cb..165cf05421 100644 --- a/src/java/org/apache/poi/ss/usermodel/BorderFormatting.java +++ b/src/java/org/apache/poi/ss/usermodel/BorderFormatting.java @@ -20,8 +20,8 @@ package org.apache.poi.ss.usermodel;
/**
- * @author Dmitriy Kumshayev
- * @author Yegor Kozlov
+ * High level representation for Border Formatting component
+ * of Conditional Formatting settings
*/
public interface BorderFormatting {
/** No border */
@@ -64,14 +64,19 @@ public interface BorderFormatting { short getBorderTop();
short getBottomBorderColor();
+ Color getBottomBorderColorColor();
short getDiagonalBorderColor();
+ Color getDiagonalBorderColorColor();
short getLeftBorderColor();
+ Color getLeftBorderColorColor();
short getRightBorderColor();
+ Color getRightBorderColorColor();
short getTopBorderColor();
+ Color getTopBorderColorColor();
void setBorderBottom(short border);
@@ -104,12 +109,17 @@ public interface BorderFormatting { void setBorderTop(short border);
void setBottomBorderColor(short color);
+ void setBottomBorderColor(Color color);
void setDiagonalBorderColor(short color);
+ void setDiagonalBorderColor(Color color);
void setLeftBorderColor(short color);
+ void setLeftBorderColor(Color color);
void setRightBorderColor(short color);
+ void setRightBorderColor(Color color);
void setTopBorderColor(short color);
+ void setTopBorderColor(Color color);
}
diff --git a/src/java/org/apache/poi/ss/usermodel/ColorScaleFormatting.java b/src/java/org/apache/poi/ss/usermodel/ColorScaleFormatting.java new file mode 100644 index 0000000000..4d6f58b580 --- /dev/null +++ b/src/java/org/apache/poi/ss/usermodel/ColorScaleFormatting.java @@ -0,0 +1,66 @@ +/*
+ * ====================================================================
+ * 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.ss.usermodel;
+
+import org.apache.poi.hssf.record.cf.Threshold;
+
+/**
+ * High level representation for the Color Scale / Colour Scale /
+ * Color Gradient Formatting component of Conditional Formatting settings
+ */
+public interface ColorScaleFormatting {
+ /**
+ * How many control points should be used to map
+ * the colours? Normally 2 or 3
+ */
+ int getNumControlPoints();
+ /**
+ * Sets the number of control points to use to map
+ * the colours. Should normally be 2 or 3.
+ * <p>After updating, you need to ensure that the
+ * {@link Threshold} count and Color count match
+ */
+ void setNumControlPoints(int num);
+
+ /**
+ * Gets the list of colours that are interpolated
+ * between.
+ */
+ Color[] getColors();
+ /**
+ * Sets the list of colours that are interpolated
+ * between. The number must match {@link #getNumControlPoints()}
+ */
+ void setColors(Color[] colors);
+
+ /**
+ * Gets the list of thresholds
+ */
+ ConditionalFormattingThreshold[] getThresholds();
+ /**
+ * Sets the of thresholds. The number must match
+ * {@link #getNumControlPoints()}
+ */
+ void setThresholds(ConditionalFormattingThreshold[] thresholds);
+ /**
+ * Creates a new, empty Threshold
+ */
+ ConditionalFormattingThreshold createThreshold();
+}
diff --git a/src/java/org/apache/poi/ss/usermodel/ComparisonOperator.java b/src/java/org/apache/poi/ss/usermodel/ComparisonOperator.java index 7e29cbf4c9..7eee789037 100644 --- a/src/java/org/apache/poi/ss/usermodel/ComparisonOperator.java +++ b/src/java/org/apache/poi/ss/usermodel/ComparisonOperator.java @@ -24,9 +24,6 @@ package org.apache.poi.ss.usermodel; * <p>
* For example, "highlight cells that begin with "M2" and contain "Mountain Gear".
* </p>
- *
- * @author Dmitriy Kumshayev
- * @author Yegor Kozlov
*/
public final class ComparisonOperator {
public static final byte NO_COMPARISON = 0;
diff --git a/src/java/org/apache/poi/ss/usermodel/ConditionType.java b/src/java/org/apache/poi/ss/usermodel/ConditionType.java new file mode 100644 index 0000000000..8bd61410e0 --- /dev/null +++ b/src/java/org/apache/poi/ss/usermodel/ConditionType.java @@ -0,0 +1,92 @@ +/*
+ * ====================================================================
+ * 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.ss.usermodel;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Represents a type of a conditional formatting rule
+ */
+public class ConditionType {
+ private static Map<Integer,ConditionType> lookup = new HashMap<Integer, ConditionType>();
+
+ /**
+ * This conditional formatting rule compares a cell value
+ * to a formula calculated result, using an operator
+ */
+ public static final ConditionType CELL_VALUE_IS =
+ new ConditionType(1, "cellIs");
+
+ /**
+ * This conditional formatting rule contains a formula to evaluate.
+ * When the formula result is true, the cell is highlighted.
+ */
+ public static final ConditionType FORMULA =
+ new ConditionType(2, "expression");
+
+ /**
+ * This conditional formatting rule contains a color scale,
+ * with the cell background set according to a gradient.
+ */
+ public static final ConditionType COLOR_SCALE =
+ new ConditionType(3, "colorScale");
+
+ /**
+ * This conditional formatting rule sets a data bar, with the
+ * cell populated with bars based on their values
+ */
+ public static final ConditionType DATA_BAR =
+ new ConditionType(4, "dataBar");
+
+ /**
+ * This conditional formatting rule that files the values
+ */
+ public static final ConditionType FILTER =
+ new ConditionType(5, null);
+
+ /**
+ * This conditional formatting rule sets a data bar, with the
+ * cell populated with bars based on their values
+ */
+ public static final ConditionType ICON_SET =
+ new ConditionType(6, "iconSet");
+
+
+ public final byte id;
+ public final String type;
+
+ public String toString() {
+ return id + " - " + type;
+ }
+
+
+ public static ConditionType forId(byte id) {
+ return forId((int)id);
+ }
+ public static ConditionType forId(int id) {
+ return lookup.get(id);
+ }
+
+ private ConditionType(int id, String type) {
+ this.id = (byte)id; this.type = type;
+ lookup.put(id, this);
+ }
+}
diff --git a/src/java/org/apache/poi/ss/usermodel/ConditionalFormatting.java b/src/java/org/apache/poi/ss/usermodel/ConditionalFormatting.java index 3344963bb6..f6e8ff441f 100644 --- a/src/java/org/apache/poi/ss/usermodel/ConditionalFormatting.java +++ b/src/java/org/apache/poi/ss/usermodel/ConditionalFormatting.java @@ -72,9 +72,6 @@ import org.apache.poi.ss.util.CellRangeAddress; * // Apply Conditional Formatting rule defined above to the regions
* sheet.addConditionalFormatting(regions, rule);
* </PRE>
- *
- * @author Dmitriy Kumshayev
- * @author Yegor Kozlov
*/
public interface ConditionalFormatting {
@@ -85,17 +82,18 @@ public interface ConditionalFormatting { /**
* Replaces an existing Conditional Formatting rule at position idx.
- * Excel allows to create up to 3 Conditional Formatting rules.
+ * Excel pre-2007 allows to create up to 3 Conditional Formatting rules,
+ * 2007 and later allow unlimited numbers.
* This method can be useful to modify existing Conditional Formatting rules.
*
- * @param idx position of the rule. Should be between 0 and 2.
+ * @param idx position of the rule. Should be between 0 and 2 for Excel before 2007, otherwise 0+.
* @param cfRule - Conditional Formatting rule
*/
void setRule(int idx, ConditionalFormattingRule cfRule);
/**
* Add a Conditional Formatting rule.
- * Excel allows to create up to 3 Conditional Formatting rules.
+ * Excel pre-2007 allows to create up to 3 Conditional Formatting rules.
*
* @param cfRule - Conditional Formatting rule
*/
@@ -110,6 +108,4 @@ public interface ConditionalFormatting { * @return number of Conditional Formatting rules.
*/
int getNumberOfRules();
-
-
}
diff --git a/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingRule.java b/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingRule.java index 1c63f19257..5fb315147e 100644 --- a/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingRule.java +++ b/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingRule.java @@ -19,24 +19,25 @@ package org.apache.poi.ss.usermodel;
+import static org.apache.poi.ss.usermodel.ConditionType.*;
+
/**
* Represents a description of a conditional formatting rule
- *
- * @author Dmitriy Kumshayev
- * @author Yegor Kozlov
*/
public interface ConditionalFormattingRule {
/**
* This conditional formatting rule compares a cell value
* to a formula calculated result, using an operator
+ * @deprecated Use {@link ConditionType#CELL_VALUE_IS}
*/
- public static final byte CONDITION_TYPE_CELL_VALUE_IS = 1;
+ public static final byte CONDITION_TYPE_CELL_VALUE_IS = CELL_VALUE_IS.id;
/**
* This conditional formatting rule contains a formula to evaluate.
* When the formula result is true, the cell is highlighted.
+ * @deprecated Use {@link ConditionType#FORMULA}
*/
- public static final byte CONDITION_TYPE_FORMULA = 2;
+ public static final byte CONDITION_TYPE_FORMULA = FORMULA.id;
/**
* Create a new border formatting structure if it does not exist,
@@ -73,19 +74,32 @@ public interface ConditionalFormattingRule { PatternFormatting createPatternFormatting();
/**
- * @return - pattern formatting object if defined, <code>null</code> otherwise
+ * @return - pattern formatting object if defined, <code>null</code> otherwise
*/
PatternFormatting getPatternFormatting();
/**
+ * @return - icon / multi-state formatting object if defined, <code>null</code> otherwise
+ */
+ IconMultiStateFormatting getMultiStateFormatting();
+
+ /**
* Type of conditional formatting rule.
* <p>
- * MUST be either {@link #CONDITION_TYPE_CELL_VALUE_IS} or {@link #CONDITION_TYPE_FORMULA}
+ * MUST be one of the IDs of a {@link ConditionType}
* </p>
*
* @return the type of condition
+ * @deprecated Use {@link #getConditionTypeType()}
*/
byte getConditionType();
+
+ /**
+ * Type of conditional formatting rule.
+ *
+ * @return the type of condition
+ */
+ ConditionType getConditionTypeType();
/**
* The comparison function used when the type of conditional formatting is set to
diff --git a/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingThreshold.java b/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingThreshold.java new file mode 100644 index 0000000000..8f2ecaf526 --- /dev/null +++ b/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingThreshold.java @@ -0,0 +1,110 @@ +/*
+ * ====================================================================
+ * 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.ss.usermodel;
+
+
+/**
+ * The Threshold / CFVO / Conditional Formatting Value Object.
+ * <p>This defines how to calculate the ranges for a conditional
+ * formatting rule, eg which values get a Green Traffic Light
+ * icon and which Yellow or Red.</p>
+ */
+public interface ConditionalFormattingThreshold {
+ public enum RangeType {
+ /** Number / Parameter */
+ NUMBER(1, "num"),
+ /** The minimum value from the range */
+ MIN(2, "min"),
+ /** The maximum value from the range */
+ MAX(3, "max"),
+ /** Percent of the way from the mi to the max value in the range */
+ PERCENT(4, "percent"),
+ /** The minimum value of the cell that is in X percentile of the range */
+ PERCENTILE(5, "percentile"),
+ UNALLOCATED(6, null),
+ /** Formula result */
+ FORMULA(7, "formula");
+
+ /** Numeric ID of the type */
+ public int id;
+ /** Name (system) of the type */
+ public final String name;
+
+ public String toString() {
+ return id + " - " + name;
+ }
+
+ public static RangeType byId(int id) {
+ return values()[id-1]; // 1-based IDs
+ }
+ public static RangeType byName(String name) {
+ for (RangeType t : values()) {
+ if (t.name.equals(name)) return t;
+ }
+ return null;
+ }
+
+ private RangeType(int id, String name) {
+ this.id = id; this.name = name;
+ }
+ }
+
+ /**
+ * Get the Range Type used
+ */
+ RangeType getRangeType();
+
+ /**
+ * Changes the Range Type used
+ *
+ * <p>If you change the range type, you need to
+ * ensure that the Formula and Value parameters
+ * are compatible with it before saving</p>
+ */
+ void setRangeType(RangeType type);
+
+ /**
+ * Formula to use to calculate the threshold,
+ * or <code>null</code> if no formula
+ */
+ String getFormula();
+
+ /**
+ * Sets the formula used to calculate the threshold,
+ * or unsets it if <code>null</code> is given.
+ */
+ void setFormula(String formula);
+
+ /**
+ * Gets the value used for the threshold, or
+ * <code>null</code> if there isn't one.
+ */
+ Double getValue();
+
+ /**
+ * Sets the value used for the threshold.
+ * <p>If the type is {@link RangeType#PERCENT} or
+ * {@link RangeType#PERCENTILE} it must be between 0 and 100.
+ * <p>If the type is {@link RangeType#MIN} or {@link RangeType#MAX}
+ * or {@link RangeType#FORMULA} it shouldn't be set.
+ * <p>Use <code>null</code> to unset
+ */
+ void setValue(Double value);
+}
diff --git a/src/java/org/apache/poi/ss/usermodel/DataBarFormatting.java b/src/java/org/apache/poi/ss/usermodel/DataBarFormatting.java new file mode 100644 index 0000000000..df9a0fef71 --- /dev/null +++ b/src/java/org/apache/poi/ss/usermodel/DataBarFormatting.java @@ -0,0 +1,72 @@ +/*
+ * ====================================================================
+ * 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.ss.usermodel;
+
+/**
+ * High level representation for the DataBar Formatting
+ * component of Conditional Formatting settings
+ */
+public interface DataBarFormatting {
+ /**
+ * Is the bar drawn from Left-to-Right, or from
+ * Right-to-Left
+ */
+ boolean isLeftToRight();
+ /**
+ * Control if the bar is drawn from Left-to-Right,
+ * or from Right-to-Left
+ */
+ void setLeftToRight(boolean ltr);
+
+ /**
+ * Should Icon + Value be displayed, or only the Icon?
+ */
+ boolean isIconOnly();
+ /**
+ * Control if only the Icon is shown, or Icon + Value
+ */
+ void setIconOnly(boolean only);
+
+ /**
+ * How much of the cell width, in %, should be given to
+ * the min value?
+ */
+ int getWidthMin();
+ void setWidthMin(int width);
+
+ /**
+ * How much of the cell width, in %, should be given to
+ * the max value?
+ */
+ int getWidthMax();
+ void setWidthMax(int width);
+
+ Color getColor();
+ void setColor(Color color);
+
+ /**
+ * The threshold that defines "everything from here down is minimum"
+ */
+ ConditionalFormattingThreshold getMinThreshold();
+ /**
+ * The threshold that defines "everything from here up is maximum"
+ */
+ ConditionalFormattingThreshold getMaxThreshold();
+}
diff --git a/src/java/org/apache/poi/ss/usermodel/DataFormatter.java b/src/java/org/apache/poi/ss/usermodel/DataFormatter.java index 28dbfbe3fb..766ded18fe 100644 --- a/src/java/org/apache/poi/ss/usermodel/DataFormatter.java +++ b/src/java/org/apache/poi/ss/usermodel/DataFormatter.java @@ -20,6 +20,7 @@ ==================================================================== */ package org.apache.poi.ss.usermodel; +import java.math.BigDecimal; import java.math.RoundingMode; import java.text.DateFormatSymbols; import java.text.DecimalFormat; @@ -38,6 +39,8 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.poi.ss.util.NumberToTextConverter; + /** * DataFormatter contains methods for formatting the value stored in an @@ -731,7 +734,7 @@ public class DataFormatter { * @see #formatCellValue(Cell) */ public String formatRawCellContents(double value, int formatIndex, String formatString) { - return formatRawCellContents(value, formatIndex, formatString, false); + return formatRawCellContents(value, formatIndex, formatString, false); } /** * Formats the given raw cell value, based on the supplied @@ -744,28 +747,42 @@ public class DataFormatter { if(DateUtil.isValidExcelDate(value)) { Format dateFormat = getFormat(value, formatIndex, formatString); if(dateFormat instanceof ExcelStyleDateFormatter) { - // Hint about the raw excel value - ((ExcelStyleDateFormatter)dateFormat).setDateToBeFormatted(value); + // Hint about the raw excel value + ((ExcelStyleDateFormatter)dateFormat).setDateToBeFormatted(value); } Date d = DateUtil.getJavaDate(value, use1904Windowing); return performDateFormatting(d, dateFormat); } - // RK: Invalid dates are 255 #s. - if (emulateCsv) { - return invalidDateTimeString; - } + // RK: Invalid dates are 255 #s. + if (emulateCsv) { + return invalidDateTimeString; + } } + // else Number - Format numberFormat = getFormat(value, formatIndex, formatString); - if (numberFormat == null) { - return String.valueOf(value); - } - // RK: This hack handles scientific notation by adding the missing + back. - String result = numberFormat.format(new Double(value)); - if (result.contains("E") && !result.contains("E-")) { - result = result.replaceFirst("E", "E+"); - } - return result; + Format numberFormat = getFormat(value, formatIndex, formatString); + if (numberFormat == null) { + return String.valueOf(value); + } + + // When formatting 'value', double to text to BigDecimal produces more + // accurate results than double to Double in JDK8 (as compared to + // previous versions). However, if the value contains E notation, this + // would expand the values, which we do not want, so revert to + // original method. + String result; + final String textValue = NumberToTextConverter.toText(value); + if (textValue.indexOf('E') > -1) { + result = numberFormat.format(new Double(value)); + } + else { + result = numberFormat.format(new BigDecimal(textValue)); + } + // Complete scientific notation by adding the missing +. + if (result.indexOf('E') > -1 && !result.contains("E-")) { + result = result.replaceFirst("E", "E+"); + } + return result; } /** diff --git a/src/java/org/apache/poi/ss/usermodel/DateUtil.java b/src/java/org/apache/poi/ss/usermodel/DateUtil.java index 79512ef102..ca1d7d4659 100644 --- a/src/java/org/apache/poi/ss/usermodel/DateUtil.java +++ b/src/java/org/apache/poi/ss/usermodel/DateUtil.java @@ -146,7 +146,7 @@ public class DateUtil { * @return Java representation of the date, or null if date is not a valid Excel date */ public static Date getJavaDate(double date, TimeZone tz) { - return getJavaDate(date, false, tz); + return getJavaDate(date, false, tz, false); } /** * Given an Excel date with using 1900 date windowing, and @@ -166,9 +166,9 @@ public class DateUtil { * @see java.util.TimeZone */ public static Date getJavaDate(double date) { - return getJavaDate(date, (TimeZone)null); + return getJavaDate(date, false, null, false); } - + /** * Given an Excel date with either 1900 or 1904 date windowing, * converts it to a java.util.Date. @@ -185,7 +185,7 @@ public class DateUtil { * @return Java representation of the date, or null if date is not a valid Excel date */ public static Date getJavaDate(double date, boolean use1904windowing, TimeZone tz) { - return getJavaCalendar(date, use1904windowing, tz, false).getTime(); + return getJavaDate(date, use1904windowing, tz, false); } /** @@ -205,7 +205,8 @@ public class DateUtil { * @return Java representation of the date, or null if date is not a valid Excel date */ public static Date getJavaDate(double date, boolean use1904windowing, TimeZone tz, boolean roundSeconds) { - return getJavaCalendar(date, use1904windowing, tz, roundSeconds).getTime(); + Calendar calendar = getJavaCalendar(date, use1904windowing, tz, roundSeconds); + return calendar == null ? null : calendar.getTime(); } /** @@ -228,10 +229,9 @@ public class DateUtil { * @see java.util.TimeZone */ public static Date getJavaDate(double date, boolean use1904windowing) { - return getJavaCalendar(date, use1904windowing, null, false).getTime(); + return getJavaDate(date, use1904windowing, null, false); } - public static void setCalendar(Calendar calendar, int wholeDays, int millisecondsInDay, boolean use1904windowing, boolean roundSeconds) { int startYear = 1900; @@ -567,7 +567,7 @@ public class DateUtil { private static int daysInPriorYears(int yr, boolean use1904windowing) { - if ((!use1904windowing && yr < 1900) || (use1904windowing && yr < 1900)) { + if ((!use1904windowing && yr < 1900) || (use1904windowing && yr < 1904)) { throw new IllegalArgumentException("'year' must be 1900 or greater"); } diff --git a/src/java/org/apache/poi/ss/usermodel/FontFormatting.java b/src/java/org/apache/poi/ss/usermodel/FontFormatting.java index 2298d79635..a6f21bde4d 100644 --- a/src/java/org/apache/poi/ss/usermodel/FontFormatting.java +++ b/src/java/org/apache/poi/ss/usermodel/FontFormatting.java @@ -22,9 +22,6 @@ package org.apache.poi.ss.usermodel; /**
* High level representation for Font Formatting component
* of Conditional Formatting settings
- *
- * @author Dmitriy Kumshayev
- * @author Yegor Kozlov
*/
public interface FontFormatting {
/** Escapement type - None */
@@ -66,15 +63,26 @@ public interface FontFormatting { void setEscapementType(short escapementType);
/**
- * @return font color index
+ * @return font colour index, or 0 if not indexed (XSSF only)
*/
short getFontColorIndex();
-
/**
- * @param color font color index
+ * Sets the indexed colour to use
+ * @param color font colour index
*/
void setFontColorIndex(short color);
+
+ /**
+ * @return The colour of the font, or null if no colour applied
+ */
+ Color getFontColor();
+
+ /**
+ * Sets the colour to use
+ * @param color font colour to use
+ */
+ void setFontColor(Color color);
/**
* gets the height of the font in 1/20th point units
diff --git a/src/java/org/apache/poi/ss/usermodel/IconMultiStateFormatting.java b/src/java/org/apache/poi/ss/usermodel/IconMultiStateFormatting.java new file mode 100644 index 0000000000..d5212e5b94 --- /dev/null +++ b/src/java/org/apache/poi/ss/usermodel/IconMultiStateFormatting.java @@ -0,0 +1,127 @@ +/*
+ * ====================================================================
+ * 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.ss.usermodel;
+
+/**
+ * High level representation for the Icon / Multi-State Formatting
+ * component of Conditional Formatting settings
+ */
+public interface IconMultiStateFormatting {
+ public enum IconSet {
+ /** Green Up / Yellow Side / Red Down arrows */
+ GYR_3_ARROW(0, 3, "3Arrows"),
+ /** Grey Up / Side / Down arrows */
+ GREY_3_ARROWS(1, 3, "3ArrowsGray"),
+ /** Green / Yellow / Red flags */
+ GYR_3_FLAGS(2, 3, "3Flags"),
+ /** Green / Yellow / Red traffic lights (no background). Default */
+ GYR_3_TRAFFIC_LIGHTS(3, 3, "3TrafficLights1"),
+ /** Green / Yellow / Red traffic lights on a black square background.
+ * Note, MS-XLS docs v20141018 say this is id=5 but seems to be id=4 */
+ GYR_3_TRAFFIC_LIGHTS_BOX(4, 3, "3TrafficLights2"),
+ /** Green Circle / Yellow Triangle / Red Diamond.
+ * Note, MS-XLS docs v20141018 say this is id=4 but seems to be id=5 */
+ GYR_3_SHAPES(5, 3, "3Signs"),
+ /** Green Tick / Yellow ! / Red Cross on a circle background */
+ GYR_3_SYMBOLS_CIRCLE(6, 3, "3Symbols"),
+ /** Green Tick / Yellow ! / Red Cross (no background) */
+ GYR_3_SYMBOLS(7, 3, "3Symbols2"),
+ /** Green Up / Yellow NE / Yellow SE / Red Down arrows */
+ GYR_4_ARROWS(8, 4, "4Arrows"),
+ /** Grey Up / NE / SE / Down arrows */
+ GREY_4_ARROWS(9, 4, "4ArrowsGray"),
+ /** Red / Light Red / Grey / Black traffic lights */
+ RB_4_TRAFFIC_LIGHTS(0xA, 4, "4RedToBlack"),
+ RATINGS_4(0xB, 4, "4Rating"),
+ /** Green / Yellow / Red / Black traffic lights */
+ GYRB_4_TRAFFIC_LIGHTS(0xC, 4, "4TrafficLights"),
+ GYYYR_5_ARROWS(0xD, 5, "5Arrows"),
+ GREY_5_ARROWS(0xE, 5, "5ArrowsGray"),
+ RATINGS_5(0xF, 5, "5Rating"),
+ QUARTERS_5(0x10, 5, "5Quarters");
+
+ protected static final IconSet DEFAULT_ICONSET = IconSet.GYR_3_TRAFFIC_LIGHTS;
+
+ /** Numeric ID of the icon set */
+ public int id;
+ /** How many icons in the set */
+ public final int num;
+ /** Name (system) of the set */
+ public final String name;
+
+ public String toString() {
+ return id + " - " + name;
+ }
+
+ public static IconSet byId(int id) {
+ return values()[id];
+ }
+ public static IconSet byName(String name) {
+ for (IconSet set : values()) {
+ if (set.name.equals(name)) return set;
+ }
+ return null;
+ }
+
+ private IconSet(int id, int num, String name) {
+ this.id = id; this.num = num; this.name = name;
+ }
+ }
+
+ /**
+ * Get the Icon Set used
+ */
+ IconSet getIconSet();
+
+ /**
+ * Changes the Icon Set used
+ *
+ * <p>If the new Icon Set has a different number of
+ * icons to the old one, you <em>must</em> update the
+ * thresholds before saving!</p>
+ */
+ void setIconSet(IconSet set);
+
+ /**
+ * Should Icon + Value be displayed, or only the Icon?
+ */
+ boolean isIconOnly();
+ /**
+ * Control if only the Icon is shown, or Icon + Value
+ */
+ void setIconOnly(boolean only);
+
+ boolean isReversed();
+ void setReversed(boolean reversed);
+
+ /**
+ * Gets the list of thresholds
+ */
+ ConditionalFormattingThreshold[] getThresholds();
+ /**
+ * Sets the of thresholds. The number must match
+ * {@link IconSet#num} for the current {@link #getIconSet()}
+ */
+ void setThresholds(ConditionalFormattingThreshold[] thresholds);
+ /**
+ * Creates a new, empty Threshold
+ */
+ ConditionalFormattingThreshold createThreshold();
+}
diff --git a/src/java/org/apache/poi/ss/usermodel/PatternFormatting.java b/src/java/org/apache/poi/ss/usermodel/PatternFormatting.java index 2739c96af3..0311ffb75e 100644 --- a/src/java/org/apache/poi/ss/usermodel/PatternFormatting.java +++ b/src/java/org/apache/poi/ss/usermodel/PatternFormatting.java @@ -63,14 +63,16 @@ public interface PatternFormatting { public final static short LEAST_DOTS = 18 ;
short getFillBackgroundColor();
-
short getFillForegroundColor();
+ Color getFillBackgroundColorColor();
+ Color getFillForegroundColorColor();
short getFillPattern();
void setFillBackgroundColor(short bg);
-
void setFillForegroundColor(short fg);
+ void setFillBackgroundColor(Color bg);
+ void setFillForegroundColor(Color fg);
void setFillPattern(short fp);
}
diff --git a/src/java/org/apache/poi/ss/usermodel/Sheet.java b/src/java/org/apache/poi/ss/usermodel/Sheet.java index 987a35efeb..f0990511ff 100644 --- a/src/java/org/apache/poi/ss/usermodel/Sheet.java +++ b/src/java/org/apache/poi/ss/usermodel/Sheet.java @@ -321,6 +321,13 @@ public interface Sheet extends Iterable<Row> { public CellRangeAddress getMergedRegion(int index); /** + * Returns the list of merged regions. + * + * @return the list of merged regions + */ + public List<CellRangeAddress> getMergedRegions(); + + /** * Returns an iterator of the physical rows * * @return an iterator of the PHYSICAL rows. Meaning the 3rd element may not diff --git a/src/java/org/apache/poi/ss/usermodel/SheetConditionalFormatting.java b/src/java/org/apache/poi/ss/usermodel/SheetConditionalFormatting.java index e20a8f74b6..a28c342a74 100644 --- a/src/java/org/apache/poi/ss/usermodel/SheetConditionalFormatting.java +++ b/src/java/org/apache/poi/ss/usermodel/SheetConditionalFormatting.java @@ -19,17 +19,15 @@ package org.apache.poi.ss.usermodel;
+import org.apache.poi.ss.usermodel.IconMultiStateFormatting.IconSet;
import org.apache.poi.ss.util.CellRangeAddress;
/**
* The 'Conditional Formatting' facet of <tt>Sheet</tt>
*
- * @author Dmitriy Kumshayev
- * @author Yegor Kozlov
* @since 3.8
*/
public interface SheetConditionalFormatting {
-
/**
* Add a new Conditional Formatting to the sheet.
*
@@ -58,7 +56,7 @@ public interface SheetConditionalFormatting { * Add a new Conditional Formatting set to the sheet.
*
* @param regions - list of rectangular regions to apply conditional formatting rules
- * @param cfRules - set of up to three conditional formatting rules
+ * @param cfRules - set of up to conditional formatting rules (max 3 for Excel pre-2007)
*
* @return index of the newly created Conditional Formatting object
*/
@@ -86,7 +84,7 @@ public interface SheetConditionalFormatting { * <p>
* The created conditional formatting rule compares a cell value
* to a formula calculated result, using the specified operator.
- * The type of the created condition is {@link ConditionalFormattingRule#CONDITION_TYPE_CELL_VALUE_IS}
+ * The type of the created condition is {@link ConditionType#CELL_VALUE_IS}
* </p>
*
* @param comparisonOperation - MUST be a constant value from
@@ -115,7 +113,7 @@ public interface SheetConditionalFormatting { * Create a conditional formatting rule that compares a cell value
* to a formula calculated result, using an operator *
* <p>
- * The type of the created condition is {@link ConditionalFormattingRule#CONDITION_TYPE_CELL_VALUE_IS}
+ * The type of the created condition is {@link ConditionType#CELL_VALUE_IS}
* </p>
*
* @param comparisonOperation MUST be a constant value from
@@ -132,13 +130,25 @@ public interface SheetConditionalFormatting { * When the formula result is true, the cell is highlighted.
*
* <p>
- * The type of the created format condition is {@link ConditionalFormattingRule#CONDITION_TYPE_FORMULA}
+ * The type of the created format condition is {@link ConditionType#FORMULA}
* </p>
* @param formula the formula to evaluate. MUST be a Boolean function.
*/
ConditionalFormattingRule createConditionalFormattingRule(String formula);
/**
+ * Create an Icon Set / Multi-State conditional formatting rule.
+ * <p>The thresholds for it will be created, but will be empty
+ * and require configuring with
+ * {@link ConditionalFormattingRule#getMultiStateFormatting()}
+ * then
+ * {@link IconMultiStateFormatting#getThresholds()}
+ */
+ ConditionalFormattingRule createConditionalFormattingRule(IconSet iconSet);
+
+ // TODO Support types beyond CELL_VALUE_IS and FORMULA and ICONs
+
+ /**
* Gets Conditional Formatting object at a particular index
*
* @param index 0-based index of the Conditional Formatting object to fetch
diff --git a/src/java/org/apache/poi/ss/util/AreaReference.java b/src/java/org/apache/poi/ss/util/AreaReference.java index d593888730..b0a69135a8 100644 --- a/src/java/org/apache/poi/ss/util/AreaReference.java +++ b/src/java/org/apache/poi/ss/util/AreaReference.java @@ -35,13 +35,23 @@ public class AreaReference { private final CellReference _firstCell; private final CellReference _lastCell; private final boolean _isSingleCell; + private SpreadsheetVersion _version; /** + * @deprecated Prefer supplying a version. + */ + @Deprecated + public AreaReference(String reference) { + this(reference, SpreadsheetVersion.EXCEL97); + } + + /** * Create an area ref from a string representation. Sheet names containing special characters should be * delimited and escaped as per normal syntax rules for formulas.<br/> * The area reference must be contiguous (i.e. represent a single rectangle, not a union of rectangles) */ - public AreaReference(String reference) { + public AreaReference(String reference, SpreadsheetVersion version) { + _version = version; if(! isContiguous(reference)) { throw new IllegalArgumentException( "References passed to the AreaReference must be contiguous, " + @@ -169,30 +179,34 @@ public class AreaReference { return false; } - public static AreaReference getWholeRow(String start, String end) { - return new AreaReference("$A" + start + ":$IV" + end); + public static AreaReference getWholeRow(SpreadsheetVersion version, String start, String end) { + return new AreaReference("$A" + start + ":$" + version.getLastColumnName() + end, version); } - public static AreaReference getWholeColumn(String start, String end) { - return new AreaReference(start + "$1:" + end + "$65536"); + public static AreaReference getWholeColumn(SpreadsheetVersion version, String start, String end) { + return new AreaReference(start + "$1:" + end + "$" + version.getMaxRows(), version); } /** * Is the reference for a whole-column reference, * such as C:C or D:G ? */ - public static boolean isWholeColumnReference(CellReference topLeft, CellReference botRight) { + public static boolean isWholeColumnReference(SpreadsheetVersion version, CellReference topLeft, CellReference botRight) { + if (null == version) { + version = SpreadsheetVersion.EXCEL97; // how the code used to behave. + } + // These are represented as something like // C$1:C$65535 or D$1:F$0 // i.e. absolute from 1st row to 0th one if(topLeft.getRow() == 0 && topLeft.isRowAbsolute() && - botRight.getRow() == SpreadsheetVersion.EXCEL97.getLastRowIndex() && botRight.isRowAbsolute()) { + botRight.getRow() == version.getLastRowIndex() && botRight.isRowAbsolute()) { return true; } return false; } public boolean isWholeColumnReference() { - return isWholeColumnReference(_firstCell, _lastCell); + return isWholeColumnReference(_version, _firstCell, _lastCell); } /** diff --git a/src/java/org/apache/poi/ss/util/CellRangeAddressBase.java b/src/java/org/apache/poi/ss/util/CellRangeAddressBase.java index 2343226713..4b5b104244 100644 --- a/src/java/org/apache/poi/ss/util/CellRangeAddressBase.java +++ b/src/java/org/apache/poi/ss/util/CellRangeAddressBase.java @@ -24,8 +24,6 @@ import org.apache.poi.ss.SpreadsheetVersion; * See OOO documentation: excelfileformat.pdf sec 2.5.14 - 'Cell Range Address'<p/> * * Common subclass of 8-bit and 16-bit versions - * - * @author Josh Micich */ public abstract class CellRangeAddressBase { diff --git a/src/java/org/apache/poi/ss/util/SheetUtil.java b/src/java/org/apache/poi/ss/util/SheetUtil.java index 6b55e223fd..cc322293ae 100644 --- a/src/java/org/apache/poi/ss/util/SheetUtil.java +++ b/src/java/org/apache/poi/ss/util/SheetUtil.java @@ -93,10 +93,9 @@ public class SheetUtil { * @param defaultCharWidth the width of a single character * @param formatter formatter used to prepare the text to be measured * @param useMergedCells whether to use merged cells - * @return the width in pixels + * @return the width in pixels or -1 if cell is empty */ public static double getCellWidth(Cell cell, int defaultCharWidth, DataFormatter formatter, boolean useMergedCells) { - Sheet sheet = cell.getSheet(); Workbook wb = sheet.getWorkbook(); Row row = cell.getRow(); @@ -123,9 +122,6 @@ public class SheetUtil { Font font = wb.getFontAt(style.getFontIndex()); - AttributedString str; - TextLayout layout; - double width = -1; if (cellType == Cell.CELL_TYPE_STRING) { RichTextString rt = cell.getRichStringCellValue(); @@ -133,30 +129,14 @@ public class SheetUtil { for (int i = 0; i < lines.length; i++) { String txt = lines[i] + defaultChar; - str = new AttributedString(txt); + AttributedString str = new AttributedString(txt); copyAttributes(font, str, 0, txt.length()); if (rt.numFormattingRuns() > 0) { // TODO: support rich text fragments } - layout = new TextLayout(str.getIterator(), fontRenderContext); - if(style.getRotation() != 0){ - /* - * Transform the text using a scale so that it's height is increased by a multiple of the leading, - * and then rotate the text before computing the bounds. The scale results in some whitespace around - * the unrotated top and bottom of the text that normally wouldn't be present if unscaled, but - * is added by the standard Excel autosize. - */ - AffineTransform trans = new AffineTransform(); - trans.concatenate(AffineTransform.getRotateInstance(style.getRotation()*2.0*Math.PI/360.0)); - trans.concatenate( - AffineTransform.getScaleInstance(1, fontHeightMultiple) - ); - width = Math.max(width, ((layout.getOutline(trans).getBounds().getWidth() / colspan) / defaultCharWidth) + cell.getCellStyle().getIndention()); - } else { - width = Math.max(width, ((layout.getBounds().getWidth() / colspan) / defaultCharWidth) + cell.getCellStyle().getIndention()); - } + width = getCellWidth(defaultCharWidth, colspan, style, width, str); } } else { String sval = null; @@ -172,66 +152,49 @@ public class SheetUtil { } if(sval != null) { String txt = sval + defaultChar; - str = new AttributedString(txt); + AttributedString str = new AttributedString(txt); copyAttributes(font, str, 0, txt.length()); - layout = new TextLayout(str.getIterator(), fontRenderContext); - if(style.getRotation() != 0){ - /* - * Transform the text using a scale so that it's height is increased by a multiple of the leading, - * and then rotate the text before computing the bounds. The scale results in some whitespace around - * the unrotated top and bottom of the text that normally wouldn't be present if unscaled, but - * is added by the standard Excel autosize. - */ - AffineTransform trans = new AffineTransform(); - trans.concatenate(AffineTransform.getRotateInstance(style.getRotation()*2.0*Math.PI/360.0)); - trans.concatenate( - AffineTransform.getScaleInstance(1, fontHeightMultiple) - ); - width = Math.max(width, ((layout.getOutline(trans).getBounds().getWidth() / colspan) / defaultCharWidth) + cell.getCellStyle().getIndention()); - } else { - width = Math.max(width, ((layout.getBounds().getWidth() / colspan) / defaultCharWidth) + cell.getCellStyle().getIndention()); - } + width = getCellWidth(defaultCharWidth, colspan, style, width, str); } } return width; } + private static double getCellWidth(int defaultCharWidth, int colspan, + CellStyle style, double width, AttributedString str) { + TextLayout layout = new TextLayout(str.getIterator(), fontRenderContext); + if(style.getRotation() != 0){ + /* + * Transform the text using a scale so that it's height is increased by a multiple of the leading, + * and then rotate the text before computing the bounds. The scale results in some whitespace around + * the unrotated top and bottom of the text that normally wouldn't be present if unscaled, but + * is added by the standard Excel autosize. + */ + AffineTransform trans = new AffineTransform(); + trans.concatenate(AffineTransform.getRotateInstance(style.getRotation()*2.0*Math.PI/360.0)); + trans.concatenate( + AffineTransform.getScaleInstance(1, fontHeightMultiple) + ); + width = Math.max(width, ((layout.getOutline(trans).getBounds().getWidth() / colspan) / defaultCharWidth) + style.getIndention()); + } else { + width = Math.max(width, ((layout.getBounds().getWidth() / colspan) / defaultCharWidth) + style.getIndention()); + } + return width; + } + /** * Compute width of a column and return the result * * @param sheet the sheet to calculate * @param column 0-based index of the column * @param useMergedCells whether to use merged cells - * @return the width in pixels + * @return the width in pixels or -1 if all cells are empty */ - public static double getColumnWidth(Sheet sheet, int column, boolean useMergedCells){ - AttributedString str; - TextLayout layout; - - Workbook wb = sheet.getWorkbook(); - DataFormatter formatter = new DataFormatter(); - Font defaultFont = wb.getFontAt((short) 0); - - str = new AttributedString(String.valueOf(defaultChar)); - copyAttributes(defaultFont, str, 0, 1); - layout = new TextLayout(str.getIterator(), fontRenderContext); - int defaultCharWidth = (int)layout.getAdvance(); - - double width = -1; - for (Row row : sheet) { - Cell cell = row.getCell(column); - - if (cell == null) { - continue; - } - - double cellWidth = getCellWidth(cell, defaultCharWidth, formatter, useMergedCells); - width = Math.max(width, cellWidth); - } - return width; + public static double getColumnWidth(Sheet sheet, int column, boolean useMergedCells) { + return getColumnWidth(sheet, column, useMergedCells, sheet.getFirstRowNum(), sheet.getLastRowNum()); } - + /** * Compute width of a column based on a subset of the rows and return the result * @@ -240,19 +203,16 @@ public class SheetUtil { * @param useMergedCells whether to use merged cells * @param firstRow 0-based index of the first row to consider (inclusive) * @param lastRow 0-based index of the last row to consider (inclusive) - * @return the width in pixels + * @return the width in pixels or -1 if cell is empty */ public static double getColumnWidth(Sheet sheet, int column, boolean useMergedCells, int firstRow, int lastRow){ - AttributedString str; - TextLayout layout; - Workbook wb = sheet.getWorkbook(); DataFormatter formatter = new DataFormatter(); Font defaultFont = wb.getFontAt((short) 0); - str = new AttributedString(String.valueOf(defaultChar)); + AttributedString str = new AttributedString(String.valueOf(defaultChar)); copyAttributes(defaultFont, str, 0, 1); - layout = new TextLayout(str.getIterator(), fontRenderContext); + TextLayout layout = new TextLayout(str.getIterator(), fontRenderContext); int defaultCharWidth = (int)layout.getAdvance(); double width = -1; @@ -274,6 +234,30 @@ public class SheetUtil { } /** + * Check if the Fonts are installed correctly so that Java can compute the size of + * columns. + * + * If a Cell uses a Font which is not available on the operating system then Java may + * fail to return useful Font metrics and thus lead to an auto-computed size of 0. + * + * This method allows to check if computing the sizes for a given Font will succeed or not. + * + * @param font The Font that is used in the Cell + * @return true if computing the size for this Font will succeed, false otherwise + */ + public static boolean canComputeColumnWidht(Font font) { + AttributedString str = new AttributedString("1"); + copyAttributes(font, str, 0, "1".length()); + + TextLayout layout = new TextLayout(str.getIterator(), fontRenderContext); + if(layout.getBounds().getWidth() > 0) { + return true; + } + + return false; + } + + /** * Copy text attributes from the supplied Font to Java2D AttributedString */ private static void copyAttributes(Font font, AttributedString str, int startIdx, int endIdx) { diff --git a/src/java/org/apache/poi/util/BitFieldFactory.java b/src/java/org/apache/poi/util/BitFieldFactory.java index 4159074d76..047d5cb1da 100644 --- a/src/java/org/apache/poi/util/BitFieldFactory.java +++ b/src/java/org/apache/poi/util/BitFieldFactory.java @@ -21,11 +21,8 @@ package org.apache.poi.util; import java.util.*; /** - * Returns immutable Btfield instances. - * - * @author Jason Height (jheight at apache dot org) + * Returns immutable Bitfield instances. */ - public class BitFieldFactory { private static Map<Integer, BitField> instances = new HashMap<Integer, BitField>(); diff --git a/src/java/org/apache/poi/util/CloseIgnoringInputStream.java b/src/java/org/apache/poi/util/CloseIgnoringInputStream.java index f4896a8312..66e42c258c 100644 --- a/src/java/org/apache/poi/util/CloseIgnoringInputStream.java +++ b/src/java/org/apache/poi/util/CloseIgnoringInputStream.java @@ -20,13 +20,11 @@ package org.apache.poi.util; import java.io.FilterInputStream; import java.io.InputStream; -import org.apache.poi.poifs.filesystem.POIFSFileSystem; - /** * A wrapper around an {@link InputStream}, which * ignores close requests made to it. * - * Useful with {@link POIFSFileSystem}, where you want + * Useful with {@link org.apache.poi.poifs.filesystem.POIFSFileSystem}, where you want * to control the close yourself. */ public class CloseIgnoringInputStream extends FilterInputStream { diff --git a/src/java/org/apache/poi/util/DrawingDump.java b/src/java/org/apache/poi/util/DrawingDump.java index 1055ab2da0..4eb6a2aff2 100644 --- a/src/java/org/apache/poi/util/DrawingDump.java +++ b/src/java/org/apache/poi/util/DrawingDump.java @@ -18,12 +18,12 @@ package org.apache.poi.util; +import java.io.File; +import java.io.IOException; + import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.poifs.filesystem.POIFSFileSystem; - -import java.io.FileInputStream; -import java.io.IOException; +import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; /** * Dump out the aggregated escher records @@ -32,8 +32,8 @@ public class DrawingDump { public static void main( String[] args ) throws IOException { - POIFSFileSystem fs = - new POIFSFileSystem(new FileInputStream(args[0])); + NPOIFSFileSystem fs = + new NPOIFSFileSystem(new File(args[0])); HSSFWorkbook wb = new HSSFWorkbook(fs); try { System.out.println( "Drawing group:" ); diff --git a/src/java/org/apache/poi/util/HexDump.java b/src/java/org/apache/poi/util/HexDump.java index 3c086ba606..02d9b6ae30 100644 --- a/src/java/org/apache/poi/util/HexDump.java +++ b/src/java/org/apache/poi/util/HexDump.java @@ -245,12 +245,15 @@ public class HexDump { { StringBuffer retVal = new StringBuffer(); retVal.append('['); - for(int x = 0; x < value.length; x++) + if (value != null && value.length > 0) { - if (x>0) { - retVal.append(", "); + for(int x = 0; x < value.length; x++) + { + if (x>0) { + retVal.append(", "); + } + retVal.append(toHex(value[x])); } - retVal.append(toHex(value[x])); } retVal.append(']'); return retVal.toString(); diff --git a/src/java/org/apache/poi/util/IOUtils.java b/src/java/org/apache/poi/util/IOUtils.java index 4f18214c46..f1d5a2378d 100644 --- a/src/java/org/apache/poi/util/IOUtils.java +++ b/src/java/org/apache/poi/util/IOUtils.java @@ -22,120 +22,149 @@ import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.io.PushbackInputStream; import java.nio.ByteBuffer; import java.nio.channels.ReadableByteChannel; import java.util.zip.CRC32; import java.util.zip.Checksum; +import org.apache.poi.EmptyFileException; + public final class IOUtils { + private static final POILogger logger = POILogFactory.getLogger( IOUtils.class ); + + private IOUtils() { + // no instances of this class + } + + /** + * Peeks at the first 8 bytes of the stream. Returns those bytes, but + * with the stream unaffected. Requires a stream that supports mark/reset, + * or a PushbackInputStream. If the stream has >0 but <8 bytes, + * remaining bytes will be zero. + * @throws EmptyFileException if the stream is empty + */ + public static byte[] peekFirst8Bytes(InputStream stream) throws IOException, EmptyFileException { + // We want to peek at the first 8 bytes + stream.mark(8); + + byte[] header = new byte[8]; + int read = IOUtils.readFully(stream, header); + + if (read < 1) + throw new EmptyFileException(); + + // Wind back those 8 bytes + if(stream instanceof PushbackInputStream) { + PushbackInputStream pin = (PushbackInputStream)stream; + pin.unread(header); + } else { + stream.reset(); + } + + return header; + } + + /** + * Reads all the data from the input stream, and returns the bytes read. + */ + public static byte[] toByteArray(InputStream stream) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + byte[] buffer = new byte[4096]; + int read = 0; + while (read != -1) { + read = stream.read(buffer); + if (read > 0) { + baos.write(buffer, 0, read); + } + } + + return baos.toByteArray(); + } + + /** + * Returns an array (that shouldn't be written to!) of the + * ByteBuffer. Will be of the requested length, or possibly + * longer if that's easier. + */ + public static byte[] toByteArray(ByteBuffer buffer, int length) { + if(buffer.hasArray() && buffer.arrayOffset() == 0) { + // The backing array should work out fine for us + return buffer.array(); + } + + byte[] data = new byte[length]; + buffer.get(data); + return data; + } + + /** + * Helper method, just calls <tt>readFully(in, b, 0, b.length)</tt> + */ + public static int readFully(InputStream in, byte[] b) throws IOException { + return readFully(in, b, 0, b.length); + } + + /** + * Same as the normal <tt>in.read(b, off, len)</tt>, but tries to ensure + * that the entire len number of bytes is read. + * <p> + * If the end of file is reached before any bytes are read, returns -1. If + * the end of the file is reached after some bytes are read, returns the + * number of bytes read. If the end of the file isn't reached before len + * bytes have been read, will return len bytes. + */ + public static int readFully(InputStream in, byte[] b, int off, int len) throws IOException { + int total = 0; + while (true) { + int got = in.read(b, off + total, len - total); + if (got < 0) { + return (total == 0) ? -1 : total; + } + total += got; + if (total == len) { + return total; + } + } + } - private static final POILogger logger = POILogFactory - .getLogger( IOUtils.class ); - - private IOUtils() { - // no instances of this class - } - - /** - * Reads all the data from the input stream, and returns the bytes read. - */ - public static byte[] toByteArray(InputStream stream) throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - byte[] buffer = new byte[4096]; - int read = 0; - while (read != -1) { - read = stream.read(buffer); - if (read > 0) { - baos.write(buffer, 0, read); - } - } - - return baos.toByteArray(); - } - - /** - * Returns an array (that shouldn't be written to!) of the - * ByteBuffer. Will be of the requested length, or possibly - * longer if that's easier. - */ - public static byte[] toByteArray(ByteBuffer buffer, int length) { - if(buffer.hasArray() && buffer.arrayOffset() == 0) { - // The backing array should work out fine for us - return buffer.array(); - } - - byte[] data = new byte[length]; - buffer.get(data); - return data; - } - - /** - * Helper method, just calls <tt>readFully(in, b, 0, b.length)</tt> - */ - public static int readFully(InputStream in, byte[] b) throws IOException { - return readFully(in, b, 0, b.length); - } - - /** - * Same as the normal <tt>in.read(b, off, len)</tt>, but tries to ensure - * that the entire len number of bytes is read. - * <p> - * If the end of file is reached before any bytes are read, returns -1. If - * the end of the file is reached after some bytes are read, returns the - * number of bytes read. If the end of the file isn't reached before len - * bytes have been read, will return len bytes. - */ - public static int readFully(InputStream in, byte[] b, int off, int len) throws IOException { - int total = 0; - while (true) { - int got = in.read(b, off + total, len - total); - if (got < 0) { - return (total == 0) ? -1 : total; - } - total += got; - if (total == len) { - return total; - } - } - } - - /** - * Same as the normal <tt>channel.read(b)</tt>, but tries to ensure - * that the entire len number of bytes is read. - * <p> - * If the end of file is reached before any bytes are read, returns -1. If - * the end of the file is reached after some bytes are read, returns the - * number of bytes read. If the end of the file isn't reached before len - * bytes have been read, will return len bytes. - */ - public static int readFully(ReadableByteChannel channel, ByteBuffer b) throws IOException { - int total = 0; - while (true) { - int got = channel.read(b); - if (got < 0) { - return (total == 0) ? -1 : total; - } - total += got; - if (total == b.capacity() || b.position() == b.capacity()) { - return total; - } - } - } - - /** - * Copies all the data from the given InputStream to the OutputStream. It - * leaves both streams open, so you will still need to close them once done. - */ - public static void copy(InputStream inp, OutputStream out) throws IOException { - byte[] buff = new byte[4096]; - int count; - while ((count = inp.read(buff)) != -1) { - if (count > 0) { - out.write(buff, 0, count); - } - } - } + /** + * Same as the normal <tt>channel.read(b)</tt>, but tries to ensure + * that the entire len number of bytes is read. + * <p> + * If the end of file is reached before any bytes are read, returns -1. If + * the end of the file is reached after some bytes are read, returns the + * number of bytes read. If the end of the file isn't reached before len + * bytes have been read, will return len bytes. + */ + public static int readFully(ReadableByteChannel channel, ByteBuffer b) throws IOException { + int total = 0; + while (true) { + int got = channel.read(b); + if (got < 0) { + return (total == 0) ? -1 : total; + } + total += got; + if (total == b.capacity() || b.position() == b.capacity()) { + return total; + } + } + } + + /** + * Copies all the data from the given InputStream to the OutputStream. It + * leaves both streams open, so you will still need to close them once done. + */ + public static void copy(InputStream inp, OutputStream out) throws IOException { + byte[] buff = new byte[4096]; + int count; + while ((count = inp.read(buff)) != -1) { + if (count > 0) { + out.write(buff, 0, count); + } + } + } public static long calculateChecksum(byte[] data) { Checksum sum = new CRC32(); @@ -150,14 +179,10 @@ public final class IOUtils { * @param closeable * resource to close */ - public static void closeQuietly( final Closeable closeable ) - { - try - { + public static void closeQuietly( final Closeable closeable ) { + try { closeable.close(); - } - catch ( Exception exc ) - { + } catch ( Exception exc ) { logger.log( POILogger.ERROR, "Unable to close resource: " + exc, exc ); } diff --git a/src/java/org/apache/poi/util/NullLogger.java b/src/java/org/apache/poi/util/NullLogger.java index 95c8c5d446..24643c8fde 100644 --- a/src/java/org/apache/poi/util/NullLogger.java +++ b/src/java/org/apache/poi/util/NullLogger.java @@ -27,12 +27,10 @@ package org.apache.poi.util; * @author Glen Stampoultzis (glens at apache.org) * @author Nicola Ken Barozzi (nicolaken at apache.org) */ -public class NullLogger extends POILogger -{ +public class NullLogger extends POILogger { @Override - public void initialize(final String cat) - { - //do nothing + public void initialize(final String cat){ + // do nothing } /** @@ -45,147 +43,7 @@ public class NullLogger extends POILogger @Override public void log(final int level, final Object obj1) { - //do nothing - } - - /** - * Check if a logger is enabled to log at the specified level - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - */ - - @Override - public boolean check(final int level) - { - return false; - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first object to place in the message - * @param obj2 second object to place in the message - */ - - @Override - public void log(final int level, final Object obj1, final Object obj2) - { - //do nothing - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third Object to place in the message - */ - - @Override - public void log(final int level, final Object obj1, final Object obj2, - final Object obj3) - { - //do nothing - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third Object to place in the message - * @param obj4 fourth Object to place in the message - */ - - @Override - public void log(final int level, final Object obj1, final Object obj2, - final Object obj3, final Object obj4) - { - //do nothing - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third Object to place in the message - * @param obj4 fourth Object to place in the message - * @param obj5 fifth Object to place in the message - */ - - @Override - public void log(final int level, final Object obj1, final Object obj2, - final Object obj3, final Object obj4, final Object obj5) - { - //do nothing - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third Object to place in the message - * @param obj4 fourth Object to place in the message - * @param obj5 fifth Object to place in the message - * @param obj6 sixth Object to place in the message - */ - - @Override - public void log(final int level, final Object obj1, final Object obj2, - final Object obj3, final Object obj4, final Object obj5, - final Object obj6) - { - //do nothing - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third Object to place in the message - * @param obj4 fourth Object to place in the message - * @param obj5 fifth Object to place in the message - * @param obj6 sixth Object to place in the message - * @param obj7 seventh Object to place in the message - */ - - @Override - public void log(final int level, final Object obj1, final Object obj2, - final Object obj3, final Object obj4, final Object obj5, - final Object obj6, final Object obj7) - { - //do nothing - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third Object to place in the message - * @param obj4 fourth Object to place in the message - * @param obj5 fifth Object to place in the message - * @param obj6 sixth Object to place in the message - * @param obj7 seventh Object to place in the message - * @param obj8 eighth Object to place in the message - */ - - @Override - public void log(final int level, final Object obj1, final Object obj2, - final Object obj3, final Object obj4, final Object obj5, - final Object obj6, final Object obj7, final Object obj8) - { - //do nothing + // do nothing } /** @@ -195,289 +53,19 @@ public class NullLogger extends POILogger * @param obj1 The object to log. This is converted to a string. * @param exception An exception to be logged */ - - @Override - public void log(final int level, final Object obj1, - final Throwable exception) - { - //do nothing - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param exception An exception to be logged - */ - - @Override - public void log(final int level, final Object obj1, final Object obj2, - final Throwable exception) - { - //do nothing + public void log(int level, Object obj1, final Throwable exception) { + // do nothing } + /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third object to place in the message - * @param exception An error message to be logged - */ - - @Override - public void log(final int level, final Object obj1, final Object obj2, - final Object obj3, final Throwable exception) - { - //do nothing - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third object to place in the message - * @param obj4 fourth object to place in the message - * @param exception An exception to be logged - */ - - @Override - public void log(final int level, final Object obj1, final Object obj2, - final Object obj3, final Object obj4, - final Throwable exception) - { - //do nothing - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third object to place in the message - * @param obj4 fourth object to place in the message - * @param obj5 fifth object to place in the message - * @param exception An exception to be logged - */ - - @Override - public void log(final int level, final Object obj1, final Object obj2, - final Object obj3, final Object obj4, final Object obj5, - final Throwable exception) - { - //do nothing - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third object to place in the message - * @param obj4 fourth object to place in the message - * @param obj5 fifth object to place in the message - * @param obj6 sixth object to place in the message - * @param exception An exception to be logged - */ - - @Override - public void log(final int level, final Object obj1, final Object obj2, - final Object obj3, final Object obj4, final Object obj5, - final Object obj6, final Throwable exception) - { - //do nothing - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third object to place in the message - * @param obj4 fourth object to place in the message - * @param obj5 fifth object to place in the message - * @param obj6 sixth object to place in the message - * @param obj7 seventh object to place in the message - * @param exception An exception to be logged - */ - - @Override - public void log(final int level, final Object obj1, final Object obj2, - final Object obj3, final Object obj4, final Object obj5, - final Object obj6, final Object obj7, - final Throwable exception) - { - //do nothing - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third object to place in the message - * @param obj4 fourth object to place in the message - * @param obj5 fifth object to place in the message - * @param obj6 sixth object to place in the message - * @param obj7 seventh object to place in the message - * @param obj8 eighth object to place in the message - * @param exception An exception to be logged - */ - - @Override - public void log(final int level, final Object obj1, final Object obj2, - final Object obj3, final Object obj4, final Object obj5, - final Object obj6, final Object obj7, final Object obj8, - final Throwable exception) - { - //do nothing - } - - /** - * Logs a formated message. The message itself may contain % - * characters as place holders. This routine will attempt to match - * the placeholder by looking at the type of parameter passed to - * obj1.<p> - * - * If the parameter is an array, it traverses the array first and - * matches parameters sequentially against the array items. - * Otherwise the parameters after <code>message</code> are matched - * in order.<p> - * - * If the place holder matches against a number it is printed as a - * whole number. This can be overridden by specifying a precision - * in the form %n.m where n is the padding for the whole part and - * m is the number of decimal places to display. n can be excluded - * if desired. n and m may not be more than 9.<p> - * - * If the last parameter (after flattening) is a Throwable it is - * logged specially. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param message The message to log. - * @param obj1 The first object to match against. - */ - - @Override - public void logFormatted(final int level, final String message, - final Object obj1) - { - //do nothing - } - - /** - * Logs a formated message. The message itself may contain % - * characters as place holders. This routine will attempt to match - * the placeholder by looking at the type of parameter passed to - * obj1.<p> - * - * If the parameter is an array, it traverses the array first and - * matches parameters sequentially against the array items. - * Otherwise the parameters after <code>message</code> are matched - * in order.<p> - * - * If the place holder matches against a number it is printed as a - * whole number. This can be overridden by specifying a precision - * in the form %n.m where n is the padding for the whole part and - * m is the number of decimal places to display. n can be excluded - * if desired. n and m may not be more than 9.<p> - * - * If the last parameter (after flattening) is a Throwable it is - * logged specially. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param message The message to log. - * @param obj1 The first object to match against. - * @param obj2 The second object to match against. - */ - - @Override - public void logFormatted(final int level, final String message, - final Object obj1, final Object obj2) - { - //do nothing - } - - /** - * Logs a formated message. The message itself may contain % - * characters as place holders. This routine will attempt to match - * the placeholder by looking at the type of parameter passed to - * obj1.<p> - * - * If the parameter is an array, it traverses the array first and - * matches parameters sequentially against the array items. - * Otherwise the parameters after <code>message</code> are matched - * in order.<p> - * - * If the place holder matches against a number it is printed as a - * whole number. This can be overridden by specifying a precision - * in the form %n.m where n is the padding for the whole part and - * m is the number of decimal places to display. n can be excluded - * if desired. n and m may not be more than 9.<p> - * - * If the last parameter (after flattening) is a Throwable it is - * logged specially. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param message The message to log. - * @param obj1 The first object to match against. - * @param obj2 The second object to match against. - * @param obj3 The third object to match against. - */ - - @Override - public void logFormatted(final int level, final String message, - final Object obj1, final Object obj2, - final Object obj3) - { - //do nothing - } - - /** - * Logs a formated message. The message itself may contain % - * characters as place holders. This routine will attempt to match - * the placeholder by looking at the type of parameter passed to - * obj1.<p> - * - * If the parameter is an array, it traverses the array first and - * matches parameters sequentially against the array items. - * Otherwise the parameters after <code>message</code> are matched - * in order.<p> - * - * If the place holder matches against a number it is printed as a - * whole number. This can be overridden by specifying a precision - * in the form %n.m where n is the padding for the whole part and - * m is the number of decimal places to display. n can be excluded - * if desired. n and m may not be more than 9.<p> - * - * If the last parameter (after flattening) is a Throwable it is - * logged specially. + * Check if a logger is enabled to log at the specified level * * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param message The message to log. - * @param obj1 The first object to match against. - * @param obj2 The second object to match against. - * @param obj3 The third object to match against. - * @param obj4 The forth object to match against. */ - @Override - public void logFormatted(final int level, final String message, - final Object obj1, final Object obj2, - final Object obj3, final Object obj4) - { - //do nothing + public boolean check(final int level) { + return false; } - } diff --git a/src/java/org/apache/poi/util/POILogFactory.java b/src/java/org/apache/poi/util/POILogFactory.java index 641949c391..7af73e3a87 100644 --- a/src/java/org/apache/poi/util/POILogFactory.java +++ b/src/java/org/apache/poi/util/POILogFactory.java @@ -15,7 +15,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - + package org.apache.poi.util; @@ -30,20 +30,18 @@ import java.util.Map; * @author Marc Johnson (mjohnson at apache dot org) * @author Nicola Ken Barozzi (nicolaken at apache.org) */ - -public class POILogFactory -{ - +@Internal +public final class POILogFactory { /** * Map of POILogger instances, with classes as keys */ - private static Map<String,POILogger> _loggers = new HashMap<String,POILogger>();; + private static Map<String,POILogger> _loggers = new HashMap<String,POILogger>(); /** * A common instance of NullLogger, as it does nothing * we only need the one */ - private static POILogger _nullLogger = new NullLogger(); + private static final POILogger _nullLogger = new NullLogger(); /** * The name of the class to use. Initialised the * first time we need it @@ -53,9 +51,7 @@ public class POILogFactory /** * Construct a POILogFactory. */ - private POILogFactory() - { - } + private POILogFactory() {} /** * Get a logger, based on a class name @@ -64,12 +60,10 @@ public class POILogFactory * * @return a POILogger for the specified class */ - - public static POILogger getLogger(final Class<?> theclass) - { + public static POILogger getLogger(final Class<?> theclass) { return getLogger(theclass.getName()); } - + /** * Get a logger, based on a String * @@ -77,11 +71,9 @@ public class POILogFactory * * @return a POILogger for the specified class */ - - public static POILogger getLogger(final String cat) - { + public static POILogger getLogger(final String cat) { POILogger logger = null; - + // If we haven't found out what logger to use yet, // then do so now // Don't look it up until we're first asked, so @@ -91,40 +83,40 @@ public class POILogFactory try { _loggerClassName = System.getProperty("org.apache.poi.util.POILogger"); } catch(Exception e) {} - + // Use the default logger if none specified, // or none could be fetched if(_loggerClassName == null) { - _loggerClassName = _nullLogger.getClass().getName(); + _loggerClassName = _nullLogger.getClass().getName(); } } - + // Short circuit for the null logger, which // ignores all categories if(_loggerClassName.equals(_nullLogger.getClass().getName())) { return _nullLogger; } - + // Fetch the right logger for them, creating - // it if that's required - if (_loggers.containsKey(cat)) { - logger = _loggers.get(cat); - } else { + // it if that's required + logger = _loggers.get(cat); + if (logger == null) { try { - @SuppressWarnings("unchecked") - Class<? extends POILogger> loggerClass = - (Class<? extends POILogger>)Class.forName(_loggerClassName); - logger = loggerClass.newInstance(); - logger.initialize(cat); + @SuppressWarnings("unchecked") + Class<? extends POILogger> loggerClass = + (Class<? extends POILogger>) Class.forName(_loggerClassName); + logger = loggerClass.newInstance(); + logger.initialize(cat); } catch(Exception e) { - // Give up and use the null logger - logger = _nullLogger; + // Give up and use the null logger + logger = _nullLogger; + _loggerClassName = _nullLogger.getClass().getName(); } - + // Save for next time _loggers.put(cat, logger); } return logger; } -} // end public class POILogFactory
\ No newline at end of file +}
\ No newline at end of file diff --git a/src/java/org/apache/poi/util/POILogger.java b/src/java/org/apache/poi/util/POILogger.java index 4088ec290c..d892366e7e 100644 --- a/src/java/org/apache/poi/util/POILogger.java +++ b/src/java/org/apache/poi/util/POILogger.java @@ -30,6 +30,7 @@ import java.util.List; * @author Glen Stampoultzis (glens at apache.org) * @author Nicola Ken Barozzi (nicolaken at apache.org) */ +@Internal public abstract class POILogger { public static final int DEBUG = 1; @@ -49,7 +50,7 @@ public abstract class POILogger { * package. You need a POILogger? Go to the POILogFactory for one */ POILogger() { - // no fields to initialise + // no fields to initialize } abstract public void initialize(String cat); @@ -60,7 +61,7 @@ public abstract class POILogger { * @param level One of DEBUG, INFO, WARN, ERROR, FATAL * @param obj1 The object to log. This is converted to a string. */ - abstract public void log(int level, Object obj1); + abstract protected void log(int level, Object obj1); /** * Log a message @@ -69,8 +70,7 @@ public abstract class POILogger { * @param obj1 The object to log. This is converted to a string. * @param exception An exception to be logged */ - abstract public void log(int level, Object obj1, - final Throwable exception); + abstract protected void log(int level, Object obj1, final Throwable exception); /** @@ -82,344 +82,32 @@ public abstract class POILogger { /** * Log a message. Lazily appends Object parameters together. + * If the last parameter is a {@link Throwable} it is logged specially. * * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first object to place in the message - * @param obj2 second object to place in the message + * @param objs the objects to place in the message */ - public void log(int level, Object obj1, Object obj2) - { - if (check(level)) - { - log(level, new StringBuffer(32).append(obj1).append(obj2)); - } - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third Object to place in the message - */ - public void log(int level, Object obj1, Object obj2, - Object obj3) - { - - - if (check(level)) - { - log(level, - new StringBuffer(48).append(obj1).append(obj2) - .append(obj3)); - } - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third Object to place in the message - * @param obj4 fourth Object to place in the message - */ - public void log(int level, Object obj1, Object obj2, - Object obj3, Object obj4) - { - - - if (check(level)) - { - log(level, - new StringBuffer(64).append(obj1).append(obj2) - .append(obj3).append(obj4)); - } - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third Object to place in the message - * @param obj4 fourth Object to place in the message - * @param obj5 fifth Object to place in the message - */ - public void log(int level, Object obj1, Object obj2, - Object obj3, Object obj4, Object obj5) - { - - - if (check(level)) - { - log(level, - new StringBuffer(80).append(obj1).append(obj2) - .append(obj3).append(obj4).append(obj5)); - } - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third Object to place in the message - * @param obj4 fourth Object to place in the message - * @param obj5 fifth Object to place in the message - * @param obj6 sixth Object to place in the message - */ - public void log(int level, Object obj1, Object obj2, - Object obj3, Object obj4, Object obj5, - Object obj6) - { - - - if (check(level)) - { - log(level , - new StringBuffer(96).append(obj1).append(obj2) - .append(obj3).append(obj4).append(obj5).append(obj6)); - } - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third Object to place in the message - * @param obj4 fourth Object to place in the message - * @param obj5 fifth Object to place in the message - * @param obj6 sixth Object to place in the message - * @param obj7 seventh Object to place in the message - */ - public void log(int level, Object obj1, Object obj2, - Object obj3, Object obj4, Object obj5, - Object obj6, Object obj7) - { - - - if (check(level)) - { - log(level, - new StringBuffer(112).append(obj1).append(obj2) - .append(obj3).append(obj4).append(obj5).append(obj6) - .append(obj7)); - } - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third Object to place in the message - * @param obj4 fourth Object to place in the message - * @param obj5 fifth Object to place in the message - * @param obj6 sixth Object to place in the message - * @param obj7 seventh Object to place in the message - * @param obj8 eighth Object to place in the message - */ - public void log(int level, Object obj1, Object obj2, - Object obj3, Object obj4, Object obj5, - Object obj6, Object obj7, Object obj8) - { - - - if (check(level)) - { - log(level, - new StringBuffer(128).append(obj1).append(obj2) - .append(obj3).append(obj4).append(obj5).append(obj6) - .append(obj7).append(obj8)); - } - } - - /** - * Log an exception, without a message - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param exception An exception to be logged - */ - public void log(int level, final Throwable exception) - { - log(level, null, exception); - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param exception An exception to be logged - */ - public void log(int level, Object obj1, Object obj2, - final Throwable exception) - { - - - if (check(level)) - { - log(level, new StringBuffer(32).append(obj1).append(obj2), - exception); - } - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third object to place in the message - * @param exception An error message to be logged - */ - public void log(int level, Object obj1, Object obj2, - Object obj3, final Throwable exception) - { - - - if (check(level)) - { - log(level, new StringBuffer(48).append(obj1).append(obj2) - .append(obj3), exception); - } - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third object to place in the message - * @param obj4 fourth object to place in the message - * @param exception An exception to be logged - */ - public void log(int level, Object obj1, Object obj2, - Object obj3, Object obj4, - final Throwable exception) - { - - - if (check(level)) - { - log(level, new StringBuffer(64).append(obj1).append(obj2) - .append(obj3).append(obj4), exception); - } - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third object to place in the message - * @param obj4 fourth object to place in the message - * @param obj5 fifth object to place in the message - * @param exception An exception to be logged - */ - public void log(int level, Object obj1, Object obj2, - Object obj3, Object obj4, Object obj5, - final Throwable exception) - { - - - if (check(level)) - { - log(level, new StringBuffer(80).append(obj1).append(obj2) - .append(obj3).append(obj4).append(obj5), exception); - } - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third object to place in the message - * @param obj4 fourth object to place in the message - * @param obj5 fifth object to place in the message - * @param obj6 sixth object to place in the message - * @param exception An exception to be logged - */ - public void log(int level, Object obj1, Object obj2, - Object obj3, Object obj4, Object obj5, - Object obj6, final Throwable exception) - { - - - if (check(level)) - { - log(level , new StringBuffer(96).append(obj1) - .append(obj2).append(obj3).append(obj4).append(obj5) - .append(obj6), exception); - } - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third object to place in the message - * @param obj4 fourth object to place in the message - * @param obj5 fifth object to place in the message - * @param obj6 sixth object to place in the message - * @param obj7 seventh object to place in the message - * @param exception An exception to be logged - */ - public void log(int level, Object obj1, Object obj2, - Object obj3, Object obj4, Object obj5, - Object obj6, Object obj7, - final Throwable exception) - { - - - if (check(level)) - { - log(level, new StringBuffer(112).append(obj1).append(obj2) - .append(obj3).append(obj4).append(obj5).append(obj6) - .append(obj7), exception); + public void log(int level, Object... objs) { + if (!check(level)) return; + StringBuilder sb = new StringBuilder(32); + Throwable lastEx = null; + for (int i=0; i<objs.length; i++) { + if (i == objs.length-1 && objs[i] instanceof Throwable) { + lastEx = (Throwable)objs[i]; + } else { + sb.append(objs[i]); + } } - } - - /** - * Log a message. Lazily appends Object parameters together. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param obj1 first Object to place in the message - * @param obj2 second Object to place in the message - * @param obj3 third object to place in the message - * @param obj4 fourth object to place in the message - * @param obj5 fifth object to place in the message - * @param obj6 sixth object to place in the message - * @param obj7 seventh object to place in the message - * @param obj8 eighth object to place in the message - * @param exception An exception to be logged - */ - public void log(int level, Object obj1, Object obj2, - Object obj3, Object obj4, Object obj5, - Object obj6, Object obj7, Object obj8, - final Throwable exception) - { - - - if (check(level)) - { - log(level, new StringBuffer(128).append(obj1).append(obj2) - .append(obj3).append(obj4).append(obj5).append(obj6) - .append(obj7).append(obj8), exception); + + String msg = sb.toString(); + msg = msg.replaceAll("[\r\n]+", " "); // log forging escape + + // somehow this ambiguity works and doesn't lead to a loop, + // but it's confusing ... + if (lastEx == null) { + log(level, msg); + } else { + log(level, msg, lastEx); } } @@ -445,239 +133,67 @@ public abstract class POILogger { * * @param level One of DEBUG, INFO, WARN, ERROR, FATAL * @param message The message to log. - * @param obj1 The first object to match against. + * @param unflatParams The objects to match against. */ - public void logFormatted(int level, String message, - Object obj1) - { - commonLogFormatted(level, message, new Object[] - { - obj1 - }); - } + public void logFormatted(int level, String message, Object... unflatParams) { + if (!check(level)) return; + Object[] params = flattenArrays(unflatParams); + String msg = StringUtil.format(message, params); + msg = msg.replaceAll("[\r\n]+", " "); // log forging escape - /** - * Logs a formated message. The message itself may contain % - * characters as place holders. This routine will attempt to match - * the placeholder by looking at the type of parameter passed to - * obj1.<p> - * - * If the parameter is an array, it traverses the array first and - * matches parameters sequentially against the array items. - * Otherwise the parameters after <code>message</code> are matched - * in order.<p> - * - * If the place holder matches against a number it is printed as a - * whole number. This can be overridden by specifying a precision - * in the form %n.m where n is the padding for the whole part and - * m is the number of decimal places to display. n can be excluded - * if desired. n and m may not be more than 9.<p> - * - * If the last parameter (after flattening) is a Throwable it is - * logged specially. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param message The message to log. - * @param obj1 The first object to match against. - * @param obj2 The second object to match against. - */ - public void logFormatted(int level, String message, - Object obj1, Object obj2) - { - commonLogFormatted(level, message, new Object[] - { - obj1, obj2 - }); - } - - /** - * Logs a formated message. The message itself may contain % - * characters as place holders. This routine will attempt to match - * the placeholder by looking at the type of parameter passed to - * obj1.<p> - * - * If the parameter is an array, it traverses the array first and - * matches parameters sequentially against the array items. - * Otherwise the parameters after <code>message</code> are matched - * in order.<p> - * - * If the place holder matches against a number it is printed as a - * whole number. This can be overridden by specifying a precision - * in the form %n.m where n is the padding for the whole part and - * m is the number of decimal places to display. n can be excluded - * if desired. n and m may not be more than 9.<p> - * - * If the last parameter (after flattening) is a Throwable it is - * logged specially. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param message The message to log. - * @param obj1 The first object to match against. - * @param obj2 The second object to match against. - * @param obj3 The third object to match against. - */ - public void logFormatted(int level, String message, - Object obj1, Object obj2, - Object obj3) - { - commonLogFormatted(level, message, new Object[] - { - obj1, obj2, obj3 - }); - } - - /** - * Logs a formated message. The message itself may contain % - * characters as place holders. This routine will attempt to match - * the placeholder by looking at the type of parameter passed to - * obj1.<p> - * - * If the parameter is an array, it traverses the array first and - * matches parameters sequentially against the array items. - * Otherwise the parameters after <code>message</code> are matched - * in order.<p> - * - * If the place holder matches against a number it is printed as a - * whole number. This can be overridden by specifying a precision - * in the form %n.m where n is the padding for the whole part and - * m is the number of decimal places to display. n can be excluded - * if desired. n and m may not be more than 9.<p> - * - * If the last parameter (after flattening) is a Throwable it is - * logged specially. - * - * @param level One of DEBUG, INFO, WARN, ERROR, FATAL - * @param message The message to log. - * @param obj1 The first object to match against. - * @param obj2 The second object to match against. - * @param obj3 The third object to match against. - * @param obj4 The forth object to match against. - */ - public void logFormatted(int level, String message, - Object obj1, Object obj2, - Object obj3, Object obj4) - { - commonLogFormatted(level, message, new Object[] - { - obj1, obj2, obj3, obj4 - }); - } - - private void commonLogFormatted(int level, String message, - Object [] unflatParams) - { - - - if (check(level)) - { - Object[] params = flattenArrays(unflatParams); - - if (params[ params.length - 1 ] instanceof Throwable) - { - log(level, StringUtil.format(message, params), - ( Throwable ) params[ params.length - 1 ]); - } - else - { - log(level, StringUtil.format(message, params)); - } + if (params.length > 0 && params[params.length-1] instanceof Throwable) { + log(level, msg, (Throwable)params[params.length-1]); + } else { + log(level, msg); } } /** - * Flattens any contained objects. Only tranverses one level deep. + * Flattens any contained objects. Only traverses one level deep. */ - private Object [] flattenArrays(Object [] objects) - { + private Object[] flattenArrays(Object... unflatParams) { List<Object> results = new ArrayList<Object>(); - - for (int i = 0; i < objects.length; i++) - { - results.addAll(objectToObjectArray(objects[ i ])); + for (Object obj : unflatParams) { + flattenObject(results, obj); } - return results.toArray(new Object[ results.size() ]); + return results.toArray(new Object[results.size()]); } - private List<Object> objectToObjectArray(Object object) - { - List<Object> results = new ArrayList<Object>(); - - if (object instanceof byte []) - { - byte[] array = ( byte [] ) object; - - for (int j = 0; j < array.length; j++) - { - results.add(Byte.valueOf(array[ j ])); + private void flattenObject(List<Object> results, Object object) { + if (object instanceof byte[]) { + for (byte b : (byte[])object) { + results.add(Byte.valueOf(b)); } - } - if (object instanceof char []) - { - char[] array = ( char [] ) object; - - for (int j = 0; j < array.length; j++) - { - results.add(Character.valueOf(array[ j ])); + } else if (object instanceof char[]) { + for (char c : (char[])object) { + results.add(Character.valueOf(c)); } - } - else if (object instanceof short []) - { - short[] array = ( short [] ) object; - - for (int j = 0; j < array.length; j++) - { - results.add(Short.valueOf(array[ j ])); + } else if (object instanceof short[]) { + for (short s : (short[])object) { + results.add(Short.valueOf(s)); } - } - else if (object instanceof int []) - { - int[] array = ( int [] ) object; - - for (int j = 0; j < array.length; j++) - { - results.add(Integer.valueOf(array[ j ])); + } else if (object instanceof int[]) { + for (int i : (int[])object) { + results.add(Integer.valueOf(i)); } - } - else if (object instanceof long []) - { - long[] array = ( long [] ) object; - - for (int j = 0; j < array.length; j++) - { - results.add(Long.valueOf(array[ j ])); + } else if (object instanceof long[]) { + for (long l : (long[])object) { + results.add(Long.valueOf(l)); } - } - else if (object instanceof float []) - { - float[] array = ( float [] ) object; - - for (int j = 0; j < array.length; j++) - { - results.add(new Float(array[ j ])); + } else if (object instanceof float[]) { + for (float f : (float[])object) { + results.add(Float.valueOf(f)); } - } - else if (object instanceof double []) - { - double[] array = ( double [] ) object; - - for (int j = 0; j < array.length; j++) - { - results.add(new Double(array[ j ])); + } else if (object instanceof double[]) { + for (double d : (double[])object) { + results.add(Double.valueOf(d)); } - } - else if (object instanceof Object []) - { - Object[] array = ( Object [] ) object; - - for (int j = 0; j < array.length; j++) - { - results.add(array[ j ]); + } else if (object instanceof Object[]) { + for (Object o : (Object[])object) { + results.add(o); } - } - else - { + } else { results.add(object); } - return results; } } diff --git a/src/java/org/apache/poi/util/StringUtil.java b/src/java/org/apache/poi/util/StringUtil.java index 99880f500e..bd417961ea 100644 --- a/src/java/org/apache/poi/util/StringUtil.java +++ b/src/java/org/apache/poi/util/StringUtil.java @@ -22,6 +22,7 @@ import java.text.FieldPosition; import java.text.NumberFormat; import java.util.HashMap; import java.util.Iterator; +import java.util.Locale; import java.util.Map; import org.apache.poi.hssf.record.RecordInputStream; @@ -310,7 +311,7 @@ public class StringUtil { Number number, String formatting, StringBuffer outputTo) { - NumberFormat numberFormat = NumberFormat.getInstance(); + NumberFormat numberFormat = NumberFormat.getInstance(Locale.US); if ((0 < formatting.length()) && Character.isDigit(formatting.charAt(0))) { numberFormat.setMinimumIntegerDigits( diff --git a/src/java/org/apache/poi/wp/usermodel/CharacterRun.java b/src/java/org/apache/poi/wp/usermodel/CharacterRun.java new file mode 100644 index 0000000000..34165463aa --- /dev/null +++ b/src/java/org/apache/poi/wp/usermodel/CharacterRun.java @@ -0,0 +1,99 @@ +/* ==================================================================== + 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.wp.usermodel; + +/** + * This class represents a run of text that share common properties. + */ +public interface CharacterRun { + public boolean isBold(); + public void setBold(boolean bold); + + public boolean isItalic(); + public void setItalic(boolean italic); + + public boolean isSmallCaps(); + public void setSmallCaps(boolean smallCaps); + + public boolean isCapitalized(); + public void setCapitalized(boolean caps); + + public boolean isStrikeThrough(); + public void setStrikeThrough(boolean strike); + public boolean isDoubleStrikeThrough(); + public void setDoubleStrikethrough(boolean dstrike); + + public boolean isShadowed(); + public void setShadow(boolean shadow); + + public boolean isEmbossed(); + public void setEmbossed(boolean emboss); + + public boolean isImprinted(); + public void setImprinted(boolean imprint); + + public int getFontSize(); + public void setFontSize(int halfPoints); + + public int getCharacterSpacing(); + public void setCharacterSpacing(int twips); + + public int getKerning(); + public void setKerning(int kern); + + public String getFontName(); + + /** + * @return The text of the run, including any tabs/spaces/etc + */ + public String text(); + + // HWPF uses indexes, XWPF special +// public int getUnderlineCode(); +// public void setUnderlineCode(int kul); + + // HWPF uses indexes, XWPF special vertical alignments +// public short getSubSuperScriptIndex(); +// public void setSubSuperScriptIndex(short iss); + + // HWPF uses indexes, XWPF special vertical alignments +// public int getVerticalOffset(); +// public void setVerticalOffset(int hpsPos); + + // HWPF has colour indexes, XWPF colour names +// public int getColor(); +// public void setColor(int color); + + // TODO Review these, and add to XWPFRun if possible +/* + public boolean isFldVanished(); + public void setFldVanish(boolean fldVanish); + + public boolean isOutlined(); + public void setOutline(boolean outlined); + + public boolean isVanished(); + public void setVanished(boolean vanish); + + public boolean isMarkedDeleted(); + public void markDeleted(boolean mark); + + public boolean isMarkedInserted(); + public void markInserted(boolean mark); +*/ +} diff --git a/src/java/org/apache/poi/wp/usermodel/Paragraph.java b/src/java/org/apache/poi/wp/usermodel/Paragraph.java new file mode 100644 index 0000000000..be488a2ef8 --- /dev/null +++ b/src/java/org/apache/poi/wp/usermodel/Paragraph.java @@ -0,0 +1,145 @@ +/* ==================================================================== + 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.wp.usermodel; + +/** + * This class represents a paragraph, made up of one or more + * runs of text. + */ +public interface Paragraph { + // Tables work very differently between the formats +// public boolean isInTable(); +// public boolean isTableRowEnd(); +// public int getTableLevel(); + + // TODO Implement justifaction in XWPF +// public int getJustification(); +// public void setJustification(byte jc); + + // TODO Expose the different page break related things, + // XWPF currently doesn't have the full set +/* + public boolean keepOnPage(); + public void setKeepOnPage(boolean fKeep); + + public boolean keepWithNext(); + public void setKeepWithNext(boolean fKeepFollow); + + public boolean pageBreakBefore(); + public void setPageBreakBefore(boolean fPageBreak); + + public boolean isSideBySide(); + public void setSideBySide(boolean fSideBySide); +*/ + + public int getIndentFromRight(); + public void setIndentFromRight(int dxaRight); + + public int getIndentFromLeft(); + public void setIndentFromLeft(int dxaLeft); + + public int getFirstLineIndent(); + public void setFirstLineIndent(int first); + +/* + public boolean isLineNotNumbered(); + public void setLineNotNumbered(boolean fNoLnn); + + public boolean isAutoHyphenated(); + public void setAutoHyphenated(boolean autoHyph); + + public boolean isWidowControlled(); + public void setWidowControl(boolean widowControl); + + public int getSpacingBefore(); + public void setSpacingBefore(int before); + + public int getSpacingAfter(); + public void setSpacingAfter(int after); +*/ + + // public LineSpacingDescriptor getLineSpacing(); + // public void setLineSpacing(LineSpacingDescriptor lspd); + + public int getFontAlignment(); + public void setFontAlignment(int align); + + public boolean isWordWrapped(); + public void setWordWrapped(boolean wrap); + +/* + public boolean isVertical(); + public void setVertical(boolean vertical); + + public boolean isBackward(); + public void setBackward(boolean bward); +*/ + + // TODO Make the HWPF and XWPF interface wrappers compatible for these +/* + public BorderCode getTopBorder(); + public void setTopBorder(BorderCode top); + public BorderCode getLeftBorder(); + public void setLeftBorder(BorderCode left); + public BorderCode getBottomBorder(); + public void setBottomBorder(BorderCode bottom); + public BorderCode getRightBorder(); + public void setRightBorder(BorderCode right); + public BorderCode getBarBorder(); + public void setBarBorder(BorderCode bar); + + public ShadingDescriptor getShading(); + public void setShading(ShadingDescriptor shd); +*/ + + /** + * Returns the ilfo, an index to the document's hpllfo, which + * describes the automatic number formatting of the paragraph. + * A value of zero means it isn't numbered. + */ +// public int getIlfo(); + + /** + * Returns the multi-level indent for the paragraph. Will be + * zero for non-list paragraphs, and the first level of any + * list. Subsequent levels in hold values 1-8. + */ +// public int getIlvl(); + + /** + * Returns the heading level (1-8), or 9 if the paragraph + * isn't in a heading style. + */ +// public int getLvl(); + + /** + * Returns number of tabs stops defined for paragraph. Must be >= 0 and <= + * 64. + * + * @return number of tabs stops defined for paragraph. Must be >= 0 and <= + * 64 + */ +// public int getTabStopsNumber(); + + /** + * Returns array of positions of itbdMac tab stops + * + * @return array of positions of itbdMac tab stops + */ +// public int[] getTabStopsPositions(); +} |